Repository navigation
feat(native): page retained feature traces through analysis views - #8533
kaoru0822-kitauji wants to merge 3 commits into
Conversation
A large trace_feature result can carry thousands of references with unavailable owners. inspect_analysis_view refused it as an unsupported parent and trace_feature rejected detail: summary, so agents had to transfer the complete result or export the session. - Give the trace result one domain owner (literalFeatureTrace.ts) used by the tool output contract and the new view. - Add a native-trace view: a summary with match counts by type, reference counts by owner outcome and the residual-unknown count, and pages of references, matches and residual_unknowns in retained order with exact filters and source indexes. Residual unknowns are paged rather than repeated in every view. - Accept detail: summary on trace_feature through the existing enhanced summary delivery; session Unknowns are recorded as before. - Offer a ready-to-call first references page when a retained complete trace exceeds the MCP response budget. Fixes #8373 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
[Medium impact] The PR appears safe to merge; both earlier findings are addressed and no new blocking issue was found. SummaryAdds summaries and filtered pages for retained native
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart LR
T["trace_feature"] --> P["Retain complete Evidence"]
P --> S["Return summary"]
P --> V["inspect_analysis_view"]
V --> R["references"]
V --> M["matches"]
V --> U["residual_unknowns"]
Reviews (2) · Last reviewed commit: "fix(native): bind native-trace pages to ..." · Reviewed by Greptile |
| view: nativeTraceViewRequestSchema, | ||
| items: nativeTraceViewItemsSchema, |
There was a problem hiding this comment.
The output schema checks view.collection and items independently. A references page containing only match or unknown rows would still pass, so clients cannot use the advertised schema to catch a wrong-collection reply. Bind each collection to its own row schema, as machoPage already does for facets.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/domain/analysisView/analysisViewResult.ts
Line: 970-971
Comment:
**Wrong rows pass output checks**
The output schema checks `view.collection` and `items` independently. A `references` page containing only `match` or `unknown` rows would still pass, so clients cannot use the advertised schema to catch a wrong-collection reply. Bind each collection to its own row schema, as `machoPage` already does for facets.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.There was a problem hiding this comment.
Agreed, fixed in fd4130d65.
Root cause: items was a union of row arrays, independent of view.collection.
Fix: nativeTraceViewCollections in nativeTraceView.ts binds each collection's request schema to its own row schema. The page result is a kind-tagged union of one strict page per collection, following the machoPage pattern. The projector builds each page in its own correlated branch.
Validation: a references page whose items are replaced with match rows now fails both analysisViewResultSchema and the advertised inspect_analysis_view output schema under Ajv; the unmodified page passes both. 8 related files, 103 tests passed.
| case "xrefs": | ||
| return ok( | ||
| createAnalysisExecution([...(SOURCES[address] ?? [])], PROVIDER), | ||
| ); |
There was a problem hiding this comment.
The new view tests never set referencesTruncated and only assert truncated: false. They would not catch a later change that drops the reference-cap warning from summaries or pages. Add a provider-capped trace and check that its summary, filtered pages and exhausted pages retain truncated: true and the cap warning. The existing producer tests do not exercise this projection.
Prompt To Fix With AI
This is a comment left during a code review.
Path: tests/boundary/mcp/nativeTraceViewsMcp.test.ts
Line: 66-69
Comment:
**Capped traces lack view tests**
The new view tests never set `referencesTruncated` and only assert `truncated: false`. They would not catch a later change that drops the reference-cap warning from summaries or pages. Add a provider-capped trace and check that its summary, filtered pages and exhausted pages retain `truncated: true` and the cap warning. The existing producer tests do not exercise this projection.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.There was a problem hiding this comment.
Agreed, fixed in fd4130d65. The fixture provider can now report referencesTruncated for the first match. A new test checks six views of that capped trace: the detail: summary reply, the retained summary, a one-row references page, an owner-filtered page, an exhausted matches page and the residual-unknown page. Each keeps truncated: true and both the coverage and reference-cap unknowns. Those messages are now exported constants from their owner, so the test compares owning values rather than prose.
Review follow-up. - Advertise each native-trace page with exactly its own row schema, so a references page cannot validate with match or unknown rows. - Export the coverage and reference-cap unknowns from their owner and verify a provider-capped trace keeps truncated and the cap warning on its summary, filtered, exhausted and unknown pages. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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>
…#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>
Summary
Fixes #8373, the retained-view part (proposal: #8373 (comment)). It is the native counterpart of #8522 (JavaScript feature traces) and uses the same retained-view projector registry.
Problem and expected behavior
From the issue (real Kuna, 3,000–16,000 references): the trace reply reached 2–8.5 MB or overflowed. A filtered bundle summary found the trace ID, but
inspect_analysis_viewreturnedunsupported_targetfor bothsummaryandnative-observation, andtrace_featurerejecteddetail: summary. Export/import was the only working route.Expected contract: a bounded summary or pages that keep each source and target identity, unavailable reason, provider/profile and reference-cap coverage, with complete Evidence still accessible. An omitted page must not imply an absent reference. Independent Unknown revisions are preserved.
Change and scope
src/domain/native/literalFeatureTrace.ts(new owner): the result shape used to live only intoolOutputSchemaGroups.tsasliteralTraceOutput. The contract output and the view now both parse withliteralFeatureTraceResultSchema.literalReferenceOwnerderivesfound/not-found/unavailablefrom the recordedcontaining_procedurewithout reinterpreting it.src/domain/analysisView/nativeTraceView.ts, registered fortrace_feature, so MCP and CLIinspect-analysis-viewshare it:summary:query,search_mode,truncated, match counts by type, reference counts by owner outcome, and the residual-unknown count, with source provider/profile/parameters.{kind:"native-trace", collection, where?, offset, limit}:referencesfilter by exacttarget_addresses(no address normalization) andowners;matchesfilter bytypes;residual_unknownspage the texts.source_indexinto the complete retained array, so duplicates stay distinct.truncatedand the provider limitations travel with every page. Residual-unknown texts are paged rather than repeated in each view'sunknowns; that matters with one Unknown per unavailable owner.rea.analysispredicate, the same check as other native views.trace_featuredetail: it uses the existing enhanced-tool summary delivery (asget_call_graphdoes). It refuses before analysis when the server retains no Evidence, andrecordWorkflowUnknownsstill runs before summary delivery.{kind:"native-trace",collection:"references",offset:0,limit:64}for a retained trace.get_evidence_bundlesummary size;Contract and boundary impact
Semantic owner and earliest changed stage: the trace result schema moved to
domain/native. Consumers are the MCP output contract, the view projector, the delivery continuation and the CLI view. The superseded inline contract schema was removed.Contribution scope fit and linked maintainer decision: read-only projection of retained Evidence. Proposal posted on [Design] Bound delivery of large native feature traces and their unknowns #8373. No new provider capability.
CLI and MCP/tool-catalog contract:
trace_featuregains optionaldetail(defaultcomplete). Its output becomes the complete result or the summary view, viaanalysisDetailOutputSchemaOf.inspect_analysis_viewgainsnative-trace. One description sentence was added. The CLIrea traceis unchanged.Provider, bridge, target-format, or platform compatibility: provider-neutral projection of already returned facts; no provider call.
Evidence, artifact, provenance, or reconstruction contract: views reference the retained parent and keep its provider/profile/parameters. Owner outcomes come from recorded
containing_procedurevalues, and page coverage is separate from discovery.Target selection, authority, upstream behavior, and cleanup details: not applicable.
Generated metadata, package, or installation impact: none committed;
docs:checkandmetadata:checkpass.Read existing files or captured data.
Evidence and regression coverage
tests/boundary/mcp/nativeTraceViewsMcp.test.ts(new; production MCP registration with a fixture provider reporting 3 string matches, 1 procedure match, and references with found / not-found / unavailable owners; full and compact output profiles). It covers:detail: summaryretains the complete parent, its counts match the parent, andlist_unknownsstill holds one Unknown per unavailable owner;references(with derived owners),matchesandresidual_unknownsexactly;[], case-variant addresses and past-end offsets return empty;unknowns;referencescontinuation, and a smaller page of it fits;fixedserver refusesdetail: summarywith no provider call.truncated: trueand the reference-cap unknown on six views (summary reply, retained summary, one-row, owner-filtered, exhausted and unknown pages);analysisViewResultSchemaand the advertisedinspect_analysis_viewoutput schema under Ajv, since each collection is bound to its own rows.tests/boundary/cli/analysisViewCli.test.ts: a savedtrace_featureEvidence file paged withinspect-analysis-view(summary counts and theowners: ["unavailable"]page).detail: summaryreturnsinvalid_request, andinspect_analysis_viewreturnsunsupported_target/invalid_request. The new test file does not load on base because it imports the new domain module.Before/after at scale (synthetic, 8,000 references, all owners unavailable; production MCP registration in-process; macOS arm64, Node 24.22.1)
trace_featurecompletetrace_featuredetail: summaryinvalid_requestinspect_analysis_viewsummary on the retained traceunsupported_targetnative-tracereferences(64)invalid_requestnative-traceresidual_unknowns(64)invalid_requestlist_unknowns(64), for referenceValidation performed
fd4130d65):npm run test:focusedonnativeTraceViewsMcp(5/5),analysisViewMcp,outputSchemaProfile,outputSchemaSemanticConstraints,advertisedMcpTool,analysisViewCli,largeToolResultandtraceFeatureCoverage: 8 files, 103/103 passed.npm run test:focusedonnativeTraceViewsMcpplus 12 related files (enhanced tools, trace coverage, input validation, Ghidra routing, IDA readiness trace, prompts, CLI tool coverage, analysis selectors, output schema profiles, analysis views, large results, CLI analysis views): 13 files, 144/144 passed.npm run test:changed: 217 files, 4236 passed, 3 skipped.npm run check:fast,npm run format:check,npm run docs:check,npm run metadata:check: passed.Compatibility, safety, and release
detailis optional with defaultcomplete; the output union is a superset.src/server/toolResult.ts. Whichever lands second needs a one-line merge of thetrace_featureentry intoownerFirstPage.Author readiness
Human owner: @kaoru0822-kitauji
Before merge
type(scope): outcome.🤖 Generated with Claude Code