Repository navigation
fix: Read verbs no longer take the exclusive maintenance-writer lease - #5043
Conversation
Problem: a pure read verb could not read an archive it did not own. `polylogue --plain read --all` against a read-only archive root failed with `PermissionError` on `.api-auth-token.<rand>.tmp`, and with that mint patched out, with `ArchiveOwnershipError: cannot open archive ownership lock`. Two separable defects, both of which made a read mutate -- or be refused by -- the thing it was reading. (a) `open_operation_read` treated "no publication guard supplied" as "take the exclusive maintenance/campaign writer lease". `OperationContext.direct_read` never sets a runtime, so every direct CLI read fell through to `_direct_pin_guard` -> `OwnedArchiveLocation.acquire`, which opens `.archive-ownership.lock` `O_RDWR|O_CREAT` and `ftruncate`s an owner record into it. A regression from 1d901ec (#4867); before it an absent daemon meant a plain unlocked local read. (b) `configured_read_operation` resolved the daemon bearer token before it knew whether a daemon was listening, so an absent daemon still cost a write into the archive root. Solution: the unguarded reader route is now optimistic rather than exclusive -- resolve the archive identity, open read-only, pin the tier snapshots, then re-resolve and require the identity to be unchanged. A republication landing mid-pin is the typed, retryable `ConcurrentArchivePublicationError` rather than a torn read or a false success; this mirrors `open_operation_control` one level up. `DaemonClient` accepts a token thunk and resolves it only after a connection is established, so a read pays nothing when no daemon answers. The sole-writer contract is untouched: every mutating call site still takes the lease (archive init, tier migration, root relocation, continuity recovery, embedding restore, the durable change train, and the daemon itself). No read on this route lazily materializes anything, so none of them needs it. `ConcurrentArchivePublicationError` is declared in `operations/operation_context` rather than `core/errors` on purpose: `devtools schema closure` reports `core/errors.py` as IN the derived-schema identity closure, so adding a class there would move the identity and demand a full reconvergence for a read-path bugfix. All four edited files are outside the closure. Verification: devtools test tests/unit/operations/test_read_path_no_writer_lease.py -> PASSED (5 tests) Reverting either fix turns all five red with the original defect signatures (`ArchiveOwnershipError: cannot open archive ownership lock`, the foreign-owner `archive location already owned`, the rewritten lease record, and the token-mint tripwire). Verified outside pytest against a 0500/0400 sealed demo archive (`read --all`, `analyze --facets`, `find` all succeed and add no root entries) and against an archive whose ownership lock is held by another process (reads succeed; the foreign owner's record survives intact). Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Warning Review limit reachedNext included review available in 1 minute. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (5)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
… verdict (#5047) Closes `polylogue-2d8oq` and `polylogue-kjy0a`. Both are instances of the defect shape this campaign has now hit six times: **a refusal or an unmeasured state collapsed into a positive claim.** ## Bug 1 — the URL policy I **accepted what `_default_daemon_url` produces** and deleted the refusal. It could not be justified: `_default_daemon_url` exists precisely so site/user TOML and `POLYLOGUE_DAEMON_URL` can point the CLI away from the built-in address, and `_status_operation_result` refused exactly those values. Correcting `_default_daemon_url` to agree was the wrong direction — this route reads through the configured archive route, so the URL selects nothing here, and an address no daemon answers must simply yield the direct fallback. The corpus already agreed: `test_status_json_daemon_not_running` passes `--daemon-url <unreachable>` and asserts `source == "direct"`. Separately, and regardless of the URL: a failed status read now records `daemon_reachable = False` / `daemon_path = "unreachable"`, renders `Daemon: unreachable`, and publishes `daemon_liveness: false` with reason `status_read_failed`. Reproduced without pytest at the tip: with `POLYLOGUE_DAEMON_URL=http://127.0.0.1:1` and with it unset, the same workspace now produces **byte-identical output**, and no `Daemon: running` appears anywhere. ## Bug 2 — ready / summary / determinate now agree `ready` and `summary` come from one component projection, on the direct path (`operations/daemon_status.py`) **and** on the daemon-serving path (`daemon/status.py`) — which carried the identical defect and which the bead did not mention. The stricter predicate's extra preconditions (parser census, authority frontier, debt classifier) are classified by a new `raw_materialization_unmeasured_reason`. One refinement mattered. The first version withheld the claim whenever *any* precondition was unmeasured, which masked genuine debt refutations — `test_build_daemon_status_claim_guard_reports_openable_but_not_converged` caught it. The rule is now: an uninspected precondition withholds **certification** only (a `ready` projection drops to `determinate=False`); a projection that already found the domain wanting stays a determinate `false`. On a pristine empty archive: `{"value": null, "determinate": false, "reason": "inspection incomplete for raw_materialization: raw authority frontier inspection not completed"}` ## Placement: no reconvergence required `storage/archive_readiness.py` is **IN** the derived-schema identity closure. The first draft edited it, which would have moved the schema identity and forced a full reconvergence *for a status-surface fix*. That file is reverted to base and the helper lives in `readiness/claim_guard.py` (`out`). Every changed file confirmed `out`. ## The seven tests Five pass untouched: `test_basic_usage_cli.py` ×3, `test_json_envelope_contract.py` ×2, plus `test_terminal_snapshots.py` and `test_convergence_surface_contract.py`. Two caveats, stated plainly: - The three `test_basic_usage_cli` tests did **not** go green on the URL fix alone. Getting past the refusal exposed that `_render_direct_status_payload` never named the daemon state and printed `Convergence debt: 0 failed, 0 deferred, 0 retry due` for a healthy empty ledger — and a bare `unavailable` for an unread one, discarding the reason the reader had already computed. Same defect family; the renderer was fixed, not the tests. - `test_json_status_snapshot` is **still red** for an unrelated pre-existing reason: the direct read takes an exclusive ownership `flock` and the seeded lease is a sealed read-only directory. Evidence it is not mine: `test_plain_read_all_snapshot`, touching none of this code, fails identically on unmodified `f84dd3b0c`. (PR #5043 addresses that producer.) ## Tests changed, and why Four assertions encoded the bugs: two asserted `daemon_liveness is True` on a failed read; `..._keeps_convergence_healthy` pinned `reason == "ready"` **without asserting `value`** — i.e. it pinned exactly the `false`/"ready" contradiction; `..._missing_ops_frontier_authority` demanded `value is False` from a domain reporting unknown. Two `test_init` tests asserted exit 1 + "Status snapshot: unavailable", reachable only via the refusal. ## Anti-vacuity - Reinstating the URL refusal → `test_configured_override_url_is_not_refused` red. - Restoring refusal-to-`True` liveness → `test_status_command_reports_operation_unavailable_without_claiming_liveness` red. - Deriving `ready`/`summary` from different predicates → `..._keeps_convergence_healthy` red. - Dropping `determinate` from the raw domains → `..._missing_ops_frontier_authority` red. - Over-broadening the unmeasured gate → `..._reports_openable_but_not_converged` red. **This one already fired during development.** ## Sweep: 11 more live instances, filed not fixed Highest severity: `archive_readiness.py:1764` publishes `archive_sessions` readiness as the literal `True`; `daemon_status.py:217` hardcodes `active_archive_root_matches_configured = True` while the honest comparison already exists at `cli/commands/paths.py:102`; `daemon/fts_status.py:131` is a literal `except sqlite3.Error: return {"session_work_events_ready": True}` where every sibling key returns `False`. Structurally the important one: `build_daemon_status`'s `_v()` substitutes optimistic model defaults for components whose collector **timed out**, so a timed-out raw-materialization probe renders `state: ready, summary: "ready"` with all-zero counts. That single root cause drives four findings — including `perf_measurable` certified from a summary object carrying no `available`/`error` field at all, while the direct path handles the same case correctly. Two producers of one claim, drifted apart, exactly as in bug 2. Also: `capability.py:665` has no branch for an unavailable embeddings tier, so a probe that never ran emits `determinate=True, ready=False` — a **certified refutation from an unmeasured domain**, the inverse-polarity twin of bug 2. And `daemon/status.py:2742` hardcodes `component_state.api = "running"`, so `polylogued status` with no daemon listening prints `daemon_liveness: false` and `daemon_api: running` in one payload. Confirmed correct: `surfaces/outcome.py`, `operations/status_workload.py`, several readiness predicates. ## Verification `devtools test` across nine status/init/readiness/integration selectors — all PASSED except the two reds described above. `devtools verify --quick` exit 0. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
## Summary Three CLI tests asserted the daemon client's pre-#5043 construction shape. The test doubles are updated to the real connection contract and the credential assertion is retargeted onto the laziness the PR introduced. The typed-indeterminate mutation assertions are unchanged. ## Which merged PR moved the ground PR #5043 (`d995eb4e4`, "Read verbs no longer take the exclusive maintenance-writer lease") made two changes these tests depend on: - `cli/operation_kernel.py:256` now passes `auth_token` as a **lazy callable** rather than an already-resolved value, so an absent socket costs nothing -- least of all a write into the archive root. - `daemon_client.py:175` now calls `connection.connect()` explicitly before resolving credentials. `TimedOutConnection` and `InterruptedConnection` defined `connected` but no `connect`, so both raised `AttributeError` instead of reaching the indeterminate path; `test_confirmed_delete_uses_an_unbounded_daemon_wait` compared the captured kwargs to `{"auth_token": None}`, which is now a lambda. ## Solution - Add `connect()` to both connection doubles. This restores the intended route: connect succeeds, `getresponse` raises `TimeoutError` / `KeyboardInterrupt`, and the client must still raise `DaemonMutationIndeterminateError`. Those assertions are untouched -- a connected daemon with no receipt is never interchangeable with no daemon. - In `test_confirmed_delete_uses_an_unbounded_daemon_wait`, assert the kernel passes exactly one kwarg named `auth_token`, that it is callable, and that calling it resolves to the monkeypatched `None`. This is strictly stronger than the old equality: it pins both the argument set and the deferral. ## Verification ``` devtools test tests/unit/cli/test_archive_query.py tests/unit/cli/test_daemon_client.py (run together with the other retargeted files, receipt 20260914T163857Z-focused-test-3135387-125edb44) -> all three tests in this PR green; no regression in either file devtools verify --quick -> exit 0, 15/15 gates ``` ## Anti-vacuity | Test | Mutation that makes it red | |---|---| | both `..._is_typed_indeterminate` | let the client convert a connected-but-receiptless mutation into an ordinary abort or a no-daemon result | | `..._unbounded_daemon_wait` | resolve the token eagerly again (`callable` goes False), or pass any extra kwarg (the key assertion goes red) | ## Residuals Test-only change. The doubles remain minimal stand-ins for `_UnixHTTPConnection`; they do not track its full surface, only the calls `_request_json_response` makes. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
## Summary
Step S2 of the CLI unification: declare the read operations the CLI
still has
no operation for, so no CLI read needs a local executor. Declaration
only —
S3 migrates the call sites.
- `query.aggregate` (count / stats / stats_by)
- `session.read` (windowed transcript reads with a snapshot-bound
continuation)
- `session.reference` (bare `from <ref>` operands)
- `cli.query` extensions: `sample`, `latest`, and the `with <units>`
projection
## Problem
Five of the thirteen rejection groups in
`_daemon_session_page_supported`
(`cli/archive_query.py:1293-1309`) name real gaps rather than stale
caution:
aggregates, exact-ref transcript reads, `--stream`, `--sample`, and the
`with`
projection have no declared operation, so those inputs are always served
by the
local `ArchiveStore` branch. The reference pipeline
(`archive_query.py:211-288`)
is a second local executor with no operation at all. Until those exist,
S3
cannot delete the local branch without losing capability.
## Solution
- `polylogue/operations/read_contracts.py` (new) holds the
request/result
models. It is **OUT** of the derived-schema identity closure (D5);
`surfaces/payloads.py` is IN, so declaring them there would have moved
the
archive's schema identity for a CLI-only change.
- Handlers in `daemon_reads.py` call the existing shared executors:
`archive.stats`/`stats_by`/`count_sessions`/`count_search_sessions`
behind
`spec_session_filter_kwargs` + `stats_filter_kwargs`,
`read_session_page` +
`session_detail_envelope_from_domain`, `fetch_attached_units`, and
`resolve_ref_operand` with `DurableRefResolver` over the pinned reader's
paths. No handler carries its own query logic.
- **8 MiB bound.** `session.read` is windowed by construction rather
than by
discovery: the handler composes only `[offset, offset+limit)` at the
storage
layer, mints a `QueryContinuation` bound to the archive epoch for the
next
window (reusing `archive/query/transaction.py`, which is IN the closure
and
is therefore only consumed, never edited), and refuses a window whose
serialized size exceeds `MAX_OPERATION_RESULT_BYTES` with a message
naming
the smaller limit. `complete`/`next_offset`/`continuation` are checked
against each other by the result model, so a truncated read cannot
report
itself whole.
- The `with <units>` projection rides beside the canonical list envelope
(`attached_units`) rather than inside it: `SessionListResponse` forbids
extras and lives in the closure. `QueryResult`'s validator (in
`daemon_protocol.py`, OUT) validates the projection's shape and hands
the
envelope the rest.
- `polylogue/cli/operation_bindings.py` (new) is the registry diff the
design
names: every `DaemonOperationSpec` is bound to a CLI lowering +
renderer,
listed as pending adoption with the step that adopts it, or listed as
CLI-external with the reason. The three new operations arrive bound, not
pending.
## Verification
```
devtools test tests/unit/daemon/test_daemon_operation_route.py tests/unit/operations/
-> PASSED exit=0 diagnosis=pytest_passed
devtools verify --quick -> all 15 gates ok, exit 0
devtools gate layering -> {"violations":[],"count":0}, exit 0
devtools render all --check -> exit 0, zero "out of sync" lines
```
Closure (`devtools schema closure`) for every file this PR touches:
```
out polylogue/operations/read_contracts.py
out polylogue/operations/daemon_protocol.py
out polylogue/operations/daemon_reads.py
out polylogue/cli/operation_bindings.py
```
No file in this change is in the closure; the derived schema identity
does not
move and no reconvergence is required.
Anti-vacuity, verified by reverting and observing the failure:
| Reverted | Observed |
| --- | --- |
| aggregates stop honouring an empty text selection (`empty_selection =
False`) |
`test_text_selection_scopes_the_aggregate_to_matched_sessions`: `assert
2 == 0` |
| `session.read` always mints a continuation |
`test_final_window_carries_no_continuation`: `TypeError: '<' not
supported between instances of 'NoneType' and 'int'` in
`QueryTransactionRequest.__post_init__` |
| drop `session.read` from the binding registry |
`test_every_declared_operation_is_classified_exactly_once`: `assert
('session.read',) == ()`;
`test_read_operations_declared_for_the_cli_are_bound_not_pending`:
`OperationBindingError: session.read is not classified` |
| drop the `SessionReadResult` completeness invariant |
`test_a_window_cannot_claim_completeness_and_a_next_offset`: `Failed:
DID NOT RAISE OperationResultContractError` |
`devtools test tests/unit/cli/test_archive_query.py
tests/unit/cli/test_daemon_operation_transport.py
tests/unit/cli/test_json_envelope_contract.py`
fails on exactly one test,
`test_confirmed_delete_uses_an_unbounded_daemon_wait`
(`auth_token` lambda vs `None`) — an inherited failure from #5043, owned
elsewhere and untouched here. (Checked pre-rebase; #5043's fix may since
have
landed.)
## Residuals
- Rebased onto `513c8873a` after S0 (#5094) and #5102 landed mid-flight.
The
aggregate and `cli.query` handlers go through the delegating
`_cli_query_spec`/`_lower_cli_query_params`, which S0 repointed at
`operations/query_lowering.py`, so there is one lowering, not two. The
conflict resolution dropped my duplicate `latest` clamp in favour of the
one
#5102 landed, and kept #5102's `_session_list_row`.
-
`tests/unit/daemon/test_daemon_operation_route.py::test_cancelled_long_delete_retains_writer_until_blocked_apply_releases`
failed once on a 25 ms `operation.await` deadline race and passed on
rerun
and on the file alone. Pre-existing timing flake, untouched by this
change.
- `session.reference` opens the durable user tier by path
(`archive.user_db_path`, `archive.index_db_path` from the pinned reader)
rather than through the pinned connection, mirroring the CLI route it
replaces. The generation is the pinned one; the connection is not.
- The `ProjectionSpec` → `ContentProjectionSpec` mapping covers the
block
kinds `body_policy` produces (tool calls, tool outputs, reasoning). The
full
read-view classification is D3/S8's table, not this step's.
- `session.lineage`, `context.compile` and the write operations in §2.3
are
not in this step (S9/S10).
- `completion` and `ingest` are declared but still unreached from the
CLI; they
are recorded in `CLI_PENDING_ADOPTION` with their adopting steps (S7,
S11).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
## Summary A read against a fresh or wiped archive root leaked a raw `sqlite3.OperationalError` to the CLI. It now raises the typed `ArchiveTierUnavailableError` at the read boundary, and the CLI's existing missing-archive handling — which was unreachable on the routes that matter — now catches it. ## Evidence Full-corpus `verify_all` on frozen `master` (`890a2921e`), job 1570, receipt `.cache/verify/runs/20260914T200510Z-all-4027943-f8bc83ff`, 22,524 selected, **147 failures with zero schema skew**. Two of them are this defect: ``` tests/integration/test_installed_package_smoke.py::test_installed_polylogue_entrypoints_under_fresh_xdg tests/integration/test_installed_package_smoke.py::test_installed_polylogue_writes_only_under_xdg_roots E Error: unexpected error: OperationalError: unable to open database file ``` Reproduced at head in one command with a fresh HOME/XDG: ``` polylogue --diagnose find polylogue Error: unexpected error: OperationalError: unable to open database file (exit 1) ``` Filed as **polylogue-wwjy6** (P1, open). ## Per-failure classification | Failure | Classification | | --- | --- | | `test_installed_polylogue_entrypoints_under_fresh_xdg` | **Product defect** — fixed the product | | `test_installed_polylogue_writes_only_under_xdg_roots` | **Product defect** — same cause, same fix | Both tests are correct as written: `polylogue --plain analyze --count` and `polylogue --plain status` against a fresh XDG root are exactly what a first run does, and both have a correct answer. Neither test was touched. ## Problem Route (re-diagnosed at head, after #5152 changed it): `cli/archive_query.py` → `cli/operation_kernel.py` → `operations/daemon_execution.py` → `operations/operation_context.py::open_operation_read` → `archive_tiers/archive.py::open_existing` → `_initialize_store` → `connection_profile.py::open_readonly_connection` → `sqlite3.connect(..., mode=ro)`. Nothing on that route converted an absent `index.db` into the typed missing-archive report the first-run surface is supposed to give, and `cli/machine_main.py` then printed it as `unexpected error`. `archive_query.py` already had `_missing_archive_refusal`, which renders the *right* answer per mode (count/stats/browse → the correct empty result; search → a refusal naming the path). It was reachable only behind `OperationKernelError`, which this failure is not, and only on the page route — the aggregate route that `analyze --count` takes had no handler at all. ## Solution 1. **`archive_tiers/archive.py`** — a read-only open that fails is classified by the *file*, not the driver message. SQLite reports a missing file under `mode=ro` with the same opaque `unable to open database file` it uses for a permission failure or a broken path, so `index_db_path.exists()` decides: absent → `ArchiveTierUnavailableError(tier="index", ...)` with a first-run remedy; present → the original exception propagates untouched. 2. **`cli/archive_query.py`** — both the page route and the aggregate route now take `_missing_archive_refusal` on that typed error, so `analyze --count` answers `0` and `find` names the path it looked for. 3. **`cli/commands/status.py`** — `status` reached its `diagnose_first_run` diagnostic by catching the raw `sqlite3.Error`. `ArchiveTierUnavailableError` is not a `sqlite3.Error`, so it is now named explicitly; without this the fix in (1) would have broken `status`, which is how the smoke test caught it mid-change. 4. **`docs/plans/sqlite-degradation-baseline.json`** — the `status.py` except-clause edit re-texts one anchored degradation seam. Re-anchored to the new digest; the site count is unchanged at **230** (one removed, the same seam re-added), so the ratchet does not grow. ## Verification ``` devtools test tests/integration/test_installed_package_smoke.py devtools test: PASSED exit=0 diagnosis=pytest_passed receipt=.cache/verify/runs/20260914T220651Z-focused-test-4181032-1538359f/run.json devtools test tests/unit/storage/test_absent_index_tier_is_typed.py devtools test: PASSED exit=0 diagnosis=pytest_passed receipt=.cache/verify/runs/20260914T221741Z-focused-test-21251-3a7b6dcd/run.json devtools verify --quick # all 17 gates ok, including layering and schema-manifest ``` Manual, fresh HOME/XDG, at head of this branch: ``` polylogue --plain analyze --count -> 0 polylogue --plain analyze -> outcome: empty (no_rows_in_scope) / Sessions: 0 ... polylogue --plain status -> Daemon: not running / No archive found. / Run `polylogue init` ... polylogue --diagnose find polylogue -> Error: archive index database not found at <path> (exit 1) ``` `tests/unit/storage/test_absent_index_tier_is_typed.py` is new and names its anti-vacuity condition per test: letting `sqlite3.OperationalError` propagate makes the first red; dropping the `exists()` guard makes the second red by reporting a *present but unreadable* tier as "not found, run `polylogue ingest`". ## Schema closure ``` IN polylogue/storage/sqlite/archive_tiers/archive.py out polylogue/cli/archive_query.py out polylogue/cli/commands/status.py out tests/unit/storage/test_absent_index_tier_is_typed.py ``` **`archive_tiers/archive.py` is IN the derived-schema identity closure — this must land before the archive rebuild starts, never during one.** ## Residuals - The defect is fixed at the read boundary for the **index** tier specifically. Other tiers opened read-only elsewhere are untouched; no evidence was gathered that they have the same leak. - `polylogue-wwjy6` names #5043 (`d995eb4e4`) as the best regression candidate. Not bisected — this PR fixes the observable behaviour and does not claim to identify the introducing commit. - The layering gate reports `stale_baseline_count: 43` on `master` today; this PR neither adds to nor reduces that. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Closes the product half of
polylogue-jih4s.The defect
operations/operation_context.py::open_operation_readtreated "nopublication_guardsupplied" as "take the exclusive maintenance-writerlease":
_direct_pin_guard→OwnedArchiveLocation.acquire→os.open(O_RDWR|O_CREAT)+ftruncate+ owner write.The guard seam has exactly one real supplier — the daemon runtime
(
daemon/operation_runtime.py:128) — andOperationContext.direct_readneversets a runtime, so every direct CLI read fell through to the writer lease.
Separately,
cli/operation_kernel.py::configured_read_operationresolved thebearer token before any socket probe, minting
api-auth-tokeninto the archiveroot.
Incidental, not deliberate. The seam's intent is publication exclusion, and
the writer lease was reached for as a stand-in because nothing read-appropriate
existed. And it could never have served that intent: a resident daemon holds
that same lease for its lifetime, so a direct read against a daemon-served
archive would always have been refused.
Two harms: a pure read could not run against a read-only archive, one another
process owned, or any permission-restricted copy — which is directly hostile to
polylogue-sjdk4, whose rollback plan depends on reading a preserved asidearchive. And a read mutated the thing it was reading.
The fix
The unguarded reader route is now optimistic rather than exclusive: resolve
identity → open
read_only=True→ pin snapshots → re-resolve and require theidentity unchanged. A mid-pin republication becomes the typed retryable
ConcurrentArchivePublicationError— never a torn read, never a false success.DaemonClient.auth_tokenaccepts a thunk resolved only after connect.No mutating call site changed; the sole-writer contract is untouched. Every read
on this route was checked for lazy materialization — none needs the lease.
devtools schema closurereportscore/errors.pyas IN the derived-schemaidentity closure, so the new exception is declared in
operation_context.pyinstead. All four edited files are outside the closure; no reconvergence implied.
Verified against the hostile cases, not just the tests
0500, tier files0400):read --all,analyze --facets,findallrc=0, and add zero root entries.succeed and the owner's record survives byte-identical.
These are the conditions the campaign's rollback actually faces.
The
.archive-ownership.lockquestion — settled in design, not yet in those testsA pure read must not require write access to that lock, and no longer does, so a
sealed archive no longer accrues one.
But the two
PermissionErrorfailures elsewhere are not fixed by this, andthe reason is precise: their error is a bare
PermissionError, whereas everyownership acquire wraps
OSErrorintoArchiveOwnershipError. So their failingcall is not an acquire — most likely sealed-directory cleanup of lock files
earlier reads had littered. Removing the producer should help; their owner should
confirm.
Corroborating, found incidentally: a leftover reproduction archive refused
rm -rfuntil chmod'd, because of the.archive-ownership.lockandapi-auth-tokenthis defect had minted into it. That is the sameundeletable-worktree symptom seen repeatedly during this campaign.
3 of 5 target tests fixed — the other two split out deliberately
The remaining two fail for a newly-revealed, unrelated cause:
operations/daemon_reads.pyis a second, thinner implementation of envelopesapi/archive.pyalready builds. I did not regenerate the read snapshot —doing so would have silently blessed
terminal_stateandwordsdisappearingfrom the row payload. Filed as
polylogue-1kavq; triage confirmed neitherfailure can originate in these four edits.
Anti-vacuity
Reverting both fixes turns all 5 new tests red with their original signatures:
the lease-acquisition tripwire,
archive location already owned(foreign owner),cannot open archive ownership lock(sealed root), the lease record rewrittenfrom
pid=previous-writer, and the token-mint tripwire.The three other
tests/unit/operationsfailures were proven pre-existing byre-running them against base product code.
🤖 Generated with Claude Code
https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK