Skip to content

fix(artifacts): preserve cancellation ownership and map source identity - #10111

Closed
ShuaixinHuang wants to merge 3 commits into
morluto:mainfrom
ShuaixinHuang:fix/bun-stream-cancellation
Closed

ShuaixinHuang wants to merge 3 commits into
morluto:mainfrom
ShuaixinHuang:fix/bun-stream-cancellation

Conversation

@ShuaixinHuang

@ShuaixinHuang ShuaixinHuang commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Superseded by #10616 at the author’s explicit request. This is the same contribution rebuilt and revalidated on main; review and verification history are retained below.


A completed producer could leave unread Bun or PyInstaller member bytes alive after cancellation or reader shutdown. Separately, release audit could lose or falsely retain a distinct NFC/NFD linker-map source when JavaScript and HTML declared targets sharing a lookup key. This PR fixes the producing ownership rules, rebased onto main 653c49419.

Trigger, root cause and repair

  • Buffered stream retirement (Bun and PyInstaller): producer completion is earlier than readable retirement. Bun previously released its scope operation; PyInstaller also removed its abort listener and settled its owning operation after the pipeline finished. With a real eight-byte CArchive member, reader.close() returned while those bytes could still be read. Keep the operation and listener owned until the readable closes. Late cancellation destroys it with ArtifactReaderFailure("cancelled") and the exact caller reason. PyInstaller joins both producer and retirement settlements, including failure paths. Verification/private-file cleanup still owns accepted native work; established source/inflater errors retain precedence, including before their error events forward them.
  • Linker-map source identity: retract an existing exact candidate first, including guesses produced after an early declaration. Only a previously admitted declaration and an observed exact source spelling can suppress ambiguous fallback. Admission alone cannot identify a missing source. Both declaration owners share the rule; target-storage deduplication no longer decides retraction. Routing, target budgets and explicit unknown coverage remain intact.

The PyInstaller follow-up belongs here because it reproduces the same producer-completion/readable-retirement defect as the existing Bun change. No second PR was opened. Related reader adapters, scope ownership, private-source cleanup, prefix inspection and CLI/MCP consumers were inspected. The new 13 cases cover actual plain/compressed CArchive readers, null/object cancellation reasons, reader shutdown, completion/listener retirement, and injected source EIO and real zlib failures. Direct helper controls exercise completion and event-forwarding stages that a consuming CLI cannot reliably pause at.

Identity regressions cover early/late/repeated declarations, both map/HTML orders, separately declaring both spellings, an exact guess produced after an early HTML declaration, and a missing canonical target with two equivalent source spellings. Compiled CLI controls cover preserved source identity and removal of false exposure. Both earlier verified review findings remain addressed (initial identity finding, late exact-candidate finding). No new provider, target execution, schema, cache or dependency.

Executed validation

Linux; pinned Node 24.22.1 / npm 11.16.0, normal locked dependency installation:

Control Actual result
Final four regression test files copied to isolated main 653c49419, production unchanged 18 failed / 326 passed (344 total; assertion failures, not timeouts)
Final committed follow-up: 22 suites 882 passed (66.86 seconds)

The 22-suite run includes all nine PyInstaller suites, PyInstaller compiled CLI and SDK MCP boundaries, release-exposure reader/Bun/graph/compiled CLI/filesystem/SDK MCP/domain/service, plus resource-scope and hash tests. The PyInstaller MCP tests use the SDK's in-memory transport; no stdio qualification is inferred from them. Real Node file handles/zlib are exercised; target programs are not executed.

All seven changed files: same-config type-aware lint 0 errors / 42 advisory warnings. Formatting, git diff --check, normal commit/pre-push hooks and final seven-file checksums passed. npm run check completed six static tasks, architecture guards and production reachability, then the whole-repository type-aware lint worker was SIGKILLed at the 8 GiB host limit; the complete command did not pass. Separately, same-configuration type-aware lint in 15 serial batches covered all 7,208 tracked JS/TS inputs: 0 errors / 4,988 advisory warnings. Batch input union/counts were verified with no omissions or duplicates. This resource-bounded qualification does not turn the failed monolithic command into a pass.

Core main reproduction (copy only the final test files to the clean base first):

npm run test:focused -- \
  src/artifacts/pyinstaller/PyInstallerBoundaries.test.ts \
  src/artifacts/bun/BunStandaloneArtifactReader.test.ts \
  src/artifacts/ReleaseExposureReader.test.ts \
  tests/acceptance/releaseExposureCli.test.ts

CI and verification limits

Current head bd10b79459383251d9a0004b7fe0397cbcb77df6: CI 43217381581, attempt 1, completed successfully: all 40 jobs accounted for, 17 successful / 23 configured skips, no failures or cancellations. Source checkout was merge a8406b35c of this head into 653c49419; both parents were verified.

  • Full Source tests: 29,186 passed / 19 skipped.
  • All eight built-test shards: 19,421 passed / 268 skipped.
  • Static checks, build, Windows native-controls cross-build, real APK signature verification, Linux x64 package end-to-end baseline, Portable tests and final CI gate: passed.
  • Automated code review on this exact head: completed with no findings; no unresolved review threads. Author readiness and conventional-title checks passed.

Deep static checks, documentation, Python producer tests, native Windows/macOS package/runtime qualification and other unselected optional lanes are not counted as passes. No older head's successful lane qualifies this head.

Historical head 8c3532ba2 passed CI 43128858199 and exact-head automated review. Those results, the older 660-pass local run and earlier package/whole-corpus qualifications do not validate this follow-up head. Earlier failures and logs remain retained; no retries, deadline increases, production trust-rule changes, result filtering or test weakening were introduced.

Historical lifecycle checks exposed UID-mapping and unreaped-orphan host failures; unchanged suites passed with real UID metadata and an external subreaper. That older host qualification is not rerun or claimed for the new base. Likewise, no fix is claimed for earlier cancelled HTML/SVG/Kuna or Windows registration timeouts. Already-merged fixture/Process CLI repairs, including #10147, were not replayed.

Bun and PyInstaller fixtures are inert source-owned executable/archive fixtures. No real Bun or Python target execution, native Windows/macOS or Windows Shell/ACP qualification was performed. Unicode coexistence controls skip on filesystems folding the two spellings. Optional skipped CI lanes do not count as passes.

Author readiness

Human owner: @ShuaixinHuang

The owner explicitly reviewed 4febdbed6, its evidence and limitations, and declared initial readiness on 2026-11-12 (Asia/Shanghai). On the same date, the owner explicitly confirmed review of the then-current head 8c3532ba2 and requested that the PR be ready for review. This records the owner's statements for those commits; the validation limits above remain documented.

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

The human owner subsequently explicitly confirmed review and requested review readiness for the current head bd10b79459383251d9a0004b7fe0397cbcb77df6 on 2026-11-12 (Asia/Shanghai). This records that statement for this head, without attesting to future code.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 11, 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-12T12:28:50.412033Z bd10b79 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.

@ShuaixinHuang ShuaixinHuang changed the title fix(artifacts): retire buffered Bun streams on cancellation fix(artifacts): preserve cancellation ownership and map source identity Nov 11, 2026

@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: f2a70cd280

ℹ️ 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/ReleaseExposureReader.ts Resolved
@ShuaixinHuang
ShuaixinHuang force-pushed the fix/bun-stream-cancellation branch 3 times, most recently from fb039eb to 9b4703f Compare November 12, 2026 00:17

@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: 9b4703f40e

ℹ️ 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/ReleaseExposureReader.ts Resolved
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