Tutorial
Build a forum API with an agent
Your agent writes a small forum service: members-only threads, edit rights, and a reply cap. Yichus proves its access rules over every handler, runs any request on rows you choose, and keeps that run as a record you can reopen in the browser.
This one is for developers comfortable with a terminal. To build a data app instead, start with Make a data app.
Code & run Run the forum’s access policy
What the proof says
Here is the verdict on the forum as written. Every access rule holds; what fails is about running two copies of the service on one database:
Verbatim from docs/forum-demo/outputs/npm-step2-verify.txt, which scripts/forum-demo/replay-npm.sh regenerates and a test holds this page to. Lines elided are marked ....
$ npx yichus@0.3.9 verify forum.bosatsu --output verdict.json
Not proven: 13 properties checked (12 proven, 1 violated). Topology: undeclared (treated as multi-instance).
First failure (violated): Interleaving the program's own table operations keeps its invariants. This property is broken; the details are the evidence.
race-free:moderators: 2 valid orderings over 'moderators' produce differing effect sequences (topology undeclared or multi-instance: fix the handler or declare instances=1)
race-free:posts: 30 valid orderings over 'posts' produce differing effect sequences (topology undeclared or multi-instance: fix the handler or declare instances=1)
Every property:
proven Parses and type-checks
proven Access rules declared or storage absence established
proven Every DB operation covered by a declared rule
proven Every table operation is seen by the checks
proven "profiles": each user reads and writes only their own rows
proven "threads": rows are read and written only where can_see allows
proven "posts": rows are read and written only where can_see and can_edit allow
proven "moderators": rows are read and written only where is_moderator allows
...
proven Handlers that read then write cannot lose updates within one request
proven A save cannot drop an edit saved since its caller read the row
violated Interleaving the program's own table operations keeps its invariants
The full verdict, with every property's details, is in verdict.json.
Declare a single instance and the same check passes. The proof shows every write sits under the rule; whether that rule is the one you asked for stays your call.
Ask about one request
Can a stranger read a members-only thread? One run answers it: a 403 with the rule that refused it, kept as a record you can reopen on the WebMCP workbench.
Start
Ask your agent to walk you through the hour: install the npm command line, type-check, prove the access rules, run one request, and open its record. It has every command and the outputs to expect.
Ask your agent about anything here; it has the detail.
Where this fits
What this is about: Safety and Permissions