fix: name the cause when the archive root is not writable - #91
Merged
Merged
Conversation
hdkiller
force-pushed
the
codex/root-not-writable
branch
from
September 10, 2026 13:52
0c49063 to
fa4e8dd
Compare
A writing command on a root that cannot be written to failed with the retryable write.interrupted carrying the stage "lock", a value the error contract does not enumerate. Nothing was interrupted there and no retry succeeds, so the condition is now archive.not_writable in the archive bucket at exit 4, not retryable, with a message that says the archive root itself must become writable and that archive repair-permissions cannot help, since the repair takes the same lock. The stage set is closed and now complete: the lock file joins record_write with the rest of the archive root, the object store reports object_write rather than the undocumented "object", a rewritten record and the rebuildable index report record_write rather than the undocumented "record_replace" and "cache_write", and the deletion's own phases delete and purge are enumerated beside the three write stages. A contract test reads every call and every constant in openpapir-core that names a stage and holds each one to the contract's enumeration.
hdkiller
force-pushed
the
codex/root-not-writable
branch
from
September 10, 2026 14:08
fa4e8dd to
d517455
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
On an archive root that cannot be written to, every writing command failed
with
write.interrupted(documented retryable) carryingstage: "lock",a value the contract's enumerated stage set does not contain. Nothing was
interrupted there and no retry can succeed, including
archive repair-permissions, which takes the same single-writer lock.What changed
archive.not_writable(archive bucket, exit4, notretryable). A lock file that cannot be created because the root refuses to
be written to is refused by name. The human line says the archive root
itself has to become writable and that
archive repair-permissionscannothelp when the root is read-only. Details are
bucket,scope(archive)and
archive_path(.); no path, filename, or user value is echoed. BothPermissionDeniedandReadOnlyFilesystemmap to it, because a read-onlymount and withheld write permission are the same condition for a caller.
No existing read-only precondition or
usage.archive_read_onlyexisted toreuse.
write.interruptedkeeps every genuinely torn write. Its other failurefrom the lock now reports the documented stage
record_write, which thecontract already gave to the archive root.
stageset is complete and closed. The contract now enumerates allfive values in prose beside the
scopeparagraph: the three write stagesplus the deletion's own phases
deleteandpurge, whichcase deletealready emitted undocumented. The lock file joins the
record_writerow inboth documents' tables. The object store now reports
object_writeratherthan the undocumented
object, and the rebuildable index reportsrecord_writerather than the undocumentedcache_write(the contractalready names a cached file under
record_write).platform.no_directory_fsyncis documented as carrying a write stage, or a deletion phase where a
deletion asked for the flush, which is what it already did.
error::stagesholds the constants,WRITES,ALL,is_documented, andis_write;publish_refusal,link_refusal, and thefsync warning
debug_asserttheir argument, so a test run catches anundocumented stage. A new contract test parses the contract's table and its
enumeration, holds both to the implementation's sets, then reads every
call in
openpapir-corethat takes a stage as its last argument (36 sitesin this tree) and holds each literal to the contract, so a new emitter
cannot introduce a stage no caller can branch on. The same test reads every
stage constant, which is how
record_replacewas found:case updaterewrites a record, and on a platform without a directory flush its
platform.no_directory_fsyncwarning carried that undocumented stage. Itreports
record_writenow, which is what the contract already gave arecord document.
docs/error-contract.md,docs/architecture.md,tests/golden/README.md, and the changelog: adirectory's read-only attribute there does not stop a file from being
created in it, so the condition arises from an access-control list or a
read-only volume; the tests that withhold write access are Unix-only for
the same reason and skip when the process writes anyway.
Goldens changed
New case
archive.not-writable(archive repair-permissionson a root thatwithholds write access), added files only:
tests/golden/archive.not-writable/json.jsontests/golden/archive.not-writable/json.exittests/golden/archive.not-writable/human.txttests/golden/archive.not-writable/human.stderr.txttests/golden/archive.not-writable/human.exitNo existing golden changed. The world restores the root's mode on drop so the
temporary directory is still removable.
Verification
./scripts/check.sh && cargo build --release --locked && cargo run --locked -p openpapir-cli -- capabilities --jsoncargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-msvc -- -D warningscargo +1.88 check --workspace --all-targets --lockedcargo llvm-cov --workspace --locked --fail-under-lines 90(97.25% lines)origin/developimmediately before pushing.Exceptions to Owned Paths, with reasons
crates/openpapir-core/src/records/document.rs: one stage constant renamed to the documentedrecord_write.crates/openpapir-core/src/cache/mod.rs: one constant, the undocumentedcache_writestage, which had to change for the set to be complete.crates/openpapir-cli/tests/golden.rsandtests/golden_support/mod.rs:the new golden case and its setup, which the acceptance criteria ask for.
The two permission cases moved into their own
permission_cases()groupbecause
archive_cases()would otherwise exceed the clippy line limit.crates/openpapir-cli/tests/concurrency.rs: the end-to-end test of the newrefusal. It is the file about the single-writer lock, and
tests/archive.rsis one line under the 1500-line source limit, so adding it there would have
left no room.