carlos / platform Public

Isolate CLI test configuration and record admission recovery checkpoint

claude agent, operated by paul@keymail.dev b634c448191650b0f9563e2eeaaa577b4ccc789b parent 5d52edd
8 files changed, +28 −8
  • apimode_test.go +3 −1
  • auth_e2e_test.go +5 −2
  • auth_test.go +1 −0
  • config_test.go +1 −0
  • docs/superpowers/plans/2026-10-03-replicator-authority-plan.md +11 −3
  • e2e_test.go +2 −0
  • scopedkeys_e2e_test.go +2 −0
  • update_test.go +3 −2

CI passed — run details

diff --git a/apimode_test.go b/apimode_test.go
index 22d6db970..b4c3b1060 100644
--- a/apimode_test.go
+++ b/apimode_test.go
@@ -3300,6 +3300,7 @@ func TestDefaultAccountConfigDefault(t *testing.T) {
// A config account paired with THIS console is honored without asking
// the console anything.
cfgPath := writeConfig(t, ".", `{"console": "`+s.console+`", "account": "acme"}`)
+ t.Setenv("CARLOS_CONFIG", cfgPath)
a, err := s.defaultAccount(context.Background())
if err != nil || a.Seg != "acme" || a.Exact {
t.Fatalf("config account = %+v, %v; want the name, resolved server-side", a, err)
@@ -3710,7 +3711,8 @@ func TestDefaultAppConfigPairing(t *testing.T) {
`{"accounts":[{"sqid":"bdk","name":"tom@keymail.dev","apps":["shop","blog"]}]}`)
// Paired with THIS console: honored without any fetch.
- writeConfig(t, ".", `{"console": "`+s.console+`", "app": "shop"}`)
+ cfgPath := writeConfig(t, ".", `{"console": "`+s.console+`", "app": "shop"}`)
+ t.Setenv("CARLOS_CONFIG", cfgPath)
app, err := s.defaultApp(context.Background(), apiAcct{Seg: "bdk", Exact: true}, false)
if err != nil || app != "shop" || *hits != 0 {
t.Fatalf("config app = %q, %v, hits=%d", app, err, *hits)
diff --git a/auth_e2e_test.go b/auth_e2e_test.go
index 6d2189118..f7aaa45a2 100644
--- a/auth_e2e_test.go
+++ b/auth_e2e_test.go
@@ -48,14 +48,17 @@ func TestAuthCLI(t *testing.T) {
fc := newFakeConsole(t)
home := t.TempDir()
creds := filepath.Join(home, ".carlos", "credentials")
- env := append(os.Environ(),
+ env := carlosTestEnv(t,
"CARLOS_CREDENTIALS="+creds,
"HOME="+home,
"CARLOS_CONSOLE=",
+ "CARLOS_CONFIG=",
)
run := func(args ...string) (string, error) {
- cmd := exec.Command(bin, args...)
+ ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+ defer cancel()
+ cmd := exec.CommandContext(ctx, bin, args...)
cmd.Env = env
// pick() walks cwd ancestors for .carlos/config, so the subprocess must not run from the real checkout.
cmd.Dir = home
diff --git a/auth_test.go b/auth_test.go
index 5a51b4955..38dd7e89b 100644
--- a/auth_test.go
+++ b/auth_test.go
@@ -23,6 +23,7 @@ func useTempCredentials(t *testing.T) string {
home := t.TempDir()
t.Setenv("HOME", home)
t.Setenv("CARLOS_CONSOLE", "")
+ t.Setenv("CARLOS_CONFIG", "")
t.Chdir(t.TempDir())
path := filepath.Join(t.TempDir(), "carlos", "credentials")
t.Setenv("CARLOS_CREDENTIALS", path)
diff --git a/config_test.go b/config_test.go
index 1089631c0..23cff19b9 100644
--- a/config_test.go
+++ b/config_test.go
@@ -98,6 +98,7 @@ func TestConfigDefaultWalk(t *testing.T) {
home := t.TempDir()
t.Setenv("HOME", home)
t.Setenv("CARLOS_CONSOLE", "")
+ t.Setenv("CARLOS_CONFIG", "")
t.Setenv("CARLOS_CREDENTIALS", filepath.Join(home, "credentials"))
root := filepath.Join(home, "project")
if err := os.MkdirAll(root, 0o755); err != nil {
diff --git a/docs/superpowers/plans/2026-10-03-replicator-authority-plan.md b/docs/superpowers/plans/2026-10-03-replicator-authority-plan.md
index f7509cd50..b045afcf2 100644
--- a/docs/superpowers/plans/2026-10-03-replicator-authority-plan.md
+++ b/docs/superpowers/plans/2026-10-03-replicator-authority-plan.md
@@ -36,12 +36,20 @@ The admission model (`internal/ops/admissionmodel`) is the executable contract;
2. **The barrier (built: `DurabilityContent.Barred`, counted in the snapshot's read transaction; `CompletenessFor` refuses while it is positive; box-wide, so the ancestry query waits for owner scope).** The publisher's snapshot (`snapshotOnce`) treats a day incomplete for an owner while a durable unsettled admission of that owner, or of any fleet whose unacknowledged ancestry includes the admission's fleet, is admitted on or before that day (box-wide: any owner); it is a query over `admissions` and `fleets`, writes nothing, and lifts at settlement. Mirrors: the model's barrier invariant and `TestSuccessorBarredByPredecessorAdmission`, `TestLandedAmbiguousCommitBarsBeforeReadBack`.
3. **Discovery, the uncertainty and the latch (built in the ledger, with review nine's and ten's corrections: `Replay` reads the latch again under the locks and takes its instant after them, and a replay that finds an uncertainty of the fleet open folds into it (one open uncertainty per fleet); publication enumerates an unresolved latch from the ledger's earliest day, returning an error if the interval exceeds 4000 days; every hold write and every admission and settlement dirty their days through `touchDay` with a fresh sequence and `publish` enumerates the latched discoveries' days (`latchedDates`), so publication revisits a day a bound reaches or a barrier leaves; `discoveryState.generation` makes a snapshot read again across a replay; a failed discovery latches the bound and counted set it computed or latches unresolved; `Replay` recomputes the bound in its transaction and closes on `maybeClose`'s test; `uncertainties.discovered_at` floors every closure; `SetPendingCounter` takes an `*atomic.Int64`, lock-free by contract. `Discover` with the fixed bound and the counted set, `uncertainties` and box-wide `holds` rows in one transaction, closed at once with nothing counted or pending; the settlement's hook writing `[admitted_at, settled_at]` and closing when no row and no pending registration remains, the fleet's pending count by `SetPendingCounter`; `EmptySettlement`; a failed transaction latched in memory with its bound and counted tokens, barring publication through the snapshot's `Barred` until `Replay`, one transaction; `DurabilityContent.Held` refusing completeness; the fleet's discovery mutex, registration and the latch's refusal of requests are the gate slice).** `Discover(fleet, at, proof, lastCleanLook)`: under the fleet's discovery mutex (new in `MeteredFleet`: registration, the recheck and the start of a discovery serialise on it, the pending set counted), the fixed bound, the counted set, the `uncertainties` row and the holds of `[from, now]` for the owners reached in one transaction, closed at once with nothing pending; a failed write latches the pending discovery in the existing failure latch (extended with the bound, the owners reached and the counted tokens; the publisher's overlay reaches successors through the ancestry query) and the fleet refuses requests until `Replay`, one transaction as the design has it. Mirrors: `TestZeroPendingClosesAtOnceAcrossMidnight`, `TestFailedDiscoveryLatchBarsUntilReplay`, `TestFailedDiscoveryReplayKeepsSettlements`, `TestReplayHoldsTheLowerBoundWhileOpen`, `TestReplayWritesSettledTokenWhileOpen`, `TestLatchOverlayReachesSuccessor`, the lower-bound tests (the in-flight request across a clean look, the proof term, the earlier-of threshold, the fixed cutoff in both orders, the admission instant, the exact bound, the empty terminals excluded).
4. **The fleet journal, construction backfill and acknowledgement.** `OpenFleet(predecessor, owners, witness)` writes the `open` row and the backfill of every interval its unacknowledged ancestry holds; `stale`, `closing`, `closed` as the design's transactions (closure carries a pending replay and refuses with an unsettled admission); `Acknowledge(successor)` root-first, copying the effective set into `inherited` and writing the holds for the closed ones. The ledger's reach query replaces the model's `reach`. Mirrors: `TestAncestryReachAndRootFirstAcknowledgement`, `TestHealthyChainContributesNothing`, the per-step inheritance invariant as a property test over a recorded schedule.
-5. **The gate and the fleet (built: `internal/ops/litestream_admission.go` and the fleet's wiring in `litestream_metered.go`; `lease.RequestGate` returns a `lease.Admission` whose transport the gate middleware completes at the SDK's finalize step and whose recorder the meter completes beside its own writes, in the worker: registered when `Start` lands, finished when `Finish` lands, abandoned with a late `Start` or a failed `Finish`, unrecorded when `Start` failed; a gate with no ledger is `lease.ProofGate`, admitting with `lease.Unadmitted`, and a gate answering with no admission is refused. The fleet's gate: the proof, a registration in the pending set under the discovery mutex (refused while stale, latched or in discovery), the row committed by one writer goroutine within `admissionBudget`, the recheck under the mutex (stale, latched, in discovery or an epoch passed: `unissued`), a definite failure cancelled with its empty settlement, an ambiguous one read back by its token by the independent retry worker until the ledger answers, left pending and counted meanwhile; past the budget `ErrAdmissionNotDurable` and the writer's outcome resolved by the writer. Discovery once per fleet from `goStaleFrom`, with the pending instants, the proof and the last clean look; a latched one replayed from the watch and at Close. The journal: the open row at build (a fleet that cannot be journalled is not built), `closing` at Close after the final look, `transport-lost` for every issued admission whose transport never finalised, `closed` waited for within `closeSettleWait` with closure retained by the retry worker past it; acknowledgement at Open and at every watch tick until it lands. The helper process does not exist yet, so all of it runs in the agent. Tests: every send admitted and settled, the journal's rows and a replacement's acknowledgement, a discovery between registration and commit refusing the commit at its recheck with the registration counted, the budget and a writer failing against a ledger that cannot answer, transport-lost at Close with the recorder pending.)** Contract (review nine, Opus P2-2; review ten, Opus P2-2): the ledger is never called with the fleet's discovery mutex held, and the pending counter the ledger reads is the lock-free `*atomic.Int64`, so a settlement under the ledger's mutex never waits on the mutex a gate recheck holds while it writes `unissued`; a registration that resolves decrements the counter before it tells the ledger (`EmptySettlement`, or the row's own transition), so the closure test sees the counter already down, and `CloseFleet` closes an open uncertainty on the same test regardless; the ledger's `Discover` does not check the fleet's journal state (the model returns unless open), which is this slice's to enforce before it calls. `MeteredFleet.admit` becomes the proof (unchanged) plus the admission: registration in the pending set under the discovery mutex, the ledger's `Admit`, the recheck, the token handed to the SDK middleware (`lease.RequestGate` returns the token; the callbacks identify it, but the persisted meter attempt still lacks its admission-token association (outstanding); the Deserialize handler return writes `TransportDone`). `lookNow` is the discovery when it finds a change; `closeNow` is `closing` then `closed`. The helper process does not exist yet (Part B): the transport and the recorder run in the agent, so the lifecycle guard is the fleet's own, `transport-lost` is written at `Close` for a transport that never finalised, and `unrecorded` where the meter's `Start` failed. Mirrors: `TestHelperDeathAndRecorderGuard` (as the agent's close), `TestSendNeedsDurableIssuedAdmission` (the middleware refuses without a token), `TestReadBackOnlyAfterTheHandleCloses`, `TestBetweenCommitAndAnswer`.
-6. **The producer fence and recovery.** `admissions.lock` flocked by the agent before its first admission on an open file description every helper will later inherit (today: the agent alone); `OpenDurabilityLedger`'s `recover` extended: with the fence, in one transaction, every unsettled admission `recovered-unknown` with its interval, every fleet not `closed` closed with its interval, every unacknowledged fleet acknowledged root-first by the first fleet built. Mirrors: `TestFenceOutlivesAgent`, `TestFenceHeldTokenSentAfterCrash`, `TestLandedAmbiguousThenCrash`, the kill-at-every-transition tests (a second process reopening the ledger after a kill at each boundary).
-7. **Part C2's reader.** The `holds` rows in the published day (`DurabilityContent`), the reader treating a box-wide row as failing every owner and an owner row as failing that owner alone, and the older-reader marker (a box-wide incompleteness marker whenever any hold exists). Box-wide stays the default; decision 10's per-owner fleets are not built.
+5. **The gate and the fleet (built: `internal/ops/litestream_admission.go` and the fleet's wiring in `litestream_metered.go`; `lease.RequestGate` returns a `lease.Admission` whose transport the gate middleware completes at the SDK's finalize step and whose recorder the meter completes beside its own writes, in the worker: registered when `Start` lands, finished when `Finish` lands, abandoned with a late `Start` or a failed `Finish`, unrecorded when `Start` failed; a gate with no ledger is `lease.ProofGate`, admitting with `lease.Unadmitted`, and a gate answering with no admission is refused. The fleet's gate: the proof, a registration in the pending set under the discovery mutex (refused while stale, latched or in discovery), the row committed by one writer goroutine within `admissionBudget`, the recheck under the mutex (stale, latched, in discovery or an epoch passed: `unissued`), a definite failure cancelled with its empty settlement, an ambiguous one read back by its token by the independent retry worker until the ledger answers, left pending and counted meanwhile; past the budget `ErrAdmissionNotDurable` and the writer's outcome resolved by the writer. Discovery once per fleet from `goStaleFrom`, with the pending instants, the proof and the last clean look; a latched one replayed from the watch and at Close. The journal: the open row at build (a fleet that cannot be journalled is not built), `closing` at Close after the final look, `transport-lost` for every issued admission whose transport never finalised, `closed` waited for within `closeSettleWait` with closure retained by the retry worker past it; acknowledgement at Open and at every watch tick until it lands. The helper process does not exist yet, so all of it runs in the agent. Tests: every send admitted and settled, the journal's rows and a replacement's acknowledgement, a discovery between registration and commit refusing the commit at its recheck with the registration counted, the budget and a writer failing against a ledger that cannot answer, transport-lost at Close with the recorder pending.)** Contract (review nine, Opus P2-2; review ten, Opus P2-2): the ledger is never called with the fleet's discovery mutex held, and the pending counter the ledger reads is the lock-free `*atomic.Int64`, so a settlement under the ledger's mutex never waits on the mutex a gate recheck holds while it writes `unissued`; a registration that resolves decrements the counter before it tells the ledger (`EmptySettlement`, or the row's own transition), so the closure test sees the counter already down, and `CloseFleet` closes an open uncertainty on the same test regardless; the ledger's `Discover` does not check the fleet's journal state (the model returns unless open), which is this slice's to enforce before it calls. `MeteredFleet.admit` becomes the proof (unchanged) plus the admission: registration in the pending set under the discovery mutex, the ledger's `Admit`, the recheck, the token handed to the SDK middleware (`lease.RequestGate` returns the token; the callbacks identify it, and StartAdmitted commits the attempt and token association atomically before a successfully recorded send; the Deserialize handler return writes `TransportDone`). `lookNow` is the discovery when it finds a change; `closeNow` is `closing` then `closed`. The helper process does not exist yet (Part B): the transport and the recorder run in the agent, so the lifecycle guard is the fleet's own, `transport-lost` is written at `Close` for a transport that never finalised, and `unrecorded` where the meter's `Start` failed. Mirrors: `TestHelperDeathAndRecorderGuard` (as the agent's close), `TestSendNeedsDurableIssuedAdmission` (the middleware refuses without a token), `TestReadBackOnlyAfterTheHandleCloses`, `TestBetweenCommitAndAnswer`.
+6. **The producer fence and recovery (built; independent Codex review accepts this slice, Opus pending).** `admissions.lock` flocked by the agent before its first admission on an open file description every helper will later inherit (today: the agent alone); `OpenDurabilityLedger`'s `recover` extended: with the fence, in one transaction, every unsettled admission `recovered-unknown` with its interval, every fleet not `closed` closed with its interval, every unacknowledged fleet acknowledged root-first by the first fleet built. Mirrors: `TestFenceOutlivesAgent`, `TestFenceHeldTokenSentAfterCrash`, `TestLandedAmbiguousThenCrash`, the kill-at-every-transition tests (a second process reopening the ledger after a kill at each boundary).
+7. **Part C2's reader (built; independent Codex review accepts this slice, Opus pending).** The `holds` rows in the published day (`DurabilityContent`), the reader treating a box-wide row as failing every owner and an owner row as failing that owner alone, and the older-reader marker (a box-wide incompleteness marker whenever any hold exists). Box-wide stays the default; decision 10's per-owner fleets are not built.
**What waits.** The helper process (Part B) and the fence's descriptor transfer, until the VFS spike; owner-scoped holds (decision 10); the activator-to-fleet handover (not designed).
## Later, each behind its gate
Part D's uid lifecycle and the sleeping binding (the unit observer extended), claims by identity, the lineage record; Part B on the VFS spike's result; the parameter-dependent pieces last, each only after its decision.
+
+## Codex checkpoint, 2026-10-03
+
+Task 4 slices 6 and 7 and the admission-to-attempt association are implemented on this design branch. The preserved gitless task4b/task4m copies were inspected and left untouched; slice 6 was salvaged with corrected fence lifetime, recovery topology, retry identity and acknowledgement behavior. Successful StartAdmitted writes the attempt and unique association in one transaction. Failed recording retains the existing send-and-hold behavior. Recovery retains the producer fence beyond Close and garbage collection while admissions remain unsettled, preserves participant timestamps, and atomically inherits all recovered unacknowledged histories into the first new fleet. Live acknowledgement remains adjacent and root-first.
+
+New snapshots are V3. Hold rows are validated with their count and a synthetic legacy recording-failure marker; real recording failures remain separate. Owner-aware Scope excludes held owners, while any box-wide hold, barrier or real recording failure still holds every owner. Strict old readers refuse all V3 snapshots, including clean days; permissive old readers see the legacy marker on held or barred days. Production hold creation remains box-wide, so decision 10 is not activated.
+
+Independent Codex reviewers accepted each scoped delta by inspection. Opus is unavailable and its review remains pending. Local normal/race tests and mutation tests are evidence about these implementations, not evidence of AWS/Stripe operation or whole-feature acceptance. The integrated full gate and exact-commit Amadan CI are tracked in the run-root checkpoint notes. Part B, agent wiring, deployment support conditions and all unapproved policy parameters remain blocked as listed above.
diff --git a/e2e_test.go b/e2e_test.go
index 1a30a9d32..5c1dc280d 100644
--- a/e2e_test.go
+++ b/e2e_test.go
@@ -86,6 +86,8 @@ func carlosTestEnv(t *testing.T, extra ...string) []string {
"CARLOS_CREDENTIALS="+filepath.Join(scratch, "credentials"),
"HOME="+scratch,
"CARLOS_CONSOLE=",
+ "CARLOS_CONFIG=",
+ "CARLOS_DESTINATION=",
)
return append(env, extra...)
}
diff --git a/scopedkeys_e2e_test.go b/scopedkeys_e2e_test.go
index 56f27be90..e3bbadecf 100644
--- a/scopedkeys_e2e_test.go
+++ b/scopedkeys_e2e_test.go
@@ -33,6 +33,8 @@ func carlosTestEnv(t *testing.T, extra ...string) []string {
"CARLOS_CREDENTIALS="+filepath.Join(scratch, "credentials"),
"HOME="+scratch,
"CARLOS_CONSOLE=",
+ "CARLOS_CONFIG=",
+ "CARLOS_DESTINATION=",
)
return append(env, extra...)
}
diff --git a/update_test.go b/update_test.go
index 3c0815aaf..e16d12cc6 100644
--- a/update_test.go
+++ b/update_test.go
@@ -119,9 +119,10 @@ func TestUpdateHintGates(t *testing.T) {
maybeUpdateHint("ship")
t.Setenv("CARLOS_NO_UPDATE_CHECK", "")
- writeConfig(t, ".", `{"update_check": "off"}`)
+ cfgPath := writeConfig(t, ".", `{"update_check": "off"}`)
+ t.Setenv("CARLOS_CONFIG", cfgPath)
maybeUpdateHint("ship")
- os.RemoveAll(".carlos")
+ os.Remove(cfgPath)
maybeUpdateHint("edge") // box verb
maybeUpdateHint("version") // parsed output