caelum0x 2b686594a3 feat: Ration phase 1 — full polyglot build for Airwallex Starter Kit 5
Six services, independently built then integrated:
- services/wal (C): crash-safe write-ahead log, CRC32-checksummed
  frames, torn-write recovery via truncate-to-last-valid-frame.
- services/ledger-core (Rust): double-entry ledger over the C WAL via
  FFI, reserve-floor enforcement BEFORE any WAL write, idempotent
  ApplyEntry, full LedgerCore gRPC service.
- services/gateway (Go): Airwallex Issuing/Global-Accounts client
  (mock mode default, live mode ready), the actual rationing math
  (reserve floor, 60% bridge cap, 24h velocity cap, partial-over-decline).
- services/agent (Go): deterministic hard-rule policy envelope computed
  BEFORE any LLM call; Claude only decides within that pre-approved
  envelope; every decision audit-logged even when the LLM call fails.
- services/tui (Go, Bubble Tea) + services/cli (Go, cobra): the only
  UI — no web frontend, per explicit direction.

Integration found and fixed three real bugs, not just compile errors:
- proto regen collision shadowing checked-in pkg/pb packages
- ledger-core/gateway address-variable mismatch (stack would never
  actually connect on default config)
- the big one: MarkDepositReceived never credited the ledger, so every
  tenant's balance was permanently stuck at 0 and bridge-funding could
  only ever decline — the core agentic-rationing feature could never
  produce a real grant. Fixed at the ledger level with idempotent
  mark-and-credit in one WAL frame, covered by 3 new tests.

End-to-end verified live, reproducibly: seed -> simulate a late deposit
-> agent grants a partial bridge with a computed rationale -> second
grant correctly declines once the 24h velocity cap engages. Verified
independently by the orchestrator too: 'make build' and 'make test'
both clean (Rust: 29 tests; Go: all packages; C: WAL test suite).

Airwallex sandbox credentials still pending organizer approval —
tracked as an owner blocker in docs/AIRWALLEX-SETUP.md, not a code gap.
2026-10-19 03:04:13 +03:00

54 lines
2.2 KiB
Go

// Package demoseed defines the fixed set of demo tenants `ration seed`
// creates. Kept as pure data + a pure constructor function (no I/O) so it
// is unit-testable without a running gateway/ledger-core.
package demoseed
// Tenant is one demo tenant definition handed to LedgerCore's CreateTenant
// RPC by the seed command.
type Tenant struct {
Name string
Currency string
ReserveFloorMinorUnits int64
// OpeningCapitalMinorUnits is settled operating capital the seed
// command credits immediately (via RecordDeposit +
// MarkDepositReceived) so the tenant starts demo-ready: available
// balance already sits above ReserveFloorMinorUnits, giving the
// agent's bridge envelope real headroom to grant against on the
// very first late-deposit scenario a judge runs. Without this, every
// freshly seeded tenant starts at a balance of exactly 0 — which is
// always below the reserve floor, so every bridge request would
// decline no matter how the late deposit itself is sized.
OpeningCapitalMinorUnits int64
}
// Tenants returns the 3 demo tenants `ration seed` creates: a small,
// medium and large platform, each in a different settlement currency, so
// the reserve-floor math in docs/AGENT-DESIGN.md has realistic variety to
// demo against. Each tenant's opening capital is 3x its reserve floor,
// i.e. 2x the floor in actual headroom — comfortably enough for the
// demo's bridge-funding scenario to produce a real grant, not just a
// decline.
func Tenants() []Tenant {
return []Tenant{
{
Name: "Lumen Creator Payouts",
Currency: "USD",
ReserveFloorMinorUnits: 250_000, // $2,500.00 — small platform
OpeningCapitalMinorUnits: 750_000, // $7,500.00 settled capital
},
{
Name: "Northwind Freight Marketplace",
Currency: "EUR",
ReserveFloorMinorUnits: 2_500_000, // €25,000.00 — medium platform
OpeningCapitalMinorUnits: 7_500_000, // €75,000.00 settled capital
},
{
Name: "Atlas Gig Exchange",
Currency: "GBP",
ReserveFloorMinorUnits: 15_000_000, // £150,000.00 — large platform
OpeningCapitalMinorUnits: 45_000_000, // £450,000.00 settled capital
},
}
}