14 Commits

Author SHA1 Message Date
086381d507 feat(gateway): make rate limiting org-scoped and plan-tiered
Rate limiting was per-API-key, so an org's `plan` field was decorative — a
free-plan org that minted 5 teammate keys got 5x the effective request
budget of a single-key free org. Org-scoped keys now share ONE rate-limit
bucket per org (`org:<id>`), sized by plan (free=120, pro=1000,
enterprise=10000 per window); orgless credentials (platform admin key,
anonymous dev identities) keep the prior per-identity behavior unchanged.

Adds GET /v1/orgs/usage (bucket status + total request count across an
org's keys) and a shared-bucket meter in the Orgs self-service console
panel.

Verified against a running dev server: 130 concurrent requests on a
free-plan org's owner key yielded exactly 120 successes + 10 real 429s,
and the org's teammate key immediately inherited the same depleted
remaining count (proving the bucket is shared, not per-key). A parallel
enterprise-plan org was unaffected. tsc + frontend build clean, 450/450
existing tests unchanged.
2026-10-24 00:40:11 +03:00
f1c6d5f26d feat(gateway): add multi-tenant organizations with self-service API keys
Backlog item 13: API keys had no tenant boundary — any valid admin key (or,
in dev, no key at all) could see or mutate every key, webhook, and resource
in the process, which isn't multi-tenant for real paying integrators.

Adds a real org layer: the platform operator onboards a new org once
(POST /v1/orgs, admin-scoped) and gets its first owner key back; from then
on the org is fully self-service through its OWN key — GET /v1/orgs/me,
POST /v1/orgs/keys (mint a sibling key for a teammate, capped to a subset of
the caller's own scopes, no self-escalation), DELETE /v1/orgs/keys/:id
(revoke, but only inside the caller's own org_id — a different org's valid
key gets a 404, not the target's real state). The platform admin key is
never touched again after the initial onboarding call.

Also fixes a related gap this surfaced: lib/gateway/index.ts's authenticate()
previously ignored any presented API key entirely when
CRED402_AUTH_REQUIRED=false (dev), skipping scope checks even for a valid
key. A valid presented key is now resolved onto AuthContext and still scope-
checked in dev; a missing key still never blocks, so the existing zero-key
console workflow is unaffected.

Frontend: new Orgs.tsx (operator onboarding + self-service panels), wired
into Developer.tsx; api.ts helpers for all five new routes.

Verified for real against a running dev server: onboarded two orgs, had one
self-mint a teammate key with no admin key involved, confirmed scope-
escalation is rejected (403), confirmed cross-tenant revoke is rejected
(404), and confirmed the admin-only org-detail route rejects a non-admin
org's own valid key (403) — this one actually leaked before the
authenticate() fix above, caught by running the flow, not by inspection.
tsc --noEmit + frontend vite build clean, 450/450 existing tests unchanged.
2026-10-24 00:30:40 +03:00
4d75f53563 feat(webhooks): add delivery dashboard with disable/enable + manual replay
Backlog item 14: outbound webhook deliveries (success and failure) are now
logged with their original payload, surfaced via GET /v1/webhooks/deliveries,
and individually replayable via POST /v1/webhooks/deliveries/:id/retry so an
integrator can fix a receiving endpoint and resend a failed event without
waiting for the protocol event to fire again. Subscriptions can be disabled
(DELETE /v1/webhooks/:id) and re-enabled (POST /v1/webhooks/:id/enable)
without losing their id/secret/filters.

Frontend: new Webhooks.tsx (extracted from Developer.tsx) renders the
delivery log with a per-subscription filter, auto-refresh, and a retry
button on failed deliveries; subscription table shows active/disabled
status with a toggle.

Verified for real: full tsc typecheck + frontend vite build clean, 450/450
existing tests still pass, exercised POST/DELETE/enable/deliveries routes
against a running dev server with curl, and ran the WebhookService directly
against a local HTTP receiver that rejects then accepts to confirm a failed
delivery logs correctly and a manual replay flips it to delivered.
2026-10-24 00:19:27 +03:00
7fdc321d79 feat: live-wire Casper writes, add marketing homepage, fix cold-start UX
Round 1 against STRATEGY-2026-10-23.md's backlog:

- Wire register_agent/stake/set_credit_score/deposit_liquidity to the real
  Casper Testnet contracts (lib/casper/live_bridge.ts), verified live against
  the real RPC node with a freshly generated (unfunded) keypair
  (npm run casper:keygen). Honesty flags built in for the Odra payable
  calling convention and the admin-gated set_credit_score call.
- Unblock NEAR's paid x402 route (npm run near:keygen generates a real
  implicit account id); QIE stays correctly flagged as blocked on unconfirmed
  external facts (asset contract, facilitator), not env plumbing.
- New public Home tab: live-stats hero, how-it-works, a real competitor
  comparison table, and a "90-second proof" that calls the real API live in
  the browser (verified end-to-end with gstack browse).
- Cold-start UX: visible retry state in X402Playground + the TS SDK, plus a
  keep-warm self-ping (lib/services/keepalive.ts) so the free Render dyno
  rarely idles out from under a real first-time caller.
- New GET /v1/credit-score/:agentId alias + docs/integrations/ samples for
  Skyfire/Nevermined/Coinbase x402.
- Self-hosting quickstart: root docker-compose.yml + scripts/bootstrap.sh,
  both run for real; fixed a real EACCES crash-loop bug in infra/Dockerfile
  (non-root user never owned the /data volume mount) found while verifying.

450/450 tests pass, typecheck clean, frontend build clean.
2026-10-23 19:57:40 +03:00
24d073ee83 feat: KeeperHub execution layer + Flare interoperable/confidential credit
Two hackathon integrations spanning the whole credit stack, sim-first
(green with no keys) with real integrations behind env flags.

KeeperHub — the on-chain execution & reliability layer (lib/keeperhub/):
- OnchainExecutor: pay-per-execution (x402/MPP) -> simulate -> smart gas
  with exponential backoff -> MEV-protected private routing -> audit trail;
  real MCP client to app.keeperhub.com; deterministic sim fallback.
- Autonomous Credit Keeper: FTSO position health -> check->execute deleverage.
- Credit Automations: declarative price/health/schedule rules as workflows.
- Autonomous Scheduler: KeeperHub-cron loop running keeper + automations.

Flare — interoperable + confidential primitives (packages/.../flare, lib/flare):
- FXRP credit satellite: CAN-gated, FTSO-priced, FDC-attested; Coston2
  Solidity vault (contracts/flare/).
- Confidential Compute credit scoring (TEE-attested, private inputs).
- FTSO-priced multi-asset collateral; FAssets mint->collateralize lifecycle.

x402 Credit-Service Marketplace: sells cred402's intelligence pay-per-call
over x402 (402->pay->200); paid receipts feed the revenue->reputation loop.

Wiring: 78 MCP tools, /v1 + /api routes, console Flare + x402 tabs, 11 demo
CLIs, 8 feature docs + docs/SUBMISSIONS.md, recorded demo video (media/).
346 tests pass; 7 adversarial verification workflows caught + fixed ~37
correctness/security issues.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-08-11 23:34:23 +03:00
d08821a140 feat: expose on-chain manifest on the production /v1 API
Cross-surface parity for on-chain observability: the chain manifest (contracts +
real install deploy transactions, each with cspr.live links) was only on the
console /api. Add it to the versioned /v1 surface so integrators can fetch it
programmatically through the authenticated, rate-limited, enveloped API.

- GET /v1/chain via ServerState.chainManifest() (read scope)
- documented in packages/openapi (cred402.v1.yaml + cred402.http)
- test: ServerState.chainManifest parity (245 pass)
2026-07-16 20:40:02 +03:00
2632ad4e16 feat: expose p3/p5/p6/p7/p10 services on REST v1 + MCP surfaces
Wires the new bureau services into the production read surfaces (REST/MCP
parity with the rest of the protocol):
- GET /v1/credit/check/:id + POST /v1/credit/check  (p3 oracle, 'Cred402 Inside')
- GET /v1/agents/:id/risk-score                      (p7 ML risk-engine v2)
- GET /v1/credit/data-commons                        (p6 anonymized public good)
- GET /v1/credit/exposure + /v1/agents/:id/exposure  (p5 omnichain reconciliation)
- GET /v1/verticals + /v1/verticals/:vertical        (p10 underwriting profiles)
- MCP: cred402.credit_check, risk_score_v2, credit_data_commons,
  agent_exposure, service_verticals (54 tools total)

ServerState gets thin delegators; ServiceVerticals persists as a field so
governance tuning survives across requests. tsc clean, full suite 233 green.
Smoke-tested all endpoints against a live server.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-17 18:04:07 +03:00
5cf86893e3 feat(contracts): deploy Cred402 Odra contracts to Casper Testnet (Casper 2.0)
Migrate the contract suite to Odra 2.x (builds on the Casper 2.0 ABI; fixes the
1.x nightly/edition2024 toolchain deadlock) and deploy 9 contracts live to
casper-test via the Odra livenet deployer:

  AgentRegistry · X402ReceiptRegistry · RWAEvidenceRegistry · RWAAssetRegistry
  ReputationEngine · AgentCreditPool · RiskPolicyManager · AgentPassport · DisputeCourt

- contracts: odra "2", no_std headers, build.rs (odra-build), per-crate Odra.toml +
  build_contract/livenet bins; pinned nightly-2025-01-15 for reproducible wasm.
- tooling: scaffold_livenet.py, deploy_all_testnet.sh, deploy_one.mjs.
- deploys.testnet.json: live manifest; README: on-chain contract hashes.
- Deployer key kept out of git (.secrets/ gitignored); wasm artifacts gitignored.

Verified on-chain: AgentRegistry ContractPackage present in global state.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-17 02:34:49 +03:00
22314584d8 docs: embed the demo video in the README (inline player + poster)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-17 01:09:59 +03:00
e40ea2aed2 feat: demo video of the live console + record script
- media/cred402-demo.mp4: 720p screencast of https://cred402.vercel.app driving the
  full loop with the Casper streaming-events feed updating live (proves the
  direct-CORS SSE end to end).
- scripts/record_demo.mjs + `npm run record:demo`: Playwright records the live site,
  ffmpeg muxes to MP4. Raw .webm is gitignored.
- README: link the demo video.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-17 01:08:27 +03:00
e879a324c4 fix(deploy): point Vercel rewrites at live https://cred402.onrender.com
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-17 00:52:24 +03:00
51a56a66c7 feat(deploy): Render Blueprint for the API + Vercel rewrites to it
- render.yaml: always-on web service `cred402-api` (node runtime, installs dev
  deps so tsx is present, health check /v1/health) — Render runs the long-lived
  node:http + SSE server the serverless Vercel deploy can't.
- api/server.ts: honor the platform-provided PORT (Render) before CRED402_PORT.
- frontend/vercel.json: rewrite /api/*, /v1/*, /graphql → https://cred402-api.onrender.com
  so the deployed console reaches the backend same-origin (no CORS, no code change).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-17 00:50:11 +03:00
2d43618725 feat: real integrations (Casper Testnet, x402/EIP-712, MCP, RealFi, cross-chain), wallet sign-in, branding
Replace the design-note docs (p1–p7) with the implemented "make it real" phase
docs (p8–p10) and wire production-grade, env-gated real integrations:

- p8 Casper Testnet: byte-exact deploys + WASM install via casper-js-sdk; live
  node reads (node.testnet.casper.network); CRED402_CHAIN=sim|testnet transport.
- p9 x402 + data + MCP: real EIP-712 typed-data digests (@casper-ecosystem/
  casper-eip-712); casper-x402 facilitator client (x402 V2); live Open-Meteo GHI;
  official @modelcontextprotocol/sdk server; casper-sidecar SSE event feed.
- p10 RealFi + cross-chain: real Stripe test-mode webhooks (HMAC-verified) and
  Plaid sandbox → privacy-preserving on-chain envelopes; Base Sepolia EVM deploy
  (Foundry); reachable via /api/realfi/* and /api/x402/facilitator routes.
- Sign-in with Casper Wallet: real extension provider + challenge/ed25519/session
  flow (/v1/auth/wallet/*), console connect + sign-in button.
- Branding: Cred402 logo mark, favicon, OG image; Vercel config for the console.

All env-gated with sim/free-API fallbacks; full suite green, all toolchains
(TS/Rust/Go/Solidity) build.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-17 00:37:36 +03:00
f1e4bb712e first 2026-06-16 02:50:52 +03:00