Repository navigation
Conversation
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. |
[Medium impact] The PR changes diagnostics and Evidence behavior across several bounded REA workflows. Fix the incorrect totals in paged state replies before merging; the other two findings are non-blocking. Findings
Fix with agent prompt### Issue 1
src/domain/analysisView/environmentStateRules.ts:663-665
A new paged query can report the page length as the full total. Capture `/api/items` with three items and `total: "03"`, followed by `?limit=1` with one item and the same total. A later `limit=2` call can select the first recorded response. This branch changes its total to `"2"`. `renderQueryList` cannot restore 3 because `queryTotalCount` rejects padded strings.
Previously, `"03"` stayed unchanged. Clients can now stop paging before fetching the last item. Keep unsupported query totals out of page counters, or teach the query renderer how to update them.
### Issue 2
src/server/registerFunctionComparisonTool.ts:47-50
Successful inline comparisons now authenticate each Evidence record twice. These new `readEvidence` calls copy and hash the payload, but the later `parseFunctionEvidence` calls still receive `resolved.value.left` and `resolved.value.right` and repeat that work.
Large function dossiers therefore get another full copy and hash on the server's main thread, delaying other requests. Parse each side once and reuse the result for the kind checks and comparison.
### Issue 3
src/javascript/analysis/JavaScriptAnalysisWorker.ts:1065-1068
The new I/O details disappear if worker cleanup also fails. `analyze` then returns `#cleanupError`, whose `execution_failure` keeps only `original.message` and captured output-not `original.diagnostics`. The new `ProviderAdapterError.message` is generic, so the returned `cleanup_incomplete` error loses the source path, phase, and I/O message.
Previously, those details survived inside `AnalysisOutputError.message`. Preserve the original error's details when building the cleanup error so users can still tell which read failed.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.SummaryImproves input errors, operation names, provider diagnostics, and Evidence metadata across existing CLI and MCP paths.
Validation was source review plus Reviews (3) · Last reviewed commit: "fix(diagnostics): attribute input and re..." · Reviewed by Greptile |
3c4159c to
3b942bc
Compare
Make failures name the request field, operation, or provider diagnostic that caused them, and classify malformed-but-recoverable data correctly. - Name the malformed inline Evidence field for match_native_functions on the MCP and CLI bundle paths, including observation indexes. - Report wrong-kind compare_functions Evidence per side as input issues. - Forward ADB and Apktool version-probe diagnostics into capability refusals. - Attribute ADB version-probe limits and snapshot-read cancellation to the requesting operation. - Map JavaScript worker I/O failure frames to ProviderAdapterError with source path, phase, and I/O message. - Count digit-string list totals in environment-state list views. - Treat negative PYZ marshal sizes as format failures so the opaque PYZ recovery applies. - Report the browser environment limitation for Electron target lists. - Treat an overflowing ELF program-header offset in the pwntools bridge as a format failure. Fixes #5716 Fixes #5917 Fixes #5932 Fixes #5950 Fixes #5968 Fixes #5974 Fixes #5981 Fixes #6094 Fixes #6114 Fixes #6120
3b942bc to
d1f1f63
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d1f1f63118
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| ...input.left_observations.map( | ||
| (value, position) => [["left_observations", position], value] as const, | ||
| ), |
There was a problem hiding this comment.
Stream observation roots instead of expanding them
For requests with a large left_observations or right_observations array, these eager maps allocate a tuple and a separate path array for every element before the first root is examined, even if left itself is invalid. NativeMatchingAdmission has charged only the input representation, not this expanded object graph, so a request near the 96-MiB allowance can exceed the advertised memory bound and OOM instead of returning the typed input/resource failure; yield each (path, value) pair lazily or explicitly charge this expansion.
AGENTS.md reference: AGENTS.md:L81-L81
Useful? React with 👍 / 👎.
| const leftRead = readEvidence(resolved.value.left); | ||
| if (!leftRead.ok) | ||
| return server.delivery.toCallToolResult(leftRead, contract); | ||
| const rightRead = readEvidence(resolved.value.right); |
There was a problem hiding this comment.
Reuse authenticated Evidence in comparison
When compare_functions receives large inline analyze_function Evidence, each new readEvidence call traverses the full record and recomputes its canonical evidence ID, but the callback later passes the original values to parseFunctionEvidence, which calls readEvidence again. Inline contract values are not immutable cache entries, so successful comparisons now validate, hash, and copy both dossiers twice, adding avoidable CPU, memory, and synchronous work before runDerivedOperation's cancellation yield; parse each side once and reuse the resulting authenticated snapshot for both the kind check and comparison.
AGENTS.md reference: AGENTS.md:L53-L54
Useful? React with 👍 / 👎.
| return Number(recorded) === items.length | ||
| ? body | ||
| : replaceAt(body, pointerTo(name), String(items.length)); |
There was a problem hiding this comment.
Paged lists report wrong totals
A new paged query can report the page length as the full total. Capture /api/items with three items and total: "03", followed by ?limit=1 with one item and the same total. A later limit=2 call can select the first recorded response. This branch changes its total to "2". renderQueryList cannot restore 3 because queryTotalCount rejects padded strings.
Previously, "03" stayed unchanged. Clients can now stop paging before fetching the last item. Keep unsupported query totals out of page counters, or teach the query renderer how to update them.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/domain/analysisView/environmentStateRules.ts
Line: 663-665
Comment:
**Paged lists report wrong totals**
A new paged query can report the page length as the full total. Capture `/api/items` with three items and `total: "03"`, followed by `?limit=1` with one item and the same total. A later `limit=2` call can select the first recorded response. This branch changes its total to `"2"`. `renderQueryList` cannot restore 3 because `queryTotalCount` rejects padded strings.
Previously, `"03"` stayed unchanged. Clients can now stop paging before fetching the last item. Keep unsupported query totals out of page counters, or teach the query renderer how to update them.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| const leftRead = readEvidence(resolved.value.left); | ||
| if (!leftRead.ok) | ||
| return server.delivery.toCallToolResult(leftRead, contract); | ||
| const rightRead = readEvidence(resolved.value.right); |
There was a problem hiding this comment.
Inline comparisons repeat expensive checks
Successful inline comparisons now authenticate each Evidence record twice. These new readEvidence calls copy and hash the payload, but the later parseFunctionEvidence calls still receive resolved.value.left and resolved.value.right and repeat that work.
Large function dossiers therefore get another full copy and hash on the server's main thread, delaying other requests. Parse each side once and reuse the result for the kind checks and comparison.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/server/registerFunctionComparisonTool.ts
Line: 47-50
Comment:
**Inline comparisons repeat expensive checks**
Successful inline comparisons now authenticate each Evidence record twice. These new `readEvidence` calls copy and hash the payload, but the later `parseFunctionEvidence` calls still receive `resolved.value.left` and `resolved.value.right` and repeat that work.
Large function dossiers therefore get another full copy and hash on the server's main thread, delaying other requests. Parse each side once and reuse the result for the kind checks and comparison.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| diagnostics: { | ||
| source_path: path, | ||
| phase, | ||
| io_message: response.message, |
There was a problem hiding this comment.
Cleanup hides worker read failures
The new I/O details disappear if worker cleanup also fails. analyze then returns #cleanupError, whose execution_failure keeps only original.message and captured output—not original.diagnostics. The new ProviderAdapterError.message is generic, so the returned cleanup_incomplete error loses the source path, phase, and I/O message.
Previously, those details survived inside AnalysisOutputError.message. Preserve the original error's details when building the cleanup error so users can still tell which read failed.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/javascript/analysis/JavaScriptAnalysisWorker.ts
Line: 1065-1068
Comment:
**Cleanup hides worker read failures**
The new I/O details disappear if worker cleanup also fails. `analyze` then returns `#cleanupError`, whose `execution_failure` keeps only `original.message` and captured output—not `original.diagnostics`. The new `ProviderAdapterError.message` is generic, so the returned `cleanup_incomplete` error loses the source path, phase, and I/O message.
Previously, those details survived inside `AnalysisOutputError.message`. Preserve the original error's details when building the cleanup error so users can still tell which read failed.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
Summary
Ten input and diagnostic defects where REA reported the wrong cause, operation, or
recovery for a request it refused or recovered from. Each fix moves the attribution
to the boundary that owns the fact:
left,right, or the observation index) on both the MCP and CLI bundle paths. Fixes [Bug] match_native_functions loses malformed Evidence field paths in MCP and CLI #5950.compare_functionsreports wrong-kind Evidence per side as input issues instead of ageneric integrity mismatch. Fixes [Bug] compare_functions misclassifies authentic wrong-kind Evidence as an integrity failure #5932.
command, stdout, stderr, probe result). Fixes [Bug] ADB and Apktool capability refusals omit collected configuration diagnostics #6094.
open_binarysnapshot read reportsopen_binary, notread_evidence_file.Fixes [Bug] Snapshot-read cancellation attributes open_binary to read_evidence_file #5968.
ProviderAdapterErrorwith source path,phase, and I/O message instead of
unreadable_output. Fixes [Bug] JavaScript worker I/O failures become unreadable provider output #6114.applies instead of aborting sibling inventory. Fixes [Bug] Negative PYZ marshal sizes abort sibling inventory as a resource limit #6120.
limitation, as inspect already does. Fixes [Bug] Electron target-list Evidence omits the observed browser environment #5917.
not an execution failure. Fixes [Bug] inspect-binary-layout classifies an overflowing ELF program-header offset as execution_failure #5716.
Problem and expected behavior
Each case was reproduced or traced in the current base (
01788bac8):an issue with
path: []. The CLI bundle loader had the same gap and emitted nodetails.issues.compare_functionskind gate constructedEvidenceIntegrityErrorwith no side.providerConfigurationRefusaldroppedfailure.diagnostics, although the erroroptions and projection already support them.
inspectAdbClienthard-codedinspect_adb_client;readAnalysisSnapshotand the JSONreaders hard-coded
read_evidence_file.environmentStateGatecompared counters with===, excluding strings thatcountOfaccepts.
#protocolFailuresent every non-resource worker failure, includingio, toAnalysisOutputError.MarshalSubsetreturnedlimitfor negative sizes;PyzArchiverecovers onlyformat.list-electron-targetsgated the environment on"target" in result, which listresults lack.
layout_impl.pyomittedOverflowErrorfrom the structural-parse tuple.Change and scope
Each change is local to the owning boundary, with no new contracts, providers, or
process launches:
malformedInlineEvidenceinNativeMatchingBundleSources.tsis used bythe loader root loop and the MCP-path
resolve.readAnalysisSnapshot(new optionalparameter defaulting to
read_evidence_file) andreadJsonObjectMembersFile.renderStateListkeeps a string counter as a string, so the gate'ssame(render(...), body)check still accepts digit-string totals.Not included: no tool schema or Evidence shape change; no change to ADB, Apktool, or
pwntools launch behavior; no unrelated cleanup. One new
max-paramswarning isintroduced in
src/application/JsonFiles.ts(warning only; the operation parameter mustreach the cancellation site).
Contribution scope: not applicable. These are fixes within existing boundaries.
Contract and boundary impact
native input parser and bundle loader, the function-comparison input gate, the ADB and
Apktool configuration projection, the snapshot reader, the JavaScript worker protocol
mapping, the PYZ marshal classifier, the environment-state gate, the Electron evidence
projection, and the pwntools bridge classifier).
boundaries).
as described under Compatibility.
Linux x64). Other providers are unchanged apart from the refusal diagnostics above.
Electron target-list Evidence now carries the same environment and limitation fields
that inspect Evidence already carries.
not applicable. Cleanup and ownership paths are untouched.
docs/public/product-catalog.json), package, or installation impact:none. No generated catalogs, skills, or dependency manifests are edited.
Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.
Evidence and regression coverage
Evidence type: executed tests and base-revision reproductions. Source-derived conclusions
are noted where a test was not run.
tests/boundary/binaryDiagnostics/pwntoolsLayoutProvider.test.ts(real pwntools bridge; gated onREA_PWNTOOLS_PYTHON)tests/boundary/cli/electronCli.test.tstests/boundary/mcp/functionComparisonReferenceFactsMcp.test.tstests/acceptance/tools/nativeFunctionMatching.test.ts(MCP cases plus one CLI case)tests/boundary/filesystem/analysisSnapshotInput.test.tstests/boundary/javascript/javascriptSourceAnalysisWorker.test.ts(real worker process with deterministic input removal)tests/process-global/apktoolEnvironment.test.tssrc/adb/AdbVersionProbe.test.tssrc/artifacts/pyinstaller/MarshalSubset.test.tssrc/domain/analysisView/environmentStateView.test.tstests/boundary/providers/adb/adbCommandFinalization.test.ts(call-site signature updates only)CLI and stdio-MCP cases,
distwas rebuilt from base first), then with the fix. All tenfailed on base and passed with the fix:
execution_failurewhereinvalid_requestwas expected.environmentor limitation.details.issues.path: []or no issues.read_evidence_file.countersempty for a string total.resource_constraintattributed toinspect_adb_client.diagnostics.unreadable_output.limitwhereformatwas expected.list-adb-devices --jsonwith an unrecognized version launcher now returnscapability_unavailablewithdetails.diagnosticscontainingselected_binary,path_source,version_probe: "unrecognized_output",stdout, andstderr.match-native-functionswithleft: "not-evidence"and--source_bundlereturnsinvalid_requestwithdetails.issues: [{path: ["left"], reason: "invalid_value", ...}].(substitute launchers only).
REA_PWNTOOLS_PYTHONpoints at pwntools 4.15.0,pyelftools 0.33, and Unicorn 2.1.2. The default vitest run skips it, and CI's
real-binary-layoutworkflow runsverify:binary:layout, not this file. It was runlocally against a venv that is not committed.
open_binarycancellation test pre-aborts the signal at the snapshot reader; itdoes not race a live MCP cancellation.
executed (only the output-limit path).
For evidence-bearing changes:
Validation performed
Merge follow-up:
mainwas merged into the branch (f2a0da223) to resolve conflicts insrc/application/JsonFiles.tsandsrc/javascript/analysis/JavaScriptAnalysisWorker.ts. After the merge:node scripts/run-typescript.mjs --noEmit— exit 0.npm run test:focused -- <12 files covering the changed boundaries>— 12 files, 164 passed, 2 skipped.npx oxlinton the two conflicted files — 0 errors; warnings only.npx oxfmt --checkon the two conflicted files — formatted.Earlier validation (before the merge):
Each entry lists a command that ran and its observed result. Run in the worktree on Node
v22.23.1 (within
engines).npm run build:cached— exit 0 (rebuilt several times, including from base source forthe CLI and stdio-MCP base runs; final
distis from the fixed tree).npx vitest run src/artifacts/pyinstaller/MarshalSubset.test.ts src/domain/analysisView/environmentStateView.test.ts src/adb/AdbVersionProbe.test.ts tests/boundary/providers/adb/adbCommandFinalization.test.ts tests/boundary/filesystem/analysisSnapshotInput.test.ts tests/process-global/apktoolEnvironment.test.ts tests/boundary/mcp/functionComparisonReferenceFactsMcp.test.ts tests/boundary/cli/electronCli.test.ts tests/boundary/javascript/javascriptSourceAnalysisWorker.test.ts tests/acceptance/tools/nativeFunctionMatching.test.ts --maxWorkers 2— 10 files, 115 tests passed.REA_PWNTOOLS_PYTHON=<local pwntools 4.15.0 venv>/bin/python npx vitest run tests/boundary/binaryDiagnostics/pwntoolsLayoutProvider.test.ts— 35 passed, 1 skipped (unsupported-host case).npx vitest run tests/boundary/binaryDiagnostics/pwntoolsLayoutProvider.test.ts(no runtime configured) — 34 passed, 2 skipped.npm run typecheck— exit 0.npx oxlint <27 changed files>— exit 0, 0 errors; pre-existing warnings plus one newmax-paramswarning insrc/application/JsonFiles.ts.npx oxfmt --check <27 changed files>— exit 0.lint-staged) — exit 0.list-adb-devices --json(unrecognized launcher) andmatch-native-functionswith malformedleftboth returned the expecteddetailsshown above.Not run: the full test suite,
npm run check:pr, and any real-provider workflow.Compatibility, safety, and release
error changes:
compare_functionswrong-kind Evidence:invalid_requestwith per-side issues(previously
evidence_integrity_mismatch).execution_failure(previouslyunreadable_output).(previously the whole artifact failed with
truncated/limit).details.diagnostics.Internal signatures changed:
inspectAdbClient(addsoperation),readAnalysisSnapshot(optional trailing
operation),readJsonObjectMembersFile(addsoperation).gated case.
access, or network access. The JavaScript worker I/O diagnostic carries the source path and
the worker's I/O message, text that was previously embedded in the output error message.
Other redaction is unchanged.
Author readiness
Human owner: @agorevski
Before merge
type(scope): outcome.