mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 15:08:38 +01:00
feat/parallel-implement
6
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
5f1e283117 |
fix(scripts): grep -q is never the reader of a pipe under pipefail (#874)
`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. An `if` then takes the else branch on a successful match. #587 found this in one file and noted it "only fires when the payload exceeds the ~4KB pipe buffer". That is not so, and the belief is why 82 copies in 22 scripts survived. Measured today on retire-site's real 1,158-byte plan output with has()'s exact pattern, 3,000 calls each: 'DRY RUN' line 3 of 20 echo|grep -q 2/3000 false misses 'apps.conf row' line 11 of 20 echo|grep -q 2/3000 false misses last phrase line 20 of 20 echo|grep -q 0/3000 'DRY RUN' here-string 0/3000 Rare per call, but verify makes hundreds of these calls, and the retire-site suite went red on those two exact phrases twice this week, passing every rerun. It is worse in a NEGATIVE check - hasnt() read a false miss as a PASS. And several copies are not tests: deploy-hetzner.sh exits 1 on a false miss, and the sshd drift watch would raise a false security alert. All 82 rewritten to `grep -q PAT <<<"$x"` (a here-string is not a pipeline, so there is no writer to signal) by a script that only touched the simple quoted-variable form and reported anything else. Checked: all 22 files pass `bash -n`, every file is a 1:1 line swap (82 lines), and the 20 line-continuation sites keep the here-string before the trailing backslash (the first draft of the rewrite got those wrong; caught in a dry-run diff before anything was written). #587's comment is corrected so it stops teaching the wrong threshold. Gate: scripts/test/no-grep-q-in-a-pipe.ts ratchets it repo-wide, including forms the rewrite skipped (e.g. "$(cmd)" | grep -q), and self-tests that its detector still fires. Proven by restoring the original deploy-hetzner.sh line. Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> |
||
|
|
95c40a9cd8 |
refactor: rename the product from FleetCrown to Loki (#695)
The product, its assistant, the repo, the host and every unit on the box now share one name. 638 files, ~3,000 mentions: UI copy, config, env keys (FLEETCROWN_* -> LOKI_*), systemd units (fleetcrown-* -> loki-*), docs, articles, the deploy workflow other repos reuse, and nine file names. - Three article slugs carried the old name and had been shared; permanent redirects keep those links alive (next.config.ts). - test-no-retired-name.sh now also forbids the old product name across the whole repo, so the rename cannot creep back through templates and examples. - ASSISTANT_STACK collapses the product and the assistant into one entry, because they are now the same name. Infra was cut over ahead of this merge: /opt/loki, loki-* units, the `loki` database and role, loki.orangecat.ch (old host 308s to it; /api, /widget, /embed keep proxying), GitHub repos bitbaum/loki and bitbaum/loki-releases. The Resend sending domain stays fleetcrown.orangecat.ch until the new domain is verified in DNS. Claude-Session: https://claude.ai/code/session_016YJVAanfj8keVSXyZnTemh Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com> |
||
|
|
fefdc64320 |
fix(register): name the host that actually serves, and stop calling a box path drift (#567)
Three defects, all the same shape: the register recorded an address that was
true once, and something downstream believed it.
1. aoz-wohnen's domain was a REDIRECT, not the canonical host
The row said `aoz-wohnen.orangecat.ch`. That host only 301s to
`aoz.orangecat.ch`, which is where AOZ Begleitung actually serves — the box's
own vhost comment says so ("One product, one URL"), and George settled it
months ago: "it should consistently be aoz. not wg, not aoz-wohnen."
This was not cosmetic. sync-infra.sh rewrites /etc/caddy/apps.d/<name>.caddy
from this field with an unconditional `tee`, so the next sync would have
emitted a block for the redirect host only and DELETED the aoz.orangecat.ch
site block — taking a live client's real URL off the air. Fixed by naming the
canonical host.
2. revamp-info listed a domain that must NOT be generated
`hirnli.orangecat.ch` is the same app, but it is served by a hand-maintained
hirnli.caddy (the middleware reads the Host header for tenant chrome). Listing
it here meant a sync would emit it a SECOND time inside revamp-info.caddy, and
two site blocks for one address fails `caddy validate` — which sync-infra runs
immediately before `systemctl reload`, so the reload aborts and every other
app's pending vhost change silently fails with it.
3. A repo_path on the box was reported as drift, and blocked everyone
dogfood-site-sep10-1201 was scaffolded directly onto the box, so its
repo_path is /home/ubuntu/dev/... — a path that cannot exist on the laptop
however healthy the fleet is. check-deploy-ready.sh called that drift and
exited 1, failing pre-push for every laptop push, on a register row that was
correct and a site serving 200. That is the category error this file's own
header warns about: judging state that is not in front of you.
Now split by DEV_ROOT: missing under DEV_ROOT is still drift and still fails;
anywhere else is announced ("not checkable here — repo_path lives on another
host") and does not fail.
The CI/CD verdicts were also fixed to count what was INSPECTED, not every
register row. With one app uninspected they said "all 16 deployed apps have
it" — absence reading as success, one level up, in the number itself.
The register's `domains` field is provisioning input, not documentation: it must
name the host that serves, and must not name a host that must not be generated.
The register NAME (`aoz-wohnen`), the systemd unit, /opt path and `aoz_wohnen`
database keep the housing-era name on purpose — they are addresses nobody reads,
and renaming them is a migration. The product is AOZ Begleitung; its SSOT is the
app's own brand.ts. Comments now say all of this in the file itself.
Verified: deploy-ready gate 20 passed (2 new cases — a box-side path is
announced and does not fail; the verdict counts only inspected apps),
client-ledger 12, uptime-sweep 66, apply-schema 34.
NOT done here, needs a box change: aoz-wohnen.orangecat.ch's 301 still lives
INSIDE the generated vhost, so a sync drops it (bookmarks break, canonical
survives). It belongs in its own aoz-legacy-redirect.caddy, the way
sink-legacy-redirect.caddy already does it.
Claude-Session: https://claude.ai/code/session_01HVudRzEmLqLHvGNqFSpJq6
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
|
||
|
|
d0029f2665 |
feat(ci): fail the build when an app ships migrations it never applies (#428)
botsmann shipped eleven migrations that were applied nowhere. /api/health served PGRST205 from a table that did not exist, for months, while every deploy went green — because deploy.sh skips apply-schema.sh entirely when the manifest's db field is `-`. Nothing failed. Nothing ran. Those look identical from outside, and that is the whole bug. Then printcraft did it too: five more migrations the pipeline never saw (#407). Twice is a class. The third is what this prevents. The gate: an app whose repo contains migrations while declaring `db=-` fails the build, naming the app and the directory holding the SQL. A zero-check, not a ratchet — no app violates this today, so any occurrence is a regression rather than inherited debt. The four apps that legitimately declare `db=-` (camille, sbb-lost-found, sink, substrata) genuinely have no migrations, and a test pins that this stays legal. ONE LIST, NOT TWO A gate with its own idea of where migrations live would drift from the applier and start lying in the other direction — passing an app whose SQL sits in a directory it never checks. So apply-schema.sh's candidate paths moved into a `migration_dirs` function above its lib-only return, and both consumers read it. Its five drizzle candidates, one prisma and two supabase homes had never been unit-testable before, because the discovery sits below that return; they are pinned now, in the applier's own order. Proven able to fail before shipping: fixtures assert a supabase-layout app and a drizzle-layout app each go red, that an app declaring its database is untouched, and that db=- with no migrations stays legitimate. The gate is about the lie, not about having SQL. 34 apply-schema tests, 18 deploy-ready-gate tests, whole ops suite green. Claude-Session: https://claude.ai/code/session_018waGt1ieA9TjpscqrbrnGb Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com> Co-authored-by: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
a58961aac8 |
fix(ci): deploy-ready gate now checks CD, not just CI — and fixes a live drift it just found (#419)
Two real gaps surfaced by a fleet-wide CI/CD audit, both now closed: 1. This gate only ever verified CI existence. camille-boulangerie had ci.yml (verify ran green on every push) and no deploy.yml at all — a green push there has never once reached the box. The gate's own stated purpose is "absence must not read as success," and it was doing exactly that for CD. Fixed in a companion PR (bitbaum/camille-boulangerie#2): the gate now detects a Deploy-shaped workflow the same way it detects CI, ratcheted independently so a CI regression and a CD regression can never mask each other under one shared count. deploy-ready-cd.baseline seeded at 0 — every deployed app now genuinely has both, verified fresh, not assumed. 2. apps.conf's `sink` entry pointed at /home/g/dev/aslan-tattoo, which no longer exists — some prior autonomous session renamed the checkout to /home/g/dev/s-ink and nothing updated the register. Running this gate locally caught it immediately (the "drift, not a bare environment" path added earlier today). Fixed the path. Neither of these was visible from CI passing: (1) needs a live check that CI has never run, and (2) can ONLY be caught locally, since it depends on the actual fleet checkouts existing — nothing schedules that check anywhere. That residual gap (no cron ever runs the fleet-inspection half) is reported separately, not fixed here — it needs a real decision about where such a check could run unattended, not a quick patch. scripts/test/deploy-ready-gate.sh gets 4 new cases using synthetic fixture repos (not the real fleet, which could coincidentally look fine) to prove CI and CD are detected independently, including camille's exact shape: a repo with only a CI workflow must be flagged for missing CD, not CI. Claude-Session: https://claude.ai/code/session_01Y9rKLxddothnXEtY6KDziN Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com> Co-authored-by: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
45938e60cf |
fix(ci): unbreak the gates — dependency graph, agent-core drift, desktop release (#400)
* refactor(infra): studio constants get one home, and the rename gets a command Fair criticism: I spent the day arguing for SSOT and then wrote new-site.sh with its own copies of GH_OWNER, BASE_DOMAIN and DEV_ROOT, and hardcoded 'maonakamoto' again in provision-widget.ts. Worse, the pattern already existed — _box-env.sh is literally labelled 'SSOT' for the box address. I did not extend it, I duplicated around it. _box-env.sh now owns GH_OWNER, SITES_BASE_DOMAIN and DEV_ROOT alongside the box address, and new-site.sh and provision-widget.ts read them instead of carrying their own. The 41 workflow files are a different case and worth being precise about: GitHub Actions requires a LITERAL owner/repo in and will not accept a variable, so that duplication cannot be removed. But a duplication you cannot remove is one you have to OWN — leaving it as 'remember to edit 41 files' is exactly the shape of step that gets skipped, the same shape as the git repository Camille never got. So sweep-gh-owner.sh is committed: one command, dry-runnable, optionally self-committing. Dry run against the fleet: 24 repos, all detected correctly. Renaming to an org is now plus one line in _box-env.sh. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix(infra): split WORKFLOW_OWNER from GH_OWNER before they diverge Same bug as the last commit, one layer down. The site template hardcoded maonakamoto/fleetcrown in its deploy.yml uses: line, derived from nothing — so every new site would bake in a literal that follows neither an account rename nor a move to an org. And GH_OWNER was quietly doing two jobs: where new site repos are CREATED, and where fleetcrown LIVES. They look identical today and are about to diverge — sites go to an org while fleetcrown stays on the personal account. One name for two values is how a rename half-works. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * chore(ci): GitHub owner maonakamoto -> catomean * chore(infra): owner is catomean Account renamed maonakamoto -> catomean. sweep-gh-owner.sh swept 24 repos and the SSOT now agrees; 32 local remotes repointed. This is the commit the sweep script exists for. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * chore(ci): GitHub owner maonakamoto -> catomean * chore(ci): GitHub owner maonakamoto -> catomean * fix(desktop): cut 0.8.14 — the owner rename touched desktop code My owner sweep changed two files in desktop/ (an update URL and a package reference) without bumping the version. That is precisely the failure #370 existed to prevent: desktop code that changes without a release ships to the server and to no machine at all, silently. The gate caught it, four commits after it was written. Working as intended, and worth saying plainly — I was the one it caught. GitHub redirects repository URLs after a rename, but only until somebody claims the freed name. An auto-updater should not depend on a redirect. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix(ci): the gate fails on your diff, not on your laptop Three things in this hook blocked pushes for reasons unrelated to the change being pushed, and together they are why --no-verify became reflex here. I passed it eight times in one day and blamed the hook; the hook was reporting real problems with misleading attribution. 1. STALE INSTALL. An unresolvable dependency surfaced as 'Cannot find module' — indistinguishable from a type error in your code. Now a precondition that fails first, loudly, naming npm ci. A day was spent on this exact confusion. 2. AGENT-CORE DRIFT. Drift arises either because you changed canonical without syncing, or because somebody changed the mirror in the other repo. Only the first is yours. It now checks whether this branch touched src/lib/agent/core/ and warns instead of blocking when it did not. 3. SCHEMA DRIFT. The guard already skipped an unreachable database but not a reachable stale one, so a local scratch DB missing someone else's columns blocked pushes touching no schema. Now scoped: if the branch changes schema a mismatch is yours and blocks; otherwise it reports and continues. The pattern is taken from desktop-release-drift, which self-scopes to files changed since the last release and is the only check here that has never blocked an unrelated push. It caught me correctly today, four commits after it was written. Where scope cannot be established the checks still fail closed — a gate that cannot establish innocence should not grant it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix(ci): resolve the default branch, never assume main The diff-scoping added in the previous commit compares against origin/main. 28 repos here use main — but aoz-housing, dotfiles and sbb-lost-found use master, and six had no origin/HEAD set at all. On those, merge-base fails, the scoping falls through to 'cannot tell', and every check treats every change as in-scope. The gate I had just fixed would have gone back to blocking unrelated pushes on a fifth of the fleet, for a reason nobody would have connected to a branch name. default_branch() now lives in lib.sh and resolves in order: the remote's own origin/HEAD, then whichever of main/master exists, then fail. Never a guess. The pre-push hook and agent-core-drift both use it. Also ran 'origin/HEAD' is unchanged and points to 'main' on the six repos missing origin/HEAD. 32 of 33 now resolve; wild-spirit has no remote at all, which is a separate finding and the same shape as camille this morning. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * feat(scaffold): every new site is born with CI ci-gate.sh cannot tell 'CI green' from 'no CI configured' — both exit 0. So a scaffolded site without a workflow deployed every push unverified while looking identical to one that passed. Substrata shipped to production that way for a day. The template now emits ci.yml alongside deploy.yml: npm ci, type-check, lint, build — the same bundle verify runs locally. Plus eslint.config.mjs, because ESLint 9 without a flat config exits non-zero on a migration notice and a new site's FIRST CI run would be red for reasons unrelated to its code. A red first run teaches people to ignore the light. Config copied from the fleet's working Next 16 apps, not invented. postcss.config.mjs assigns before exporting — the anonymous default export is a lint warning, and a scaffold should not emit its own warnings. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * feat(ci): no deployed app ships without CI, ratcheted to zero ci-gate.sh exits 0 for 'CI green' AND for 'no CI configured'. Absence is indistinguishable from success, so an app with no workflow deploys every push unverified while looking exactly like one that passed. Nothing reported it, because nothing was looking. The audit found two: camille-boulangerie, and sink — which is sinktattoo.com, a real client's site. sink turned out to be a FALSE POSITIVE, and that is the more useful finding: apps.conf pointed at /home/g/dev/s-ink, a path that does not exist, so the gate reasoned about an absent repository and reported the wrong fault. It sent me to add a workflow to a repo that already had one. The register was the bug. So the gate now distinguishes a stale register entry from a missing workflow and fails loudly on the former — a gate that lies about what to fix is worse than no gate. apps.conf repointed at /home/g/dev/aslan-tattoo. Camille genuinely had none and now does. Baseline is 0: a new deployed app without CI is a build failure. Tested in all four directions — over baseline fails, at baseline passes, under baseline passes and prompts, stale path fails. The first version could never fail at all: it set HERE before sourcing lib.sh, which overwrites HERE, so BASELINE_FILE pointed at a missing file and silently fell back to the current count. Found by testing the gate rather than trusting it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * feat(scaffold): template ships .nvmrc Every new site now pins Node once, and both CI and the deploy read it. Without it the deploy warns and the two pipelines pick a version independently — the kind of difference that surfaces as 'green in CI, broken on the box'. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * feat(hetzner): scaffold sets the deploy key itself, from one configured path new-site.sh printed `gh secret set ...` and called that operator hygiene. What it actually produced was substrata live in production deploying only from a laptop, because a printed instruction is a step that gets skipped. The key is piped from DEPLOY_KEY_PATH straight into `gh secret set` — never read into a variable, a log, or an agent's context — so the safety argument that motivated the manual step is kept while the step disappears. Per-repo on purpose: GitHub Free does not expose org-level secrets to PRIVATE repositories, so an org secret alone would silently cover only part of the fleet. DEPLOY_KEY_PATH joins the other constants in _box-env.sh so there is one path, not one per script. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y9rKLxddothnXEtY6KDziN * fix(ci): make the deploy-ready gate judge the diff, not the workstation The gate inspected the sibling checkouts under DEV_ROOT and nothing else. All 15 are cloned on the workstation, so it printed "all 15 deployed apps have CI"; CI clones this repo only, so the same commit printed fifteen missing repos and exited 1 — red on a diff that touched none of them. Third instance of one class: a gate judging state outside the commit. Its real cost is not the red run, it is that everyone learns the gate is noise and reaches for --no-verify. Split into the two halves that were tangled: REGISTER INTEGRITY — apps.conf lives in this repo, so it is in the diff, so CI must judge it. Now actually checked: field count, unique names, unique numeric ports. Previously nothing validated the register at all. FLEET INSPECTION — needs the checkouts. Where none exist it is announced as NOT RUN and exits 0. Announced, because "no output" and "all clear" looking identical is the bug this file was written to fix. Where some exist, a bad path is still drift and still fails. test:deploy-ready-gate locks it shut from both sides: a malformed register must fail even with no checkouts present, and a bare environment must never claim the fleet passed. Added to verify, so CI runs it in exactly the environment that used to break it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y9rKLxddothnXEtY6KDziN --------- Co-authored-by: Mao Nakamoto <georgy.butaev@revamp-it.ch> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com> Co-authored-by: t <t@t.t> |