Repository navigation
fix(android): bound inline search Evidence with retained inventory provenance - #1890
Merged
morluto merged 1 commit intoOct 11, 2026
Merged
Conversation
…ovenance Focused and zero-match search_android_classes responses embedded every examined class name: JadxSession records each raw list_classes page into observed calls, those calls ride into Evidence raw_result on the registration path, and the complete inline Evidence is serialized into every tool response (issue morluto#1850: 382,435 bytes for one match). When the server session retains Evidence, record the complete raw-call record first, then deliver a summary Evidence that keeps the pagination audit (totals, offsets, page sizes, elided item counts), the unchanged normalized matches and truthful coverage metadata, and links the retained complete inventory by Evidence ID. Sessions without retention keep the complete inline delivery, so complete CLI JSON output is unchanged and no provenance is discarded. 🤖 Generated with AI assistance (disclosure voluntary per repo policy)
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. |
2 tasks done
3 tasks done
Owner
|
This keeps focused Android searches readable without dropping evidence, @akushonkamen. In retained sessions, the inline response carries pagination and omission facts plus a link to the complete stored inventory; sessions without retention still receive full inline Evidence. Thanks for preserving provenance and the existing CLI behavior. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Focused and zero-match
search_android_classesresponses embedded every examined class name: a single-match search on a 7,096-class APK returned a 382,435-byte tool response because the complete raw provider inventory rode inside the inline Evidence. When the server session retains Evidence, the complete raw-call record is now written to the retained store and the tool response delivers a bounded summary Evidence that keeps the pagination audit, the unchanged normalized matches and truthful coverage metadata, and links the retained complete inventory by Evidence ID (Fixes #1850).Problem and expected behavior
Smallest trigger: load a 7,096-class APK through the jadx bridge and call
search_android_classeswith a query matching exactly one class. Prior behavior: the response's inlineraw_resultcontained everylist_classespage with all 7,096 class names, because the raw provider call record was captured whole and serialized into every tool response. The violated invariant: a bounded, focused search response should not grow with the size of the unfiltered inventory, and a single match must not cost the full class list on the wire. Expected behavior: the inline Evidence carries the pagination audit (total,offset,limit, per-pageitems_omitted), aninventory_elidedmarker, the unchanged normalized matches andcoverage: complete/total_classes, andevidence_links+complete_evidence_idpointing at the retained complete record; sessions without retention keep the complete inline delivery, so CLI JSON output is unchanged and no provenance is discarded.Change and scope
Root cause chain:
src/android/JadxSession.tsrecords eachlist_classespage's complete MCP envelope into#observedCalls(src/android/JadxSession.ts:220-221); those calls ride into the execution asrawResultthroughcreateAnalysisExecution(src/android/JadxSession.ts:145-152);src/application/android/AndroidAnalysisService.tsembeds them into the Evidence (src/application/android/AndroidAnalysisService.ts:44-55); andsrc/server/contractToolHandler.tsserializes the complete Evidence into every tool response (src/server/contractToolHandler.ts:66-71). The normalized result (src/domain/android/JadxAnalysis.ts:175) is itself bounded; only the raw-call record is not.Fix: new
src/application/android/AndroidSearchEvidenceSummary.ts, applied on thesearch_android_classesregistration path insrc/server/registerAndroidTools.ts. When the session retains Evidence, the complete Evidence (with the full raw-call inventory) is recorded first viarecordEvidence, then a summary Evidence is delivered withitems_omittedcounts replacing the full per-page name lists. Sessions without retention skip summarization entirely, preserving the previous complete inline behavior for CLI consumers. Intentionally not included: no change to the normalized search contract, no change to non-search Android tools, and no budgeting for retention-free sessions.Contract and boundary impact
src/server/registerAndroidTools.ts, after the normalized result and raw-call record exist and before serialization.search_android_classesschema is unchanged and the normalized result is byte-identical; the inlineraw_resultfor retaining sessions now elides inventory items behinditems_omittedcounts pluscomplete_evidence_id, which is an output-size bound, not a shape change to the advertised contract.evidence_links; observed vs. elided content remains distinguishable viainventory_elidedanditems_omitted.docs/public/product-catalog.json), package, or installation impact: none; no catalog, package, or installation contract changes and no generated outputs committed.Evidence and regression coverage
tests/boundary/process/androidSearchEvidenceBudget.test.tsdrives a real 7,096-class jadx protocol fixture through the MCP server and asserts (1) with a retaining session: the single-match and zero-match inlineraw_resultcontain no class names, stay under 32 KiB, carryitems_omitted, and link a retained complete record whose raw calls hold all 7,096 names; (2) without a retaining session: the complete inventory stays inline.src/change removed (test and fixtures in place) on the rebased base, the retaining-session case fails exactly on the inline-raw assertion — the single-match response contains the full 7,096-name inventory, i.e. the issue symptom.For evidence-bearing changes:
Validation performed
Rebased onto
origin/main(fa9a7e5e, which touchessrc/domain/evidence.ts), artifacts refreshed withnpm run test:prepare, then:npx vitest run --project process-boundary tests/boundary/process/androidSearchEvidenceBudget.test.tswith thesrc/fix removed — 1 failed / 1 passed; the failure is the bounded-Evidence assertion with the full 7,096-name inventory present in a single-match response (base reproduction).npx vitest run tests/boundary/android/ tests/boundary/process/ src/server/ src/domain/android/ src/contracts/android/— 36 files passed, 237 passed + 2 skipped, 0 failed.npx vitest run src/android/ src/server/— 2 files passed, 12 passed. (Note:npx vitest run src/android/alone exits 1 with "No test files found";src/android/has no test files in this repository.)npx vitest run tests/acceptance/tools/localToolContracts.test.ts tests/boundary/mcp/— 97 files (95 passed + 2 skipped), 370 passed + 3 skipped, 0 failed.npx tsc --noEmit— exit 0.npx oxlint— 0 errors (themax-params(5)warning onregisterAndroidToolsis pre-existing atorigin/main);npx oxfmt --check src/ tests/— clean.Compatibility, safety, and release
evidence_links/complete_evidence_id; CLI output (no retention) is byte-identical in shape.Review checklist
type(scope): outcome.🤖 Generated with AI assistance (disclosure voluntary per repo policy)