Repository navigation
fix(snapshot): classify non-object roots as invalid content - #2685
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. |
|
|
@jiangjiang248, thanks for fixing the snapshot error path. An array or null root now gets a content error instead of misleading file-permission advice. Welcome to REA! |
Fixes #2675
Summary
Readable snapshots containing
[],null, or scalar roots currently returnexecution_failurewith reasonioand permission advice. Classify these rejected documents as invalid content instead, consistently for native and streamed JSON reads.Problem and expected behavior
The object-member reader throws an unclassified
TypeErrorafter successfully reading a non-object JSON root.JsonFilesconsequently treats it as a filesystem exception. A document-shape rejection should take the existing typed input-error path, retain its explanation, and leave file-selection failures distinct.Change and scope
Return the existing
invalidJsonresult at both root checks inreadJsonObjectFile. The shared Evidence-file boundary then reportsevidence_integrity_mismatch/invalid-json. The change stays at the producing boundary; it does not broaden catch clauses or reinterpret arbitraryTypeErrors as malformed input.Add filesystem-boundary regressions using real temporary files and the production snapshot reader and error projection. Exercise arrays, null, numbers, strings, and booleans, both with small input and with 9 MiB of whitespace to select streaming. Controls cover syntax errors, missing snapshot members, valid snapshots, missing files, directories, and unchanged input bytes.
Contract and boundary impact
src/application/JsonInputFile.ts, object-root validation after JSON decoding.Expected effects:
Evidence and regression coverage
tests/boundary/filesystem/analysisSnapshotInput.test.ts.6a05248d464387c0ce4ec1577b4c1b24d3d355c7, the new suite produced 10 failed / 3 passed. All ten non-object-root cases returnedexecution_failure/ioinstead of the expected content classification. The final suite passes 13/13.projectAnalysisError:{ "code": "evidence_integrity_mismatch", "message": "Evidence file is not valid JSON. Repair or recreate the file and try again.", "details": { "reason": "invalid-json" } }This excerpt shows selected projection fields, not a captured CLI/MCP transport response.
Remaining proof gaps: no installed-package CLI/MCP session, real Hopper/Ghidra/IDA lane, Linux/macOS run, or complete test suite was executed. This fix concerns the shared file/error boundary and needs no analysis engine.
Observed, derived, and inferred claims remain distinguishable.
Artifact identity, source provenance, and failed attempts remain preserved.
Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.
Validation performed
npm run test:focused -- tests/boundary/filesystem/analysisSnapshotInput.test.ts— 13 passed on the final diff; also builds the runtime and skill prerequisites.npx --no-install vitest run tests/boundary/filesystem/analysisSnapshot.test.ts tests/boundary/filesystem/cliJsonInput.test.ts --testNamePattern "analysis snapshot member decoding|analysis snapshot file ownership|CLI JSON streamed input"— 27 passed, 10 outside-selection tests skipped. Includes existing cancellation, file ownership, syntax, UTF-8, and streaming controls.npm run check— passed: typecheck, lint, format, Knip, metadata, module boundaries, and architecture guards. Lint reported 0 errors and repository warnings.npm run verify:test-discovery— all 1,034 test files discovered exactly once.npx --no-install oxfmt --check src/application/JsonInputFile.ts tests/boundary/filesystem/analysisSnapshotInput.test.ts— passed.Compatibility, safety, and release
AI assistance
Codex assisted with issue investigation, implementation, regression tests, validation, and this PR description. The change is submitted through the authorized contributor account; this disclosure does not claim personal manual authorship or human mastery of the codebase.
Before merge
type(scope): outcome.