Skip to content

Day run — 2026-11-01

Brief for an unattended coding-agent run while the operator is away. The agent reads this first, works the queue in order, and writes the report at the bottom.

  • Specs: this repo, main (every context PR up to #16 is merged). Read decisions-log.md first, then the task’s spec links.
  • Code: router-africa. main has migrations 0000–0004 and every Phase 1 schema file (PRs #3–#8, #17). Still open: #9 (P1.10, now based on main), #15 (FX markup scope, on #9), the pricing stack #10 → #11 → #12 → #16, #13 (P0.12), #14 (P7.01), #18 (CLAUDE.md).
  • Phase 0 as built: ../../infra/installation-as-built.md section 14 (droplet 2 vCPU / 4 GB / 70 GB, Postgres 17, the Cloudflare resource names, Zero Trust team routerafrica). GitHub: secret CLOUDFLARE_API_TOKEN, variable CLOUDFLARE_ACCOUNT_ID; branch rules are not enforced (GitHub Free).
  1. One task, one branch, one PR. Branch <task-id>-<short-name> from main, unless the queue says to stack. A stacked PR names its base in the description. Never push to main or release/*. Never merge.
  2. Never deploy, run wrangler deploy or wrangler secret, create cloud resources, touch the droplet, or read or write secrets. Dry runs, helm lint and helm template are fine.
  3. Tests ship with the code. Run npm run typecheck, npm run lint and npm run test before pushing.
  4. If a decision or an account is needed, stop that part. Record the question in the report and move on. Don’t guess decisions that aren’t in the decisions log.
  5. Status: update the task’s row in its phase file in a context-repo PR at the end of the run (one PR for all rows), and write the outcome in the report below.
  6. Usage: if a usage limit stops the run, schedule a wake-up after the reset and continue the queue.

Priority today: frontend and backend. Configuration tasks (9–11) only run if the app tasks are done.

# Task Base Notes
1 Bump context/ submodule main Point it at context main (now has every decision through #16)
2 P7.01 remainder push to #14’s branch Date range picker and chart wrapper
3 P7.02 p7.01-ui-web-components (#14) App shell and states (34–36)
4 P4.02 main Scheduled-job dispatcher
5 P4.07 main Audit writer and event catalogue
6 P3.02 p1.10-query-helpers (#9) Key authentication
7 P5.04 main Orgs, workspaces, roles and permissions: the permission model and checks, and workspace and member routes on apps/dashboard-api, building on PR #1’s auth. Invitation emails wait for P0.05
8 Screens against a mocked API p7.02-* Approved by the operator (2026-11-01). Overview (8) and API keys (12–15) with MSW handlers whose shapes come from packages/types
9 P0.07 main Only if time is left; config is lower priority today. [env.staging] / [env.production] for apps/api and apps/dashboard-api: routes and custom domains, Queues (usage-events-*, niobi-callbacks-*), R2 (router-africa-content-*), placeholders for Hyperdrive and VPC bindings. wrangler deploy --dry-run per environment
10 P0.06 + P0.12 remainder main Only if time is left. pr.yml, deploy-staging.yml, deploy-production.yml (required tag input); fixed order gates → migrate → dashboard-api → dashboard → admin → api → droplet services → smoke; steps for missing code skip cleanly; migrate and droplet steps run on the self-hosted runner (label it; the runner doesn’t exist yet). Workflows request packages: write themselves. Dependabot config and dependency caching. Replace ci.yml and niobi-proxy-deploy.yml
11 P0.08 (repo part) main Only if time is left. infra/postgres/ (CloudNativePG, one single-instance cluster per environment, Postgres 17 pinned, production WAL archiving + daily base backup to router-africa-db-backups-production, 30 days, credentials from a Kubernetes secret), infra/gateways/bifrost-1/values-{staging,production}.yaml from installation-as-built.md with the image pinned, infra/niobi-proxy/ chart skeleton. Requests and limits sized for 2 vCPU / 4 GB: the operator measured memory at 35% used (about 1.4 GB) with today’s production Bifrost, so about 2.6 GB is left for the staging Bifrost, both app databases, cloudflared, the runner and niobi-proxy. Write the budget in the PR, and say if it doesn’t fit. An apply runbook for the operator

Not today: anything that deploys or needs the droplet; P5.01 (needs P0.05); D.08.

Scope extended by the operator (2026-11-01, 17:10): after item 8, build every remaining screen and API: the Phase 5–8 tasks (customer dashboard screens 1–36, admin screens 37–55, their dashboard-api routes, and the apps/api request path), against mocks where a dependency isn’t built or merged yet. Then items 9–10. Excluded: Helm chart configs and setting the databases up (item 11 and anything that applies to the droplet). Same rules: one task, one branch, one PR, stacked where a task needs an unmerged one; questions recorded, not guessed. Work through usage resets (wake-up after each reset).

Work in this order; each row is one PR. Dashboard screens stack on the previous screens PR (starting from #25) and use MSW contracts in packages/types; API rows implement those contracts in apps/dashboard-api from main (or stacked on #24 where they need its tenancy module). Mark each row when its PR is open.

# Scope Base PR
E1 Usage (9), Request logs + log detail (10–11) screens #25 #26
E2 Billing: balance, top-up, transfer, transactions, rates, billing details (16–21) E1 #27
E3 Workspaces list/create/settings/members (22–25), Team: members, invitations, remove member (26–28) E2 #28
E4 Settings: profile, security, organization, data & privacy, notifications (29–33); onboarding (5–6); accept invitation (7) E3 #29
E5 Admin console shell + screens 37–55 (apps/admin) #29 (lockfile, ui-web) #30
E6 dashboard-api: keys, models, overview routes (P5.07 without gateway push, P5.08 reads) integration/2026-11-01 #31
E7 dashboard-api: usage, logs, billing, transactions, rates, settings routes E6 (#31) #32
E8 dashboard-api: invitations and members (P5.05), consent/content-logging (P5.06), notifications (P5.10) E7 (#32) #33
E9 dashboard-api admin route group (P5.11) and admin APIs for 37–55. E9a = staff gate and APIs for 37–41, 49, 50, 54 — code #34. E9b = APIs for 42–48, 51–53, 55 — code #35 E8 (#33) done
E10 apps/api request path: model gate, hold, gateway call, settle (P3.03–P3.08) against a fake gateway — code #36 #35 done

Queue 2 (approved by the operator, 2026-11-01 evening: “all”)

Section titled “Queue 2 (approved by the operator, 2026-11-01 evening: “all”)”

Same rules. Run after the summary below; outcomes are appended to the Report as Q2.n.

# Task Base Notes
Q2.1 P4.01 usage queue consumer #36 (api.e10-request-path) Request logs, rollups, content-storage rollup; then enable the consumers held back in #37
Q2.2 P3.09 hold/settle concurrency test Q2.1 Real Postgres (CI service container), N parallel requests, no over-approval; wire into the gates step in #38
Q2.3 P4.04–P4.06 reconciliation jobs Q2.2 Ledger invariant check, usage reconciliation, key reconciliation; against the Gateway interface
Q2.4 P2.05 + P4.03 daily rates job Q2.3 Frankfurter + manual overrides; the FX source for most markets is still open
Q2.5 P5.12 + P7.13 view as customer Q2.4 Read-only impersonation and the banner
Q2.6 P5.03 + P5.13 session hardening, auth conformance suite Q2.5 Done: #44
Q2.7 P3.10 (local part) API conformance Q2.6 Done: #46
Q2.8 P7.14 (part) wording, accessibility, Playwright on the mock #29/#30 stack Done: #47
Q2.9 Housekeeping Done: #48

Queue 3 (from the operator’s answers, 2026-11-01 late evening)

Section titled “Queue 3 (from the operator’s answers, 2026-11-01 late evening)”

The answers are recorded in the decisions log (Operator answers to the 2026-11-01 day run). Same rules. These run after Q2.9.

# Task Base Notes
Q3.1 Request history with no date limit (answer 6); USD is always the sign-up fallback (answer 3) #48 Done: #49
Q3.2 Hold fallback of 100,000 output tokens (answer 11) Q2.7 packages/pricing and the request path
Q3.3 Unbilled usage charged automatically (answer 8) Q3.2 Done: #51
Q3.4 Margin at the request’s own rate (answer 9) Q3.3 Done: #52
Q3.5 dashboard-api tests on real Postgres in CI (answer 14) #38 Done: #53 (harness), #54 (workflow)
Q3.6 Top-up through a hosted checkout in an iframe (answer 7) #53 Done: #55
Q3.7 Maansa FX source (answer 13) #12 Needs Maansa’s API docs and an account: question for the operator
Q3.8 Turn on the usage-queue consumers with their dead-letter queues #37 The operator created usage-events-dlq-staging and -production (actions item 17, 2026-11-02)
Q3.9 Staging mock gateway (decisions log, Daily backups; no staging Bifrost) Q3.6 A Gateway that answers chat with canned completions and usage, and manages credentials without Bifrost; chosen by config in staging for both Workers

Written by the agent: per task, the outcome (done / partial / blocked), the PR, the tests that ran, and any question for the operator.

  • PR: code #19, branch chore-bump-context from main. Submodule moved from 58e73fb to context main d31a98e.
  • Tests: none needed (pointer change only).
  • Questions: none.
  • PR: pushed to code #14 (77b4068); description updated. P7.01 is now complete.
  • Built: DateRangePicker (presets, two-month calendar, no future dates, optional retention floor), date-range helpers, ChartFrame + TimeSeriesChart (area/bar/line, stacking, one palette, shared tooltip/legend, loading/empty/error states), and a Storybook theme switch so every story renders in dark and light.
  • Tests: repo-wide typecheck, lint and test pass; 8 new unit tests for the date helpers; storybook build succeeds; screenshots checked (spend chart dark and light, empty chart, open picker).
  • Question: the specs name no chart library. I used Recharts (what shadcn’s chart component uses). Say if you want another.
  • PR: code #20, branch p7.02-app-shell, stacked on #14: merge #14 first, then retarget #20 to main.
  • Built: routes /o/:orgId/w/:workspaceId/:screen; / and /o/:orgId reopen the last workspace used; org switcher (34) and workspace switcher with currencies (35), both keeping the screen; no-access inside the shell for a hidden workspace or foreign org, 404 for unknown pages, no-org and no-workspace states (36); sidebar with Docs link and sign out; placeholder screens. Org/workspace response schemas added to packages/types (dashboard.ts, its own commit 21df167 so P5.04 can reuse it).
  • Tests: 15 new (router-level on jsdom over a fake API, plus path helpers). Repo-wide typecheck, lint and test pass; vite build succeeds.
  • Assumes from P5.04: GET /api/orgs and GET /api/orgs/:orgId/workspaces (shapes in the PR). Route shape /o/…/w/… was my choice; the specs only require both ids in the URL.
  • PR: code #21, branch p4.02-job-dispatcher from main.
  • Built: dispatch() wired into scheduled(): lease claim with UPDATE … RETURNING, finish and job_runs insert in one transaction, expired leases reclaimed as failed (lease expired), runNow() on the same claim, a dependency-free cron parser. The registry is empty and all jobs stay disabled until their tasks land.
  • Tests: 11 dispatcher tests on PGlite (overlapping ticks run a job once; a throwing job is recorded as failed and runs again on schedule; reclaim; run-now can’t overlap) and 22 cron tests. Repo-wide checks pass.
  • For P1.06: the dashboard role needs INSERT on logs.job_runs and logs.audit_events, since dashboard-api writes both directly.
  • PR: code #22, branch p4.07-audit-writer from main.
  • Built: a catalogue of 52 actions in packages/types (label, and whether a staff action needs a reason); writeAudit, withAudit (the change and its event in one transaction) and auditedRead (content.read committed before the read). It refuses unknown actions, missing staff reasons, and secrets or content in metadata.
  • Tests: 15 on PGlite. The done-when holds: with audit inserts failing, content.read returns nothing and the reader never runs; withAudit rolls the change back. Repo-wide checks pass.
  • Note: the task text says ratelimit.updated but db-schema.md says rate_limit.changed; I followed the spec. Catalogue additions beyond the spec’s list are in the PR for review.
  • PR: code #23, branch p3.02-key-auth, stacked on #9: merge #9 first, then retarget #23 to main.
  • Built: key format helpers in packages/types (generate, checksum check, mask, hash); keyAuth middleware on /v1/* on top of #9’s single request-path read; identical 401s, 403 account_suspended, key_not_in_header, WWW-Authenticate, x-request-id everywhere; a 60-second cache of rejected keys only.
  • Tests: 33 on PGlite. The done-when holds: malformed keys never reach the database; revoked keys, frozen workspaces and suspended orgs are refused on the next request; a burst of 20 identical bad keys reads Postgres once per window. Repo-wide checks pass.
  • Question: the base62 alphabet order isn’t in the spec. I used 0-9A-Za-z, which becomes part of the key format. Confirm or change it before any key is issued.
  • Overlap to tidy after merges: #9’s LogsStore.recordAudit/recordJobRun insert raw rows, while #22 and #21 write those tables directly (with validation and a transaction). Pick one path once both are in.
  • PR: code #24, branch p5.04-orgs-permissions from main.
  • Built: one permission module (20 permissions × Owner/Admin/Member, workspace visibility, writes refused in a suspended org); dashboard-api routes for orgs, workspaces and workspace members; org and Default workspace created on sign-up with the currency preselected from CF-IPCountry. Response shapes match the shell in #20.
  • Tests: 66 matrix tests and 10 route tests through real sign-up on PGlite. Done-when: matrix passes; a Member is refused every workspace they’re not in; a suspended org is read-only. Repo-wide checks pass.
  • Questions: (1) currency fallback when the country’s currency isn’t enabled (used USD, then the first enabled); (2) may Members read the org member list (allowed); (3) may Members create keys in their workspaces (allowed; managing others’ keys is Owner/Admin).
  • Follow-ups: audit events for these changes once #22 is on main; member role changes, removal and invitations are P5.05.

8. Screens against a mocked API — done (in review)

Section titled “8. Screens against a mocked API — done (in review)”
  • PR: code #25, branch p7.screens-overview-keys, stacked on #20.
  • Built: MSW mock (npm run dev:mock; every response parsed with the packages/types schema); contracts for overview, models and keys; Overview (8); API keys list, create, reveal-once, detail drawer with edit, rotate and revoke (12–15).
  • Tests: 27 in apps/dashboard (overview, list, create/reveal, edit/rotate/revoke, validation, formatting). Repo-wide checks pass; screenshots checked in mock mode.

E1. Usage, logs, log detail (9–11) — done (in review)

Section titled “E1. Usage, logs, log detail (9–11) — done (in review)”
  • PR: code #26, stacked on #25. 8 new tests; repo-wide checks pass; screenshots checked.
  • Question: request-log retention isn’t decided; the logs date picker uses 90 days (UI only).

E2. Billing (16, 17, 19–21) — done (in review)

Section titled “E2. Billing (16, 17, 19–21) — done (in review)”
  • PR: code #27, stacked on #26. 9 new tests; repo-wide checks pass; screenshots checked.
  • Also fixed on #25/#26: credits were shown with a currency code (“12,415.50 KES”), against the decisions log (Credit balance & non-refundability). They’re now “credits” everywhere; fees and totals paid keep the currency.
  • Questions: (1) how the customer pays through Niobi (hosted page, mobile-money prompt with a phone number, card); the contract allows an optional payment URL; (2) minimum and maximum top-up per currency; (3) usage in Transactions as daily totals.

E3. Workspaces and Team (22–28) — done (in review)

Section titled “E3. Workspaces and Team (22–28) — done (in review)”
  • PR: code #28, stacked on #27. 9 new tests; repo-wide checks pass; screenshots checked.

E4. Settings, onboarding, accept invitation, create org — done (in review)

Section titled “E4. Settings, onboarding, accept invitation, create org — done (in review)”
  • PR: code #29, stacked on #28. 13 new tests (66 in the app); repo-wide checks pass. Every customer screen (1–36) is now built; screens run on the MSW mock (npm run dev:mock in apps/dashboard).
  • Note: the official Better Auth passkey client couldn’t install next to our pinned version (peer conflict); the passkey UI calls the plugin endpoints with @simplewebauthn/browser. Check the payload when P5.02 enables the plugin.

E5. Admin console (37–55) — done (in review)

Section titled “E5. Admin console (37–55) — done (in review)”
  • PR: code #30, stacked on #29. Every staff screen, staff sign-in with required two-factor, Admin/Support roles, reasons on money and access changes. 16 tests; repo-wide checks pass; screenshots checked. npm run dev:mock in apps/admin (staff sam@router.africa / correct-horse-battery-staple-42, code 123456).
  • All screens 1–55 are now built against mocked APIs. Next: the real APIs (E6–E10).

Integration branch — integration/2026-11-01

Section titled “Integration branch — integration/2026-11-01”
  • main plus every open code PR merged in the documented order (#9, #15, #10, #11, #12, #16, #13, #18, #19, #21, #22, #23, #24, #14, #20, #25–#30). The whole stack merges; the only conflicts were packages/types/src/index.ts (export lines, unioned) and package-lock.json (regenerated).
  • One real fix: the old openai-error export came back from #14’s older base and had to be dropped (#8 replaced it with api-error). Expect the same when merging #14 into main.
  • Repo-wide typecheck, lint and test pass on it. jsdom tests got a 20 s timeout: under turbo every package runs at once and the first test in a file timed out.
  • The API work (E6–E10) is based on this branch, since it needs #24’s tenancy module and the contracts from the dashboard stack. Its PRs target the integration branch. To ship: merge the PRs in order as before, or merge this branch.

E6. dashboard-api keys, models, overview — done (in review)

Section titled “E6. dashboard-api keys, models, overview — done (in review)”
  • PR: code #31, on integration/2026-11-01. 12 tests; repo-wide checks pass.
  • Key lifecycle as decided: pending → gateway credential (encrypted AES-256-GCM) → active → secret once; failures leave nothing; update rolls back on a gateway refusal; revoke is Postgres first, then the gateway with retry.
  • For you: a new secret CREDENTIAL_KEY_V1 (32 random bytes, base64) per environment, and the Bifrost management binding. Until then staging/production answer 503 on key changes; development uses an in-memory stand-in gateway.

E7. dashboard-api usage, logs, billing, settings, onboarding — done (in review)

Section titled “E7. dashboard-api usage, logs, billing, settings, onboarding — done (in review)”
  • PR: code #32, stacked on #31. 10 tests; repo-wide checks pass.
  • Built: time-bounded usage (per currency) and log reads with keyset paging; content read audited before R2; balance, fee quote, top-ups through a PaymentsClient with one guarded credit path (applyTopUpResult); transactions; rates; workspace settings with the consent record; billing details; ownership transfer; onboarding.
  • Migration 0006 (org_billing_details) was hand-trimmed: drizzle’s snapshots are behind the hand-edited 0001, so db:generate proposes bogus workspace_members changes. Regenerate the snapshots before the next schema change.
  • For you: niobi-proxy’s binding for payments in staging/production (until then top-ups answer 503; development uses a stand-in), and the R2 CONTENT binding for stored prompts.

E8. dashboard-api team, invitations, workspace summary — done (in review)

Section titled “E8. dashboard-api team, invitations, workspace summary — done (in review)”
  • PR: code #33, stacked on #32. 7 tests; repo-wide checks pass. Content-logging consent and low-balance settings landed in E7 (#32).
  • Built: members (role change, remove with revoke/reassign of their keys), invitations with email and single-use accept by the invited address, public invite preview, workspace summary, create with Members, audit events.
  • Still for P5.10: the low-balance alert job (sending the email) registers with the dispatcher; it needs P0.05’s email domain to be useful.

E9a. dashboard-api admin gate and APIs for 37–41, 49, 50, 54 — done (in review)

Section titled “E9a. dashboard-api admin gate and APIs for 37–41, 49, 50, 54 — done (in review)”
  • PR: code #34, stacked on #33. 11 tests; repo-wide checks pass.
  • Built: migration 0007 (staff columns on users, impersonated_by/audience on sessions); /api/admin/* needs a staff role and two-factor (/me answers before two-factor), and its writes are accepted only from ADMIN_BASE_URL; Support is read-only except force-logout and resend-verification. Overview, orgs, users, workspaces (adjust, move with FX less the FX markup), keys (search by pasted key, revoke), audit log, staff (at least one Admin), jobs. Every change takes a reason and writes a staff audit row.
  • Left for P5.12: view-as-customer answers 501 (needs impersonation and the cross-origin one-time-token hand-off).
  • For you: ADMIN_BASE_URL per environment; the first Admin is set by hand in the database (role = 'admin').

E9b. dashboard-api admin APIs for 42–48, 51–53, 55 — done (in review)

Section titled “E9b. dashboard-api admin APIs for 42–48, 51–53, 55 — done (in review)”
  • PR: code #35, stacked on #34. 13 tests; repo-wide checks pass. Every admin screen now has a real API.
  • Built: rates (history, recompute through the job dispatcher), markup rules, FX overrides and currency settings, model catalog, top-ups with check-now (same guarded credit path), margin per day/currency/model with fee revenue separate, gateway sync with retry, top-up fees, workspace discounts, unbilled usage charge/release, edge rate limits behind an EdgeLimitsClient.
  • Contract fixes (UI updated): top-up fees are percent or flat per vendor and currency (the UI had a combined option the schema and pricing-model.md don’t have); flat markup rules now carry their per-tokens unit and currency, as pricing-model.md says.
  • Questions for you:
    1. Charging unbilled usage uses today’s rate and refuses (409) if the workspace lacks available credits, rather than charging part. Keep?
    2. Margin converts provider cost at the latest FX rate, not the day’s rate. Keep for launch?
  • For you: a Cloudflare API token (secret) scoped to the zone’s rate-limiting rules, for edge limits in staging/production (503 until then). Dev stand-in values (600/min API, 20/min auth) are placeholders, not launch values.

E10. apps/api request path (P3.03–P3.08) — done (in review)

Section titled “E10. apps/api request path (P3.03–P3.08) — done (in review)”
  • PR: code #36, stacked on #35 (it moves the credential crypto into packages/types so both Workers share it). 23 request-path tests + 4 hold-maths tests; repo-wide checks pass.
  • Built:
    • POST /v1/chat/completions: the gate read, then one transaction for the idempotency claim, spend window and hold, then the gateway call with the decrypted credential and SSE pass-through, then settle or release;
    • after the response: the usage event, R2 content and the stored replay;
    • GET /v1/models and GET /v1/key, with credits and no currency.
    • Tested: balance = SUM(ledger) and held = SUM(open holds) after mixed outcomes; a disconnect settles on the partial usage the gateway reports.
  • Fixed on the way: with tee(), the gateway would never have seen a client disconnect. The stream now cancels upstream. The generic /v1/* auth also no longer drops the chat model gate.
  • Decided in the PR (P3.07 asked): a failed queue publish is logged for alerting, not retried.
  • Questions for you:
    1. max_tokens above the ceiling: the decisions log says cap, api-errors.md says 400 max_tokens_above_limit. I capped, since the decisions log wins. Should the catalogue drop that reason?
    2. Idempotency windows: automatic 30 s, client key 24 h.
    3. Hold fallback when a model has no default or ceiling: 4096 output tokens.
    4. Content cap: 1 MiB per request.
  • Still open: P3.01 (Bifrost adapter; needs P0.10/P0.13), P3.09 (concurrency on a real Postgres), P3.10/P3.11 (staging). Until P3.01 lands, chat answers 503 outside tests.
  • For you: CREDENTIAL_KEY_V1 on apps/api as well; the USAGE_QUEUE and CONTENT bindings (P0.07).
  • PR: code #37 into main. wrangler deploy --dry-run passes for both Workers in both environments.
  • Built: routes (custom domain api[-staging].; app[-staging].router.africa/api/* for dashboard-api), usage-events-* producer on apps/api, router-africa-content-* R2 on both, ADMIN_BASE_URL, Hyperdrive placeholders (P1.06), VPC Service placeholders (P0.10).
  • Held back on purpose: queue consumers on dashboard-api stay commented until P4.01/P6.03, because today’s no-op queue() would acknowledge and drop every event. admin[-staging]. /api/* waits for P8.01.
  • Found: Wrangler 3.114 silently ignores vpc_services, so P0.10 needs a Wrangler 4 upgrade.
  • For you: create the two Pages projects, attach the custom domains, then the first real deploy.

10. P0.06 + P0.12 remainder — done (in review)

Section titled “10. P0.06 + P0.12 remainder — done (in review)”
  • PR: code #38, stacked on #13.
    • pr.yml, deploy-staging.yml (push to main) and deploy-production.yml (manual, with a required tag that must exist; fails fast otherwise);
    • a reusable gates.yml (lint, typecheck, test with the Turborepo cache, the secret scan) and deploy.yml (gates → migrate → dashboard-api → dashboard → admin → api → droplet services → smoke);
    • Dependabot, with the auth stack in its own PR.
    • Replaces ci.yml and niobi-proxy-deploy.yml; no staging-branch triggers remain.
  • How missing pieces skip:
    • Cloudflare steps wait for CLOUDFLARE_ACCOUNT_ID.
    • Migrate and droplet steps wait for SELF_HOSTED_RUNNER=true (label router-africa-cluster). Without that check, they’d queue for a day on a runner that doesn’t exist.
    • Deploy jobs require a successful migrate, so code never ships ahead of its schema.
    • Droplet services run a per-service deploy.sh that P0.08 adds.
  • CI on the PR itself:
    • The gates ran on GitHub and the lint/typecheck/test job passed.
    • The secret scan first failed: gitleaks scans --all branches, so newer branches’ content failed the PR. It now scans only the commit under test’s history and passes.
    • Two known non-secrets are allowlisted: #23’s made-up masking-test key and #31’s documented dev-only credential key. Merge #13 with #38, since #13 alone would fail its scan on a re-run.
  • Not done: actionlint (its binary download was blocked here).
  • For you: the repository variables CLOUDFLARE_ACCOUNT_ID (and later SELF_HOSTED_RUNNER), the secret CLOUDFLARE_API_TOKEN, and the canary keys once P1.07 seeds the test workspace.

Queue done. Items 1–10 and E1–E10 are all in review. Item 11 (Helm and databases) was excluded by the operator.

  • Screens: every screen, 1–55, is built.
  • APIs: every dashboard and admin API is built.
  • Request path: apps/api (gate, hold, gateway call, settle, after-response, endpoints) is built and tested on PGlite against a fake gateway.
  • Stand-ins: the gateway, payments and edge limits run on dev stand-ins until their bindings exist. Outside development they answer 503 instead of guessing.
  • Open PRs: code #19–#38. Merge order is in README.md Current status.

Questions for you, from today (none is guessed into a decision; each says what I used meanwhile):

  1. Chart library: Recharts (item 2).
  2. API key base62 alphabet order: 0-9A-Za-z (item 6). Confirm before any key is issued.
  3. Currency fallback at sign-up when the country’s currency isn’t enabled: USD, then the first enabled (item 7).
  4. May Members read the org member list, and create keys in their workspaces? Both allowed (item 7).
  5. rate_limit.changed vs the task text’s ratelimit.updated: followed db-schema.md (item 5).
  6. Request-log retention: the UI uses 90 days (E1).
  7. How customers pay through Niobi (hosted page, mobile-money prompt, card); minimum and maximum top-up per currency (E2).
  8. Charging unbilled usage: today’s rate, and refuse if the workspace lacks credits (E9b).
  9. Margin converts provider cost at the latest FX rate, not the day’s (E9b).
  10. max_tokens above the ceiling: capped, per the decisions log. api-errors.md still lists 400 max_tokens_above_limit. Drop it? (E10)
  11. Idempotency windows of 30 s automatic and 24 h client key; a 4096-token hold fallback; a 1 MiB content cap (E10).

Needs from you (accounts, secrets, console):

  • Secrets: CREDENTIAL_KEY_V1 on both Workers, CLOUDFLARE_API_TOKEN, and a Cloudflare token scoped to rate-limiting rules (edge limits).
  • Variables: ADMIN_BASE_URL (now in Wrangler vars) and CLOUDFLARE_ACCOUNT_ID.
  • Pages projects and custom domains (P0.07).
  • The droplet work: P0.08–P0.10, then Bifrost bindings for P3.01 and P5.07.
  • niobi-proxy (phase 6); P0.05 for email.
  • Regenerate the drizzle snapshots before the next schema change (E7).

Tooling. /ra-dev-pr-review skill — done (in review)

Section titled “Tooling. /ra-dev-pr-review skill — done (in review)”
  • PR: context #18. It lives at .claude/skills/ra-dev-pr-review/SKILL.md (89 lines).
  • What it does: reviews code PRs against the decisions log, the task’s spec and Done when, the working rules, ten Router.Africa invariants and a short best-practice list. It loads only the docs the changed paths need. Run /ra-dev-pr-review <n…|all> [--comment].
  • To run it from the code repo: link it into ~/.claude/skills; the PR has the one-line command.

Q2.1. P4.01 usage queue consumer — done (in review)

Section titled “Q2.1. P4.01 usage queue consumer — done (in review)”
  • PR: code #39, stacked on #36. 6 tests; repo-wide checks pass.
  • Built: queue() writes request logs and rollups idempotently through the logs store, moves last_used_at forward only, sends malformed events to the DLQ at once and retries a failed batch. niobi-callbacks messages are retried until P6.03.
  • For you: create the queues usage-events-dlq-staging and usage-events-dlq-production (not in P0.02). Then enable the consumers held back in #37; the PR has the exact config.
  • Question for P1.06: last_used_at is in core, but the consumer role is logs only. Grant it that one column, or keep the consumer on the dashboard role.

Q2.2. P3.09 hold/settle concurrency test — done (in review)

Section titled “Q2.2. P3.09 hold/settle concurrency test — done (in review)”
  • PR: code #40, stacked on #39. CI wiring: a Postgres 17 service container in gates.yml, pushed to code #38.
  • Built: 6 tests at N = 100 over 20 real connections, on a throwaway database with the real migrations:
    • holds against a small balance (exactly what fits is approved);
    • the last hold capped at what’s left;
    • concurrent settles and releases;
    • holds interleaved with settles;
    • the spend-cap window (exactly the cap is approved);
    • 100 identical bodies (exactly one claims). The invariants are checked each time.
  • Done when: passes at N = 100 against Postgres 17. 3 of the 6 fail when the conditional WHERE is removed (checked, then restored).
  • Found a production bug that PGlite hid:
    • Cause: Drizzle’s postgres-js driver leaves timestamps unserialized, so a JS Date in a raw sql template throws on real Postgres.
    • Impact: every chat request (the idempotency insert) and every job-dispatcher tick would have failed.
    • Fixed: in #40 (apps/api), and pushed to code #21 for the dispatcher. Both checked against Postgres 17: fails before, passes after.
  • Suggestion: run the dashboard-api suite once on the CI Postgres too, since PGlite can hide this class of bug. It isn’t done yet; it would join Q2.9 housekeeping if you agree.

Q2.3. P4.04–P4.06 reconciliation jobs — done (in review)

Section titled “Q2.3. P4.04–P4.06 reconciliation jobs — done (in review)”
  • PR: code #41, stacked on #40. 8 tests, passing on both PGlite and Postgres 17; repo-wide checks pass.
  • Built:
    • Ledger invariant check: reports mismatches and stuck holds as a partial run with an alert log line, and cleans up expired claims, sessions and verifications.
    • Usage reconciliation: finds not_charged and token_mismatch rows from the gateway’s logs, never charges, and moves the watermark only after the whole window is read.
    • Key reconciliation: all five mismatch kinds, auto-clearing once fixed, plus credential backfill for a new gateway.
    • The gateway jobs skip until a gateway is bound and enabled.
  • Interface changes:
    • buildJobRegistry({ gateway, keyRing }) replaces the static registry.
    • Gateway.listCredentials() is added, because drift can’t be seen without the gateway’s config.
  • Also: the reconciliation tests run on real Postgres in CI, using #38’s service container. That partly answers the PGlite blind spot from Q2.2.
  • Still needs staging: P4.05 and P4.06’s Done when (a real Bifrost call and hand-made mismatches), after P0.10 and P3.01.

Q2.4. P2.05 + P2.02 + P4.03 daily rates and catalog sync — done (in review)

Section titled “Q2.4. P2.05 + P2.02 + P4.03 daily rates and catalog sync — done (in review)”
  • PR: code #42, stacked on #41. It needs the pricing stack (#10, #11, #12, #16) merged first. 6 tests on PGlite and Postgres 17; repo-wide checks pass.
  • daily_rates:
    • stores today’s FX (a manual rate today wins; a missing one keeps the last rate, flagged);
    • prices every model that is on in every enabled currency, rounding up to the step;
    • keeps the pre-rounding rate;
    • is idempotent within a day;
    • reports, rather than publishing, any model or currency missing a cost, an FX rate or a markup rule.
  • model_catalog_sync: new models are added switched off; removed ones get in_catalog = false and are never deleted.
  • Admin’s Recompute rates button now runs real code.
  • Open (already in the decisions table): the FX source for most markets. Until it’s chosen, those currencies need a manual rate (screen 44); the job lists them each run.

Q2.5. P5.12 + P7.13 view as customer — done (in review)

Section titled “Q2.5. P5.12 + P7.13 view as customer — done (in review)”
  • PR: code #43, stacked on #42. 6 API tests and 3 dashboard tests; repo-wide checks pass.
  • Built:
    • Start: Admin only, with a reason, on customers only. A single-use 60-second token travels in the URL fragment and is exchanged on the dashboard origin, through a small Better Auth plugin endpoint, for a 30-minute session with impersonated_by set.
    • Read-only: every non-GET route is refused, including Better Auth’s own write routes, and so are stored-content reads.
    • Audit: start and end are audited.
    • Dashboard: a “Viewing as” banner with an exit button, and a client guard that blocks writes with a visible message.
  • Done when: a test proves an impersonated session can’t call any non-GET route or read content.
  • Found: Better Auth’s createSession ignores an expiresAt override unless overrideAll is passed, so the session first lasted a day. It’s fixed and tested, with a 30-minute backstop in requireSession as well.
  • Not done: the sessions.audience (app/admin) check from auth-security.md. It isn’t needed for this, because a customer session can’t pass the staff gate. It’s left for P5.03/P5.13 (Q2.6).
  • Code: #44, branch api.q2.6-auth-hardening, based on api.q2.5-view-as (#43).

  • Built:

    • a staff-console Better Auth instance with its own secret, cookie, routes (/api/admin/auth), admin audience, and 8-hour sessions with a 12-hour absolute limit; app sessions are checked for the app audience;
    • REAUTH_REQUIRED step-up on sensitive routes, with dashboard handling (sign out, then sign in again);
    • password change always revokes the other sessions;
    • Pages _headers (CSP, HSTS);
    • the admin UI’s auth calls moved to /api/admin/auth;
    • conformance tests: dashboard-api test/conformance.test.ts (12), apps/api test/conformance.test.ts plus an item-6 assertion, and dashboard content-rendering.test.tsx (item 19).
  • Checks: typecheck, lint and test pass (dashboard-api 318, api 57 + 6 skipped, dashboard 70, admin 16). Two tests that run first in their files now get 40 s, because the full parallel run is slow to start.

  • New secret for you: BETTER_AUTH_SECRET_ADMIN per environment, 32+ characters and different from BETTER_AUTH_SECRET_APP.

  • Housekeeping: stop the throwaway Postgres container ra-concurrency-pg when done.

Q2.7. P3.10 (local part) — done (in review)

Section titled “Q2.7. P3.10 (local part) — done (in review)”
  • Code: #46, based on api.q2.6-auth-hardening (#44).
  • Built: apps/api/test/openai-sdk.test.ts. The official openai SDK (v7, test-only) runs through the app in-process against the fake gateway. It covers:
    • a chat completion;
    • streaming;
    • models.list();
    • the SDK’s error classes, with our metadata.reason.
  • Conformance item 20: after a mixed run, neither the client’s key nor the gateway credential appears in any log, response, usage event, stored content or gateway request (api-key-security.md §9 item 6).
  • §9 coverage: the other lifecycle items were already covered (items 1–4 in key-auth and request-path, item 7 in #44, items 5 and 9 in dashboard-api). Item 8 waits for the leak-scanning endpoint.
  • Checks: typecheck, lint and test pass (apps/api: 62 passed, 6 skipped).
  • Not done: the staging part of P3.10, and P3.11. Both need a deployed staging stack.
  • CI note: #40–#46 fail only the secret scan. #38’s allowlist covers both findings (a made-up test key and a development-only placeholder), so the scan should pass once #38 merges and the stack is rebased onto it.

Operator answers (2026-11-01, late evening)

Section titled “Operator answers (2026-11-01, late evening)”
  • Recorded: all 14 answers are in the decisions log (Operator answers to the 2026-11-01 day run).
  • Docs aligned:
  • Code work from the answers is Queue 3 (Q3.1–Q3.7).
  • Interpretations to check:
    • Answer 5: “changed for both” was read as “both documents use one name”, namely rate_limit.changed, as in db-schema.md and the code.
    • Answer 14: “staging and production branches” was read as push to main (staging deploys from main), the production workflow, and manual runs. There is no staging branch.
  • Question: answer 13 names the Maansa API. Q3.7 needs its documentation link and an account (API key) before it can be built.
  • Code: #47, based on p8.e5a-admin-customers (#30).
  • Built:
    • the wording guard (a unit test over every dashboard screen; no violations found);
    • an axe accessibility pass on 9 screens plus a keyboard check;
    • Playwright on the mock: onboarding → key → dashboard, and top-up → balance in credits. ?mock=new starts before onboarding.
  • Fixed:
    • the Usage breakdown tabs had no panel;
    • revoked key rows failed text contrast.
  • Checks: typecheck, lint and test pass. 11 of 11 Playwright tests pass locally.
  • Not done: sign-up and a real charged call (they need staging), and the post-deploy and nightly runs (#38’s pipeline, once staging exists). The top-up test changes with Q3.6.
  • Code: #48, based on api.q2.7-sdk-conformance (#46).
  • Drizzle snapshots: already in sync at the top of the stack (drizzle-kit generate: no schema changes). Nothing to do.
  • One write path: LogsStore.recordAudit and recordJobRun were removed. Nothing called them, and they couldn’t share the caller’s transaction (db-schema.md 8.3). Audit events go only through audit/writer.ts, job runs only through the dispatcher.
  • Wrangler 4: wrangler ^4.156 and workers-types ^5 in both Workers. The unused vitest-pool-workers was removed; it pinned Wrangler 3.
  • Bug it surfaced: apps/api lacked nodejs_compat, which the postgres driver needs at runtime. Added. #37’s wrangler.toml needs the same line.
  • Checks:
    • typecheck and lint pass;
    • tests pass except one dashboard test that timed out under full parallel load; it passes alone, and #48 doesn’t touch the dashboard;
    • the dry-run deploy passes for both Workers with no warnings.

Q3.1. History with no date limit; USD fallback — done (in review)

Section titled “Q3.1. History with no date limit; USD fallback — done (in review)”
  • Code: #49, based on api.q2.9-housekeeping (#48). It’s on the backend stack because that stack already includes the dashboard.
  • Answer 6:
    • the logs date picker has no 90-day minimum;
    • the usage chart answers any range (over 366 days used to return nothing);
    • Transactions has no 90-day window. The 200-row caps stay, and paging is later if needed.
    • Staff screens are unchanged.
  • Answer 3: USD is the fallback whenever the country’s currency isn’t enabled, and USD is always usable for a workspace, even if switched off.
  • Checks: typecheck, lint and test pass (dashboard-api: 319).

Q3.2. Hold fallback of 100,000 tokens — done (in review)

Section titled “Q3.2. Hold fallback of 100,000 tokens — done (in review)”
  • Code: #50, based on api.q3.1-history-usd-fallback (#49).
  • Built: FALLBACK_MAX_TOKENS changed from 4,096 to 100,000, and the hold is still capped at the available balance. There’s a new test, and the seedModel helper can now create a model with no limits.
  • Checks: typecheck, lint and test pass (apps/api: 63 passed, 6 skipped).

Q3.3. Unbilled usage charged automatically — done (in review)

Section titled “Q3.3. Unbilled usage charged automatically — done (in review)”
  • Code: #51, based on api.q3.2-hold-fallback (#50).
  • Built: one charging function (packages/db/src/unbilled.ts), used by the reconciliation job, the request path and the admin “charge” action.
    • Rates: each charge uses the rate in force when the request ran: the settlement’s or hold’s locked rate, or the published rate at the log’s time. The admin screen used today’s rate, against the spec; fixed.
    • Short of credits: the row stays pending on the admin screen and is charged on the workspace’s next request once credits cover it.
    • Holds: a still-open hold is closed with the charge.
  • Spec: db-schema.md 8.3 item 7 now says this, replacing “Nothing is charged automatically”.
  • Checks: typecheck, lint and test pass (dashboard-api 322; apps/api: 64 passed, 6 skipped). The new reconciliation tests also pass on real Postgres 17.
  • For P1.06: the api role needs SELECT, UPDATE on core.usage_discrepancies.

Q3.4. Margin at each request’s own rate — done (in review)

Section titled “Q3.4. Margin at each request’s own rate — done (in review)”
  • Code: #52, based on api.q3.3-auto-charge-unbilled (#51).
  • Built:
    • each request carries the FX rate (with markup) built into its locked price: published_rates.fx_rate, on the usage event and in request_logs.fx_rate;
    • the hourly rollup sums gateway_cost_usd × fx_rate into usage_hourly.gateway_cost_local, and Margin reads that, never the latest FX;
    • migration 0008 adds the two columns. Older queued events still parse.
  • Why a rollup: the decisions log says reports read rollups, never raw rows, so it isn’t computed from settlements at read time.
  • Spec: db-schema.md updated (request_logs.fx_rate, usage_hourly.gateway_cost_local).
  • Checks: typecheck, lint and test pass (dashboard-api 323; apps/api: 64 passed, 6 skipped).

Q3.5. Real-Postgres tests on deploys and manual runs — done (in review)

Section titled “Q3.5. Real-Postgres tests on deploys and manual runs — done (in review)”
  • Code:
    • #53, the harness, based on #52: test:postgres runs the whole dashboard-api suite on Postgres, copying one migrated template database per test file and dropping each test’s database when the test ends.
    • #54, the workflow, based on #38: PRs run on PGlite only. A real-postgres job (the whole suite plus the P3.09 concurrency test) runs from deploy.yml (pushes to main and production) and by hand (workflow_dispatch).
  • What the first full run found: 318/323 passed. The 5 failures were one test helper reading PGlite’s cause.constraint (postgres.js says constraint_name); no app code was affected. Now 323/323 on both.
  • Checks: typecheck, lint and test pass. test:postgres passes 323/323 locally against Postgres 17 and leaves no databases behind.
  • Done:
    • item 17: the dead-letter queues exist, so Q3.8 is added;
    • item 18: the Pages projects exist;
    • item 15: CREDENTIAL_KEY_V1 is set on router-africa-dashboard-api-staging.
  • Problem: wrangler secret put --env staging in apps/api failed. That checkout’s wrangler.toml has no [env.staging] until #37, and Wrangler 4 rejects it. Workaround given: run from the repo root with --name router-africa-api-staging (and -production).

Q3.6. Hosted checkout in an iframe — done (in review)

Section titled “Q3.6. Hosted checkout in an iframe — done (in review)”
  • Code: #55, based on api.q3.5-suite-on-postgres (#53).

  • Built:

    • after “Pay”, the hosted checkout for that total shows in a sandboxed iframe inside the top-up dialog, and the status still updates by itself;
    • the mock serves a stand-in checkout page;
    • paymentUrl is documented as the hosted checkout.

    The live Niobi call is phase 6.

  • Questions for Niobi (added to actions item 21.5):

    1. the checkout page’s origin, for the dashboard CSP’s frame-src (until then the browser blocks the iframe);
    2. confirmation that their checkout may be framed by app.router.africa;
    3. per-currency top-up limits.
  • Checks: typecheck, lint and test pass.

  • Q3.7 is blocked on the Maansa API docs and account. Next (resume point): Q3.8, turning on the usage-queue consumers.

  • Secrets set (names confirmed with wrangler secret list):

    • CREDENTIAL_KEY_V1 on all four Workers;
    • BETTER_AUTH_SECRET_APP and BETTER_AUTH_SECRET_ADMIN on router-africa-dashboard-api-staging and -production.
  • Still to set, from item 21’s accounts: TURNSTILE_SECRET_KEY and RESEND_API_KEY on both dashboard-api Workers (required outside development), and optionally GOOGLE_CLIENT_ID with GOOGLE_CLIENT_SECRET. The Turnstile site key goes in wrangler.toml vars.

  • Loop: paused at Q3.8 at the operator’s request.

  • Turnstile and Resend: TURNSTILE_SECRET_KEY and RESEND_API_KEY are set (the operator). On #37:

    • the Turnstile site key 0x4AAAAAAFvpwGmdvGtZ7GcH (one site for both hostnames);
    • EMAIL_FROM: production notifications@router.africa, staging staging-notifications@router.africa;
    • nodejs_compat on apps/api.

    The dry run passes for both Workers in both environments.

  • Google sign-in: later, by the operator’s choice.

P0.08. Server work, agent part — done (in review)

Section titled “P0.08. Server work, agent part — done (in review)”
  • Asked for by the operator on 2026-11-02 (“server work”), lifting the earlier exclusion for this task.
  • Code: #57, based on main:
    • Bifrost values: production exactly as running, staging with no ingress and its own secrets;
    • CloudNativePG operator 1.30.1 and Postgres 17.11 per environment, with production WAL archiving plus daily base backups to R2, kept 30 days;
    • the niobi-proxy chart skeleton;
    • the runbook infra/README.md.
  • Checked: helm template and helm lint locally (Helm 4.3, real charts). Nothing was run on the droplet.
  • Operator next: infra/README.md step 1 (measure) on the droplet, and send the output.
  • Revised the same day on the operator’s decisions (decisions log, Daily backups; no staging Bifrost):
    • production is backed up once a day (a pg_dump CronJob to R2, kept 30 days by a lifecycle rule), not with continuous archiving;
    • no staging Bifrost (its values are removed), so P0.11 no longer applies;
    • a staging mock gateway is queued as Q3.9.
  • Installed by the operator on the droplet, following infra/README.md:
    • production Bifrost is under tracked values (diff empty);
    • the CloudNativePG operator is in place;
    • the staging and production app databases are healthy, with helm test passing;
    • the daily backup is set up, and its first dump reached R2.
  • Memory: 1693 Mi still available. Recorded in as-built section 15, and P0.08 is marked done.
  • Before P0.09/P0.10: add memory or swap, since the droplet has no swap. Then reboot for the pending Ubuntu updates.

P0.10. Tunnel and private access, agent part — done (in review)

Section titled “P0.10. Tunnel and private access, agent part — done (in review)”
  • Code: #60, based on #57:
    • the cloudflared chart (2 replicas, outbound only);
    • the Bifrost route-split allow-list (exact routes from Bifrost’s OpenAPI; tested locally with the real nginx config, 18 of 18 cases as intended);
    • the runbook: create the tunnel, install both charts, and create four VPC Services (production gateway inference and management, plus Postgres for staging and production).
  • For the operator to confirm:
    • nginx instead of Traefik for the route split, because K3s’s Traefik also serves production Bifrost;
    • certificate verification off on the Postgres VPC Services (private CA; Workers VPC can’t take one yet; Origin CA is the follow-up).
  • Hyperdrive configs wait for the database roles (P1.04/P1.06).
  • Operator next: infra/README.md P0.10 step 1, then send the outputs and the four service IDs.
  • Installed by the operator:
    • the tunnel router-africa-cluster is healthy, with 2 connectors;
    • the route split is running; in the cluster, inference /health gives 200 and management /api/providers gives 404;
    • four VPC Services exist (IDs in as-built section 16).
  • Bindings: the production gateway bindings are on #64 (GATEWAY_INFERENCE, GATEWAY_MANAGEMENT), and the dry run passes. The Postgres service IDs wait for Hyperdrive (P1.04/P1.06).
  • Confirmed by the operator (2026-11-02): nginx for the route split, and no certificate check on the database links. Decisions log: Route split in nginx; database links without certificate checks.

P1.06. Database roles and Hyperdrive, agent part — done (in review)

Section titled “P1.06. Database roles and Hyperdrive, agent part — done (in review)”
  • Code:

    • #62, on #55: migration 0009 grants api the request-path tables only, dashboard all of core plus read and append-only audit and job runs in logs, and consumer the request logs and rollups plus api_keys.last_used_at. The queue consumer moves to HYPERDRIVE_LOGS. A test per role passes on PGlite and Postgres 17 (suite 326/326 on Postgres).
    • #63, on #60: CloudNativePG managed roles with per-role password secrets, and the runbook (passwords, roles, the staging schema through an SSH tunnel as migrator, six Hyperdrive configs).
  • Production schema: waits for the merged code and the pipeline (P0.09).

  • Operator next: infra/README.md P1.06.

  • Installed by the operator:

    • the managed roles are reconciled in both clusters;
    • the staging schema is applied (10 migrations; grants checked);
    • six Hyperdrive configs exist, bound on #64 (#37 was merged first) (dry run passes).

    Recorded in as-built section 17, and P1.06 is marked done. The production schema waits for the pipeline (P0.09).

Backend stack brought up to date with main (2026-11-02)

Section titled “Backend stack brought up to date with main (2026-11-02)”
  • Asked for by the operator. #64 was merged first (the operator asked). Then main was merged into integration/2026-11-01 and up through #31 → #62, with merge commits (the repo’s practice) and no force-pushes. Every layer typechecks.
  • Resolved:
    • Migrations: renumbered after main’s 0005–0007: billing details 0008 (#32), staff and sessions 0009 (#34, hand-written checks kept), margin 0010 (#52), roles and grants 0011 (#62).
    • #36: #61’s key-auth fix kept, with the request path’s routes and bindings on top.
    • #40 and #48: main’s reviewed job history through LogsStore kept, so #48’s “one write path” part is dropped.
    • #42: the daily-rates job uses main’s rate_sig_figs (#56).
  • Checks at the top: lint passes; dashboard-api 340/340 on PGlite and Postgres 17; apps/api 74; drizzle-kit: no schema changes. One dashboard test timed out under full parallel load and passes alone.
  • Operator: staging’s database has the old numbering and needs a reset, then migrating again.
  • Not yet updated: the UI stack (#14 → #47), the pipeline (#38, #54), the infra stack (#57 → #63), and #16, #18, #19, #22, #24. (All done later the same day except #16; see below.)

The rest of the open PRs brought up to date with main (2026-11-02)

Section titled “The rest of the open PRs brought up to date with main (2026-11-02)”
  • Done:

    • the screens stack #14 → #47;
    • the pipeline #38 (retargeted to main) and #54;
    • the infra stack #57 → #63;
    • #18, #19, #22 and #24.

    All with merge commits, no force. Typecheck runs at every layer; lint, tests and helm lint at the tops.

  • #38: it replaces ci.yml and niobi-proxy-deploy.yml, so main’s hardening of them (#13’s review) moved into its workflows:

    • actions pinned to commits, and gitleaks pinned by digest;
    • a PR scans only its own commits;
    • a new weekly-secret-scan.yml.
  • #16: left alone. It looks replaced by #59; waiting for the operator.

Q3.8. Usage-events consumers on — done (in review)

Section titled “Q3.8. Usage-events consumers on — done (in review)”
  • Code: #68, on #62.
    • Consumers on in both environments: batches of 100 or 5 s, 5 retries, then usage-events-dlq-<env>.
    • A USAGE_EVENTS_DLQ producer sends malformed events there at once.
    • niobi-callbacks stays off (P6.03).
  • Tests: test/queue-config.test.ts; the dry run passes for both environments.

Q3.9. Staging mock gateway — done (in review)

Section titled “Q3.9. Staging mock gateway — done (in review)”
  • Code: #69, on #68. The new packages/gateway holds createMockGateway(), which is stateless:
    • canned completions, JSON or SSE with a usage chunk;
    • usage priced from its own three-model list;
    • [mock:<reason>] in a message returns that catalogue failure;
    • credentials issued with no gateway behind them.
  • Wiring: GATEWAY_MODE = "mock" in both Workers’ staging vars. A new Gateway.reconciles: false makes the key and usage reconciliations skip it.
  • Tests: 7 in the package; the OpenAI SDK through apps/api on the mock; the registry skips.

P3.01 (with P2.03). Bifrost adapter — done (in review)

Section titled “P3.01 (with P2.03). Bifrost adapter — done (in review)”
  • Code: #71, on #69, plus #70 on #63, which adds GET /api/models/details to the gateway allow-list. Built against Bifrost v2.2.3’s OpenAPI. The PR description has the details:
    • inference with x-bf-vk and x-request-id, no retry, a header timeout;
    • only content-type passed back, and extra_fields and cost scrubbed from bodies and SSE chunks;
    • errors mapped to the catalogue with no message text;
    • virtual keys named ra:<keyId>, models with costs, logs paged oldest first.
  • Tests: 21 against a scripted Bifrost; the OpenAI SDK through apps/api and the adapter.
  • To verify live (P0.13):
    • the allowed_models naming;
    • that PUT replaces provider configs;
    • the budget error type;
    • whether management needs BIFROST_MANAGEMENT_AUTH;
    • that x-request-id becomes the log id.
  • Question for the operator: Bifrost budgets need a reset period, and our admin cap has none. The adapter uses monthly (1M). Keep it?
  • Blocked on the operator:
    • P0.09 (runner): the droplet needs swap or 8 GB first;
    • P0.13 (the private path from a deployed Worker): needs a deploy, which the agent may not do;
    • Q3.7 (Maansa): needs the docs and an account.
  • Waiting on the operator: #16 (close?), the budget period, applying #70 after merge, and the staging database reset (status file, item 1).