31 Commits

Author SHA1 Message Date
0e2f9faf3e fix(toolgate): default own-product tool URLs on instead of permanently dead
scribase_url/rally_url/menivor_url being unset made config_url fail every
call regardless of auth kind (byo_required still needs a server-known base
URL, only the credential is BYO) — so scribase.*/rally.*/menivor.* catalog
tools were dead on every deployment that never set these three non-secret
URLs, including the live box. Default them to the real, live production
hosts (api.scribase.com, vcpeer.com, api.menivor.com) when unset, same
on-by-default rule signup_enabled already uses; explicit env still wins.

4 new unit tests in config.rs; cargo test -p switchyard-server 43/43 pass,
cargo clippy 0 warnings. Not deployed to railyard-box per the standing
no-default-deploys-to-ereboslab.com instruction — code default only.
2026-11-09 19:24:10 +03:00
f6eaf416fa docs(relay): correct I18/I19 parity status -- live, not missing
Semantic cache and PII guardrails were already fully coded and tested
since Oct 6 (apps/relay/crates/relay-semantic-cache,
apps/relay/crates/relay-guardrails) and wired into gateway/src/router.rs,
but the production Relay image on railyard-box was built from a checkout
87 commits behind main (predating both features). Rebuilt and deployed
relay from current main, enabled RELAY_SEMANTIC_CACHE=memory and
RELAY_GUARDRAILS_JSON={"pii":"redact"} in /etc/products/relay.env, and
verified both live end-to-end with a real throwaway API key (a request
with a fake email got x-relay-guardrails: email=1; the identical repeat
got x-relay-cache: hit, similarity 1.0000).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-21 04:33:44 +03:00
8bc3b49ca9 docs(product-analytics): refresh parity recount for A4/A22/A23, add real Mixpanel ingestion-compat test
The 2026-10-05 static parity recount still called A4 (native SDKs),
A22 (warehouse destinations) and A23 (CDP destinations/transforms)
PARTIAL, but the code that closes them landed on main the next day
(fba4dba7, 8cd06952, 0e611a19, b4612a4f, 41653aeb, aa25b536) and was
never folded back in. Add scripts/parity/wave-r.mjs on top of wave-q.mjs
(recount.mjs now merges waves, later wins) and regenerate
docs/parity/recount-2026-10-15.txt: analytics moves from 24/6/7 to
27/3/7 DONE/PARTIAL/MISSING. Verified before writing any of it: full
pnpm run test:all in apps/product-analytics (220 tests, 216 pass, 0
fail, 4 skipped for an uncached Chromium) and `swift test` in
packages/analytics-swift (6/6).

Add apps/product-analytics/docs/MIXPANEL-PARITY-CHECKLIST.md and
test/qy/mixpanel-compat.test.ts, which points the real `mixpanel` npm
client (not a mock) at this service. Findings: /track and /engage
($set/$set_once/$unset) are Mixpanel-compatible today; /groups is not
(the real SDK's $group_key/$group_id don't match this service's
$group_type/$group_key), the $add/$append/$union/$remove people ops are
accepted but silently dropped, there's no /import route, and a
non-verbose Mixpanel client treats this service's JSON response as a
failure. None of that ingestion-routing code is touched here; it's
scoped to docs and tests only.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-15 17:04:12 +03:00
e26f114357 docs: fix-all round 3 results
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-06 20:03:29 +03:00
635d2ac440 docs: fix-all round 2 results
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-06 19:19:24 +03:00
548ab68691 docs(plans): FIXALL-2026-10-06 results, test counts and what is left
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-06 17:26:15 +03:00
af36f7a180 test(product-analytics): destinations clock from the real hour, SDK deps resolve on a fresh checkout, test:all
The CDP destinations suite fixed its clock at 2026-10-05 while the runner
compares it with the database's inserted_at, so it passed only that day.
The SDK packages are in no installing workspace; their posthog-* imports now
resolve from this service's pinned copies when the package has no install.
test:all runs a1, a2, a3 and qy (pnpm test runs a1 only).

