Skip to content

backend setup --analytics basin|duckdb, --ingest, backend migrate (plans/35, 0.19.0) - #44

Merged
phasenull merged 3 commits into
mainfrom
feat/backend-migrate-sinks
Nov 15, 2026
Merged

phasenull merged 3 commits into
mainfrom
feat/backend-migrate-sinks

Conversation

@phasenull

Copy link
Copy Markdown
Member

CLI side of plans/35 (backend move and scale-out), built to the plan's Contracts B and C and the A/B migration job contract. Version 0.19.0.

Sink switch (Contracts B)

  • backend setup --analytics basin --events <url> --recordings <url> writes analytics = { backend: "basin", events, recordings, token, ...dials }. The token is BASIN_SEND_TOKEN from env / .env (never a flag, never printed). backend stays as the fleet API.
  • --analytics duckdb moves analytics back to the backend.
  • Without --analytics, the record's sink is kept. 0.18 replaced a Basin sink.
  • With a Basin sink, the key check only needs the fleet part (checkBackendEndpoint({ parts })), so a TYPETORCH_PARTS=fleet backend passes. The streams are checked too. doctor does the same.
  • The setup reads the record first, only to choose the checks. The write starts from the verified record and is refused if that record's sink or ingest address changed in the meantime, so nothing is written unchecked.

--ingest <url> / --ingest none (Contracts C)

  • Optional backend.ingest, checked unless --force: /healthz, plus the game key must get role game from /v1/auth/check. Without the flag the address is kept and checked again.
  • The old analytics duckdb section still points at backend.url.

typetorch backend migrate

  • Start a move: --from <url> (TYPETORCH_OLD_ADMIN_TOKEN), --from-basin (CLOUDFLARE_ACCOUNT_ID, BASIN_BUCKET, BASIN_SQL_TOKEN, BASIN_NAMESPACE), or --to-basin [--events --recordings] (BASIN_SEND_TOKEN; the streams default to the record's). Optional [--rows-per-second].
  • Manage it: status [--json] [--watch], pause, resume, cancel, resolve <page> resend|skip.
  • --from checks first: the old server's /healthz and that the token is admin there. --force skips these checks. It refuses --from equal to backend.url, and warns when the signed record still points at the old URL.
  • A 501 prints "this backend doesn't support it yet: update it".
  • status shows the steps, a bar and percent, rows/s, the cap, the days to go and an ETA. The per-day report gives counts per table and lists every missing / differs / duplicates day. It also shows waitingFor, the decision with both resolve commands, and error.
  • --watch polls every 5 s, each call has a 10 s timeout, and Ctrl+C exits cleanly.
  • New secrets BASIN_SEND_TOKEN, BASIN_SQL_TOKEN and TYPETORCH_OLD_ADMIN_TOKEN are in SECRET_VARS: scrubbed from output and never passed to a child process.

Tests

  • New test/backend-move.test.ts, 14 tests against mocked servers:
    • the sink is kept / replaced / restored, the record stays signed (sig + sigF) and passes bodyProblems;
    • the race guard;
    • --ingest set / kept / removed;
    • exact start bodies for all three directions and for pause / resume / cancel / resolve;
    • secrets never appear in the output, and a --token flag is refused;
    • status rendering for running, needs_decision, done, failed and idle;
    • --watch, Ctrl+C, retries.
  • bunx tsc --noEmit clean, bun run build ok, node scripts/smoke.mjs passes.
  • Full bun test: 884 pass, 6 fail. All 6 also fail on main 84e73d8 in this environment:
    • 5 s timeouts in migrate.test.ts, debug-macros.test.ts and kernel-luau.test.ts;
    • the backend bless test, which depends on test order.

Notes

  • The emergency guide's warning that Basin games must not run backend setup is no longer needed with this CLI.
  • The --ingest key check needs ingest-role nodes to answer GET /v1/auth/check. Contract C's list of ingest routes doesn't include it; otherwise use --force.

🤖 Generated with Claude Code

phasenull and others added 3 commits November 15, 2026 21:24
…e (plans/35)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…backend migrate; 0.19.0 (plans/35)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d, not written unchecked

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@phasenull
phasenull merged commit cff9bad into main Nov 15, 2026
1 check passed
@phasenull
phasenull deleted the feat/backend-migrate-sinks branch November 15, 2026 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant