Skip to content

docs: agents may stage and restart merged Chromeria builds - #265

Merged
lukemaj merged 3 commits into
mainfrom
docs/staging-restart-rule
Nov 14, 2026
Merged

lukemaj merged 3 commits into
mainfrom
docs/staging-restart-rule

Conversation

@lukemaj

@lukemaj lukemaj commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

What: AGENTS.md gives agents standing authority to stage a merged main build on bestia, rocky and cavallo and restart Chromeria to swap it in, following the runbook's checks.
Why: The user granted this on 2026-10-14 and approved landing it on 2026-11-14; the old staging rule from #78 was not carried into the V2 move.
So what: The user approved this on 2026-11-14; it merges under that approval once exact-head checks and independent review pass, and agents then follow the runbook for every install.

Details

  • The rule is one bullet in "Pull requests", right after the standing merge authority it extends: after a merge, the same rollout the daily absorption job runs. It covers merged main only.
  • The runbook owns the procedure, so AGENTS.md only points at it: ~/dev/runbook/cavallo/CHROMERIA.md (Rules, "Restarting to install a build", "Before and after a restart"), plus rocky/CHROMERIA.md or bestia/README.md. It owns the restart tool, the pre-check, the post-check, deployment retention and the CHANGES.md record.
  • docs/fork.md still says opening a PR grants no installation authority; this grant starts at the merge, so the two agree.

Rebuild on current main (2026-11-14)

Rebuilt by cherry-picking the two original commits onto origin/main 29b14db, plus one commit that fits the text to current main:

The old head's failing Check and Test Server 6 ran on a pre-rebuild base; the rebuilt head reruns CI.

Proof

  • bash scripts/fork-check.sh --upstream upstream: OK (AGENTS.md is registered in scripts/fork-upstream-edits.txt).
  • vp run check:changed: format passes; no code changed.

Elon record

Done by Claude Opus 5.5 in Claude Code (T3 Code).

🤖 Generated with Claude Code

@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:XS labels Oct 14, 2026
@lukemaj

lukemaj commented Oct 14, 2026

Copy link
Copy Markdown
Contributor Author

What: Independent review of exact head 0969c36ea098600615209c4ddade52b341657f43 found two blocking defects in the runbook checks required by this PR.
Why: The pre-check can hide destructive-to-interrupt work, and the post-check can wake work that has already resumed.
So what: Correct the referenced runbook checks before accepting the restart safety rule; no checkout, installation or restart was performed.

Verdict: FAIL. Reviewed the complete PR diff and runbook commit de8e42644a8c1a537014f99fb99d38527d1705e3, against recovery code at the requested PR SHA.

  1. Blocking: the pre-check is not sufficient to establish that no long command is running. Location: AGENTS.md pre-check bullet, through cavallo/CHROMERIA.md:150-162 at runbook de8e426. The scalar subquery returns only one matching command, without ordering, and truncates it to 60 characters. A Claude/Grok run with parallel pwd and pnpm build can therefore show only pwd, and the documented rule permits restarting while the build is running. A long shell command can also hide its build/deploy suffix after the truncation. A read-only SQLite fixture with those two command rows returned only pwd. The check also reads only active runs, while ProviderRuntimeRecoveryService.ts explicitly cancels background-capable items on settled runs and provider-native children with null run IDs. Required correction: inspect all active commands and relevant provider-owned background work, with enough input to decide whether interruption loses work; include thread IDs so the caller exception is unambiguous. Do not treat the current single preview column as the safety gate.

  2. Blocking: the post-check does not establish that a thread still needs a wake. Location: AGENTS.md post-check bullet, through cavallo/CHROMERIA.md:172-188. It identifies cancelled runs by time and absence of one automatic message ID, but never checks for a later nonqueued run. The named caller gets the restart helper's manual resume; a coordinator can also wake a child before this check. Both remain in this result because those messages are not message:restart-continuation:<old-run-id>, so the instruction to wake every result submits duplicate work. Multiple qualifying cancelled runs also produce multiple wakes to the same thread. A read-only SQLite fixture containing a cancelled cut run followed by a completed manual resume still returned that thread. RestartContinuation.ts explicitly rejects continuation when a later nonqueued run exists, an essential safeguard missing here. Required correction: reconcile the recorded pre-restart run identities with current thread state, exclude superseded/resumed work, and deduplicate by thread before sending. Also distinguish a cancelled waiting/background run from a cut unfinished root turn: recovery can cancel both, but isRestartNoteSource deliberately prevents waking settled background work.

Other checks:

  • Authority is limited to merged fork builds on the three named machines and matches the supplied user decision. The small AGENTS.md pointer is clear; the blockers are in the procedure it makes mandatory.
  • Both documented SQL blocks ran successfully with sqlite3 -readonly on bestia's live database. This proves syntax/schema compatibility, not the correctness of the inferred restart sets. Held-queue JSON and status predicates match the code.
  • Recovery cancels active work and closes pending runtime requests. Graceful shutdown marks requests cancelled; startup marks remaining requests expired. Automatic continuation is conditional on settings and provider/thread/session/turn checks. Delegated-result recovery and explicit queue holds agree with the broad claims; no queue-resume MCP entry was found.
  • Bestia's separate transient user service is appropriate: the live t3code.service has its own cgroup and KillMode=mixed; the updater must run outside that cgroup. systemd-run defaults to a transient service, and passing PATH preserves tool discovery. Reviewed the installed systemd 261 manual and systemd's source documentation. The one-time scheduler shape is valid, and ending the caller's turn avoids its own active-run idle wait. No updater or transient unit was started.

Nits, not blockers: point rocky agents at rocky/CHROMERIA.md as well, since it owns rocky-specific staging differences; the PR body's claim that pending approvals always “expire” should distinguish graceful-shutdown cancellation from startup expiration.

Elon record:

Requirements and who asked: The user requested exact-head independent review of restart authority, recovery claims, SQL safety and bestia's updater procedure.
Deleted: No checkout, implementation, restart, installation or additional reviewer delegation.
Bottleneck: The required checks must correctly identify work that would be lost and threads that still need continuation.
Checked myself: Complete diff, exact-head recovery and continuation code, delegated-result recovery and queue hold, pushed runbook diff, read-only live SQL, minimal read-only SQLite counterexamples, installed systemd manual and live service properties.

Reviewed by gpt-6.1-sol, medium effort, through the Codex harness in T3 Code.

@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

ℹ️ The exact PR base did not have a successful artifact. Baseline uses the latest successful main measurement shown below.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅
Codex Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Codex Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅
Codex Live turn WebSocket decoded 20.9 KiB 20.9 KiB 0 B (0.0%) 29.3 KiB ✅
Codex Live turn messages 2 2 0 (0.0%) 8 ✅
Claude Total thread wire 5.0 KiB 5.0 KiB +7 B (+0.1%) 6.8 KiB ✅
Claude Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Claude Live turn WebSocket wire 1.2 KiB 1.2 KiB +7 B (+0.6%) 2.0 KiB ✅
Claude Live turn WebSocket decoded 21.2 KiB 21.2 KiB 0 B (0.0%) 29.3 KiB ✅
Claude Live turn messages 2 2 0 (0.0%) 8 ✅

Baseline: 6d167d4 · PR result: ff2e027 · Source CI: failure

Scenario and decoded snapshot size

10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

  • Codex decoded thread snapshot: 108.5 KiB
  • Claude decoded thread snapshot: 108.8 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

@lukemaj

lukemaj commented Oct 14, 2026

Copy link
Copy Markdown
Contributor Author

Verdict: failure. Two blocking findings. The systemd-run escape, the SQL shape, and the restart-recovery claims in the code check out.

Reviewed 0969c36ea098600615209c4ddade52b341657f43 (AGENTS.md only) and runbook de8e426. Code read from chromeria-worktrees/staging-restart-rule at that SHA. SQL run with sqlite3 -readonly on bestia. No restart.

Blocking

  1. The wake step is wider than the decision. The user allowed a restart on the condition that coordinators continue and may wake their children. AGENTS.md tells the restarting agent to "wake every cut thread Chromeria did not continue," and cavallo/CHROMERIA.md says to t3_thread_send Continue where you left off. into each row the post-check returns. That set is every started run cancelled after the noted time, on the whole machine. A coordinator that already got cancelled will re-delegate (that is what happened to the Codex child in Restart continuation silently skips some cut turns; Codex threads were never continued #264) while this wake also revives the old child, so the work runs twice. Threads the restarter does not coordinate get a new turn they did not ask for.

    The instruction needs to match the decision: a coordinator wakes its own children. Other cut threads are reported, not messaged.

  2. On bestia the post-check is not anchored to the restart, so cut threads can be left unwoken. bestia/README.md says to schedule_task with {type: "once", at: ...} and end the turn. chromeria-server-update builds and smoke-tests while t3code.service is still up, and only then waits for an idle count. A once task fires at at if the server is up (ScheduledTaskService.ts isMissedFixedTimeRun applies only to fixed_time; an overdue once fires on the next poll and then nextRunAt is null, so it never fires again). Any at during the build consumes the post-check before the swap. The pre-check still allows other claudeAgent and grok runs in running, but the updater waits until those are gone too, so the idle wait can outlast a later at as well.

    A fire that stays queued does not keep the updater waiting: the idle query counts only preparing, starting, running, and waiting. Startup then sets queueHeld on queued runs (ProviderRuntimeRecoveryService.ts around the queued-run loop), and a new dispatch into a held queue is stored held (Orchestrator.ts around the queueHeld: true spread on message dispatch). That post-check never starts. queue.resume is the only clear, and there is no MCP tool for it.

    The post-check predicate has the same window problem. It selects every cancelled run with startedAt set and completed_at at or after the pre-check time. That time is noted before the build, so a cancel during the build is treated as a restart cut. The Mac job is the same predicate with a shorter window (GRACE_SECONDS is 30). The rocky result in the PR body used a known restart instant; the written steps do not.

    The one-shot has to run only after the new build is healthy, and the predicate has to be that restart's cancels.

Nits

  • Leaving the <restart time> placeholder makes the comparison false ('2026-10-14T…Z' >= '<restart time>' is 0), so the check reports no cut threads and looks successful.
  • The pre-check command subquery has no LIMIT 1. Two command_execution rows in running for one run abort the statement. None of the 22 active runs on bestia has more than one, and a failed statement is fail-closed.
  • "Read cavallo/CHROMERIA.md in full" also takes the agent through the watchdog publish procedure, which says that procedure never restarts Chromeria.
  • "A restart cuts every running turn" skips a waiting run that still has a replayable checkpoint.capture (ProviderRuntimeRecoveryService.ts, the hasReplayableCheckpoint continue). The updater still waits on waiting, so the check is stricter than the sentence.
  • A post-check that runs in the same moment the server becomes healthy can list a thread whose provider-runtime.continue effect has not written message:restart-continuation:<runId> yet.
  • continueThreadsAfterServerUpdate defaults to false (packages/contracts/src/settings.ts). bestia's settings.json is true. rocky and cavallo were not rechecked from this machine.

Cleared

  • Scope matches the grant: bestia, rocky, and cavallo, merged fork main, without a further ask. CHANGES.md is the standing machine record, not a new restart power. The named tools are the ones that exist.
  • From inside t3code.service, systemd-run --user --collect --setenv=PATH="$PATH" started a sibling app.slice/review-probe-*.service, not a child of t3code.service. KillMode=mixed kills that service's cgroup only. The probe had HOME, XDG_RUNTIME_DIR, and DBUS_SESSION_BUS_ADDRESS, systemctl --user is-active worked, and node, git, sqlite3, curl, tar, sha256sum, and vp resolved. The probe unit exited and is inactive. ~/.local/bin/chromeria-server-update hashes equal to de8e426 (92ece82bf52e…). Adding waiting to the idle query matches runs whose approvals die on reconcile.
  • Reconcile cancels preparing, starting, running, and waiting runs (checkpoint exception above), expires pending non-message runtime requests on startup, and holds queued runs until queue.resume. The only queueHeld: false write is that command. No MCP tool sends it.
  • With the setting on, continueRestartedRun dispatches Continue where you left off. as message:restart-continuation:<sourceRunId> for a run restartContinuationRun accepts. It returns without a message when the run is not running, the provider thread or session fails the liveness checks, the user had interrupted, or the source is a maintenance command. That is the Restart continuation silently skips some cut turns; Codex threads were never continued #264 skip. A declined continuation still calls recoverDelegatedTask, so the parent hears cancelled. recoverDelegatedTasks runs after reconcile and before the effect worker (serverRuntimeStartup.ts).
  • Both runbook statements execute on bestia: 22 active runs (claudeAgent, grok, codex only), post-check returned 0 not-continued and 0 held. The six cancelled runs here all have null startedAt, so the filter excluded them. json_extract(..., '$.queueHeld') = 1 matches JSON true. completed_at values like 2026-10-14T07:05:10.216Z compare in order with date -u +%FT%T.

@lukemaj

lukemaj commented Oct 14, 2026

Copy link
Copy Markdown
Contributor Author

What: Round 2 independent review of exact head ff2e027381f91952f2da424c5762ad8a61d8e23e finds two blocking defects in the referenced restart procedure.
Why: Bestia's final idle gate omits settled background work, and the post-check treats creation order as execution order.
So what: Fix these two runbook checks before accepting this restart rule; no restart or updater was run during this review.

Blocking findings

  1. P1: Bestia can still kill background work that starts during the build. Location: bestia/scripts/chromeria-server-update:45-57 and the detached-updater procedure in bestia/README.md, runbook commit 2b1b591. The agent runs the complete pre-check before launching the updater and ending its turn. The build and idle wait then run unattended, but the final gate counts only runs with status preparing/starting/running/waiting. A different thread can launch background work while the build runs, settle its root turn, and leave a nonterminal tool item or pendingBackgroundTasks without any active run. Both idle checks pass and the service stops, killing that work. This is a supported state, not just a hypothetical race: read-only bestia data contained two provider threads with pending background tasks and no active run in their thread. ProviderRuntimeRecoveryService.ts explicitly cancels background items on already-settled runs and clears the persisted roster. The improved manual pre-check fixes the original omission at inspection time, but it does not protect the delayed bestia restart. Include the same unfinished-work and background-roster checks in the updater's final idle gate, failing closed on query errors.

  2. P2: The post-check can wake a thread whose later turn already completed. Location: cavallo/CHROMERIA.md:200-202, runbook commit 2b1b591. later.ordinal > r.ordinal tests creation order, not execution order. In Orchestrator.ts, delegated completion wakes can jump queued prompts; startNextQueuedRun preserves the queued run's original ordinal. Reachable example: a queued prompt has ordinal 2, a delegated completion wake with ordinal 3 starts first and is cut, then the user resumes the held ordinal-2 prompt and it completes before the post-check. There is now a later executed turn, but the query still emits cancelled ordinal 3. That thread was running in the pre-check and can have no parent, so the documented wake rule sends another continuation after work has already progressed. A read-only SQLite CTE with cancelled ordinal 3 completed at 07:00:01 and completed ordinal 2 at 07:02:00 returned incorrectly reported not continued|top-level. The server's runRanAfter helper in packages/shared/src/orchestrationV2ThreadError.ts:69-77 explicitly compares completion time first and ordinal only as a tie-breaker. Use execution-aware ordering in the post-check, including live later turns, rather than ordinal alone.

Round 1 response verification

  • Sol 1: Full inputs and all unfinished item rows are now inspected; app-owned exclusion matches isAppOwnedDelegation; persisted background rosters are included. The remaining delayed bestia gate problem is finding 1.
  • Sol 2: DISTINCT removes duplicate thread rows; later higher-ordinal nonqueued runs are excluded; the prose correctly restricts wakes to pre-check running rows. Execution-order coverage remains incomplete, finding 2.
  • Grok 1: Addressed. Parent lineage is returned and only parentless threads may be manually woken. RestartContinuation.ts and Orchestrator.ts retain delegated result recovery and coordinator-owned delivery.
  • Grok 2: Addressed for the reported cases. The timestamp comes from the actual stop boundary, and the scheduled bestia check waits for the updater's running <sha> result instead of treating build completion as restart completion.
  • Nits: Rocky's dedicated pointer is present; the PR body correctly distinguishes clean-shutdown approval cancellation from startup expiry. No additional nits.

Proof and limits

Read the complete PR diff with gh pr diff 265 --repo toolboxmd/chromeria; confirmed the live PR head equals the requested SHA. Read recovery, continuation and relevant orchestration code through git show <sha>:<path>, and the referenced runbook files at 2b1b591.

Ran both documented SQL blocks with sqlite3 -readonly on bestia and rocky. Bestia pre-check returned 24 run rows, 1 work row and 2 background rows; post-check using the service's last actual ActiveExitTimestamp returned no rows. Rocky pre/post checks returned no rows using its last watchdog status=quitting timestamp. Separately confirmed the two bestia background rosters belong to threads without active runs. The ordering counterexample used read-only in-memory SQLite. Live queries validate syntax and current data; they do not exercise a restart. No checkout, restart, updater, restart job, or live-state write occurred.

Elon record

Requirements and who asked: User: exact-head, independent read-only round 2 review; protect running work before restart and preserve coordinator ownership afterward.
Deleted: No implementation, browser, restart or build execution was needed for this review.
Bottleneck: The safety decision occurs after an unattended build, and the post-check must recognize actual execution order.
Checked myself: Exact diff and recovery code, pinned runbook, read-only SQL on bestia and rocky, settled-background state, and the SQL ordering counterexample.

Reviewed by GPT-6.1 Sol, medium reasoning, Codex harness in T3 Code.

@lukemaj

lukemaj commented Oct 14, 2026

Copy link
Copy Markdown
Contributor Author

Independent review, round 2, of ff2e027381f91952f2da424c5762ad8a61d8e23e. Verdict: failure. One blocking finding.

Checked AGENTS.md in the PR diff, server code at that SHA (ProviderRuntimeRecoveryService.ts, RestartContinuation.ts, Orchestrator.ts, runRanAfter), and the runbook agents will read: ~/dev/runbook at b639b21 (restart text last changed in 5119a04; the PR body still names 2b1b591). SQL was run read-only against bestia's chromeria-v2.sqlite. Nothing was restarted.

Round 1

  • Sol 1, cleared. The pre-check lists every nonterminal command_execution, dynamic_tool, and subagent row, with the full $.input (live open rows: shown length equals raw length; stored text inputs reach 21046 characters), and every provider thread whose pendingBackgroundTasks is non-empty. app_owned rows with childThreadId are excluded, matching isAppOwnedDelegation. Live nonterminal providers are claudeAgent, grok, and codex, which is what the prose names.
  • Sol 2, SQL cleared. select distinct remains. A thread with any later non-queued run is excluded. The predicate now follows runRanAfter: unfinished (completed_at null) is latest, otherwise later completion time, ordinal only on a tie. All 268 stored completed_at values are 24-character ISO strings, so that string compare matches time.
  • Grok 1, cleared. The post-check selects lineage.parentThreadId. Live subagent threads have one; top-level threads have null. The wake rule sends t3_thread_send only when that column is null.
  • Grok 2, cleared. Bestia stop time is ActiveExitTimestamp. On this machine that is the Stopping journal line (2026-10-13 23:21:38 CEST), three seconds before Stopped, and date -u -d prints 2026-10-13T21:21:38. Shutdown reconcile runs after that line, and '2026-10-13T21:21:38.871Z' >= '2026-10-13T21:21:38' is true while the previous second is false. The Mac stamp is the status=quitting line logged before stop_app(), with Z removed. The once-task checks the updater journal before it queries. 5119a04 makes chromeria-server-update wait for the same run, tool-work, and background counts as the pre-check; the installed script matches the repo copy.
  • Nits from round 1, cleared. AGENTS.md sends rocky at rocky/CHROMERIA.md. A clean shutdown cancels pending runtime requests; startup marks them expired.

Blocking

The post-check will not wake a cut thread that started after the pre-check snapshot, which is the thread a restart can still kill.

cavallo/CHROMERIA.md says to keep the pre-check run rows and to wake a not continued row only when it has no parent and was a running row in that snapshot. AGENTS.md says to wake each cut top-level thread Chromeria did not continue. The runbook is the text agents follow, and it drops the rest.

On a Mac the snapshot is taken, then chromeria-restart-and-resume sleeps 30 seconds (GRACE_SECONDS) and quits. The job does not look at other threads again. A Codex turn, or a Claude turn restartContinuationRun skips, that is running at SIGTERM and was not running at the snapshot is cancelled. The post-check SQL returns it (cancelled, startedAt set, no later run under runRanAfter). The prose then says not to wake it. restartContinuationRun continues only a running run that still has a strong native thread, and this PR already records that no Codex thread has been continued (#264). That work stays dead.

On bestia the updater waits until its busy count is 0 twice, so the threads in the original snapshot are idle before the stop. The threads it can still cut are ones that become busy during tar and systemctl stop, after that second sample. Those ids are absent from the snapshot, so the same sentence leaves them unwoken.

Waiting threads are why the snapshot exists: reconcile overwrites status to cancelled, and a waiting run's provider turn is already settled (only pending or running provider turns are cancelled). Freeze the running thread ids at the quit itself (the Mac job, and the updater just before systemctl stop), or wake a parentless row only when its active attempt's provider turn was cancelled with that run. A list taken before the grace period, or before the bestia build, does not.

Nits

  • "It already got the child's cancelled result" is false when the child was auto-continued. continueRestartedRun dispatches the continuation and then calls recoverDelegatedTask. finalizeAppOwnedSubagent returns without delivering while that continuation run is still non-terminal (delegatedTaskProgress stays working). Leaving the child unwoken is right either way. Waking the parent can make it delegate the same work again.
  • The bestia success line is running <sha>; service <state>, previous runtime in <path>. It starts with running <sha>;. A check that the journal ends with that string never matches, and the once-task reschedules forever.
  • completed_at >= <restart time> has no end. A top-level thread cancelled after the service is back, and present as running in the old snapshot, is woken too. Run the query as soon as the new build is healthy.

@lukemaj

lukemaj commented Oct 14, 2026

Copy link
Copy Markdown
Contributor Author

What: Round 3 independent Sol review found one blocking defect in the referenced post-restart wake procedure.
Why: A Stop request can persist before shutdown cancels the still-live provider turn, so cancelled does not prove that waking it respects user intent.
So what: Exclude runs with a recorded interrupt request from the post-check before approval; the previously reported fixes are otherwise verified.

Reviewed exact PR head ff2e027381f91952f2da424c5762ad8a61d8e23e, full PR diff, and runbook 90ec162d58a4d5dd63762cfc02d9420f606f4936. The local runbook subsequently advanced to 2fa0449, but its four reviewed procedure/script files have no diff from 90ec162.

Blocking finding

P2: The manual post-check can restart work the user explicitly stopped. Location: runbook cavallo/CHROMERIA.md, lines 198-208 and 218-220 (linked by this PR's new AGENTS.md section).

Concrete reachable sequence on a Mac: the pre-check passes for a running Claude/Grok top-level thread; the user presses Stop during the restart job's 30-second delay; Orchestrator.ts:9145-9185 commits a run_interrupt_request and schedules the provider interrupt as an effect, leaving the run/provider turn live until that effect settles. If shutdown cuts that window, ProviderRuntimeRecoveryService.ts cancels the still-live run and its pending/running provider turn. The post-check then selects it, and its unconditional parentless-thread instruction sends Continue where you left off. despite the user's Stop. No later run is needed for this failure.

This is why the server's own RestartContinuation.ts:128-143 explicitly rejects a source run containing run_interrupt_request; checking only r.status = 'cancelled' and pt.status = 'cancelled' omits that guard. The response that user interrupts always end interrupted holds after interrupt settlement, but does not cover this persisted-request window. Add a not exists check for a run_interrupt_request turn item on r.run_id before selecting manual wake candidates. This is a source-proven path; I did not reproduce it by interrupting or restarting the live app. Neither inspected live database currently contained a cancelled-provider-turn run with that request marker.

Verification of earlier responses

  • R1 Sol 1: pre-check prints full tool input without the former truncation, includes every unfinished non-app-owned command/tool/subagent item, and checks provider pendingBackgroundTasks; contract schemas require the subagent origin/child fields used by its exclusion.
  • R1 Sol 2 and R2 Sol 2: distinct deduplicates thread rows; the later-run exclusion uses completion order, a live non-queued run, and ordinal only for equal completion timestamps, matching the server continuation guard and runRanAfter.
  • R1 Grok 1: only parentless results are woken; delegated children remain their coordinator's responsibility.
  • R1 Grok 2 and R2 Grok 1: bestia's scheduled post-check first confirms updater completion; there is no pre-check snapshot restriction; provider-turn cancellation filters out settled waiting turns. Restart bounds derive from bestia's actual service start and the Mac's quitting log.
  • R2 Sol 1: updater's final idle loop counts active runs, unfinished non-app-owned tool items, and provider background tasks. Query failure cannot yield the exact 0 required to pass. Installed bestia updater SHA-256 matches reviewed source: 928d9a86d09b54bef0c782bfce163ef51997250bb3b65d87d04b9062f47ee813.
  • R2 Grok wording/time nits: success wording is now running <sha>; service active ...; bestia uses ActiveEnterTimestamp minus two minutes rather than the empty exit timestamp.

Read-only live proof

Executed both complete SQL blocks with sqlite3 -readonly on bestia and via ssh rocky, all exiting 0. Used bestia threshold 2026-10-14T07:28:14 (service entry 07:30:14Z) and rocky threshold 2026-10-14T06:55:36 (last status=quitting).

  • Bestia pre-check reports active runs including Codex, unfinished commands/tools, and a background-task row, so restart would currently be blocked. Post-check returns one uncontinued Codex child with a parent and four held-queue threads; it therefore calls for no direct top-level wake. The cancelled-live provider counts at the 07:30Z restart are Claude 4, Grok 13, Codex 9, consistent with Restart continuation silently skips some cut turns; Codex threads were never continued #264's latest evidence.
  • Rocky pre-check and post-check both return no rows. Verified the database contains historical runs rather than treating an empty result as proof without checking the source.

No additional nits. No checkout changes, database writes, app restarts, updater launches, restart jobs, or thread wakes were performed.

Review performed by GPT-6.1 Sol, medium reasoning, through the Codex harness in T3 Code.

@lukemaj

lukemaj commented Oct 14, 2026

Copy link
Copy Markdown
Contributor Author

Independent review, round 3, of ff2e027381f91952f2da424c5762ad8a61d8e23e. Verdict: success. No blocking finding.

Checked AGENTS.md in the PR diff, recovery and continuation at that SHA, and the runbook at 90ec162 (the restart text this round was asked to verify). While this review was running the runbook clone moved to 429450c; the only change to the restart check is an extra run_interrupt_request exclusion, which matches continueRestartedRun and drops none of the turns below. Nothing was restarted, and the database was opened with sqlite3 -readonly.

Round 2

  • Sol 1, cleared. bestia/scripts/chromeria-server-update at 90ec162 counts active runs, unfinished non-app-owned command_execution / dynamic_tool / subagent rows, and pendingBackgroundTasks. A failing query becomes 1 (|| echo 1), so the idle loop does not proceed. The installed ~/.local/bin/chromeria-server-update matches that file byte for byte; its SHA-256 starts 928d9a86d09b. A bad query on the live database returns 1.
  • Sol 2, cleared. The later-turn predicate is a non-queued run that is unfinished or completed later, with ordinal only when completed_at ties. That is runRanAfter in packages/shared/src/orchestrationV2ThreadError.ts. Every stored completed_at is a 24-character ISO string (bestia 323, rocky 2745), so the string compare matches time.
  • Grok 1, cleared. The pre-check snapshot is no longer a wake filter. The post-check keeps a cancelled run only when its active attempt has a provider turn in cancelled. ProviderRuntimeRecoveryService.ts writes that status only for a pending or running turn, and it is the only writer of provider-turn cancelled. A user stop settles the run and the provider turn as interrupted (settleInterruptedRun). On bestia's 07:30Z restart the predicate is the issue Restart continuation silently skips some cut turns; Codex threads were never continued #264 census before the later-turn filter: Claude 4, Grok 13, Codex 9, all with completed_at from 2026-10-14T07:30:18.543Z to 07:30:20.028Z. After the later-turn filter one row remains, the Codex child named in Restart continuation silently skips some cut turns; Codex threads were never continued #264, and it has a parent, so the wake rule leaves it. No attempt in either database has two provider turns, so the active-attempt join is not mixing an old cancelled turn with a settled one.
  • Nits, cleared. The updater's last line is running <sha>; service <is-active>, previous runtime in <path>, and the bestia page now looks for running <sha>; service active .... ActiveExitTimestamp is empty; ActiveEnterTimestamp is 2026-10-14 09:30:14 CEST, and the documented date -u -d prints 2026-10-14T07:28:14, which includes the cancel cluster. TimeoutStopUSec is 1min 30s. There is no upper bound, and on this database that does not add wakes: a provider turn becomes cancelled only in recovery, and a later turn is excluded.

Proof

Bestia, exact pre-check: it runs, and one snapshot was 20 run rows, 9 work rows, 1 background row (the machine was busy, so the counts moved between queries). The gate total was 35 when the run, work, and background counts were 22, 12, and 1. Twenty-two open app-owned subagent rows were excluded. Exact post-check at 2026-10-14T07:28:14: one not continued row, a child, and four held queues, the same four #264 reported. None of the 26 cut turns has a run_interrupt_request.

Rocky via ssh rocky, exact checks: 0 run, 0 work, 0 background. Post-check using the last status=quitting stamp 2026-10-14T06:55:36 (the log line is <stamp>Z status=quitting, and the page drops the Z): no not continued rows, no held queues. Cancelled provider turns on rocky all belong to cancelled runs and all fall before that stamp.

Nit

cavallo/CHROMERIA.md still says the coordinator already got the child's cancelled result. That is true when continuation was skipped. When the child was auto-continued, recoverDelegatedTask does not deliver while that continuation run is non-terminal. Leaving the child unwoken is still right.

Elon record

Requirements and who asked: User: read-only round 3 of this exact head; confirm the runbook fixes for the round 2 findings.
Deleted: No checkout, restart, updater, or database write.
Bottleneck: The post-check has to name the turns that were live at the stop and still have no later turn.
Checked myself: Recovery and runRanAfter at the PR SHA, runbook 90ec162, installed updater hash, read-only SQL on bestia and rocky, and the 07:30Z census against #264.

@lukemaj

lukemaj commented Oct 14, 2026

Copy link
Copy Markdown
Contributor Author

What: Round 4 independent review passes at ff2e027381f91952f2da424c5762ad8a61d8e23e, with no blocking findings.
Why: Runbook d65a8f0 excludes Stop-requested runs using the same run ID and run_interrupt_request predicate as the server.
So what: The prior R3 P2 is cleared; the coordinator can proceed through the remaining merge gates.

Reviewed the complete PR diff and the requested runbook files at d65a8f0, without checking out or editing either working tree.

  • R3 fix verified: apps/server/src/orchestration-v2/RestartContinuation.ts:128-143 rejects a source run when any turn item for that run has type run_interrupt_request, regardless of item status. The new SQL NOT EXISTS has the same semantics. The existing test at RestartContinuation.test.ts:703-710 covers that server condition; inspected, not executed.
  • Net diff verified: git -C ~/dev/runbook diff 90ec162 d65a8f0 -- cavallo/CHROMERIA.md contains only the three-line exclusion. git diff 8e020cf^ 30b26fe is empty, confirming the accidental commit was exactly reverted.
  • Live SQL proof, 2026-10-14: Extracted the post-check SQL directly from git show d65a8f0:cavallo/CHROMERIA.md, substituted each machine's documented restart threshold, and ran it with sqlite3 -readonly; rocky through ssh rocky. Both exited 0 without SQL errors. Bestia threshold 2026-10-14T07:28:14: one not continued row, a delegated child, and four held-queue rows. Rocky threshold 2026-10-14T06:55:36: no rows. No top-level wake candidate appeared. Thread identities and titles are omitted from this public record.
  • Proof limit: Current live candidates were unchanged by the exclusion (bestia 1 before/after; rocky 0 before/after), so the live check proves compatibility with both databases, while the Stop-case correction is verified against the exact server predicate. No restart, updater, restart job, thread wake, or live-state write was performed.
  • Other checks: The later-run SQL matches runRanAfter; recovery cancels pending/running provider turns; skipped delegated continuations flow through recoverDelegatedTask. The bestia updater retains its active-run, unfinished-tool-work, and background-task idle gate. No remaining blocking defect or new nit found in this review scope.

Elon record

  • Requirements and who asked: User's round 4 brief: independently verify the Stop exclusion, run both post-checks read-only, and report blocking defects.
  • Deleted: No new implementation or repeated restart experiment was needed.
  • Bottleneck: Correctly excluding user-stopped work from manual continuation.
  • Checked myself: Exact PR head/diff, committed runbook files and net diff, restart/recovery code and existing Stop test, both live read-only SQL queries.

Reviewed by GPT-6.1 Sol, medium effort, through the Codex harness in T3 Code.

@lukemaj

lukemaj commented Oct 14, 2026

Copy link
Copy Markdown
Contributor Author

What: Ready except one red check: Test Server 6 fails on OrchestratorMcpToolkit.integration.test.ts ("continuation offers ... length of 1 but got 2").
Why: That test also fails on main itself (CI runs 38524585625 at the base 614c13f, 38531256583 at a68e394). It is #259, with its fix open in #278. This PR only changes AGENTS.md. A rerun of the failed jobs failed the same way.
So what: Once #278 merges, update this branch from main and rerun the Sol and Grok reviews on the new head, then merge. Until then it stays unmerged.

State at head ff2e027: review/independent-sol success (round 4), review/independent-grok success (round 3), mergeable. Runbook side is live at lukemaj/runbook d65a8f0.

@lukemaj
lukemaj force-pushed the main branch 3 times, most recently from ae8eb24 to d275565 Compare October 18, 2026 18:19
@lukemaj

lukemaj commented Oct 19, 2026

Copy link
Copy Markdown
Contributor Author

User decision (2026-10-19, relayed in chat), to apply when this rule is refreshed onto main:

  • Agents may stage merged Chromeria builds on any machine without asking.
  • cavallo first: the user quits Chromeria themselves, the staged build swaps in on quit, and the user confirms it works. Agents never trigger the cavallo swap.
  • Only after the user confirms cavallo may agents swap rocky, then bestia, with a smoke test after each swap (open a thread, load a page in the preview browser) and rollback on failure.
  • Reason: build f31c797704 passed the health checks with a dead preview browser (fix(desktop): preview browser loads no pages after #470 #524), so health checks alone are not a gate.
  • The in-app "Update" button installs upstream pingdotgg/t3code releases, not Chromeria builds, so it is not the propagation path.

@lukemaj
lukemaj force-pushed the main branch 11 times, most recently from 1f3073e to 6262854 Compare November 12, 2026 11:39
@lukemaj
lukemaj force-pushed the main branch 2 times, most recently from 29650cc to 3dba01b Compare November 14, 2026 02:13
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lukemaj and others added 2 commits November 14, 2026 19:43
…runbook page

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…owns its checks

The rule moves into Pull requests beside the merge authority, drops the
#264 claim (fixed by #301) and the held-queue claim, and points at the
runbook for the restart tool, checks, retention and records.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lukemaj
lukemaj force-pushed the docs/staging-restart-rule branch from ff2e027 to 2ac81b9 Compare November 14, 2026 18:47
@lukemaj

lukemaj commented Nov 14, 2026

Copy link
Copy Markdown
Contributor Author

Independent review (review/independent) at 2ac81b9: APPROVE, no blocking findings.

The new bullet (AGENTS.md:171) limits authority to merged main, requires reading the runbooks and passing the pre-check, keeps the adjacent merge gates and the deployment authority boundary in docs/fork.md:213, and leaves the procedure and retention ownership (runbook shared/CHROMERIA-DEPLOY-RETENTION.md) with the runbook. Against base 29b14db only AGENTS.md changes; it is registered in scripts/fork-upstream-edits.txt:11 and fork-check passed.

Reviewer: Codex gpt-6.1-sol (high), delegated read-only via T3 Code.

@lukemaj

lukemaj commented Nov 14, 2026

Copy link
Copy Markdown
Contributor Author

Agent work on this PR

Estimated cost at least $1.55 · 377 responses · 540 sessions · 756.7 h wall time

Model Responses Tokens Estimated cost
grok-4.7 (grok, high) 90 >=284,591,606 (lower bound) unknown
grok-4.7 (grok, xhigh) 77 >=269,389,199 (lower bound) unknown
grok-4.7 (grok, medium) 104 >=165,878,503 (lower bound) unknown
muse-spark-1.3-contributor (opencode, xhigh) 63 6,322,334 unknown
claude-opus-5-5 (claude, medium) 14 2,850,548 $0.89
gpt-6.1-sol (codex, medium) 29 1,876,056 $0.66

Flags: 75 human corrections · 284 large tool outputs · 10 permission requests · 187 repeated commands · 24 repeated failures · 2,082 repeated reads · 239 repeated skill loads · 2 tests edited after a failure · 19 sessions without usage records · 77 worker sessions without an owner · 334 unpriced responses

Details: snapshot, prices, coverage, counters
  • Task toolboxmd/chromeria#265: outcome unknown (recorded acceptance only; a finished process never implies it).
  • Proof: docs: agents may stage and restart merged Chromeria builds #265
  • Snapshot a239a90388053b33a80db205de4d1c194f42b6f59df365bd50a3d0b93cb3a436, records up to 2026-11-14 18:50 UTC.
  • 540 sessions on claude, codex, grok, muse, opencode; AgentsMD 17.1.1, 17.4.6.
  • The total includes work shared with 58 other tasks, counted whole in each, so sums across PRs overlap.
  • Not counted: 18,335 responses (at least $1,127.78) in sessions shared with other PRs that worked in no single PR's checkout.
  • 6,324 responses in these sessions worked on other PRs and are counted there.
  • Totals reconcile with the measured sessions: yes. Evidence complete: no.
  • Prices: list-price estimate from T3 local rate table (path withheld) as of 2026-11-08, schedule 41ee98103a7e65eabaf3a4bf10d10256c167880d7f9bbfbb8aa5f81e64a128ea. Unknown prices stay unknown, never zero.
    • T3 LiteLLM rate table when present; bundled schedule covers the rest.
    • Model price sources: T3 local rate table (path withheld).
    • Unpriced: unknown model (334).
  • Native session usage or worker ownership is unavailable.
  • Harness-reported cost (separate from the estimate): $0.106724 over 63 responses; 314 responses report none.
  • Usage totals are not billing. Subscription spending is separate and is never posted as spend.
  • Crashed runs are counted separately: 0.

Token counters by model (native counter semantics; never added across semantics):

  • grok-4.7 (grok, high), grok counters: input includes cached, output includes reasoning: input >=281,493,956 (lower bound); cache-read >=268,601,472 (lower bound); cache-write >=0 (lower bound); output >=3,097,650 (lower bound); reasoning >=2,468,319 (lower bound); harness total >=284,591,606 (lower bound).
  • grok-4.7 (grok, xhigh), grok counters: input includes cached, output includes reasoning: input >=266,752,991 (lower bound); cache-read >=254,767,744 (lower bound); cache-write >=0 (lower bound); output >=2,636,208 (lower bound); reasoning >=1,946,645 (lower bound); harness total >=269,389,199 (lower bound).
  • grok-4.7 (grok, medium), grok counters: input includes cached, output includes reasoning: input >=164,551,274 (lower bound); cache-read >=155,332,992 (lower bound); cache-write >=0 (lower bound); output >=1,327,229 (lower bound); reasoning >=903,778 (lower bound); harness total >=165,878,503 (lower bound).
  • muse-spark-1.3-contributor (opencode, xhigh), opencode counters: input excludes cache, reasoning separate: input 902,636; cache-read 5,391,311; cache-write 0; output 13,871; reasoning 14,516; harness total 6,322,334.
  • claude-opus-5-5 (claude, medium), claude counters: input excludes cache, output includes thinking: input 28; cache-read 2,821,656; cache-write 21,023; output 7,841; reasoning 2,733; harness total 2,850,548.
  • gpt-6.1-sol (codex, medium), codex counters: input includes cached, output includes reasoning: input 1,861,636; cache-read 1,688,320; cache-write 0; output 14,420; reasoning 2,144; harness total 1,876,056.

Generated tokens (reasoning and other output are disjoint; other output includes code, tool calls and replies):

Model Reasoning Other output Reasoning share Split known for
grok-4.7 (grok, high) unknown unknown unknown 0 of 90
grok-4.7 (grok, xhigh) unknown unknown unknown 0 of 77
grok-4.7 (grok, medium) unknown unknown unknown 0 of 104
muse-spark-1.3-contributor (opencode, xhigh) 14,516 13,871 51.1% 63 of 63
claude-opus-5-5 (claude, medium) 2,733 5,108 34.9% 14 of 14
gpt-6.1-sol (codex, medium) 2,144 12,276 14.9% 29 of 29

Usage by work phase (this task's own responses):

Phase Model Responses Input Cache read Cache write Output Reasoning Total Priced part
unclassified claude-opus-5-5 (claude, medium) 14 28 2,821,656 21,023 7,841 2,733 2,850,548 $0.889447
unclassified gpt-6.1-sol (codex, medium) 29 1,861,636 1,688,320 0 14,420 2,144 1,876,056 $0.659664

Recorded activity by phase (observations, not separate token bills):

Phase Tool calls MCP results Reads Skill invocations File changes Failed tool results
unclassified 49 8 1 unavailable 0 4

Selected rates (USD per million tokens). These rates value the report at the selected schedule date; they do not establish historical prices or subscription spending.

Model Input tier Input Cache read Cache write Other output Reasoning
claude-opus-5-5 all 4 0.2 5m: 5; 1h: 8 20 20
gpt-6.1-sol all 2 0.1 2.5 10 10
grok-4.7 all unknown unknown unknown unknown unknown
muse-spark-1.3-contributor all unknown unknown unknown unknown unknown

Other output and reasoning are priced without double counting inclusive native output. Missing rates remain unknown.

Local measurement from native records; usage totals are not billing. Updated in place by agent-observer publish.

@lukemaj
lukemaj merged commit 49b225c into main Nov 14, 2026
24 checks passed
@lukemaj
lukemaj deleted the docs/staging-restart-rule branch November 14, 2026 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant