Repository navigation
fix(artifacts): preserve iNES shutdown ownership and I/O failures - #11748
Conversation
…al-open-11154-20261116
…repair-11154-20261116 # Conflicts: # src/artifacts/InesArtifactReader.ts # tests/boundary/filesystem/fileHandleChunks.test.ts # tests/boundary/filesystem/inesCancellation.test.ts
…repair-11154-20261116
…file
The Windows-only case at `clientConfigurationEnvironment.test.ts:226` wrote
`rea_mcp_input_schema_profile: "full"`. That profile was retired: the reader
now refuses it ("REA_MCP_INPUT_SCHEMA_PROFILE accepts only \"compact\" …"),
so `configureClientConfiguration` returned `failed/readback` before writing
and the case failed on every Windows run, including main's own
`Windows capability and package lane`.
The case has no Windows dependency — it passes an explicit `configPath` and
the Kimi write dialect is the same everywhere — so it now runs on every
platform, which is what let the stale value rot unnoticed. The fixture keeps
the lowercase explicit key the case is about, with the supported value.
Verified on `main` `d6bcfc10`: the same fixture driven through
`configureClientConfiguration(..., "win32")` on this host reproduced
`{"status":"failed","reason":"readback"}` with the retired value and now
returns `{"status":"configured"}` with `compact`. The file's 75 cases pass
here (66 run, 9 platform-conditioned skips) and `check:fast` passes.
…alue-11154 # Conflicts: # tests/boundary/mcp/decompileAllCaveats.test.ts # tests/boundary/mcp/environmentServeMcp.test.ts
Codex Review Summary: ❌ FailedThis 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. |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
[Medium impact] The reviewed changes appear safe to merge. SummaryThe PR makes
DiagramsequenceDiagram
participant Caller
participant Reader as InesArtifactReader
participant Stream as Region stream
participant Scope as ArtifactResourceScope
participant File as Owned descriptor
Caller->>Reader: close()
Reader->>Stream: Abort with recorded shutdown reason
Reader->>Scope: close()
Scope->>Scope: Wait for admitted reads and source checks
Scope-->>Reader: Work settled
Reader->>File: close()
Reader-->>Caller: Closed, or close failure retained for retry
Reviews (7) · Last reviewed commit: "fix(artifacts): preserve first iNES stre..." · Reviewed by Greptile |
|
@morluto Could you please review this PR when you have time? As the author, I am finding the ongoing work of keeping these pending branches synchronized and revalidated a substantial maintenance burden. The current head's CI has passed, there are no unresolved inline review threads, and the PR description records the evidence and remaining validation limits. If this change is outside the project's priorities or scope, a clear direction would also help me avoid further unnecessary maintenance. Thank you. |
Co-authored-by: morluto <[email protected]>
The doctor readiness fixture and process-capture progress assertions are not required by descriptor retirement or I/O failure precedence. Restoring them, and the Ghidra installation test already merged in morluto#11732, leaves this change on the iNES reader, chunk reader, and their regressions. The unused artifact chunk helper import is removed. Co-authored-by: morluto <[email protected]>
Identity checks observe mtime, and a same-size overwrite inside one clock tick is indistinguishable from the original file. The admission test then reports a format error instead of source integrity. Age the fixture the same way the prefix race already does.
An unstored oversized command table is a truncated Mach-O load-command parse, projected as invalid_format. The old message lock named a sentence the parser no longer produces. Co-authored-by: morluto <[email protected]>
…ng case The standalone close test repeated the paused entries() refusal already covered by the close/cancel pair. The borrowed-descriptor stat stays on that close case. Co-authored-by: morluto <[email protected]>
The only content conflict was the Go provider's invalid_format issue. Both sides already omit the retired Mach-O prose lock; the typed truncation failure stays. Architecture layer counts still match the baseline. Co-authored-by: morluto <[email protected]>
Problem and fix
Opening an iNES region and then cancelling without consuming the returned stream can terminate the Node process, even when the caller handles errors on that public stream. The reader eagerly creates an internal descriptor stream but attaches its consumer inside a lazy generator. Cancellation reaches that hidden source before an error listener exists. Closing the reader also fails to retire buffered producers or join pending reads and final source validation.
Use the existing artifact resource scope to own producer completion and readable retirement, pipe through an immediately connected transform, and admit asynchronous final identity validation independently. Close cancels and joins admitted work before releasing an owned descriptor; borrowed descriptors stay with their owner, and failed closes retain retry ownership. The shared positional reader also preserves a physical I/O rejection when cancellation races its asynchronous delivery.
Scope and review follow-up
This is the existing replacement for #11739, requested by the human owner; earlier reproduction and review history remain in #11154. No replacement PR or new source push was made during the November 18 qualification.
The valid final-progress finding is addressed: successful
capture_process_scenariomust retain cleanup facts in the last notification. Only preceding progress is bounded; the timeout path retains its separate cleanup lookup because error delivery can append a failure notification.The published branch includes main
8ffea11ee, the explicitly declared #11732 missing-installation JVM-probe prerequisite, and the doctor fixture's SIGTERM-readiness ordering. These additions still require review and are not represented as merged upstream. Open #10674 adds NES 2.0 support and overlaps the iNES reader, documentation and regressions; this fix retains classic iNES scope and does not integrate that capability.Reproduction and executed validation
Linux, Node 24.22.1 / npm 11.16.0. Latest main fetched and checked:
d72dfb8c69376c14a0fcc386dc3f7d639b4abc97.Fresh production-boundary reproduction uses a real 16,400-byte classic iNES file (one PRG bank; SHA-256
dc0d9711c5cbfa24c5fb8091cbbe4df8aeb732ecb57229999c9207fa2637f485), a native file descriptor, and the source loader. Enumerate entries, open the header region with an AbortSignal, attach an error listener to the returned stream, leave it unread, then abort and allow two event-loop turns. Untouched main exits 1 with an unhandled internal stream error. Callingreader.close()before the abort also exits 1. Both cases exit 0 with the public stream destroyed after applying the published core fix; explicit public-stream destruction followed by abort also exits 0. These probes were run independently of Vitest.For the test pair, an isolated main checkout received only this PR's two regression test files, leaving production code unchanged:
npm run test:focused -- tests/boundary/filesystem/inesCancellation.test.ts tests/boundary/filesystem/fileHandleChunks.test.ts— 17 failed / 42 passed, plus 1 uncaught cancellation error.af98ad728d0af726e934d18ef2a1c896bbc64e43: iNES reader, positional chunk reader, their two regression files, and iNES documentation. Verified all five tested files byte-for-byte against that published head.npm run test:focused -- tests/boundary/filesystem/inesCancellation.test.ts tests/boundary/filesystem/inesArtifact.test.ts tests/boundary/filesystem/fileHandleChunks.test.ts tests/acceptance/artifactExtractionCoverage.test.ts— 100 passed / 4 files, including all 59 tests in the failing pair; required runtime build passed.npm run check:fast— typecheck/lint and architecture guards passed (2,871 source files).npm run docs:check— six tasks and eight consistency tests passed.node scripts/ci/static-check-report.mjs typed-lint src/artifacts/InesArtifactReader.ts src/filesystem/readFileHandleChunks.ts tests/boundary/filesystem/inesCancellation.test.ts tests/boundary/filesystem/fileHandleChunks.test.ts— four files, 0 errors / 7 advisory warnings.git diff --check— passed.Coverage includes pending reads, I/O/cancellation precedence, final source validation, unread and buffered stream retirement, paused inventory closure, borrowed descriptors and failed-close retries. Extraction coverage also passed against the latest-main composition.
Earlier qualification of the full published branch at
af98ad728ran the doctor-cancellation, file-handle, iNES-cancellation and process-progress suites: 72 passed / 4 suites, plus required runtime build, fast checks, docs checks and diff checks. This is separate from the fresh five-file core composition above.Hosted checks and limitations
CI run 43890844606 completed successfully for the exact published head
af98ad728d0af726e934d18ef2a1c896bbc64e43, including the required CI gate, static/source/build/docs checks, 12 selected shards and the selected platform baseline lanes. This qualifies the published branch, not a newly pushed merge withd72dfb8c. Greptile reported 5/5 with no actionable findings; there are no inline review threads. Codex's current-head attempt failed with an explicit quota limitation and is not counted as a completed review.The fresh latest-main run covers the five core files, not a fresh integration of all nine published files, including the JVM prerequisite and doctor/process-test changes. No fresh full monolithic local gate/suite, full-repository typed lint, or local native Windows/macOS run is claimed. The shared environment has an 8 GiB limit; full-repository typed lint previously exhausted it during other qualification and was not repeated here. No public schema, provider, execution authority or installation policy is added.
Stream interruption order
At
33c24cc1ab, iNES uses one recorded interruption across reading, transform delivery, and final source validation. With close requested first, a later caller abort preserves the shutdown result even when source validation was already pending. The inverse order retains typed caller cancellation. Tests also cover admitted physical errors and the join of late validation before descriptor retirement. The exact revision passed 136 focused tests with two existing skips, 836 incrementally selected tests with 16 existing skips, andcheck:fast.Author readiness
Human owner: @ShuaixinHuang
@ShuaixinHuang explicitly confirmed review of this replacement’s current final diff, evidence and limitations, accepted responsibility, and declared it ready for initial maintainer review.
Summary
Opening an iNES region and cancelling before the returned stream is consumed can terminate the process. Closing the reader can also release an extraction-owned descriptor while a read or final source check is still admitted. Producer completion and readable retirement stay on the artifact resource scope, and a physical descriptor rejection stays primary when cancellation races its delivery.
Change and scope
Merged current
origin/main(6a5d77bf2). The missing-installation JVM probe already landed in #11732 (f46b97d1e). The merge duplicated that Ghidra test; the duplicate is removed. This diff does not touchGhidraInstallation.doctorCancellation.test.tsandprocessCaptureProgress.test.tsare restored to main. Neither edit is required by iNES shutdown ownership or I/O failure precedence. Main already requires successful capture cleanup facts on the last notification.NES 2.0 (#10674) is not integrated. Classic iNES remains the supported boundary.
The header-admission regression ages its fixture before a same-size overwrite. Identity is observed through mtime, so a rewrite inside one clock tick was reported as a format error instead of source integrity. The same race fails on main's reader.
The Go provider test for an unstored oversized Mach-O command table asserts the typed parse failure (
kind: "truncated",format: "macho",field: "Mach-O load commands") and the projectedinvalid_formatissue. It no longer locks the retired sentence about the load-command range.The paused-inventory close case now lives only in the existing close/cancel pair. That pair already refuses the next
entries()step after close or cancel. The close arm also checks that the borrowed descriptor stays open. A secondFileHandle.close()resolves on this runtime, so the removed test's descriptor check was not implied by cleanup.Contribution scope: ordinary fix inside the existing read-only artifact reader. No new provider, execution, injection, or mutation authority. Not applicable for a separate maintainer scope decision.
Contract and boundary impact
InesArtifactReaderowns region-stream retirement and joins admitted reads and final source checks beforeclosereleases an extraction-owned descriptor. Inventory readers still borrow the admitting scope's descriptor.readFileHandleChunksowns the physical read outcome when cancellation races error forwarding.unavailable,cancelled,io,integrity). Reconstruction bytes are unchanged.Expected effects:
Evidence and regression coverage
check:pr, full-repository typed lint beyondcheck:fast, or native Windows/macOS run.Lifecycle coverage in
inesCancellation.test.tsincludes pending reads, final source validation, unread and buffered retirement, paused inventory closure, borrowed descriptors, and failed-close retry. The chunk reader covers a rejected descriptor read that stays primary while cancellation is delivered.Validation performed
Linux, Node 24.22.1. Head
86de59dcb7e3c9aa763d598880cc53a693fa4d69.npx oxfmton the touched tests — formatted.npm run check:fast— typecheck, lint, and architecture guards passed (2898 source files).npm run test:focused -- tests/boundary/filesystem/inesCancellation.test.ts— 49 passed.npm run test:focusedfor the iNES, chunk-reader, doctor, and domain iNES suites passed 109 tests, andtests/boundary/go/goBinaryProvider.test.tspassed 17 tests. Those files are unchanged by this fold exceptinesCancellation.test.ts, which was re-run above.Compatibility, safety, and release
Author readiness
Human owner: @ShuaixinHuang
@ShuaixinHuang explicitly confirmed review of the prior published diff, evidence, and limitations, accepted responsibility, and declared this PR ready for initial maintainer review. Later pushes do not require a new sign-off. The validation section above is the evidence for the narrowed head.