Skip to content

fix: guard write_file replacements with complete-read proof - #294

Merged
AetherAI3 merged 2 commits into
mainfrom
fix/issue-269-write-precondition
Oct 6, 2026
Merged

AetherAI3 merged 2 commits into
mainfrom
fix/issue-269-write-precondition

Conversation

@AetherAI3

@AetherAI3 AetherAI3 commented Oct 6, 2026 •

Copy link
Copy Markdown
Owner

Summary

Addresses #269. write_file now creates missing paths exclusively. Replacing an existing small text file requires expected_revision and an executor-scoped replace_token from the same complete byte-mode read_file result. Partial reads, old path/content-only calls, stale or cross-session proofs, binary targets, and files beyond one complete read page are rejected before any old content is changed.

Writes are staged and synced in a sibling file. New files commit with an atomic create-only hard link; existing files are checked against the digest-backed revision immediately before same-directory rename. Success reports prior and new revisions. The local tool schema, hosted request flag, protocol type, diff preview, and documentation use the same contract. Large-file callers are directed to patch_file.

The documented concurrency limit is that a non-cooperating external writer can change a path between the final revision check and rename; strict serializability against such writers needs a workspace lock.

Verification

  • npm run build
  • Focused tests: 114 tests, 102 passed, 12 platform skips; after final additions, 48 tests, 47 passed, 1 platform skip.
  • Independent Linux host (Node 24): fresh branch checkout, npm ci, build, and 93 focused tests: 92 passed, 1 expected permission-mode skip.
  • Cases cover complete and empty reads, multibyte text, partial and line reads, stale same-size edits, atomic path swaps, a swap during staging, create races, binary and oversized targets, legacy async calls, symlinks, failed staging, and failed rename.
  • git diff --check

GitHub Actions jobs on this PR did not start: GitHub annotated them "The job was not started because your account is locked due to a billing issue." This is an account gate, so the Windows and Linux results above provide the executable test evidence.

The companion AETHER-CLOUD PR advertises the new schema and rejects older coding hosts that request write_file without the capability flag.

@AetherAI3
AetherAI3 merged commit 7971fea into main Oct 6, 2026
1 of 8 checks passed
@AetherAI3
AetherAI3 deleted the fix/issue-269-write-precondition branch October 6, 2026 13:04
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