Adds docs/plans/FIXALL-2026-10-06.md, the ranked gap list for this branch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-06 14:01:42 +03:00
507837d774 fix(contract): publish the scribase.purchases.tracked_revenue meter (QY1.0 verify, Wave Q 5.2)
Dispatch 5.2 has QY1.0 add the Purchases meter to the consumer contract
before QU1.4 merges; it was not added, and QU1.4 shipped against its own
fixture. The Scribase seed gains the metric (sum of tracked_usd, one event
per organization and month, $0 mirror charge) and the contract its meter and
sample event, in the shape QU1.4 sends (transaction id
scribase:scribase.purchases.tracked_revenue:<org>_<YYYYMM>, tracked_usd and
billable_usd). consumers.test.ts 3/3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-05 14:18:33 +03:00
ee981ecd24 docs(parity): Railyard recount on main after Wave Q (infra 29/10/5, analytics 24/6/7)
Output of node scripts/parity/recount.mjs on main f8b5069.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-05 14:02:22 +03:00
7d82919e88 feat(parity): Railyard recount steward for infra and analytics rows (QY1.0)
Static record of PARITY-RECOUNT-2026-09-30 section 5: I1-I44, A1-A26 and L1-L12.
recount.mjs prints DONE, PARTIAL or MISSING per row and reproduces infra 26/12/6
and analytics 20/9/8 (L11 n/a, not counted). G12 marked done in LIMRUN-GAPS.md.

Skipped: IB/CAPACITY.md and IB/stacks/scribase-etl are not in this worktree
(infra-box is a different repo; the etl stack also waits on QS1.3).
Skipped: GTM/policy denylist byte-equality was not verified, so policy files
were not edited.
2026-10-02 23:46:58 +03:00
cbadc84dd5 merge: product analytics (A1-A3) into main after Wave P3
# Conflicts:
#	apps/console/components/Nav.tsx
2026-09-30 09:19:37 +03:00
4acf11b52d docs(analytics): A3 hand-offs for A1's copy, migration and privacy tests (A3)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 08:49:57 +03:00
a98d62c167 perf(product-analytics): A3 capacity within the 192 MiB cap, recording bytes per minute, and the A3 open-source record (A3)
- Recording chunks, their reads and S3 export files use native zlib instead
  of fflate, so compression runs outside the JS heap.
- test/a3/capacity.ts: 10 minutes of A1's 50 events/s plus 20 recording
  sessions flushing every 2 s plus one webhook export: max 186.4 MiB (ps)
  against the 192 MiB cap; inside view rss 100-116 MiB, heap used 15-32
  MiB, no growth. Stored recordings: 13 232 bytes per recorded minute on
  the fixture (49 923 uncompressed). Written to CAPACITY.md.
- NOTICE files for the vendored and ported parts; test/a3/vendor.test.ts
  pins their hashes and checks the served SDK parts equal the wrapper's.
- docs/analytics/oss/A3.md: what was copied, ported and written, the
  aws4fetch substitution for the AWS SDK and why, environment, security
  notes, test map and the hand-offs (A1 flags route merge for segment
  survey targeting, Shell link, package script, NOTICE line, compose env,
  Expo example provider; flags merge switch).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 08:38:02 +03:00
41334ca940 docs(analytics): A2 capacity measurement (trends 30 d p95 925 ms, 3-step funnel 1.9 s, 8-week retention 0.64 s on 1 000 000 events) and 549 bytes per event
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 06:37:35 +03:00
d8651480e0 feat(product-analytics): row level security on the SQL session table, deduplicated distinct trends, A2 migration test and open-source record (A2)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 06:18:10 +03:00
b58a36844d fix(ship): only a person who can push to the repository may link it (PY3.1 verifier)
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>
2026-09-30 04:33:15 +03:00
09a75337f9 docs(analytics): A1 capacity measurement (128.5 MiB max at 50 events/s for 10 min) and the A1 open-source record
- test/a1/capacity.ts runs the service as its own process and samples RSS
  from outside; result written to docs/analytics/CAPACITY.md.
- docs/analytics/oss/A1.md: pinned SDKs and libraries, the files ported
  from the upstream persons code (MIT, cbb1e9253027), the wire protocol, and
  the hand-offs to A2/A3 (including the SDK's /static/ extension scripts).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 04:11:14 +03:00
014f62b224 feat(ship): ship on push through the customer's own GitHub Actions and Cloudflare, with no token shown (PY3.1)
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>
2026-09-30 03:10:35 +03:00
c6fc339449 docs(analytics): product analytics plan, lim.run gap audit, OSS and capacity notes
Architect pass for Railyard product analytics (branch analytics/2026-09-30).
- PLAN.md: a new apps/product-analytics service that speaks the public
  capture protocol of the MIT/Apache PostHog SDKs (so the unmodified web,
  React Native and server SDKs work), backed by partitioned Postgres on box 2;
  identify, merges and groups ported from PostHog MIT code; insights ported
  from the vendored Umami Postgres SQL plus PostHog query semantics;
  experiments on the existing flags slot (read through its client API, written
  only through its service); three packages A1 (ingest, storage, SDKs,
  identify/groups, GDPR), A2 (insights, cohorts, dashboards, SQL), A3 (replay,
  heatmaps, surveys, experiments, exports) with disjoint file ownership.
- LIMRUN-GAPS.md: G1-G12 gaps of Scribase against lim.run with owner lanes.
- OSS.md: licences verified with gh api and npm view, pinned commits,
  rejected candidates with reasons.
- CAPACITY.md: 192 MiB service cap (est.), no ClickHouse, gate order.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 02:41:26 +03:00
4c51de52b1 feat(mint): portfolio mirror of paid events with signed outbound webhooks, no ledger handle (PY1.5)
Mint side of PY1.5 (dispatch 5.3: a ledger entry per paid event, mirrored
from Dodo webhooks; Mint never initiates a payout of third-party funds).
- POST /v1/mirror/events: each product records what its payment provider
  told it, with its own mirror key (MINT_MIRROR_KEYS_JSON); a replay of the
  same provider event is a no-op (unique provider + event id);
  GET /v1/mirror/events lists only the calling product's records.
- Records live beside the ledger (mint_mirror_events, migration 0013) and the
  mirror module has no ledger handle: no balance, hold or payout can result.
- Outbound: every record is delivered to each configured endpoint
  (MINT_EVENT_WEBHOOKS_JSON) as a Standard Webhooks signed mirror.recorded
  event from an outbox, every 15 s, retried 30 s doubling to 6 h until a 2xx.
  The signer lives in mint-payments (the only crate that talks HTTP) and
  reproduces the Railyard bridge contract's signature vector.
- /metrics already exists (RY-MT1) and is scraped by the box-2 job.

Tests: mint workspace green; mint-server tests/mirror.rs 3/3 (idempotency,
product isolation, signed delivery with retry and backoff, config checks);
mint-payments outbound 1/1; mint-store-postgres pg_mirror_live and pg_live
against a scratch local cluster (DATABASE_URL, --ignored) 3/3; migration 0013
re-applied by hand without error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 22:27:28 +03:00
e6361cd780 fix(consumers): events carry external_subscription_id, which Rago requires (PY1.5)
Rago's create_event requires external_subscription_id; the contract now sends
<product>-portfolio-<external_customer_id> alongside the dispatch's
external_customer_id, and CONSUMERS.md says so. consumers 3/3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 21:58:24 +03:00
a126131ed9 feat(consumers): portfolio Rago seeds, the consumer contract fixtures, switch table, key plan and nightly reconciliation (PY1.5)
Railyard side of PY1.5 (dispatch 5.3). Acceptance:
1. tests/contract/consumers/contract.json is the contract PM1.5, PR1.5 and
   the Scribase carve-out test against: env names (RELAY_URL, RELAY_KEY,
   RAGO_URL, RAGO_API_KEY, MINT_URL, MINT_API_KEY, RAILYARD_LIVE), the
   RAILYARD_LIVE switch (default 0), every product's meters and one sample
   event per meter with the <product>:<meter>:<source id> idempotency key.
2. apps/rago/seeds/portfolio/{scribase,menivor,rally}-portfolio.json define
   exactly those meters (valid Rago aggregations, field names where summed)
   under $0 mirror plans; consumers.test.ts checks seeds against the contract.
4. tools/reconcile-portfolio/reconcile.mjs compares each product's own counts
   with Rago's totals per customer, meter and month; on the fixtures the
   difference is 0, and dropped, extra or malformed rows are named (exit 1/2).
5. Nothing switches live in code: docs/CONSUMERS.md gains the Wave P switch
   table. scripts/relay/provision-product-keys.mjs prints names and the box
   steps only (no value is generated, read or printed).
3 (Mint stack, 128 MiB, /metrics scraped): infra-box stacks/mint; Mint's
/metrics handler exists since RY-MT1.
Not in this commit: Mint outbound event webhooks and the paid-event mirror
(see the lane report).

Tests: consumers 3/3, reconcile 2/2, provision 1/1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 21:57:43 +03:00
0ce1528ac8 feat(relay): named claude-haiku and claude-sonnet-5 routes and LiteLLM price cross-check (RY-RL2)
claude-haiku (claude-haiku-4-5) and claude-sonnet-5 route Anthropic first
and the OpenRouter copy second; claude-sonnet stays on 4.5 unchanged. Both
are priced in config/catalog.json at list price, so the metered startup
check passes and a request served by the OpenRouter leg bills the same
catalog price. A contract test ties tensorzero.toml, catalog.json and the
built-in list prices together.

relay-catalog gains a read-only cross-check against LiteLLM's MIT price
JSON (relay-price-crosscheck CLI): it flags differences above 5% and never
changes a price. First run flags the two llama alias routes, whose retail
price differs from the gpt-oss model that now serves them. The provider
canary route list now covers the two new routes (34 calls a day).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 01:42:32 +03:00
57158358e1 feat(relay): engine ADR and daily provider-contract canary (RY-RL1)
Records OD-RY1's default: keep the TensorZero fork as the Relay engine,
maintain the four adapters in use, Bifrost as the Wave E provider layer,
LiteLLM price JSON read-only, and the three tripwires.

The canary calls every named chat route plain, streaming and with a
forced tool call, plus each fallback leg once, and passes a call only when
the route's first configured provider served it (raw usage provider_type).
A revoked Anthropic key is red even while OpenRouter keeps answering.
Output is canary format v1 under product railyard. routes.json is generated
from tensorzero.toml for boxes without tomllib; tests fail when stale.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 01:32:11 +03:00
e612536a6e feat(rago-seeds): menivor_llm_call + gtm_topup metrics, gtm_usage plan
- menivor-reels.json: menivor_llm_call count metric (the code videogen
  metering.py sends per Relay-routed LLM call), charged at $0 on
  menivor_reels so current_usage shows it without billing it.
- autogtm.json (Rally): gtm_topup sum metric over properties.amount_cents
  (vcglass meterRagoTopup), and the gtm_usage plan vcglass subscribes
  projects to by default (RAGO_GTM_PLAN_CODE) which did not exist: $0 base,
  $0 charges, because money moves through the Creem-funded balance.
- import.sh default base URL and README examples now include /api/v1
  (routes are nested there); README org SQL includes the required slug.
- CONSUMERS.md: menivor_llm_call is now seeded.

Verified by importing both seeds into a local rago-api on a throwaway
Postgres, subscribing, sending events: gtm_topup sums 5000, llm calls
count 2, both $0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 02:34:07 +03:00
975bd2778e docs: update Rally wiring in CONSUMERS.md after chat-fetch routing
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 01:25:16 +03:00
758b358b3b feat(railyard): consumer map + game-economy client API
- docs/CONSUMERS.md: per-product map (Rally, Menivor, Scribase, OpenJev,
  sampled apps and games) of direct vendor calls vs Railyard hops, with
  file refs and target wiring.
- game-economy: IAP credit hooks (/v1/iap/credit, /v1/iap/reverse,
  /v1/iap/revenuecat) that credit premium currency from a funding
  account via idempotent Mint transfers; amounts come from
  GAME_IAP_PRODUCTS. Route tests included.
- game-economy docs/HTTP-API.md and a zero-dependency TS client for
  Expo games (player) and game backends (server).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 00:38:19 +03:00
e53623cda0 refactor(turnstile): rename turnstile-demo crate to turnstile-server
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 01:25:24 +03:00
4ef3e0f8eb feat(aeonrift): shop economy + collection screen + product catalog server + mobile iOS scaffold; content-lint CLI; drop vendored bevy_render slice
- aeonrift-ascendancy: server/product.rs catalog, client shop.rs purchase flow, collection screen, actions; mobile/ios Info.plist + PrivacyInfo
- content-lint: lib enhancements + standalone content-lint CLI bin
- remove vendored slice/bevy_render (independent build base, now gitignored with other vendored OSS)
- docs: capability graph + done-fully plan

Both changed crates cargo-check clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-09-22 04:36:47 +03:00
2ca05faac8 docs(railyard): OSS foundations — internal Apache crate reuse map + external MIT/Apache fork targets per app + license risk register 2026-08-24 21:23:07 +03:00
236c60999a docs(railyard): enterprise architecture + graph-engineering + scale reality for all rail apps 2026-08-24 20:51:57 +03:00