Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript
240 KB
Raw Blame

Implementation plan

Managed sync reliability contract (#6317) and the two-consumer preparing wedge (#6278 follow-up)

Thread: GBRA-61. Issues: #6317 (new), #6278 (comments of 2026-10-08 15:15Z and 15:25Z). Stacks on #6298 (GBRA-59, PR 1 of #6278) which stacks on #6279 (GBRA-45). Target: PR 3 of the #6278 family, garrytan/gbrain, version stamped at the merge slot (master + 1 PATCH).

0. Why now

Garry's production brain (the #6278 deployment: 0.60.110.0, Postgres via Supavisor transaction pooler, 13,627-entry managed worktree, bulk lanes 6) has not moved sync data since 2026-09-20. Eighteen days, seven upgrades, every health signal green. #6298 contains the wedge (a budget cuts a stuck preparation at 120 s, the root is freed by the 600 s ceiling at the latest, and a member cut twice is held so the catch-up keeps going). This plan is what #6298 does not do: find and remove the cause of this deployment's wedge, make a second wedge of any class impossible to miss, and make the system refuse to call itself healthy while data does not move.

1. What is established (evidence, not hypothesis)

From the reporter's live captures on 0.60.110.0 (#6278, 15:15Z and 15:25Z comments):

  • E1. 16 managed_sync_import requests of one bulk group (manifest 529–544) sat in state='running', claim_phase.phase='preparing' for 25+ minutes while the lease renewed every 10 s. pg_stat_activity: no statement older than ~3 s, no lock wait over ~1 s, no idle in transaction over ~5 s. statement_timeout = 10min on both the pooler and the direct URL. Owner process at 5–20 % CPU, no child processes, no git locks. So this deployment's wedge is a never-settling JS await with nothing in flight at the database. The Phase 0 class #6298 proved (a relation lock wait a transaction-mode pooler hides) is real but is not this deployment's class.
  • E2. prepareManagedSyncMutation on the same 16 rows from a scratch process (fresh engine, pool 10, same host, same DB) completes in 2.6–3.4 s each, 15 s for all 16 four at a time. All 16 intents are lineEndingOnly: true. Nothing in the data or in prepare's own logic hangs.
  • E3. Every wedge had two persistence consumers alive on the host: the serve-resident consumer and the consumer inside the gbrain sync CLI (lanes configured: 6, effective: 6, so the CLI owned the laneRun). The group was claimed by serve 7 s after it booted, 77 s before any sync CLI existed. With the CLI killed and serve alone, the same group reached publishing within 22 s and committed. Observed once: every wedge had at least two consumer-bearing processes on the host, and the one single-consumer attempt published. Up to three processes hosted consumers (src/core/persistence/service.ts:160-163: any process that waits on a write starts one, and the jobs worker waited on 45 adoption writes), and the lone-consumer success was a process 11 minutes old, so "lone process" and "fresh process" are not yet separated (Phase 0 arms ii and iii).
  • E4. fence_repair / chronicle owner_unavailable for weeks: job workers launched with HOME=/root (non-persistent) and GBRAIN_HOME unset minted a new host.json identity after every container restart and saw the binding as another host's. Fixed on their side with GBRAIN_HOME=/data; nothing in gbrain pointed at it.
  • E5. runDrain's stall probe could not fire: fingerprint included claim_expires_at (owner-refreshed) and drain_stalled required !claimable_here (false on the same host). The progress meter printed an ETA from the last good window. Seven upgrades passed process-level acceptance (/health ok, PID alive, sync_running: true).

What #6298 (head 471094d3) already ships against #6317, verified by reading its diff:

  • #6317 item 1 (phase ceiling by phase age): yes. preparation-budget.ts races every preparation against its budget ("the budget wins even when the preparer ignores its signal"); preparation_ceiling_ms (600 s) frees the root from an abandoned preparation; max_preparation_attempts (2) finishes the request failed/preparation_stalled.
  • #6317 item 2 (drain fingerprint, claimable_here): yes for the fingerprint ("Lease columns (updated_at, claim_expires_at) are deliberately absent: a renewal is not progress") and preparation_overdue → preparation_abandoned when the owner pid is this process. The !claimable_here condition still gates the generic drain_stalled; this plan removes it (section 3, B2).
  • #6317 item 4 (observability): partly. claim_phase stamps carry phase, step (~27 await boundaries), waitingOn (git|fs|db|pool|unknown) and the owner process (kind, pid, version); writer status blockers carry operation, intent_kind, preparation_attempts, claim.stall; a live stalled <N>s on <step> progress line prints during a pass. Missing (GBRA-59 confirmed 2026-10-08): the pool gauge is not exposed (waiting_on: 'pool' only when instrumented), no shipped stack dump (Phase 0 used a debug-only SIGUSR2 installer, never shipped), no "consumers alive on this host".
  • Item 5: GBRA-59's PR 2 adds the owner_unavailable reasons matrix (host_mismatch with both ids' prefixes); the host_identity_split doctor check and GBRAIN_HOME propagation for job workers were deferred there "until evidence" and are now this plan's I1 (agreed with GBRA-59).
  • Items 3 and 6: not covered anywhere.

What #6298 does to this deployment's wedge, per GBRA-59: release at 120 s → root stays blocked while the zombie await lives, up to persistence.preparation_ceiling_ms (600 s from claim start) → at the ceiling the root is freed, attempts pinned at the limit, the next claim finishes the request preparation_stalled, the sync holds that file and continues; the breaker stops the run preparation_systemic after 5 consecutive stalls with no commit. So each wedge costs ≤ 10 minutes and one healthy file held. Containment, not a fix.

2. Phase 0 (starts now, read-only, no approval needed): reproduce and name the await

Ubicloud VM (UBI_OWNER=gbra61), Postgres behind PgBouncer in transaction mode (a stand-in: Supavisor queues clients at the pooler where pg_stat_activity cannot see them, so a negative result here does not clear the production trigger), 15k-page fixture, gbrain serve --http plus gbrain sync --source default --no-pull --no-embed with lanes 6, on current master first (the reporter's 0.60.110.0 has master's vendored driver; #6298's head carries #6279's pipelining change to vendor/postgres/src/connection.js:241-252, so a repro there mixes two drivers) and then on #6298's head.

Deliverables, in order:

  1. Reproduce E3: a group claimed by the process without the lane run (start serve, enqueue the run, start the CLI 60–90 s later as the reporter's timeline shows) that stays preparing past 5 minutes with nothing in pg_stat_activity.
  2. Name the await. First instrument: #6298's enterClaimStep stamps (claim_phase.step, waiting_on; the clock reaches every preparer through service.ts preparePersistedMutation), read with gbrain sources writer status --json every 10 s during the wedge on the #6298 build. Second instrument, best effort: the owner under bun --inspect, capturing Debugger.paused call frames and asyncStackTrace; its absence does not fail Phase 0. The arms: (i) serve + sync CLI on the reporter's timeline; (ii) one long-lived consumer only (a serve that has run the catch-up for 30+ minutes, no CLI); (iii) arm (i) plus a jobs-kind process submitting managed_maintenance_adopt_fact_fence writes every 20 s. The write-up states which arms wedged. Time box: 3 hours for arms (i) and (ii) with a 15 k fixture; arm (iii) is dropped first and arm (ii)'s warm-up shortened to 15 minutes if the box is tight. Candidate (a) needs real pool numbers, so the Phase 0 build carries the small vendored-driver accessor from C1 (about 20 lines) from the start; without it (a) is inferred from waiting_on: 'pool' only.
  3. Check the two candidates the code supports, in this order: (a) pool self-deadlock in the claiming process (every ordinary connection checked out by a holder that waits for another connection; invisible through a transaction pooler), using #6298's pool waitingOn and pool-gauge.ts; (b) a cross-process wait on state only the other process has (windowPredecessorAllows, page_write_guards FOR UPDATE held by the other process's open transaction; note that the in-process lane sets are not consulted for a foreign run's rows, since sync-lanes.ts:75-79 laneOf returns null unless this process opened that exact run, so the reporter's rows, which carry the previous day's run id, took the plain FIFO path in both processes); (c) a per-process resource exhausted in a long-lived owner (ordinary pool checked out by idle holders, a reserved connection never returned), which arm (ii) tests; (d) a response lost between the pooler and the driver (a query whose reply never arrives: waiting_on: db with no server-side statement, which matches E1 exactly; the C1 accessor's queued-query count and a per-query age in the driver tell it from (a) and (c)).
  4. Write docs/eval/managed-sync-two-consumer-repro.md with the exact timeline, the stack, and whether #6298's budget cuts it at 120 s and holds after two attempts (E1 class), including how long the root stays blocked per occurrence. The committed write-up uses placeholders for the deployment, hosts and paths (AGENTS.md privacy rule); real names stay in the thread.

Phase 0's answer picks lane A's fix. Preregistered reading of the arms: arm (i) wedges and arm (ii) does not → the second consumer is the cause class, B1 is a cause fix and lane A names the exact await; arms (i) and (ii) both wedge → the cause is in the long-lived owner (candidate (c) or (a)), B1 is only a concurrency policy, lane A targets the owner and B1c's lane hand-off waits for lane A; neither wedges in 3 hours → the trigger is unreproduced, B1 ships as policy, and the production capture from §6 step (4) becomes the evidence. Lanes B–E start at once; B1c (the lane hand-off) and lane A's final choice merge only after arms (i) and (ii) report, so the costliest protocol is never built on the n=1 observation alone. If the await cannot be named in 3 hours, lane A ships the structural fix (B1) alone and the plan says so.

3. Build (one PR, stacked on #6298; lanes are parallel subagents, integrator merges)

Lane A: remove the cause

  • A1. Fix the named await from Phase 0 with a forced-probe regression test (fails on #6298's head, passes with the fix; the repo's flake rule) in the two-process shape (serve consumer + CLI consumer against one Postgres, lanes > 1): with B1 on, the group publishes and only the serve pid appears in its members' claim_phase.owner; with --no-delegate, the group publishes within the window whichever process claims it.
  • A2. If the cause is the pool: the preparation path takes its connections through the long-hold budget (pool-budget.ts) like publication does, so a wave of four prepares can never hold every ordinary connection; a prepare that would need the last connection waits with waitingOn: 'pool' and the budget cuts it.
  • A3. If the cause is cross-process state: the fix is B1 (one consumer) plus the narrowest guard Phase 0 names. (The plan's earlier laneOf refusal is dropped: sync-lanes.ts:75-79 already returns null for a row whose run is not open in this process, so a foreign-run group already takes the FIFO path.)

Lane B: one consumer per host, and a stall that can fire

  • B1. One full consumer per host: the first live resident consumer wins, as a preference. Split into four parts; B1a, B1b and B1d ship in every case; the default of the brain-wide switch persistence.single_consumer is set by Phase 0's preregistered reading (on only when arm (i) wedges and arm (ii) does not; otherwise shipped off, because funnelling every write through an owner that wedges on its own would turn one stuck write into a host-wide stall); B1c exists only under D1 (a) and waits for Phase 0 arms (i) and (ii) (see §2). Scope of the rule: resident kinds (sync, jobs, autopilot, mcp) defer to the first live full consumer; a serve always starts full; short-lived foreground commands (put, import, dream, cycle, sources, cli) keep today's own consumer for the life of their write, because awaitWrite's wake is in-process only (pr6298:service.ts:195 consumer.wake(true); no LISTEN/NOTIFY) and the owner's idle backoff reaches 5 s (pr6298:consumer.ts:193,210), so a waiter-only gbrain put would often return writer_pending; a cross-process wake (pg_notify on admission) is a TODO, not this PR.
    • B1a (probe). The rule lives in startPersistenceConsumer (src/core/persistence/service.ts:80), so it covers every process that waits on a write (awaitWrite, service.ts:160-163: the sync CLI, the jobs worker's adoption writes, gbrain put), not only drainManagedSync. The probe is the database, never a socket: a live row for this host in the B3 persistence_consumers table of a resident kind (serve, sync, jobs, autopilot, mcp), mode full, that is not this process (renewed within 30 s; leases are 30 s, consumer.ts claimLeaseMs ?? 30_000, renewed every 10 s, claim-lease.ts; "lapsed" below means 60 s without renewal), not restart_required (the owner reached #6298's zombie cap, consumer.ts DEFAULT_ZOMBIE_CAP/restartRequired()) and not wedged (the row carries, from the owner's own status(), its zombie count and the age of its oldest abandoned root barrier, because #6298 releases a request at its budget and keeps only an in-process root barrier until the ceiling (pr6298:consumer.ts:678-694,735-745), so an "oldest running claim" would miss exactly the abandoned preparation; wedged = restart_required or any root barrier older than persistence.preparation_ceiling_ms, and a wedged owner stops suppressing), whose binding is state='active'. A serve always starts full (so a serve started beside a running CLI makes two full consumers until that run ends, listed by doctor meanwhile); every other resident kind defers to the first live full row. The persistence IPC socket is not used: src/mcp/resolve-ipc-binding.ts:103-113 opens it only when owner.engine === 'pglite'. A probe the database cannot answer falls back to today's behaviour with one log line. Residual: two processes that start within one renewal of each other can both read no live row and both start full, and nothing bounds that overlap by time (the heartbeat is evidence of a process, not a fenced role; there is no demotion of a consumer that started full). Reconciliation is minimal and explicit: only a consumer that was promoted from waiter-only drains back (finishes its in-flight tasks, claims nothing new, returns to waiter_only) once the elected owner's row is live and healthy again for three consecutive ticks, so a promotion storm after a heartbeat outage converges; two consumers that both started full stay full until one exits, which doctor names. T1b races two starters and asserts persistent overlap is reported, and tests owner recovery after a promotion. This is a preference the plan states as such, not a fenced invariant; a fenced consumer role is deferred to the thin-client parity follow-up. Process identity in the stamp and the row is {kind, pid, nonce, pid_ns} (a random per-process nonce and the pid-namespace inode from /proc/self/ns/pid where readable), because containers sharing one GBRAIN_HOME share a host id and reuse pids (pr6298:claim-phase.ts:93-96 records only kind, pid, version today); owner_pid === process.pid checks (pr6298:sync-drain.ts:329) compare the nonce too.
    • B1b (waiter-only seam). When the probe finds a live full resident consumer that is not this process, startPersistenceConsumer returns a WaiterOnlyConsumer with the consumer's whole external surface (wake() no-op, settlement listeners through settledWaiters, holds() false, foregroundCompletions() 0, status() reporting waiter_only with the owner's pid, stop() no-op; the existing call sites need no change) that claims nothing and writes no heartbeat row. awaitWrite's own timeout is unchanged: a waiter-only process returns writer_pending to its caller exactly as a process whose consumer is busy does today, and never waits longer than the owner's tick plus one lease. startPersistenceConsumer stays synchronous (pr6298:service.ts:88, called synchronously at :108 and :182): the consumer starts in a probing mode that claims nothing and runs the heartbeat probe on its first tick, then settles to full or waiter_only; a waiter-only consumer re-probes on every tick (one indexed read on the consumers table) and promotes when its owner's row is lapsed, wedged, not full, or gone, so promotion follows the owner's progress, not only its liveness (an owner at the zombie cap, DEFAULT_ZOMBIE_CAP = 1, pr6298:consumer.ts:42,483, stops claiming while its heartbeat keeps going; without the per-tick re-probe no process on the host would consume). The probe and the heartbeat are single-flight with a cancellable deadline (the consumer's phaseMs), never a queue of timers; stop() cancels and awaits the in-flight probe or promotion before the engine closes, and a probe result that arrives after stop() is dropped; a probe that cannot answer within its deadline leaves the consumer in probing for that tick and logs once after three misses. A waiter-only process's writer_pending envelope names the owner (kind, pid, claim.stall.step) and puts gbrain sources writer status --source <id> --json in fix.verify, so an agent whose gbrain put waits on a wedged owner is told who holds it instead of polling a receipt that will not settle. promote() turns it into a full consumer in place (same services entry): called when the owner's heartbeat lapses 60 s while a waiter is pending (one log line, [persistence] owner_lapsed promoted_to_consumer) and by the skew fallback in B1d. A live but wedged owner keeps renewing; its row's claim_past_ceiling flag (B1a) makes it stop suppressing after the 600 s ceiling, and before that B2's drain_stalled (naming the owner pid) and B4/I2 are the exits, with the owner's own #6298 budget as the containment (T2). A serve is always a full consumer; a CLI that took its own consumer before a serve started is not demoted (its run ends; doctor lists both meanwhile). PGLite is unchanged (its single-writer lock already allows one process). An owner on another host never suppresses (ownership is per host, persistence_worktrees.owner_host_id).
    • B1c (lane policy over the resolve IPC). Managed sync on top of that: the CLI runs as a pure driver (admits groups, saves the cursor, waits on receipts, prints progress) and sends the lane policy to the owner over the resolve IPC socket every serve already opens (resolve-ipc-binding.ts:100-102, the transport of the sync_start|sync_status|sync_abort family, shared-secret checked), as two new kinds lanes_open {worktree_id, run, lanes} and lanes_close {run} (new members of the IpcRequest union and handler type in resolve-ipc.ts; accepted only from a verified-secret caller on a managed brain for a worktree this host owns). This is not "lane logic unchanged": the CLI's admission reads lane state from its own process (pr6298:sync-run.ts:806 laneApplyMsPerMember for group sizing, :873 lanePolicy().effective for admission depth, :977 the lanes progress line, :846 laneRunOf calling openLanes locally), and step-down happens where the group publishes (pr6298:group-publish.ts:416), which under (a) is the owner. So under (a) the CLI must not call openLanes locally; it reads the effective lane count and apply timing back from the owner in each lanes_renew reply and sizes groups from that. Three kinds, not two: lanes_open (idempotent; the owner calls openLanes(worktreeId, run, lanes, coordinationPath), pr6298:sync-lanes.ts:45, once per run), lanes_renew {run} every 10 s (the CLI heartbeat; it never calls openLanes, which replaces the whole LaneState including the claimed/begun sets, task counts and step-down, pr6298:sync-lanes.ts:44-47), and lanes_close {run} (the owner marks the run closing, so a late renewal is rejected, awaits its own closeLaneRun, pr6298:sync-lanes.ts:54-60, and only then runs cancelOrphanedLaneRows; the CLI's finally waits for the owner's reply before it cancels anything, so the owner's in-flight claims are never cancelled under it). Open and renew are serialized per worktree and run in the owner. The handshake precedes the CLI's first admission, not merely its first awaitWrite, because admission already exposes rows and wakes consumers (pr6298:sync-run.ts:914-934). The owner closes a lane run whose renewals stop for 60 s. The three kinds are registered inside the GBRAIN_SERVE_SYNC_IPC block (resolve-ipc-binding.ts:129-131) so the kill switch disables them with the sync family and B1d's fallback holds. A promoted CLI (B1b) whose run is open in the owner never becomes a second lane runner: laneRoots() in a process that handed a run off returns nothing for that run. New client code: a Postgres branch of the delegation ladder (today sync-delegate.ts:160 gates on probeLivePgliteHolder).
    • B1d (skew and escape hatch). The lanes_open handshake precedes the CLI's first awaitWrite. An owner that cannot take the hand-off makes the CLI print one actionable warning ([sync] the running gbrain serve (pid N) predates lane hand-off; this run uses its own consumer; restart that serve on this gbrain version to remove the second consumer), set the process-level own-consumer flag and promote() any waiter-only consumer already made, so that run behaves as today. The real signals of an older owner are what the existing client already classifies, not a stipulated unsupported_kind: unknown_kind:<kind> from the base server, a missing protocol echo (stale_serve), IPC_UNAVAILABLE, a missing socket or GBRAIN_SERVE_SYNC_IPC=0 (pr6298:src/core/context/resolve-ipc.ts:683-693,860-881, resolve-ipc-binding.ts:129-131); T1c tests a real older serve build, not a stub. Mixed versions the other way: an older serve writes no heartbeat row, so a new CLI beside it starts full (two full consumers until the serve is upgraded); the CLI's start line says so when the binding owner is active but no row exists (owner row missing: older serve or no serve; running own consumer), and the behaviour notice states it. Flags: the existing gbrain sync --no-delegate / GBRAIN_SYNC_NO_DELEGATE=1 (src/commands/sync/args.ts:107) extend to Postgres and mean "keep your own consumer" on both engines (one flag, help text rewritten in user terms; no new --own-consumer); the brain-wide off switch is persistence.single_consumer (default on) with env mirror GBRAIN_SINGLE_CONSUMER=0, following the persistence.preparation_deadlines / GBRAIN_PREPARATION_DEADLINES pattern, so a supervisor running three processes restores today's behaviour in one place. When no live full resident consumer exists: today's behaviour. Decision D1 below covers the alternatives, including (a′) handing the whole drain to the serve through the existing sync_start kind.
  • B2. runDrain notices a same-host stall it cannot fire on today (the gate at pr6298:sync-drain.ts:325 !print.stall.claimable_here), but it does not end #6298's run-continuing containment early: today the drain waits, #6298 frees the root at the 600 s ceiling, holds the file and the run carries on, and firing at the 150 s allowance would turn that recovery into a blocked exit for every one-shot, cron and agent caller. So: from the allowance to the ceiling the drain keeps going and prints the existing live stalled <N>s on <step> line with the owner pid, kind and C3 triple every 10 s (and B4 flips data_moving at the ceiling); drain_stalled fires, regardless of claimable_here, only when the ceiling passes without the root being released, or when the owner's row is wedged/restart_required, naming request, phase, step, owner host, pid and nonce (the claim_phase stamp from #6298 has all of it; #6298 already dropped the lease columns from the fingerprint). The lapsed-owner case: claimable_here is the wrong predicate (claimableWriteSql requires state='queued', pr6298:journal.ts:470,503-506, and a lapsed head is still running), so the drain waits one more window only when head_lapsed is true, the worktree's owner is this host and a live full row exists in persistence_consumers; otherwise it fires at once with cause: owner_missing. Gate item G5: fire at the allowance (the issue's literal ask) vs at the ceiling (this text, the default). The existing preparation_abandoned path (owner is this process) is unchanged. The stop's envelope changes with its meaning: a new cause: owner_wedged_here carries the owner pid and kind, retry_after_ms set to the time left until the 600 s ceiling (after which #6298 frees the root and the next pass holds the entry), next.safe_to_loop: true and fix.next: wait while the ceiling is ahead, and fix.next: tell_user_to_run (restart the named pid) once it has passed; the why text "and nothing here can claim it" (pr6298:sync-drain.ts:536-541), the drain_stalled row in docs/guides/write-refusals.md:416 and the live-sync outcome table are rewritten to match. Window: the stall line starts at the allowance #6298 computes (max(STALL_MS 30 s, budget 120 s + STALL_GRACE_MS 30 s) after STALL_PASSES 3 passes, measured from the stamp's step_since); the exit waits for persistence.preparation_ceiling_ms, which stays untouched. Progress, for B2, B4 and I2 alike, is a committed receipt or a step advance (step_since moving): a 64-member group prepares in waves of four (pr6298:group-publish.ts:553-575) and commits nothing until every wave is done, so a per-member budget is not a group budget and only a head whose step has not advanced for the whole window is stalled.
  • B3. writer status --json carries host.consumers: the processes on this host that hold a consumer (pid, kind from claimOwner().kind in claim-phase.ts, build, started_at, mode full|waiter_only, and the C1 pool numbers), from a small persistence_consumers heartbeat table (one row per process, primary key (host_id, pid, nonce) with pid_ns and started_at columns, so a reused pid after a container restart or across pid namespaces is a new row, renewed by its own single-flight 10 s timer in every full consumer, independent of claim renewal (an idle serve holds no claim), through executeRawDirect like the claim lease; that leaves the ordinary pool only when the dual pool is active (pr6298:postgres-engine.ts:2804-2813), so with a single URL a starved pool does stop the heartbeat, and that is acceptable: the row is a liveness signal, not a progress signal, and a starved owner losing suppression is the wanted outcome; the row also carries the owner's host_json_path, persistence_home and minted_under so I1 can name the owner's file without reading its filesystem, and the wedged fields of B1a; live = renewed within 30 s, lapsed = 60 s; each renewal statement also deletes rows lapsed for more than 60 s in the same CTE, idempotent, no lock; a failed heartbeat write is logged once and never stops the consumer). This is one new schema migration (number taken at the merge slot, bun run new:migration, PGLite and Postgres parity, schema.sql plus the golden tests). Doctor warns two_consumers_on_host only when two live rows of resident kinds (serve, sync, jobs, autopilot, mcp, from claimOwner().kind) on one host have both been alive for longer than 30 s; every other row (put, import, dream, cli, … or younger than 30 s) is listed, not warned.
  • B4. The health surfaces stop calling a parked sync healthy. gbrain sources status / writer status --json carry, per managed source, data_moving, not_moving_since and movement_state: data_moving is false when an unfinished managed-sync cursor (readManagedSyncBacklog, pr6298:sync-drain.ts:589) has had neither a committed managed_sync_* receipt nor a head step advance for longer than persistence.preparation_ceiling_ms (600 s) while a drain or full consumer is live on the owner host; a cursor left between cron or timeout runs with no live consumer is movement_state: parked (informational, not counted against the score), because readManagedSyncBacklog returns every unfinished cursor whether or not a run is active; the movement watermark is the newest completed_at of committed managed receipts in the current source incarnation, not a count (compaction nulls intent and can shrink counts, pr6298:journal.ts:817), read through a partial index (worktree_id, completed_at DESC) WHERE state='committed' added in the same migration (the baseline indexes cover pending, recovery and principal reads only, pr6298:src/schema.sql:2024-2028); sync_running: true (pr6298:src/commands/sources.ts:1256) is always printed beside it. Doctor check managed_sync_not_moving (warn, counts against the score only for not_moving, never for parked; structured fix gbrain sources writer status --source <id> --json, never unstructured, pr6298:src/commands/doctor/check-fix.ts:127-138) uses the same rule, and gbrain sources status --json prints that exact writer-status command beside data_moving: false, so an agent reaches the request, step and owner in two calls; serve prints one [gbrain notice] when a source flips to not moving. /health stays liveness-only (pr6298:src/commands/serve-http-metrics.ts:216-222) and unauthenticated; the per-source detail lives on the authenticated and CLI surfaces. About 40 lines, sharing I2's snapshot reader.

Lane C: see inside a preparing claim

  • C1. writer status --json ends each running claim with one next_action envelope under the agent operator contract (for a live owner inside its allowance: fix.next: wait with retry_after_ms to the budget; past the ceiling or restart_required: fix.next: tell_user_to_run naming the owner pid and kind for the host admin; for a lapsed claim: fix.next: run the resume command), so the two-call journey ends in an action rather than fields. For each running claim it carries: owner {host_id, pid, kind, build}, phase_age_ms, step, step_age_ms, waiting_on, last_sql {label, age_ms} (the label is the first keyword plus table of the statement the step last issued, recorded by the boundedReads wrapper that #6298's prepareManagedSyncMutation already routes every raw preparation read through, into the claim clock; no SQL text, no parameters), and pool {checked_out, max, waiters} read from the vendored driver's own pool arrays (vendor/postgres/src/index.js: open, idle and queued queries; a small exported accessor) when the owner is this process, else from the owner's heartbeat row (B3 carries the numbers); pool-gauge.ts stays what its header says it is (src/core/pool-gauge.ts:5-14: a tracked subset that must never produce available/waiting figures) and is reported beside it as tracked_subset (gate decision G1 chooses between the driver accessor and the subset-only label; default until then: the driver accessor).
  • C2. Gate item G6, default defer: both Eng voices found the signal path unsafe (a pid plus a capability flag does not identify a process across pid namespaces or reuse, and SIGUSR2 terminates a process without a handler) and the native voice found the command not worth its cost, since claim_phase.step, waiting_on and last_sql (C1) already name where a preparation is parked and a stack captured at step entry does not show where the await is suspended. If kept, C2 is gbrain sources writer dump <request-id> [--json] over the resolve IPC kind claim_dump {request_id} only (same socket and secret as lanes_open; the owner must be the resident serve), with no --signal path and no per-boundary new Error().stack (the dump is the clock's step frame list: step, waiting_on, started_at, last_sql); the text that follows describes the dropped signal path for the record: otherwise gbrain sources writer dump <request-id> --signal checks first that the owner's heartbeat row advertises dump: true (a handler exists only from this release; an older or unknown owner is never signalled, pr6298:consumer.ts:175-179 installs none today) and that the pid is on this host and alive, sends SIGUSR2 itself, and waits for claim.last_dump; without the capability it returns a structured dump_unsupported result whose fix names the owner's build and the restart. For another host it prints the owner's host id and pid. The owner writes the dump under its resolved persistence home (persistenceHome(), identity.ts:37, never a literal ~/.gbrain), logs the absolute path on one [persistence] line, and writer status --json shows it as claim.last_dump {path, host_id}; the operator reads the file on the owner's host. The stack comes from the preparation's own frame list that enterClaimStep maintains in an AsyncLocalStorage (step name, waiting_on, started_at, and new Error().stack captured at the boundary), so it works in Bun without the inspector. No page content, no SQL parameters. The SIGUSR2 handler is installed by every full consumer (B3 heartbeat processes) and writes only the dump file.
  • C3. The [persistence] consumer log lines for preparation deadline (budget cut-off), ceiling_exceeded, the preparation_stalled hold and owner_lapsed promoted_to_consumer, and the drain's drain_stalled summary line, print the same step/waiting_on/last_sql triple, so a tail of the log diagnoses a stall without a command.

Lane D: identity that does not drift, upgrade that proves movement

  • I1 (host identity; #6317 item 5). Host identity stays a file (changing the derivation would re-own every binding), but it stops being silent: at consumer start and in doctor, when this process's host.json id differs from the binding owner's and the owner's local_path resolves on this filesystem (same machine-id/volume), doctor emits host_identity_mismatch naming both file paths, the env (HOME, GBRAIN_HOME) each was minted under, and the fix (GBRAIN_HOME=<owner's home> on the supervisor). host.json keeps version: 1 (both readers reject any other version, identity.ts:58,65, so a v2 file would break an older CLI or a rollback reading the same home) and gains an optional minted_under: {home, gbrain_home, hostname, machine_id} that older readers ignore, so the message can name where each came from (item 5 asks for both paths; the env is what makes the fix one line); a file without it reports minted_under: unknown. The printed fix uses the GBRAIN_HOME parent value (config resolution appends .gbrain itself, config.ts:1866-1882). Also flagged, for containers without a stable machine-id (E4's shape): the binding's local_path exists on this filesystem and holds the managed worktree, and this process's host.json was minted after the binding under a different HOME/GBRAIN_HOME. An existing file is never rewritten or re-identified; minted_under is written only at mint time. Test: two processes with different GBRAIN_HOME against one brain; doctor flags it and names both files.
  • I2 (movement proof; #6317 item 6). A deploy ends with data movement, not process liveness. Standalone command gbrain sources writer movement [<source>] [--wait <dur>] [--warn-only] [--json] (same source selection as writer status, persistence-admin.ts:18,173): it snapshots, per active managed source, the newest completed_at of committed managed_sync_* receipts in the current incarnation (B4's watermark, same index), the head's step_since, the managed cursor (op_checkpoints managed-sync index/total and its held count) and the source watermark (sources.last_sync_at, last_commit), waits the window (default max(300 s, configured preparation budget + 60 s); progress inside the window is a commit or a step advance, so a healthy multi-wave group under a raised persistence.sync_preparation_ms reads within_allowance, never not_moving; --wait <dur> takes the same duration syntax as sync's timeouts and overrides; the output prints the effective budget it judged against), and judges each source: moved (at least one new committed publication; a cursor that advanced only by holds, pr6298:sync-run.ts:445-449 advanceHeld, or a last_sync_at touched by an up-to-date check, is not movement), current (nothing pending and no unresolved holds), held (pending work advanced only by holds), not_moving, unknown (the read failed). Exit and envelope per state, all under the agent operator contract (code, why, fix.next, fix.verify): moved/current → exit 0; held → exit 0 with a warning naming the holds and the hold kind's own route (pr6298:sync-holds.ts:341-353: fence holds → gbrain repair fences --source <id>; preparation_stalled holds → gbrain sources writer status --source <id> --json, then gbrain sources retry-held <id>), because the containment #6298 creates is not a stall; within_allowance (no commit yet, but the head's step advanced inside the window: a multi-wave group preparing normally) → exit 0 with retry_after_ms and fix.next: wait; not_moving → exit 1 (the contract's generic failure exit, never 10/11/124) with code managed_sync_not_moving (the one code shared with B4 and doctor; reason: movement_check), fix.argv gbrain sources writer status --source <id> --json, fix.verify the same movement command; unknown → the read failure's own code (database_contention or the engine error), fix.next: report, never managed_sync_not_moving. --warn-only prints the same envelopes and exits 0. gbrain upgrade does not run it: upgrade.ts:231-285 swaps the binary and runs post-upgrade without restarting serve or a sync, and the autopilot --swap-only channel exits for its supervisor to relaunch, so no upgrade call site ever sees the new processes. Instead upgrade and post-upgrade end by printing the supervisor's step (after restarting serve and the workers, run: gbrain sources writer movement, printed bare so it inherits the default window), the docs' upgrade checklist (docs/guides/upgrades-auto-update.md) gets the same step with a supervisor restart-and-verify sequence (restart serve and the workers, gbrain sources writer movement, then gbrain doctor --json), and the code is registered in src/core/error-registry.ts (class → exit code and retryable, bun run build:error-codes; the registry's AST test fails CI on an unregistered literal code, pr6298:src/core/error-registry.ts:1-13) with its catalogue anchor. Decision D2 below (refuse or warn) sets the command's default exit.

Lane E: docs, CHANGELOG, KEY_FILES, behaviour notice

  • docs/guides/live-sync.md (one consumer per host, --no-delegate on Postgres, persistence.single_consumer), the CLI flag registry regenerated for the extended --no-delegate, writer movement (with --wait, --warn-only) and writer dump (src/core/cli-flag-registry.generated.ts), src/core/error-registry.ts entries (class, exit code, retryable; bun run build:error-codes) and catalogue anchors for drain_stalled (updated meaning), two_consumers_on_host, host_identity_mismatch (the name GBRA-59 deferred as host_identity_split is retired in favour of this one, agreed in the file-ownership step), managed_sync_not_moving (shared by B4, doctor and I2; there is no separate upgrade_data_not_moving) and dump_unsupported, each with a full agent-operator envelope (code, why, fix.next with actor, fix.verify) and a contract test per code; docs/guides/write-refusals.md:416 (drain_stalled no longer means "nothing here can claim it") and docs/guides/troubleshooting.md:52-54 (a stuck write can hold its root up to the 600 s ceiling, not budget × attempts) rewritten; one placeholder-free diagnostic transcript (doctor → sources status --json → writer status --json → writer dump) in troubleshooting.md, Coordination: GBRA-59's PR 2 edits the owner_unavailable reasons matrix too; agree file ownership with GBRA-59 before the lanes start. Line numbers in this plan cite master unless prefixed pr6298:; lane subagents restamp against #6298's head before editing (for example startPersistenceConsumer is pr6298:service.ts:88, openLanes pr6298:sync-lanes.ts:45, laneOf pr6298:sync-lanes.ts:131-135). docs/guides/troubleshooting.md (symptom rows for drain_stalled, two_consumers_on_host, host_identity_mismatch, managed_sync_not_moving), docs/architecture/KEY_FILES.md entries for new files, src/core/behavior-change-notice.ts rows for B1 (consumer election is a preference; how the fallback appears) and I2, CHANGELOG in the repo's voice, mirror of the Phase 0 write-up into gbrain-evals.

4. Tests (the smallest set that proves each claim)

  • T1 (E3 regression): two processes (a spawned gbrain serve and the test's CLI drain), one Postgres, lanes 4, 100-page fixture; the group completes within the window; the drain reports which process published; with B1 on, exactly one full-mode consumer heartbeat exists on the host and the CLI found the owner through the table alone (no socket); a second case kills the CLI mid-run and asserts the owner's lane run closes within two leases and its orphaned lane rows are cancelled by the owner.
  • T1b (B1 scope): a jobs-kind process waiting on an adoption write beside a live owner never claims (zero rows with its pid in claim_phase.owner), the write settles for the waiter; then the owner is killed and the waiter promotes itself within two leases and the write still settles; an owner at the zombie cap (restart_required) or with a root barrier past the ceiling makes the waiter promote on its next tick while the owner's heartbeat is still live; two starters within one renewal both start full and doctor reports the persistent overlap; after a promotion the recovered owner is live for three ticks and the promoted consumer drains back to waiter-only; stop() during an unresolved probe returns cleanly and a late probe result is dropped; on PGLite the probe and heartbeat are inert; a put-kind process keeps its own consumer beside a live owner.
  • T1c (B1 skew): a real older serve build (previous release) answering unknown_kind/stale_serve, a missing socket, and GBRAIN_SERVE_SYNC_IPC=0 each make the CLI fall back to its own consumer with the one actionable warning line; the reverse (new serve, older CLI) runs two full consumers; the older CLI writes no row, so doctor lists the serve's row plus claim_phase.owner pids seen on running claims that have no row (consumers_without_heartbeat), which is the only evidence an older process leaves.
  • T1d (B3 doctor): a put-kind row 10 s old beside a serve row produces no warning; two resident-kind rows live for 60 s produce two_consumers_on_host; a row lapsed 90 s is deleted by the next renewal; the migration has its schema golden and PGLite/Postgres parity test.
  • T2 (B2): a same-host owner that renews a preparing claim forever (fault point); the drain exits drain_stalled within 2× the stall window naming the owner pid. A second case: a lapsed claim this process can reclaim is given exactly one extra window, then drain_stalled.
  • T3 (I1): two GBRAIN_HOMEs against one brain; doctor returns host_identity_mismatch with both paths. A second case: a container-shaped fixture with no machine-id, a re-minted host.json under a different HOME and the worktree present at the binding's path; doctor flags it.
  • T4 (I2): writer movement run directly in its states: a pending cursor and a parked consumer exits 1 with managed_sync_not_moving; with the consumer running it exits 0; with nothing pending it skips and exits 0; a healthy source beside a stalled one exits non-zero naming the stalled one; a cursor advanced only by holds reports held, exits 0 and prints the hold kind's route; a 16-member group preparing slowly in waves reports within_allowance and exits 0; --warn-only exits 0 on the not-moving fixture with the summary printed; a slow but healthy group under a raised persistence.sync_preparation_ms passes the bare printed command (within_allowance, then moved); every state's envelope passes the contract test. post-upgrade prints the supervisor step.
  • T5 (C2, only if G6 keeps it): writer dump over the resolve IPC kind on a request parked inside a real preparer await (a barrier inside prepareManagedSyncMutation's import_screen step, not the consumer:preparing fault point, which fires before the preparer enters its named steps, pr6298:group-publish.ts:567-570) returns the step frame list whose last entry names the parked step; a non-serve owner returns dump_unsupported.
  • Full Ubicloud gate on the integrated head (UBI_OWNER=gbra61), merged with #6298's final head, stamped one past it.

5. Decisions for Garry (D-numbers used by the autoplan reviewers)

  • D1. How the CLI and serve share a catch-up. The plan's author recommended (a); after review (a′) is recommended and (a) is kept as the alternative. (a) CLI drives, resident owner consumes, lane policy crosses the resolve IPC socket as lanes_open/lanes_close (lane logic unchanged; in-process state stays in one process; the owner runs and closes the lane run). (a′, now the recommended option: all four CEO and Eng voices prefer it, and the Eng voices showed (a) is not "lane logic unchanged", see B1c) Reuse the serve-delegated sync family as it exists (sync-delegate.ts, serve-sync-runner.ts: sync_start|sync_status|sync_abort, single-flight, Ctrl-C abort, argv allowlist): lift the PGLite gate (sync-delegate.ts:160) and the managed-brain refusal (serve-sync-runner.ts:176) so the serve runs drainManagedSync itself and the CLI only polls; concrete cost: a Postgres branch in sync-delegate.ts:160 that uses the B3 heartbeat instead of probeLivePgliteHolder; an authorization hand-off, not just a lifted gate: the runner runs under withLegacySyncDelegation, and assertDurableSyncCaller refuses managed sync in that context by design (pr6298:src/core/persistence/sync-authority.ts:26-30,78-99,125-127), so the CLI sends its verified cli registration (id + credential, as the PGLite persistence IPC already does, local-client.ts:60-76) in sync_start, the serve verifies it with withVerifiedLocalRegistration (the pattern provider.ts:40-63 uses) and runs drainManagedSync as that writer, keeping revocation and grant checks, with denied, revoked and stdio-principal tests; the secret, managed-brain and bound-source checks stay; and extending the sync_status payload (core/context/sync-ipc.ts) with DrainReport and next; the CLI prints from sync_status instead of in-process progress; the delegation ladder's default-deny argv classifier (sync-delegate.ts:58-105, which today refuses --json and does not admit --lanes/--no-bulk) is extended to admit the managed catch-up's flags explicitly, and gbrain sync --source <id> --no-pull --json is tested unchanged through delegation; --no-delegate bypasses the ladder before the classifier; the serve's event loop hosts the catch-up (measure MCP latency during a drain before rejecting this). It leaves two delegation mechanisms (PGLite persistence IPC, serve-delegated sync) instead of three, and is the path the deferred thin-client parity generalizes. (b) Lane state moves into the database (persistence_lane_runs) so any consumer honors it: more general, a new table and a migration, every lane check becomes a query. (c) CLI refuses to run while a serve is alive: simplest, but then a catch-up means stopping the brain's MCP for an hour or more.
  • D2. Movement check: refuse or warn. (recommended) refuse: writer movement exits non-zero with the writer summary when pending work does not move in the window; --warn-only exists for pipelines that cannot fail. Alternative: warn and exit 0 by default, which is what let seven upgrades pass.
  • D3. Host identity: warn (recommended) or re-derive. Re-deriving from a machine id re-owns every existing binding on upgrade and breaks multi-brain-per-user hosts; warning with both paths and the env fixes E4 in one line.
  • D4. Ship the Phase 0 cause fix in this PR or in its own. Recommended: this PR if Phase 0 names the await inside its 3-hour box and lane A's fix is ready the same day; otherwise this PR ships B–E and the cause fix follows as PR 4 with its own repro. B1 ships in either case: one consumer per host is #6317 item 3 and stands on its own; if arm (ii) (a lone long-lived owner) also wedges, lane A targets the owner and B1 still removes the second consumer. Gate-only taste items: G1 pool numbers in C1 (default: an accessor on the vendored driver; alternative: pool-gauge.ts's subset under the label tracked_subset, no waiters); G2 same-host dead-owner release (a consumer that finds a running claim whose stamped owner pid is dead on this host releases it at once, TODOS.md:135; default: not in this PR). Open at the gate (not auto-decided): whether this stays one PR (Garry's direction) or splits into 3a (B1, B2, B3, C1) and 3b (C2, I1, I2, docs); the spec reviewer recommends a split on size (~25 files); the native CEO voice would split by certainty instead (3a: B2, B4, C1, C3, I1, I2; 3b: B1, B3, C2 and lane A after Phase 0); the outside voice keeps one batched PATCH release. Recommended: one PR with B1c and lane A gated on Phase 0 inside it, splitting by certainty only if Phase 0 is inconclusive by end of day.

6. Interim operational relief (today, no code)

This is an ask for Garry today, not reference material: the fix PR lands days out behind #6279 → #6298 and the merge queue, and the capture in step (4) below is the best Phase 0 evidence available because it comes from the real Supavisor deployment. While #6279 → #6298 land: run the catch-up with exactly one consumer on the host. One consumer means more than stopping serve: every process that waits on a write starts a consumer (src/core/persistence/service.ts:160-163 awaitWrite calls startPersistenceConsumer), and the jobs worker's adoption writes do exactly that (prepared-maintenance.ts:162), so the procedure is: (1) stop serve; (2) pause the jobs worker and autopilot maintenance for the window (fence_repair, chronicle, extract_facts, dream/cycle), and do not run repair ... --apply beside it; (3) run timeout 14400 gbrain sync --source default --no-pull --no-embed in the existing restart loop (no #6298 budget is deployed yet, so a wedge still ends at the watchdog); (4) in a second shell, while sleep 60; do gbrain sources writer status --json >> writer-status.ndjson; done, which is Phase 0's evidence if it wedges anyway; (5) restart serve and the workers. Success looks like: the step (4) log shows phase: publishing and committed receipts, and gbrain sources status default --json shows the managed backlog (index/total) falling pass over pass; the same command after the restart shows data_moving: true once B4 ships. Proven by the reporter's own timeline (E3) for one group; at #6298's measured 120–263 pages/min, 13.6k entries is one to two hours. gbrain sync --no-lanes with serve running keeps two consumers, so by E3 it is not relief; it only tests whether the lane run matters, and is worth one pass only if the one-consumer run cannot be scheduled. MCP access is down while serve is stopped; that is Garry's call.

7. Out of scope

fence_repair during a sync (GBRA-59's PR 2); the adoption writes' pre-submission fence scan (#6298); lanes to 16 and the feeder (#6279); DB-resident lane state unless D1 picks (b); Postgres thin-client parity (every write operation delegating to a live owner over IPC, as PGLite does in local-client.ts), a multi-PR change recorded in TODOS.md at ship time; the laneOf refusal the first draft listed under A3 (redundant, see A3); a cross-process consumer wake (pg_notify on admission) so short-lived foreground commands could also be waiter-only (TODOS.md); a fenced exclusive consumer role (TODOS.md); C2 unless G6 keeps it.

  • CEO-1 (B1 transport): the probe is the B3 persistence_consumers heartbeat row (host localHostId(), any resident kind serve|sync|jobs|autopilot|mcp, mode full, renewed within 30 s, binding state='active', no restart_required, no claim_past_ceiling), never a persistence IPC socket (src/mcp/resolve-ipc-binding.ts:103-113 opens that socket only on PGLite); a probe the database cannot answer falls back to today's behaviour with one log line. With D1 (a), the lane policy crosses the resolve IPC socket every serve opens as lanes_open {worktree_id, run, lanes} / lanes_close {run} (new IpcRequest members in resolve-ipc.ts, verified secret, managed brain, worktree owned by this host); the owner calls openLanes in its own process and its consumer claims the CLI-admitted lane rows through claimNextLaneHead; lanes_open is re-sent every 10 s (the renewal cadence) and is the CLI heartbeat; the owner closes a lane run whose lanes_open stops for 60 s and owns closeLaneRun and cancelOrphanedLaneRows for it; lanes_close is sent on every CLI exit path; unsupported_kind (the handshake precedes the first awaitWrite) makes the CLI warn once, set the process-level own-consumer flag and promote() any waiter-only consumer already made. The first live full resident consumer wins; a serve always starts full; two starters within one renewal can both start full (stated as a preference, not a fenced invariant; T1b races them). B1c and lane A's final choice merge only after Phase 0 arms (i) and (ii) report, under the preregistered reading in §2. Tests T1, T1c.
  • CEO-2 (Phase 0 controls): arms (i) serve + sync CLI, (ii) one long-lived consumer only (30+ minutes, no CLI), (iii) arm (i) plus a jobs-kind process submitting adoption writes every 20 s; the write-up names which arms wedged with the head's claim_phase.step and waiting_on. Lanes B–E do not wait for Phase 0; B1 ships whatever arm (ii) shows.
  • CEO-3 (B1 scope and seam): enforced in startPersistenceConsumer (service.ts:80): with a live same-host owner that is not this process it returns a WaiterOnlyConsumer carrying the consumer's whole external surface (wake() no-op, settledWaiters listeners, holds() false, foregroundCompletions() 0, status() waiter_only + owner pid, stop() no-op) that claims nothing and writes no heartbeat row; awaitWrite's timeout is unchanged (writer_pending as today); promote() converts it in place when the owner's heartbeat lapses 60 s while a waiter is pending (one log line) or on the B1d skew fallback; a live-but-wedged owner stops suppressing once its row shows a claim past the 600 s ceiling (claim_past_ceiling), and before that B2, B4 and I2 are the exits; a serve is always a full consumer; no demotion of an earlier full consumer; PGLite unchanged; another host's owner never suppresses. --own-consumer and GBRAIN_OWN_CONSUMER=1 force the old path. Test T1b.
  • CEO-4 (B3 table and doctor rule): persistence_consumers is one new schema migration (number at the merge slot, PGLite and Postgres parity, schema.sql, golden tests), primary key (host_id, pid, started_at), columns kind (claimOwner().kind), build, started_at, renewed_at, mode, restart_required and the C1 pool numbers; renewed by its own 10 s timer in every full consumer through the direct lane (executeRawDirect), independent of claim renewal, live within 30 s, lapsed at 60 s, each renewal deleting rows lapsed over 60 s in the same CTE; a failed heartbeat write is logged once and never stops the consumer. two_consumers_on_host warns only for two live resident-kind rows (serve, sync, jobs, autopilot, mcp) both older than 30 s. Test T1d.
  • CEO-5 (B2 condition): drain_stalled fires after the #6298 allowance (max(30 s, budget 120 s + 30 s grace), three passes, from step_since) regardless of claimable_here, naming request, phase, step, owner host and pid, except that a lapsed claim a consumer on this host can reclaim gets exactly one more window; preparation_abandoned for this process's own pid unchanged; the 600 s ceiling untouched. Test T2 both cases.
  • CEO-6 (Phase 0 instrument): claim_phase.step/waiting_on from #6298's enterClaimStep, read every 10 s with gbrain sources writer status --json, first; bun --inspect second and optional.
  • CEO-7 (I2 shape): standalone gbrain sources writer movement --wait <seconds> [--json], judged per source from committed managed_sync_* receipts (holds via advanceHeld and up-to-date last_sync_at touches are not movement): moved, current, held, not_moving, unknown; exit 0 only when every source is moved or current, else non-zero upgrade_data_not_moving with the C1 summary (default window 300 s; D2 at the gate sets refuse vs warn as the default, --warn-only prints the summary and exits 0; registry regenerated for --wait/--warn-only); gbrain upgrade and post-upgrade never run it (neither owns the relaunch, upgrade.ts:231-285) and print the supervisor's step; docs/guides/upgrades-auto-update.md and the error catalogue carry it. Test T4: the states plus healthy-beside-stalled and holds-only.
  • CEO-8 (interim relief, section 6): stop serve, pause maintenance submitters, keep the restart loop, capture writer status --json every 60 s, restart; --no-lanes is a sub-hypothesis test, not relief.
  • CEO-9 (scope): A3's laneOf refusal dropped as redundant (sync-lanes.ts:75-79); C2 (step-entry stack over the resolve IPC kind claim_dump or SIGUSR2, handler installed by full consumers), C3 (the triple on the preparation deadline/ceiling/hold lines, the promotion line and the drain_stalled summary) and host.json v2 minted_under are accepted as #6317 items 4 and 5 ask for them; last_sql is recorded by #6298's boundedReads wrapper; Postgres thin-client parity and DB-resident lane state (unless D1 picks (b)) deferred to TODOS.md at ship time and listed in ## 7; flag registry regenerated for --own-consumer, writer movement, writer dump; src/core/behavior-change-notice.ts rows for B1 and I2.
  • CEO-12 (B4, from both voices' top finding): per-source data_moving/not_moving_since on sources status and writer status --json (false after the 600 s ceiling with no committed receipt on an unfinished cursor), doctor managed_sync_not_moving counted in the score, one [gbrain notice] from serve on the flip, /health unchanged; shares I2's reader. Test: a parked consumer flips the field and the doctor check within the ceiling; a moving one never does.
  • CEO-13 (I1 container case): doctor also flags a re-minted host.json (newer than the binding, different HOME/GBRAIN_HOME) when the binding's local_path holds the worktree on this filesystem, so E4's container shape is caught without a machine-id; T3 second case.
  • CEO-14 (D1 at the gate): option (a′) is costed in the plan and marked the reviewers' preference; the choice stays Garry's. Citations are restamped against pr6298 by the lane subagents; GBRA-59 PR 2 file ownership agreed before the lanes start; §6 is put to Garry today as an ask.
  • CEO-11 (Phase 0 box and privacy): 3 hours for arms (i) and (ii); arm (iii) dropped first, arm (ii) warm-up shortened to 15 minutes if tight; the Phase 0 build carries the C1 driver accessor; the committed write-up uses placeholders (AGENTS.md privacy rule). The one-PR-or-split question is open at the gate, not auto-decided.
  • CEO-10 (G1 default): C1 reads checked_out/max/waiters from a small accessor on the vendored driver (vendor/postgres/src/index.js open/idle/queued arrays) and reports pool-gauge.ts beside it as tracked_subset; the gate's alternative is the subset-only label with no waiters. G2 (dead-owner release) default: not in this PR.
  • DX-1 (agent operator contract, replaces the CEO block's "error-catalogue rows"): every code this plan adds or changes (drain_stalled with the new cause: owner_wedged_here, two_consumers_on_host, host_identity_mismatch, managed_sync_not_moving, dump_unsupported) is registered in src/core/error-registry.ts (class → exit code, retryable; bun run build:error-codes) with a catalogue anchor and a full envelope (code, why, fix.next with actor, fix.verify), proven by one contract test per code; doctor fixes are structured, never unstructured. There is no separate upgrade_data_not_moving: B4, doctor and writer movement share managed_sync_not_moving (reason: movement_check on the command).
  • DX-2 (drain_stalled meaning): the same-host live-owner stop carries cause: owner_wedged_here, the owner pid and kind, retry_after_ms to the 600 s ceiling, next.safe_to_loop: true and fix.next: wait before the ceiling, fix.next: tell_user_to_run (restart the named pid) after it; the why string (pr6298:sync-drain.ts:536-541), docs/guides/write-refusals.md:416 and the live-sync outcome table are rewritten. Test T2 asserts the envelope.
  • DX-3 (two-call journey): gbrain sources status --json prints the exact writer status --source <id> --json command beside data_moving: false; writer status --json ends each running claim with one next_action envelope (wait with retry_after_ms inside the allowance; tell_user_to_run naming pid and kind past the ceiling or on restart_required; run the resume command for a lapsed claim). A transcript test proves symptom → next command in two calls without SQL.
  • DX-4 (writer movement surface, supersedes CEO-7's --wait <seconds> and exit wording): gbrain sources writer movement [<source>] [--wait <dur>] [--warn-only] [--json]; default window max(300 s, budget × max attempts + 60 s), printed as the effective budget; states moved/current exit 0, held exit 0 with a warning and fix.argv gbrain repair fences --source <id> (gate G4 may flip to non-zero), within_allowance exit 0 with fix.next: wait, not_moving exit 1 with managed_sync_not_moving, unknown the read failure's own code with fix.next: report; upgrade/post-upgrade print the bare command; the upgrade guide carries the supervisor restart-and-verify sequence. Test T4 covers every state and the slow-but-healthy group.
  • DX-5 (flags, supersedes CEO-3's --own-consumer/GBRAIN_OWN_CONSUMER): the existing gbrain sync --no-delegate / GBRAIN_SYNC_NO_DELEGATE=1 extend to Postgres and keep the CLI's own consumer (help text in user terms; flag registry regenerated for the extension); the brain-wide switch is persistence.single_consumer (default on, env GBRAIN_SINGLE_CONSUMER=0), following the preparation_deadlines pattern; under D1 (a′) the delegation ladder's argv classifier admits the managed catch-up's flags (--json, --lanes, --no-bulk, --no-pull, --no-embed) explicitly and gbrain sync --source <id> --no-pull --json is tested through delegation.
  • DX-6 (skew, supersedes CEO-1's unsupported_kind): the fallback triggers on what an older owner really returns (unknown_kind:<kind>, stale_serve, IPC_UNAVAILABLE, missing socket, GBRAIN_SERVE_SYNC_IPC=0) with one actionable warning naming the pid and the restart; an older serve writes no heartbeat row, so a new CLI beside it starts full and its start line says so; T1c runs a real previous-release serve and the reverse pairing.
  • DX-7 (consumer start): startPersistenceConsumer stays synchronous; the consumer starts in probing mode (claims nothing until the first-tick probe answers) and settles to full or waiter_only; a waiter-only writer_pending envelope names the owner (kind, pid, claim.stall.step) with writer status in fix.verify.
  • DX-8 (writer dump): --signal checks the owner row's dump: true capability and same-host liveness before sending SIGUSR2, else returns dump_unsupported; the dump is written under the owner's persistenceHome() and reported as claim.last_dump {path, host_id}; T5 covers the unsupported owner and an alternate GBRAIN_HOME.
  • DX-9 (host.json, supersedes "v2" in CEO-9/I1): the file keeps version: 1 and gains optional minted_under; existing files are never rewritten; missing metadata reports unknown; the printed fix uses the GBRAIN_HOME parent value.
  • DX-10 (docs): troubleshooting.md:52-54 prose corrected (a stuck write can hold its root up to the ceiling), one placeholder-free diagnostic transcript added, §6 gets its success signal, behaviour notices state that consumer election is a preference and how the fallback appears; GBRA-59's deferred host_identity_split name is retired for host_identity_mismatch.
  • ENG-1 (promotion on progress, supersedes the first-tick-only probe in DX-7/CEO-3): a waiter-only consumer re-probes on every tick and promotes when the owner's row is lapsed, wedged, not full or gone; wedged is derived from the owner's own status() (zombie count, oldest abandoned root barrier age; restart_required or a barrier older than the ceiling), not from running claims; the probe and heartbeat are single-flight with the consumer's phase deadline; stop() cancels and awaits them; late results are dropped; the re-probe backs off with the consumer's idle delay. Test T1b (zombie cap, wedged owner, stop during probe, PGLite inert).
  • ENG-2 (identity): claim stamps and heartbeat rows carry {kind, pid, nonce, pid_ns}; same-process checks compare the nonce; the row's primary key is (host_id, pid, nonce); the row also carries host_json_path, persistence_home, minted_under and the wedged fields.
  • ENG-3 (B2 exit timing, supersedes CEO-5's and DX-2's "fires after the allowance"): the drain prints the stall line with owner pid, kind and the C3 triple every 10 s from the allowance, keeps running, and fires drain_stalled only past the ceiling without a root release or when the owner is wedged; the lapsed-owner wait uses head_lapsed + owner host + a live full row, never claimable_here; sync-drain-claims.test.ts's same-host case is rewritten, the foreign-host case unchanged. Gate G5 may move the exit back to the allowance.
  • ENG-4 (B1 scope and default, supersedes CEO-3's "every waiter"): resident kinds defer; serve starts full; short-lived foreground kinds keep their own consumer; persistence.single_consumer's shipped default is set by Phase 0's preregistered reading (on only if arm (i) wedges and arm (ii) does not); only promoted consumers drain back (three healthy owner ticks); persistent overlap of two full starters is reported, not bounded. A jobs-elected owner cannot run a sync, so the sync CLI runs its own FIFO consumer and says so.
  • ENG-5 (D1): (a′) is the recommended option, costed with the verified CLI-registration hand-off (withVerifiedLocalRegistration, denied/revoked/stdio tests) instead of lifting assertDurableSyncCaller; under (a) the protocol is lanes_open (idempotent), lanes_renew (never openLanes), lanes_close (owner marks closing, rejects late renewals, awaits its closeLaneRun, then cancels orphans; the CLI waits for the reply), serialized per worktree/run, registered in the GBRAIN_SERVE_SYNC_IPC block, handshake before the first admission, CLI reads lane count and timing back and never calls openLanes locally; a promoted CLI is never a second lane runner. The choice stays Garry's.
  • ENG-6 (progress and movement, supersedes count-based wording in CEO-7/DX-4): progress is a committed receipt or a head step advance for B2, B4 and I2; the watermark is the newest completed_at of committed managed receipts in the current incarnation via a partial index (worktree_id, completed_at DESC) WHERE state='committed' added in the migration; I2's default window is max(300 s, budget + 60 s); held routes by hold kind (retry-held for preparation_stalled); B4 reports movement_state: parked (not scored) when no drain or full consumer is live.
  • ENG-7 (C2): the --signal path is dropped; C2 is gate item G6 with default defer (if kept: IPC-only, no per-boundary stack capture; T5 uses a barrier inside a real preparer step).
  • ENG-8 (Phase 0): arms run on master first, then #6298's head; candidate (d) (lost pooler/driver response) added; PgBouncer is a stand-in for Supavisor and a negative result does not clear production; A1's regression test is a forced probe (fails on #6298's head, passes with the fix).
  • ENG-9 (seams and tests): WaiterOnlyConsumer implements an extracted PersistenceConsumerLike interface; the consumer mode machine (probing/full/waiter_only/promoted) is an explicit enum with a comment diagram; T1c's older-CLI case asserts consumers_without_heartbeat; T4's held case exits 0; T5 (if G6 keeps C2) parks inside import_screen; the test plan artifact at the path in the Review record is the /qa input.
  • ENG-10 (TODOS at ship time, collected from all phases): thin-client parity; DB-resident lane state unless D1 (b); fenced consumer role; pg_notify cross-process wake; external alerting on data_moving; same-host dead-owner release unless G2.

Review record

Autoplan run (GBRA-61, 2026-10-08)

Driver: Capy (claude-fable-5-1) running /autoplan from ~/.claude/skills/autoplan. Voices: native = Capy subagent on anthropic/claude-opus-5-5 (high), outside = Capy subagent on openai/gpt-6.1-sol (high); the Codex CLI is not installed and Capy's gstack adaptation substitutes a subagent for it. Phases: CEO → DX (dxRequired by terms: 20 matches, developer tool) → Eng; Design skipped (no UI scope: zero matches for component/screen/form/button/modal/layout/dashboard/sidebar/nav/dialog). Design doc check found only docs/designs/SYSTEM_ONE_JEV_V1.md, unrelated; not used. Mode: SELECTIVE EXPANSION (autoplan override; ~25 planned files would have made 0E recommend SCOPE REDUCTION, recorded here and offered at the gate as a user challenge if both voices ask to split).

CEO scope document: /home/user/.gstack/projects/garrytan-gbrain/ceo-plans/2026-10-08-managed-sync-reliability-6317.md. CEO Step 0 checkpoint: /home/user/.gstack/projects/garrytan-gbrain/autoplan-ceo-vYq31F/ceo-implementation.md (source sha f42d27d5…9d66a).

CEO Step 0 ledger

Row Owner Current Proposed Status Exact approval and scope
CEO-R1 0A/P5 B1 probes the persistence IPC socket; C2 dump_claim admin op on it Probe = B3 heartbeat row; transport = resolve IPC socket (sync_* family) or signal; D1 gains option (a′) reuse of serve-delegated sync settled (auto, mechanical: the socket does not exist on Postgres, resolve-ipc-binding.ts:103-113) baseline replacement 1; D1 (a′) added to the gate
CEO-R2 0A/P2 Phase 0 reproduces two consumers Adds single long-lived consumer control and a jobs-worker adoption-write arm settled (auto, mechanical) accepted:ceo item 2
CEO-R3 0A/P2 B1 covers drainManagedSync B1 covers every awaitWrite caller via startPersistenceConsumer (waiter-only consumer when a live same-host owner exists) settled (auto, P1/P2; blast radius service.ts/consumer.ts) accepted:ceo item 3
CEO-R4 0A/P8 Section 6 says stop serve Full one-consumer procedure, status capture, --no-lanes demoted settled (auto, mechanical) baseline replacement 4
CEO-R5 0A/P7 D2 inside gbrain upgrade Standalone writer movement check; upgrade calls it when it owns the relaunch settled (auto; refuse-vs-warn stays D2 at the gate) baseline replacement 3
CEO-R6 0B TODOS.md:135 same-host dead-pid release Add on top of B3 heartbeat TASTE → gate T3 provisional: not added
CEO-R7 0A/P6 C1 pool from pool-gauge.ts Vendored-driver accessor (recommended) vs subset-only label TASTE → gate T2 baseline replacement 2 names both; recommended option written
CEO-R8 0B B3 doctor warns on any two consumers Warn only for two resident kinds alive > one lease; transient cli consumers listed settled (auto, mechanical) accepted:ceo item 4
CEO-R9 0A/P4 B2 drops claimable_here entirely Keep one narrow wait: lapsed claim this process can reclaim waits one more window settled (auto, P5 explicit) accepted:ceo item 5
CEO-R10 0A/P9 Phase 0 names the await with the inspector enterClaimStep stamps first, inspector second settled (auto, mechanical) accepted:ceo item 6
CEO-R11 0E One PR (Garry's direction) Possible split (B+C+E now, D1/D2 later) pending voices → user challenge only if both voices recommend it not applied
CEO-R12 0G — Postgres thin-client parity; DB-resident lane state DEFERRED to TODOS.md not applied

0I. Temporal interrogation

HOUR 1 (foundations):   #6298's diff is the base: preparation-budget.ts, claim-phase.ts step/owner stamps, group-publish.ts
                        wave/cut/hold, sync-drain.ts allowance. The implementer must know the persistence IPC socket is
                        PGLite-only and the resolve IPC socket is universal (resolve-ipc-binding.ts). human ~1d / CC ~20 min.
HOUR 2-3 (core logic):  B1: where the owner-alive decision lives (startPersistenceConsumer, service.ts:80) and how a
                        waiter-only consumer still hands off settlements (settledWaiters). B3: heartbeat cadence shares the
                        claim-lease timer (claim-lease.ts). Ambiguity: a `serve` that is alive but at the zombie cap
                        (consumer.ts restartRequired) must not count as a live owner. human ~2d / CC ~1h.
HOUR 4-5 (integration): The Postgres E2E tier runs two processes rarely; T1 needs a two-process harness (spawn `gbrain serve`
                        under test env) — test/helpers has cli-spawn helpers. Flag registry regen for --own-consumer.
                        Migration number taken at the merge slot (persistence_consumers table). human ~1d / CC ~40 min.
HOUR 6+ (polish/tests): Doctor check names (`two_consumers_on_host`, `host_identity_mismatch`), error-catalogue rows for
                        `upgrade_data_not_moving`, BEHAVIOR_CHANGES rows (B1, D2), CHANGELOG voice, KEY_FILES entries,
                        gbrain-evals mirror of the Phase 0 write-up. human ~1d / CC ~30 min.
Feasibility blockers:   none hard; Phase 0's 3-hour box decides A1/A2/A3 (D4).

CEO dual voices (completed)

  • Native (anthropic/claude-opus-5-5, Capy subagent, INPUT ceo d46ca7e2…799a9, completed): 8 findings (4 High, 3 Medium, 1 Low). Recommendation: approve with changes.
  • Outside (openai/gpt-6.1-sol, Capy subagent standing in for the Codex CLI, INPUT ceo d46ca7e2…799a9, completed): 5 findings (1 Critical, 3 High, 1 Medium). Recommendation: revise before implementation.
  • Both verified independently: persistence IPC is PGLite-only (pr6298:src/mcp/resolve-ipc-binding.ts:104); awaitWrite starts a consumer in every waiting process (pr6298:service.ts:182); the drain_stalled gate at pr6298:sync-drain.ts:325; laneOf null for a foreign run; pool-gauge.ts:5-14; /health liveness-only (pr6298:serve-http-metrics.ts:216-222); holds advance the cursor (pr6298:sync-run.ts:445-449).
CEO DUAL VOICES — CONSENSUS TABLE:
  Dimension                             Claude(opus-5-5)        Outside(gpt-6.1-sol)     Consensus
  1. Premises valid?                     E3 n=1, confounded      E1/E2 do not name await  CONFIRMED concern → Phase 0 preregistration (CEO-2, §2)
  2. Right problem to solve?             yes, framed one level   yes, but health contract CONFIRMED → B4 added (CEO-12)
                                         too low (health signal) unchanged
  3. Scope calibration correct?          split by certainty      one batched release      DISAGREE → taste G3 at the gate
  4. Alternatives sufficiently explored? D1 (a′) under-costed    D1 adds 2nd protocol     CONFIRMED → (a′) costed, reviewers' preference (CEO-14)
  5. Competitive/market risks covered?   internal; GBRA-59 PR 2  n/a (internal)           CONFIRMED low; coordination note added
  6. 6-month trajectory sound?           three delegation paths  two overlapping protocols CONFIRMED concern → (a′) preferred, parity deferred
CONFIRMED = completed subagent + outside. 5 confirmed, 1 disagreement → gate.

Disposition of voice findings (0D, auto-decided unless marked): native F1 + outside #1 (health surfaces) → ACCEPTED as B4/CEO-12 (P1, blast radius: sources.ts, diagnostics.ts, one doctor check, ~40 lines). Outside #2 (movement per source, holds are not movement) → ACCEPTED into I2/CEO-7. Native F2 + outside #3 (Phase 0 cannot falsify B1; sequence B1c after evidence) → ACCEPTED: preregistered reading in §2, B1c and lane A gated on arms (i)/(ii). Native F4 + outside #4 (B1 is a preference, elect first live full consumer, wedge-aware probe) → ACCEPTED into B1a (the fenced role the outside voice asks for is deferred with thin-client parity; stated as a preference). Native F3 + outside #5 (D1 (a′)) → costed in §5; TASTE at the gate (D1 is Garry's). Native F5 (§6 as an ask today) → ACCEPTED (gate Q5). Native F6 (split by certainty) → TASTE G3 (outside voice keeps one PR; not a user challenge). Native F7 (I1 container case) → ACCEPTED CEO-13. Native F8 (citations) → ACCEPTED (restamp note). Outside #1's "persistent freshness check in monitoring" beyond doctor/status → deferred to TODOS (an alerting integration is outside this repo's surfaces).

CEO review sections

Current scope. Mode SELECTIVE EXPANSION (autoplan override). Governing rows: CEO-R1…R10 settled; CEO-R6 (G2) and CEO-R7 (G1) taste; CEO-R11 (one PR vs split, G3) taste; CEO-R12 deferred; voice dispositions above. Accepted: CEO-1…CEO-14. Deferred: thin-client parity, DB-resident lane state, fenced consumer role, external alerting. Rejected: A3 laneOf refusal. Pending for Garry: D1–D4, G1–G3, Q5 (interim relief today).

Section 1: Architecture Review. Components after the plan:

                 host (one localHostId; I1 flags a second host.json on the same fs)
  +-------------------+     resolve IPC (secret)      +----------------------------+
  | gbrain sync (CLI) | ---- lanes_open/close ------> | gbrain serve (owner)       |
  |  driver only      |     claim_dump                |  PersistenceConsumer FULL  |
  |  WaiterOnly       | <--- sync_status (a′ only) -- |  heartbeat 10 s (direct)   |
  +---------+---------+                               |  openLanes(run) / lanes    |
            | admits rows (intent.lane=run)           |  SIGUSR2 → dumps/           |
            v                                         +------+---------------------+
  +-----------------------------------------------------------v----------------------+
  | Postgres: persistence_requests (claim_phase stamp: owner, step, waiting_on, last_sql)|
  |           persistence_consumers (host_id,pid,started_at | kind,mode,renewed_at,     |
  |             restart_required, claim_past_ceiling, pool{checked_out,max,waiters})   |
  |           persistence_worktrees (owner_host_id, heartbeat_at)  op_checkpoints       |
  +---------------------------------------------------------------------^---------------+
            ^                                 ^                          |
  +---------+---------+   +-------------------+------+   +---------------+-------------+
  | jobs worker       |   | doctor / sources status  |   | writer movement --wait      |
  | WaiterOnly while  |   | two_consumers_on_host    |   | per-source moved/current/   |
  | a full owner lives|   | managed_sync_not_moving  |   | held/not_moving (I2)        |
  +-------------------+   | host_identity_mismatch   |   +-----------------------------+
                          +--------------------------+

Data flow (B1a probe), four paths: happy: row live → WaiterOnly → write settles via owner → listener fires. Nil (no table row / no owner): full consumer, today's path. Empty (table exists, zero rows): same as nil. Error (probe query fails): one log line, full consumer (fail-open; the claim lease is still the lock, so correctness holds; only the one-consumer preference is lost).

State machine, consumer mode:

  start ──probe──> FULL ──(never demoted)──> stop
    └───live full row──> WAITER_ONLY ──owner lapsed 60 s | claim_past_ceiling | skew fallback──> FULL
  Invalid: FULL → WAITER_ONLY (prevented: no demotion path); WAITER_ONLY claiming (prevented: claim methods absent on the type).

Coupling: new coupling CLI→serve over the resolve IPC (B1c) is the main cost; (a′) replaces it with the existing sync_* family (D1). B3 couples every full consumer to one small table; failure of the table is fail-open. Scaling: 10x hosts → one row per process per host, trivial; 100x writes → the heartbeat is one statement per 10 s per process on the direct lane, independent of write volume. Single points of failure: the resident serve becomes the only publisher on the host; its wedge is now visible (B4, claim_past_ceiling) instead of silent, and waiters promote at the ceiling. Security: lanes_open/claim_dump are new IPC kinds behind the existing shared secret, managed-brain and bound-worktree checks; SIGUSR2 writes only a local file under the owner's home; no new unauthenticated surface (/health unchanged). Production failure scenarios: pooler drops the direct lane → heartbeat fails → logged once, owner keeps running, others may promote after 60 s (two full consumers until it recovers; doctor names it). Rollback: config/flag level (GBRAIN_OWN_CONSUMER=1, --own-consumer) restores today's topology in seconds; the migration is additive (one table) and needs no down-migration. Findings: 2 (B1 is a preference, recorded; direct-lane heartbeat required), both applied.

Section 2: Error & Rescue Map. See the registry below (12 rows, 0 GAPs after amendments). Catch-alls: the heartbeat write and probe are the two places that swallow; both log once and degrade to a named, visible state (full consumer), which the plan now states.

Section 3: Security & Threat Model. Attack surface: two or three new resolve-IPC kinds (lanes_open, lanes_close, claim_dump); input validation: worktree_id must be a worktree this host owns, run a UUID, lanes an integer 1–8 (the same bound as --lanes), request_id a UUID; rejected loudly as invalid_params. Authorization: shared secret from the data dir (existing), plus managed-brain and bound-source checks carried over from sync_start. Likelihood/impact of a local attacker opening lanes on a brain: Low/Low (local user already has the data dir). writer dump output: step names and stack frames only, no page content or SQL parameters (stated). host.json v2 minted_under records HOME/GBRAIN_HOME/hostname: local paths in a 0600 file, same class as today's host.json; not printed to public artifacts (privacy rule noted for the eval write-up). Findings: 1 (bound lanes and validate ids), applied as text above; no High.

Section 4: Data Flow & Interaction Edge Cases. Async ordering, the one that matters: invariant "at most one full consumer per host" across the probe → write heartbeat row window. Schedule A: P1 probes (no row), P2 probes (no row), P1 writes row, P2 writes row → two full consumers. Schedule B: P1 probes, P1 writes, P2 probes (row live) → one. Nothing prevents A; the plan now states it as a one-renewal window, a preference, with T1b racing two starters (regression proof) and doctor naming the outcome. Movement check ordering: snapshot → wait → re-read; a commit that lands between snapshot and the first read counts as movement (desired). Interaction edge cases: double writer movement runs are independent reads; Ctrl-C during a delegated drain → lanes_close on every exit path (B1c) or sync_abort (a′); large list: host.consumers bounded by processes on one host. Findings: 1 (race stated), applied.

Section 5: Code Quality Review. Fits existing patterns: heartbeat on the claim-lease cadence (claim-lease.ts), kinds from claimOwner(), IPC kinds in the IpcRequest union, doctor checks as files under src/commands/doctor/checks/. Duplication risk: (a) adds a second delegation protocol beside serve-sync-runner.ts (flagged; D1). WaiterOnlyConsumer as a separate class implementing the consumer's external surface is explicit over a mode flag threaded through PersistenceConsumer (P5). Findings: 1 (the D1 duplication), carried to the gate.

Section 6: Test Review. Codepath → test map: B1a probe → T1, T1b (race), T1c (skew); B1b seam → T1b (waiter settles, promotes); B1c → T1 (hand-off, killed CLI); B2 → T2 (two cases); B3 → T1d (table, doctor thresholds, cleanup) + migration goldens; B4 → new test (parked consumer flips data_moving and the doctor check); C1 → extend persistence-writer-status-stall.test.ts with pool numbers from the accessor; C2 → T5 (IPC and SIGUSR2); C3 → log-line assertion in the budget tests; I1 → T3 (two cases); I2 → T4 (five states). 2 a.m. Friday test: T1's killed-CLI case plus T2's live-renewing owner. Hostile QA: two processes starting within one renewal (T1b race) and a serve that wedges with a live heartbeat (claim_past_ceiling). Chaos: kill the owner mid-group with waiters pending (promotion + #6298 recovery). Pyramid: unit (budget, stamp, movement classification) > integration (two-process Postgres) > E2E (full gate). Flakiness: every two-process test depends on time; use the fixtures' testWaitMs scaling and fault points, never sleeps. Findings: 2 (B4 test, race test), applied.

Section 7: Performance Review. New queries: heartbeat upsert every 10 s per full consumer (primary key hit), probe once per consumer start, doctor read of one small table, movement snapshot = one op_checkpoints read plus one count of committed receipts per source (index on (source_id, state, completed_at) exists for receipts? verify at implementation; add if not). Pool pressure: the heartbeat uses the direct lane, not the ordinary pool; lanes_open renewals are IPC, not SQL. Slow paths: writer movement waits by design (300 s). Findings: 1 (receipt count index to verify), carried to Eng.

Section 8: Observability & Debuggability Review. Entry/exit logs: promotion, heartbeat failure, probe failure, lane-run close by lapse, claim_past_ceiling each have one named [persistence] line (C3 lists the triple-bearing ones). Metrics: data_moving/not_moving_since (B4) is the one that says it works; two_consumers_on_host the one that says the topology drifted. Three-weeks-later reconstruction: claim_phase stamps plus persistence_consumers rows (kept 60 s) are not enough for history; the doctor finding and the [gbrain notice] lines are the record, which is acceptable for this PR. Runbooks: troubleshooting rows for the four new codes (Lane E). Findings: 1 (history is log-only), accepted as is.

Section 9: Deployment & Rollout Review. Migration: one additive table, no lock on existing tables, zero-downtime; number taken at the merge slot (RELEASING rule). Mixed versions: a new CLI against an old serve → unsupported_kind fallback (B1d); an old CLI against a new serve → the old CLI starts its own consumer (two full, listed by doctor); both bounded. Feature flags: GBRAIN_OWN_CONSUMER/--own-consumer as the kill switch; GBRAIN_SERVE_SYNC_IPC=0 already disables the IPC family. Rollout order: migration with the release; nothing to toggle. Post-deploy checklist (first 5 minutes): gbrain sources writer movement --wait 300, gbrain doctor --json shows no two_consumers_on_host, writer status --json shows host.consumers with one full. Full Ubicloud gate on the integrated head with UBI_OWNER=gbra61. Findings: 0 beyond what the plan states; examined migration, flags, skew and the checklist.

Section 10: Long-Term Trajectory Review. Debt: (a) would leave three delegation mechanisms (flagged, D1); B3 adds a table other features can use (dead-owner release G2, TODOS.md:135). Reversibility: 4/5 (flags restore today's topology; the table is additive). Knowledge: KEY_FILES entries and the eval write-up carry it. One-year question: "why does the CLI not consume on Postgres" is answered by one function (startPersistenceConsumer) and one doctor check, which is obvious enough. Retrospective on cherry-picks: B4 was the load-bearing addition both voices found missing; nothing rejected turned out load-bearing. Findings: 1 (D1 debt), at the gate.

Section 11: Design & UX Review. SKIPPED (no UI scope).

Required outputs

NOT in scope. Deferred (TODOS.md at ship time): Postgres thin-client parity (every write delegates); DB-resident lane state unless D1 (b); a fenced exclusive consumer role; external alerting integration for data_moving; same-host dead-owner release unless G2 is accepted; machine-stable host identity unless D3 picks it. Rejected: A3's laneOf refusal (redundant, sync-lanes.ts:75-79); --no-lanes as relief (keeps two consumers).

What already exists. See the CEO scope document 0B: serve-delegated sync family (sync-delegate.ts, serve-sync-runner.ts, sync-ipc.ts; reused under D1 (a′), or its socket reused under (a)); persistence_worktrees.heartbeat_at; claim_phase owner/step stamps (#6298); local_process_ingress; pool-gauge.ts subset and pool-budget.ts; runDrain fingerprint without lease columns (#6298); the flag registry generator.

Dream state delta. The plan now moves every axis of the 12-month ideal except the fenced role and machine-stable identity: one full consumer per host (preference, visible when violated), liveness = data moved on status, doctor and a deploy gate, the stuck step and owner named, identity drift named with both files and the env.

Error & Rescue Registry.

  METHOD/CODEPATH                 | WHAT CAN GO WRONG                      | CLASS / CODE              | RESCUED? | ACTION                                   | USER SEES
  --------------------------------|----------------------------------------|---------------------------|----------|------------------------------------------|---------------------------
  startPersistenceConsumer probe  | table read fails (DB down, pooler)     | PgAccess / storage_error  | Y        | log once, full consumer (fail-open)      | [persistence] line; doctor may list 2
  heartbeat upsert (direct lane)  | write fails                            | storage_error             | Y        | log once, keep running                   | row lapses; doctor lists; others may promote
  WaiterOnly await                | owner lapses with waiter pending       | owner_lapsed              | Y        | promote() after 60 s                     | one log line; write settles
  WaiterOnly await                | owner alive but wedged                 | claim_past_ceiling        | Y        | stop suppressing at ceiling; B2/B4 name  | drain_stalled / data_moving=false
  lanes_open over resolve IPC     | unsupported_kind / IPC_UNAVAILABLE     | unsupported_kind          | Y        | warn once, own consumer for the run      | start line says own consumer
  lanes_open renewals stop        | CLI died                               | lane run lapsed           | Y        | owner closes run, cancels orphan rows    | next drain re-admits
  runDrain stall                  | same claim/phase past allowance        | drain_stalled             | Y        | exit naming request/step/owner pid       | Next: writer status …
  writer movement                 | no source moved in window              | upgrade_data_not_moving   | Y        | non-zero (or --warn-only), C1 summary    | per-source verdicts
  writer movement                 | snapshot read fails                    | unknown                   | Y        | exit non-zero, says unknown              | named read failure
  writer dump                     | owner on another host / no handler     | owner_unavailable         | Y        | prints host id + pid, no signal sent     | instruction, not a hang
  doctor host_identity_mismatch   | machine-id missing (container)         | n/a                       | Y        | second predicate (binding path + mint)   | finding with both paths
  managed_sync_not_moving check   | cursor read fails                      | storage_error             | Y        | finding `unknown`, never `ok`            | doctor shows unknown

Failure Modes Registry.

  CODEPATH                 | FAILURE MODE                         | RESCUED? | TEST?        | USER SEES?            | LOGGED?
  -------------------------|--------------------------------------|----------|--------------|-----------------------|--------
  B1a probe                | two starters in one renewal          | Y (doc.) | T1b race     | doctor warning        | Y
  B1b waiter               | owner lapses                         | Y        | T1b          | promotion line        | Y
  B1b waiter               | owner wedged, heartbeat live         | Y        | T2 + B4 test | drain_stalled, B4     | Y
  B1c lanes_open           | old serve                            | Y        | T1c          | warning               | Y
  B1c lanes_open           | CLI dies                             | Y        | T1 case 2    | owner log, re-admit   | Y
  B2 drain_stalled         | lapsed+claimable (one extra window)  | Y        | T2 case 2    | stall line            | Y
  B3 heartbeat             | direct lane down                     | Y        | T1d          | doctor lists          | Y
  B4 data_moving           | cursor read fails                    | Y        | B4 test      | unknown               | Y
  C2 dump                  | remote owner                         | Y        | T5           | instruction           | Y
  I1 identity              | no machine-id                        | Y        | T3 case 2    | finding               | Y
  I2 movement              | holds-only advance                   | Y        | T4           | held, non-zero        | Y
  migration                | applied on PGLite                    | Y        | goldens      | n/a                   | n/a
  CRITICAL GAPS: 0

Completion Summary (CEO).

  +====================================================================+
  |            MEGA PLAN REVIEW — COMPLETION SUMMARY                   |
  +====================================================================+
  | Mode selected        | SELECTIVE EXPANSION (autoplan override)     |
  | System Audit         | persistence IPC PGLite-only; awaitWrite     |
  |                      | starts consumers; pool-gauge subset; health |
  |                      | liveness-only; holds advance cursor         |
  | Step 0               | 9 premises challenged (3 invalid as written)|
  |                      | 19 scope decisions, 14 accepted, 3 taste    |
  | Section 1  (Arch)    | 2 issues found (applied)                    |
  | Section 2  (Errors)  | 12 error paths mapped, 0 GAPS               |
  | Section 3  (Security)| 1 issue found, 0 High severity              |
  | Section 4  (Data/UX) | 3 edge cases mapped, 0 unhandled (1 stated) |
  | Section 5  (Quality) | 1 issue found (D1 duplication → gate)       |
  | Section 6  (Tests)   | Diagram produced, 2 gaps (applied)          |
  | Section 7  (Perf)    | 1 issue found (index, to Eng)               |
  | Section 8  (Observ)  | 1 gap found (history log-only, accepted)    |
  | Section 9  (Deploy)  | 0 risks flagged beyond plan                 |
  | Section 10 (Future)  | Reversibility: 4/5, debt items: 1           |
  | Section 11 (Design)  | SKIPPED (no UI scope)                       |
  +--------------------------------------------------------------------+
  | NOT in scope         | written (8 items)                           |
  | What already exists  | written                                     |
  | Dream state delta    | written                                     |
  | Error/rescue registry| 12 rows, 0 CRITICAL GAPS                    |
  | Failure modes        | 12 total, 0 CRITICAL GAPS                   |
  | TODOS.md updates     | 6 items proposed (at ship time)             |
  | Scope proposals      | 19 proposed, 14 accepted (SEL)              |
  | CEO plan             | written (~/.gstack/projects/garrytan-gbrain/ceo-plans/2026-10-08-managed-sync-reliability-6317.md) |
  | Outside voice        | openai/gpt-6.1-sol via Capy subagent, completed (Codex CLI absent) |
  | Lake Score           | N/A (no coverage-scored question offered a 10/10 option; choices differed in kind) |
  | Diagrams produced    | 3 (architecture, data-flow paths, state machine) |
  | Stale diagrams found | 0                                           |
  | Unresolved decisions | 8 (D1–D4, G1–G3, Q5), all for Garry at the gate |
  +====================================================================+

Decision Audit Trail (CEO rows)

# Phase Decision Classification Principle Rationale Rejected
1 CEO B1 probe = heartbeat table, not persistence IPC Mechanical P5 socket PGLite-only (resolve-ipc-binding.ts:103-113) socket probe
2 CEO B1 enforced in startPersistenceConsumer for every waiter Mechanical P1/P2 service.ts:160-163 drain-only
3 CEO Phase 0 arms (ii)/(iii) + preregistered reading Mechanical P1 E3 n=1, confounded single repro
4 CEO I2 standalone command; upgrade prints the step Mechanical P5 upgrade never owns relaunch in-upgrade window
5 CEO I2 movement per source, holds not movement Mechanical P1 advanceHeld any-source advance
6 CEO B4 data_moving on status/doctor/notice Taste (accepted expansion, both voices) P1/P2 health signal unchanged otherwise command-only
7 CEO B1a elects first live full resident consumer, wedge-aware Mechanical P1 both voices; claim_past_ceiling serve-only
8 CEO B2 keeps one narrow lapsed+claimable wait Mechanical P5 dead-owner reclaim unconditional
9 CEO B3 doctor warns only for resident kinds > 30 s Mechanical P3 noise on every gbrain put any two
10 CEO heartbeat own 10 s timer on direct lane Mechanical P1 idle serve, starved pool claim-renewal piggyback
11 CEO A3 laneOf refusal dropped Mechanical P4 redundant keep
12 CEO G1 pool numbers from vendored driver (default) Taste P1 gauge contract subset label
13 CEO G2 dead-owner release not in PR (default) Taste P3 not required by #6317 add
14 CEO G3 one PR, B1c/lane A gated inside Taste P6 voices disagree on split split now
15 CEO D1 (a′) costed, reviewers' preference, choice stays Garry's Taste → gate P4 second protocol (a) as recommended
16 CEO §6 put to Garry today Mechanical P6 days to land reference only
17 CEO I1 container predicate Mechanical P1 E4 shape machine-id only
18 CEO B1c sequenced after Phase 0 arms (i)/(ii) Mechanical P6/P1 costliest piece on n=1 build at once
  • CEO-1 (B1 transport): the probe is the B3 persistence_consumers heartbeat row (host localHostId(), any resident kind serve|sync|jobs|autopilot|mcp, mode full, renewed within 30 s, binding state='active', no restart_required, no claim_past_ceiling), never a persistence IPC socket (src/mcp/resolve-ipc-binding.ts:103-113 opens that socket only on PGLite); a probe the database cannot answer falls back to today's behaviour with one log line. With D1 (a), the lane policy crosses the resolve IPC socket every serve opens as lanes_open {worktree_id, run, lanes} / lanes_close {run} (new IpcRequest members in resolve-ipc.ts, verified secret, managed brain, worktree owned by this host); the owner calls openLanes in its own process and its consumer claims the CLI-admitted lane rows through claimNextLaneHead; lanes_open is re-sent every 10 s (the renewal cadence) and is the CLI heartbeat; the owner closes a lane run whose lanes_open stops for 60 s and owns closeLaneRun and cancelOrphanedLaneRows for it; lanes_close is sent on every CLI exit path; unsupported_kind (the handshake precedes the first awaitWrite) makes the CLI warn once, set the process-level own-consumer flag and promote() any waiter-only consumer already made. The first live full resident consumer wins; a serve always starts full; two starters within one renewal can both start full (stated as a preference, not a fenced invariant; T1b races them). B1c and lane A's final choice merge only after Phase 0 arms (i) and (ii) report, under the preregistered reading in §2. Tests T1, T1c.
  • CEO-2 (Phase 0 controls): arms (i) serve + sync CLI, (ii) one long-lived consumer only (30+ minutes, no CLI), (iii) arm (i) plus a jobs-kind process submitting adoption writes every 20 s; the write-up names which arms wedged with the head's claim_phase.step and waiting_on. Lanes B–E do not wait for Phase 0; B1 ships whatever arm (ii) shows.
  • CEO-3 (B1 scope and seam): enforced in startPersistenceConsumer (service.ts:80): with a live same-host owner that is not this process it returns a WaiterOnlyConsumer carrying the consumer's whole external surface (wake() no-op, settledWaiters listeners, holds() false, foregroundCompletions() 0, status() waiter_only + owner pid, stop() no-op) that claims nothing and writes no heartbeat row; awaitWrite's timeout is unchanged (writer_pending as today); promote() converts it in place when the owner's heartbeat lapses 60 s while a waiter is pending (one log line) or on the B1d skew fallback; a live-but-wedged owner stops suppressing once its row shows a claim past the 600 s ceiling (claim_past_ceiling), and before that B2, B4 and I2 are the exits; a serve is always a full consumer; no demotion of an earlier full consumer; PGLite unchanged; another host's owner never suppresses. --own-consumer and GBRAIN_OWN_CONSUMER=1 force the old path. Test T1b.
  • CEO-4 (B3 table and doctor rule): persistence_consumers is one new schema migration (number at the merge slot, PGLite and Postgres parity, schema.sql, golden tests), primary key (host_id, pid, started_at), columns kind (claimOwner().kind), build, started_at, renewed_at, mode, restart_required and the C1 pool numbers; renewed by its own 10 s timer in every full consumer through the direct lane (executeRawDirect), independent of claim renewal, live within 30 s, lapsed at 60 s, each renewal deleting rows lapsed over 60 s in the same CTE; a failed heartbeat write is logged once and never stops the consumer. two_consumers_on_host warns only for two live resident-kind rows (serve, sync, jobs, autopilot, mcp) both older than 30 s. Test T1d.
  • CEO-5 (B2 condition): drain_stalled fires after the #6298 allowance (max(30 s, budget 120 s + 30 s grace), three passes, from step_since) regardless of claimable_here, naming request, phase, step, owner host and pid, except that a lapsed claim a consumer on this host can reclaim gets exactly one more window; preparation_abandoned for this process's own pid unchanged; the 600 s ceiling untouched. Test T2 both cases.
  • CEO-6 (Phase 0 instrument): claim_phase.step/waiting_on from #6298's enterClaimStep, read every 10 s with gbrain sources writer status --json, first; bun --inspect second and optional.
  • CEO-7 (I2 shape): standalone gbrain sources writer movement --wait <seconds> [--json], judged per source from committed managed_sync_* receipts (holds via advanceHeld and up-to-date last_sync_at touches are not movement): moved, current, held, not_moving, unknown; exit 0 only when every source is moved or current, else non-zero upgrade_data_not_moving with the C1 summary (default window 300 s; D2 at the gate sets refuse vs warn as the default, --warn-only prints the summary and exits 0; registry regenerated for --wait/--warn-only); gbrain upgrade and post-upgrade never run it (neither owns the relaunch, upgrade.ts:231-285) and print the supervisor's step; docs/guides/upgrades-auto-update.md and the error catalogue carry it. Test T4: the states plus healthy-beside-stalled and holds-only.
  • CEO-8 (interim relief, section 6): stop serve, pause maintenance submitters, keep the restart loop, capture writer status --json every 60 s, restart; --no-lanes is a sub-hypothesis test, not relief.
  • CEO-9 (scope): A3's laneOf refusal dropped as redundant (sync-lanes.ts:75-79); C2 (step-entry stack over the resolve IPC kind claim_dump or SIGUSR2, handler installed by full consumers), C3 (the triple on the preparation deadline/ceiling/hold lines, the promotion line and the drain_stalled summary) and host.json v2 minted_under are accepted as #6317 items 4 and 5 ask for them; last_sql is recorded by #6298's boundedReads wrapper; Postgres thin-client parity and DB-resident lane state (unless D1 picks (b)) deferred to TODOS.md at ship time and listed in ## 7; flag registry regenerated for --own-consumer, writer movement, writer dump; src/core/behavior-change-notice.ts rows for B1 and I2.
  • CEO-12 (B4, from both voices' top finding): per-source data_moving/not_moving_since on sources status and writer status --json (false after the 600 s ceiling with no committed receipt on an unfinished cursor), doctor managed_sync_not_moving counted in the score, one [gbrain notice] from serve on the flip, /health unchanged; shares I2's reader. Test: a parked consumer flips the field and the doctor check within the ceiling; a moving one never does.
  • CEO-13 (I1 container case): doctor also flags a re-minted host.json (newer than the binding, different HOME/GBRAIN_HOME) when the binding's local_path holds the worktree on this filesystem, so E4's container shape is caught without a machine-id; T3 second case.
  • CEO-14 (D1 at the gate): option (a′) is costed in the plan and marked the reviewers' preference; the choice stays Garry's. Citations are restamped against pr6298 by the lane subagents; GBRA-59 PR 2 file ownership agreed before the lanes start; §6 is put to Garry today as an ask.
  • CEO-11 (Phase 0 box and privacy): 3 hours for arms (i) and (ii); arm (iii) dropped first, arm (ii) warm-up shortened to 15 minutes if tight; the Phase 0 build carries the C1 driver accessor; the committed write-up uses placeholders (AGENTS.md privacy rule). The one-PR-or-split question is open at the gate, not auto-decided.
  • CEO-10 (G1 default): C1 reads checked_out/max/waiters from a small accessor on the vendored driver (vendor/postgres/src/index.js open/idle/queued arrays) and reports pool-gauge.ts beside it as tracked_subset; the gate's alternative is the subset-only label with no waiters. G2 (dead-owner release) default: not in this PR.

Phase 2 (Design): skipped, no UI scope (zero matches for view/rendering terms).

Phase 2.5 DX review (DX POLISH; product type CLI Tool, AI agent primary)

DX snapshot: /home/user/.gstack/projects/garrytan-gbrain/autoplan-dx-X7k9SA/dx-implementation.md (sha 7cc1305a…e14c, source 7229d2ef…80f3). Methodology read: autoplan-dx-methodology-OCFWBc/methodology.md lines 1–2124 (principles, rubric, Step 0A–0G, passes 1–8, required outputs; skip-listed sections loaded only).

Product type. CLI Tool (gbrain sync, gbrain sources writer …, gbrain doctor), with the AI agent as primary user (AGENTS.md: the agent operator contract) and a human operator reading logs second. Auto-confirmed (autoplan).

0A Persona card. The operator agent: Claude Code or Capy running gbrain on a managed Postgres brain for one human. It reads JSON envelopes, branches on code and fix.next, never on prose; it has no SQL access, no inspector, no pg_stat_activity. Behind it, a human operator (the #6278 reporter's shape) who reads logs and runs a supervisor. Tolerance: an agent abandons after one envelope without a fix.next; a human abandons after one day of diagnosis (which is what #6278 cost).

0B Empathy narrative (first person, the agent). 09:00. The sync I started last night printed an ETA of 20 hours and then nothing for twelve. /health is ok. sync_running is true. writer status --json says assessment: stalled, reason: cause_unknown, resumes_on_its_own: false, and the only other field is a claim age in the hundreds of thousands of milliseconds. I don't know who holds it (a pid is not in the JSON), what it is doing, or whether waiting helps. The runbook says "inspect the writer" and I just did. I escalate to the human with "the sync is stuck", which is what they already know. (Observed: everything above is the reporter's own 2026-10-08 capture; predicted: with this plan, the same morning goes gbrain doctor --json → managed_sync_not_moving with a fix command → writer status --json → next_action: wait 240 s or tell_user_to_run: restart pid 4121 (serve, 0.60.110.0), stuck 11 min at import_screen waiting on pool → done in two calls.)

0C Competitive benchmark. Clock: from "something looks stuck" to "I know the one next command", persona above, documented start = the symptom table in docs/guides/troubleshooting.md:28. Reference tier (no web research run; Aside unavailable, WebSearch not used): Postgres itself (pg_stat_activity + pg_blocking_pids: 2 queries, under 2 minutes, Champion); Temporal/Sidekiq-class queues (a web UI naming the stuck job and worker: Competitive); plain cron+log tails (Red Flag). gbrain today: Red Flag (the reporter needed a day and raw SQL). Target tier: Competitive (2–5 min) by CLI alone; Champion is out of reach while the dump needs a second process.

0D Magical moment. The agent runs one command and is told which process is wedged, on which step, and what to do, with no SQL. Delivery vehicle (lowest effort within existing capabilities): writer status --json's next_action envelope (C1, as amended) fed by the #6298 stamp; the "wow" is step: import_screen, waiting_on: pool, owner: serve pid 4121, next: wait 240 s. Both voices named the same vehicle.

0E Mode. DX POLISH (autoplan override; enhancement to an existing product).

0F Developer journey trace.

STAGE           | DEVELOPER DOES                                      | FRICTION POINTS                                         | STATUS
----------------|-----------------------------------------------------|---------------------------------------------------------|--------
1. Discover     | sees ETA stop; doctor / sources status              | nothing said "not moving" (B4 missing before CEO)       | fixed (B4; sources status prints the writer-status cmd)
2. Install      | n/a (upgrade of an installed brain)                 | one additive migration; version skew CLI↔serve          | fixed (B1d real skew signals, start-line notice)
3. Hello World  | writer status --json                                | fields without an action; "fix what it names"           | fixed (C1 next_action envelope)
4. Real Usage   | gbrain sync … on Postgres beside serve              | --own-consumer was new vocabulary; per-process override | fixed (--no-delegate extended; persistence.single_consumer)
5. Debug        | writer dump; drain_stalled                          | kill -USR2 not a valid fix; stale "nothing can claim it" | fixed (--signal with capability check; cause owner_wedged_here)
6. Upgrade      | supervisor runs writer movement                     | printed --wait 120 < budget; three names for one code   | fixed (bare command, budget-aware window, one code)

0G First-time developer confusion report (agent). T+0:00 gbrain sync exits drain_stalled, safe_to_loop: false, "nothing here can claim it", yet writer status shows a live owner on this host → confused (addressed: owner_wedged_here, safe_to_loop: true, retry_after_ms). T+0:02 upgrade prints --wait 120; the plan's own default is 300 s → the check fails a healthy deploy (addressed: bare command). T+0:05 two_consumers_on_host has no fix.next → relay to human with nothing to run (addressed: envelope + registry). T+0:08 kill -USR2 is not gbrain … so I cannot run it as fix.argv, and I do not know whether the target has a handler (addressed: --signal with capability check). T+0:10 host.json v2 refused by the older CLI in the other container (addressed: version stays 1, optional metadata). T+0:12 --own-consumer vs --no-delegate: which one? (addressed: one flag).

Dual voices (completed).

  • Native (anthropic/claude-opus-5-5, Capy subagent, INPUT dx 7cc1305a…e14c): 12 findings (3 High, 7 Medium, 2 Low); recommendation approve with F1–F3 fixed first.
  • Outside (openai/gpt-6.1-sol, Capy subagent standing in for Codex, INPUT dx 7cc1305a…e14c): 8 findings (5 High, 3 Medium); recommendation revise before implementation.
DX DUAL VOICES — CONSENSUS TABLE:
  Dimension                           Claude(opus-5-5)                 Outside(gpt-6.1-sol)              Consensus
  1. Getting started < 5 min?          3 cmds, --wait 120 contradiction  journey ends at "fix what it names" CONFIRMED gap → C1 next_action, bare command
  2. API/CLI naming guessable?         3 names for 1 code; --own-consumer movement lacks [<source>], flags    CONFIRMED gap → one code, --no-delegate, [<source>]
  3. Error messages actionable?        no envelopes; registry not catalogue no contract matrix; drain why stale CONFIRMED gap → registry + envelopes + contract tests
  4. Docs findable & complete?         write-refusals row stale           troubleshooting prose promises wrong CONFIRMED gap → rows rewritten, transcript added
  5. Upgrade path safe?                skew via unsupported_kind only     real old serve says unknown_kind; v2 host.json breaks readers CONFIRMED gap → real skew signals, version stays 1
  6. Dev environment friction-free?    per-process override only          --no-delegate vs classifier under (a′) CONFIRMED gap → brain-wide switch, classifier admits flags
CONFIRMED = native + outside agree. 6/6 confirmed, 0 disagreements. No single-voice critical.

Disposition (0D, auto-decided; all mechanical under P1/P5 except where marked): native F1 + outside #6 → bare command, budget-aware default, within_allowance state (accepted). Native F2 + outside #2 → error-registry entries, envelopes with fix.next/actor/verify, contract test per code, managed_sync_not_moving structured doctor fix (accepted). Native F3 + outside #2 → cause: owner_wedged_here, loop-safe wait until the ceiling, docs rows rewritten (accepted). Native F4 → waiter-only writer_pending names the owner (accepted). Native F5 + outside #5 → dump --signal with capability check, dump under persistenceHome(), dump_unsupported (accepted). Native F6 → one code managed_sync_not_moving; upgrade_data_not_moving dropped (accepted; mechanical consistency). Native F7 + outside #7 → extend --no-delegate, no --own-consumer; classifier admits managed flags under (a′) (accepted; both voices). Native F8 → movement [<source>], <dur>, per-state fix, held exits 0 with warning (accepted; held semantics is a small taste call, recorded as DX-T1 with the default "exit 0 + warning", because the hold is the containment working). Native F9 → one check name (accepted). Native F10 → persistence.single_consumer brain-wide switch (accepted). Native F11 → probing start mode, synchronous seam kept (accepted). Native F12 + outside #8 → §6 success signal, troubleshooting prose, transcript (accepted). Outside #1 → two-call journey (sources status --json → writer-status command → next_action) (accepted). Outside #3 → real skew signals, older serve writes no row (accepted). Outside #4 → host.json stays version 1 with optional metadata; GBRAIN_HOME parent value (accepted).

Pass 1 Getting Started: 4/10 → 8/10. Before: three commands and a dead end at cause_unknown. After: doctor or sources status names the source and the command; writer status ends in an action. FIX TO 10: gbrain doctor prints the next_action itself for a single stuck source (deferred: doctor fixes are one level, DX-TODO-1). Stripe test: passes in one terminal. Pass 2 API/CLI: 5/10 → 8/10. One flag (--no-delegate) instead of a new one; movement [<source>] [--wait <dur>] matches writer status; one code for one concept; host.consumers, data_moving, claim.last_dump are nouns an agent can guess. Remaining gap: movement lives under sources writer while data_moving lives on sources status; acceptable (status reads, writer acts). Pass 3 Error messages: 3/10 → 8/10. Three traced paths: (1) drain_stalled today: "nothing here can claim it … inspect the writer" (pr6298:sync-drain.ts:536-541) → after: cause: owner_wedged_here, owner serve pid N, retry_after_ms 240000, fix.next: wait (Tier 3 shape with fix.verify). (2) two_consumers_on_host today: n/a → after: fix.next: tell_user_to_run naming the pid to stop or the run to let finish. (3) managed_sync_not_moving → fix.argv writer status. Remaining gap: the [persistence] log lines are prose; acceptable (C3 gives them the triple). Pass 4 Documentation: 5/10 → 8/10. Symptom table route exists (troubleshooting.md:28); the stale promises at :52-54 and write-refusals.md:416 are rewritten; one real transcript added. Remaining gap: no "upgrade checklist" page for supervisors beyond the auto-update guide (DX-TODO-2). Pass 5 Upgrade path: 4/10 → 8/10. Additive migration; host.json stays version 1; real skew signals tested both ways; behaviour notices for B1 and I2. Remaining gap: no codemod needed; an older CLI beside a new serve runs two full consumers until upgraded (stated). Pass 6 Dev environment: 6/10 → 8/10. Brain-wide switch plus per-run flag; --json everywhere; non-interactive; two-process test harness is the new cost for contributors (Eng phase). Pass 7 Community: 7/10 → 7/10. Open source, CONTRIBUTING names where a doctor check and a migration go; no change needed by this plan. Pass 8 DX measurement: 3/10 → 6/10. The clock (symptom → next command) is measurable from the transcript test; writer movement is the deploy gate. Gap: no telemetry on how often managed_sync_not_moving fires (not proposed; it would need consent, DX-TODO-3).

+====================================================================+
|              DX PLAN REVIEW — SCORECARD                             |
+====================================================================+
| Dimension            | Score  | Prior  | Trend  |
|----------------------|--------|--------|--------|
| Getting Started      |  8/10  |  4/10  | +4 ↑   |
| API/CLI/SDK          |  8/10  |  5/10  | +3 ↑   |
| Error Messages       |  8/10  |  3/10  | +5 ↑   |
| Documentation        |  8/10  |  5/10  | +3 ↑   |
| Upgrade Path         |  8/10  |  4/10  | +4 ↑   |
| Dev Environment      |  8/10  |  6/10  | +2 ↑   |
| Community            |  7/10  |  7/10  |  0 →   |
| DX Measurement       |  6/10  |  3/10  | +3 ↑   |
+--------------------------------------------------------------------+
| TTHW                 | ~3 min | ~1 day | ↑ (symptom → next command; estimate, not measured) |
| Competitive Rank     | Competitive (target met on paper)             |
| Magical Moment       | designed via writer status next_action        |
| Product Type         | CLI Tool (agent primary)                      |
| Mode                 | POLISH                                        |
| Overall DX           |  7.6/10 | 4.6/10 | +3 ↑  |
+====================================================================+
| DX PRINCIPLE COVERAGE                                               |
| Zero Friction      | covered (two calls)                            |
| Learn by Doing     | covered (transcript)                           |
| Fight Uncertainty  | covered (envelopes on every code)              |
| Opinionated + Escape Hatches | covered (single_consumer, --no-delegate) |
| Code in Context    | covered (real transcript, supervisor sequence) |
| Magical Moments    | covered (next_action)                          |
+====================================================================+
DX IMPLEMENTATION CHECKLIST
============================
[ ] Symptom → next command in two CLI calls, under 5 minutes, no SQL (transcript test)
[ ] Every new code in src/core/error-registry.ts with class, exit code, retryable; catalogue anchor; contract test (code, why, fix.next+actor, fix.verify)
[ ] drain_stalled: cause owner_wedged_here, retry_after_ms to the ceiling, safe_to_loop true; why text, write-refusals.md:416 and live-sync table rewritten
[ ] writer status --json: next_action envelope per running claim; sources status --json prints the writer-status command beside data_moving:false
[ ] One code managed_sync_not_moving across B4, doctor, movement; no upgrade_data_not_moving
[ ] writer movement [<source>] [--wait <dur>] [--warn-only]; states moved/current/held/within_allowance/not_moving/unknown with per-state exit and fix; bare command printed by upgrade/post-upgrade
[ ] --no-delegate / GBRAIN_SYNC_NO_DELEGATE extended to Postgres (help text in user terms); persistence.single_consumer + GBRAIN_SINGLE_CONSUMER brain-wide switch; no --own-consumer
[ ] writer dump --signal with dump:true capability check; dump_unsupported; dump under persistenceHome()
[ ] host.json stays version 1; optional minted_under; GBRAIN_HOME parent value in the fix
[ ] Real skew tests: older serve (unknown_kind/stale_serve/no socket/IPC off) and older CLI beside new serve
[ ] Consumer starts in probing mode; waiter_only writer_pending names the owner
[ ] troubleshooting.md:52-54 prose corrected; one placeholder-free diagnostic transcript; supervisor restart-and-verify sequence in upgrades-auto-update.md
[ ] Behaviour notices for B1 (preference, fallback appearance) and I2; CHANGELOG; KEY_FILES; flag registry regenerated
[ ] §6 success signal line

NOT in scope (DX). Doctor printing the next_action itself (DX-TODO-1); a supervisor-facing upgrade checklist page (DX-TODO-2); telemetry on managed_sync_not_moving frequency, consent-gated (DX-TODO-3); a --follow mode for writer status (not requested). What already exists (DX). Agent operator contract (docs/protocol/AGENT_OPERATOR_v1.md), error registry + catalogue + build:error-codes, doctor structured fixes (check-fix.ts), sync-delegate.ts ladder and --no-delegate, troubleshooting symptom table, persistence.preparation_deadlines switch pattern, writer status [<source>] selection. TTHW. Observed today: about one day (reporter). Target: under 5 minutes, two calls. Predicted after the plan: about 3 minutes (doctor 20 s, writer status 10 s, reading; writer movement is a deploy gate and is not on this clock). Taste (DX-T1). held exits 0 with a warning (default) vs non-zero: both voices wanted a per-state fix; exit code is the open taste; surfaced at the gate as G4.

Decision Audit Trail (DX rows)

# Phase Decision Classification Principle Rationale Rejected
19 DX Every new code gets a registry entry + full envelope + contract test Mechanical P1 contract is the agent's only interface catalogue rows only
20 DX drain_stalled gains owner_wedged_here, loop-safe wait to the ceiling Mechanical P1/P5 B2 changed its meaning keep "nothing can claim it"
21 DX one code managed_sync_not_moving Mechanical P5 agents branch on codes three names
22 DX extend --no-delegate; brain-wide single_consumer switch Mechanical P4/P5 existing switch patterns new --own-consumer
23 DX movement [] [--wait ], per-state exits, bare printed command, budget-aware default Mechanical P5 120 < budget; consistency --wait 120
24 DX dump --signal with capability check; dump under persistenceHome Mechanical P1 signalling an unknown pid is unsafe print kill
25 DX host.json stays version 1 + optional metadata Mechanical P1 readers reject other versions v2
26 DX probing start mode; waiter envelope names owner Mechanical P5 synchronous seam async call sites
27 DX real skew signals, both directions tested Mechanical P1 unsupported_kind is not what old serve says stub
28 DX held exits 0 with warning (default) Taste → G4 P3 hold is containment working non-zero
  • DX-1 (agent operator contract, replaces the CEO block's "error-catalogue rows"): every code this plan adds or changes (drain_stalled with the new cause: owner_wedged_here, two_consumers_on_host, host_identity_mismatch, managed_sync_not_moving, dump_unsupported) is registered in src/core/error-registry.ts (class → exit code, retryable; bun run build:error-codes) with a catalogue anchor and a full envelope (code, why, fix.next with actor, fix.verify), proven by one contract test per code; doctor fixes are structured, never unstructured. There is no separate upgrade_data_not_moving: B4, doctor and writer movement share managed_sync_not_moving (reason: movement_check on the command).
  • DX-2 (drain_stalled meaning): the same-host live-owner stop carries cause: owner_wedged_here, the owner pid and kind, retry_after_ms to the 600 s ceiling, next.safe_to_loop: true and fix.next: wait before the ceiling, fix.next: tell_user_to_run (restart the named pid) after it; the why string (pr6298:sync-drain.ts:536-541), docs/guides/write-refusals.md:416 and the live-sync outcome table are rewritten. Test T2 asserts the envelope.
  • DX-3 (two-call journey): gbrain sources status --json prints the exact writer status --source <id> --json command beside data_moving: false; writer status --json ends each running claim with one next_action envelope (wait with retry_after_ms inside the allowance; tell_user_to_run naming pid and kind past the ceiling or on restart_required; run the resume command for a lapsed claim). A transcript test proves symptom → next command in two calls without SQL.
  • DX-4 (writer movement surface, supersedes CEO-7's --wait <seconds> and exit wording): gbrain sources writer movement [<source>] [--wait <dur>] [--warn-only] [--json]; default window max(300 s, budget × max attempts + 60 s), printed as the effective budget; states moved/current exit 0, held exit 0 with a warning and fix.argv gbrain repair fences --source <id> (gate G4 may flip to non-zero), within_allowance exit 0 with fix.next: wait, not_moving exit 1 with managed_sync_not_moving, unknown the read failure's own code with fix.next: report; upgrade/post-upgrade print the bare command; the upgrade guide carries the supervisor restart-and-verify sequence. Test T4 covers every state and the slow-but-healthy group.
  • DX-5 (flags, supersedes CEO-3's --own-consumer/GBRAIN_OWN_CONSUMER): the existing gbrain sync --no-delegate / GBRAIN_SYNC_NO_DELEGATE=1 extend to Postgres and keep the CLI's own consumer (help text in user terms; flag registry regenerated for the extension); the brain-wide switch is persistence.single_consumer (default on, env GBRAIN_SINGLE_CONSUMER=0), following the preparation_deadlines pattern; under D1 (a′) the delegation ladder's argv classifier admits the managed catch-up's flags (--json, --lanes, --no-bulk, --no-pull, --no-embed) explicitly and gbrain sync --source <id> --no-pull --json is tested through delegation.
  • DX-6 (skew, supersedes CEO-1's unsupported_kind): the fallback triggers on what an older owner really returns (unknown_kind:<kind>, stale_serve, IPC_UNAVAILABLE, missing socket, GBRAIN_SERVE_SYNC_IPC=0) with one actionable warning naming the pid and the restart; an older serve writes no heartbeat row, so a new CLI beside it starts full and its start line says so; T1c runs a real previous-release serve and the reverse pairing.
  • DX-7 (consumer start): startPersistenceConsumer stays synchronous; the consumer starts in probing mode (claims nothing until the first-tick probe answers) and settles to full or waiter_only; a waiter-only writer_pending envelope names the owner (kind, pid, claim.stall.step) with writer status in fix.verify.
  • DX-8 (writer dump): --signal checks the owner row's dump: true capability and same-host liveness before sending SIGUSR2, else returns dump_unsupported; the dump is written under the owner's persistenceHome() and reported as claim.last_dump {path, host_id}; T5 covers the unsupported owner and an alternate GBRAIN_HOME.
  • DX-9 (host.json, supersedes "v2" in CEO-9/I1): the file keeps version: 1 and gains optional minted_under; existing files are never rewritten; missing metadata reports unknown; the printed fix uses the GBRAIN_HOME parent value.
  • DX-10 (docs): troubleshooting.md:52-54 prose corrected (a stuck write can hold its root up to the ceiling), one placeholder-free diagnostic transcript added, §6 gets its success signal, behaviour notices state that consumer election is a preference and how the fallback appears; GBRA-59's deferred host_identity_split name is retired for host_identity_mismatch.

Phase 3 Eng review (always last; reviews the CEO- and DX-amended plan)

Eng snapshot: /home/user/.gstack/projects/garrytan-gbrain/autoplan-eng-DB3F0U/eng-implementation.md (sha ce5b9ed0…9494, source 48cdc579…6996). Methodology read: autoplan-eng-methodology-hkWIEO/methodology.md lines 1–2223 (preferences, cognitive patterns, scope challenge A–C, sections 1–4, test review steps 1–5 and artifact, required outputs; skip-listed sections loaded only). Scope challenge override: never reduce.

Step 0 scope challenge (code read, not memory). Sub-problem → existing code: owner liveness → persistence_worktrees.heartbeat_at (host-level only) and claim_phase owner stamp (pr6298:claim-phase.ts:90-104, bare pid); delegation → sync-delegate.ts ladder + serve-sync-runner.ts + assertDurableSyncCaller (pr6298:sync-authority.ts:26-30), which refuses managed sync under the shared-secret lane by design; stall detection → pr6298:sync-drain.ts:306-329; movement → readManagedSyncBacklog (pr6298:sync-drain.ts:589) and advanceHeld (pr6298:sync-run.ts:445-449); pool numbers → pool-gauge.ts subset and the vendored driver; process start → startPersistenceConsumer synchronous, services map per engine (pr6298:service.ts:88-110); lane state → in-process LaneState read by the CLI's admission (pr6298:sync-run.ts:806,846,873,977). Complexity count (estimate): about 27 changed files, 1 new table, 1 new class (WaiterOnlyConsumer behind an extracted PersistenceConsumerLike interface), 0–3 new IPC kinds depending on D1, 2 new CLI subcommands. Fewer moving parts: D1 (a′) removes the three lane kinds and the cross-process lane lifecycle; G6 default (defer C2) removes a command, a kind and a signal handler. Search check: no new framework pattern beyond a heartbeat table and pg_notify (deferred); labels: heartbeat table [Layer 1], waiter-only consumer [Layer 3] (first-principles from service.ts:160-163), lane hand-off over IPC [Layer 2] (bespoke; replaced by (a′)). Search unavailable — proceeding with in-distribution knowledge only. TODOS cross-reference: TODOS.md:135 (same-host dead-pid release) is G2; TODOS.md:6/21 (hard ceilings) are what #6298 shipped. Distribution: no new artifact; the migration ships with the release.

Dual voices (completed).

  • Native (anthropic/claude-opus-5-5, Capy subagent, INPUT eng ce5b9ed0…9494): 1 Critical, 4 High, 6 Medium, 2 Low; recommendation: revise B1b promotion, B2 exit timing, cross-process wake; pick D1 (a′).
  • Outside (openai/gpt-6.1-sol, Capy subagent standing in for Codex, INPUT eng ce5b9ed0…9494): 7 High, 3 Medium; recommendation: revise authorization, consumer lifecycle, lane renewal and movement-budget contracts before implementation; Phase 0 may proceed.
ENG DUAL VOICES — CONSENSUS TABLE:
  Dimension                           Claude(opus-5-5)                          Outside(gpt-6.1-sol)                         Consensus
  1. Architecture sound?               B1c not "lane logic unchanged"; pick (a′)  B1c renew destructive; (a′) needs auth hand-off CONFIRMED → (a′) recommended with registration hand-off; open/renew/close split
  2. Test coverage sufficient?         promotion at zombie cap, kill mid-lane,     oracles contradictory; fault point before     CONFIRMED gaps → T1b/T2/T4/T5 rewritten, forced probe
                                       latency, PGLite inert, pid collision        named steps; forced before/after probe
  3. Performance risks addressed?      no index for latest committed receipt;      receipt counts unstable under compaction;    CONFIRMED → completed_at watermark + partial index
                                       B4 cost                                     scan cost
  4. Security threats covered?         bare pid → SIGUSR2 to wrong process         pid + capability ≠ identity; (a′) auth seam  CONFIRMED → nonce+pid_ns; signal path dropped; registration hand-off
  5. Error paths handled?              waiter never promotes at zombie cap (Crit)   probing wedge; heartbeat not isolated        CONFIRMED → re-probe per tick, promote on progress, probe lifecycle
  6. Deployment risk manageable?       single_consumer default from Phase 0        allowances vs multi-wave groups              CONFIRMED → default preregistered; progress = commit or step advance
CONFIRMED = native + outside agree. 6/6 confirmed, 0 disagreements. Single-voice critical: native's "waiter never promotes" (the outside voice names the same mechanism as "probing wedge", so treated as confirmed).

Disposition (0D, auto-decided; P5 explicit + P3 pragmatic dominate in Eng): native Critical + outside #5/#6 → waiter re-probes every tick, promotes on lapsed/wedged/not-full/gone owner; wedged from the owner's own zombie/root-barrier state, not "oldest running claim"; probe single-flight with deadline; stop() awaits it (accepted). Native High (B1c) + outside #2 → under (a) three kinds with idempotent open, a renew that never calls openLanes, close that waits for the owner's closeLaneRun; CLI reads lane count/timing back; handshake before admission; registered in the GBRAIN_SERVE_SYNC_IPC block (accepted); and D1's recommended option becomes (a′) (taste, strong consensus: four voices; stays Garry's). Outside #1 → (a′) costed with the verified-registration hand-off instead of lifting assertDurableSyncCaller (accepted). Native High (B2 cuts containment) → stall line from the allowance, exit only past the ceiling or on a wedged owner (accepted as default; G5 at the gate because it departs from #6317 item 2's literal ask). Native High (no cross-process wake) → short-lived foreground kinds keep their own consumer; pg_notify wake deferred (accepted). Native High (B1 mandatory whatever arm (ii) shows) → persistence.single_consumer default set by the preregistered reading (accepted). Native Medium (lapsed predicate) → head_lapsed + owner host + live full row (accepted). Both (process identity) → nonce + pid namespace in stamp and row; --signal dropped (accepted); C2 as a whole → G6 taste, default defer (one voice says defer, the other wants identity validation). Both (heartbeat lane) → text corrected: liveness not progress; single-URL starvation lapses it, which is wanted (accepted). Outside #7 + native (allowances vs multi-wave groups) → progress = commit or step advance for B2, B4 and I2 (accepted). Outside #8 → completed_at watermark in the current incarnation, partial index in the migration (accepted). Native Medium (B4 parked cursor) → movement_state: parked, no score hit (accepted). Native (Phase 0 validity) → arms on master first, candidate (d), Supavisor caveat, forced probe for A1 (accepted). Outside #4 → under (a′) a jobs-elected owner cannot run a sync; the CLI runs its own FIFO consumer for the sync and says so (accepted; stated in B1 scope via resident-kind precedence: serve first). Outside #3 → overlap claim removed; minimal drain-back for promoted consumers only (accepted). Outside #10 + native Low → T4/T1c/T5/Lane E contradictions fixed; fence-repair route per hold kind; WaiterOnlyConsumer behind an interface; I1 reads the owner's paths from the heartbeat row (accepted).

Section 1: Architecture. Dependency graph after the Eng amendments (D1 (a′) shown; (a) adds the dashed box):

  gbrain sync (CLI) ──sync_start{registration}──> gbrain serve ──withVerifiedLocalRegistration──> drainManagedSync (owner process)
        │  polls sync_status{DrainReport,next}         │  PersistenceConsumer FULL (heartbeat 10 s, nonce, wedged fields)
        │  --no-delegate ⇒ own consumer                │  [ (a) only: lanes_open / lanes_renew / lanes_close ]
        v                                              v
  persistence_consumers (host_id,pid,nonce | kind,mode,renewed_at,restart_required,root_barrier_age,pool,host_json_path)
        ^                 ^                                   ^
  jobs/autopilot/mcp ──probe per tick──> WaiterOnly ──promote on lapsed|wedged|gone──> FULL ──drain back after owner healthy 3 ticks──> WaiterOnly
  put/import/dream: own consumer for the write's life (today's behaviour)
  doctor / sources status / writer movement ──read──> consumers table + persistence_requests (partial idx committed completed_at) + op_checkpoints

Boundaries: the owner process is the only publisher on its host while healthy; the CLI becomes a client. Coupling: (a′) couples the CLI to the serve's sync_* surface that already exists; (a) would add a second lifecycle protocol. Single point of failure: the owner; made visible (B4, wedged) and recoverable (promotion on progress) instead of silent. Security: new authorization crossing under (a′) is explicit (verified CLI registration, revocation honoured); no new unauthenticated surface. Production failure per new path: owner wedges with a live heartbeat → waiters promote at the ceiling, drain prints stall lines then owner_wedged_here; pooler drops the direct lane → heartbeat lapses → promotion (wanted); migration holding the table during apply-migrations → probe deadline, consumer stays probing for that tick, logs after three misses. Rollback: persistence.single_consumer false and --no-delegate restore today's topology in seconds; the table is additive. Findings: 4 (promotion on progress, (a′) auth hand-off, lane renew/close split under (a), heartbeat lane semantics), all applied; dispositions above.

Section 2: Code quality. Shared-code rubric: the delegation family is reused (two authored callers today: sync-delegate.ts and serve-sync-runner.ts; the managed branch adds a third through the same wire shapes), which is the reliability gain that justifies (a′) over a new protocol; the heartbeat reader is shared by B1a, B4, doctor and I2 (one module, four callers). Organization: WaiterOnlyConsumer behind PersistenceConsumerLike (the class has private members, pr6298:consumer.ts:115,122, so a structural fake would not typecheck); the probe/heartbeat in one new file beside claim-lease.ts; doctor checks as files under src/commands/doctor/checks/. Error-handling gaps closed: probe failure, heartbeat failure, late probe after stop, lapsed-owner predicate. Complexity flag: startPersistenceConsumer grows a mode state machine (probing/full/waiter_only/promoted) with four transitions; keep it as an explicit enum and a table of transitions in a comment diagram. Findings: 3 (interface extraction, lapsed predicate, mode diagram), applied.

Section 3: Test review. Framework: bun test (unit shards), Postgres E2E tier (bun run test:e2e), Ubicloud gate (CLAUDE.md/docs/TESTING.md); fixtures in test/helpers/persistence-postgres.ts, cli-spawn.ts, serve-http.ts; fault points in src/core/persistence/fault-points.ts. Coverage diagram:

CODE PATHS                                                              USER FLOWS
[+] service.ts startPersistenceConsumer                                 [+] Operator: stuck catch-up
  ├── probe: no row / live full / wedged / error                          ├── [GAP] [→E2E] doctor → sources status → writer status (transcript test, DX-3)
  │   ├── [GAP] probing→full on no row (T1)                               ├── [GAP] [→E2E] T1 two-process catch-up, kill CLI mid-run
  │   ├── [GAP] probing→waiter on live full (T1b)                         └── [GAP]        §6 relief procedure (manual; checklist only)
  │   ├── [GAP] probe error → full + log (edge)                          [+] Deploy: writer movement
  │   └── [GAP] stop() during probe (edge)                                ├── [GAP] six states + healthy-beside-stalled (T4)
  ├── WaiterOnly: wake/holds/status/stop                                  ├── [GAP] bare printed command under raised budget (T4)
  │   ├── [GAP] writer_pending envelope names owner (T1b)                 └── [GAP] --warn-only (T4)
  │   └── [GAP] re-probe per tick → promote on lapsed|wedged|gone (T1b)  [+] Mixed versions
  ├── promoted → drain back after 3 healthy ticks (T1b)        [GAP]      ├── [GAP] older serve: unknown_kind/stale_serve/no socket/IPC off (T1c)
  └── PGLite inert                                             [GAP]      └── [GAP] older CLI beside new serve (T1c, consumers_without_heartbeat)
[+] heartbeat (new file) upsert/delete CTE, nonce, wedged fields         [+] Agent contract
  ├── [GAP] row shape + cleanup at 90 s (T1d)                              └── [GAP] envelope per code: registry, fix.next, fix.verify (DX-1)
  ├── [GAP] write failure logged once (edge)
  └── [GAP] single-URL starvation lapses row (edge)
[+] sync-drain.ts runDrain stall gate (B2)
  ├── [★★★ TESTED] allowance/budget cases — sync-drain-claims.test.ts:48-92 (pr6298)   (one case rewritten: exit at ceiling)
  ├── [GAP] stall line from allowance, exit only past ceiling (T2)
  ├── [GAP] wedged owner → owner_wedged_here (T2)
  └── [GAP] head_lapsed + owner host + live row → one extra window (T2)
[+] movement reader (B4/I2) completed_at watermark, step advance, parked
  ├── [GAP] compaction does not move the watermark backwards (edge)
  ├── [GAP] parked cursor, no live consumer (edge)
  └── [GAP] partial index present (migration golden)
[+] doctor checks: two_consumers_on_host, managed_sync_not_moving, host_identity_mismatch
  ├── [GAP] thresholds and kinds (T1d)
  ├── [GAP] parked not scored (edge)
  └── [GAP] two GBRAIN_HOMEs; container shape without machine-id (T3)
[+] delegation (a′): sync_start with registration; classifier admits managed flags
  ├── [GAP] [→E2E] gbrain sync --source <id> --no-pull --json through delegation
  └── [GAP] denied / revoked / stdio principal refused
[+] lane hand-off (a) only: open/renew/close; late renewal rejected; close waits owner closeLaneRun
  └── [GAP] [→E2E] CLI killed during a lane task
[+] Lane A fix: [GAP] forced probe fails on pr6298 head, passes after
LLM integration: none (no prompt/LLM files touched; no eval suite required)
COVERAGE: 1/31 paths tested today (3%) | after the plan's tests: 31/31 planned | GAPS: 30 (5 E2E, 0 eval)
QUALITY today: ★★★:1 | all GAPs carry a value card in the test plan artifact

Legend: ★★★ behavior + edge + error | ★★ happy path | ★ smoke check | [→E2E] = needs integration test | [→EVAL] = needs LLM eval

Regression rule (IRON): test/sync-drain-claims.test.ts (pr6298:57) asserts drain_stalled for an owner "elsewhere" at the allowance; B2 preserves that for a foreign-host owner and changes only the same-host live-owner exit; the test is rewritten, not weakened, and the foreign-host case keeps its assertion. Flakiness: every two-process test is time-based; use testWaitMs scaling and fault-point barriers inside real awaits (the consumer:preparing fault point fires before the preparer's named steps, pr6298:group-publish.ts:567-570), never sleeps. Test plan artifact written: /home/user/.gstack/projects/garrytan-gbrain/user-master-eng-review-test-plan-20261008-163713.md. Findings: 6 gaps groups, all added to §4 or the artifact; one test to rewrite.

Section 4: Performance. New per-tick work: a waiter-only consumer's re-probe is one primary-key-adjacent read on a table with at most a few rows per host every tick (250 ms default idle → up to 4 reads/s per waiter; acceptable, but the probe backs off with the consumer's idle delay to the 5 s max so an idle waiter reads every 5 s). Heartbeat: one upsert per 10 s per full consumer, single-flight. Movement/B4 reader: one indexed completed_at read per source plus one op_checkpoints read; the partial index keeps it off retained history (the baseline indexes do not cover it, pr6298:src/schema.sql:2024-2028). Memory: the frame list for C2 is dropped with G6's default; nothing else grows. Pool pressure: no new ordinary-pool holders; the probe uses the direct lane like the lease. Findings: 2 (probe backoff, partial index), applied.

Failure modes (Eng additions to the CEO registry).

  CODEPATH                        | FAILURE MODE                                  | RESCUED? | TEST?         | USER SEES?                      | LOGGED?
  --------------------------------|-----------------------------------------------|----------|---------------|---------------------------------|--------
  waiter re-probe                 | owner wedged, heartbeat live                  | Y        | T1b           | promotion line; data_moving      | Y
  waiter re-probe                 | owner at zombie cap                           | Y        | T1b           | promotion line                   | Y
  promotion storm                 | several waiters promote, owner recovers       | Y        | T1b           | doctor overlap, drain-back line  | Y
  probe                           | table locked by migration / slow              | Y        | edge          | probing, log after 3 misses      | Y
  B2 exit                         | same-host wedge before ceiling                | Y        | T2            | stall line every 10 s, no exit   | Y
  lane renew (a)                  | late renewal after close                      | Y        | (a) test      | rejected; run stays closed       | Y
  delegation (a′)                 | revoked registration                          | Y        | auth test     | permission_denied envelope       | Y
  movement reader                 | compaction during window                      | Y        | edge          | watermark unchanged, no false negative | n/a
  CRITICAL GAPS: 0

NOT in scope (Eng). Cross-process consumer wake (pg_notify), so short-lived commands could also be waiter-only; a fenced exclusive consumer role; C2 unless G6 keeps it; Postgres thin-client parity; DB-resident lane state unless D1 (b). What already exists (Eng). Delegation family (reused under (a′)); withVerifiedLocalRegistration (provider.ts:40-63) as the authorization pattern; claim-lease.ts cadence; fault points and testWaitMs fixtures; sync-drain-claims.test.ts allowance cases; error registry + build:error-codes.

Worktree parallelization strategy.

Step Modules touched Depends on
S1 Phase 0 repro + driver accessor docs/eval/, vendor/postgres/src/index.js (accessor only) —
S2 Heartbeat table + probe/waiter seam (B1a/b, B3) src/core/persistence/{service,consumer,heartbeat*}.ts, src/core/schema-migrations/, schema.sql —
S3 Movement reader + B4 + I2 + doctor checks src/core/persistence/movement*.ts, src/commands/{sources,persistence-admin,doctor/checks} S2 (reads the table)
S4 B2 drain gate + envelopes + registry (DX-1/2) src/core/persistence/sync-drain.ts, src/core/error-registry.ts, error-catalogue.ts, docs rows S2 (wedged fields)
S5 D1: (a′) delegation branch + registration hand-off, or (a) lane kinds src/commands/sync-delegate.ts, src/core/serve-sync-runner.ts, src/core/context/{resolve-ipc,sync-ipc}.ts, src/mcp/resolve-ipc-binding.ts S2, Phase 0 arms (i)/(ii), gate D1
S6 I1 identity + C1 pool/next_action + C3 log triple identity.ts, diagnostics.ts, consumer.ts log lines, doctor check S2 (host_json_path on the row)
S7 Lane A cause fix named by Phase 0 S1
S8 Docs, CHANGELOG, KEY_FILES, notices, registry regen, eval mirror docs/, src/core/behavior-change-notice.ts, generated registries all
Parallel lanes: Lane W1: S1 → S7. Lane W2: S2 → S3 → S4 (shared consumer.ts/service.ts sequential inside the lane). Lane W3: S6 (after S2's table lands; touches identity.ts and diagnostics.ts only). Lane W4: S5 after the gate decides D1 and Phase 0 reports. Integrator: S8, merge order W2 → W3 → W4 → W1, full Ubicloud gate on the integrated head (UBI_OWNER=gbra61). Conflict flags: consumer.ts (S2, S4, S6 log lines) and sync-run.ts (S5 under (a)) are the shared files; S4 and S6 rebase onto S2's branch before editing.

Completion summary (Eng).

  • Step 0: Scope Challenge — scope kept (never reduce); two reductions by decision instead: D1 (a′) recommended (removes three IPC kinds), G6 default defers C2.
  • Architecture Review: 4 issues found (applied).
  • Code Quality Review: 3 issues found (applied).
  • Test Review: diagram produced, 30 gaps identified (all planned; 5 E2E; one test rewritten, none weakened).
  • Performance Review: 2 issues found (applied).
  • NOT in scope: written. What already exists: written.
  • TODOS.md updates: 6 items collected across phases (thin-client parity; DB-resident lane state; fenced consumer role; pg_notify wake; external alerting on data_moving; dead-owner release unless G2) — to be written at ship time by the implementing thread (this run writes no repo files beyond the plan).
  • Failure modes: 0 critical gaps flagged.
  • Unresolved decisions: 11 at the gate (D1–D4, G1–G6, Q5).
  • Outside voice: openai/gpt-6.1-sol via Capy subagent, completed (Codex CLI absent; no substitution claimed as Codex).
  • Parallelization: 4 lanes, 3 parallel / 1 gated.
  • Lake Score: N/A (no coverage-scored question offered a 10/10 option; every choice differed in kind).

Decision Audit Trail (Eng rows)

# Phase Decision Classification Principle Rationale Rejected
29 Eng waiter re-probes per tick; promotes on lapsed/wedged/not-full/gone Mechanical P1 zombie cap stops claiming with a live heartbeat first-tick only
30 Eng wedged from owner's zombie/root-barrier state, nonce+pid_ns identity Mechanical P5 released request is not running; pid reuse oldest running claim; bare pid
31 Eng B2 fires only past the ceiling or on a wedged owner (default) Taste → G5 P3 keeps #6298 containment; issue asked for the allowance fire at 150 s
32 Eng short-lived foreground kinds keep own consumer; pg_notify deferred Mechanical P3/P5 in-process wake only waiter-only for all
33 Eng single_consumer default set by Phase 0's preregistered reading Mechanical P6/P1 B1 funnels writes into a possibly-wedging owner always on
34 Eng D1 recommended option → (a′) with registration hand-off Taste → D1 P4/P5 four voices; (a) not "lane logic unchanged" (a) as recommended
35 Eng under (a): open/renew/close split, close waits owner Mechanical P5 openLanes replaces state renew = open
36 Eng progress = commit or step advance (B2/B4/I2) Mechanical P1 multi-wave groups commit only
37 Eng completed_at watermark + partial index Mechanical P1 compaction, no index receipt count
38 Eng C2 signal path dropped; C2 itself G6 default defer Taste → G6 P3 unsafe signal; C1 covers the need keep with --signal
39 Eng parked state, not scored Mechanical P5 cron-shaped brains score every unfinished cursor
40 Eng promoted consumers drain back; no other demotion Mechanical P5 promotion storms converge fenced role now
41 Eng Phase 0 on master first; candidate (d); forced probe for A1 Mechanical P1 driver mix; repo flake rule pr6298 only
  • ENG-1 (promotion on progress, supersedes the first-tick-only probe in DX-7/CEO-3): a waiter-only consumer re-probes on every tick and promotes when the owner's row is lapsed, wedged, not full or gone; wedged is derived from the owner's own status() (zombie count, oldest abandoned root barrier age; restart_required or a barrier older than the ceiling), not from running claims; the probe and heartbeat are single-flight with the consumer's phase deadline; stop() cancels and awaits them; late results are dropped; the re-probe backs off with the consumer's idle delay. Test T1b (zombie cap, wedged owner, stop during probe, PGLite inert).
  • ENG-2 (identity): claim stamps and heartbeat rows carry {kind, pid, nonce, pid_ns}; same-process checks compare the nonce; the row's primary key is (host_id, pid, nonce); the row also carries host_json_path, persistence_home, minted_under and the wedged fields.
  • ENG-3 (B2 exit timing, supersedes CEO-5's and DX-2's "fires after the allowance"): the drain prints the stall line with owner pid, kind and the C3 triple every 10 s from the allowance, keeps running, and fires drain_stalled only past the ceiling without a root release or when the owner is wedged; the lapsed-owner wait uses head_lapsed + owner host + a live full row, never claimable_here; sync-drain-claims.test.ts's same-host case is rewritten, the foreign-host case unchanged. Gate G5 may move the exit back to the allowance.
  • ENG-4 (B1 scope and default, supersedes CEO-3's "every waiter"): resident kinds defer; serve starts full; short-lived foreground kinds keep their own consumer; persistence.single_consumer's shipped default is set by Phase 0's preregistered reading (on only if arm (i) wedges and arm (ii) does not); only promoted consumers drain back (three healthy owner ticks); persistent overlap of two full starters is reported, not bounded. A jobs-elected owner cannot run a sync, so the sync CLI runs its own FIFO consumer and says so.
  • ENG-5 (D1): (a′) is the recommended option, costed with the verified CLI-registration hand-off (withVerifiedLocalRegistration, denied/revoked/stdio tests) instead of lifting assertDurableSyncCaller; under (a) the protocol is lanes_open (idempotent), lanes_renew (never openLanes), lanes_close (owner marks closing, rejects late renewals, awaits its closeLaneRun, then cancels orphans; the CLI waits for the reply), serialized per worktree/run, registered in the GBRAIN_SERVE_SYNC_IPC block, handshake before the first admission, CLI reads lane count and timing back and never calls openLanes locally; a promoted CLI is never a second lane runner. The choice stays Garry's.
  • ENG-6 (progress and movement, supersedes count-based wording in CEO-7/DX-4): progress is a committed receipt or a head step advance for B2, B4 and I2; the watermark is the newest completed_at of committed managed receipts in the current incarnation via a partial index (worktree_id, completed_at DESC) WHERE state='committed' added in the migration; I2's default window is max(300 s, budget + 60 s); held routes by hold kind (retry-held for preparation_stalled); B4 reports movement_state: parked (not scored) when no drain or full consumer is live.
  • ENG-7 (C2): the --signal path is dropped; C2 is gate item G6 with default defer (if kept: IPC-only, no per-boundary stack capture; T5 uses a barrier inside a real preparer step).
  • ENG-8 (Phase 0): arms run on master first, then #6298's head; candidate (d) (lost pooler/driver response) added; PgBouncer is a stand-in for Supavisor and a negative result does not clear production; A1's regression test is a forced probe (fails on #6298's head, passes with the fix).
  • ENG-9 (seams and tests): WaiterOnlyConsumer implements an extracted PersistenceConsumerLike interface; the consumer mode machine (probing/full/waiter_only/promoted) is an explicit enum with a comment diagram; T1c's older-CLI case asserts consumers_without_heartbeat; T4's held case exits 0; T5 (if G6 keeps C2) parks inside import_screen; the test plan artifact at the path in the Review record is the /qa input.
  • ENG-10 (TODOS at ship time, collected from all phases): thin-client parity; DB-resident lane state unless D1 (b); fenced consumer role; pg_notify cross-process wake; external alerting on data_moving; same-host dead-owner release unless G2.

Pre-gate verification

Phase Required outputs Status
CEO premise challenges (9), findings per section (1–10, 11 skipped), Error & Rescue registry (12 rows), Failure Modes registry (12 rows, 0 critical), NOT in scope, What already exists, dream state delta, Completion Summary, consensus table (5/6 confirmed, 1 disagree) complete
Design skipped, no UI scope skipped
DX 8 dimension scores, developer journey map, empathy narrative, TTHW assessment and target, DX Implementation Checklist, consensus table (6/6) complete
Eng scope challenge grounded in code, architecture diagram, codepath-to-test diagram, test plan on disk, NOT in scope, What already exists, failure modes registry (0 critical), Completion Summary, consensus table (6/6) complete
Cross-phase audit trail rows 1–41 (one per auto-decision) complete

Per-phase task JSONL was not emitted (Capy run without the skills' JSONL writers); the Implementation Tasks below are aggregated by hand from the accepted obligations.

Implementation Tasks (aggregated across phases)

  • T-01 (P1, human: ~1 d / CC: ~1 h) — persistence — persistence_consumers migration (PK (host_id, pid, nonce), kind, mode, renewed_at, pid_ns, started_at, restart_required, root_barrier_age, pool, host_json_path, persistence_home, minted_under, dump) + partial index (worktree_id, completed_at DESC) WHERE state='committed'; number at the merge slot; schema.sql, goldens, PGLite parity. Surfaced by: CEO-4, ENG-2, ENG-6.
  • T-02 (P1, human: ~2 d / CC: ~2 h) — persistence — probe + heartbeat module (single-flight, deadline, direct lane, CTE cleanup), consumer mode machine (probing/full/waiter_only/promoted), WaiterOnlyConsumer behind PersistenceConsumerLike, per-tick re-probe and promotion on progress, drain-back, persistence.single_consumer switch, resident-kind scope. Surfaced by: CEO-1/3, DX-7, ENG-1/4/9.
  • T-03 (P1, human: ~1 d / CC: ~1 h) — sync-drain — B2: stall line from the allowance with owner pid/kind/triple, exit past the ceiling or on a wedged owner, owner_wedged_here envelope with retry_after_ms, lapsed predicate (head_lapsed + owner host + live row); rewrite the same-host case in sync-drain-claims.test.ts. Surfaced by: CEO-5, DX-2, ENG-3.
  • T-04 (P1, human: ~1 d / CC: ~1 h) — status/doctor — movement reader (completed_at watermark, step advance, parked), B4 data_moving/not_moving_since/movement_state on sources status and writer status, doctor managed_sync_not_moving (structured fix), [gbrain notice] on flip, sources status --json prints the writer-status command. Surfaced by: CEO-12, DX-3, ENG-6.
  • T-05 (P1, human: ~1 d / CC: ~1 h) — CLI — gbrain sources writer movement [<source>] [--wait <dur>] [--warn-only] [--json] with six states, per-state exit and envelope; upgrade/post-upgrade print the bare command; upgrade guide restart-and-verify sequence. Surfaced by: CEO-7, DX-4, ENG-6.
  • T-06 (P1, human: ~1 d / CC: ~1 h) — errors/docs — error-registry.ts entries + catalogue anchors + contract tests for drain_stalled (new cause), two_consumers_on_host, host_identity_mismatch, managed_sync_not_moving, (dump_unsupported if G6 keeps C2); rewrite write-refusals.md:416, troubleshooting.md:52-54, live-sync outcome table; diagnostic transcript. Surfaced by: DX-1/2/10.
  • T-07 (P1, human: ~2 d / CC: ~2 h, gated on D1 and Phase 0) — delegation — (a′): Postgres branch in sync-delegate.ts, verified CLI-registration hand-off in sync_start, drainManagedSync in the serve, sync_status carries DrainReport/next, classifier admits managed flags, --no-delegate extended; denied/revoked/stdio tests. Or (a): lanes_open/lanes_renew/lanes_close per ENG-5. Surfaced by: CEO-1/14, DX-5/6, ENG-5.
  • T-08 (P2, human: ~0.5 d / CC: ~30 min) — identity/status — I1 host_identity_mismatch (both predicates), minted_under on a version-1 host.json, owner paths from the heartbeat row; C1 next_action envelope, last_sql via boundedReads, pool numbers from the vendored-driver accessor (G1 default) + tracked_subset; C3 log triple. Surfaced by: CEO-9/10/13, DX-3/9, ENG-9.
  • T-09 (P1, human: ~0.5 d / CC: ~3 h box) — eval — Phase 0 on Ubicloud: arms (i)/(ii)/(iii) on master then #6298's head, candidates (a)–(d), preregistered reading, claim_phase.step as first instrument, driver accessor in the build, placeholder write-up mirrored to gbrain-evals. Surfaced by: CEO-2/6/11, ENG-8.
  • T-10 (P1, human: ~1 d / CC: ~1 h, gated on Phase 0) — persistence — Lane A cause fix with a forced-probe regression test. Surfaced by: A1, ENG-8.
  • T-11 (P2, human: ~0.5 d / CC: ~30 min) — docs/release — behaviour notices (B1 preference and fallback, I2), CHANGELOG, KEY_FILES, flag registry regen, TODOS.md (6 items), GBRA-59 file ownership, citations restamped against pr6298, §6 success signal. Surfaced by: CEO-9/14, DX-10, ENG-10.
  • T-12 (P1, human: ~2 d / CC: ~2 h) — tests — T1, T1b, T1c, T1d, T2, T3, T4, T5 (if kept), transcript test, contract tests; two-process Postgres fixture with a spawned serve; full Ubicloud gate on the integrated head. Surfaced by: §4, ENG-9, test plan artifact.

GSTACK REVIEW REPORT

Review Trigger Why Runs Status Findings
CEO Review /plan-ceo-review (via /autoplan) Scope & strategy 1 issues_open (8 gate decisions) 9 premises challenged, 3 invalid as written; 14 accepted obligations; 12 error paths, 0 critical gaps
Outside Review openai/gpt-6.1-sol via Capy subagent (Codex CLI absent) Independent 2nd opinion 3 (ceo, dx, eng) completed CEO 5 (1 Critical), DX 8 (5 High), Eng 10 (7 High)
Eng Review /plan-eng-review (via /autoplan) Architecture & tests (required) 1 issues_open (gate decisions D1, G5, G6) 4 architecture, 3 quality, 30 test gaps planned, 2 performance; 0 critical gaps
Design Review /plan-design-review UI/UX gaps 0 skipped (no UI scope) —
DX Review /plan-devex-review (via /autoplan) Developer experience gaps 1 issues_open (G4) 8 dimensions scored; overall 4.6 → 7.6/10; TTHW ~1 day → ~3 min target
  • OUTSIDE COVERAGE: provider openai/gpt-6.1-sol (Capy subagent standing in for the Codex CLI, which is not installed and was not installed): CEO completed (5 findings), DX completed (8), Eng completed (10); Design skipped. Native voice anthropic/claude-opus-5-5 completed in all three phases (8, 12, 13 findings). Spec review loop: anthropic/claude-sonnet-5-5, 3 launches, final 6/10.
  • CROSS-MODEL: native (Anthropic Claude Opus 5.5) and outside (OpenAI GPT-6.1 Sol) are distinct model families. Overlap: CEO 5/6 dimensions confirmed (disagreement: one PR vs split); DX 6/6; Eng 6/6. Independent agreement on the three load-bearing changes: health surfaces must change (B4), the plan's B1 was a preference not an invariant, and D1 (a′) over a new lane protocol.
  • VERDICT: CEO, DX and ENG reviews complete with issues open at the user gate; nothing CLEAR until Garry decides D1–D4, G1–G6 and Q5. Eng review required: no (completed); approval required: yes.

Scores (driver's assessment, before → after the amendments): CEO 4/10 → 7/10; DX 4.6/10 → 7.6/10; Eng 3/10 → 7/10.

DECISIONS (Garry, 2026-10-08, "approve all"): D1 (a′) serve-delegated sync with a verified CLI-registration hand-off; D2 refuse by default (--warn-only); D3 warn with both paths and env; D4 cause fix in this PR when Phase 0 names it in its box and the fix is ready the same day, else PR 4, persistence.single_consumer default set by Phase 0's preregistered reading; G1 vendored-driver accessor; G2 not in this PR; G3 one PR with the Phase 0-gated pieces inside it; G4 held exits 0 with a warning; G5 drain_stalled at the ceiling or on a wedged owner, stall line from the allowance; G6 writer dump deferred; Q5 interim relief recommended to Garry.

DECISIONS AS REVIEWED (kept for the record):

  • D1 catch-up sharing: (a′) reuse serve-delegated sync with a registration hand-off (recommended after review) vs (a) lane hand-off over the resolve IPC (author's original) vs (b) DB-resident lane state vs (c) CLI refuses beside serve.
  • D2 movement check default: refuse (exit 1 with the summary; recommended) vs warn and exit 0.
  • D3 host identity: warn with both paths and env (recommended) vs re-derive from a machine id.
  • D4 Phase 0 cause fix in this PR (if named in the 3-hour box and ready the same day; recommended) vs PR 4.
  • G1 pool numbers: vendored-driver accessor (default) vs pool-gauge.ts subset labelled tracked_subset.
  • G2 same-host dead-owner release: not in this PR (default) vs add on the heartbeat.
  • G3 one PR with B1c/lane A gated inside (recommended) vs split by certainty (3a: B2, B4, C1, C3, I1, I2; 3b: B1, B3, C2, lane A).
  • G4 held movement state: exit 0 with warning and hold route (default) vs non-zero.
  • G5 drain_stalled exit: at the 600 s ceiling or on a wedged owner (default) vs at the 150 s allowance (the issue's literal ask).
  • G6 C2 writer dump: defer (default) vs keep IPC-only.
  • Q5 interim relief today: stop serve, pause maintenance submitters, run the one-consumer catch-up with the 60 s status capture (MCP down for one to two hours) — Garry's call.