Console has been deployed since 2026-10-14 but sign-in never worked: SCRIBASE_URL
was baked to the Scribase control-plane API (api.scribase.com) instead of a real
project's own gateway, because no project had ever been provisioned for it.
Also fixed a real, unrelated bug found while provisioning: the control-api's
real-time project-runtime image (scribase-project-runtime:local) had been
reclaimed by a routine docker image prune (it has no running container, so it's
unprotected) -- this broke every new Scribase project, temp or paid, not just
this one. Rebuilt it on box 1 via the documented narrow compose step.
Provisioned a real (temporary, 72h TTL) Scribase project for the console via
`npx scribase init --temp --yes` against production, applied all 14 of
db/migrations/*.sql against it via the real database/execute API (0007_ship.sql
had a literal backslash in a regex that the SQL-execute endpoint's injection
guard rejects outside E'...'/$$...$$ -- rewrote `github\.com` as the
behaviorally-identical `github[.]com` character class; existing tests already
only check accept/reject behavior, unaffected), and wired the real anon/service
role keys via `wrangler secret put`.
Deployed (version 49f09f0f-d84b-4379-acc4-d1a78df81a90) and verified end to end:
a real POST to /auth/email now reaches the real gateway's /auth/v1/otp (confirmed
by direct curl to the gateway, bypassing the app) and correctly hits GoTrue's own
over_email_send_rate_limit after repeated test calls -- proof the full
app -> SCRIBASE_URL -> gateway -> GoTrue chain is for real wired correctly, not
the prior 404 "route not found" / zero-project-exists failure.
Remaining real step (not done here): this project is temporary and expires in
72h. A permanent one needs either a real SCRIBASE_ACCESS_TOKEN for the
ereboslab org, or the $1 Dodo card-check "Keep this project" flow at the
project's claim URL -- both genuinely owner-gated (2FA / a real card), see
plans/railyard.md and apps/console/DEPLOY.md for the exact next step.
Closes backlog item 4: Rithub (apps/gitea, live at git.ereboslab.com) had
zero discovery or signup surface. A signed-in Console session now
provisions a dedicated Gitea user, private org and first repo in one call
(lib/gitea.ts, admin API with sudo= impersonation), via a new public
/rithub landing page and POST /api/v1/rithub/provision route. Signed out,
the CTA goes through the same cross-sell sign-in bridge as items 1/2;
signed in, it closes the loop item 5's OIDC provider opened ("one sign-in,
not a second account").
Verified against a real gitea/gitea:1.23 container: user/org/repo creation,
sudo impersonation, slug-collision retries and the route's idempotency
check all confirmed live. tsc clean, npm test 167/167, npm run test:bundle
3/3 (including a full client build).
- Apps tab: one-click Mint ledger account per app (POST /v1/accounts
already existed on Mint; the gap was the UI), db/migrations/0012.
- Console is now a real OIDC provider for Rithub (Gitea) SSO: RS256
id_token + self-contained access_token over the authorization-code
grant, single-use codes (db/migrations/0013), discovery/jwks/
authorize/token/userinfo routes. A visitor who isn't signed in yet
is bounced through existing sign-in and lands back on /oidc/authorize
automatically. Gated on RAILYARD_OIDC_SIGNING_KEY/RAILYARD_OIDC_CLIENTS
(scripts/gen-oidc-key.mjs generates the former); unset, every /oidc/*
route is a clean 503.
- Public, numbers-backed /compare/relay-vs-openrouter page with a
spend-tier pricing table and a Console-signup CTA using the existing
cross-sell attribution bridge.
Verified: tsc clean, full `npm test` (167) and `npm run test:bundle`
(3) green; a scratch script exercised the OIDC code/token/userinfo
flow end to end against real generated RSA keys (found and fixed a
missing email_verified claim); `next dev` used to curl every new
route live (discovery, jwks, authorize's 400s and sign-in detour,
token validation, userinfo auth, the comparison page, the mint-account
API).
Prefilled /auth/start?email=&src=insights deep link from the Insights
dashboard banner into Console signup, with first-touch attribution
recorded on the new org (migration 0011, signup_source column) so the
only proven self-serve funnel (Insights) now converts into Console
signups instead of dead-ending.
- packages/cli/src/domains.mjs: a dependency-free client of Cloudflare's
public Workers Custom Domains API (zones lookup, PUT/GET/DELETE
/accounts/{id}/workers/domains, certificate pack state). Cloudflare
issues the TLS certificate; a domain reads active once it is. The token
goes in the Authorization header only and is scrubbed from every error.
Byte copy at apps/console/lib/ship/cf-domains.mjs (drift test).
- railyard domains [add|remove HOSTNAME] [--app]: the console attaches the
hostname to the app's production Worker with the org's Cloudflare grant
(the QY1.1 OAuth step; the access token is opened and used inside the
console only). Without a grant (409 no_cloudflare_grant) the CLI does the
same with the local login (CLOUDFLARE_API_TOKEN or the wrangler login
file after `wrangler whoami`) and the console records the outcome. Adding
an attached hostname keeps it; one on another Worker is refused; remove
is idempotent; a hostname outside the account's zones is refused plainly.
- Console: migration 0010 railyard.app_domains (one org per hostname,
lower case, cascade, RLS, no anon); GET/POST/DELETE /api/v1/domains and
POST /api/v1/domains/record (CLI bearer); states refreshed from
Cloudflare when the org has a grant. Cloudflare OAuth default scopes add
zone:read and ssl_certs:write (orgs linked before need to run
railyard link once more for console-side domains).
- Scribase bridge: new signed route domains {scribase_org_id, app?} ->
{available, domains:[{app, hostname, state, checked_at, created_at}],
next} for the Deploy tab; contract fixture v2 adds it (additive).
Tests: CLI 23/23 (new domains.test.mjs 5: grant path with the real console
handlers and a fake Cloudflare, local-login path, wrangler config file,
refusals, idempotent remove, no token printed or sent to the console);
console 147/147 (new lib/ship/domains.test.ts 4: drift, worker naming
equal to the CLI's, attach/detach and cross-org refusal, record and
refresh, bridge listing; 0010 migration on a scratch PG); contract 6/6;
console tsc clean.
Owner-only: one real-domain proof (railyard domains add on a domain in the
owner's Cloudflare account) is not run here; record it at the deploy gate.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- packages/openfeature-railyard/src/targeting.mjs: one dependency-free
evaluator (sync SHA-1, rollout hash = parseInt(sha1("<flag>.<id>")[0:15])
/ 0xfffffffffffffff, inside when <= rollout/100; ordered rules, all
conditions of a rule must match, first match wins with its own value).
Property operators follow the reference matcher of posthog-node (MIT):
exact/is_not (lists, true/false by truthiness), icontains, regex, gt/gte/
lt/lte (numeric, else text), is_set/is_not_set. Segments are named sets of
property conditions per environment (Flagsmith segment shape, BSD-3);
cohorts are product analytics cohort ids. Byte copies with .d.mts types in
apps/console/lib/flags and apps/product-analytics/src/flags (drift test).
- Console: rules and segments live in Railyard's store for both backends
(migration 0009: railyard.flag_targeting, railyard.flag_segments, bounded
checks, cascade, RLS, no anon), so the table fallback and the Flagsmith
backend have the same rule features. setFlag validates rules and segment
references; a used segment cannot be removed; branches copy rules and
segments. The read endpoint takes ?id, ?props (JSON, 2 KB) and ?cohorts,
answers each flag for that person and ships {on, value, rules} plus the
segments used, so SDKs evaluate locally; without a person a targeted flag
reads off (old clients stay safe). Flags screen: rules per flag (everyone,
a property, a segment; cohorts only with RAILYARD_REPLAY_LIVE) with a
share, and segments. POST /api/flags/segments.
- Product analytics /flags: evaluates targeted flags with the person's
stored properties (request person_properties override) and cohort
membership (through person overrides).
- OpenFeature providers and the client: evaluation context targetingKey +
attributes (+ cohorts) resolve per person; cached starts keep rules.
- Contract fixture: flags items carry targeting (additive, version 2).
Tests
- openfeature 16/16: SHA-1 vs node crypto, rollout shares within bounds
over 10 000 ids and monotonic growth, operators, rules, validation, read
answer, client and both providers vs the evaluator, cached start, drift.
- console 142/142 incl. both backends with the same 20 rule sets, segments,
isolation, read-endpoint context, 0009 migration on a scratch PG, and
10 000 ids x 20 rule sets: provider local == read endpoint (0 mismatches).
- product analytics test/qy 10/10 incl. 10 000 ids x 20 rule sets: provider
local == /flags from stored people and cohorts (0 mismatches), and the
unmodified posthog-node local evaluation agreeing on all 18 non-cohort
sets for 10 000 ids (0 mismatches, 0 undecided); a3 experiments unchanged.
- contract 6/6; console and PA tsc clean.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RYP-E3 in Wave P. ADR RY-0004 records the evidence that path A exists
(Cloudflare self-managed OAuth clients, changelog 2026-06-03, authorization
code flow only) and builds it; path B stays the written fallback; path C
stays rejected.
- railyard link: one URL; at most two consents in the browser (install the
Railyard GitHub App on the repo, then Cloudflare's own consent screen with
PKCE), each skipped when done before; then one pull request from the App on
railyard/ship-on-push adding .github/workflows/railyard.yml. Nothing is
pushed to a default branch. The installation id GitHub sends back is not
trusted; the App's view of the repo decides.
- The workflow holds no key: it asks GitHub for an OIDC token (audience = the
console) and runs `railyard ci`. The console checks issuer, audience,
expiry and signature, the stable repository_id, the Railyard workflow ref
only, push/workflow_dispatch on branches only, and a paused org; it answers
with a short-lived Cloudflare access token (sealed refresh token rotated and
resealed; a cached access token reused while 10 min are left).
- railyard ci masks the token first, deploys exactly like railyard deploy,
never opens a login, and reports with a fresh OIDC token. The console
records the deploy (branch and commit from the token) and writes one
preview comment on the branch's pull request, edited on later pushes.
- Signed App webhooks drop links on uninstall or repo removal.
- GET /api/v1/github/manifest creates the App (owner item Y4); the done page
shows one command that pipes the App key into wrangler secrets.
- Migration 0007_ship.sql (idempotent; scratch Postgres only): installations,
links (one per repo), sealed Cloudflare grants, link sessions; RLS on, no
anon/authenticated grants.
- Off until RAILYARD_SHIP_ON_PUSH_LIVE=1 and every name is set (routes 503;
copy stays "arriving" under denylist rule railyard-slot-ship-on-push).
Env: RAILYARD_SHIP_ON_PUSH_LIVE, GITHUB_APP_ID, GITHUB_APP_SLUG,
GITHUB_APP_PRIVATE_KEY, GITHUB_APP_WEBHOOK_SECRET, CLOUDFLARE_OAUTH_CLIENT_ID,
CLOUDFLARE_OAUTH_CLIENT_SECRET, CLOUDFLARE_OAUTH_SCOPES (optional); reuses
RAILYARD_CREDENTIALS_KEY.
Tests: console 122/122 (ship 12, migration 0007 on a scratch cluster), tsc
clean; CLI 18/18 (link and ci 5, copy lint). The 5-minute push-to-live run on
a real repo and Cloudflare account is owner-run.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RYP-E4, dispatch 4.2 PY2.2 (Railyard side):
- lib/watch: checks (public https app addresses only; IPs, private names and
our own hosts refused), 20 per org, a status page slug each. The box 1
agent reads GET /api/v1/watch/agent/checks (ids and URLs only, bearer
WATCH_AGENT_TOKEN) and posts results to /api/v1/watch/agent/results.
Two failures in a row turn a check red; each change emails the owner once
through Rally Send (product railyard, from status@, idempotency key per
change; a failed send is retried on the next result). Older, unknown and
future results change nothing.
- /status/<slug>: live results only (state, share of the last checks, bars),
the check's name and never its address or any host or vendor name.
- The Watch screen: add by address, pause or resume, open the status page.
- Bridge route uptime (contract cases, uptime_check_keys): a check for the
given address, or the app's latest live deploy; the first result is the
slot's proof (check_result).
- Gated on RAILYARD_WATCH_LIVE (denylist rule railyard-slot-watch): off, no
check runs, the pages 404, the nav has no Watch item and the slot answers
arriving. The copy test lints each gated surface with the flag and proves it
checks the flag first.
- Migration 0006 (watch_checks, watch_status; https only, history capped at
90, cascades with the org).
Tests: watch 10/10, bridge 25/25, contract 3/3, migration 7/7 (0006 twice on a
scratch cluster), watch copy 7/7, console 108/108 with the bundle build,
tsc clean, SDK 7/7.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RYP-E2 and SP-E6, dispatch 4.2 PY2.1 (Railyard side):
- lib/flags: flag environments per app environment (a Scribase environment
or branch), each with a public client key that reads that one environment.
Two backends, one surface: the unmodified Flagsmith server (one Flagsmith
organisation per Railyard org, a project per app, an environment per env;
FLAGS_API_URL + FLAGS_ADMIN_TOKEN) and, as the fallback the dispatch names
when the box 2 gate keeps Flagsmith down, the console's own tables
(migration 0005). An environment keeps the backend it was made on.
- A branch environment starts with its parent's flags (copy_from), then
changes alone.
- GET /api/v1/flags/client?key=: CORS-open, cached 15 s when keyed by URL;
the first read by an app is the slot's proof (first_flag_read).
- Bridge route flags (contract: id_format, three cases, flags_item_keys);
BRIDGE_SLOTS.flags landed.
- The Flags screen (nav item) flips with one click and adds a flag by key;
POST /api/flags writes only the signed-in org's environments.
- packages/openfeature-railyard: a zero-dependency polling client (30 s,
offline start from storage, back-off) and OpenFeature client and server
providers, with Expo and Next.js examples.
Tests: flags core 11/11 (both backends, a fake of the Flagsmith API, tenant
isolation, branch copies, a 502 that leaves nothing half made), bridge 19/19,
contract 3/3, migration 6/6 (0005 twice on a scratch cluster), console 85/85
with the bundle build, tsc clean, SDK 7/7 (a flip reaches the app within 60 s
in the worst cache timing on a fake clock; copy lint on docs and the screen).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contract scribase-bridge version 2:
- webhook-id is msg_<route>_<24 hex>; the id is inside the Standard Webhooks
signed content, so a signature made for one route is refused on another
(401, fixture wrong_route). ai and ai_usage cannot be confused.
- every orgs request carries addon.as_of (Scribase's epoch ms of the state).
Railyard stores it (migration 0004, addon_as_of) and applies a sync only
when no newer state is stored: one guarded PATCH through PostgREST. An older
sync answers 200 with stale: true and changes nothing.
- RAILYARD_BRIDGE_ACCEPT_LEGACY=1 (default off) accepts the P1 sender for the
minutes between the console and control-api deploys; it never lets an id
that names another route through.
Tests: bridge 15/15 (3 new), contract 3/3 with the new cases, postgrest-repo
and migration 11/11 (0004 applied twice on a scratch cluster, guarded update
proven in SQL), console suite 66/66, bundle 3/3, tsc clean.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Railyard side of PY1.4 (ADR RY-0003). Acceptance:
1. Bridge `ai` gives a Scribase project environment one key (ry_ai_..., shown
once, to the Scribase control plane only, stored here as SHA-256; `rotate`
revokes the old one) and a one-time link to /connect/ai (15 minutes), the
only place a provider key is typed. It is sealed with AES-256-GCM under
RAILYARD_CREDENTIALS_KEY, bound to org and provider, and only a
four-character hint is ever read back.
2. BYOK only: POST /api/v1/ai/chat/completions (OpenAI-compatible) refuses
with 403 byok_required when the org has not connected the provider the
model names, and never calls Relay then. When it does call, the customer's
key fills that provider's slot and every other slot carries a refusal
marker, so Relay (caller credential wins) can never use our keys, not even
on failover; a test pins the slot list to Relay's PROVIDER_KEY_SLOTS.
Credentials in a request body are refused.
3. Daily and monthly token caps per key (429 with the period); usage (atomic
rpc) and one trace per call (model, provider, status, tokens, latency),
read per project key by the bridge `ai_usage` route for the Scribase tab;
Relay traces carry tensorzero::tags for the same filter.
4. Copy says "your provider bills you directly"; no credits are included
anywhere (copy lint over the connect page and every gateway message).
apps/relay/config/tenants/README.md records the tenant rules.
Migration: apps/console/db/migrations/0003_ai_gateway.sql (idempotent;
applied twice to a scratch local cluster by test/migration.test.ts).
Env: RELAY_URL (var), RELAY_TENANT_KEY, RAILYARD_CREDENTIALS_KEY (secrets).
Tests: console 63/63 (gateway 6, bridge 12, migration 3, repo 5), tsc clean,
tests/contract 3/3.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PY1.0 acceptance (C8 delta check on main f919636; Wave E Y-0 to Y-5 merged):
1. Denylist .3 (gtm/policy, published by this package) adds portfolio-ott-drm
and portfolio-ott-comparison (DRM, Netflix-style, your own Netflix beyond
Menivor), addon-unlaunched (ADDON_LIVE), rally-capacity-purchase
(RALLY_CAPACITY_PURCHASE_LIVE) and at-cost (allowed only next to a live
price source). Re-vendored byte for byte; every new rule has failing
fixtures (policy/test/fixtures/denylist-3-new-phrases.json); .2 fixtures kept.
2. apps/console/app/api/v1/bridge/scribase/{orgs,claims,proof}: signed
(Standard Webhooks, RAILYARD_SCRIBASE_BRIDGE_SECRET), replay-proof calls from
Scribase control-api. The first call creates the Railyard org bound to the
Scribase org id (deterministic owner id, no second sign-up) and mirrors the
add-on into the entitlement (plan "addon"); a lapsed add-on pauses the org
and keeps its data. Keys go only to the Scribase CLI: a claim is a one-time,
pre-approved device code (120 s) exchanged at /api/v1/device/token; a grep
test keeps every bridge handler free of stdout, stderr and log writes.
3. proof answers {slot, state, live, proof:{kind,id,at}, next}; slots whose
package has not landed answer "arriving".
Contract: tests/contract/fixtures/scribase-bridge/contract.json, run by
tests/contract/scribase-bridge.test.ts; the Scribase carve-out tests the same file.
Migration: apps/console/db/migrations/0002_scribase_bridge.sql (idempotent;
applied twice to a scratch local cluster only by test/migration.test.ts).
Env: RAILYARD_SCRIBASE_BRIDGE_SECRET (secret; unset keeps the bridge off).
Tests: console npm test 48/48, tests/contract 2/2, policy 11/11, cli 9/9, mcp 9/9,
tsc --noEmit clean.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Next.js console for Cloudflare Workers (OpenNext config, wrangler.jsonc)
with data in the console's own Scribase project, schema railyard
(migration 0001: orgs, org_members, apps, deploys, entitlements,
billing_events, api_tokens, device_codes; idempotent, RLS on, no anon
grants).
- Sign-in with Google or GitHub through Scribase Auth (PKCE), user read
from the auth server, org and entitlements row created, signed
HttpOnly session.
- Money ladder (pure, immutable): $1 card check credited back to the
customer wallet, 14-day trial with the plan's limits, $19 a month or
$190 a year, pause switch and one-click cancel (ends at the next
billing date; a trial ends now).
- Webhook: Standard Webhooks signature and timestamp verified, replays
ignored by unique message id, signed checkout metadata, other brands
ignored, a refund of the card check reverses the credit and the
trial, a failed wallet call releases the id for the provider's retry.
- Apps, Usage and Billing screens, one primary action each; Add app
shows the deploy command and the Insights tag in two clicks.
- CLI device-flow login and org-scoped hashed tokens for Y-3.
- Test mode only: the live payment host is refused unless the owner
sets RAILYARD_DODO_LIVE=1.
Tests (node --test, 25): journey from sign-in to entitlements and the
snippet, refund, pause and cancel, webhook security, ladder, tokens and
org isolation, PostgREST repo, a component test of Add app with the copy
lint, a next build grep for sentinel secrets in the client bundle, and
the migration applied twice on a scratch Postgres.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>