feat(javascript): page retained feature traces through analysis views (#8522)

* feat(javascript): page retained feature traces through analysis views

A bidirectional trace_application_feature result can exceed one MCP
response, and inspect_analysis_view refused trace parents as unsupported,
so the only recovery was exporting the whole session.

- Add a shared feature-trace view owner: a summary with the trace's
  identity, producer counts and coverage, and pages of paths, nodes,
  edges, seed_matches and native_handoffs in retained order with exact
  filters. Node rows are compact unless observations are requested.
  Page coverage never upgrades trace coverage.
- Accept an optional MCP view on trace_application_feature that retains
  the complete trace before returning the selected facts; the CLI keeps
  complete JSON and reads saved traces with inspect-analysis-view.
- Offer a ready-to-call first paths page when a retained complete trace
  exceeds the MCP response budget.
- Share the distinct authority/state/confidence basis helper with
  module references.

Fixes #8296

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(javascript): name the retained parent when a selected view overflows

Review follow-up for the feature-trace views.

- Share one delivery owner between trace_application_feature and
  compare_source_to_bundle: stage the selected view against the
  completed parent, keep the established contract that a cancelled
  request commits no session facts, then commit sources and the parent.
- A selected view that exceeds the response budget now references the
  retained parent and offers the same selection at half its limit,
  instead of naming the view record, which cannot be a view parent.
- Cover two native handoffs paged one at a time, the oversized selected
  page, and cancellation after the trace completes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(javascript): bind feature-trace pages to their collection rows

Advertise each feature-trace page with exactly its own row schema, so a
paths page cannot validate with node, edge, seed-match or handoff rows.
The native-trace view in #8533 received the same review finding; the two
sibling views now share one strict page contract.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(javascript): mix valid rows from another collection into a trace page

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kaoru0822andClaude Opus 5.5 authored and GitHub committed 2026-11-01 08:56:05 -08:00
1 parent 44b6384009
commit 423059a4de
18 files changed
+1250 -111

No files matched your search

@@ -27,12 +27,28 @@ export const javascriptModuleReferencesRequestSchema = z.strictObject({
});
/** Unique support states, without promoting mixed observations to one fact. */
const basisSchema = z.strictObject({
export const javascriptFactBasisSchema = z.strictObject({
authority: applicationGraphEvidenceSchema.shape.authority,
state: applicationGraphEvidenceSchema.shape.state,
confidence: applicationGraphEvidenceSchema.shape.confidence,
});
type JavaScriptFactBasis = z.infer<typeof javascriptFactBasisSchema>;
/** Distinct support states in first-observed order; mixed support stays mixed. */
export const javascriptFactBasis = (
evidence: Iterable<JavaScriptFactBasis>,
): JavaScriptFactBasis[] => {
const support = new Map<string, JavaScriptFactBasis>();
for (const { authority, state, confidence } of evidence)
support.set(`${authority}:${state}:${confidence}`, {
authority,
state,
confidence,
});
return [...support.values()];
};
/** Reusable facts rather than task-specific dependency interpretations. */
export const javascriptModuleReferenceSchema = z.strictObject({
node_id: prefixedDigestSchema("jag_node"),
@@ -40,7 +56,7 @@ export const javascriptModuleReferenceSchema = z.strictObject({
path: z.string().nullable(),
identity: applicationNodeIdentitySchema,
retained_source_range_count: z.int().nonnegative(),
basis: z.array(basisSchema).min(1),
basis: z.array(javascriptFactBasisSchema).min(1),
});
export type JavaScriptModuleReference = z.infer<