feat(cli): expose provider selection diagnostics in session status (#9603)

* feat(cli): expose provider selection diagnostics in session status

The registry now records how each deep provider became selected and why a
candidate was rejected, but the session status projection dropped both
fields. CLI providers/capabilities and MCP binary_session therefore showed
a candidate list that could not explain an automatic or explicit choice,
so users had to re-derive the reason from prose in selection errors.

Project selection_source and rejections for every candidate. Complete detail
keeps the rejection remediation and diagnostics; summary keeps the stable
origin, code and reason and lists the dropped fields in omitted_fields.
Existing candidate fields are unchanged, so both projections stay additive.

* test(javascript): distinguish package scope in route fixtures

* test(apple): separate identity and refusal fixture groups

* fix(session): preserve binding source in refreshed candidates

---------

Co-authored-by: 2SinceJuly <202121119+2SinceJuly@users.noreply.github.com>
Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
This commit is contained in:
authored and GitHub committed 2026-11-09 21:47:15 +08:00
1 parent 78343052c2
commit 217b6fdcdc
8 files changed
+366 -77

No files matched your search

+20 -16
View File
@@ -139,23 +139,27 @@ export class SessionProviderRouter {
} = {},
): Promise<readonly AnalysisProviderCandidateStatus[]> {
const { signal, target, refresh = false } = options;
if (refresh && route.selection !== undefined) {
const current = await this.registry.candidates(
target,
signal === undefined ? {} : { signal },
);
return current.map((candidate) => ({
const candidates =
refresh && route.selection !== undefined
? await this.registry.candidates(
target,
signal === undefined ? {} : { signal },
)
: (route.selection?.candidates ??
(await this.registry.candidates(
undefined,
signal === undefined ? {} : { signal },
)));
const binding = route.binding;
if (binding === null) return candidates;
return candidates.map((candidate) => {
const selected = candidate.provider.id === binding.identity.id;
return {
...candidate,
selected: candidate.provider.id === route.binding?.identity.id,
}));
}
return (
route.selection?.candidates ??
this.registry.candidates(
undefined,
signal === undefined ? {} : { signal },
)
);
selected,
selectionSource: selected ? binding.selectionSource : null,
};
});
}
/** Produce exact candidate rejections for an intentionally unbound route. */