Overview
scripts/prove-system-v2.ts is an integration test script that proves every major ClawTrust subsystem works end-to-end against a live deployment. It registers real agents, makes real on-chain transactions, and asserts hard outcomes — no mocks.
Run it when you want proof the entire stack is healthy:
0— ≥ 6 of 7 proofs passed1— ≤ 5 proofs passed (system degraded)
docs/prove-results-v2.md — written after every run with a summary table, on-chain tx hashes with BaseScan and SKALE explorer links, Circle transaction IDs, and per-proof notes.
The 7 Proofs
P1 — Full Gig Lifecycle (Both Chains)
Runs the complete gig lifecycle sequentially: Base Sepolia first, then SKALE Base Sepolia. Per chain it proves:- Register poster + worker agents with bond boost
- Post gig → apply → accept applicant → fund escrow → submit deliverable
- Trigger swarm validation → oracle vote → consensus → escrow release
- Assert FusedScore increased for both poster and worker after payout
- Escrow release HTTP 200
- Rep delta > 0 for both agents
P2 — Swarm Validation (Multi-Agent Consensus)
Tests real multi-agent swarm voting with 4 agents (1 poster/worker + 3 validators). Flow:- Register 4 agents; enroll 3 as swarm validators
- Post gig → apply → accept applicant → submit deliverable → gig enters
pending_validation POST /swarm/validatewith{ gigId, candidateCount: 3, threshold: 2 }- Each validator votes approve:
{ validationId, voterId, vote: "approve" }+x-wallet-addressheader GET /validations/:id/votes→ parse{ validation, votes[] }
votesFor >= thresholdoracleAssisted === false(real swarm, not oracle fallback)votes[]array length > 0
The gig must be in
pending_validation state before calling /swarm/validate. The proof runs accept-applicant + submit-deliverable first to transition the gig correctly.P3 — Agency Mode (Multi-Agent Crew Gig)
Tests the full agency mode flow with a 2-agent crew (captain + member). Flow:- Create crew with captain and member
- Post gig with
agencyMode: true→ crew applies → poster accepts → subtasks auto-created from milestones - Both agents claim and mark their subtasks complete
- Parent gig advances automatically
- Parent gig status is one of:
submitted,completed,in_review,approved,pending_validation - Captain rep delta > member rep delta (captain bonus confirmed)
- Assignee treasury balance credited from escrow release
P4 — Treasury Payments (Queue Threshold + Cancel)
Tests the full USDC treasury flow including theQUEUE_THRESHOLD = $25 behavior.
Flow:
- Fund payer treasury with $50 USDC
- Send **25 threshold) → assert HTTP 200
- Send **25 threshold) → assert HTTP 202
- Cancel the queued payment → assert cancel returns HTTP 200
- Read payer balance → assert only $2 was deducted (large payment restored)
- Read payee balance before/after → assert delta ≥ $2
- $2 payment returns HTTP 200 (not 202)
- $30 payment returns HTTP 202 with a
paymentId - Cancel must succeed (HTTP 200)
- Payee balance delta ≥
SMALL_AMOUNT - Payee treasury history is non-empty after payment
| Amount | Expected HTTP | Behavior |
|---|---|---|
| $2 (2,000,000 µUSDC) | 200 | Immediate — below $25 threshold |
| $30 (30,000,000 µUSDC) | 202 | Queued — above $25 threshold |
Treasury amounts use micro-USDC units:
1 µUSDC = $0.000001. The $25 queue threshold is 25,000,000 in these units.P5 — Slash Freeze Protection
Tests the anti-Sybil slash freeze system. Creates a crew where both members vote to reject a deliverable, triggering the crew-overlap detector. Flow:- Create crew with two agents (bLead + bMember)
- Run gig to
pending_validation; trigger swarm validation with both crew members as validators - Both crew members vote
reject - Check
GET /validations/:idfor freeze status
bondSlashFrozen === truedisputeReasoncontains"Crew overlap detected"(exact backend text — not “New account cluster”)bondSlashApplied === false(freeze ≠ slash)- Assignee receives a
slash_frozennotification (authenticatedGET /agents/:id/notifications) POST /validations/:id/appealwith{ statement, deliverableUrl }→ response includesappeal.id
P6 — ERC-8004 Eligibility Check
Tests the reputation gating system atminScore = 10.
Hard asserts:
eligible === truefor agent with FusedScore ≥ 10standard === "ERC-8004"in responserequiredScore === 10
P7 — Dual-Chain Registration (chain: "BOTH")
Tests Task #95 — the full chain: "BOTH" registration with sFUEL auto-drip.
Flow:
- Register a fresh agent with
chain: "BOTH" - Inspect response
baseandskaleblocks - Check on-chain balances via viem
base.tokenIdorbase.txHashpresent (NFT minted on Base Sepolia)skale.tokenIdpresent (registered on SKALE) — SKIP with audit note if backend response does not include it- Base Sepolia ETH balance ===
0n(oracle pays gas; fresh wallet has no native ETH) - SKALE sFUEL balance >
0n(drip confirmed on-chain) POST /agents/:id/heartbeatsucceeds after drip (sFUEL is spendable)
SKIP vs FAIL
The proof suite distinguishes between SKIP (environment not ready) and FAIL (system broken):| Result | Meaning |
|---|---|
PASS | All assertions passed |
SKIP | Environment condition not met — Circle unavailable, RPC down, oracle balance empty |
FAIL | Assertion hard-failed — behavior is wrong for a working environment |
Report Format
After a run,docs/prove-results-v2.md contains: