This repo was one of two deliberately excluded from the fleet rollout, because
its copy of auto-merge-sweep.sh carried something the canonical did not: the
DEPLOY RECONCILER. Converting before that landed would have let merges reach
main and never reach the box — the exact failure the reconciler exists to
prevent, and one this repo has already had (2026-08-05: three PRs merged, main
green, zero Deploy runs created).
That reconciler is now in the canonical (maonakamoto/dotfiles), generalised
behind DEPLOY_WORKFLOW and off by default, so this file enables it explicitly
with `deploy_workflow: deploy.yml`. Removing that input makes merges land and
never ship.
Verified before deleting the local copy: diffed it against the canonical and
accounted for every line that differs. All 36 non-comment differences are the
`main_*` vs `base_*` variable naming for identical logic, the reconciler now
absorbed, and a hardcoded ci.yml re-arm the canonical does via REARM_WORKFLOWS.
Nothing unique is lost. That check is not ceremony — the first attempt at
choosing a canonical picked the LONGEST variant, which turned out to be missing
features ten repos depended on.
Also repointed two references that would have become lies the moment the file
was deleted: CLAUDE.md and deploy.yml both told the reader the policy lived at
scripts/ci/auto-merge-sweep.sh. They now say where it actually lives, and that a
fix made here would reach nobody.
Fleet duplication: 9 copies -> 8.
Co-authored-by: t <t@t.t>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Merge→live measured 14–27 minutes. The irreducible work in that window is
about 80 seconds: build 66s, rsync 4s, restart 4s, verify 7s. Nearly all
of the rest was waiting, so nearly all of the fix is removing waits
rather than making anything faster.
Two waits, measured:
1. The runner drain, 480 of the ship step's 570 seconds. The deploy
watched one in-flight agent, then restarted anyway at the cap. The
web app had been live and verified for eight of those minutes. Two
systems with opposite needs were sharing one job's wall-clock — the
app wants to be live now, the runner wants to not kill anyone's work
— and the runner won every time.
A shorter timeout would only kill agents sooner. The wait itself is
fine; the place it happened is what cost. Waiting is expensive in CI
and free on the box, so it now happens on the box: the deploy
schedules a detached systemd-run unit and returns as soon as the app
is verified. The drain gets *longer* (1800s, not 480) and cheaper at
the same time, because nothing is holding a runner open for it.
2. The CD reconciler, up to 10 minutes and 18.6 of #284's 26.8. Deploy
chains off CI via workflow_run, which never fires for a CI run that
GITHUB_TOKEN started — i.e. for every auto-merged PR, the only path
that merges code here. The sweep covered that by reconciling on its
next tick: correct, self-healing, and late.
A dispatch is not a push, so it is not subject to the no-cascade
rule. ci.yml now dispatches Deploy itself the moment main goes green.
The sweep keeps its reconciler as the safety net, which is the right
shape for "did something get missed?" and the wrong one for "did
something just happen?".
Also caches .next/cache across deploys — the build is the one part of
this that is genuinely work, so it is the one part worth shrinking.
Not done, and worth saying: I thought CI and Deploy each built the app,
so the tested artifact was never the shipped one. That was wrong. ci.yml
deliberately skips `next build` because App-Router pages query Postgres
during pre-render; the build happens once, in Deploy. There was no
discarded build and no artifact to pass.
The decoupling has a test, and it asserts the property rather than the
patch: the deploy must not block on a drain, the restart must be
detached, the script must be shipped before it is invoked, and the drain
must stay bounded. Verified the first two assertions fail against the
previous version (4 blocking markers, 0 systemd-run) rather than merely
passing against this one.
Co-authored-by: t <t@t.t>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Production was rolled back today and self-healed before anyone looked.
CI shipped main at 09:47 and verified it live at 09:48 — the deploy log
says "live build is fe9395b950 — the commit this deploy shipped". Ten
minutes later /opt/fleetcrown/app was overwritten with a tree ~25
commits old, and for the next ten minutes production served the
previous day's code, including a health endpoint too old to report
which commit it was running. The next unrelated deploy quietly put main
back.
check-deploy-ref.sh was supposed to have ended this class, and it
cannot: it asks "are you on main?", which every commit that ever landed
on main answers yes to, forever. A checkout sitting on last week's main
walks straight through it. The build-ref marker added in #279 makes the
damage visible after the fact, which is how this was found, but nothing
made it impossible.
So gate on the direction of the move instead of the name of the branch:
the commit currently live must be an ANCESTOR of the commit being
shipped, i.e. a deploy may only ever add history. An older commit, or a
sideways jump onto unrelated history, is refused with the two subjects
printed and the fix spelled out. ALLOW_ROLLBACK=1 is the override, so a
deliberate rollback is one word, not a workaround.
Undecidable cases warn and allow on purpose — no marker on the box, a
SHA this checkout has not fetched. This gate must never be the reason a
box that is already broken cannot be repaired.
The gate is its own script rather than a branch inside deploy-hetzner.sh
so it can be tested without deploying anything: ten cases over throwaway
git repos, covering the exact regression, the fast-forward it must not
slow down, the override, and every undecidable path.
Co-authored-by: t <t@t.t>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
* fix(loki,deploy): the approval queue survives a Groq outage; deploys can't ship off-main
"What is pending for approval?" answered "Not in your data." in production while
drafts were waiting. Two independent causes, both fixed here.
1. A hand-run deploy shipped a feature branch to the box — twice, minutes
apart — rotating the correct CI build out through app.prev and reverting
three merged PRs. Prod served a Loki with no approval-queue tool while main
had shipped it hours earlier. The symptom was indistinguishable from an
application bug and was chased through the app first.
scripts/ci/check-deploy-ref.sh now refuses any deploy whose commit is not
contained in origin/main, naming both the unreviewed commits and the ones it
would roll back. Override is explicit and announces itself. deploy-hetzner.sh
calls it before the schema step, so a refusal leaves the box untouched.
The existing --ref guard only ever covered HEAD drift DURING a build; this is
the invariant that was missing. Second occurrence of this class — see the
comment it replaces.
2. Even on the right build the answer was wrong, because the queue was reachable
ONLY by tool call. Groq's org-wide TPM window is exhausted: both the 70B and
the 8B step-down 429 on every call, the bounded retry expires, the tool loop
dies, and Loki answers from seed facts on a TOOLLESS fallback model — which
cannot see a tool-only table, so it truthfully reports nothing.
pendingApprovalFacts() moves to sources.ts and is seeded into the grounded
context on an approval cue, so the question is answerable with the tool loop
entirely unavailable. The tool now calls the same function: one definition,
both paths. Approvals lead the fact list — the seed is head-sliced, so the
subject of the turn must not sit in the tail.
Tests: deploy-ref-gate.sh (7) covers the incident shape directly — an off-main
branch is refused, an ancestor of main is not. approval-cues.ts (24) pins the
cue against the operator's real phrasings, including the typo from the report,
because a missed cue is silent and reads as a truthful "nothing is pending".
Also folds the duplicated dateLabel (handlers.ts + an inline copy in sources.ts)
into one exported helper.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* fix(loki): drop the now-unused getPendingActions import
The tool handler delegates to pendingApprovalFacts, so the direct query import
is dead. tsc does not flag unused imports; eslint does.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: test <test@test>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
A red base branch blocks merges — correctly. But when the PR that repairs
the base is itself in the queue, the guard blocks the fix for the thing it
is blocking on, and neither side can ever move.
Observed 2026-08-07 on aoz-housing: a green PR fixing master's E2E seed sat
while sweep after sweep exited 0 on "refusing to merge onto a broken base".
Every run reported success, so the automation looked healthy and idle rather
than permanently stuck. Four commits went undeployed for ~16h behind it.
This is the third time in this fleet that a permanent stall has been
indistinguishable from an ordinary skip, so fix the class, not the instance:
keep the guard (never merge onto a broken base — that is load-bearing) and
make the stall loud instead. When the base is red, list the open, non-draft,
CLEAN, unheld PRs that cannot land and say how to unstick it.
Breaking the tie stays a deliberate call; only its invisibility is removed.
Co-authored-by: test <test@test>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
`gh pr list` returns newest-first, and the sweep merges the first eligible
PR and stops. So the newest green PR won every sweep, and an older one could
wait indefinitely.
Not theoretical — observed today. Consecutive sweeps merged #181 and #180
while #155 (green since this morning), #176 and #178 sat untouched and were
never even evaluated, because the loop breaks after the first merge. With
several agent sessions opening PRs continuously, "newest wins" is
starvation. It also starves exactly the wrong PR: the one that has been
waiting longest is the one whose checks were proven against the most
now-stale main.
PR numbers increase monotonically with creation, so sorting by number
ascending is FIFO. The ordering was never a decision — it was whatever gh
happened to return — so make it one, and say so in the header comment next
to the one-car-per-sweep rule it belongs with.
Co-authored-by: test <test@test>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
* fix(system): box capacity specs must not wrap under the status word
Caught rendering prod /system at 320px: the upgrade-target row was a single
baseline-aligned flex row, so the spec text wrapped beneath the "blocked"
badge — "…160" on one line, "GB disk" orphaned on the next, reading as two
unrelated fragments.
Narrow screens now put the spec line on its own full-width row (order-3 +
w-full) with the status pushed right beside the type name; sm+ keeps the
original single-line layout. Layout utilities only — no new tokens.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* fix(cd): auto-merged PRs must actually reach the box
Three PRs merged onto a green main today and none of them deployed. The
re-arm looked healthy because CI itself ran — but GitHub does not emit a
`workflow_run` event for a run that GITHUB_TOKEN started, so Deploy never
chained off the dispatched CI. Every auto-merged commit was landing
merged-but-not-live, silently. Only #164 shipped, because a human token
pushed it.
A chain cannot fix this, because the link GitHub refuses to create is the
chain itself. So deployment becomes a reconciler: each sweep compares main's
tip against the last successful Deploy and dispatches deploy.yml directly
when they differ. Self-healing by construction — a deploy that never fired,
or fired and failed, is retried next sweep instead of needing a human to
notice. It only ever runs against a tip whose own CI is green, which the
guard above it already established, and it stands down while a deploy is in
flight.
deploy.yml gains workflow_dispatch (and an if/checkout that handle both
entry points — `ref:` must not fall through to an empty string, which would
silently ship the default branch).
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
---------
Co-authored-by: test <test@test>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Nobody is in the merge loop. The owner does not review PRs, and background-job
agent sessions are barred from merging by hand — so a verified, ready change
had no way to reach main without a manual step that nobody wants to take.
Move the policy into the repo, where it is visible, revocable, and applies
uniformly to every PR: a non-draft PR with every check green and no hold label
gets squash-merged, then CI is dispatched on main so Deploy ships it.
Two design points that are load-bearing, ported from OrangeCat's live run:
- One PR per sweep, only onto a green main. A PR's checks prove it against the
main it branched from, not against the other queued PRs — batching would put
an untested combination on main.
- Explicit `gh workflow run ci.yml --ref main` after a merge. A push made with
the default GITHUB_TOKEN does not trigger workflows, and Deploy chains off CI
via workflow_run, so without it every automated merge lands and silently
never deploys. ci.yml gains workflow_dispatch for exactly this.
Mergeability is polled rather than read once: GitHub computes it lazily and
invalidates it whenever the base moves, so the fast path always sees UNKNOWN
on its first look. Cancelled checks are re-run rather than read as failures —
ci.yml uses cancel-in-progress, so an unrelated push can strand a PR forever.
Hold work back with a draft PR or a hold label. Corollary, now documented in
CLAUDE.md: never open a non-draft PR you would not want deployed.
Co-authored-by: test <test@test>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>