Commit Graph
6 Commits
Author SHA1 Message Date
CatoandClaude Opus 5.5 31de29870b fix(scripts): grep -q is never the reader of a pipe under pipefail (#140)
* fix(scripts): grep -q is never the reader of a pipe under pipefail

`echo "$x" | grep -q PAT` under `set -o pipefail` can report "not found"
for text that IS there: grep -q exits on its first match and closes the
pipe, the writer takes SIGPIPE (141), and pipefail makes the pipeline
status 141, so an `if` takes the else branch on a successful match.

It is not confined to payloads past the ~4KB pipe buffer. Measured in
loki (loki#874) on a real 1,158-byte output, 3,000 calls: 2/3000 false
misses for a phrase near the top, 0/3000 via a here-string. Rare per
call; a suite makes hundreds. loki's retire-site suite went red on
exactly those phrases twice this week.

48 copies in 14 scripts here, rewritten to `grep -q PAT <<<"$x"`,
including:
- auto-merge-sweep.sh: the required-check coverage test. A false miss
  marks a green job "uncovered".
- gc-merged-worktrees.sh: `in_use`. A false miss reads a live session's
  worktree as unused. The pushed / clean / MERGED guards still stand, so
  it cannot lose work, but it can remove a directory from under a live
  session.
- cicd-hygiene, nav-contract, org-drift, verify-floor audits and
  verify-predicates: false passes and false findings.

Checked: all 14 files pass `bash -n`; every file is a 1:1 line swap (48
lines); the 8 line-continuation sites keep the here-string before the
trailing backslash; fleet's 30 CI test scripts pass before and after
(30/30 -> 30/30); workflows still parse.

Gate: scripts/ci/test-no-grep-q-in-a-pipe.sh, wired into ci.yml. Scans
scripts/ and templates/, self-tests its detector both ways, and was
proven by restoring the original auto-merge-sweep.sh line.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Cato <41178744+catomean@users.noreply.github.com>

* fix(ci): main was red on a ratchet that fell, and a sweep test lied

Two failures on fleet main that were blocking every PR, including this
one. Neither was caused by the grep -q rewrite: main (7ed94a2, the base
of this branch) failed CI on the same step for the same reason.

1. org-drift ratchet fell. `org-drift-audit.sh --check` failed on main
   since c43464d with "baseline entries with no matching violation - the
   ratchet fell: bitbaum/README.md". Good news: someone fixed that drift.
   Nobody lowered the baseline, so main stayed red and the auto-merge
   sweep refused everything. Line removed; --check now passes (44 repos
   swept, 3 known violations, no new contradictions).

2. test-auto-merge-sweep.sh lied. Its verdict `[ "$FAIL" -eq 0 ]` sat at
   line 400 of 473, with ~70 lines of tests appended after it. A bash
   script exits with its LAST command's status, so the verdict was
   discarded: the suite exited 0 while printing "27 passed, 1 failed",
   and its later tests were not even counted. Verdict moved to the end;
   the suite now counts 38.

   The hidden failure was real and was mine: test 13 asserted the sweep
   always "waits for CI to catch up" when the newest base run is for an
   older commit. The deadlock fix changed that - it waits only while a
   run is in flight, and otherwise dispatches CI. Test 13 now asserts
   both cases (13a waits and dispatches nothing; 13b dispatches and does
   not merge). `rearms()` moved above its first use.

Proven by mutation: an injected late failure now fails the suite;
reverting the sweep to always-wait fails 13b; making it never wait fails
13a.

Gate: scripts/ci/test-verdict-is-last.sh, wired into ci.yml, requires
every suite's verdict to be its file's last command. Proven by restoring
the old mid-file verdict. All 34 fleet CI commands are now green, and
none exits 0 while reporting a failure.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Cato <41178744+catomean@users.noreply.github.com>

---------

Signed-off-by: Cato <41178744+catomean@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-24 11:58:34 -07:00
CatoandClaude Fable 5.1 231ad50706 chore: rename FleetCrown to Loki (#65)
The product was renamed on 2026-09-14: bitbaum/loki, loki.orangecat.ch,
LOKI_* env keys, loki-* units. This repo referenced the old name in
38 files changed, 119 insertions(+), 119 deletions(-).
Email addresses at the old sending domain stay until the new domain is
verified in Resend.


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

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-13 16:23:38 -07:00
CatoandClaude Opus 5 c8c0c6077a feat(fleet): make throwaway repos disposable, and point the audits inward (#58)
* feat(fleet): make throwaway repos disposable, and point the audits inward

Six scaffolded repos appeared in two days and nobody created them carelessly —
FleetCrown provisions one per project and agents scaffold sites to test that
path. Together they were 15 of the 26 gaps that were about to turn the
version-currency ratchet red against a committed baseline of 0. That is how a
ratchet dies: not disputed, drowned. A gate whose number is mostly noise gets
muted, and every true finding inside it is muted with it.

The house rule (CLAUDE.md, "Clean up the experiment when the experiment is
over") already says an experiment is torn down in the session that created it,
repo included. This adds the backstop, because that rule covers the session
that creates a repo and nothing covers the session that dies, is interrupted,
or forgets — which is how all six survived.

  scripts/local/prune-ephemeral-repos.sh

A throwaway repo carries the GitHub topic `fleet-ephemeral` from birth: on the
repo, not in a list somebody must remember to update, so a later sweep can find
it without recognising the name. The script lists by default, deletes on
--delete --yes, and refuses anything unmarked — "it is obviously a test repo"
is the reasoning that eventually deletes something real. Deletion is the
intended action, per the house rule; --archive is only a holding position.

Its selector is pinned in both directions on every fixture and its --yes guard
runs through the script itself via an injected repo list, so no assertion is a
re-implementation of the thing it checks. Four mutants were each confirmed to
turn the test red before this shipped: selector ignores the topic, substring
instead of exact match, guard removed, empty result reported silently.

  scripts/ci/shared-registry-audit.mjs

Every audit in this repo sweeps the OTHER repos. None asked whether SHARED.md —
the file whose first line is "check this file, if it is here, install it" —
matches the dependency graph. It did not: bip-kit had eight adopters and no
row. This derives the adopter count from package.json across the org and fails
when a package with 2+ adopters has no registry row. It resolves the npm: and
github: aliases half the fleet installs under, because a key-only reader
reports zero adopters for a package with five, and it counts a row only from
the registry TABLE — bip-kit was mentioned in the prose the whole time, and a
substring search over the file would have called that covered.

It does not judge the content of a row. A gate that guesses at prose gets muted.

  scripts/ci/blessed-versions.json

@bitbaum/ai-kit fell through the seam between `internal_tags` (deleted when it
graduated to npm, correctly) and `majors` (never added — it was 0.x that day).
It shipped 1.0.0 and nothing noticed, because the comment explaining its
absence still described it as a 0.x package. Seven of thirteen consumers sat on
0.x carets while the package was at 1.4.1 and no gate said so. Both it and
design-tokens are now tracked, and the stale exemption is rewritten to say what
actually happened: a version-tracking exemption must be re-read when the
version moves.

  scripts/ci/org-drift-audit.sh

The only org sweep that did not pass --no-archived, so a retired repo still had
its README judged against the org register.

The baseline is raised in the same commit, as the process requires. It covers
real staleness on real repos (causius, diplodoctor, heidi, sbb-fundbuero) plus
the ai-kit gaps that were previously unmeasurable — not the six scaffolds,
which are already deleted.

Known and deliberately not fixed here: version-currency reads only each repo's
ROOT package.json, so kivvi/packages/ai (^0.15.0) and datacat/backend (^0.13.0)
remain invisible to it. Attributing a gap to repo-vs-path changes the report
shape and the fixtures, and folding it in would make this baseline number
un-reviewable.

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

* fix(shared-inventory): one red ratchet must not hide the other

Both reports now run before either ratchet, and each ratchet carries
`!cancelled()`. Without it the first failing check ends the job and the second
never runs — reporting green by absence, which is worse than not having the
gate at all.

This was the live case, not a hypothetical: the duplication ratchet was already
red (ai-provider-client 17 -> 19) when the registry gate was added below it, so
the new gate would have been masked from its first scheduled run.

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-12 10:03:13 -07:00
CatoandClaude Fable 5.1 2a7319f898 feat(org-drift): find documents using a name or host that has been replaced (#43)
* feat(org-drift): find documents using a name or host that has been replaced

A rename that is only remembered is a rename that drifts.

aoz-wohnen.orangecat.ch, revampit.orangecat.ch, sbb.orangecat.ch and
sink.orangecat.ch all answer 200 — every one is a redirect. So a document
naming any of them looks perfectly healthy from the outside, and nothing ever
reports it. All four were found in 2026-09 by tripping over them, including on
the public studio page, which named a real transport company on a demo that has
no connection to it.

That is the same failure this audit already exists for — a document saying
something that is no longer true — so it is the same sweep, not a second script
with its own copy of the exemption and baseline logic.

THE GAP WAS A REGISTER, NOT A SCRIPT

Nothing recorded that a name had been replaced, so no check could have found a
document still using it. registers/retired.json is that record: kind, from, to,
since, why, and how the retirement was VERIFIED rather than who asserted it.
Adding a retirement is a ROW; the script does not change.

Nine entries to start, each confirmed rather than remembered — the four hosts by
following them with curl, "AOZ Housing" against the app's own brand.ts and live
<title>, "SBB Fundbüro" against the title it actually ships, and the two repo
renames against the commits that made them.

Findings say what to use instead and since when. "This document is wrong" costs
a reader a search; "say X instead, since 2026-09-10" costs them an edit.

THE RATCHET

51 files across 7 repos already use a retired form. Baselined with a reason,
not fixed here: one PR touching 51 files in 7 repos would be a worse change than
the drift it removes. Most are one host (revampit). The sbb-fundbuero ones are
worth doing first — a repo still calling itself "SBB Fundbüro" while the site it
ships is titled "Nordbahn Fundbüro".

A TEST THAT DAMAGED THE ARTIFACT IT CHECKED

Found while running the suite: the vacuous-scan case ran the real script without
overriding INVENTORY, so a test whose entire point is "scan nothing" overwrote
the committed 41-repo inventory with "Scanned 0 repos, found 0 violation(s)" —
the tracked record of the fleet's drift, replaced by the output of a
deliberately empty run, every time anyone ran the tests. Redirected to a temp
file. Same shape as the sed range in #42: a check satisfied just as well by a
broken reader as by a clean file.

Verified: 49 passed, 0 failed (13 new). The new cases pin the mechanism, not
live data — a fixture register, so retiring something tomorrow does not break
the suite. Regex metacharacters must be escaped (an unescaped old.example.ch
also matches oldXexampleYch), a name containing '&' must survive the sed
replacement, a clean line must yield no hint, and the register that RECORDS a
retirement must be exempt from it or the ratchet can never reach zero.

Note: this audit is already red on main for pre-existing org-claim violations
("bitbaum AG", incorporation language in four fleetcrown docs). Confirmed by
running the committed version against the same tree; not introduced here, and
not baselined here either — that is a decision about incorporation wording, not
a drift fix.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HVudRzEmLqLHvGNqFSpJq6

* fix(org-drift): baseline the file the API scan found and the local sweep missed

CI caught sbb-fundbuero/CLAUDE.md, which my local USE_LOCAL sweep did not. That
asymmetry is the point of the audit's default: USE_LOCAL greps local checkouts,
which go stale, while the real scan reads the org's default branches. A ratchet
that sees less than production prevents less than it claims.

Also corrects the previous commit message. It said this audit was "already red
on main for pre-existing org-claim violations". It is NOT — that came from the
same misleading local sweep. main's baseline holds three entries and CI was
green before this branch; the only genuinely new finding was the one file above.
The fleetcrown docs mentioning incorporation appear in a local grep because it
walks every docs/*.md, while the API scan reads a narrower set of paths.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HVudRzEmLqLHvGNqFSpJq6

* fix(org-drift): baseline from the API scan, not the local sweep; list the audit in SHARED.md

The baseline is now generated by the instrument that judges it. The previous
commit baselined 51 files from a USE_LOCAL=1 sweep, and CI correctly rejected
44 of them as entries matching nothing production can see — the local sweep
greps every docs/*.md in stale checkouts, while the real scan reads a narrower
set of paths from the org's default branches. A baseline full of unreachable
entries is a ratchet that cannot fall.

Seven real entries remain, in four other repos, each an agent-facing file
(CLAUDE.md / AGENTS.md / README.md) — the worst place for a stale address. The
inventory is committed as the API scan regenerated it: 46 repos, 10 violations.

Also lists org-drift-audit.sh in SHARED.md's central-audits table. It was
missing, which is exactly why a duplicate of it was nearly written today —
the table exists so that "is there already a checker for this?" has an answer.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HVudRzEmLqLHvGNqFSpJq6

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-10 17:22:39 -07:00
918a6d6f0e Use gh API by default, baseline existing violations (#33)
* Use gh API by default, baseline existing violations

- org-drift-audit.sh: Default to GitHub API scan via gh CLI, scans all
  bitbaum org repos. Finds 4 existing violations across 41 repos.
  Local DEV_ROOT scan available via USE_LOCAL=1.

- org-drift.baseline: Baselined 4 existing violations found in first run:
  bitbaum/CLAUDE.md (AI product studio claim)
  bitbaum/README.md (bitbaum AG claim)
  crewless/README.md (door disagreement with apps.conf)
  fleetcrown/README.md (door disagreement with apps.conf)

- org-drift-inventory.txt: Generated inventory showing 41 repos scanned,
  4 violations found. The ratchet now prevents new violations from landing.

First real run complete. The count can only fall.

Co-authored-by: Cato <catomean@users.noreply.github.com>

* Fix test suite for gh API mode

Test now uses USE_LOCAL=1 to test the vacuous-pass check,
since gh API mode connects to GitHub. All 36 tests pass.

Co-authored-by: Cato <catomean@users.noreply.github.com>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Cato <catomean@users.noreply.github.com>
2026-09-09 01:01:27 -07:00
a795806430 Add org register and drift-prevention system (#32)
- registers/org.json: machine-readable register for org facts (publicName,
  legalStatus, houseDomain, host, design, ventures). Agents read this, not
  READMEs. A new claim is a register row or it does not ship.

- scripts/ci/org-drift-audit.sh: check script that scans bitbaum org repos
  for public documents contradicting the register. Forbidden: incorporation
  pending, bitbaum AG, AI product studio as identity, github.io host, legal
  personal name. Validates live doors against apps.conf. Exits non-zero on
  new violations.

- scripts/ci/org-drift-inventory.txt: generated inventory of violations,
  updated by the audit script. A ratchet preventing new lies from landing.

- scripts/ci/org-drift.baseline: baseline for existing violations that
  predate the gate. May fall or hold, may never rise.

- scripts/ci/test-org-drift-audit.sh: test suite (36 checks, no network,
  no checkout). Tests forbidden_patterns, is_public_doc, is_exempt_path,
  baseline_keys, apps.conf parsing.

- README.md: documents the drift-prevention system.

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Cato <catomean@users.noreply.github.com>
2026-09-09 00:30:59 -07:00