Commit Graph
10 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 Opus 5 227fbad30b chore(retired): record aoz-housing -> aoz-begleitung, now that the docs agree (#96)
The last step of the rename, and it had to be last.

The `repo` row makes the old name traceable, and it is also what makes
org-drift-audit.sh police it: from here, any public document on a default
branch that says `aoz-housing` fails the build. That audit judges REMOTE
default branches, so landing the row alongside the doc fixes was unsatisfiable
— it would have judged main, where the docs were not yet fixed, and the fixes
could not merge while it failed. The row is a post-condition on the documents,
not a co-requisite. They are all on their default branches now: fleet#94,
aoz-begleitung#243, loki#732.

It lands with its one baseline exception, and only now, for the mirror-image
reason: without the row nothing flags aoz-begleitung/CLAUDE.md, so an entry for
it would match no violation and org-drift rejects that correctly.

The exception is real, not a shortcut. `JWT_ISSUER` is still the literal
string `aoz-housing` and must stay so — src/proxy.ts and src/lib/auth/config.ts
pass it as the JWT issuer, and changing it invalidates every live session. A
live auth value, not a name.

Checked before opening, with this row in place: org-drift --check swept 45
repos, 5 known violations, no new contradictions, no unmatched baseline entry.


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

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-15 13:34:06 -07:00
CatoandClaude Opus 5 144855dea6 chore(aoz): rename the repo to aoz-begleitung, and record why (#94)
* chore(aoz): rename the repo to aoz-begleitung, and record why

`bitbaum/aoz-housing` is now `bitbaum/aoz-begleitung`. It was the last public
place the product was still called Housing: registers/retired.json retired "AOZ
Housing" as the PRODUCT name on 2026-09-10, but the repo kept it, and the repo
is PUBLIC — so the retired name sat on the org page, in every clone URL, and in
~55 references across this repo alone.

The deploy name `aoz-wohnen` is deliberately NOT renamed with it, and that is the
decision, not an omission. It is an infrastructure identifier — systemd unit,
/opt path, database — and nothing on the box keys on the repo name; renaming it
would touch a live site for no visible gain. Two names now instead of three.

The registers are DERIVED and were regenerated, not hand-edited:
origin.json (aoz's `stamped` and `swh` drop to null, correctly and temporarily —
Software Heritage archived the old origin URL and the OpenTimestamps manifest
names the old repo; the nightly origin-proof re-stamps) and packages.json.

proofs/origin/*.json are untouched on purpose. They are hash-chained and
append-only, so a past proof naming bitbaum/aoz-housing is correct history;
rewriting one would both falsify the record and break the chain.

retired.json gains the `repo` row, which is what makes the old name traceable —
and what makes org-drift-audit.sh start flagging documents that still use it.
Three were flagged: this repo's AGENTS.md (fixed here), the renamed repo's
README (fixed in aoz-begleitung#243) and its CLAUDE.md, which is BASELINED with
a reason rather than fixed: `JWT_ISSUER` is still the literal string
`aoz-housing` and must stay so — src/proxy.ts and src/lib/auth/config.ts pass it
as the JWT issuer, and changing it invalidates every live session. A live auth
value, not a name.

Verified across the rename: bitbaum/aoz-housing redirects to the new repo,
https://aoz.orangecat.ch still 200, aoz-wohnen-app still active, and the new
clone URL resolves to 431bae7 — the same tip as before.

Tests green: deploy-freshness 24, deploy-reconciler 34, repo-metadata 17,
model-pin, version-currency, product-identity 45, verify-predicates 29.

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

* chore(aoz): defer the retired-name row until the docs it polices have landed

org-drift-audit.sh reads the org's DEFAULT BRANCHES, not the working tree. So
adding the `aoz-housing -> aoz-begleitung` row to retired.json in the same PR
that fixes AGENTS.md is a deadlock by construction: the audit judges main, where
AGENTS.md is still unfixed, so `--check` fails — and the fix cannot merge while
it fails.

The row is a POST-condition, not a co-requisite. Fix the documents first, let
them reach the default branches, then declare the name retired and let the audit
hold the line from there. The row returns in its own PR once this and loki#732
are on main.

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

* chore(aoz): the baseline exception belongs with the row that creates it

Same sequencing lesson, mirrored. Without the retired-name row nothing flags
aoz-begleitung/CLAUDE.md, so a baseline entry for it matches no violation — and
org-drift rejects that correctly: "baseline entries with no matching violation —
the ratchet fell". A baseline full of entries that match nothing is a ratchet
that cannot fall, which the file's own header already says.

So the row and its one exception land together, in the PR after this one.

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 06:37:48 -07:00
CatoandClaude Opus 5 55e0976894 Revert(retired): SBB Fundbüro is not retired — it is the pitch (#51)
I added three retirement rows saying the SBB name was replaced by Nordbahn.
That was backwards. The demo is being pitched TO SBB; naming it after the
prospect is the artefact. Left in place, these rows would have made
org-drift-audit flag the SBB name as drift in every future doc — the check
actively fighting the thing it exists to protect.

Removed: sbbfundbuero.orangecat.ch, sbb-fundbuero, "SBB Fundbüro",
"SBB Lost & Found". Also drops the baseline line for the Blick citation, which
named a repo that no longer exists under that name.

KEPT, because they are real and were verified: sbb.orangecat.ch ->
sbbfundbuero.orangecat.ch and sbb-lost-found -> sbb-fundbuero. That earlier
rename was George's own and still holds.

The lesson this file now carries by omission: a retirement is only a fact when
the OWNER has decided. "The README says the name is probably wrong" is not a
decision, especially when the next sentence says the question is open.


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

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-11 06:42:16 -07:00
CatoandClaude Opus 5 3dd9be9980 feat(retired): sbb-fundbuero -> nordbahn-fundbuero, and its host (#49)
The repo, the register key and the public host all carried the name of a real
transport company the demo has no connection to. The site had always titled
itself Nordbahn Fundbüro, on an operator invented on purpose, and the repo's
own Naming section said the working name "is probably the wrong one".

Migrated 2026-09-11, verified at each step:
  repo    bitbaum/sbb-fundbuero -> bitbaum/nordbahn-fundbuero (GitHub redirects)
  host    sbbfundbuero.orangecat.ch -> nordbahn.orangecat.ch (308, method kept)
  register/unit/cron/checkout all moved; port 4016 kept — it has no name in it

One baselined false positive: the only remaining "sbb-fundbuero" is inside a
Blick article URL cited in the provenance table, about SBB's REAL lost-property
office. A literal-string check cannot tell a citation from a claim; that
judgement belongs in the baseline, with its reason.


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

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-11 05:57:18 -07:00
CatoandClaude Fable 5.1 80dc37e517 chore(org-drift): lower the retired-name baseline 10 -> 4; the seven are fixed at source (#45)
sbb-fundbuero #70, evig #474, hirnli #109, aoz-housing #237 — each merged,
deployed and verified live (release symlink on the right SHA, unit active,
200). evig/CLAUDE.md stays, with its reason: it documents that the old host
still resolves and must remain a 308 — the record of the retirement, not an
instance of it.

Gated against the API scan before pushing: 4 known violations, no new
contradictions, no stale entries. The inventory is committed as that scan
regenerated it.


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

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-11 00:07:17 -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
CatoandClaude Opus 5 ff79e556b5 feat(ci): 17 of 24 repos could not report a CVE, and nothing measured that (#39)
* feat(ci): 17 of 24 repos could not report a CVE, and nothing measured that

surf-your-life.orangecat.ch served Next 16.2.3 — two CRITICAL unauthenticated
RCEs — plus a critical @auth/core flaw and six more high findings. Thirteen in
total, on a live site, for months.

Nothing was ignored. Dependabot alerts were simply OFF for that repo, so GitHub
never raised one and there was no number for anyone to act on. The correlation
across the fleet that day was exact:

  botsmann        alerts ON  -> Dependabot PR #193 took it to 16.3.3 on its own
  orangecat       alerts ON  -> its security job went red, which is how this surfaced
  surf-your-life  alerts OFF -> silence, 1 critical + 6 high

17 of 24 repos were off. The instrument was missing, not the diligence.

WHY THE EXISTING SWEEP COULD NOT SEE IT. version-currency.mjs compares MAJORS
parsed out of package.json ranges: parseMajor("^16.2.12") is 16, blessed is 16,
no gap. Every minor and patch is invisible, and it reads the declared RANGE
while the lockfile decides what ships — a caret that ALLOWS 16.3.4 sits on
16.2.12 forever, because an already-satisfied dependency is never upgraded on
install. Both vulnerable pins returned zero gaps from it. That limit is now
written into its own header rather than left to be rediscovered; the two audits
are complements, not overlaps.

A HARD FLOOR, NOT A RATCHET. Its siblings baseline a count because their
findings have legitimate exceptions. This one has none: a repo with alerts off
cannot report a CVE, so the correct number is zero permanently. A baseline here
would only make "some repos are deaf" an accepted state.

THE POPULATION COMES FROM `gh repo list`. Writing this, I first hand-typed the
repo list from `ls ~/dev` — which invented a repo that does not exist
(~/dev/revamp-info is a checkout whose remote points at bitbaum/hirnli) and
MISSED 17 that do, including every shared package (ai-kit, ai-forms, bip-kit,
limitkit, threadkit, design-tokens) that is published to npm and consumed
fleet-wide. Archived repos and forks are excluded, matching version-currency so
both audits measure the same population.

Ten tests, each a mutation: a repo with alerts off must exit 1, an UNREADABLE
repo must exit 1 rather than pass, and an empty repo list must exit 2 rather
than read as a clean fleet.

All 41 repos now have alerts and automated security-fix PRs enabled; the audit
reports 41/41.

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

* chore(ci): the org-drift ratchet fell and its baseline still claimed the violation

`org-drift-audit.sh --check` was failing every PR in this repo — not for
anything in the PR, but because fleetcrown/README.md was fixed and its baseline
line outlived it. The audit is built so that a baseline entry with no matching
violation is itself an error, precisely so the list cannot rot into a claim
about a problem that no longer exists. It did its job; nobody deleted the line.

Unrelated to the Dependabot work on this branch, and separated into its own
commit for that reason. Left alone it blocks everyone.

  46 repos swept, 3 known violations, no new contradictions (was: exit 1).

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

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-10 15:57:27 -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