Plan: private staging redesign (#759b) #771

Open
opened 2026-10-30 06:38:11 +00:00 by kayg · 8 comments
Owner

Redesign plan for #759 / #642 after the BM2 findings in #770; plan only, no product code or builds.

Read the plan — branch plan/759b-staging, commit c7464621, based on origin/dev at d83e54db, worktree /home/agent/wt/plan-759b on 6by32-compute01.

Recommends disposable app-created scratch versus conservative adopted-file recovery, bounded private retention with admin reporting, and no per-chunk receipt/intent writes. Includes states, SIGKILL failure table, per-upload metadata/sync costs, reuse/removal scope, and first-PR performance/scaling/crash gates (≥95% of dev throughput on the perf VM; zero scratch leftovers after next-start recovery).

Decisions for kayg: whether same-UID direct edits to app-controlled scratch are outside the preservation promise; seven-day private retention followed by restoration/admin recovery; and process-associated owner locks, since explicit OFD/flock unlock plus CLOEXEC alone does not solve SIGKILL with a fork-only child.

#759 is paused pending review of this plan. No merge or deployment.

Redesign plan for #759 / #642 after the BM2 findings in #770; plan only, no product code or builds. [Read the plan](https://git.kayg.org/kayg/calternal/src/branch/plan/759b-staging/docs/plans/759b-private-staging.md) — branch `plan/759b-staging`, commit `c7464621`, based on `origin/dev` at `d83e54db`, worktree `/home/agent/wt/plan-759b` on 6by32-compute01. Recommends disposable app-created scratch versus conservative adopted-file recovery, bounded private retention with admin reporting, and no per-chunk receipt/intent writes. Includes states, SIGKILL failure table, per-upload metadata/sync costs, reuse/removal scope, and first-PR performance/scaling/crash gates (≥95% of dev throughput on the perf VM; zero scratch leftovers after next-start recovery). Decisions for kayg: whether same-UID direct edits to app-controlled scratch are outside the preservation promise; seven-day private retention followed by restoration/admin recovery; and process-associated owner locks, since explicit OFD/flock unlock plus CLOEXEC alone does not solve SIGKILL with a fork-only child. #759 is paused pending review of this plan. No merge or deployment.
Author
Owner

Independent plan review, round 1. Reviewed plan/759b-staging bd64b7a8 against dev d83e54db, on 6by32-compute01. Read #759 and its decision table (69306), #642/69195, #770/70275 and 70298, current storage docs/ADR, and the fsio, attachment, upload and action-executor paths. Static review only; no builds, measurements, product edits or pushes.

Verdict: approve with edits. The app-scratch/adopted split is the right simplification, conditional on kayg accepting the stated same-UID boundary. The failure table is not yet an implementable guarantee. No P0 found.

  1. P1 — A fork-only child can still prevent the next server from starting. Plan §2, lines 54–67, changes operation ownership, but must explicitly cover installation ownership too. Dev crates/fsio/src/lib.rs:582–615 takes File::try_lock() and explicitly unlocks only in Drop; crates/calternal/src/storage.rs:108–113 requires those Home/state locks before startup. On Linux these descriptor-associated locks survive in the fork child's inherited open descriptions. Scenario: server holds both root locks, forks a child that neither execs nor closes them, then receives SIGKILL. POSIX operation locks disappear correctly, but the new server cannot acquire the installation locks and never reaches recovery. CLOEXEC and explicit destructor unlock do not solve this case. Make the death-safe ownership decision cover these locks, preserve exclusion against another state root, and test an actual server restart with the child alive. The sentence “cover … data/state recovery” is insufficiently specific about changing this prerequisite.

  2. P1 — Publication reconciliation needs a stable key and an admission barrier; dev does not already supply them. Plan lines 41–45 and table lines 92–94 promise retry reconciliation. Dev attachments/src/place.rs:96–110 publishes, drops pending, then best-effort updates the hash index. engine/src/execute.rs:134–162 stores idempotency only after the handler returns. calternal/src/main.rs:165–169 starts attachment cleanup in the background. Scenario: kill after exclusive placement but before index/result commit; on restart retry the same upload before recovery processes its intent. Neither the hash index nor engine dedup proves the first placement, so a second name can be published. Persist the user, original idempotency key and action/input identity, not merely an HTTP request ID, and gate affected keys/placement on reconciliation. Define finalization after the engine's durable result commit, including commit failure. Keep unrelated startup/health fast. The table's reference to “existing idempotency reconciliation” is false for this window.

  3. P2 — The POSIX choice is sound, but its lifetime protocol and acceptance tests need to cover process-wide lock semantics. Plan lines 58–63 correctly identify fork, sibling threads and the any-close hazard. F_SETLK is available on Linux (including OrbStack Linux guests) and macOS; it is not inherited by a fork child and is released when the owning process dies. However, one centralized fd alone is not enough: record locks belong to the process, are not counted per guard, and a same-process acquisition can convert an existing lock. Scenario: overlapping shared root-handshake guards A/B use the same range; A explicitly unlocks while B is between mkdir and owner-lock installation. A separate recovery process can now enter unless a process-local root gate/reference count prevents it. Similarly, a scanner opening and closing another fd to that lock inode drops the process's locks. Require one inode-keyed owner of all opens/dups/unlocks and local root/recovery synchronization, with a fixed lock order. Add tests for overlapping guards, same-process concurrent recovery and an independent process probing the lock after an unrelated same-inode fd closes. Run the owner/fork/restart cases on Linux and native macOS; a Linux VM running on a Mac does not validate Darwin semantics. These are missing from the explicit first-PR matrix, not evidence that F_SETLK itself is unsuitable.

  4. P2 — The two completion fsyncs are not justified by the stated crash model, and the cost accounting misses a directory. Plan lines 105–115 explicitly limit the new claim to process death. A fully written record installed before publication remains in the surviving kernel after SIGKILL; physical record/directory flushes are not required solely for that guarantee. Some completion metadata is needed for finding #2; dev does not close the gap. Either remove the two extra flushes for this limited contract, or explain the additional power-loss guarantee and its full ordering. Also, dev fsio/src/beneath.rs:177–186 publishes within one directory and syncs that directory. Moving publication from private staging to a public directory changes two parents; durable retirement needs the source parent accounted for too (compare fsio/src/directory.rs:58–67). The fixed overhead therefore needs a complete syscall/durability budget, including construction and retirement, rather than simply “reuse dev's … directory syncs.” Zero extra per-chunk work is credible; ≥95% throughput is plausible, not established by O(N). Gate end-to-end response time, include small uploads as well as the proposed large ones, and measure concurrent note-save latency so extra metadata flushes cannot hide behind good aggregate throughput.

  5. P2 — Held evacuation needs its own missing stop boundaries, or should be simplified. Plan lines 69–78 and table line 97 say exclusive destination plus inventory makes replay idempotent, without specifying their order. Scenario: move the unknown inode to recovered/, then die before installing the inventory; the source is gone and the claimed export/disposition record is missing. Copying instead needs crash handling after destination creation, after its durability, and before source retirement, without duplicate recoveries. Define a replayable destination identity/intent before mutation and retire source/metadata last, or use a same-filesystem exclusive move into a self-describing operation directory that recovery can enumerate. Also add stops after completion-intent installation but before placement, after placement but before attachment index update, after index update but before engine commit, and during intent retirement. For cancellation, explicitly require payload removal before deletion of its last authority record. The broad existing table rows do not establish these orderings.

  6. P2 — The proposed hardlink fallback contradicts the current accepted ADR and is unnecessary scope. Plan table line 93 retains link/unlink publication. Current docs/adr/0062-user-files-on-hdd-app-data-on-ssd.md:140–145 supersedes the hardlink fallback, and lines 170–175 explicitly forbid falling back to hardlinks on ext4. Dev fsio/src/lib.rs:163–175 already supports exclusive native rename on Linux and Apple and safely refuses unsupported operations. Scenario: crash after link but before unlink leaves the app-created public/private alias the newer ADR disallows, adding another recovery branch and authority exception. Use native exclusive rename for the new private path and fail safely when unavailable; if a compatibility exception is intended, obtain and document it explicitly.

The proposed first-PR tests are otherwise feasible and useful: real-child deterministic stops plus an ordinary-binary randomized kill loop complement each other. Random byte/time offsets do not prove syscall-boundary coverage. Use an injectable clock for deadline tests, explicit client counts and a defined paired-run statistic for the perf gate, fresh content/keys to avoid dedup measuring a different workload, and a precise recovery barrier that does not require idle live uploads to disappear. No performance or platform pass is claimed by this review.

Cuts that preserve the product rules:

  • Remove the seven-day waiting state: immediately try journal restoration, then move genuinely unknown bytes to an admin-only, self-describing recovery directory on the same filesystem. This bounds staging cleanup without deleting possibly unique data. It does not reclaim that data's disk space.
  • Keep a simple diagnostic and discoverable recovery files; defer the new export/disposition inventory workflow, deadline persistence and scheduler unless there is a concrete administrative requirement.
  • Reuse existing upload admission (server/src/upload.rs:34–74: global/per-user permits) and quota machinery. Those do not by themselves bound accumulated recovered bytes; account for those bytes and apply existing admission/backpressure rather than introducing a second configurable cap system in this PR.
  • Keep the minimum completion record/key reconciliation required by finding #2, but remove physical flushes whose only stated purpose is surviving process death. Do not add per-chunk intents, receipts or hash passes.
  • Drop the hardlink fallback. Retain guarded adopted-file preservation and the targeted lock registry; those enforce actual rules rather than optional workflow.

Plan references above are to bd64b7a8; dev references are to d83e54db.

Independent plan review, round 1. Reviewed `plan/759b-staging` **bd64b7a8** against **dev d83e54db**, on **6by32-compute01**. Read #759 and its decision table (69306), #642/69195, #770/70275 and 70298, current storage docs/ADR, and the fsio, attachment, upload and action-executor paths. Static review only; no builds, measurements, product edits or pushes. **Verdict: approve with edits.** The app-scratch/adopted split is the right simplification, conditional on kayg accepting the stated same-UID boundary. The failure table is not yet an implementable guarantee. No P0 found. 1. **P1 — A fork-only child can still prevent the next server from starting.** Plan §2, lines 54–67, changes operation ownership, but must explicitly cover installation ownership too. Dev `crates/fsio/src/lib.rs:582–615` takes `File::try_lock()` and explicitly unlocks only in `Drop`; `crates/calternal/src/storage.rs:108–113` requires those Home/state locks before startup. On Linux these descriptor-associated locks survive in the fork child's inherited open descriptions. Scenario: server holds both root locks, forks a child that neither execs nor closes them, then receives SIGKILL. POSIX operation locks disappear correctly, but the new server cannot acquire the installation locks and never reaches recovery. CLOEXEC and explicit destructor unlock do not solve this case. Make the death-safe ownership decision cover these locks, preserve exclusion against another state root, and test an actual server restart with the child alive. The sentence “cover … data/state recovery” is insufficiently specific about changing this prerequisite. 2. **P1 — Publication reconciliation needs a stable key and an admission barrier; dev does not already supply them.** Plan lines 41–45 and table lines 92–94 promise retry reconciliation. Dev `attachments/src/place.rs:96–110` publishes, drops pending, then best-effort updates the hash index. `engine/src/execute.rs:134–162` stores idempotency only *after* the handler returns. `calternal/src/main.rs:165–169` starts attachment cleanup in the background. Scenario: kill after exclusive placement but before index/result commit; on restart retry the same upload before recovery processes its intent. Neither the hash index nor engine dedup proves the first placement, so a second name can be published. Persist the **user, original idempotency key and action/input identity**, not merely an HTTP request ID, and gate affected keys/placement on reconciliation. Define finalization after the engine's durable result commit, including commit failure. Keep unrelated startup/health fast. The table's reference to “existing idempotency reconciliation” is false for this window. 3. **P2 — The POSIX choice is sound, but its lifetime protocol and acceptance tests need to cover process-wide lock semantics.** Plan lines 58–63 correctly identify fork, sibling threads and the any-close hazard. F_SETLK is available on Linux (including OrbStack Linux guests) and macOS; it is not inherited by a fork child and is released when the owning process dies. However, one centralized fd alone is not enough: record locks belong to the process, are not counted per guard, and a same-process acquisition can convert an existing lock. Scenario: overlapping shared root-handshake guards A/B use the same range; A explicitly unlocks while B is between mkdir and owner-lock installation. A separate recovery process can now enter unless a process-local root gate/reference count prevents it. Similarly, a scanner opening and closing another fd to that lock inode drops the process's locks. Require one inode-keyed owner of **all** opens/dups/unlocks and local root/recovery synchronization, with a fixed lock order. Add tests for overlapping guards, same-process concurrent recovery and an independent process probing the lock after an unrelated same-inode fd closes. Run the owner/fork/restart cases on Linux and native macOS; a Linux VM running on a Mac does not validate Darwin semantics. These are missing from the explicit first-PR matrix, not evidence that F_SETLK itself is unsuitable. 4. **P2 — The two completion fsyncs are not justified by the stated crash model, and the cost accounting misses a directory.** Plan lines 105–115 explicitly limit the new claim to process death. A fully written record installed before publication remains in the surviving kernel after SIGKILL; physical record/directory flushes are not required solely for that guarantee. Some completion metadata **is needed** for finding #2; dev does not close the gap. Either remove the two extra flushes for this limited contract, or explain the additional power-loss guarantee and its full ordering. Also, dev `fsio/src/beneath.rs:177–186` publishes within one directory and syncs that directory. Moving publication from private staging to a public directory changes two parents; durable retirement needs the source parent accounted for too (compare `fsio/src/directory.rs:58–67`). The fixed overhead therefore needs a complete syscall/durability budget, including construction and retirement, rather than simply “reuse dev's … directory syncs.” Zero extra per-chunk work is credible; ≥95% throughput is plausible, **not established by O(N)**. Gate end-to-end response time, include small uploads as well as the proposed large ones, and measure concurrent note-save latency so extra metadata flushes cannot hide behind good aggregate throughput. 5. **P2 — Held evacuation needs its own missing stop boundaries, or should be simplified.** Plan lines 69–78 and table line 97 say exclusive destination plus inventory makes replay idempotent, without specifying their order. Scenario: move the unknown inode to `recovered/`, then die before installing the inventory; the source is gone and the claimed export/disposition record is missing. Copying instead needs crash handling after destination creation, after its durability, and before source retirement, without duplicate recoveries. Define a replayable destination identity/intent before mutation and retire source/metadata last, or use a same-filesystem exclusive move into a self-describing operation directory that recovery can enumerate. Also add stops after completion-intent installation but before placement, after placement but before attachment index update, after index update but before engine commit, and during intent retirement. For cancellation, explicitly require payload removal before deletion of its last authority record. The broad existing table rows do not establish these orderings. 6. **P2 — The proposed hardlink fallback contradicts the current accepted ADR and is unnecessary scope.** Plan table line 93 retains link/unlink publication. Current `docs/adr/0062-user-files-on-hdd-app-data-on-ssd.md:140–145` supersedes the hardlink fallback, and lines 170–175 explicitly forbid falling back to hardlinks on ext4. Dev `fsio/src/lib.rs:163–175` already supports exclusive native rename on Linux and Apple and safely refuses unsupported operations. Scenario: crash after link but before unlink leaves the app-created public/private alias the newer ADR disallows, adding another recovery branch and authority exception. Use native exclusive rename for the new private path and fail safely when unavailable; if a compatibility exception is intended, obtain and document it explicitly. The proposed first-PR tests are otherwise feasible and useful: real-child deterministic stops plus an ordinary-binary randomized kill loop complement each other. Random byte/time offsets do not prove syscall-boundary coverage. Use an injectable clock for deadline tests, explicit client counts and a defined paired-run statistic for the perf gate, fresh content/keys to avoid dedup measuring a different workload, and a precise recovery barrier that does not require idle live uploads to disappear. No performance or platform pass is claimed by this review. **Cuts that preserve the product rules:** - Remove the seven-day waiting state: immediately try journal restoration, then move genuinely unknown bytes to an admin-only, self-describing recovery directory on the same filesystem. This bounds staging cleanup without deleting possibly unique data. It does **not** reclaim that data's disk space. - Keep a simple diagnostic and discoverable recovery files; defer the new export/disposition inventory workflow, deadline persistence and scheduler unless there is a concrete administrative requirement. - Reuse existing upload admission (`server/src/upload.rs:34–74`: global/per-user permits) and quota machinery. Those do not by themselves bound accumulated recovered bytes; account for those bytes and apply existing admission/backpressure rather than introducing a second configurable cap system in this PR. - Keep the minimum completion record/key reconciliation required by finding #2, but remove physical flushes whose only stated purpose is surviving process death. Do not add per-chunk intents, receipts or hash passes. - Drop the hardlink fallback. Retain guarded adopted-file preservation and the targeted lock registry; those enforce actual rules rather than optional workflow. Plan references above are to [bd64b7a8](https://git.kayg.org/kayg/calternal/src/commit/bd64b7a8/docs/plans/759b-private-staging.md); dev references are to [d83e54db](https://git.kayg.org/kayg/calternal/src/commit/d83e54db).
Author
Owner

Revised the plan after round-1 comment 70310 and pushed 32fa5d90 to plan/759b-staging only.

Revised plan

Finding Change Section
1 — P1: inherited installation locks Change Home/state DataLock to death-safe POSIX ownership too. Keep exclusion against another state root. Require actual server restart/recovery while the fork-only child remains alive. §1 Boundary and ownership; §3 Linux/native macOS tests
2 — P1: publication/key gap Completion record stores user, original idempotency key, action/input identity and placement/response identity. Gate affected keys/scopes before retries. Finalize only after durable engine commit; failed/uncertain commit retains the file/record and gate. Removed the false existing-reconciliation claim. §2 Publication and recovery
3 — P2: process-wide lock lifetime One inode-keyed owner controls opens/dups/closes/unlocks. Add local reference-counted root gate and fixed lock order. Test overlapping guards, same-process recovery and unrelated same-inode close requests with an independent probe and raw-close negative control. Require Linux AND native macOS (macos-01-std or Mac Studio). §1; §3 platform tests
4 — P2: flush/cost/performance Remove both completion fsyncs. Budget construction, existing pending flushes, both publication parents, variable database costs and retirement. Gate end-to-end response and concurrent note-save latency as well as throughput; include 4 KiB/256 KiB/4 MiB, fresh content/keys, explicit 1/4 upload clients and median paired ratios. §3 Cost and first-PR gates
5 — P2: recovery cuts and stop points Remove seven-day Held state, deadline persistence, inventory workflow, scheduler and new cap system. Journal restoration first; unknown bytes go immediately by exclusive rename to self-describing same-filesystem admin recovery directories. Identity/intent first, source metadata last. Charge recovered bytes to existing quota/admission. Add all publication/recovery stops and payload-before-last-authority cancel order. §2 recovery and SIGKILL table; §3 tests
6 — P2: hardlink fallback Use native exclusive rename only; fail safely when unsupported, following ADR 0062. No link/unlink recovery branch. §2 publication; §3 budget

Question 1 remains in plain language; question 2 is removed; question 3 remains decided. The test plan includes an injectable clock and a precise recovery barrier that permits live idle uploads and persistent lock files.

Validation: rendered the document to 3 A4 pages with its print styles; git diff --check passed. Only the plan changed. No code changes, builds, runtime/platform tests or performance measurements were run; those remain first-implementation-PR gates.

Revised the plan after round-1 comment 70310 and pushed **32fa5d90** to `plan/759b-staging` only. [Revised plan](https://git.kayg.org/kayg/calternal/src/commit/32fa5d9079d4629d7b6b4d7f01825a1c1aa5211b/docs/plans/759b-private-staging.md) | Finding | Change | Section | |---|---|---| | 1 — P1: inherited installation locks | Change Home/state DataLock to death-safe POSIX ownership too. Keep exclusion against another state root. Require actual server restart/recovery while the fork-only child remains alive. | §1 Boundary and ownership; §3 Linux/native macOS tests | | 2 — P1: publication/key gap | Completion record stores user, original idempotency key, action/input identity and placement/response identity. Gate affected keys/scopes before retries. Finalize only after durable engine commit; failed/uncertain commit retains the file/record and gate. Removed the false existing-reconciliation claim. | §2 Publication and recovery | | 3 — P2: process-wide lock lifetime | One inode-keyed owner controls opens/dups/closes/unlocks. Add local reference-counted root gate and fixed lock order. Test overlapping guards, same-process recovery and unrelated same-inode close requests with an independent probe and raw-close negative control. Require Linux AND native macOS (macos-01-std or Mac Studio). | §1; §3 platform tests | | 4 — P2: flush/cost/performance | Remove both completion fsyncs. Budget construction, existing pending flushes, both publication parents, variable database costs and retirement. Gate end-to-end response and concurrent note-save latency as well as throughput; include 4 KiB/256 KiB/4 MiB, fresh content/keys, explicit 1/4 upload clients and median paired ratios. | §3 Cost and first-PR gates | | 5 — P2: recovery cuts and stop points | Remove seven-day Held state, deadline persistence, inventory workflow, scheduler and new cap system. Journal restoration first; unknown bytes go immediately by exclusive rename to self-describing same-filesystem admin recovery directories. Identity/intent first, source metadata last. Charge recovered bytes to existing quota/admission. Add all publication/recovery stops and payload-before-last-authority cancel order. | §2 recovery and SIGKILL table; §3 tests | | 6 — P2: hardlink fallback | Use native exclusive rename only; fail safely when unsupported, following ADR 0062. No link/unlink recovery branch. | §2 publication; §3 budget | Question 1 remains in plain language; question 2 is removed; question 3 remains decided. The test plan includes an injectable clock and a precise recovery barrier that permits live idle uploads and persistent lock files. Validation: rendered the document to **3 A4 pages** with its print styles; `git diff --check` passed. Only the plan changed. No code changes, builds, runtime/platform tests or performance measurements were run; those remain first-implementation-PR gates.
Author
Owner

Independent plan review, round 2 of at most 3. Reviewed plan/759b-staging 32fa5d9079 against dev d83e54db, on 6by32-compute01. Verified the remote branch head. Read round-1 review 70310 and response 70315, #759/69306, #642/69195, #770/70275 and 70298, storage docs/ADR 0062, and the requested dev paths. Static review only; no builds, runtime tests, measurements, plan edits or pushes.

Verdict: approve with edits. No P0/P1 finding in this round; the stated redesign trigger is not met. Two P2 edits remain. Approval of the fast scratch path remains conditional on kayg's answer to Question 1; this review does not decide the same-UID preservation boundary.

Findings, ranked

  1. P2 — NEW: Restore the destination-inheritance requirement and account for its cost. Evidence: plan §1 lines 19–27, 63–66, §3 138–142, 177–185. The previous plan explicitly retained #759's inheritance rules (bd64b7a8:123–125); the revision omits that requirement and its test. Dev crates/attachments/src/stage.rs:165–174 creates the payload in the final destination folder; crates/fsio/src/beneath.rs:134–145 lets that kernel create inherit the destination's policy. Cross-directory staging already checks inherited group, setgid and attributes in crates/fsio/src/lib.rs:395–415, 438–453; crates/fsio/src/directory.rs:43–49 rechecks policy before publication.

    Scenario: Documents/YYYY/YYYY-MM-DD has a setgid group/default ACL different from .calternal/tmp/<operation>. A new upload is created privately and renamed into that public folder. Rename preserves the inode's existing group/ACL; it does not apply the destination's defaults. The upload can be acknowledged successfully while ordinary filesystem clients who previously inherited access can no longer read it. Reusing the exclusive rename alone does not preserve dev's behavior.

    Concrete edit: explicitly preserve destination-equivalent group/ACL/security inheritance and revalidate the relevant policy before publication, using the existing fsio policy machinery where applicable. Define a safe refusal or supported private staging strategy for mismatches; a fallback must still meet the no-public-prefix rule. Add a destination-policy-change/mismatch test and include the required metadata calls in the cost trace. This is a missing requirement, not a request for a new permissions subsystem.

  2. P2 — NEW: The new p95 acceptance gates lack a sample/overlap protocol. Evidence: plan §3 157–167 specifies client counts and three cold/five warm pairs, but no upload count or minimum run duration, no minimum note-save sample count, and no required overlap of those samples with upload activity. Dev crates/perf/src/scenarios/uploads.rs:16–45 supplies a different fixed workload: twenty 8 MiB uploads and ten edits per upload separated by 20 ms. crates/perf/src/stats.rs:52–58, 84–96 computes nearest-rank percentiles and treats single-sample runs differently. That existing scenario does not implement the newly specified size/client/rate matrix.

    Scenario: a 4 KiB warm upload finishes before the first periodic note save. Three/five paired runs can then produce no overlapping save samples, or a purported p95 based on one or a few saves taken mostly after upload completion. Such a run cannot establish the intended concurrent-save latency gate, even when the upload ratio passes. Repeating the existing fixed 8 MiB scenario would also miss the required small-upload workloads.

    Concrete edit: require the first PR to extend the harness, predeclare requests/duration and minimum valid samples per workload, sustain uploads while collecting the 1-save/second client, and reject missing/insufficient/non-overlapping samples. Define paired ratios as head/dev throughput and head/dev within-run p95, reporting cold and warm separately. Keep the stated thresholds. This adds a reproducible measurement contract, not another benchmark system.

Round-1 resolution audit

Round-1 finding Verified in the revised document
1 — inherited installation locks Resolved at plan level: §1 39–45 explicitly changes Home/state DataLock, locks every validated root and preserves exclusion with another state root. §3 177–183 requires a real server restart/recovery with the fork-only child alive on Linux and native macOS. This now covers the prerequisite in dev fsio/src/lib.rs:582–615 / calternal/src/storage.rs:108–113.
2 — publication/key gap Resolved at plan level: §2 72–94 records user/original key/action/input identity, gates affected keys/scopes, reconstructs the result/events, and retains the record/file on failed or uncertain engine commit. Finalization follows durable result commit. This explicitly replaces the missing dev bridge between attachments/src/place.rs:96–110 and engine/src/execute.rs:149–162.
3 — POSIX lifetime Resolved at plan level: §1 47–61 controls all opens/dups/closes/unlocks by inode, releases registry bookkeeping before waits, orders locks, counts overlapping shared guards, and gives same-process recovery exclusive access. §3 180–183 tests independent-process exclusion and the raw-close negative control. No concrete registry/gate deadlock follows from the stated ordering; implementation must preserve it through guard destruction as well as acquisition.
4 — unjustified completion fsyncs / missing parent / perf gates Resolved as requested: §3 129–153 removes both completion flushes, counts both publication parents and variable database costs; 157–167 adds small uploads, end-to-end response and concurrent-save gates. Finding 2 above is a new gap in the newly specified measurement protocol.
5 — recovery order / excessive Held workflow Resolved for the stated process-death model: §2 96–110 installs destination identity/intent before exclusive rename and retires source metadata last; 112–123 covers replay and cancellation ordering. Seven-day Held state, deadline persistence, disposition inventory, scheduler and a second cap system are removed. Source-only/destination-only replay is specified, with conflicting/missing identities failing safely.
6 — hardlink fallback Resolved: §2 88–89 requires native exclusive rename and safe refusal. This follows ADR 0062 140–145 and removes the link/unlink crash branch still present in dev fsio/src/beneath.rs:208–217.

Remaining checks and limits

  • Reconciliation and availability: §2 79–86 explicitly limits blocking to affected keys/placement scope and keeps unrelated startup/health available. Read §3's 172–176 recovery barrier as a test wait, not a pre-listen global barrier. Dev calternal/src/main.rs:142–169 listens and starts recovery in the background. First-PR tests should hold one scope unresolved while proving /healthz, another user's work and unrelated note saves still progress; recovery should commit reconstructed outcomes without recursively entering an execution path waiting on its own gate.
  • Durability/syscall budget: the fixed flush arithmetic is consistent with the requested new-file dev path: pending file+parent are two (stage.rs:190–194, fsio/src/lib.rs:75–81); dev publication is payload+one parent (beneath.rs:177–185), while the proposal is payload+two parents. Thus the proposed fixed total is P(N) + 5 + I + E, one publication-parent fsync beyond dev. The construction/owner/provenance/completion/retirement operations are now visible in the budget. This is still a budget, not an exhaustive measured syscall count; inheritance work from finding 1 must be included. Database opens/checkpoints and newly created public folders must remain separate, as the plan says.
  • Can the perf gate pass? It is a meaningful hard gate once finding 2 is fixed; static review cannot establish a pass. Large uploads avoid BM2's extra per-chunk receipt/append-intent work, but small HDD uploads pay the extra parent sync and operation metadata. O(N) and the fixed flush count do not prove a ≤5% latency regression. A measured failure must block acceptance rather than be averaged away across sizes/layouts or excused by large-file throughput.
  • Host feasibility: Linux perf runs on perf-test-02/03, using binaries built elsewhere and the stated runner/cache controls, are feasible. Native Darwin owner/fork/restart tests belong on macos-01-std or the Mac Studio. PreparedDirectory's optimized implementation is Linux-only in dev (directory.rs:88–94); test its Linux path there and its safe decline/applicable platform behavior on macOS, rather than claiming Linux guest results validate Darwin. No platform or perf pass is claimed here.
  • Simplicity: keep the revised cuts. The completion record/reconciliation bridge and POSIX lifetime owner enforce concrete guarantees; neither needs per-chunk logging or a new recovery scheduler. Question 1's stricter alternative would need its own proof and measurements, not automatic reuse of the fast-path performance assumptions.

Plan line references: 32fa5d90. Dev file references: d83e54db.

Verdict: approve with edits.

Independent plan review, **round 2 of at most 3**. Reviewed `plan/759b-staging` **32fa5d9079d4629d7b6b4d7f01825a1c1aa5211b** against **dev d83e54db**, on **6by32-compute01**. Verified the remote branch head. Read round-1 review 70310 and response 70315, #759/69306, #642/69195, #770/70275 and 70298, storage docs/ADR 0062, and the requested dev paths. Static review only; no builds, runtime tests, measurements, plan edits or pushes. **Verdict: approve with edits.** No P0/P1 finding in this round; the stated redesign trigger is not met. Two P2 edits remain. Approval of the fast scratch path remains conditional on kayg's answer to Question 1; this review does not decide the same-UID preservation boundary. ### Findings, ranked 1. **P2 — NEW: Restore the destination-inheritance requirement and account for its cost.** Evidence: plan §1 **lines 19–27, 63–66**, §3 **138–142, 177–185**. The previous plan explicitly retained #759's inheritance rules (`bd64b7a8:123–125`); the revision omits that requirement and its test. Dev `crates/attachments/src/stage.rs:165–174` creates the payload in the final destination folder; `crates/fsio/src/beneath.rs:134–145` lets that kernel create inherit the destination's policy. Cross-directory staging already checks inherited group, setgid and attributes in `crates/fsio/src/lib.rs:395–415, 438–453`; `crates/fsio/src/directory.rs:43–49` rechecks policy before publication. **Scenario:** `Documents/YYYY/YYYY-MM-DD` has a setgid group/default ACL different from `.calternal/tmp/<operation>`. A new upload is created privately and renamed into that public folder. Rename preserves the inode's existing group/ACL; it does not apply the destination's defaults. The upload can be acknowledged successfully while ordinary filesystem clients who previously inherited access can no longer read it. Reusing the exclusive rename alone does not preserve dev's behavior. **Concrete edit:** explicitly preserve destination-equivalent group/ACL/security inheritance and revalidate the relevant policy before publication, using the existing fsio policy machinery where applicable. Define a safe refusal or supported private staging strategy for mismatches; a fallback must still meet the no-public-prefix rule. Add a destination-policy-change/mismatch test and include the required metadata calls in the cost trace. This is a missing requirement, not a request for a new permissions subsystem. 2. **P2 — NEW: The new p95 acceptance gates lack a sample/overlap protocol.** Evidence: plan §3 **157–167** specifies client counts and three cold/five warm pairs, but no upload count or minimum run duration, no minimum note-save sample count, and no required overlap of those samples with upload activity. Dev `crates/perf/src/scenarios/uploads.rs:16–45` supplies a different fixed workload: twenty 8 MiB uploads and ten edits per upload separated by 20 ms. `crates/perf/src/stats.rs:52–58, 84–96` computes nearest-rank percentiles and treats single-sample runs differently. That existing scenario does not implement the newly specified size/client/rate matrix. **Scenario:** a 4 KiB warm upload finishes before the first periodic note save. Three/five paired runs can then produce no overlapping save samples, or a purported p95 based on one or a few saves taken mostly after upload completion. Such a run cannot establish the intended concurrent-save latency gate, even when the upload ratio passes. Repeating the existing fixed 8 MiB scenario would also miss the required small-upload workloads. **Concrete edit:** require the first PR to extend the harness, predeclare requests/duration and minimum valid samples per workload, sustain uploads while collecting the 1-save/second client, and reject missing/insufficient/non-overlapping samples. Define paired ratios as head/dev throughput and head/dev within-run p95, reporting cold and warm separately. Keep the stated thresholds. This adds a reproducible measurement contract, not another benchmark system. ### Round-1 resolution audit | Round-1 finding | Verified in the revised document | |---|---| | 1 — inherited installation locks | **Resolved at plan level:** §1 **39–45** explicitly changes Home/state `DataLock`, locks every validated root and preserves exclusion with another state root. §3 **177–183** requires a real server restart/recovery with the fork-only child alive on Linux and native macOS. This now covers the prerequisite in dev `fsio/src/lib.rs:582–615` / `calternal/src/storage.rs:108–113`. | | 2 — publication/key gap | **Resolved at plan level:** §2 **72–94** records user/original key/action/input identity, gates affected keys/scopes, reconstructs the result/events, and retains the record/file on failed or uncertain engine commit. Finalization follows durable result commit. This explicitly replaces the missing dev bridge between `attachments/src/place.rs:96–110` and `engine/src/execute.rs:149–162`. | | 3 — POSIX lifetime | **Resolved at plan level:** §1 **47–61** controls all opens/dups/closes/unlocks by inode, releases registry bookkeeping before waits, orders locks, counts overlapping shared guards, and gives same-process recovery exclusive access. §3 **180–183** tests independent-process exclusion and the raw-close negative control. No concrete registry/gate deadlock follows from the stated ordering; implementation must preserve it through guard destruction as well as acquisition. | | 4 — unjustified completion fsyncs / missing parent / perf gates | **Resolved as requested:** §3 **129–153** removes both completion flushes, counts both publication parents and variable database costs; **157–167** adds small uploads, end-to-end response and concurrent-save gates. Finding 2 above is a new gap in the newly specified measurement protocol. | | 5 — recovery order / excessive Held workflow | **Resolved for the stated process-death model:** §2 **96–110** installs destination identity/intent before exclusive rename and retires source metadata last; **112–123** covers replay and cancellation ordering. Seven-day Held state, deadline persistence, disposition inventory, scheduler and a second cap system are removed. Source-only/destination-only replay is specified, with conflicting/missing identities failing safely. | | 6 — hardlink fallback | **Resolved:** §2 **88–89** requires native exclusive rename and safe refusal. This follows ADR 0062 **140–145** and removes the link/unlink crash branch still present in dev `fsio/src/beneath.rs:208–217`. | ### Remaining checks and limits - **Reconciliation and availability:** §2 **79–86** explicitly limits blocking to affected keys/placement scope and keeps unrelated startup/health available. Read §3's **172–176** recovery barrier as a test wait, not a pre-listen global barrier. Dev `calternal/src/main.rs:142–169` listens and starts recovery in the background. First-PR tests should hold one scope unresolved while proving `/healthz`, another user's work and unrelated note saves still progress; recovery should commit reconstructed outcomes without recursively entering an execution path waiting on its own gate. - **Durability/syscall budget:** the fixed flush arithmetic is consistent with the requested new-file dev path: pending file+parent are two (`stage.rs:190–194`, `fsio/src/lib.rs:75–81`); dev publication is payload+one parent (`beneath.rs:177–185`), while the proposal is payload+two parents. Thus the proposed fixed total is **P(N) + 5 + I + E**, one publication-parent fsync beyond dev. The construction/owner/provenance/completion/retirement operations are now visible in the budget. This is still a budget, not an exhaustive measured syscall count; inheritance work from finding 1 must be included. Database opens/checkpoints and newly created public folders must remain separate, as the plan says. - **Can the perf gate pass?** It is a meaningful hard gate once finding 2 is fixed; static review cannot establish a pass. Large uploads avoid BM2's extra per-chunk receipt/append-intent work, but small HDD uploads pay the extra parent sync and operation metadata. O(N) and the fixed flush count do not prove a ≤5% latency regression. A measured failure must block acceptance rather than be averaged away across sizes/layouts or excused by large-file throughput. - **Host feasibility:** Linux perf runs on `perf-test-02/03`, using binaries built elsewhere and the stated runner/cache controls, are feasible. Native Darwin owner/fork/restart tests belong on `macos-01-std` or the Mac Studio. `PreparedDirectory`'s optimized implementation is Linux-only in dev (`directory.rs:88–94`); test its Linux path there and its safe decline/applicable platform behavior on macOS, rather than claiming Linux guest results validate Darwin. No platform or perf pass is claimed here. - **Simplicity:** keep the revised cuts. The completion record/reconciliation bridge and POSIX lifetime owner enforce concrete guarantees; neither needs per-chunk logging or a new recovery scheduler. Question 1's stricter alternative would need its own proof and measurements, not automatic reuse of the fast-path performance assumptions. Plan line references: [32fa5d90](https://git.kayg.org/kayg/calternal/src/commit/32fa5d9079d4629d7b6b4d7f01825a1c1aa5211b/docs/plans/759b-private-staging.md). Dev file references: [d83e54db](https://git.kayg.org/kayg/calternal/src/commit/d83e54db). **Verdict: approve with edits.**
Author
Owner

Applied round-2 findings (orchestrator), plan head 657546c675:

Finding Change
P2 destination inheritance Section 2 publication: apply destination group/setgid/ACL/security policy before rename via existing fsio checks, recheck before rename, safe refusal on mismatch; section 3 construction budget counts the calls.
P2 perf sampling Section 3 perf: extend harness; at least 60 s and 50 uploads per workload; only overlapping note saves count; fewer than 50 overlapping saves = invalid run; cold/warm reported separately.

Round 2 found no P0/P1. Plan is ready for kayg (Question 1 pending).

Applied round-2 findings (orchestrator), plan head 657546c675770a7cb6974dccb8e5cc53e280886a: | Finding | Change | |---|---| | P2 destination inheritance | Section 2 publication: apply destination group/setgid/ACL/security policy before rename via existing fsio checks, recheck before rename, safe refusal on mismatch; section 3 construction budget counts the calls. | | P2 perf sampling | Section 3 perf: extend harness; at least 60 s and 50 uploads per workload; only overlapping note saves count; fewer than 50 overlapping saves = invalid run; cold/warm reported separately. | Round 2 found no P0/P1. Plan is ready for kayg (Question 1 pending).
Author
Owner

Implementation preflight stopped under the “code proves the plan wrong → comment here” rule. No product implementation, push, or PR yet.

Commit-outcome evidence can expire before completion reconciliation. Reviewed approved plan 657546c6 against dev d83e54db on 10by32-01-std.

The plan requires a completion record/public inode to survive a failed or uncertain engine commit, then reconciliation to resolve the durable commit outcome and commit/replay the original key/events exactly once. It does not bound restart delay or specify how that evidence survives idempotency retention.

Dev has a seven-day default (crates/store/src/lib.rs:78–91). Its writer unconditionally prunes old idempotency rows before processing its first command on open (writer.rs:47, 79–81), and again after commits. The permanent journal retains request IDs and event data, but no original idempotency key or canonical action/input hash (schema.rs:18–33). attachments.added carries name/type/shelf/size/content hash, not a key-bound commit witness (attachments/src/actions.rs).

Concrete stop sequence:

  1. Completion installed; payload published and indexed.
  2. Engine transaction commits result plus event.
  3. SIGKILL before completion/pending retirement (also the uncertain-commit window).
  4. Restart after seven days. Opening the user store can prune the original result before reconciliation consults it.
  5. An absent idempotency row now means either “never committed” or “committed, then pruned”. Recommitting can duplicate the original event. Content/path matching does not prove which key committed. Failing closed would protect bytes but leave an ordinary intact completion blocked rather than resolve its promised outcome.

Deterministic characterization passed (one test, zero sleeps): commit an attachments.added event with key/input/result; set only the fixture idempotency timestamp to zero through SQLite; reopen using the default retention; enqueue an empty commit as the exact post-prune writer barrier. The original event remains, lookup of the original key returns None, and committing the same key/event again succeeds and produces two journal events. This demonstrates the existing-store behavior, not a completed redesign or a full crash test.

Command, verbatim:

/usr/local/bin/build-slot.sh cargo test -j3 -p calternal-store tests::completion_reconciliation_loses_key_evidence_after_startup_prune -- --exact --nocapture
running 1 test
test tests::completion_reconciliation_loses_key_evidence_after_startup_prune ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 8 filtered out; finished in 0.00s

Please specify the intended commit-evidence lifetime/protocol in the plan: e.g. pin key-bound commit evidence until completion retirement with pruning ordered behind intent discovery, or persist an exact commit correlation witness that reconciliation can verify against the retained journal. An original request ID could be an additional correlation field, but the completion must still bind the original key/action/input, and the replay/retention behavior needs an explicit test. This is distinct from changing normal retention for already-retired uploads. Also add deterministic stops spanning expiry/pruning and the commit-before-retirement boundary.

I have not selected or implemented either protocol, changed retention, or weakened tests. The temporary diagnostic is preserved locally at /tmp/759b-plan-evidence/diagnostic.patch with its log; the worktree source was restored. Full gates, death matrix, performance, and native Darwin tests were not run because implementation stopped at this finding. Branch/worktree: fix/private-staging-759b, /home/agent/wt/impl-759b, still at d83e54db.

Implementation preflight stopped under the “code proves the plan wrong → comment here” rule. No product implementation, push, or PR yet. **Commit-outcome evidence can expire before completion reconciliation.** Reviewed approved plan `657546c6` against dev `d83e54db` on `10by32-01-std`. The plan requires a completion record/public inode to survive a failed or uncertain engine commit, then reconciliation to resolve the durable commit outcome and commit/replay the original key/events exactly once. It does not bound restart delay or specify how that evidence survives idempotency retention. Dev has a seven-day default (`crates/store/src/lib.rs:78–91`). Its writer unconditionally prunes old idempotency rows **before processing its first command on open** (`writer.rs:47`, `79–81`), and again after commits. The permanent journal retains request IDs and event data, but no original idempotency key or canonical action/input hash (`schema.rs:18–33`). `attachments.added` carries name/type/shelf/size/content hash, not a key-bound commit witness (`attachments/src/actions.rs`). Concrete stop sequence: 1. Completion installed; payload published and indexed. 2. Engine transaction commits result plus event. 3. SIGKILL before completion/pending retirement (also the uncertain-commit window). 4. Restart after seven days. Opening the user store can prune the original result before reconciliation consults it. 5. An absent idempotency row now means either “never committed” or “committed, then pruned”. Recommitting can duplicate the original event. Content/path matching does not prove which key committed. Failing closed would protect bytes but leave an ordinary intact completion blocked rather than resolve its promised outcome. **Deterministic characterization passed (one test, zero sleeps):** commit an `attachments.added` event with key/input/result; set only the fixture idempotency timestamp to zero through SQLite; reopen using the default retention; enqueue an empty commit as the exact post-prune writer barrier. The original event remains, lookup of the original key returns None, and committing the same key/event again succeeds and produces two journal events. This demonstrates the existing-store behavior, not a completed redesign or a full crash test. Command, verbatim: ```text /usr/local/bin/build-slot.sh cargo test -j3 -p calternal-store tests::completion_reconciliation_loses_key_evidence_after_startup_prune -- --exact --nocapture ``` ```text running 1 test test tests::completion_reconciliation_loses_key_evidence_after_startup_prune ... ok test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 8 filtered out; finished in 0.00s ``` Please specify the intended commit-evidence lifetime/protocol in the plan: e.g. pin key-bound commit evidence until completion retirement with pruning ordered behind intent discovery, or persist an exact commit correlation witness that reconciliation can verify against the retained journal. An original request ID could be an additional correlation field, but the completion must still bind the original key/action/input, and the replay/retention behavior needs an explicit test. This is distinct from changing normal retention for already-retired uploads. Also add deterministic stops spanning expiry/pruning and the commit-before-retirement boundary. I have not selected or implemented either protocol, changed retention, or weakened tests. The temporary diagnostic is preserved locally at `/tmp/759b-plan-evidence/diagnostic.patch` with its log; the worktree source was restored. Full gates, death matrix, performance, and native Darwin tests were not run because implementation stopped at this finding. Branch/worktree: `fix/private-staging-759b`, `/home/agent/wt/impl-759b`, still at `d83e54db`.
Author
Owner

Resolved by the orchestrator (plan head 1b411e508f): pin approach. The writer's idempotency prune excludes keys of outstanding completion records, and per-user completion discovery runs before the first prune on open. Records retire only after resolution, so evidence always exists; normal retention unchanged. Tests added to the plan: expiry-crossing restart resolves exactly once; stops between engine commit and retirement. Implementation resumes.

Resolved by the orchestrator (plan head 1b411e508f8898093a20126a82435e92750f72b5): pin approach. The writer's idempotency prune excludes keys of outstanding completion records, and per-user completion discovery runs before the first prune on open. Records retire only after resolution, so evidence always exists; normal retention unchanged. Tests added to the plan: expiry-crossing restart resolves exactly once; stops between engine commit and retirement. Implementation resumes.
Author
Owner

Implementation stopped under the “code proves the plan wrong → stop and comment here” rule. The expiry/pruning resolution in 70564 is understood; this is a separate installation-lock transition gap in approved plan 1b411e508f against dev d83e54db, on 10by32-01-std (Linux arm64).

Mixed-generation installation owners are not mutually excluded. Dev crates/fsio/src/lib.rs:582–615 uses std::fs::File::try_lock() (Linux flock). The plan replaces it with process-associated POSIX F_SETLK. These are independent lock families on this local Linux filesystem. A deterministic two-process characterization demonstrated both orderings: a new POSIX owner remains alive while an independent process acquires the exact dev File::try_lock() primitive on the same persistent .lock inode; and a dev-primitive owner remains alive while the new POSIX owner acquires it. Neither process exits or releases its lock before the other acquires. No sleeps or deadlines are used.

This affects the installation prerequisite, before staging recovery: calternal/src/storage.rs:108–113 takes these same Home/state locks. Its startup/shutdown contract (storage.rs:11–12, 29–32, tests startup_waits_for_a_previous_server_to_release_both_roots and a_lock_held_past_the_longest_grace_still_fails_startup) explicitly requires a new server to wait while the previous server can still write. Merely changing the lock family lets a new binary bypass an old binary still running or finishing shutdown; a later old-binary start can likewise bypass the new owner, including with another state root sharing the Home. I tested the actual locking primitives in separate processes, not two full server instances.

Evidence: first added an independent POSIX exclusion probe. It failed against dev as expected. After an experimental registry-backed POSIX DataLock change, the existing fsio suite plus that probe passed (36 tests, no existing tests changed). The mixed-generation characterization then produced:

/usr/local/bin/build-slot.sh cargo test -j3 -p calternal-fsio tests::staging_759b_mixed_generation_lock_characterization -- --exact --nocapture

running 1 test
legacy_parent=false: BOTH generations acquired the same installation inode
legacy_parent=true: BOTH generations acquired the same installation inode
test tests::staging_759b_mixed_generation_lock_characterization ... ok

That last pass characterizes the gap; it is not an acceptance/regression pass. The full experimental patch, standalone test text, commands and logs are preserved on this VM at /tmp/759b-implementation-evidence/ (experimental-owner-and-characterization.patch, mixed-generation-test.rs, mixed-generation.log, lock-red.log, locks.log, README.txt).

Please settle the transition in the plan: either an explicit, enforceable offline upgrade/rollback requirement for the lock-family boundary, or a compatibility/fencing protocol with mixed-generation tests in both acquisition orders. Holding a legacy flock for the new server's lifetime without additional design reintroduces the living fork-child/SIGKILL problem; checking and immediately unlocking it only protects against an already-running old owner, not a later old opener. I have not selected a transition protocol or silently added a new deployment requirement.

All experimental source changes have been restored; fix/private-staging-759b remains clean at d83e54dbe5. No commit, push or PR. target/ has been deleted and lease heartbeat hb-877b57b0.service stopped. Full gates, the ≥1,000-offset death loop, release/perf runs and native macOS tests were not run because this implementation stopped at the demonstrated plan gap. Native macOS owner/drop/duplicate/fork-restart, Home/state exclusion, shared-guard/alias-close, inheritance and recovery checks remain pending.

Implementation stopped under the “code proves the plan wrong → stop and comment here” rule. The expiry/pruning resolution in 70564 is understood; this is a separate installation-lock transition gap in approved plan **1b411e508f8898093a20126a82435e92750f72b5** against dev **d83e54db**, on **10by32-01-std (Linux arm64)**. **Mixed-generation installation owners are not mutually excluded.** Dev `crates/fsio/src/lib.rs:582–615` uses `std::fs::File::try_lock()` (Linux flock). The plan replaces it with process-associated POSIX `F_SETLK`. These are independent lock families on this local Linux filesystem. A deterministic two-process characterization demonstrated **both orderings**: a new POSIX owner remains alive while an independent process acquires the exact dev `File::try_lock()` primitive on the same persistent `.lock` inode; and a dev-primitive owner remains alive while the new POSIX owner acquires it. Neither process exits or releases its lock before the other acquires. No sleeps or deadlines are used. This affects the installation prerequisite, before staging recovery: `calternal/src/storage.rs:108–113` takes these same Home/state locks. Its startup/shutdown contract (`storage.rs:11–12, 29–32`, tests `startup_waits_for_a_previous_server_to_release_both_roots` and `a_lock_held_past_the_longest_grace_still_fails_startup`) explicitly requires a new server to wait while the previous server can still write. Merely changing the lock family lets a new binary bypass an old binary still running or finishing shutdown; a later old-binary start can likewise bypass the new owner, including with another state root sharing the Home. I tested the actual locking primitives in separate processes, not two full server instances. **Evidence:** first added an independent POSIX exclusion probe. It failed against dev as expected. After an experimental registry-backed POSIX DataLock change, the existing fsio suite plus that probe passed (36 tests, no existing tests changed). The mixed-generation characterization then produced: ```text /usr/local/bin/build-slot.sh cargo test -j3 -p calternal-fsio tests::staging_759b_mixed_generation_lock_characterization -- --exact --nocapture running 1 test legacy_parent=false: BOTH generations acquired the same installation inode legacy_parent=true: BOTH generations acquired the same installation inode test tests::staging_759b_mixed_generation_lock_characterization ... ok ``` That last pass characterizes the gap; it is not an acceptance/regression pass. The full experimental patch, standalone test text, commands and logs are preserved on this VM at `/tmp/759b-implementation-evidence/` (`experimental-owner-and-characterization.patch`, `mixed-generation-test.rs`, `mixed-generation.log`, `lock-red.log`, `locks.log`, `README.txt`). Please settle the transition in the plan: either an explicit, enforceable offline upgrade/rollback requirement for the lock-family boundary, or a compatibility/fencing protocol with mixed-generation tests in both acquisition orders. Holding a legacy flock for the new server's lifetime without additional design reintroduces the living fork-child/SIGKILL problem; checking and immediately unlocking it only protects against an already-running old owner, not a later old opener. I have not selected a transition protocol or silently added a new deployment requirement. All experimental source changes have been restored; `fix/private-staging-759b` remains clean at **d83e54dbe571b625504001a8b6add90d44ca6161**. No commit, push or PR. `target/` has been deleted and lease heartbeat `hb-877b57b0.service` stopped. Full gates, the ≥1,000-offset death loop, release/perf runs and native macOS tests were not run because this implementation stopped at the demonstrated plan gap. Native macOS owner/drop/duplicate/fork-restart, Home/state exclusion, shared-guard/alias-close, inheritance and recovery checks remain pending.
Author
Owner

Resolved by the orchestrator (plan head f8b1db010c): offline upgrade across the flock to POSIX boundary. Deploy and rollback already stop the old server before starting the other (scripts/deploy-prod.sh, PR #773). The new server probes each installation lock with a non-blocking flock at startup, refuses while it is held, and releases it immediately without holding it, so the fork-child issue does not return. No mixed-generation fencing. Tests: an old-style flock holder blocks startup; release lets it proceed. Implementation resumes.

Resolved by the orchestrator (plan head f8b1db010cba7665b628db8678f7b019204dabed): offline upgrade across the flock to POSIX boundary. Deploy and rollback already stop the old server before starting the other (scripts/deploy-prod.sh, PR #773). The new server probes each installation lock with a non-blocking flock at startup, refuses while it is held, and releases it immediately without holding it, so the fork-child issue does not return. No mixed-generation fencing. Tests: an old-style flock holder blocks startup; release lets it proceed. Implementation resumes.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
kayg/calternal#771
No description provided.