Skip to content

perf(artifacts): add opt-in Interface Builder summary delivery and pages - #2684

Closed
kaoru0822-kitauji wants to merge 7 commits into
mainfrom
perf/interface-builder-summary
Closed

kaoru0822-kitauji wants to merge 7 commits into
mainfrom
perf/interface-builder-summary

Conversation

@kaoru0822-kitauji

Copy link
Copy Markdown
Collaborator

Summary

Over MCP, decode_interface_builder currently fails on ordinary apps. The complete graph for XLD.app is 6.7 MB (1,980,857 o200k tokens) and for Transmission.app 6.3 MB. The text and structuredContent copies together exceed the default 10 MiB response budget, so the caller gets resource_constraint ("its complete MCP response exceeds the stdio response budget") instead of an answer. A caller who only wants the windows, outlets or actions of one nib had no way to ask for less.

This PR adds the same opt-in delivery #2634 added for inspect_macho, which WASM, EVM, managed, Android, Dart AOT and pcap already have. Refs #2016, #1065.

Problem and expected behavior

Smallest trigger: open_binary /Applications/Transmission.app, then decode_interface_builder {} returns resource_constraint. Expected: a first call can return a bounded answer while the complete Evidence stays retained for exact pages.

Change and scope

  • src/domain/analysisView/interfaceBuilderView.ts (new) owns Interface Builder views.

    • Summary: returns every decoded document row (bounded at 64), the provider, available_counts, tallies by node kind, edge relation and coverage status, and decoder truncation.
    • kind: "interface-builder" pages: cover documents, nodes, edges or coverage in original order. For nodes and edges, an optional document keeps rows whose recorded evidence[].artifact_path equals that exact documents[].relative_path. That's the producer's own attribution; nothing is reparsed from IDs. An undecoded path is refused instead of returning an empty page. Every page carries source_truncated.
    • Identity check: the parent subject digest and graph.target_sha256 must both equal target_sha256.
  • decode_interface_builder gets an optional detail and a complete-or-summary output schema. Delivery detail is stripped before execution and from Evidence parameters, so the summary's parent_evidence_id equals a complete call's Evidence ID. The preflight refuses summary before decoding when the server keeps no Evidence (the fix from perf(native): add opt-in Mach-O summary delivery and retained pages #2634).

  • Related cleanup: the new view would have been the ninth copy of three patterns, pushing jscpd to 3.02% (threshold 3.0%). Each now has one owner:

    • parseAnalysisViewResult (analysisViewParent.ts) parses a parent's normalized result and maps issues into source.normalized_result. It replaces the identical blocks in the WASM, EVM, managed, Android, Dart AOT, web capture, Mach-O and IB views.
    • retainedSummaryDelivery / withoutDeliveryDetail (retainedSummaryDelivery.ts) own the preflight and summary hooks and the shared registration options type used by the artifact, native and managed registrations.
    • openProductionTarget (tests/support/mcp/productionSession.ts) owns the "production session plus open_binary" setup in five MCP tests.

    Duplication is now 2.98%. Behavior of the existing views and registrations is unchanged; their suites pass.

  • Docs: docs/mcp-contracts.md, docs/native-investigation.md, the skill reference, and the inspect_analysis_view description.

Not included: changing the producer's representation. Nodes repeat the document path in id, name and evidence, and limitations list each max_documents omission; that's a contract question. The default stays complete, and the CLI is unchanged (inspect-analysis-view with inline Evidence already supports the new kind).

Contribution scope: not applicable. This is the established opt-in delivery pattern with no new execution, mutation or authority.

Contract and boundary impact

  • Semantic owner and earliest changed stage: projection of retained decode_interface_builder Evidence; MCP delivery selection in registerArtifactTools.

  • Contribution scope fit and linked maintainer decision: not applicable.

  • CLI and MCP/tool-catalog contract: additive. The new optional detail and summary output variant, and a new interface-builder view request/result. Omitted detail keeps the old result and Evidence identity.

  • Provider, bridge, target-format, or platform compatibility: none. The decoder receives the same parameters.

  • Evidence, artifact, provenance, or reconstruction contract: the complete Evidence and its ID are unchanged. Views are derived Evidence linked to the retained parent.

  • Generated metadata, package, or installation impact: catalog regenerated at build; docs:check passes.

  • Read existing files or captured data.

Evidence and regression coverage

  • src/domain/analysisView/interfaceBuilderView.test.ts (any platform) covers:
    • tallies and documents without rows
    • a document-filtered node page with offset
    • visible truncation
    • refusals for an unknown document, the wrong view kind, and a mismatched subject digest
  • tests/boundary/mcp/interfaceBuilderSummaryMcp.test.ts (any platform; production session, real UIKitOutlet.xml nib archives in a two-document .app) checks:
    • Omitted detail records no detail.
    • The summary documents and counts equal the complete result.
    • parent_evidence_id equals the complete Evidence ID.
    • All edges reassemble from 2-row pages.
    • A document-filtered node read equals the complete nodes attributed to that nib (and is a strict subset).
    • An unknown document is refused.

Real applications (macOS, real MCP stdio, this branch)

App complete over MCP summary 20 edges of one document
XLD.app (64 decoded nibs, 6,528 nodes) resource_constraint; CLI JSON 6,734,711 B / 1,980,857 tok 35,497 B / 10,090 tok 6,989 tok
Transmission.app (5,560 nodes) resource_constraint; CLI JSON 6,313,752 B / 1,948,182 tok 12,106 B / 3,762 tok 5,034 tok

For both apps, the summary's parent equals the CLI complete Evidence ID, and paging every node 500 at a time reproduces all nodes exactly. Decoding takes 0.5–1.5 s for complete and summary alike (same analysis); each page takes about 30–40 ms. Tokens are o200k_base via tiktoken. CPU and peak memory weren't measured separately, because only delivery differs.

About 7 KB of each XLD response is the producer's 69 limitations, and they appear twice (normalized result and Evidence envelope), as in every view. I left that envelope repetition alone.

Catalog cost: tools/list grows from 687,395 to 690,367 o200k tokens (+2,972, +0.43%). decode_interface_builder adds 862 and inspect_analysis_view adds 2,110. Each page's rows use the existing strict graph schemas, so the union can't strip fields (the #2634 Greptile finding).

Validation performed

  • npx vitest run src — 5,127 passed. One failure, src/ida/IdaWorkspaceThinning.test.ts "copies exactly the selected slice when later slices follow it across read boundaries", fails identically on unmodified main on this host.
  • npm run test:focused -- with these files passes: interfaceBuilderSummaryMcp, nativeMachoSummaryMcp, nativeDemangleMcp, keyedArchivePrototypeKeyMcp, keyedArchiveNumberMetadataMcp, artifactMcp.inlineInventory, analysisSummaryDetailMcp, toolSchemaValidity, serverIdentity, managedArtifactSummaryMcp, wasmArtifactMcp, evmInterfaceMcp, androidPackageSummaryMcp, dartAotSummaryMcp, pcapRetainedView, analysisViewCli, analysisViewMcp, sazWebCapture, qlogCapture, retainedApplicationEvidenceMcp, binaryDiagnosticsMcp, interfaceBuilderUIKitKeyedArchive, dylibResolutionMcp, enhancedTools.01, keyedArchiveSelection, targetContentProvenance.
  • npm run check:fast, npm run typecheck, npm run format:check, npm run docs:check, npm run knip, npm run jscpd (2.98%), npm run verify:architecture-guards — pass.

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: macOS real apps (XLD, Transmission). The new tests use committed fixture archives and run on all platforms.
  • Package or release metadata impact: none beyond the regenerated catalog.
  • Security, privacy, process, or containment review: views read only retained Evidence; no new process, file or network effects.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

🤖 Generated with Claude Code

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-14T00:37:13.943969Z f3cd103 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@greptile-apps

greptile-apps Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium impact] The reviewed changes appear safe to merge.

Summary

This diff finishes a shared-parser cleanup, documents Interface Builder summary paging, and adds a test for invalid delivery detail.

  • The artifact guide shows how to page large Interface Builder graphs.
  • Web capture views now use the shared parent-result parser.

Reviews (12) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 765ba7ff55

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/server/retainedSummaryDelivery.ts Resolved
@kaoru0822-kitauji

Copy link
Copy Markdown
Collaborator Author

Heads-up on b6d0fb5: the new detail: "brief" assertion in tests/boundary/mcp/interfaceBuilderSummaryMcp.test.ts fails locally (macOS, after npm run build:cached):

FAIL tests/boundary/mcp/interfaceBuilderSummaryMcp.test.ts > retains complete Interface Builder Evidence and pages one document's rows
SyntaxError: Unexpected token 'I', "Input vali"... is not valid JSON
 ❯ parseMcpToolError tests/fixtures/mcpToolError.ts:15:17
 ❯ tests/boundary/mcp/interfaceBuilderSummaryMcp.test.ts:74:12

decode_interface_builder is registered through toolRegistrationOptions, so the SDK validates the contract's detail enum before the handler runs. The call returns the SDK's plain-text error, Input validation error: Invalid arguments for tool decode_interface_builder: detail: Invalid option: expected one of "complete"|"summary", not an REA invalid_request projection. The same happens for inspect_macho and inspect_artifact, and with REA_MCP_INPUT_SCHEMA_PROFILE=compact. The new typed preflight stays as defense in depth, but this MCP path can't reach it.

If you meant the SDK-level refusal to be the contract, this assertion passes:

expect(invalidDetail.isError).toBe(true);
expect(JSON.stringify(invalidDetail.content)).toContain(
  'detail: Invalid option: expected one of \\"complete\\"|\\"summary\\"',
);

If you'd rather have REA's structured invalid_request here, these registrations would need applicationValidatedInputSchema, as pcap and web capture use. I'll push the assertion change if you want; I'm leaving the branch alone while you're working on it.

@morluto

morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner

Review findings addressed at their producing boundaries and consumers. Latest changes were reviewed from source; tests and provider runs were skipped at the maintainer's request. Findings requiring separate decisions or verification remain open.

  1. thread 1

The shared delivery preflight now parses the canonical analysisDetailSchema before admission or execution. An invalid selection returns the tagged AnalysisInputError Result with a detail issue, which is delivered as invalid_request; the field is only removed later from execution/Evidence parameters. Both artifact and native delivery families consume this owner. Added an MCP request regression for detail="brief"; it was not run at the user's explicit request.

Source inspected at b6d0fb5; git diff --check passed. Tests, builds, source checks and CI reruns were skipped at the user's explicit request. No passing runtime/provider verification is claimed for this update.

@morluto morluto added performance Performance regressions, scaling limits, and bounded-resource work area: evidence Evidence, artifacts, and reconstruction area: server Server layer and tool wiring area: domain Domain logic, errors, and pure functions P2: medium Medium priority issue labels Oct 13, 2026
morluto added a commit that referenced this pull request Oct 13, 2026
kaoru0822-kitauji and others added 5 commits October 14, 2026 02:40
decode_interface_builder returns the complete object, hierarchy and
connection graph inline. XLD.app's graph is 6.7 MB (about 1.98M o200k
tokens) and Transmission.app's 6.3 MB; over MCP the doubled text and
structured content exceed the default response budget, so an agent got
a resource_constraint error instead of any answer.

Add the established opt-in delivery: omitted or complete detail keeps the
complete result and its Evidence ID, while summary retains the complete
Evidence and returns every decoded document with node-kind,
edge-relation and coverage-status tallies (10k tokens for XLD).
inspect_analysis_view kind interface-builder pages documents, nodes,
edges or coverage; nodes and edges accept an exact decoded document path,
matched against each row's recorded evidence, and an undecoded path is
refused. Decoder truncation stays visible on every page.

Related cleanup, since the new code repeated it a ninth time:
- parseAnalysisViewResult owns parsing a view parent's normalized result
  with the operation's schema and mapping issues into the view source.
- retainedSummaryDelivery owns the preflight/summary hook pair and the
  shared registration options for artifact, native and managed tools.
- openProductionTarget owns the production MCP session test setup.
Duplication drops from 3.02% to 2.98% (threshold 3.0%).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
graph.truncated is also set for invalid archives, omitted dictionary keys
and fixed decode budgets, not only caller-selected limits, so the view's
unknown now points at coverage and limitations for the cause. The MCP
test requests the summary first and reads its retained pages before any
complete call, covering the flow where complete delivery cannot fit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@morluto
morluto force-pushed the perf/interface-builder-summary branch from 62bdd3a to 94e360c Compare October 13, 2026 18:40
@kaoru0822-kitauji kaoru0822-kitauji added the ci-fix-wip Claimed by the CI-fix track label Oct 14, 2026
@kaoru0822-kitauji

Copy link
Copy Markdown
Collaborator Author

CI-fix track: the failing lanes (real-web-runtime Invalid URL: undefined in list_browser_targets, real-web-source-map owned-browser startup, and the Windows inspection retry probe) don't touch this PR's files. Several other PRs based on the same main failed them too, and all three pass on current main (run 38484743093). I merged origin/main (no conflicts). Verified locally on the merged tree: check:fast, docs:check, the PR's analysisView and MCP boundary tests (11 files, 90 tests), and test:changed (59 files). Waiting on a new CI run.

@kaoru0822-kitauji

Copy link
Copy Markdown
Collaborator Author

CI-fix track: the Windows lane failure (tests/acceptance/webModuleCli.test.ts hitting its 15 s deadline) doesn't look caused by this PR. The CLI had already printed its full JSON result but didn't exit in time. The test takes 2–3 s in main's Windows lane, passes locally in ~0.4 s on this merged head, and fails in no other recent CI run. Sibling acceptance tests on this runner were also about 2× slower than on main. Nothing in this PR touches the CLI, process exit, or web-module tracing. I'll re-run the failed job once the in-progress mutation lane finishes.

morluto added a commit that referenced this pull request Oct 14, 2026
Preserve XML and Interface Builder identity at their parsing boundary, retain usable Objective-C slots with precise coverage, and keep native trace failures distinct from absence. Add caller-selected Interface Builder summaries backed by complete retained Evidence, and preserve comparison limitations.

Reviewed fixes: #1969, #2088, #2108, #2513, #2639, #2684, #2731, #2759, #2875, #2888, #2889, #2970, #2971, #3002.

Validation: relevant native/domain focused lane passed 142 tests; earlier Interface Builder/MCP checks passed 24 tests. Real native UI and Ghidra producer coverage was not repeated.
morluto added a commit that referenced this pull request Oct 14, 2026
Use one named input-schema projection for clients and catalog identity, preserve dialect declarations, and bound compact schema depth. Keep canonical SDK output validation when output advertisements are disabled. Release request-owned state on cancellation and carry upstream limitations through composed workflows. Preserve doctor full-output envelopes and validate navigation facts at their owner.

Reviewed fixes: #2088, #2108, #2513, #2684, #2693, #2695, #2836, #2864, #2868, #2877, #2933, #2998, #3002, #3015.

Validation: focused schema, SDK output-validation, context, and workflow tests passed; no schema dialect or canonical output validation was relaxed.
# Conflicts:
#	docs/mcp-contracts.md
#	src/server/retainedSummaryDelivery.ts
#	tests/boundary/mcp/interfaceBuilderSummaryMcp.test.ts
@kaoru0822-kitauji

Copy link
Copy Markdown
Collaborator Author

CI-fix track: merged current main to clear the conflicts. Most of this PR already landed on main in 80de314, so overlapping files take main's version: retainedSummaryDelivery.ts (main validates detail once through the tool's input contract instead of a second preflight parser) and the reflowed docs/mcp-contracts.md paragraphs. What's left against main is the skill reference paragraph, the web capture view moved onto the shared parseAnalysisViewResult, and the invalid-detail MCP assertion, which still passes on main's contract. Locally: interfaceBuilderSummaryMcp, webNetworkCaptureView, historical/SAZ web capture and analysisViewCli tests passed (81), and check:fast and docs:check are clean.

@kaoru0822-kitauji kaoru0822-kitauji removed the ci-fix-wip Claimed by the CI-fix track label Oct 14, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@kaoru0822-kitauji kaoru0822-kitauji added ci-fix-wip Claimed by the CI-fix track and removed ci-fix-wip Claimed by the CI-fix track labels Oct 14, 2026
@kaoru0822-kitauji

Copy link
Copy Markdown
Collaborator Author

CI-fix track: the new Source tests failure (JavaScript semantic analysis and IdaNativeProtocol) comes from main, not this PR. Current main fails the same 5 tests; the fix is in #3080.

@morluto

morluto commented Oct 15, 2026

Copy link
Copy Markdown
Owner

@kaoru0822-kitauji, thanks for identifying that complete Interface Builder graphs could exceed MCP response budgets and proposing a summary-plus-pages workflow. The current tool keeps complete Evidence while allowing compact summaries and selected pages for callers (main).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: domain Domain logic, errors, and pure functions area: evidence Evidence, artifacts, and reconstruction area: server Server layer and tool wiring P2: medium Medium priority issue performance Performance regressions, scaling limits, and bounded-resource work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants