Skip to content

feat(artifacts): name which ASAR integrity check failed on the reader failure - #11021

Merged
morluto merged 3 commits into
mainfrom
feat/asar-integrity-check
Nov 15, 2026
Merged

morluto merged 3 commits into
mainfrom
feat/asar-integrity-check

Conversation

@morluto

@morluto morluto commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Summary

Refs #10508 (Phase 6.1). The ASAR reader raises ArtifactReaderFailure("integrity", ...) for ten different consistency checks, from "metadata changed since inventory" to "unpacked entry changed before read". Only the message said which. The failure now carries integrityCheck (entry-metadata, unpacked-entry-identity, container-identity, foreign-entry, read-coverage, declared-size, reader-ownership), and the ASAR tests assert it instead of matching message sentences.

Problem and expected behavior

  • asarStreamingAllocation.test.ts and asarInventoryFreshness.test.ts told apart a stale member, a replaced unpacked file and a replaced container only by message text. A consumer had the same problem.
  • Expected: the reader states which check failed as a typed field; the field survives cleanup wrapping, so a failed close does not erase it.

Change and scope

  • ArtifactReader.ts: ArtifactIntegrityCheck union and optional integrityCheck on ArtifactReaderFailureOptions / ArtifactReaderFailure. ArtifactReaderFailure.withCleanup carries it like boundary and readerLimit.
  • AsarArtifactReader.ts, AsarEntryStream.ts: every integrity failure names its check. Messages are unchanged.
  • AsarArtifactReader.#snapshotPath: a missing snapshot was reported as an integrity failure, but it is reachable only when close() is queued between prepareContainer() and the following entries() or openContainer() operation. It now fails as unavailable ("ASAR snapshot was closed"), like the sibling closed-inventory check. reader-ownership remains only for a read stream over a handle the reader does not own, which no public sequence reaches (the handle is adopted under the same serialized operation).
  • Tests: 4 assertions switch from message sentences to integrityCheck; two keep stringContaining(entry.path), since the member path is a fact under test.

Not included:

  • Other readers' integrity failures (DMG, directory, release exposure, PE, ...) leave the field undefined. Their tests in this slice do not read the check from prose; each would be its own owner change.
  • Public CLI/MCP projection: integrity failures project as artifact_changed and similar codes, without a check field. Adding it there means changing every projection site (StableArtifactFailure, native and Rust providers, ...), which is a separate change. Rebuild sites outside withCleanup (for example ProcessCli.artifactFailureFacts) do not copy the field yet; there it reads as undefined (not named), not as a wrong value.

Follow the contribution scope.
Unresolved scope, authority, side effects, or required verification block
integration. Link the required maintainer scope decision for new providers or
capabilities involving target execution, injection, mutation, or protection
recovery; ordinary fixes within existing boundaries may state "not applicable".
Draft PRs may leave the scope decision pending and the readiness and merge checklists
unchecked. Maintainers can help resolve open questions.

Contract and boundary impact

  • Semantic owner and earliest changed stage: AsarArtifactReader / AsarEntryStream (producer), ArtifactReaderFailure (carrier)
  • Contribution scope fit and linked maintainer decision: not applicable (additive in-process failure fact, Phase 6.1 tracker [Design] Assert structured remediation facts instead of guidance prose #10508)
  • CLI and MCP/tool-catalog contract: none
  • Provider, bridge, target-format, or platform compatibility: none
  • Evidence, artifact, provenance, or reconstruction contract: none
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): cleanup wrapping keeps the field; no lifecycle change
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact (CI generates and validates ignored catalogs and skills/; edit authored instructions in .agents/skills/reverse-engineer-anything/ and never commit build outputs): none

Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.

  • 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: 35 in the two boundary files before and after. src/artifacts/AsarEntryStream.test.ts goes from 2 to 5: the truncated-after-EOF case asserts declared-size, a table covers bytes over and under the header size (declared-size), and a source ending with incomplete coverage asserts read-coverage. asarInventoryFreshness.test.ts adds two lifecycle cases: an entry inventoried before close() and opened afterwards fails with foreign-entry; a close() queued behind preparation fails entries() and openContainer() as unavailable with no integrityCheck (before the fix: integrity / reader-ownership). reader-ownership itself is not asserted (unreachable, see above).
  • Mutation (run locally, then reverted): with foreign-entry replaced by entry-metadata at its site, the new stale-entry case fails. Earlier: with the constructor ignoring integrityCheck, 6 of 35 fail, including "preserves an unpacked identity failure when closing its handle fails", which goes through withCleanup.
  • Wall/CPU (npm run test:focused, after): 11.7 s wall, 15.7 s user, 3.5 s sys including build; vitest 1.5 s.
  • User-visible CLI/MCP output: none

For boundary fixes, identify the applicable boundary regressions
and lifecycle regressions
covered by the evidence above, and explain relevant gaps.

For evidence-bearing changes:

  • 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/asarStreamingAllocation.test.ts tests/boundary/filesystem/asarInventoryFreshness.test.ts: 35 passed
  • Same with the field dropped in the constructor: 6 failed (expected)
  • npm run test:local -- src/artifacts/AsarEntryStream.test.ts: 5 passed
  • After the close-race fix: npm run test:focused -- tests/boundary/filesystem/asarInventoryFreshness.test.ts tests/boundary/filesystem/asarStreamingAllocation.test.ts src/artifacts/AsarEntryStream.test.ts: 42 passed; the close-race case failed before the producer change (received integrity / reader-ownership)
  • npm run check:fast: passed

Compatibility, safety, and release

  • Breaking changes or migration steps: none
  • Real Hopper/Ghidra, browser, or OS coverage: macOS only
  • Package or release metadata impact: none
  • Security, privacy, process, or containment review: none

Author readiness

Human owner:

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

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 Nov 15, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

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

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-15T10:34:01.464537Z
We couldn’t complete this review. Comment @codex review to try again.
446f71c 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 Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] The PR appears safe to merge; no actionable defects remain in the reviewed changes.

Summary

Adds typed integrityCheck names to ASAR failures and preserves them when cleanup also fails.

  • ASAR integrity failures now name the check that stopped the read.
  • A closed ASAR snapshot now reports that the reader is unavailable.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[ASAR check fails] --> B[ArtifactReaderFailure with integrityCheck]
  B --> C{Cleanup also fails?}
  C -->|No| E[Caller receives named check]
  C -->|Yes| D[withCleanup copies integrityCheck]
  D --> E
Loading

Reviews (2) · Last reviewed commit: "fix(artifacts): report a close queued be..." · Reviewed by Greptile

Comment thread src/artifacts/AsarEntryStream.ts Resolved
@morluto
morluto force-pushed the feat/asar-integrity-check branch from b4e899e to 92c03c2 Compare November 15, 2026 10:29
@deskinsjerri1-commits

deskinsjerri1-commits commented Nov 15, 2026 via email

Copy link
Copy Markdown

…ailable

The missing-snapshot check was reachable when close() ran between a
prepareContainer() and the following entries() or openContainer()
operation, and reported a caller close as an integrity failure. Classify
it like the sibling closed-inventory check and cover foreign-entry with a
stale entry opened after close.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@morluto
morluto merged commit d8c0a71 into main Nov 15, 2026
14 of 17 checks passed
@morluto
morluto deleted the feat/asar-integrity-check branch November 15, 2026 11:35
@morluto morluto added area: evidence Evidence, artifacts, and reconstruction enhancement New feature or request labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: evidence Evidence, artifacts, and reconstruction enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants