fix(epic3): выводить Tools-сигнал из клиентской проекции tools/list (Story 3.5, FR-14)
CI / UI Checks (pull_request) Successful in 8s
CI / Rust Checks (pull_request) Successful in 10m49s
CI / Rust Feature Validation (pull_request) Skipped
CI / Frontend E2E (pull_request) Skipped
CI / Community Image Smoke (pull_request) Skipped
CI / Required Checks (pull_request) Successful in 1s
CI / Deploy (pull_request) Skipped
Community Release / release (push) Successful in 25m35s

QA F1: CatalogFingerprint сравнивал только Tool-bindings, а tools/list
строится из catalog_tool_definitions, которая ещё зависит от
tool_selection_policy (mode, groups, search.max_results); в Search-режиме
отдаваемый список вообще не зависит от bindings. Из-за этого commit,
меняющий только политику, не порождал notifications/tools/list_changed
(клиент оставался со stale-каталогом), а binding-only commit в Search
порождал ложный сигнал.

Теперь Tools-часть отпечатка — канонизированные определения, которые
реально отдаёт tools/list (отсортированы, чтобы порядок чтения не был
ложным изменением): сигнал есть ровно тогда, когда меняется видимая
клиенту проекция.

ATDD: новый сценарий на обеих ревизиях — policy-only commit (Direct ->
Search) даёт ровно один Tools-кадр и авторитетный tools/list с
search_tools/call_tool, а последующий binding-only commit в Search-режиме
не сигналит. Юнит-оракулы переведены на реальную проекцию: policy-only
change, невидимое поле политики, version bump с идентичным определением и
binding change в Search-режиме — silent.
This commit is contained in:
bsodfather committed 2026-10-26 17:22:07 +00:00
1 parent a0365bb80b
commit 44774883a0
4 files changed
+483 -110

No files matched your search

@@ -8,7 +8,8 @@
//!
//! Shape of the chosen seam (ARC decision, kanban t_c12863fb): a **stream-local watcher**. One open
//! notification stream owns one bounded periodic read of the published Agent catalog the stream is
//! scoped to; a change of the visible Resource/Prompt/Tool binding projection produces the revision's
//! scoped to; a change of the visible Resource/Prompt/Tool projection of that snapshot (the Resource
//! and Prompt bindings plus the exact Tool definitions `tools/list` serves) produces the revision's
//! list-change notification. There is no post-commit hook, no cross-process bus and no durable
//! queue: the committed catalog is the source of truth, so a signal can never be produced before its
//! commit, and a failed read can never roll the commit back — it only skips that tick and stays
@@ -188,10 +189,13 @@ fn acknowledged_filter_wire(accepted: Signals) -> Value {
///
/// The projection is derived from the same committed catalog read that already feeds
/// `resources/list`, `resources/templates/list`, `prompts/list`, `prompts/get` and `tools/list`: the
/// exact Resource, Prompt and Tool bindings of the published Agent snapshot, in deterministic
/// binding order. `catalog_revision` alone is *not* the comparison key — a commit that only changes
/// Tools must not produce a Resource or Prompt signal, and vice versa — so the three binding vectors
/// are compared on their own.
/// exact Resource and Prompt bindings of the published Agent snapshot, in deterministic binding
/// order, and the exact Tool definitions that `tools/list` would serve. The Tool part is taken from
/// [`crate::manifest::catalog_tool_definitions`] rather than from the bindings, because that is the
/// projection the client sees: it also depends on the Tool selection policy (mode, groups, search
/// settings), and in `Search` mode it does not depend on the bindings at all. `catalog_revision`
/// alone is *not* the comparison key — a commit that only changes Tools must not produce a Resource
/// or Prompt signal, and vice versa — so the three projections are compared on their own.
///
/// shortcut: a Resource revocation invalidates a bound publication without a new Agent snapshot, so
/// it does not change this projection and produces no list-change signal; the revocation gate at
@@ -201,62 +205,40 @@ fn acknowledged_filter_wire(accepted: Signals) -> Value {
pub(crate) struct CatalogFingerprint {
resources: Vec<(String, u32)>,
prompts: Vec<(String, u32)>,
/// Tool name, published Operation version and the visible title/description of the binding.
tools: Vec<(String, u32, String, String)>,
/// Canonical JSON of every definition `tools/list` serves, sorted so a re-ordered read is not a
/// false change.
tools: Vec<String>,
}
impl CatalogFingerprint {
pub(crate) fn of(catalog: &PublishedAgentCatalog) -> Self {
// The bound Tool is the published Operation snapshot of the binding, so its own version is
// part of the visible `tools/list` projection, next to the binding's own title/description.
Self::from_parts(
catalog
.resources
.iter()
.map(|binding| (binding.resource_id.as_str(), binding.resource_version)),
catalog
.prompts
.iter()
.map(|binding| (binding.prompt_id.as_str(), binding.prompt_version)),
catalog.tools.iter().map(|binding| {
(
binding.tool_name.as_str(),
binding.operation.version,
binding.tool_title.as_str(),
binding.tool_description.as_str(),
)
}),
)
}
fn from_parts<'a>(
resources: impl Iterator<Item = (&'a str, u32)>,
prompts: impl Iterator<Item = (&'a str, u32)>,
tools: impl Iterator<Item = (&'a str, u32, &'a str, &'a str)>,
) -> Self {
fn sorted<T: Ord>(values: impl Iterator<Item = T>) -> Vec<T> {
let mut sorted = values.collect::<Vec<_>>();
sorted.sort();
sorted.sort_unstable();
sorted
}
fn owned<'a>(values: impl Iterator<Item = (&'a str, u32)>) -> Vec<(String, u32)> {
sorted(values.map(|(name, version)| (name.to_owned(), version)))
}
Self {
resources: owned(resources),
prompts: owned(prompts),
tools: sorted(tools.map(|(name, version, title, description)| {
resources: sorted(catalog.resources.iter().map(|binding| {
(
name.to_owned(),
version,
title.to_owned(),
description.to_owned(),
binding.resource_id.as_str().to_owned(),
binding.resource_version,
)
})),
prompts: sorted(catalog.prompts.iter().map(|binding| {
(
binding.prompt_id.as_str().to_owned(),
binding.prompt_version,
)
})),
tools: sorted(
crate::manifest::catalog_tool_definitions(catalog)
.into_iter()
.map(|definition| definition.to_string()),
),
}
}
/// The list-change types whose visible binding projection differs between `previous` and `self`.
/// The list-change types whose visible projection differs between `previous` and `self`.
pub(crate) fn changes_since(&self, previous: &Self) -> Signals {
Signals {
resources: self.resources != previous.resources,