Skip to content

Drop ambiguous prompt names instead of failing aggregation - #6099

Merged
JAORMX merged 1 commit into
mainfrom
aggregator-prompt-ambiguity-followup
Jul 28, 2026
Merged

JAORMX merged 1 commit into
mainfrom
aggregator-prompt-ambiguity-followup

Conversation

@JAORMX

@JAORMX JAORMX commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Summary

Addresses post-merge review feedback on #6075 (discussion_r3665086460), which landed ~12 minutes before that PR merged and was never applied.

  • The hard error's blast radius was wildly out of proportion to its trigger. ErrUnresolvedConflicts from resolvePromptConflicts propagated out of ResolveConflicts before the already-computed tools, resources and templates were ever returned, so one ambiguous prompt name failed the entire aggregated view: tools/list, resources/list, resource-templates/list, prompts/list, Discover's presence flags, and backend visibility through authorizedBackends. Errors are never cached, so while the condition persisted every request re-swept every backend and failed again. And the condition needs no conflict-resolution config to reach — an unlucky combination of operator-chosen workload names and backend-chosen prompt names is enough (backend b1 prompt x_y and backend b1_x prompt y both compose to b1_x_y). Now every prompt claiming an ambiguous name is dropped and the collision is logged at ERROR; aggregation succeeds and the rest of the group keeps serving.
  • Dropping all claimants, not just the loser, is the load-bearing part. The tool precedent (prefix_resolver.go) drops only the loser, which does not work here: the survivor would inherit the ambiguous name and with it any policy written for the prompt it collided with, since Cedar's resource identity is Prompt::"<advertised name>" and nothing else. With the name advertised by nobody, every permit and forbid on it is vacuous and nothing is reachable under an ambiguous identity.
  • The header docstring overclaimed its own invariant. It asserted a blanket "the advertised name never moves". That holds per (backendID, name) pair, but not for a shared string: under priority, a permit(... resource == Prompt::"review") written while b1 owned that name silently begins authorizing b2's different prompt once a higher-ranked b2 deploys, with no config edit. The invariant is now scoped to the pair and the permit-redirection caveat is stated explicitly. forbid still fails closed, because the loser is dropped rather than aliased.
  • The drop-not-re-prefix decision is now protected in the comment. The obvious future "improvement" — don't drop the priority loser, prefix it so nothing is lost — is exactly what reopens the fail-open, and nothing warned against it. The header now says the drop is deliberate and why.

Type of change

  • Bug fix
  • New feature
  • Refactoring (no behavior change)
  • Dependency update
  • Documentation
  • Other (describe):

Test plan

  • Unit tests (task test)
  • E2E tests (task test-e2e)
  • Linting (task lint-fix)
  • Manual testing (describe below)

task test passes; the only failures are three pre-existing environment-dependent ones in this sandbox (TestNewServer_ReadTimeoutConfigured, TestSecurityHeaders — both "no available runtime found" — and TestCompositeProvider_RealProviders), all unrelated to this change. task lint-fix reports 0 issues. task docs produces no diff (no CLI-facing text changed).

TestDefaultAggregator_ResolveConflicts_PromptPrefixAmbiguity pinned the hard error; it is replaced by TestDefaultAggregator_PromptAmbiguityDropsEveryClaimant, which runs the full AggregateCapabilities pipeline so it can assert the ambiguous name is absent from both the advertised list and the routing table, that surviving prompts still translate back to their backend's own name, and that aggregation returns no error. Three cases: a two-way composition collision, a three-way one, and a prefixed name hitting a priority-listed backend's literal bare name (that last case moved here from ..._PromptPriority, which no longer has a competing error assertion).

Both mutations the fix must be robust against were checked against the new tests:

Mutation Result
Keep the first claimant instead of dropping all (the tool precedent) All three subtests fail — the ambiguous name appears in the advertised map and in RoutingTable.Prompts
Revert to returning ErrUnresolvedConflicts require.NoError fails; AggregateCapabilities propagates any ResolveConflicts error verbatim (default_aggregator.go:466-469)

Changes

File Change
pkg/vmcp/aggregator/capability_conflicts.go Drop-all on ambiguity with an ERROR log naming the name, the colliding backends and their original prompt names; resolvePromptConflicts loses its error return; header rewritten for the three review points
pkg/vmcp/aggregator/default_aggregator.go Prompt resolution no longer produces an error to propagate
pkg/vmcp/aggregator/capability_conflicts_test.go Ambiguity test rewritten to pin drop-both over the full pipeline, three-way case added, priority-loser drop assertion given its rationale
docs/arch/10-virtual-mcp-architecture.md Conflict Resolution section: drop-both instead of hard error, per-pair invariant, permit-redirection caveat, drop-not-re-prefix rationale

