2 Commits

Author SHA1 Message Date
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
ee5070acb8 feat(railyard): nightly Relay and Rago shadow-metering reconciliation (RY-RG1)
tools/reconcile-relay-rago compares relay_cost_events with Rago relay_llm_usage
events for one UTC day, event by event: missing (dropped), dead-letter, amount
mismatch, duplicate across orgs, orphan and overdue pending. Drift over 0.5%,
any dead-letter or any duplicate pages the railyard ntfy topic; smaller findings
are reported at default priority. ry_rago_drift_ratio and per-key and per-org
figures go to VictoriaMetrics; a JSON report is kept per day. Both databases are
read in READ ONLY transactions, so no charge of record changes.

Includes systemd service and timer (04:20 UTC), installer, env sample, the
emitter flip checklist per lane, and 12 offline tests (fake psql, local ntfy and
VictoriaMetrics).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 02:09:50 +03:00