mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 07:59:11 +01:00
fix/queue-blocker-date
11
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
b58f514ef6 |
Add scoped Bitbaum studio portal and keep Loki self-service free (#995)
* feat: start request-scoped Bitbaum portal and studio review * test: prove scoped portal boundaries and restore studio record join * fix: support canonical studio origin and readable partner review * fix: support canonical studio origin and readable partner review |
||
|
|
064cad655d |
fix(runs): one clock for the lane and the reaper — no second prompt into a live session (#896)
* wip: one clock for the lane and the reaper * wip: database test for the lane and the reaper, wired into CI |
||
|
|
d42dbfed4d |
fix(ci): a test that never exits is a failure, not a 56-minute wait (#809)
groq-chain-fallback finished its assertions in two seconds, printed its check
mark, and then held every CI run open for FIFTY-SIX MINUTES. It read as "CI is
slow" rather than "a test is broken", so nobody looked.
Its refusal cases drive the vendor-error path, which fire-and-forgets a quota
write: recordRefusal -> persist -> lazy import of @/db -> postgres(url,{max:5}).
Nothing closes that pool, so its sockets hold the event loop open. The file now
ends with process.exit(0), as the other database-touching tests already do
(rag-retrieval, telegram-allowlist). Exiting is safe precisely because the
pending write is worthless: the readings come from a stubbed vendor answering a
fake key, so persisting them would put fiction in the quota table.
Reproduced both directions against a real database: without the exit the
process is still alive when killed at 45s; with it, 1s.
This was invisible locally, which is why it survived -- with no DATABASE_URL the
lazy import rejects and the process exits in two seconds. The hang exists only
where a database does, so test-unit.ts's own header claim that these tests
"behave identically on a laptop and in CI" was quietly false, in timing rather
than in pass/fail.
The runner is the real fix: it spawned every file with no timeout, so one wedged
test set the runtime of the whole suite. It now enforces a per-file deadline
(UNIT_TEST_TIMEOUT_MS, default 120s) and reports a timeout as a named failure
pointing at the likely cause. Proven by mutation: a planted file that wedges the
event loop goes red in 20s instead of running forever.
Claude-Session: https://claude.ai/code/session_01NLZ6vs1jsWw2kKbpWTZHf2
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
||
|
|
efeabdec64 |
test(e2e): does Loki work as intended — asked of the live site, on a clock (#712)
Three testable meanings, one script, no browser and no mocks (scripts/test/loki-loop-e2e.ts, run as the signed-in operator through the same API the /loki page uses): 1. knows the fleet — a fleet-shaped question is answered from the studio map (all three pillars named, fleet_map among the retrieved sources) and the reply is an answer, not the model's plan for one; 2. publishes the map — /api/fleet/map is public with the pillars live, and bitbaum's map.json is the same map, recently generated; 3. closes the loop (--dispatch) — a request typed into a thread comes back into that thread as an outcome turn. A run that never returns is aborted with a [loki-e2e] marker so no test leaves the operator's queue hanging. Proven against production before commit: 3/3 without dispatch; with dispatch and the builder unauthenticated, the loop failed honestly inside two minutes with the runner's own diagnosis delivered into the thread. Scheduled on the box every six hours (install-loki-e2e-watch.sh -> loki-e2e-check.sh, alert on flip; the dispatch leg only when the builder-auth probe last said ok). pnpm run test:e2e:loki runs it from a laptop. Claude-Session: https://claude.ai/code/session_016YJVAanfj8keVSXyZnTemh Co-authored-by: Claude Fable 5.1 <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> |
||
|
|
1647fe7987 |
fix(sweep): a test that rotted behind a wrong excuse, and a box spec off by 2x (#480)
Three follow-ups from sweeping the earlier findings. Two of the four I had
carried forward did NOT survive checking and are dropped: /api/control/dispatch
is a real route, so the docs referencing it are correct; and
scripts/test/push-notifications.ts exists. Verifying first is why this commit
is smaller than the list that prompted it.
1. THE TEST NOBODY RAN, FOR A REASON THAT WAS NEVER TRUE
scripts/test/push-notifications.ts read scripts/agent-hook-bridge.sh, which was
deleted on 2026-06-11 in
|
||
|
|
caa0e41c3b |
chore: add a formatter (#449)
* chore: add a formatter, matching the style this repo already writes singleQuote=false was chosen by counting this repo's own imports, not by fleet decree. The fleet is genuinely split and the two repos that already had a .prettierrc disagreed with each other, so there was no standard to restore. Quote style does not cross repo boundaries; having a gate does. Markdown is ignored for now — prettier rewraps prose, which would bury the real diff. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * style: format with prettier (1062 files) Mechanical. No behaviour change. This SHA is listed in .git-blame-ignore-revs so `git blame` skips it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * chore: teach git blame to skip the reformat Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * fix(lint): reattach two guards the reformat detached Both effects were one-liners, so a trailing eslint-disable-line covered the setState call: useEffect(() => { setSelected(new Set()); }, [q.length]); // eslint-disable-line ... prettier expanded the block. The comment stayed on the closing line while the call moved above it, so the guard protected nothing and the rule its author had deliberately silenced failed the build. This is the second shape of the same defect — hirnli had the eslint-disable-NEXT-line variant. Both come from the same fact: an eslint directive binds to a line number, so reformatting can silently unbind it, which makes 'mechanical, no behaviour change' false for any bulk reformat. * chore(desktop): bump the runner version the reformat requires desktop-release-drift enforces that anything built into Fleet Runner which differs from the last released tag must carry a version ahead of that tag — main read 0.8.15 and fleet-runner-v0.8.15 already shipped. A whole-repo reformat changes bytes under desktop/, so the gate fires. The alternative was adding desktop/ to .prettierignore, which would buy a quiet PR by carving a permanent hole in the formatter's coverage — the precise shape of silent drift this test was written to catch. Bumping is what the rule asks for and costs one patch release whose only content is whitespace. * chore: merge main and re-format A whole-repo reformat conflicts with any concurrent commit, and a conflicting PR runs no checks at all while reporting nothing. Conflicts resolved to main, which is correct because this branch changes formatting and nothing else. * chore: leave desktop/ out of this reformat desktop-release-drift is right to refuse this. Everything under desktop/ is built into Fleet Runner, so changing it means shipping: bump the version AND add a FLEET_RUNNER_RELEASES entry, whose stated audience is 'person who installed Fleet Runner and wants to know what changed'. For a whitespace-only build the honest answer is 'nothing', so that release should not exist — and I should not write release notes claiming otherwise. I had bumped to 0.8.16 to get the gate green. That was the wrong direction: publishing a build to three OS runners to keep a formatting PR quiet. Reverted. desktop/ is excluded in .prettierignore with the reasoning recorded there, to be formatted alongside the next real runner change, where the bump and the notes are true anyway. --------- Co-authored-by: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
a577014533 |
chore: clear the code-debt audit — gates, auth coverage, deps, CI database (#362)
* perf(gates): stop charging 8 minutes to push and 3 minutes to commit
Measured on main today: `npm run verify` took 490s and `.husky/pre-commit`
took 172s of it on EVERY commit. That is not a safety property, it is a tax on
committing and pushing — the two habits that keep work off a single disk. The
same fleet audit found 206 finished files stranded uncommitted for ten days.
Nothing here weakens a check. Every one still runs, on the same files:
disk-gc /proc scan 110s -> 16s in_use() forked a readlink per PID on
every call. Hundreds of processes times
several candidate dirs is thousands of
forks per run. Now one `ls -l` pass,
cached for the run. This is SHIPPED code,
so bitbaum's hourly GC gets it too — and
caching is the more correct reading
anyway: "in use when the sweep started"
should not flip between tiers.
eslint 132s -> 7s --cache. Cold is 150s (+18s to write it),
paid once by CI; developers pay warm.
test-disk-gc fixture sparse files via truncate instead of
dd-ing ~300MB of zeros nothing reads.
The code under test only calls df, which
the test already stubs, so it cannot tell.
pre-commit 172s -> ~0 lints STAGED files only. tsc cannot be
scoped to a file set and moves to the
push side, where the full bundle already
runs. A commit is local and reversible; a
push is shared. Gate them differently.
verify 490s -> 334s, still green. `npm run verify` remains the single
definition of verified and CI still calls it verbatim.
* fix(deps): clear every high-severity advisory (15 -> 4, 0 high)
`npm audit fix` took 9 of the 15. The two HIGH ones it left were both the same
root cause — ajv's advisory is *via* fast-uri — and the vulnerable range is
3.0.0-3.1.4 with 3.1.6 already published inside the same major. So an override
closes both with no breaking change:
HIGH fast-uri host confusion via literal backslash authority delimiter
HIGH ajv (inherits the above)
before 1 low 7 moderate 7 high
after 0 low 4 moderate 0 high
The remaining 4 moderates are deliberately NOT fixed. They are one chain —
drizzle-kit -> @esbuild-kit/* -> esbuild — and npm's offered remedy is
drizzle-kit@0.18.1, thirteen minor versions back, which would take the schema
tooling with it. The advisory is esbuild's DEV SERVER accepting cross-origin
requests; drizzle-kit is a devDependency, esbuild is not referenced by
next.config.ts, and neither reaches production. Downgrading working migration
tooling to silence a dev-server advisory that does not apply is a worse trade
than carrying it, so it is carried knowingly rather than silently.
verify green at 372s.
* test(api): make auth coverage checkable instead of archaeological
There is no middleware.ts — all 214 routes guard themselves, through ELEVEN
different mechanisms: four session getters, two private-zone wrappers, a cron
secret, a runner bearer, a widget token, an agent token, and signed webhook
secrets. Each is reasonable on its own. They are layers, not duplicates, and
collapsing them would be worse than leaving them.
The defect is that the SET is not knowable by inspection. Auditing it today
took seven passes. The first reported 44 unguarded routes including
/api/people and /api/memory — every one a false alarm from a helper the grep
had not met yet. Each later pass found another mechanism and shrank the list:
44 -> 27 -> 18 -> 25 -> 18
Nothing was actually wrong. That is the problem: a property needing seven
attempts to verify is a property nobody verifies, and its failure mode is
silent — a new route with no guard looks exactly like the 18 that are public
on purpose.
So this asserts the checkable version of the rule: every route either names a
known mechanism, or appears on a PUBLIC list with a reason a human wrote. The
reasons are the real artifact; until now the answer to "why is this endpoint
open?" existed only in whoever wrote it.
The list is self-cleaning — it also fails when an entry names a route that now
guards itself, or one that no longer exists, so it cannot rot into exemptions
nobody re-examined. All three failures verified red before committing.
Current state: 214 routes, 196 guarded, 18 public with a recorded reason.
No unguarded route was found. Runs in verify via the unit glob; no DB, no
network, 1s.
* test(ci): give CI a database, so the billing test stops being skipped forever
Six suites sat on a permanent skip list for want of a Postgres. One of them
is the OrangeCat entitlement end-to-end — signature verification, actor
lookup, grant write, dedupe, expiry sweep. That is the billing boundary, and
it had never run in CI once. "Only passes locally via .env.local" means, in
practice, that nobody runs it.
It turns out it needs a MIGRATED database, not a seeded one, so CI can just
have one. It now runs green there.
Two things this surfaced that are worth writing down:
* drizzle/*.sql does NOT replay from empty. 0001_canonical_project_identity
references `user_projects`, which 0000 never creates; 51 of 56 migrations
fail against a fresh database. The journal is history, not a rebuild
recipe — so CI uses `drizzle-kit push`, and anyone reaching for those
files to rebuild an environment should know they will not work.
* push is only non-interactive because the CI database is EMPTY. Its
truncate prompts fire for tables holding rows, and an empty database has
none. The comment says so at the call site, because pointing this at a
database with data would be a very bad afternoon.
pgvector/pgvector:pg16 rather than stock postgres — knowledge-embeddings
declares a `vector` column and push dies without the extension.
Skips are now conditional rather than permanent: SKIP_UNLESS_ENV keeps a test
out of the run only while its prerequisite is missing, instead of excluding it
on every machine forever because some machines lack a database. Verified both
ways — 103 tests with no DATABASE_URL, 104 with one, full verify green at 191s.
---------
Co-authored-by: t <t@t.t>
|
||
|
|
84a0edd70d |
fix(mobile): a dialog you cannot close, on pages nothing could test (#287)
* fix(deploy): a marker that can lie is worse than no marker Two flaws in #279, found before its deploy ran. 1. The stamp preferred GITHUB_SHA over the checked-out commit. deploy.yml's workflow_run path checks out `workflow_run.head_sha`, which is not always the run's GITHUB_SHA, so the marker could name a commit that was never compiled. Since the deploy compares the live marker against the shipped ref, a lying marker manufactures a false alarm. Git HEAD is literally what was built, so it now comes first; GITHUB_SHA is the last resort for checkouts with no .git. 2. A mismatch rolled the box back. The realistic cause of a mismatch is a second deploy landing behind this one — and reverting to app.prev would discard the NEWER build, turning a benign race into exactly the incident the check exists to catch. It now reports loudly and leaves the running build alone. What was missing before was never the ability to revert; it was ever being TOLD that the box serves something else. That, plus /api/health, is the fix. Both are pinned by tests, including one asserting the mismatch path does not call rollback_box. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * fix(mobile): a dialog you cannot close, on pages nothing could test Testing prod in a real phone viewport turned up two defects and the reason neither was ever going to be caught. THE OVERLAYS The mobile navigation sheet — the only route to half the app on a phone — ignored Escape and let the page keep scrolling behind it. Checking the other overlays found the same thing twice more: the floating Loki assistant could be opened with a key (`?`) and not closed with one, and the sessions drawer and command palette both cover the app while the page scrolls underneath. The cause is structural. `useEscapeToClose` was a private helper inside modal.tsx, so the behaviour was reachable only by using <Modal>/<Drawer>; every hand-rolled overlay started from zero and had to remember. Some did. Three did not — and CommandPalette already carries a comment about fixing "the user's 'Escape doesn't close' complaint", so this is the class's third appearance, not its first. The hook moves to hooks/use-escape-to-close.ts, and scripts/test/overlay-contract.ts enforces the rule: anything claiming role="dialog" handles Escape, and the overlays that cover the app lock what is behind them. Fixing the fourth instance by hand would have cost more than that file. THE BLIND HALF /people, /money, /habits, /events, /goals and /memory sit behind the PIN, so the prod smoke skipped them, the UI dogfood's flows failed as "skipped", and the responsive audit's page list never included them. Three checks, one hole, in the same place — and it read as coverage: 97 green probes, 84 green viewport checks. The PIN was never the boundary. The unlock is an HMAC under AUTH_SECRET, and anything holding AUTH_SECRET can already mint a session as any user — which is exactly what print-session-token.ts does. So the format moves to a request-free module and the tooling mints its own unlock. Nothing new is granted; the tests just stop pretending a third of the product does not exist. The PIN keeps guarding what it was built to guard: a person at a keyboard. The smoke now proves the gate before walking through it — a session without the unlock must be refused — so bypassing it adds an assertion instead of removing one. 97 probes to 129, all green against production. VERIFIED IN PROD - 129/129 authenticated probes, including the private zone for the first time - 84 viewport checks across 320/390/768/1440, no horizontal overflow, now including the six private pages - new audit:mobile drives a touch Chromium: every page's last element is reachable above the floating nav at max scroll, and the menu sheet closes on the close button, a backdrop tap, and Escape 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> |
||
|
|
192aedc807 |
test(orangecat): end-to-end proof for the BTC pass entitlement route (#246)
Only the HMAC helper was unit-tested; nothing exercised the real /api/orangecat/entitlement route against the DB. This drives it live: signature verify, actor lookup, idempotent grant insert, users.plan write, dedupe on retry, and the expiry sweep. Zero real money — it's the synthetic stand-in for a live sats payment, proving every piece of the FleetCrown side is correct before attempting one for real. Co-authored-by: Mao Nakamoto <maonakamoto@users.noreply.github.com> Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com> |
||
|
|
f63315ace7 |
test(ci): glob-discover unit tests; converge CI and pre-push
Addresses the Test/Quality panel finding that only ~12 of ~32 test:* scripts ran automatically and a newly-added test:* was born dead (never in CI): - scripts/test-unit.ts globs scripts/test/*.ts and runs every pure test in parallel. New pure tests are picked up for free. Infra-dependent tests are skipped with an explicit reason (server/DB/Groq/embeddings). Classification was verified under true CI conditions (.env.local hidden + dead DATABASE_URL, since dotenvx otherwise injects a live DB and masks the dependency): 29/29 pure tests green, 6 correctly skipped. - ci.yml and .husky/pre-push both now run `npm run test:unit` (+ test:home), so a green push and a green CI run the same suite and can't diverge. - Runner avoids top-level await (tsx→CJS rejects it), uses the local tsx bin at concurrency 2 (esbuild-friendly on a 2-core box), and handles spawn errors. NOT done (needs your decision — flagged): required-status-checks branch protection would REJECT direct pushes to main, breaking the push-to-main-deploy flow, unless the deploy also moves into CI (needs the box SSH key as a GitHub secret — your call). `next build` in CI still needs a Postgres service to pre-render; deferred (deploy-time build + the new rollback already gate it). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> |