ErrUnresolvedConflicts itself is untouched and still used by the manual tool resolver (manual_resolver.go:166). Tool resolution is unchanged.

Does this introduce a user-facing change?

Yes. A vMCP group whose backends produce an ambiguous advertised prompt name previously served nothing at all — every list verb failed until an operator renamed something. It now serves everything except the colliding prompts, which are dropped and reported at ERROR. No configuration change is needed to pick this up.

Special notes for reviewers

On surfacing (the one open item from the review). The reviewer's caveat was that "the hard error is impossible to miss and drop-both isn't... If you take it, surface it somewhere an operator actually sees, not only slog.Warn." This PR logs at ERROR rather than WARN, and richer surfacing is deliberately deferred — every candidate surface needs new plumbing that would dwarf the fix:

  • /status (pkg/vmcp/server/status.go) is built from the backend registry and the health monitor. The server holds no reference to the aggregation result — the caching aggregator owns it and hands it back per request — so routing dropped-prompt state there means new server-held state plus its invalidation.
  • AggregationMetadata exists but is consumed only for trace-span attributes and Debug logs; nothing operator-facing reads it. Making it operator-visible is the same plumbing problem one layer down.
  • VirtualMCPServer.Status would be the right home, but the operator observes discovered backends, not the running aggregator's per-request conflict outcomes. That is a CRD field plus a controller feedback path.
  • The aggregator has no meter, so a metric means threading a MeterProvider through NewDefaultAggregator and its call sites.

Happy to open a follow-up for whichever of these you consider the right long-term surface — my instinct is a counter on AggregationMetadata exposed through /status — but it wants its own PR and its own design discussion rather than riding along here.

On the mixed-listed case. A group where some claimants are priority-listed and some are not is treated as ambiguous and all claimants are dropped, matching the pre-existing resolvability condition (!winner.listed || !contender.listed). Priority rank only decides when every claimant is listed, i.e. when all claims are literally the same bare name.

Generated with Claude Code

An advertised prompt name with no defined owner — two (backendID, name)
pairs composing to the same string — failed the whole aggregation. That
error propagated out of ResolveConflicts before the already-computed
tools, resources and templates were returned, so one ambiguous prompt
name took down tools/list, resources/list, resource-templates/list,
prompts/list, Discover's presence flags and backend visibility for the
entire group. Errors are never cached, so every request re-swept every
backend and failed again while the condition persisted. Reaching it
needs no conflict-resolution config, only an unlucky combination of
operator-chosen workload names and backend-chosen prompt names.

Drop every prompt claiming an ambiguous name instead, logging the name,
the colliding backends and their original prompt names at ERROR.
Dropping all claimants rather than only the loser (the tool precedent)
is what makes this safe: a survivor would inherit the ambiguous name
and with it any policy written for the prompt it collided with, since
Cedar authorizes on the advertised name alone. Advertised by nobody,
every permit and forbid on the name is vacuous and the rest of the
group keeps serving.

Also scope the header's stability invariant to the (backendID, name)
pair it actually holds for, and state the caveat it does not cover:
under priority, whoever wins a shared bare name inherits every permit
written for it. forbid still fails closed because the priority loser is
dropped rather than aliased — record that the drop is deliberate, so
the obvious future "improvement" of re-prefixing the loser does not
reopen the fail-open.

Addresses post-merge review feedback on #6075.

Co-Authored-By: Claude Fable 5 <[email protected]>
@github-actions github-actions Bot added the size/M Medium PR: 300-599 lines changed label Jul 28, 2026
@codecov

codecov Bot commented Jul 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.39%. Comparing base (de1953e) to head (2196d3f).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6099      +/-   ##
==========================================
+ Coverage   72.37%   72.39%   +0.02%     
==========================================
  Files         731      731              
  Lines       75739    75753      +14     
==========================================
+ Hits        54816    54845      +29     
+ Misses      17025    16990      -35     
- Partials     3898     3918      +20     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@JAORMX
JAORMX merged commit 919479d into main Jul 28, 2026
48 checks passed
@JAORMX
JAORMX deleted the aggregator-prompt-ambiguity-followup branch July 28, 2026 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Medium PR: 300-599 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants