Vendors ai-knowledges/evren/decision-core's HTTP/parsing wrapper
(apps/console/lib/evrenDecisionCore.ts, this repo is a standalone deployable
with no shared workspace) and swaps the hand-rolled fetch+AbortController+
parsing boilerplate in apps/console/lib/eventAnomaly.ts for callSystemOne/
parseScoreAnswer/parseChoiceAnswer. Same inputs, same decision semantics,
same exported surface (EventAnomalyDeps/classifyEventAnomaly/
classifyAppEventAnomaly/groundEventAnomalyReason/finalizeEventAnomalyReason)
-- live-verified against the real /v1/systemone gateway with a deliberate
severe-spike case (correctly clamped to severe_spike) and a no-baseline case
(correctly forced to normal_variance), matching the pre-refactor grounding
rules exactly.
Adds lib/eventAnomaly.ts: classifies each app's current-period event volume
against its own trailing 30-day baseline (normal_variance / traffic_spike /
traffic_drop, with a severity score) via Evren's /v1/systemone gateway
(model "laya"), same wire contract and module shape as bidstage-tenders'
evren-fit.ts, sahibinden's evren-risk.ts and homeplan's architectFit.ts.
The current/baseline features (current_events, baseline_mean_daily, ratio,
day_of_week, app_age_days) are plain arithmetic over two real
insightsClient.summary() calls, never trusted to the model.
groundEventAnomalyReason/finalizeEventAnomalyReason clamp the model's
claimed reasonCode against that real ratio in both directions (unsupported
spike/drop claim downgraded; a normal_variance call contradicted by a
clearly extreme real ratio upgraded) -- live-verified against the real
gateway (2026-11-05) that this correction is not just defensive: on 6 real
test vectors spanning normal/spike/drop/no-baseline/borderline cases, the
model's own `reason` choice answered `severe_drop` in 5 of 6 regardless of
the real evidence (gateway-reported confidence ~0.04, near-uniform
probabilities every time) -- the ground+finalize pipeline is what makes the
final per-app classification correct in every case, not the raw model call.
Wires into apps/console/lib/config.ts (EVREN_LLM_API_KEY, optional,
fail-open, added to SECRET_ENV) and lib/deps.ts, and surfaces the worst
real per-app anomaly as a badge on the Usage page next to "Events this
month", reusing the existing capMessage/insightsView wiring point.
Additive only: a gateway outage, bad response, or missing key never
changes the existing event count or cap note. Not deployed.
The Insights cross-sell banner, the Rithub landing page, and the
Relay-vs-OpenRouter comparison page all link straight to
`/auth/start?src=<slug>` with no `provider`/`email` for a logged-out
visitor (the normal case). That hit the fallback branch, which returned
a developer-facing `400 Pass ?provider=google|github or
?email=you@company.com` instead of taking the visitor anywhere — every
"Start free" / "Open Railyard Console" CTA on those pages 400'd for any
visitor without a known email, independent of the separate
Scribase-project outage already tracked in plans/railyard.md.
Per the GTM campaign-workflow playbook's "ad claims vs current product
page" / "follow a test submission end to end" checks
(plans/gtm/_archive/CAMPAIGN-WORKFLOW-90D-2026-10-10.md), redirect to
the real sign-in page instead, preserving the `src` attribution cookie
the same way the provider/email branches already do — `auth/callback`
and `lib/email-signin.ts` read that same cookie at completion time, so
attribution is unaffected.
Verified live: built with real required env vars (prerender-clean, all
4 OIDC routes included), ran `next start`, and curled the exact CTA
URLs used by the three pages — pre-fix returns 400, post-fix returns
302 to the sign-in page with `ry_src` set correctly.
Events this month always rendered the static empty-state copy regardless
of real traffic. Call insights.summary() (already exposed via deps()),
sum month_events across apps and show it against the entitlement's
eventsLimit, with lib/caps.ts's capMessage for the near/at-cap note -
the same data the Insights page already computes via insights-view.ts.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
See plans/railyard.md's 2026-10-27 entry — npx scribase init --temp provisions
a real project with zero interactive steps; done, migrated, deployed, verified.
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.
L8 ("Embeddable replay") was tracked as MISSING/not started in the repo's
own parity recount (docs/parity/recount-2026-10-15.txt). Session replay
already existed, but the only share surface was a 10-minute,
console-origin-only signed link -- no way for a customer to paste a
recording into their own support tool, status page or doc, which is the
actual point of an embeddable player for a product-analytics add-on to
spread to more surfaces.
Add a second, explicit link scope to the existing signed-link primitive
(src/replay/shared/signed-link.ts): "console" (unchanged, <=10 min,
frame-ancestors restricted to PA_CONSOLE_ORIGIN) and "embed" (new, <=7
days, frame-ancestors *). The scope is mixed into the HMAC, so a console
link can never be replayed as an embed and vice versa -- proved live.
New console API POST /v1/projects/:id/replays/:session/embed (writer
role only, default 24h/cap 7d) returns a URL and a ready-to-paste
<iframe>. New player routes /player/embed/replay(/events) serve the same
masked recording with the permissive CSP, verified by scope.
Verified for real (no test files added per instructions): typecheck
clean, full existing apps/product-analytics suite green (225 tests, 221
pass, 4 skipped only for an uncached Chromium, 0 regressions), and a
throwaway local harness run (scratch Postgres + the real service) proving
end to end: a viewer role is refused /embed (403), an owner mints a link
with iframe_html and a capped expiry, the embed page answers 200 with
frame-ancestors * and no inline script, its event stream replays the real
recorded event, a console-scoped link 403s at /player/embed/replay and an
embed-scoped link 403s at /player/replay, and ttl_hours is capped at 7
days.
Not deployed: product-analytics has no live deployment anywhere yet
(confirmed on railyard-box: no product-analytics container exists next to
mint/rago/relay/insights) -- it ships together with the console, which is
itself blocked on provisioning the "railyard-console" Scribase project
(see the console post-mortem below).
Also corrects apps/console/NOTES.md: tried to deploy the already-merged,
already-tested GET /api/v1/rail/status (c3b7edcf) to the live
railyard-console Worker. Fixed the local toolchain (corepack prepare
pnpm@10.30.3 --activate; no keys file needed, wrangler deploy never
touches the 4 secrets already live since 2026-10-14) and built/deployed
clean -- but current main's own SCRIBASE_URL guard (lib/config.ts,
intentional, added in a72111e9) then 500d every route including `/`,
because the real railyard-console Scribase project has never been
provisioned. Rolled back immediately to the last known-good version
(3c6adda0) and verified `GET /` is back to 200. Corrected NOTES.md so the
real blocker (one owner-only Scribase signup/project-creation step, not
tooling) isn't mistaken for a tooling problem again.
pnpm-lock.yaml: brought into sync with already-declared apps/insights-edge
dependencies (rrweb, rrweb-player) that were missing their lockfile
entries; no version changes to anything else.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Consumer products (Rally, Menivor, Scribase, ...) and operators currently
have no single place to ask "is the rail actually up" -- they'd have to
probe Mint, Rago, Relay and Abacus separately before routing real traffic.
Adds lib/rail-status.ts (pure, injectable fetch per the repo's own transport
invariant) that checks every configured service in parallel with a bounded
per-service timeout, and GET /api/v1/rail/status that wires it to four new
optional env vars (MINT_HEALTH_URL, RAGO_HEALTH_URL, RELAY_HEALTH_URL,
ABACUS_HEALTH_URL -- unset services read "not_configured" and are excluded
from the verdict, so this degrades cleanly on any partial deployment).
Overall reads ok/degraded/down/unconfigured; HTTP status is 200 for
ok/degraded and 503 for down/unconfigured so a caller that only checks the
status code still gets the right answer without parsing the body.
TDD: 7 new tests in lib/rail-status.test.ts (all services healthy, one down
degrades the rest, a thrown network error reads down not an unhandled
rejection, a hung service times out instead of blocking forever, an unset
service skips the network call and is excluded from the verdict, zero
configured services reads unconfigured not a false ok, every service down
reads down). Full console suite: 166 pass (164 + the pre-existing env-only
failure in add-app-component.test.ts, unrelated -- missing root node_modules
in this sandbox, not a code regression).
Not deployed: the console Worker's deploy needs
~/.config/products-keys/railyard-console.env (not present on this machine)
and a working wrangler/pnpm toolchain (corepack's pnpm cache is broken here,
and the workspace root node_modules does not exist), so this could not be
shipped to railyard.ereboslab.com from this session -- noted in NOTES.md.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Rithub (apps/gitea) was proven locally on 2026-10-15 but never shipped, so
the Nav's "Code" link 404'd and an earlier fix (b16fd286) papered over it by
pointing at the public GitHub mirror instead. Deployed it for real:
- docker compose stack live on railyard-box (/srv/railyard-gitea): web on
host port 3350, Postgres on 5434 (3300/3400/3100/5433 were already taken
by rago/mint/relay/the shared Postgres), admin account created.
- Fronted by Caddy (infra-box/caddy/sites/gitea.caddy, CADDY_SITES += gitea)
with a Let's Encrypt cert, not the Cloudflare Tunnel the original RUNBOOK
draft proposed -- every other box service (rago/relay/mint/errors) already
uses plain Caddy + a proxied Cloudflare DNS A record, so this follows that
proven pattern instead of a new one.
- DNS: git.ereboslab.com -> 130.61.113.116 (not git.railyard.ereboslab.com --
no other service here uses a "railyard." prefix; corrected throughout
apps/gitea's docs and defaults).
- Verified live: https://git.ereboslab.com/ 200s, title "Rithub (by
Railyard)", logo/branding assets 200.
Nav.tsx/config.ts default back to the real URL; RAILYARD_GIT_URL still
overrides it. SSH-over-2222 still needs the one OCI security list rule
(owner step, documented in deploy/RUNBOOK.md) -- HTTPS clone/push and the
web UI work today without it.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
apps/gitea (Rithub) was proven locally on 2026-10-15 but never shipped to
railyard-box: no gitea container/env on the box, no DNS for
git.railyard.ereboslab.com, and the box-tunnel TUNNEL_TOKEN that would
publish it is still blank. The Nav's "Code" link has been pointing there
since 97827bb4/8d3ab266, so it 404s for every console user.
caelum0x/railyard is public now (README/LICENSE/CONTRIBUTING shipped for
OSS distribution), so point the default at that real, live repo instead.
RAILYARD_GIT_URL still overrides it once apps/gitea actually deploys.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
railyard-console was deployed live on 2026-10-14 (railyard.ereboslab.com
returns 200) but sign-in has been silently broken since: SCRIBASE_URL is
set to https://api.scribase.com, the shared control-plane/management API,
not a project's own gateway host, so POST /auth/v1/otp there 404s. Verified
directly against the box's Scribase DB that no project exists for the
console at all yet (zero rows for organization_id='ereboslab').
Add a config-read guard + test so this exact misconfiguration fails loudly
on the next deploy instead of shipping a console that renders but can
never sign anyone in, and correct DEPLOY.md/README.md's stale "never
deployed" / "no action needed" claims to match verified reality, with the
missing owner step spelled out (replace SCRIBASE_URL with the real
project's api_url once provisioned).
Not deployed: redeploying the guard alone, before a real SCRIBASE_URL
exists, would turn today's "page loads, sign-in silently fails" into a
500 on every request, which is worse. Provisioning the real project is
confirmed owner-gated (needs a working SCRIBASE_ACCESS_TOKEN for the
ereboslab org; none found on this machine), matching migration 0001's own
header, not an oversight.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The route read env.SCRIBASE_URL at module load, which made Next try to
statically prerender it at build time with no Cloudflare bindings
available, failing the build. Matches the force-dynamic pattern already
used by every other authenticated route in this app.
First production deploy: railyard.ereboslab.com is live.
Adds Config.gitUrl (RAILYARD_GIT_URL, default
https://git.railyard.ereboslab.com) and a "Code" entry in the main Nav —
an external link, since apps/gitea runs native accounts (no Railyard
session/SSO integration yet, see apps/gitea's TODO(railyard-sso)).
Verified: npm run typecheck clean, npm test 159/159 (was 159 baseline, no
new test count change — the existing Nav.tsx copy-lint test covers the new
link text).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
readConfig() already threw when DODO_API_BASE is the live host and
RAILYARD_DODO_LIVE is unset, but the only covered case was "absent".
Add the case that actually matters before a real deploy: any value
other than the exact string "1" ("true", "yes", "on", "01", padded
whitespace, empty) must still refuse the live host. Pure test addition,
no payment flow or secret touched.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
apps/console is code-complete (typecheck clean, test suite green) and
has never been deployed - the only missing artifact was a reviewable
runbook so the real deploy is one command instead of an investigation.
DEPLOY.md covers: pre-flight checklist (RAILYARD_DODO_LIVE must stay
unset for a test-mode-only first deploy, enforced by lib/config.ts and
covered by test/config-billing.test.ts), the exact wrangler secret put
sequence for all 9 secrets named in wrangler.jsonc's header comment,
the actual build/deploy script names (cf:build / cf:deploy), a verify
step, and rollback (detach the custom domain or wrangler delete, since
there is no prior version to wrangler rollback to on a first deploy).
Not executed this session: no production deploys, per the session's
hard limits.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The destination catalogue had no transforms (recount A23): every destination
got every event with every property.
A destination may now carry a declarative transform, applied by the exports
runner before any send for every kind (webhook, S3, Slack, Discord, HubSpot,
ClickHouse, BigQuery): 'where' keeps the events matching every condition (on
a property, the event name or distinct_id; eq, neq, in, not_in, exists,
not_exists, contains, gt, lt), then 'keep' or 'drop', 'rename' and 'set'
reshape the properties. Events are never mutated in place; the cursor moves
past every row read even when nothing is sent. No code runs, so a transform
cannot reach the network or the database. POST and PUT /exports take it (PUT
with null removes it); the console form has the field.
Also: the surveys and vendor tests resolve the upstream SDK from the
wrapper's own install, else the service's pin of the same version (checked),
so they run on a fresh checkout instead of failing or skipping.
Tests: qy/transforms (unit, refusals, end to end through a webhook,
replace/remove). All product analytics suites (a1, a2, a3, qy): 206 passed,
4 skipped (no cached Chromium on this machine), 0 failed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Exports reached S3 files and webhooks only (recount A22: no warehouse sync).
A project's events can now land as rows in the customer's own warehouse,
delivered by the exports runner like every destination (cursor, retries with
backoff, run log, on/off):
- ClickHouse over its HTTP interface: the table is created when missing as a
ReplacingMergeTree ordered by the event uuid (a retried batch collapses to
one row per event), rows go in as JSONEachRow; user in the clear, password
sealed; database/table names checked.
- BigQuery tabledata.insertAll: the service account key (sealed) signs an
RS256 JWT assertion exchanged for an access token at Google only (token_uri
pinned outside tests); insertId = event uuid; a missing table is created
once with the event schema (JSON properties, day partitions); row errors
fail the batch.
- Migration 0030 allows the kinds; the console's new-destination form and
client mapping offer them.
Tests: qy/warehouse (inputs, ClickHouse rows and isolation, BigQuery sign-in
verified with the public key, table created once, insertIds, a wrong password
is a retried delivery with the warehouse's reason) and the console form
mapping. qy + console suites: 41 passed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
readConfig required all Dodo values, so the console could not start before
the railyard Dodo brand and products exist (owner item Y-2), although
Railyard is sold inside the Scribase add-on (bridge orgs need no checkout).
Dodo values are now optional: billingReady is true only when the key, the
webhook secret and the three product ids are all set. Without them checkout,
pause and cancel redirect with 'card payments open soon', the webhook answers
503, and everything else runs. Scribase project and session secret stay
required. 4 new tests; console 158/158, tsc clean.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The console could only sign in with Google or GitHub, so it could not open
before both OAuth apps exist (owner item Y-2). Add email sign-in: Scribase
Auth mails a one-time code (POST /otp), the console redeems it (POST /verify),
reads the user from the auth server, checks it matches the address, and opens
the same session as the OAuth path. Same-origin checks on both posts; inputs
validated before any call. RAILYARD_OAUTH_PROVIDERS picks the OAuth buttons
(default google,github; empty = email only). 7 new tests, console 154/154,
tsc clean.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- 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>
Alerts and subscriptions (A25)
- PA src/alerts: threshold alerts (above/below a number) and anomaly alerts
(the last complete interval N standard deviations from at least 7 before
it) on any saved insight, watching one headline value per insight kind
(metric.ts). Checked by the service scheduler every minute, each alert at
its own hour or day, leased so two passes never double-send; an alert
emails once when it starts firing and again only after it clears.
- Weekly dashboard emails at a weekday and hour (UTC): an HTML table of each
tile's latest value and the interval before (no images), then the next
weekly slot.
- Mail through the Rally Send transactional contract (Wave E 5.2:
product, project, to, from_local, subject, html, text, idempotency_key,
unsubscribe_url, tags; 202/422/429 read) when RALLY_TX_URL/KEY are set.
The service has no other mail path, so without them each email is
logged as not_configured (never dropped silently) and the console says so.
- Every email has an unsubscribe link (HMAC-signed, GET page or one-click
POST); unsubscribed addresses are skipped and logged; per-recipient mail
log (sent, failed, unsubscribed, not_configured).
- Migrations 0026 alerts, 0027 subscriptions, 0028 mail log and
unsubscribes, 0029 row level security for all four.
- Console: product-analytics/alerts (one screen: alerts and weekly emails,
pause, check or send now, delete, latest emails).
Destination catalogue (A23)
- Slack ({text, blocks}), Discord ({content}, no mentions) and HubSpot
(contacts upserted by email through CRM v3 batch upsert with the
customer's private app token) next to the webhook and S3 kinds
(migration 0025). Each request carries Standard Webhooks headers under a
per-destination signing secret shown once; the target secret (webhook
address or token) is sealed with it and never read back. Delivery,
backoff retries, the run log and the on/off switch are the exports
runner's. Shapes follow PostHog CDP templates slack and hubspot (MIT,
1348173f5911, nothing from ee/); NOTICE updated. Outside dev/test only
hooks.slack.com and discord.com webhook addresses are accepted.
- MAX_DESTINATIONS 3 -> 6 (target) so the catalogue fits; the A3 cap test
follows the constant. Console exports screens list the new kinds.
Also: the A2 lane-scope test now skips QY commits (the QY lane owns RY/
and wires the console on purpose). Deploy fragment and README name
PA_EXPORTS_KEY, PA_PUBLIC_URL, PA_CONSOLE_URL, RALLY_TX_URL, RALLY_TX_KEY.
Tests: product-analytics test/qy 26 (alerts 10 incl. one-tick mail with a
fake clock, anomaly, weekly table, unsubscribe, isolation, not configured,
Rally contract, copy lint of every email, console form mappings;
destinations 3 incl. signatures, isolation, retry with backoff and the
switch; migrations 2) + a3 exports 6 + a1 52/52 + a2 67/67 + a3 49/49;
console 142/142; PA and console tsc clean.
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>
Product analytics (A26, contract 5.3)
- Bridge: new signed route product_analytics {scribase_org_id, app, days?,
with_server_key?} -> host, public key (the site key), first product event,
web view; the server key only when asked, only to the Scribase control plane.
- sites answers analytics_host and analytics_key next to the page-tag values
(nothing of the Insights path removed); insights answers
first_product_event_at; the analytics proof falls back to
first_product_event when no page-tag event came.
- lib/product-analytics.ts: one-app, viewer-scoped org tokens for every call;
PRODUCT_ANALYTICS_PUBLIC_URL (default the SDK default host).
- PA: POST /v1/server/{app_id}/batch with Authorization: Bearer ry_pak_<hex>
(HMAC of the app id under PRODUCT_ANALYTICS_CONSOLE_SECRET, constant-time
check) for server-side forwarders (QU1.4); the public key is refused there.
- Contract tests/contract/fixtures/scribase-bridge/contract.json stays
version 2 with additive QY1.2 keys: product_analytics route and answer
keys, analytics_host section (env names, capture paths, server door).
Web view (A18)
- PA src/web/query.ts: visitors, page views, visits, bounce, daily series,
top pages, entry referrers ($direct), entry UTM, p75 page speed with
ratings, from pa.events under RLS. Shapes follow PostHog web analytics
stats_table (MIT, 7b13402a6350, nothing from ee/), NOTICE updated.
- Console: product-analytics/web screen (range picker, tables, page speed).
/s.js page speed (I7, P-Y12)
- The page tag sends LCP, INP, CLS, FCP and TTFB once per page view
(hidden, pagehide, or before a route change) as a performance event;
data-vitals="off" turns it off. Port of insights-web metrics.ts; metric
definitions per GoogleChrome/web-vitals (Apache-2.0), NOTICE added.
1,620 bytes gzip (budget 3,072).
- With PRODUCT_ANALYTICS_URL the edge collector also forwards every stored
event to product analytics ($pageview, $web_vitals, custom events,
$identify) with cookieless daily ids, no IP, retried on 5xx with the same
uuids, so the web view reads the same store.
Also: lib/ship/ship.test.ts type errors from QY1.1 fixed (doneText helper).
Tests
- insights-edge 34/34 (19 existing + 11 vitals within 10% of
chrome-page-loads.json and 3 KB gzip + 4 forwarding).
- console 135/135; contract 6/6; console tsc clean.
- product-analytics a1 52/52; test/qy 7/7 (web view hand counts, isolation,
edge-shape events, server door, and an end-to-end bridge -> SDK event ->
first_product_event proof: 31 ms against the 60 s target); tsc clean.
Note: performance events still count toward the collector's monthly cap,
as the insights-web ones already did.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Created with wrangler kv namespace create RAILYARD_SITES on 2026-09-30; the
console writes site entries and the edge collector reads them (P1 step 2.4).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A1's console copy test lints every string literal under product-analytics/,
URL paths included, with every module switch off. The plan's folder names
for click maps and variant tests spell gated modules, so their URL segments
are assembled once in _lib/a3-client.ts (PATHS, EXP, HEAT) and used
everywhere; the tab and list read "Variant tests"; messages use the
singular. Hand-off recorded: that test should skip URL paths, as
test/a3/console.test.ts does.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
flags merge pending: the flags slot (wave-p2-railyard PY2.1) is not on main,
so experiments/_slot/flags-slot.ts carries a copy of its FlagEnv and Flag
types and the setFlag contract, answers no slot until the merge (the
one-block switch is written in the file), and is tested with an in-memory
fixture of that contract: one setFlag call per start or stop, the service
then reads the flag back as live.
- _lib/a3-client.ts: every A3 endpoint through A1's paFetch, and the pure
form mappings (tested).
- Screens (one primary action each, no emoji, copy denylist clean):
recordings (by person, event id or funnel drop-off; the player embedded
from the signed 10-minute link; settings), click maps (overlay from a
signed link, scroll depth bars), surveys (list, new, results, start and
stop), experiments (list, new, results with the sample-ratio warning,
start and stop), exports (destinations, signing secret shown once from a
short-lived path cookie, runs, pause, resume, retry, test, delete; saved
insight CSV download).
- Recordings and click maps wait for RAILYARD_REPLAY_LIVE, experiments for
RAILYARD_FLAGS_LIVE (the copy denylist's own switches); until then those
screens say they are arriving, name nothing else, and their actions
refuse. Segments stay the console's word for cohorts.
- Uses A1's Shell and http helpers and A2's insights client read-only;
no console dependency, manifest or lib change.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Line, column, funnel, retention grid and paths charts follow the dataviz
rules (fixed categorical order validated on the console surface, 2px lines,
24px columns with 4px rounded ends, hover and keyboard tooltips, a legend
for two or more series and a table view on every chart). No new console
dependency; one primary action per screen; copy lint passes. The insights
screens are reached from their own sub-navigation; a link from A1's product
analytics frame is a hand-off.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Railyard GitHub App is shared by every Railyard org, so an installation on a
repository proved nothing about who was linking it: any org could start
railyard link for a repository the App was installed on (for example all of a
GitHub organization's repositories), get a link to its own org, open the
workflow pull request there, and, once the workflow was on the default branch,
receive that repository's code on every push in its own Cloudflare account.
The browser half now has the user sign in with the App (its user authorization,
no click after the first time) and checks with that user's own token that they
can push to the repository before anything is recorded or opened. The token is
used once and never stored. go and the setup URL no longer skip to Cloudflare or
the pull request. Needs GITHUB_APP_CLIENT_ID and GITHUB_APP_CLIENT_SECRET (the
manifest command stores them) and the App callback URL, which the manifest sets.
Tests first: an attacker org with read-only GitHub access is refused, claims no
installation and opens no pull request; forged codes and a refused sign-in fail.
Console 129/129, tsc clean.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Railyard MCP server's flags.list now lists the org's flags per app and
environment (key, on or off, value, description) from the new console route
GET /api/v1/flags?app= for an org's ry_ token (lib/flags/http.ts
tokenListFlags; read only, at most 100 environments). A token only ever reads
its own org: the MCP test shows org B naming org A's app lists nothing and
never sees org A's flag. Annotations stay read-only (the linter test), and
the README row says what it does.
Tests: mcp 9/9 (incl. copy lint), console 128/128, tsc clean.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RYP-G3 in Wave P.
- @railyard/insights-web: page views (with client-side route changes),
events, identify, and LCP, INP, CLS, FCP and TTFB per page view, sent once
when the page is hidden or the route changes; no cookies, no storage, Do
Not Track and consent respected. src/metrics.ts adapts MIT-licensed code
(NOTICE keeps the licence) with two changes that match Chrome's field
reporting: LCP stops at the first input, and INP picks its percentile from
the page's interaction count. On six worked fixtures (after-click paint,
two shift windows with a post-input shift, prerender activation, 120
interactions, multi-event interactions) every metric and the p75 are
within 10% of Chrome's values.
- Edge collector and ingest carry `performance` events (the five metrics,
in the upstream ranges) into upstream event type 5 rows.
- Insights GET /api/v1/tenants/{org}/vitals: p75 per app, per UTC day, and
in the day before and after each given deploy time (up to 10); ratings
from the published thresholds; org-scoped (SQL test with hand p75s).
- Console: the Page speed screen (only with RAILYARD_REPLAY_LIVE=1) and the
Scribase bridge `insights` answer gain `vitals` (p75 cells and one marker
per deploy from the console's own deploy records, so a deploy is marked on
the next read); a vitals failure never hides the rest of the tab.
The Scribase Analytics sub-tab (carve-out) joins these markers to the
environment's error issues: "This deploy raised errors by N" links to the
Errors tab.
Tests: console 128/128 (view model, bridge marker, flag gate, copy lint),
insights-web 12/12 (fixtures, client, copy), insights fork 12/12, edge
19/19, tsc clean.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The console signs a 5-minute HS256 org token with WebCrypto (no new
dependency) and reads the service; screens refresh every 10 seconds while
live, show capMessage at the cap, export a person as JSON and request a
deletion that stays visible until done. Copy passes the vendored denylist.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RYP-F1 in Wave P. Everything scoped by the org through website.team_id with
bound parameters only; tested at the SQL level on a throwaway cluster with
the upstream migrations plus the fork's 90 and 91.
- Identify: the edge collector (contract v1.1, additive) and the page tag
accept `identify(userId, traits)` and a `user` on any event. Insights links
the session (upstream session_link and session.distinct_id) and keeps one
profile per (app, user) with first and last seen and merged traits
(migration 91_railyard_people). Before this, an identify from the collector
made Insights refuse the whole batch.
- Saved cohorts: performed (with min times), not performed, trait equals and
first seen within; counts are live. On fixtures a cohort equals a
hand-written SQL count (two definitions).
- Retention by property (country, language, screen, trait.<key>; day or week
periods), breakdowns (path, referrer, country, language, screen, event,
hostname, data.<key>, trait.<key>).
- Export: events (31 days) or profiles, JSON or CSV, 100,000 rows; formula
cells defused.
- Delete by user id: one statement removes events, event data, session data,
revenue, replay and heatmap rows, links, sessions and the profile in the
org's apps only; recorded in railyard_erasure; a pending request is retried
by POST /api/v1/erasure/sweep (hourly), so it is done within 24 h.
- Console /api/v1/insights/* for an org's ry_ token: the org comes from the
token, app names resolve to the org's own app, the platform token never
leaves; served only with RAILYARD_REPLAY_LIVE=1 (denylist rule
railyard-slot-replay), else 503 "arriving".
- New packages: @railyard/insights-react-native (offline queue, identify kept
across restarts, reset, consent) and @railyard/insights-server (server
track and identify; profiles, cohorts, retention, breakdown, export,
deleteUser through the console). No dependencies.
Env: RAILYARD_REPLAY_LIVE (console). Migration: insights
91_railyard_people (idempotent; scratch Postgres only).
Tests: insights fork 9/9 (depth SQL incl. isolation, cohort vs hand SQL,
erasure), edge 18/18, console 125/125 (tsc clean), RN 3/3, server 5/5
(incl. copy lint), CLI 18/18. The upstream vitest suite runs in the image
build on box 2 or CI (not on the Mac).
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>
A Worker's response is not edge-cached from Cache-Control alone. The client
read now uses the Workers Cache API (caches.default) for URL-keyed reads:
a hit is answered without a database read, and the stored answer expires on
its 15 s max-age, so a flip still reaches every app within 60 s. Header-keyed
reads are never cached. Absent in `next dev`, where every read goes through.
Tests: bridge 25/25 (new: a URL-keyed read served from the cache, header-keyed
reads not cached), console 109/109 with the bundle build, contracts 6/6, SDK
7/7, tsc clean.
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>
One project's first event, visitors, events, month's stored events against the
add-on's cap, the funnel, and the same cap message the collector follows.
Contract case added. Tests: bridge 11/11, contract 3/3, tsc clean.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Railyard side of PY1.3 (RYP-D2, RYP-E1, SC-E3). Acceptance:
1. apps/insights: umami-software/umami v3.4.0 (MIT, commit ec0ff503),
vendored --depth 1, LICENSE kept, NOTICE added. Fork additions only:
src/railyard/{ingest,summary,tenancy,api-only}.ts, /v1/ingest/batch (the
edge collector contract v1, bearer INSIGHTS_INGEST_TOKEN, no IP ever,
retried batches de-duplicated by migration 90_railyard_ingest_receipts),
/api/v1/tenants/{org}/summary (bearer INSIGHTS_API_TOKEN), src/proxy.ts
(INSIGHTS_API_ONLY=1 serves only the Railyard API and the heartbeat).
Tenant isolation is tested at the API level (an app id owned by another org
is refused) and at the SQL level (upstream migrations 01-26 plus 90 on a
throwaway cluster: org B never reads org A's rows, even naming its app).
Upstream vitest suite: not run on the Mac (pnpm 12.3.4 pinned upstream,
disk floor); it runs in the image build on box 2 or CI.
2. No upstream product name in anything a customer loads: the page tag, the
console pages and the fork's additions (tests); the upstream dashboard is
never served in API-only mode.
3. The console writes the collector's site entry on "Add app", on
auto-created apps from deploys, and rewrites every entry on add-on, plan or
pause changes (lib/sites.ts, SITES KV binding). The bridge gains
`sites` (the project's app, site key, page tag and collector URLs, entry
written) and the analytics proof is the first event from Insights. The
console's Insights page shows visitors, events, first event and the
visit -> signup -> first action funnel.
5. insights-edge/src/caps.ts: at 100% of the cap events are still counted and
not stored until the next UTC month; the console shows the same message
from a byte-identical copy (lib/caps.ts, tested).
4 (384 MB at 50 events a second for 10 min) is measured on staging before deploy.
Env: INSIGHTS_API_URL, INSIGHTS_API_TOKEN, SITES KV binding (console);
INSIGHTS_INGEST_TOKEN, INSIGHTS_API_TOKEN, INSIGHTS_API_ONLY (Insights).
Tests: console 54/54 (tsc clean), insights fork 7/7 (incl. SQL isolation),
insights-edge caps + collector + sim 14/14, tests/contract 3/3.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Railyard side of PY1.2 (SC-E2, SP-F2). Acceptance:
1. packages/cli/src/scribase/env.mjs: in a Scribase project folder,
`railyard deploy` reads the public URL and anon key `scribase init` wrote
(.env, .env.local; NEXT_PUBLIC_/VITE_/EXPO_PUBLIC_/PUBLIC_ variants) into
the build env and onto the Worker (--var), prints their names only, and
leaves secrets out by name (service role key, SECRET/PASSWORD names, a
service-role JWT under any name). `railyard link-scribase` reads a one-time
claim from stdin (no flag takes it), exchanges it once and saves the token
0600; nothing is printed.
2. A git branch with Scribase branch settings (.scribase/branches/<branch>.env,
written by the PS2.0 hook) deploys its <app>-<branch> preview against that
branch (fixture test).
3. Bridge: deploy slot landed; proof is the latest successful deploy; new
route POST /api/v1/bridge/scribase/deploys lists the bound org's deploys for
the Scribase Deploy tab (org isolation test). Contract cases added.
4. Real Cloudflare end-to-end stays owner-run (tests use the fake wrangler).
Tests: packages/cli 13/13, console bridge + deploys 15/15, tests/contract 3/3,
tsc clean.
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>