caelum0x 55012ad463 feat: p9 Enterprise RealFi GA (tenants, entitlements, audit trail)
EnterpriseRealFi adds the production access-control layer in front of the
oracle / data commons / attestation surfaces: named tenants on plans
(developer/growth/enterprise) with entitlement gating, a rolling 30-day quota,
a trailing 60s rate limit, suspend/resume, and a sequential, exportable audit
trail recording every allow/deny decision. guard() wraps authorize-then-run.

8 new tests, full suite 226 green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-17 17:43:56 +03:00

2.1 KiB

p9 — Enterprise RealFi GA

Make the RealFi + credit surfaces sellable. Named tenants, plan-based entitlements, per-tenant quotas and rate limits, and an exportable audit trail — the access-control and accountability layer that turns the APIs into a product.

Why

The oracle (p3), data commons (p6), and RealFi attestation registry are powerful read/write surfaces, but a demo API isn't a product. Enterprises need to know who can call what, with enforced limits, and need an audit record they can hand to compliance. p9 is the GA hardening: tenancy, entitlements, metering, and audit.

Scope

  • Tenants & plans. Onboard named tenants on plans (developer / growth / enterprise) that bundle entitlements, a monthly operation quota, and a per-minute rate limit. Ad-hoc entitlements can be granted on top of a plan.
  • Entitlement gating. Every operation maps to an entitlement (credit_check, bulk_underwrite, issue_attestation, data_commons, audit_export); calls without the entitlement are denied.
  • Quota + rate limits. A rolling 30-day quota and a trailing 60-second rate window, both enforced per tenant and surfaced in usageFor().
  • Audit trail. Every authorization decision (allowed or denied, with reason) is appended to a sequential audit log, exportable and filterable for SLA/compliance.

Deliverables (shipped)

  • lib/services/enterprise_realfi.ts — EnterpriseRealFi:
    • registerTenant({ tenant_id, plan, extra_entitlements? }).
    • authorize(tenantId, entitlement) → entitlement + quota + rate enforcement, fully audited.
    • guard(tenantId, entitlement, fn) — authorize-then-run convenience.
    • usageFor(), suspendTenant() / resumeTenant(), exportAudit(filter).
    • PLANS — developer / growth / enterprise tiers.
  • test/enterprise_realfi.test.ts — entitlement gating, quota, rate-limit bursts + window advance, suspend/resume, guard, extra grants, unknown-tenant handling.

Success metric

A paying tenant can be onboarded, scoped to exactly the operations it bought, held to its limits, and audited end-to-end — with no operator code change per customer.