Skip to content

fix(safe-bash): drain admitted owned output writes on close - #719

Closed
kamilio wants to merge 1 commit into
mainfrom
codex/owned-output-operation-drain-current
Closed

kamilio wants to merge 1 commit into
mainfrom
codex/owned-output-operation-drain-current

Conversation

@kamilio

@kamilio kamilio commented Sep 10, 2026 •

Copy link
Copy Markdown
Member

When cancellation arrives during an explicitly owned output write, an output operation can finish cleanup before that write settles. This lets curl return or shell disposal complete while its destination is still writing.

Track writes when they are admitted and drain them together with cleanup callbacks. Cancellation still reaches the caller promptly, opaque destinations retain their existing behavior, and cleanup can release a pending owned write without deadlocking.

Publication is rebased onto upstream main ede5985, including the separately landed provider prerequisites. The two fix files retain their exact reviewed hashes. The validation below remains bound to the preserved52a source/artifact; fresh broad CI qualifies the rebased head. No stale compiled workspace outputs are being presented as current-main validation.

Validation on the exact 52a76 source basis:

  • 99 focused output/contract tests passed, including false cancellation reasons, multiple pending writes, and close invoked during write admission.
  • Built-package consumer checks passed: 26 built groups, three source groups, and three expected negative cases.
  • Source-and-tests typecheck passed after the maintained SafeJS declaration build and canonical filesystem rematerialization. The four composed source files, lock, 19 retained filesystem outputs, and 54 shell browser outputs retained their verified hashes.
  • Full guarded ESLint passed: all 10,673 configured files, zero errors or warnings. Root lint types failed because unrelated workspace declarations were absent; workflow lint was not run. The user explicitly authorized publishing without repeating broad local validation. The normal commit succeeded; this isolated Git worktree has no configured hook or executable default hooks. GitHub CI remains required.
  • Fresh packed real-Shell lifetime verification passed all three unchanged tests (19 assertions, 1.54s): owned caller cancellation, owned Shell disposal, and opaque-output control. The historical packed536 two-failure result is preserved. This validates the standalone output fix, not the final platform composition or hosted service.

The inventory prerequisite was separately composed for qualification; it is not part of this two-file fix. Its historical local patch has since been superseded upstream by be65352. The standalone proof does not include the full platform composition or PR714 response-mode changes.

Diagnostic proof of the owned-output regression

Historical diagnostic evidence: upstream536 source baseline had two failing owned-output cases and one passing opaque-output control; the fix passed 99 focused source tests. This image is not a product UI, packed-runtime, or Cloudflare-service proof. It binds production SHA256 f345e2d19cf1be9e1ba935a72ff7656e3383f9354483b24c471770c85b79f5ec and test SHA256 1f8f7a02e7df80a7f4860e0248eac9c5b988d6ea6e64c1e179b2d9eaf2bd0821.

Current diagnostic test evidence

after: Diagnostic test evidence

Rendered from the saved current52a focused99PASS log and fresh packed actualShell3PASS log. This is diagnostic test evidence, not product UI, final48 qualification, or hosted Cloudflare proof. Image SHA256 22eb7a408f6b209beac7f02d46b2bad82e7836baed66dafd0653863b8abcbd40.

@poe-code-agent poe-code-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@kamilio

kamilio commented Sep 10, 2026

Copy link
Copy Markdown
Member Author

Fresh packed-runtime verification now passes all three unchanged agent-service Shell lifetime tests: caller cancellation during an owned write, Shell disposal during an owned write, and the opaque-output control (3 passed, 19 assertions, 1.54s). This replaces the earlier packed536 two-failure result for the standalone output fix.

The tested package was produced from the exact reviewed output source in commit214247cad556ba2f39f14d607e6300a553083521 using maintained declaration normalization and strict public packaging. All1,944 package files were hashed, npm-packed files matched the public output byte-for-byte, and the complete native asset set passed maintained source-bound validation. The original qualification inputs remained unchanged. No compiler or broad-root validation rerun was needed for packaging.

This proves the standalone52a output fix; it does not claim the final platform composition, PR714 response-mode integration, Linux-native execution on Mac, or Cloudflare-service parity. Current CI includes passing full virtual-bash and packed-public-API jobs; E2E has separately diagnosed provider/model failures and is not being reported as green.

Keep owned output writes alive through scope cleanup after cancellation, while opaque destinations retain prompt cancellation. Enroll writes before invoking host code so reentrant close cannot miss them.

Tests added: owned and opaque cancellation with a false reason and late failure; concurrent writes whose cleanup releases a pending write; close reentered during write admission. Current focused suite: 99 passed.

Local full ESLint and source-and-tests typecheck passed. Root lint types remains incomplete due missing unrelated workspace declarations; workflow lint and fresh packed Shell runtime checks remain pending. Redundant local hooks skipped under explicit user authorization; GitHub CI remains required.
@kamilio
kamilio force-pushed the codex/owned-output-operation-drain-current branch from 214247c to 0834011 Compare September 10, 2026 23:46

@poe-code-agent poe-code-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

kamilio added a commit that referenced this pull request Sep 11, 2026
Integrate the reviewed two-file patch from PR #719 at 0834011. Preserve prompt caller cancellation while close waits for enrolled destination writes and concurrent cleanup.

Three regressions failed before the patch; 165 focused tests and 445 contract tests pass. Build, package/root types, ESLint and workflow lint pass. Full committed-candidate tests and packed qualification remain pending before push.
@kamilio

kamilio commented Sep 11, 2026 •

Copy link
Copy Markdown
Member Author

Integrated the reviewed PR head 083401179359459036afd37ff0293aeba5aadc3f into main as 6464b23f302430a8b54c314c29b15a29237815d6, preserving the exact reviewed implementation and regression-test blobs. Remote main is verified at 40cfe4707cd96bc880f1e6959a6d9329d37c40ab.

Focused RED/GREEN reproduced three ownership failures and passed 165 focused tests plus 445 contract tests. Full maintained unit validation subsequently passed: shared 22,465; Python 29; Bash runner 313, reviewed parallel 125, serial 31,118; SafeJS 21,663; terminal 288; root posttest 2. Maintained skips remain disclosed in the committed qualification plan. Root lint, package consumer types, normal build, and all 35 current packed-consumer stages passed.

The first full run encountered an unrelated-path native hazard-worker timeout whose scenario was missing from its error. A separately reviewed diagnostic change preserves the one-second limit and original error cause; historical evidence remains intact. The complete subsequent run passed, but the original timeout cause remains unproven.

Closing as integrated directly into main, rather than creating a duplicate merge commit. Publication is complete and verified: [email protected] is npm latest with GitHub release v15.0.20; all three scoped safe packages are npm latest at 0.1.546. Main, scoped-package, and Pages workflows succeeded: main release, scoped safe packages.

@kamilio kamilio closed this Sep 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant