20 Commits

Author SHA1 Message Date
60689764e8 fix(vend): close second unbound mint_account_id path on self-serve app creation
POST /v1/customer/apps (customer_create_app) took CreateApp.mint_account_id
straight from the client with no ownership check, the same cross-tenant
fund-custody bug class b50ea569 closed only on end-user provisioning
(POST /v1/customer/apps/:app_id/end-users). Any self-serve tenant admin
could create a tenant_reserve app pointed at another tenant's real Mint
account id and have their traffic's holds draw on that account.

Every self-serve app now gets a fresh Mint account Vend itself opens and
owns (provision_self_serve_app_mint_account), same pattern the signup flow
already uses for a tenant's first app — the client's mint_account_id is
discarded, never trusted. Operator-only /v1/control/.../apps is untouched.

Found during independent re-verification of the b50ea569 fix per the
"check for a second, similarly-shaped endpoint" instruction.
2026-11-06 22:23:12 +03:00
7db3c71ff4 feat(vend): AI-discoverability pass -- /index.md mirror, llms.txt/llms-full.txt/ai.txt, ai-summary meta
Same pattern already shipped for scribase.com/homeplan (plans/scribase.md,
plans/homeplan.md 2026-11-06 entries), adapted to Vend's one real public
page. Developer/infra-facing distribution thesis: being citable when a
developer asks an AI assistant for a white-label OpenRouter or a Stripe
Connect alternative for agent-built apps is a real discovery channel.

- GET /index.md: markdown mirror of the landing page (hand-ported from
  landing.html's own copy), text/markdown, noindex/follow,
  Content-Location + Link: rel="canonical" back to /.
- GET /llms.txt, /llms-full.txt, /ai.txt (llmstxt.org / ai-visibility.org.uk
  conventions).
- landing.html: <meta name="ai-summary"> + <link rel="alternate"
  type="text/markdown"> + a footer link to /llms.txt.

Verified for real (not just read): cargo build -p vend-server clean;
cargo test -p vend-server 40 lib + 28 integration tests, 0 regressions;
a throwaway oneshot-request test (deleted before this commit) proved
/index.md, /llms.txt, /llms-full.txt, /ai.txt all return 200 with the real
expected headers/content, the landing page's <head> carries the new tags,
and a bogus path still 404s. cargo clippy -p vend-server --all-targets
-D warnings: the 7 warnings it reports are 100% pre-existing on a clean
main (confirmed via git stash/clippy/git stash pop), none touch a line
this commit changed.
2026-11-06 19:28:43 +03:00
b50ea5694f fix(vend): self-serve end-user wallet provisioning trusted an unverified mint_account_id
POST /v1/customer/apps/:app_id/end-users let any self-serve tenant admin bind
an arbitrary, unverified mint_account_id to their own app's end-user. Since
end_user_reserve funding opens every metered-request hold against that exact
account (vend_tenancy::funding_account_id -> run_flow), a tenant who merely
*knew* another account's id (never created it, never controlled it) could
attribute their own app's billing to that account — a cross-tenant fund-
custody gap, not merely a cosmetic one. Proven live against real Postgres
(crates/vend-store/tests/cross_tenant_wallet_binding.rs): an unrelated
tenant B binds tenant A's real wallet as its own end-user, then resolve() +
funding_account_id() (the exact functions run_flow calls) hand back A's
account as B's funding source.

Fix: added MintTransport::get_account (GET /v1/accounts/:id) and a new
verify_customer_owns_mint_account gate in the customer-facing handler only —
it checks the account's Mint-recorded owner_ref against the exact
`vend:{app_id}:{external_ref}` convention ensure_wallet already writes on
real wallet creation, now shared via vend_core::whitelabel::wallet_owner_ref.
The operator-only /v1/control/.../end-users route is intentionally untouched
— the README already documents hand-mapping an existing account as a
trusted-operator capability. Proven closed by a FakeMint-backed unit test in
vend-server (control::tests) covering cross-tenant, wrong-ref, orphan-
account, and the still-working legitimate case.

cargo build/test/clippy clean across the vend workspace; the 7 pre-existing
clippy findings are unchanged from main (verified via git stash).
2026-11-05 23:44:41 +03:00
d9d704a2f2 feat(vend): add SEO meta (OG/Twitter/canonical/JSON-LD) and /sitemap.xml to the public landing page
vend.ereboslab.com/ is Vend's only real public, indexable page (/admin and
/console already correctly carry <meta name="robots" content="noindex">, and
were left untouched). The landing page had only a <title> and a meta
description — no canonical link, no Open Graph or Twitter Card tags (so
shared links rendered with no title/description card), and no structured
data. /sitemap.xml 404'd (no route registered).

Added: <link rel="canonical">, og:*/twitter:* tags, a SoftwareApplication
JSON-LD block, and a GET /sitemap.xml route that lists only the one
indexable URL. robots.txt is a shared Cloudflare-edge default across all
*.ereboslab.com hosts (not app-owned code) — confirmed correct (no
Disallow), left untouched.

cargo build -p vend-server and cargo test -p vend-server --lib (39 passed)
both green.
2026-11-04 19:56:28 +03:00
ad1bb093ec fix(vend): add a real creation path for KeyScope::EndUser provisioning keys
resolve()/wallets.rs fully enforce KeyScope::EndUser, but every real mint()
call (operator and customer /keys endpoints) hardcoded scope: KeyScope::App,
end_user_id: None — an end-user-scoped key could never actually be issued.

- CreateAppKey now carries scope + end_user_external_ref; issue_app_key
  resolves the ref via TenantRepo::find_end_user (itself the belongs-to-app
  check) and threads scope/end_user_id through to MintParams.
- IssueKeyRequest gains scope ("app"/"end_user", default "app" for backward
  compatibility) + end_user_external_ref on both the operator and customer
  /keys endpoints.
- admin.html and console.html key-issuance forms gained a scope selector and
  end-user external-ref field.
- New apps/vend/crates/vend-store/tests/end_user_scoped_keys.rs proves, against
  a real Postgres, that an EndUser-scoped key now mints and binds the resolved
  end_user_id, that a missing/unknown/cross-app ref is rejected, and that
  App-scoped issuance is unaffected.

bootstrap_product and the Tenant key scope are intentionally untouched — this
closes exactly the EndUser creation-path gap from the audit finding.
2026-11-03 16:01:04 +03:00
35c9c3364c docs: close the DNS gap note on toolgate/vend/ledgerline/context-passport
The read-only cloudflare-api MCP connection was never the only Cloudflare
credential available — ~/products/.env's CLOUDFLARE_DNS_API_TOKEN is a
separate, real, write-scoped token. Created the four missing A records
(ledgerline/vend/toolgate/context-passport.ereboslab.com -> railyard-box),
reloaded Caddy, confirmed real Let's Encrypt certs obtained within seconds,
and verified every sub-app live over HTTPS through Cloudflare. Docs-only;
no application code changed.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-28 19:38:09 +03:00
3aa6f03f84 docs(vend): document the real first production deploy on railyard-box
Vend had full infra scaffolding prepared (compose profile, Caddy site,
reserved DB password) but was never actually filled in or started. This
pass built the image, created three real Mint accounts (clearing, provider
payout, platform payout), minted a real Relay API key, wrote
/etc/products/vend.env, and brought the service up for real.

Verified live end-to-end against the deployed container: self-serve signup
(real tenant/app/wallet, each with its own Mint account), /v1/models,
wallet create/read, a chat completion against a real zero-balance wallet
correctly refused with insufficient_funds (cross-checked against Mint's own
balance endpoint), and a top-up attempt correctly failed on the missing
payment-provider credential (same funding wall as every other Railyard
sub-app, not a Vend bug).

No application code changed; this documents the real ops deploy (same
pattern as the Toolgate deploy earlier this session).
2026-10-28 03:23:11 +03:00
486cae67a0 fix(vend): correct Mint account-kind casing and ambiguous SQL column breaking signup/login
Found by actually running vend-server against a real (test-funded) mint-server
and real Postgres, not just its own test suite (which uses in-memory fakes for
both):

