Skip to content

fix(artifacts): preserve iNES shutdown ownership and I/O failures - #10152

Closed
ShuaixinHuang wants to merge 4 commits into
morluto:mainfrom
ShuaixinHuang:fix/ines-reader-retirement
Closed

ShuaixinHuang wants to merge 4 commits into
morluto:mainfrom
ShuaixinHuang:fix/ines-reader-retirement

Conversation

@ShuaixinHuang

@ShuaixinHuang ShuaixinHuang commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Superseded by #10554 at the author’s explicit request. The replacement carries the same focused lifecycle/I/O fix on main 8578daf8b; this PR remains closed to preserve its review and CI history.


Latest main integration — 2026-11-14

Merged main 5815178a8d581fa81a9422cdfb9f86dd5cb913d7 at 36ddb7432be8f72feed3f70360f426d18e25365b. Kept this PR's scope-admitted header/inventory work, joining of pending I/O/readable retirement, post-await state checks and primary read-failure ownership. Main's independent paused-inventory controls are retained. The moved #assertOpen has one definition at main's location; relative to the previously published reader, the integrated production-file difference is only that method's placement. The shared physical-read failure state machine is byte-identical to the published PR.

Fresh qualification: 353 passed / 15 focused files, including real compiled CLI/stdio MCP, iNES cancellation/closure/identity, descriptor failure and retry, and shared ASAR/FIT/Bun/Deno/process consumers. check:ci:fast 3 tasks passed; all four changed TS files type-aware lint 0 errors / 5 advisory warnings; discovery and docs passed (9 README tests). Normal commit/pre-push hooks, final diff review and all five PR-file hashes passed. No regression, retry, timeout or skip was removed/relaxed to resolve the conflict.

Hosted CI for the new merge head is pending. Earlier baseline and CI evidence below qualifies only its named older heads, not this merge commit. No fresh monolithic full check, native Windows/macOS, real Bun target or emulator qualification is claimed; initial human declarations remain recorded.


Closing an iNES reader could release its extraction-owned descriptor while a region read or final source check was pending. Its stream could deliver bytes after close() resolved, and a paused inventory could continue yielding entries. Shutdown also exposed a shared read-error forwarding gap: cancellation could replace an already rejected physical read with unavailable/cancelled, losing its I/O classification and exact cause.

The reader now uses ArtifactResourceScope for admission, stops region producers, and joins producer completion plus readable retirement before releasing its owned descriptor. Async final identity validation is admitted independently, so consumer destruction cannot release its descriptor early. Borrowed inventory descriptors stay open; failed owned closes retain the same retry owner. The unowned nested generator is replaced with a bounded pipeline; identity, length and byte-exact reconstruction checks remain.

Two automated-review findings were reproduced and repaired at their owners:

  • Recheck reader/caller state after awaited source validation, before allocating streams. Otherwise closure in that continuation window could create an aborted source without a pipeline error listener. PositionalArtifactReader.open() already performs this check.
  • Model shared descriptor reads as idle/pending/failed. A rejected read stays failed while Readable.from forwards its rejection; lifecycle/caller cancellation cannot overwrite that physical failure. Successful, unread and buffered cancellation retain their existing behavior.

This is an existing offline-reader lifecycle/provenance repair. No new provider, execution authority, public schema, dependency, budget, installation behavior or generated metadata. Maintainer scope decision: not applicable. Source inspection and targeted searches found no matching fix: open #8689 only adjusts a different timestamp fixture; merged #9649/#9641/#10081 address earlier failure-provenance boundaries. No separate issue was opened.

Executed evidence

Head e49bb2f25, latest fetched main/base a01674377; Linux x64, Node 24.22.1 / npm 11.9.0, source-authored cartridge bytes:

  • Unchanged main production, only the two final test files copied: 18 failed / 75 passed, plus one uncaught cancellation error. No test or acknowledgement timeout. The three-suite command was node scripts/run-exact-tests.mjs run tests/boundary/filesystem/inesCancellation.test.ts tests/boundary/filesystem/inesArtifact.test.ts tests/boundary/filesystem/fileHandleChunks.test.ts.
  • Review controls: on ea9aa396a, post-validation closure/cancellation produced 2 failed / 44 passed and one uncaught closed-reader error. On dd7264075, final error-forwarding regressions produced 4 failed / 53 passed. These controls use real identity checks and real native write-only descriptor failures, plus injected EIO at an actual iNES descriptor method; same/distinct cancellation reasons are covered.
  • Fixed consumers: npm run test:focused -- <15 exact test files> passed 348 tests across iNES filesystem/domain/compiled CLI/real stdio MCP, resource ownership, Godot, shared descriptor reads, ASAR, FIT, Bun/Deno readers, process inspection and capture. Regression coverage includes pending and failed I/O, final validation, consumer destruction, unread/buffered streams, borrowed/owned descriptors, cleanup retry and paused iteration.
  • npm run check:fast, normal commit/pre-push hooks, formatting and git diff --check: passed. Typed lint via node scripts/ci/static-check-report.mjs typed-lint on all four changed TS files: zero errors, five pre-existing warnings. Final checked-file SHA-256 inputs were verified unchanged.
  • Initial-head npm run docs:check: passed, including nine README tests; docs have not changed since. Initial-head npm run check passed its pre-typed stages but its monolithic typed-lint stage was SIGKILLed at the cloud 8 GiB ceiling, including a lower-GC retry. It is not reported as passing. The unchanged checker/config/rules subsequently passed all 7,207 default-inventory files in nine serial batches (0 errors, 4,986 advisory warnings), with exact scope/digest verification; follow-up changes were checked again above.
Exact focused-test selection
npm run test:focused -- \
  tests/boundary/filesystem/inesCancellation.test.ts \
  tests/boundary/filesystem/inesArtifact.test.ts \
  tests/acceptance/inesContainer.test.ts \
  src/domain/inesContainer.test.ts \
  src/artifacts/ArtifactResourceScope.test.ts \
  src/artifacts/GodotPckArtifactReader.test.ts \
  tests/boundary/filesystem/fileHandleChunks.test.ts \
  src/artifacts/ArtifactFileSource.test.ts \
  src/artifacts/FitArtifactReader.test.ts \
  src/artifacts/bun/BunStandaloneArtifactReader.test.ts \
  src/artifacts/deno/DenoStandaloneArtifactReader.test.ts \
  src/artifacts/deno/DenoStandaloneArtifactReader.boundaries.test.ts \
  src/process/ProcessInspectionCleanup.test.ts \
  src/process/capture/ProcessCaptureRead.test.ts \
  tests/boundary/filesystem/asarStreamingAllocation.test.ts

Scheduling gates/microtasks establish ordering at production boundaries, not naturally occurring race frequency. Local native Windows/macOS, real Bun execution and emulator behavior were not exercised. No game ROM or target execution was used. Current-head CI passed, including CI required, source/static/build/docs, all eight built-test shards, portable tests, Linux native packaging, Windows native-control cross-build, APK verification and the real macOS Apple lane. The macOS lane explicitly ran the iNES CLI/MCP/source-boundary suites. This reports the workflow's selected lanes; skipped deep/provider/platform lanes remain visible in the run. Automatic re-review of e49bb2f25 completed with no findings and no unresolved findings. Both earlier valid review threads were fixed and resolved.

Previous-head lane successes are not counted as current-head passes. Initial CI's Apple lane exceeded its 15-minute job limit (confirmed by its check annotation); the current-head Apple lane and complete workflow passed.

Author readiness

Human owner: @ShuaixinHuang

The human owner explicitly confirmed review of the final head e49bb2f2544b633c0aef1a38776925b5a31443c9 and instructed that this PR be ready for maintainer review. All three declarations below are confirmed by that instruction.

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-14T02:34:59.261980Z 36ddb74 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ea9aa396a7

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/artifacts/InesArtifactReader.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dd72640758

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/artifacts/InesArtifactReader.ts Resolved
@ShuaixinHuang ShuaixinHuang changed the title fix(artifacts): retain iNES read ownership through shutdown fix(artifacts): preserve iNES shutdown ownership and I/O failures Nov 12, 2026
@greptile-apps

greptile-apps Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no blocking issue was found.

Summary

The PR keeps iNES reads and final source checks owned until shutdown finishes. It also preserves physical read errors when cancellation arrives before the stream forwards them.

  • The iNES reader stops region work before it releases an owned descriptor.
  • A rejected file read stays the reported error when cancellation races it.

Diagram

sequenceDiagram
  participant Caller
  participant Reader as InesArtifactReader
  participant Scope as ArtifactResourceScope
  participant Stream
  participant File as Owned descriptor
  Caller->>Reader: open(entry)
  Reader->>Scope: Admit read and stream ownership
  Reader->>Stream: Start bounded pipeline
  Caller->>Reader: close()
  Reader->>Stream: Abort lifecycle
  Reader->>Scope: Stop admission and join work
  Stream-->>Scope: Producer and readable retire
  Scope-->>Reader: Work settled
  Reader->>File: Close owned descriptor
  Reader-->>Caller: Shutdown complete
Loading

Reviews (2) · Last reviewed commit: "chore: merge main while preserving iNES ..." · Reviewed by Greptile

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 bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants