Skip to content

fix(snapshot): classify non-object roots as invalid content - #2685

Merged
morluto merged 1 commit into
morluto:mainfrom
jiangjiang248:fix/snapshot-root-classification
Oct 13, 2026
Merged

morluto merged 1 commit into
morluto:mainfrom
jiangjiang248:fix/snapshot-root-classification

Conversation

@jiangjiang248

Copy link
Copy Markdown
Contributor

Fixes #2675

Summary

Readable snapshots containing [], null, or scalar roots currently return execution_failure with reason io and 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 TypeError after successfully reading a non-object JSON root. JsonFiles consequently 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 invalidJson result at both root checks in readJsonObjectFile. The shared Evidence-file boundary then reports evidence_integrity_mismatch / invalid-json. The change stays at the producing boundary; it does not broaden catch clauses or reinterpret arbitrary TypeErrors 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

  • Semantic owner and earliest changed stage: src/application/JsonInputFile.ts, object-root validation after JSON decoding.
  • Contribution scope fit and linked maintainer decision: ordinary correction within existing read-only snapshot loading; advance scope decision not applicable.
  • CLI and MCP/tool-catalog contract: existing error vocabulary, schemas, and commands retained. Only erroneous rejection classification changes.
  • Provider, bridge, target-format, or platform compatibility: provider-independent; verified on Windows with Node 24.18.0 and npm 11.16.0.
  • Evidence, artifact, provenance, or reconstruction contract: valid snapshot decoding and snapshot-member validation retained; rejected input bytes remain unchanged and the root-shape cause message is preserved.
  • Target selection, authority, upstream behavior, and cleanup details: same selected regular file and existing file-handle ownership boundary; no new execution, mutation, or provider authority.
  • Generated metadata, package, or installation impact: none; no schema, package, authored skill, or generated-catalog change. Existing documentation and contract vocabulary remain applicable.

Expected effects:

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added: tests/boundary/filesystem/analysisSnapshotInput.test.ts.
  • Base reproduction: on 6a05248d464387c0ce4ec1577b4c1b24d3d355c7, the new suite produced 10 failed / 3 passed. All ten non-object-root cases returned execution_failure / io instead of the expected content classification. The final suite passes 13/13.
  • Representative production error projection after the fix, observed through 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

  • Breaking changes or migration steps: none; callers now receive the existing content-error classification for previously misclassified documents.
  • Real Hopper/Ghidra, browser, or OS coverage: Windows filesystem boundary only; no real-provider claim.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: no new capability or authority; no private targets, credentials, generated outputs, or binaries included.

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

  • 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.

@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-13T07:37:02.150616Z 5e3e312 PR opened
ℹ️ 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 PR appears safe to merge; no actionable issue was found.

Summary

readJsonObjectFile now reports arrays, null, and scalar roots as invalid content instead of filesystem failures.

  • Readable non-object snapshot roots report as invalid content.

Reviews (1) · Last reviewed commit: "fix(snapshot): classify non-object roots..." · Reviewed by Greptile

@morluto
morluto merged commit 9cf49c7 into morluto:main Oct 13, 2026
1 check passed
@morluto morluto mentioned this pull request Oct 13, 2026
3 tasks done
@morluto morluto added the bug Something isn't working label Oct 14, 2026
@morluto

morluto commented Oct 15, 2026

Copy link
Copy Markdown
Owner

@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!

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(snapshot): non-object JSON roots report file-access failures

2 participants