Skip to content

feat(safe-fs): support atomic resize operations for truncate - #711

Draft
kamilio wants to merge 5 commits into
mainfrom
codex/atomic-resize-operation
Draft

feat(safe-fs): support atomic resize operations for truncate#711
kamilio wants to merge 5 commits into
mainfrom
codex/atomic-resize-operation

Conversation

@kamilio

@kamilio kamilio commented Sep 10, 2026

Copy link
Copy Markdown
Member

Problem

truncate currently requires retained writable handles. A transactional filesystem can safely resize a file in one atomic mutation but cannot necessarily retain an inode across distributed requests. Such a backend cannot use the command despite being able to preserve its size and quota semantics.

Change

Add optional atomicResize and resizeFile(path, operation, options) to safe-fs. The operation carries the signed bigint size, modifier, optional reference snapshot, and block-scaling intent so the backend computes the final size against the target within its own transaction. The documented contract requires overflow checks and quota validation before publication.

truncate continues to prefer retained handles and uses the atomic operation only when the backend explicitly advertises it. Device and mount wrappers forward supported operations, scoped filesystems account for them, and read-only, quota, and overlay wrappers withhold the capability. Cancellation waits for an admitted operation to settle without promising rollback.

The branch is reconciled with upstream strict-fixture type fixes; the PR diff contains only the atomic resize contract, command integration, and their tests.

Validation

  • Maintained root build.
  • 1,683 focused truncate, archive-permission, and byte-value tests.
  • 94 focused safe-fs capability, device, and atomic-resize tests.
  • safe-fs typecheck and safe-bash's source/test + 26 consumer type groups pass.
  • Root ESLint (10,529 files; zero diagnostics), root types, and workflow lint pass. Guarded ESLint also passed after the read-only test expectation was updated.
  • 77 read-only tests pass after explicitly asserting that atomic resize is denied.
  • The maintained full unit run failed. The shared phase passed 22,403 tests, Python passed 29, and the shell-runner phase passed 303. The shell phase reported 27,509 tests: 27,371 passed, 51 failed, one cancelled, and 86 skipped. Its main archival failure is an existing test-tool API mismatch: npm 10.9.4 bundles tar 6.2.1, which exports Parse, while the committed-archive helper calls tar.Parser. The original failure evidence is retained; archive controls have not been relaxed.
  • Other full-run failures include timeout cases, two capability expectations, and unavailable pinned historical Git objects in this shallow checkout. The read-only expectation is corrected in this branch; the registration matrix correction is committed and passes. The remaining historical-evidence and lifecycle cohorts plus registration pass 17/17 after fetching the exact pinned Git objects; the reconciled archive-permission, byte-value, and registration cohort passes 106/106. Two other unchanged focused timing cases pass. These focused results do not make the full run green.
  • CI provider automation also failed with unavailable model/provider responses. No paid reruns or model configuration changes were requested.

Draft status

Awaiting resolution of broad-run failures; downstream integration screenshot is below. No merge or release is requested.

The API is optional; this PR does not add atomic resizing to backends that cannot provide it. It does not require or replace the independent device comparison fix in #710.

Downstream integration evidence

Recorded controlled Poe2 integration of the optional resize contract with its downstream shell adapter, API and native storage, rendered in real Chat. Partial UTF-8 c3 grows to c30000; an oversize resize to 131073 returns status 1 and preserves authoritative bytes [195, 0, 0]. No model run or production service. This is not standalone upstream validation; broader failures and current CI remain unresolved.

Downstream atomic resize integration

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