Skip to content

Add npm run judge, JUDGES.md, and refuse failed deliveries honestly - #19

Merged
angelraph merged 1 commit into
masterfrom
claude/judge-run
Nov 10, 2026
Merged

angelraph merged 1 commit into
masterfrom
claude/judge-run

Conversation

@angelraph

Copy link
Copy Markdown
Owner

Part 4 of the plan: one command for judges, plus a bug the command found.

npm run judge (scripts/judge-testnet.ts) runs real testnet transactions and prints PASS or FAIL per claim:

  • A. The desk refuses 40 (maxPerClause) and 12 to a payee with no paid jobs (newPayeeCeiling); the same 12 passes for a payee with released clauses.

  • B. A direct create_clause panics MANDATE:max_per_clause and MANDATE:new_payee_ceiling; set_mandate from a non-DAO account panics ONLY_OWNER; a forged record_outcome panics ONLY_OWN_CLAUSE.

  • C. A full job: the clause has exactly one function-call key. While it is funded:

    • the buyer's submit_delivery → ONLY_WORKER_KEY
    • early expire → NOT_EXPIRED
    • close → NOT_TERMINAL
    • the worker's freeze → ONLY_BUYER
    • the worker key moving NEAR → needs full access
    • the worker key calling another method → not allowed
    • the worker key calling another contract → receiver mismatch

    Then a gasless delivery pays exactly 2, standing rises by 1, and close returns about 1.99 NEAR.

  • D. A 1-minute job: a late delivery is refused, anyone can expire and the buyer gets 2 back, and close returns the deposit.

Latest run: 23 of 24 passed before the fix in this PR. The 24th was the late delivery, which the clause did refuse on chain while the desk's reply said success. With this PR the check passes as refused. After merge it will show DEADLINE_PASSED once the desk deploys.

Bug fixed

  • A meta-transaction's outer status reports the delegate action, not the call inside it. So a delivery that the clause refused (for example DEADLINE_PASSED) was logged as delivered and answered as success.
  • relayDelivery now reads the clause's own receipt (innerFailure) and throws DeliveryRefusedError with the contract's reason.
  • /relay answers 422 and does not log a delivery.
  • The agent library also checks that the clause left funded.
  • Tests: 2 new in tests/relayer.inner.test.ts, 1 new in tests/near.relayer.test.ts.

Also

  • Scripts and src/agent use FastNEAR RPC; rpc.testnet.near.org is deprecated and rate-limited us mid-run.
  • JUDGES.md: a five-minute path, each claim mapped to its check and reason code, the test counts, the on-chain accounts, and the known limits. Linked from the top of the README.

Checks: root typecheck, 226 tests.

🤖 Generated with Claude Code

scripts/judge-testnet.ts runs every claim on testnet with real
transactions and prints PASS or FAIL with explorer links: the desk's
refusals before signing, earned standing lifting a limit, the factory's
own mandate checks, a full job attacked while funded (the buyer cannot
deliver, nobody can expire early or close, only the buyer may freeze,
the worker key cannot move NEAR or call anything else), a gasless
delivery that pays at once, close returning the deposit, and a job
left to expire. Each attempt to break a rule must fail with its code.

Running it found a real bug: a relayed delivery that the clause
refuses (for example after the deadline) still reported success,
because a meta-transaction's outer status covers the delegate action,
not the call inside it. The relayer now reads the receipt the clause
ran, the desk answers 422 with the contract's reason and does not log
a delivery, and the agent library checks the clause left "funded".

Scripts and the agent library now use FastNEAR's RPC; the public
rpc.testnet.near.org endpoint is deprecated and rate-limits.

JUDGES.md gives a five-minute path and maps each claim to its check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
clausehold Ready Ready Preview Nov 10, 2026 6:49am UTC
clausehold-api-mainnet Ready Ready Preview Nov 10, 2026 6:49am UTC
clausehold-api-testnet Ready Ready Preview Nov 10, 2026 6:49am UTC

@angelraph
angelraph merged commit e8c7ce5 into master Nov 10, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant