Commit Graph
5 Commits
Author SHA1 Message Date
CatoandClaude Opus 5 28fc7de4ae fix(deploy-freshness): cross-check a stale verdict here too, from one definition (#95)
I put the commit-index cross-check in the reconciler only, reasoning that a
wrong STALE there costs a real deploy while this gate merely reports. That was
the wrong call, and it took about an hour to prove: the first audit run after
the aoz rename went RED on evig, whose tip had a successful deploy-selfhost.yml
run sitting in `actions/runs?head_sha=...` the entire time.

A gate that cries wolf gets muted, and this one guards the single mechanism
between "merged" and "live". "It only reports" is not a reason to tolerate a
false positive in it — reporting is the whole job.

So `deployedByShaIndex` and `runsForSha` move OUT of the reconciler and into
this module, and the reconciler imports them. One definition, not two: the
thing that reports a stall and the thing that repairs one already share
deployFreshness, and splitting the confirmation across both files is exactly
the drift those imports exist to prevent. Their eight assertions move with them.

The audit now asks the commit index before calling anything stale, and says
which index answered when they disagree.

Live run after the change: 21 repos, all deployed, exit 0 — evig included.
Worth being precise: evig resolved through the NORMAL path this time, because
the flake is intermittent, so this run did not exercise the new branch. What
covers it is the moved unit tests and the reconciler's own evig incident.

33 + 25 assertions, none lost in the move (was 24 + 34).


Claude-Session: https://claude.ai/code/session_01NLZ6vs1jsWw2kKbpWTZHf2

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-15 06:46:45 -07:00
CatoandClaude Opus 5 ad9b7f57b0 fix(reconciler): confirm against a different index, not the same flaky one twice (#92)
The reconciler dispatched a real, redundant deploy of a repo that was already
live. The box timer's second tick ran it for real, it decided evig was stale,
and it shipped `deploy-selfhost.yml @ main (e2c67d8)` — a tip that had TWO
successful deploys at 05:42:17 that morning, for that exact SHA.

No harm done: the run shipped the identical commit and evig stayed up. But left
running it would have re-fired every fifteen minutes.

I had already seen this flake on datacat and had already added a guard for it,
and the guard was the wrong shape. `actions/workflows/{file}/runs?branch=main`
intermittently returns a page that omits its own newest runs — datacat twice and
evig once inside ninety minutes, each confirmed by a direct probe moments later
returning exactly the runs that had been missing. My guard re-read THE SAME
ENDPOINT. Reading a flaky endpoint twice mostly gives you the same flake twice;
that is repetition, not independent evidence, and I should have seen it when I
wrote it.

`actions/runs?head_sha=<sha>` is a different index — keyed by commit rather than
by workflow and branch — and answers the question actually being asked: has this
commit had a successful deploy run? On evig's tip it returned the
deploy-selfhost.yml success the other endpoint had just denied. confirmedStale
now consults it first, matching runs by workflow path basename so a green CI run
is never mistaken for a deploy.

34 assertions, 4 mutants killed: counting any successful run as a deploy,
accepting a non-success conclusion, accepting a run still in flight, and making
the confirmation inert.

The third is worth recording. My first version of that assertion SURVIVED its
mutation: `status === "completed"` was never exercised, because a non-terminal
run reports `conclusion: null` and failed the conclusion check anyway — an
untested branch that looked covered. It now uses a run that is unfinished but
already claims success, which is the anomaly the check exists for.


Claude-Session: https://claude.ai/code/session_01NLZ6vs1jsWw2kKbpWTZHf2

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-15 05:52:49 -07:00
CatoandClaude Opus 5 5bbdd66625 feat(reconciler): re-run CI for a tip that can never go green (#89)
* fix(reconciler): make a stale verdict survive being asked twice

Two dry runs twenty-five minutes apart disagreed about datacat. The second
called it STALE and would have dispatched a deploy; the same code path, re-run
immediately afterwards against the same unchanged tip, said DEPLOYED — and the
tip did have a successful Deploy run for its exact SHA, from 05:22 that
morning. Nothing about the repo changed across the three reads.

The likeliest mechanism is the one behind every other bug in these two files:
`actions/workflows/{file}/runs` is eventually consistent, and a reply from a
lagging replica that omits the newest run is indistinguishable from a repo that
never deployed. A window is not an absence; neither is a stale replica.

A wrong STALE is not a wrong report here — it is a redundant deploy of a repo
that is already live, which on a client site is a real production event
triggered by a phantom. So the verdict is re-read immediately before acting and
must still be STALE. Two reads is not a proof, since a replica can lag twice,
but it converts a common transient into a rare one for one API call per repo
actually being shipped. A re-check that cannot be read is not a confirmation
and so is not a deploy.

Dry run after the change: 21 surveyed, 0 to ship, datacat no longer flagged.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NLZ6vs1jsWw2kKbpWTZHf2

* feat(reconciler): re-run CI for a tip that can never go green

loki today: concurrency cancelled BOTH CI runs for main's tip, so all SIX of
its Deploy runs `skipped` — the chained trigger requires
`workflow_run.conclusion == 'success'`, and that green run could never appear,
because nothing in the fleet re-runs a cancelled CI. The tip sat unshipped for
over two hours and would have sat there indefinitely.

shouldDispatch refuses to deploy that, and the refusal is right: shipping an
unverified tip to clear a stalled deploy turns a stall into a bad release. But
refusing is not repairing. A reconciler that only ever declines leaves the repo
exactly as stuck as it found it.

Re-running CI is the remedy that matches the fault, and it is a categorically
cheaper action than deploying: it publishes nothing, changes nothing on the box,
and is idempotent. If it goes green the ordinary chain ships the tip; if it goes
red, the tip SHOULD be stuck and now says so out loud.

It fires only on the no-green-run case. Not on a RED tip — a broken build is not
repaired by running it again, and retrying red every half hour is a CI
amplifier, not a fix. Not while a run is in flight. Not on a repo that is live
or still inside the window. Capped at 3, deliberately tighter than the deploy
cap of 5: a stalled deploy is self-limiting, an org-wide CI re-run loop is not.

The CI workflow filename is discovered per repo (ci.yml, else the workflow whose
`name:` is CI) rather than assumed — hardcoding it would silently re-run nothing
in the repos that spell it differently, the same shape as hardcoding `main` as
the default branch, which reported two repos as never deployed.

25 assertions, 4 mutants killed: re-running a red tip, ignoring the in-flight
guard, making the repair inert, and re-running already-deployed repos. The live
path is not exercised by the dry run because no repo is currently stuck that
way — loki was repaired by hand before this existed.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NLZ6vs1jsWw2kKbpWTZHf2

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-15 05:21:53 -07:00
CatoandClaude Opus 5 03d962297c docs(deploy): these are pilots and concepts, not clients (#88)
bitbaum has no clients. `apps.conf`'s `client-app` is a PROVISIONING fact about
how a site was set up, not a commercial relationship: publicly these are Pilots
(real use, no terms) and Concepts (built to apply — SBB, Reparaturbonus).

I wrote "a client site" three times while building the deploy audit and
reconciler, in comments that are the first thing a reader meets. The point
those comments make does not need the word and is not weakened by losing it —
what makes reparaturbonus-zh matter in that story is that real people were
served four hours of stale code, which is true of a concept site too.

No behaviour change.


Claude-Session: https://claude.ai/code/session_01NLZ6vs1jsWw2kKbpWTZHf2

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-15 05:14:17 -07:00
CatoandClaude Opus 5 0d3e5b4010 feat(fleet): one clock for the fleet's deploys (#85)
The reconciler logic is neither missing nor broken. auto-merge-sweep.sh already
compares the base tip against the last successful deploy and closes the gap,
with a green guard and an in-flight guard, and it is already centralised as a
reusable workflow. What is broken is its CLOCK.

Each caller repo supplies its own `schedule:`, so the fleet depends on ~25
independent GitHub crons, and GitHub honours them erratically. Time since each
repo's sweep last ran, measured today against a stated ten-minute cadence:

    loki 19m · evig 151m · reparaturbonus-zh 244m · vitareba 276m

Quiet repos are hit worst, which is exactly backwards — GitHub de-prioritises
schedules on low-activity repos, and a client site nobody pushes to all week is
the definition of low-activity. The repos least likely to have a human watching
are the ones whose clock stops first. reparaturbonus-zh sat merged-but-not-live
for four hours today for precisely that reason: its Deploy lost a timing race
and nothing retried it, while CI stayed green and /api/health returned 200.

So: one schedule, in the most active repo in the org, dispatching deploys only
where they are needed. It does not reimplement the sweep and it does not merge
anything — it closes the merged-but-not-live gap and nothing else.

Staleness comes from the audit's own deployFreshness, imported rather than
re-derived, so the thing that REPORTS a stall and the thing that FIXES one
cannot drift into disagreeing.

What it refuses to do is the load-bearing part:

  - never ships a RED tip, however stale;
  - never ships while a deploy is in flight;
  - never ships a tip whose CI has not finished;
  - never ships a tip with no green CI run at all. That is loki right now —
    concurrency cancelled both its CI runs, so no green run exists for the
    chained deploy to fire on. It needs a CI re-run, not a deploy, and the
    output says so instead of papering over it by shipping something unverified;
  - never ships more than MAX_DISPATCHES (5) in one tick. A reconciler holds a
    deploy button for all 21 repos; a whole fleet going stale at once is far
    likelier to be a bug in the predicate than 21 real stalls, so past the cap
    it reports and ships nothing.

Both decisions that can cause a deploy are pure and tested: 18 assertions, and
5 mutants killed — reading a cancelled CI run as green, dropping the in-flight
guard, shipping a red tip, making the tool inert, and raising the cap above the
fleet size. The workflow proves those guards BEFORE the run that can dispatch.

Dry run is the default; the live survey of all 21 repos dispatched nothing and
correctly held loki back.

Also captures gh's stderr instead of forwarding it: probing 21 repos for a
.github/workflows directory printed eight bare 404s above the report, expected
misses indistinguishable from a real failure and noisy enough to hide one.


Claude-Session: https://claude.ai/code/session_01NLZ6vs1jsWw2kKbpWTZHf2

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-15 04:33:42 -07:00