Skip to content

fix(safe-bash): preserve ownership during archive and split writes - #721

Closed
kamilio wants to merge 5 commits into
mainfrom
codex/zip-csplit-atomic-543
Closed

kamilio wants to merge 5 commits into
mainfrom
codex/zip-csplit-atomic-543

Conversation

@kamilio

@kamilio kamilio commented Sep 11, 2026 •

Copy link
Copy Markdown
Member

ZIP and csplit currently check an output entry and then mutate its path separately. A replacement between those operations can make publication, append, metadata updates, or cleanup affect a different entry.

This change adds optional filesystem operations that compare the expected entry and parent inside the mutation and return the committed entry receipt. ZIP uses owned staging for publication and cleanup; unzip also conditions directory creation and metadata updates. Csplit uses conditional writes/removal and bounded buffering, preserving keep-file, cancellation, empty-output, and byte-count behavior. Unsupported adapters fail closed.

The source is reconciled against the published 0.1.543 source (ede5985e5e2b35b38eebd0faaeb3ed6a390493e9). Existing atomic resize, device comparison authority, curl response intent, and declaration inventory fixes are preserved. The separate output-drain change in #719 is outside this PR.

Validation at 50dfdb95baa73b28ea20d07e780ee9f4b048392d:

  • Independent review approved the current source. Four create-intent findings were fixed, including forwarding through filesystem wrappers; all review threads are resolved.
  • Local focused SafeFS: 90 tests passed across five files, covering owned staging, conditional mutation, cleanup, atomic resize, and device comparison.
  • Maintained Node22 shell CI: 31,221 passed, zero failed, 63 skipped; runner tests: 313 passed.
  • Packed public APIs, end-to-end checks, and initial security/guard checks passed.
  • General CI remains failed: ten timeout failures were observed across concurrent streams (eight SafeJS cases, PPR2 co, and coverage-demo replay). The 22,543-pass/one-failure summary belongs only to the shared process, not the entire job. No timeout was increased, and no cause or flake classification is claimed.
  • The selected local SafeFS build remains queued. Current-source full local build/type/lint and actual platform Worker qualification are not claimed.

This is ready for source review while qualification continues. Downstream platform integration and release pinning remain blocked on qualification and a verified upstream release. No package publication or merge is performed by this PR.

Add optional atomic staging, directory metadata, and conditional file mutation
contracts. ZIP, unzip, and csplit use committed receipts to reject replacement
races during publication and cleanup. Bound csplit buffering and retain its
error, cancellation, keep-file, and empty-output behavior.

Tests cover replacement races, stale receipts, scope routing, read-only denial,
ZIP extraction metadata, csplit byte counts, buffered limits, and cancellation.

Validation: independent source review passed. Focused runtime qualification
is pending the existing private dependency installation queue.

@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

Declare the receipt at its single assignment while retaining the deferred
cleanup closure and cancellation assertions. Addresses the actual CI
prefer-const finding; runtime qualification remains pending.

@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

Include csplit in the portable capability declaration inventory and assert
read-only denial. Include conditional removal in the retained cleanup view
and propagate early callback failure instead of awaiting an unresolved gate.

Both mismatches were observed in CI; deadlines and runtime sources are unchanged.

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

Requested changes: capability queries on missing outputs omit create intent.

Pass create intent when ZIP, unzip, and csplit query capabilities for outputs
that may not exist yet. Preserve support on backends that distinguish reads
of missing entries from creating them.

Add create-sensitive archive roundtrip and split byte-output regressions.
Focused execution remains pending the existing filesystem/build sequence.

@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

Forward creation intent in scoped, mounted, and device-backed capability
checks for new conditional files, directories, and staging. Keep existing
entry and cleanup checks unchanged.

Add three wrapper regressions for create-sensitive backend support, exact
published bytes, and deletion queries without creation intent. The archive
regression exposed this missing layer in actual Node22 CI.

@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 reviewed PR #721 conditional filesystem mutations and owned staging. Preserve foreign replacements during archive publication, cleanup, and split writes. Retain current LLM browser coverage and register the ZIP ownership regression explicitly. Focused tests, normal build, consumer and root types, and repository lint pass. Full committed-candidate tests and packed-consumer qualification remain pending before delivery.
@kamilio

kamilio commented Sep 11, 2026 •

Copy link
Copy Markdown
Member Author

Integrated reviewed PR head 50dfdb95baa73b28ea20d07e780ee9f4b048392d directly into main as aa8def258bd940b4a587ff74be7223679610d3fd. Remote main is verified at 829c377ee1ed0556314106cfdd5a2b30e31229ce after the qualification record. Independent review confirmed the reviewed content, preserved newer LLM browser coverage and PR 719 output draining, and verified the explicit ZIP regression inventory entry.

Tests-first validation reproduced seven ZIP ownership failures and 37 SafeFS failures. The implemented candidate passed 82 focused SafeFS tests, 693 focused Bash tests, and 106 inventory checks. All 26 maintained consumer-type groups, root types, workflow lint, and guarded ESLint passed; ESLint covered all 10,778 configured files with zero errors or warnings.

The complete maintained unit command passed: shared 22,501; Python 29; Bash runner 313, reviewed parallel 125, serial 31,142; SafeJS 21,663; terminal 288; root posttest 2. Maintained skips remain disclosed in the committed qualification plan. The normal post-test build and all 35 current packed-consumer stages passed, with identical source/path inventories and clean diffs before and after.

Closing as integrated directly into main, without a duplicate merge commit. Publication is verified: [email protected] and @poe-platform/safe-fs, @poe-platform/safe-js, and @poe-platform/safe-bash at 0.1.547 are available on npm's latest tags. GitHub release v15.0.21 is published, and its tag points to verified remote main 829c377ee1ed0556314106cfdd5a2b30e31229ce.

All workflows succeeded: main release, scoped safe packages, and Pages. Published release.

@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