18 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
52c5c87a1f fix: point frontend config comment at the canonical Render service
frontend/src/lib/config.ts told operators to set VITE_API_BASE to
cred402.onrender.com (no -1) — a stale duplicate Render deploy still
running an old pre-Algorand build. Every other reference in the repo
(render.yaml, README, vercel.json rewrites, docs, examples) already
points at the canonical cred402-1.onrender.com. Fixed the comment and
documented the duplicate-service cleanup (owner-gated, no Render API
token available here) in docs/ACTIVATION_CHECKLIST.md.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-15 16:34:17 +03:00
f7e366702c fix: label simulation mode on the On-Chain console tab
The On-Chain tab presented the real Testnet contract registry but implied the
running credit state + event stream were on-chain. Add an explicit simulation
banner (contracts are real on Testnet; scores/receipts/anchoring are simulated;
demo agents are labeled) and correct the event-log caption.
2026-09-06 10:00:34 +03:00
388d482cfc chore: add Apache-2.0 LICENSE (unblocks open-core) + extract http_utils from server god-file 2026-08-25 03:09:55 +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
9dbf54f10f feat: On-Chain tab — prominent "our address & activity" link + single feed
Follow-up to the /contract-package link fix. The contract pages render but show
"No activity to display" (the protocol runs off-chain, so contracts have no
post-install calls). The page that actually shows our testnet address + on-chain
activity is the deployer account (all 26 deploys), so lead with it.

- add a prominent CTA banner linking to our Casper Testnet account (address +
  all deploy transactions on cspr.live)
- fix duplicate event feed: the On-Chain tab has its own feed, so hide the global
  sidebar feed there (layout goes single-column)
2026-07-16 20:55:48 +03:00
b25ef73300 feat: link real on-chain deploy transactions on the On-Chain tab
Surface the actual transactions we made on Casper Testnet. Pulled the 26 real
module-install deploys from the cspr.live account API (deploys.transactions.json,
committed for zero runtime dependency) and mapped each contract to its install
deploy via the Odra package-hash key name.

- data: deploys.transactions.json — real deploy hashes, blocks, timestamps
- backend: chain_manifest attaches deploy_hash + /deploy/<hash> cspr.live link to
  each contract (latest install) and exposes the full transactions list
- frontend: On-Chain tab gets a "tx ↗" link per contract and a dedicated
  "On-chain transactions — deploys we made" table (deploy hash, contract, block,
  time), plus an "all account txs" link; stat row shows on-chain deploy count
- test: transaction linking + per-contract install-deploy coverage (244 pass)

Verified: sample deploy c9609ec2… (AgentRegistry install) resolves as a
processed deploy at block 8,204,027 on cspr.live.
2026-07-16 19:18:05 +03:00
89b474fa53 feat: on-chain observability — cspr.live linking across the console
Make Casper Testnet activity observable end-to-end. The 14 deployed Odra
contracts, the deployer account, and protocol events now link to the real
cspr.live block explorer instead of showing opaque, per-boot-random hashes.

- backend: /api/chain serves the canonical deploys.testnet.json manifest
  enriched with cspr.live URLs (lib/services/chain_manifest.ts)
- backend: Explorer search resolves deployed contracts by name/crate/hash
  and returns their cspr.live link
- backend: /api/export/events.csv exports the full on-chain event log
- frontend: new On-Chain tab — contract registry with real hashes + copy,
  deployer account, per-contract live event counts, click-to-focus the feed,
  and event-log CSV export
- frontend: EventFeed upgraded — text/severity filters, pause/resume with
  buffered count, expand-to-JSON, contract-link, single-contract focus
- frontend: Explorer results link on-chain objects to cspr.live; header shows
  a live chain pill; footer contracts link out
- test: chain_manifest + explorer contract-resolution coverage (242 pass)

The Vercel /api/:path* rewrite already proxies the new endpoints. Deployed
contracts/hashes/accounts link to cspr.live; the session event log's synthetic
deploy hashes are deliberately not linked.
2026-07-16 19:02:32 +03:00
f3827666bf feat: Bureau frontend panel — data-commons, risk-score, verticals
New 'Bureau' tab surfacing the credit-bureau intelligence (p3/p5/p6/p7/p10):
- anonymized public credit-data commons (p6): agents, utilization, dispute
  slash rate, per-category + per-tier aggregates
- agent credit lookup: ML risk-score v2 (p7, PD + ml/rules/blended + band) +
  oracle credit-check (p3, eligibility, recommended limit, risk flags)
- per-vertical underwriting profiles table (p10)

api.ts gains typed getDataCommons/getVerticals/getRiskScore/getCreditCheck
helpers over the /v1 endpoints; adds .form-row/.chip-row CSS (also used by
existing components). Frontend tsc + vite build clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-17 23:12:13 +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
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
3200f52d5b feat(console): connect live SSE directly to the API (CORS) for rock-solid events
Vercel's edge can buffer/timeout proxied Server-Sent Events. Route the two live
streams (protocol events + analytics) straight to the API via VITE_API_BASE; the
API already sets permissive CORS. REST keeps using the same-origin rewrites.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-17 01:00:12 +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