1. vend-mint-client's create_account() sent Vend's internal lowercase
   `kind` convention ("user"/"org") straight through to Mint's real
   `/v1/accounts`, whose AccountKind enum deserializes PascalCase variant
   names only ("User"/"Org"). Every call 422s with "unknown variant `org`",
   which the client's generic status-code mapper then turns into the
   misleading `capture_exceeds_hold`. This silently broke BOTH self-serve
   signup (POST /v1/auth/signup, which creates the tenant + app Mint
   accounts) and end-user wallet creation (POST /v1/wallets) against any
   real mint-server -- two of the five calls in the README's own "Launch in
   five calls" walkthrough. The existing "real mint contract" test
   (vend_dtos_match_real_mint_router_hold_contract) exercises holds,
   captures, releases and transfers against the real mint-server router but
   never create_account, so this wire-format drift had no test coverage.
   Fixed by translating lowercase -> PascalCase at the HTTP client boundary
   only, so the rest of Vend (and vend-testkit's FakeMint) keep the
   lowercase convention.

2. vend-store's setup_customer_password() ran
   `UPDATE customer_users u SET ... activated_at = COALESCE(activated_at, now())
   FROM tenant_memberships m WHERE m.id = $1 AND m.user_id = u.id`: since
   both customer_users and tenant_memberships have an activated_at column,
   Postgres rejects the unqualified reference as ambiguous. This ran on
   every self-serve signup (right after workspace creation) and every
   invited-member password setup, in both cases immediately failing the
   sign-in that follows. Never caught because every whitelabel/metered-flow
   test drives vend_testkit::InMemoryStore, not the real sqlx-backed
   VendStore -- customer-auth SQL had no Postgres-backed test at all.
   Fixed by qualifying the column as u.activated_at.

Verified live: built vend-server and ran it for real against a standalone
harness that boots mint-server's actual router/ledger (test-seeded
balances, no real payment provider) plus a minimal fake Relay, backed by a
local Postgres. Before the fix, POST /v1/auth/signup failed at the Mint
account-creation step; after fixing that, it created the workspace but then
failed at login with the ambiguous-column error; after both fixes, signup,
admin bootstrap, native login, a real metered chat completion (hold ->
capture -> three-way provider/tenant/platform payout split, balances
verified to the cent), exact-idempotent replay, and cross-tenant isolation
on /v1/customer/* all worked end to end over real HTTP. Full workspace test
suite (cargo test --workspace) and vend-store's live-Postgres money-path
suite still pass with no regressions.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-24 22:00:25 +03:00
933306855b feat(vend): flip self-serve signup live and ship its landing page
VEND_SIGNUP_ENABLED now defaults to true (it's the primary funnel, not
an opt-in extra) and GET / now serves a real marketing landing page
describing the white-label kit and linking into the console's existing
self-serve "Create a workspace" signup, instead of a bare root with no
discovery surface for a working signup API.
2026-10-23 15:35:37 +03:00
0f2bf3c3c0 fix(vend): regenerate Cargo.lock to match Cargo.toml
CI (.github/workflows/ci.yml) and the production Dockerfile both run
`cargo build/test --locked` for apps/vend, but the committed Cargo.lock
was missing entries pulled in transitively (jsonwebtoken -> x509-parser,
asn1-rs, der-parser, time, etc.). `cargo build --locked` failed outright
with "cannot update the lock file ... because --locked was passed" --
verified failing before this fix, passing after.

Minimal regeneration only (plain `cargo build`, no `cargo update`): 170
lines added, zero existing pinned versions changed. `cargo test --locked
--workspace` (136 tests) and `cargo build --locked -p vend-server --bin
vend-server` (the exact Dockerfile command) both pass clean.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-16 01:41:11 +03:00
1c742a7c93 ci: test every Rust app and the Node suites, with a scratch Postgres
CI ran cargo for rago, mint and some relay crates only, without a database,
and no Node suite at all: the live money-path suites (rago pg-tests, mint's
ignored live tests, vend, abacus, turnstile, ledgerline, passport, relay
storage/traces, game-economy) never ran, nor did the console, product
analytics, insights-edge, the SDK packages or the Scribase bridge contract.

- scripts/ci/scratch-postgres.sh starts a throwaway cluster per job from the
  runner's initdb (skips cleanly when Postgres is not installed) and exports
  DATABASE_URL (plus TURNSTILE_/RELAY_TEST_DATABASE_URL); a stop script
  removes it.
- The Rust matrix adds ledgerline, vend, abacus, turnstile, toolgate,
  game-economy, agent-runtime, context-passport and relay-storage-postgres /
  relay-traces; rago runs with pg-tests; mint runs its live suites.
- A node job runs the console, product analytics test:all, insights-edge, the
  SDK packages (borrowing product analytics' pinned SDK install) and the
  bridge contract.
- vend's Cargo.lock was stale (mint-payments gained ring), so
  'cargo test --locked' failed for vend; refreshed.

Verified locally against a scratch database: vend 136, abacus 95, turnstile
92, toolgate 114, context-passport 58 passed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-06 16:04:27 +03:00
c69b2305dc fix(deploy): trimmed build contexts, vend mint deps, shared-plane doc matches the stack
- apps/{vend,turnstile,abacus}/Dockerfile.dockerignore: per-Dockerfile ignore
  files so repo-root builds upload only the workspaces they compile
- apps/relay/ui/Dockerfile.dockerignore: the gateway .dockerignore excludes ui/
  and pnpm-lock.yaml, which the Relay UI image needs
- apps/vend/Dockerfile: copy apps/mint (vend-mint-client path-depends on
  mint-core/mint-protocol); the builder stage failed without it
- apps/DEPLOY-SHARED-PLANE.md: rewritten to match infra-box
  stacks/railyard/docker-compose.yml (docker compose profiles, host ports
  3100-4000, one Postgres with Relay observability in Postgres, no ClickHouse,
  abacus + relay-ui, env matrix, basic_auth/SSH access for the console)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 04:14:56 +03:00
b9d20ccc77 feat(consoles): friendly error messages in Rago, Vend and Turnstile admin
Map validation, auth, not-found, 5xx and network errors to plain-language
messages; unknown codes fall back to the server message.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 00:23:35 +03:00
a0234ffa45 chore(polish): Relay branding, error states, Rithub brand, README apps table
- Relay UI: user-facing TensorZero strings -> Relay; bug-report links point to
  the Relay operator; API Keys card description; tests updated to match
- Vend admin/console, Turnstile admin: load failures render as red role=alert
  error state instead of muted empty state
- Rithub web: capitalized brand in title/header/footer/sign-in
- README: complete, current Apps table with console locations

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 19:15:29 +03:00
4bb1472e3e feat(vend): white-label "your own OpenRouter" kit
Vend + Relay + Mint white-label kit: self-serve workspace signup
(POST /v1/auth/signup, off by default), per-app model pricing with markup,
end-user wallets and top-ups, tenant earnings, migration 0009_whitelabel,
customer console and operator admin pages for the new flows, and matching
TypeScript/Python SDK and mint-client updates. Covered by
tests/whitelabel_flow.rs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 12:41:49 +03:00
8b5fe4252e feat(platform): harden game-economy, Identity Lock receipts, Vend console, Turnstile paid tools
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 00:05:58 +03:00
33ee4bd8df feat: operator /admin consoles for vend, abacus, turnstile (reuse each service's real auth)
- vend-server GET /admin: tenants/apps/keys/usage/users via existing /v1/control (Bearer admin token)
- abacus-proxy GET /admin: receipt lookup by request_id (X-API-Key; only authed read endpoint — labeled)
- turnstile-demo GET /admin: tool catalog + settlement lookup (open endpoints; no challenge-list — labeled)
- same include_str! vanilla-JS pattern as rago /admin; HTML-escaped; noindex; no new auth path
- honest: surfaced only real endpoints, no fabricated views; cargo check 0 all three

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-09-23 10:47:35 +03:00
894359e5ff feat(railyard): per-app completion pass — money-correct settlement + crate cores
- rago: exactly-once prepaid settlement (deterministic idempotency, unique partial index + in-tx ON CONFLICT guard) — closes the double-charge risk
- mint: double-entry + reserve conservation verified (14 tests)
- ledgerline: atomic settlement outbox + partial recovery index (37 tests)
- abacus: hard per-agent budget enforcement + kill-switch (54 tests)
- vend: crash reaper / in-flight session reconciliation
- turnstile/agent-runtime/ranguard/rit/game-economy/context-passport/rithub: core advanced + tests
2026-09-07 17:17:54 +03:00
f633ec8b86 feat(vend): hold-reaper for panic-orphaned Mint holds (crash safety) 2026-08-24 20:26:33 +03:00
a853ab7edf Railyard: extract AI settlement+model rail from videogen (mint/relay/agent-runtime/vend/abacus/turnstile/ledgerline/prism) 2026-08-24 20:10:29 +03:00