mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 10:48:20 +01:00
register/probe-loop3
6
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
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> |
||
|
|
0ffe305a62 |
fix(api): a second route shipped the user's credential hashes — and the gate that ends the class (#309)
* fix(api): a second route was shipping the user's credential hashes
POST /api/onboarding returned the whole users row — `{ ok: true, user }` —
so passwordHash and privateZonePinHash went to the browser on every
onboarding finish, exactly as GET /api/me did before #306. The client never
read that object; it checks `res.ok` and nothing else.
It survived the grep that found #306 only because it was nested one level
deeper (`json({ ok: true, user })`, not `json(user)`). That is the second
instance of one class, so this stops being something to grep for:
- scripts/test/no-raw-user-response.ts scans every route handler and server
action, taints identifiers bound to a whole users row, and fails if one
reaches a response call unprojected. Negative-tested against the real
pre-fix source — it flags both branches — plus 13 fixtures covering the
nested, shorthand and spread forms.
And the export had grown a second answer to the same question:
- src/lib/account-export.ts kept its own REDACTED_USER_FIELDS deny-list, so
a secret column added later would be withheld by /api/me (allow-list) and
shipped by /api/me/export (deny-list that never heard of it). Both now
project through user-client-view.ts, which is exhaustive over the schema.
The export additionally omits Stripe ids — a policy narrowing of the
allow-list, not a second notion of what is secret.
- buildExportManifest generates its `excluded` lines from those same lists,
so the document describing what was withheld cannot drift from what was,
and the test asserts the linkage rather than a copy of the wording.
Verified: tsc clean, eslint 0 errors, 88/88 unit files, design-system ok.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* fix(ci): the deploy-ref fixtures inherited a handle to the real repo
The husky pre-push hook exports GIT_DIR — for a worktree push that is
.git/worktrees/<name>, the real repository. scripts/test/deploy-ref-gate.sh
runs from that hook, so every git call in the fixture suite inherited it.
An explicit GIT_DIR is not a search path, so GIT_CEILING_DIRECTORIES (guard 1)
did not constrain it, and the g() assertion (guard 2) could not see it either:
with GIT_DIR set and no work tree, `git -C <fixture> rev-parse --show-toplevel`
answers `<fixture>` — matching exactly, while objects and refs land in the real
repo. The suite this file was written to make safe was, from a hook, pointed
back at the thing it must never touch.
Guard 5 ($TMP must not be inside a repo) is what actually held the line, and it
held it by failing closed: with GIT_DIR set, an empty mktemp dir reads as a repo
root, so every push from a worktree died with "temp dir is inside a git repo" —
a true refusal with a misleading reason, and no way to push at all.
Now the ambient git environment is cleared first, from `git rev-parse
--local-env-vars` so it cannot fall behind a new variable. Test 9 re-runs the
whole suite with GIT_DIR pointing at a decoy repo and asserts both that it
passes and that the decoy is unchanged.
Verified to bite: with the unset removed, test 9 fails and the child run dies at
guard 5 exactly as the real push did.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* refactor(ci): one definition of an isolated git fixture
not-behind-gate.sh has the same inherited-GIT_DIR hole the previous commit
fixed in deploy-ref-gate.sh — and found it itself: run from the pre-push hook,
its own isolation probe reported "g() accepted a non-repo dir nested in a repo
— it would have mutated the ENCLOSING repo". Correct, and it was right.
Fixing it in place would have been the third copy of the same paragraph. The
copies are the hazard: both suites carry scars from 2026-08-15, each was
hardened against what its own incident taught it, and neither against the
other's — deploy-ref-gate knew $TMP must not sit inside a repo, not-behind-gate
knew a fixture must never write git config. A third suite would have copied
whichever file it sat next to.
So the four properties that must hold before a fixture touches git now live in
scripts/test/lib/git-fixture-env.sh, sourced by both. Each suite keeps its own
g() — the per-command assertion that the directory about to be mutated is the
fixture — because their fixture shapes genuinely differ.
Verified under the real hook environment (GIT_DIR=.git/worktrees/<name>):
deploy-ref-gate 9 passed, not-behind-gate 15 passed.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
---------
Co-authored-by: t <t@t.t>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
|
||
|
|
95f3f752f6 |
fix(test): the isolation probe passed with no guard at all (#302)
#300 added a test asserting that `g()` refuses a directory which is not its own fixture repo — the walk-up that published fixture commits to GitHub. The test was decorative. It probed a bare `"$TMP/not-a-repo"`, and since nothing above $TMP is a repo, git finds nothing whether or not any defence exists. Removing the assertion entirely leaves that probe passing. Which is the same mistake the file was written to remove, one level up: #300 replaced a tautological `case "$root" in "$TMP"/*` with a guard nobody had run against the thing it forbids. Measured, each with the assertion stripped out: bare "$TMP/not-a-repo" refused anyway → PASSES WITH NO GUARD nested in a repo with NO commit refused anyway → `rev-parse HEAD` fails in an empty repo too, so an escape is indistinguishable from a refusal nested in a repo WITH a commit exit 0, returns the enclosing repo's sha → the only shape that bites The probe now builds an enclosing repo, gives it a commit, and targets a non-repo directory inside it. Verified directly: with a bare `git -C` in place of `g`, that call resolves to the enclosing repo and exits 0 — exactly the condition the assertion trips on. Honest note on the evidence: stripping `g()` from the whole suite makes it fail at test 1 rather than test 8, because setup_repo's origin assertion depends on the helper too. So the whole-suite strip is NOT a clean demonstration of test 8. The targeted probe above is what proves it. Caught by a colleague reviewing the merged fix, who hit all three shapes on their own copy before flagging it. Co-authored-by: t <t@t.t> Co-authored-by: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
1caa6b3e98 |
fix(test): the deploy-gate fixture could destroy the repo it runs in (#300)
This suite runs from the husky PRE-PUSH hook, so it is armed on every push from
every session. Today its fixtures fell through to the real checkout, and because
pre-push runs BEFORE the transfer, git then pushed what the fixture had just
mangled: `refs/heads/main` on GitHub ended up pointing at a fixture commit whose
tree is a single file named `f`. It also wrote `core.hooksPath=/dev/null` into
the SHARED .git/config, silently disabling every hook for every worktree until
someone noticed.
The mechanism is `git -C <dir>`: when <dir> is not a repo, git WALKS UP the
directory tree and operates on whatever repo it finds. `setup_repo` then ran
`git branch -M main` and `git push origin main` against the real one.
I wrote the guard that was supposed to prevent this, and it was theatre:
case "$root" in "$TMP"/*) ;; *) fail ... ;; esac
`$root` is constructed as "$TMP/a", so the pattern can never fail. It reads like
containment and enforces nothing. Test 6 did not even go through setup_repo — a
bare `git init "$TMP/e"` with no guard at all, which is why its failure ("gate
blocked a checkout with no origin/main") was the first visible symptom: the gate
resolved the REAL origin/main because it was operating on the real repo.
Rebuilt so that no single failure can reach a real repo:
1. GIT_CEILING_DIRECTORIES="$TMP" — git will not search for a repository above
the temp dir, so the walk-up that caused this cannot physically happen.
2. Every git call goes through `g`, which asserts the target resolves to
exactly that fixture path (physical paths, so a symlinked TMPDIR is not a
false mismatch). There are no bare `git -C` calls left.
3. Pushes name an explicit PATH, never the remote `origin` — a fallthrough now
has nowhere to publish. The fixture's own origin URL is asserted too.
4. Identity and hook suppression come from ENV, never `git config`. A config
write is what corrupted the shared config; env cannot leak.
5. $TMP is refused outright if it sits inside a git repo.
Test 8 is new and pins the property that was missing: `g` must REFUSE a
directory that is not its own repo rather than letting git walk up. Without the
ceiling that call resolves to the surrounding worktree; with it, git says
"fatal: not a git repository".
Verified after the rewrite that the real repo is untouched by a run — HEAD,
branch, reflog and core.hooksPath all unchanged.
Scope note: scripts/test/not-behind-gate.sh inherited the same false guard and
is being fixed separately in #299 by its author, so it is deliberately not
touched here.
Co-authored-by: t <t@t.t>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
|
||
|
|
52ede1bf1b |
fix(loki): a 429 that means "too big" is not a 429 that means "too busy" (#270)
* fix(loki): a 429 that means "too big" is not a 429 that means "too busy"
Groq returns 429 for two unrelated conditions and the handler treated them as
one. CAPACITY ("Rate limit reached ... Used 5959, Requested 400") means the
per-minute window is momentarily spent — waiting helps, and a smaller model has
its own budget so stepping down helps too. SIZE ("Request too large ... Limit
6000, Requested 15041, please reduce your message size") means ONE request is
larger than the entire allowance — waiting can never help, and stepping down
makes it strictly worse because the cheaper model has HALF the ceiling
(verified 2026-08-14: llama-3.3-70b-versatile = 12000 TPM,
llama-3.1-8b-instant = 6000).
So an oversized prompt stepped down to the model that could not possibly take
it, burned 25s in a wait for a window that never grows big enough, and then gave
up the turn. Loki's tool loop died on every question and every answer came from
the toolless fallback — which cannot read the tables the questions are about.
- classifyGroqLimit (pure) tells the two apart from the response body; status,
type and code are identical in both, so only the wording distinguishes them.
- llm.ts throws size-429s immediately, worded so loop.ts's shed ladder
recognises them and retries with fewer facts — the only thing that actually
fixes an oversized prompt.
- The shed ladder now goes to 5 attempts instead of 2: it is the cure now, not
a long shot, so let it shed far enough to fit.
- Unrecognisable bodies default to capacity: that path retries and degrades,
where guessing "size" would shed context that was never the problem.
Tests use bodies captured verbatim from the live API, including the daily-cap
body (capacity — the budget refills) which shares the size body's phrasing about
tokens per minute.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* test(deploy-gate): a fixture builder must not be able to aim at a real repo
setup_repo commits and renames a branch to `main`. Pointed at a real checkout
that is a repo-destroying sequence, and this suite runs from `verify` on every
push, in parallel sessions — so "the paths are obviously fine" is not a property
worth assuming. It now refuses unless the fixture path is under $TMP, and
asserts the clone actually produced its own repo there (a failed clone would
leave the -C target missing, and with no `set -e` the suite marches on).
Also guards an empty $TMP, which would make fixture paths absolute-from-root
while still satisfying the "$TMP"/* containment pattern.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
---------
Co-authored-by: test <test@test>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Co-authored-by: t <t@t.t>
|
||
|
|
c8415a348b |
fix(loki,deploy): the approval queue survives a Groq outage; deploys can't ship off-main (#262)
* 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> |