bend-laws
Prove business rules with Bend laws and check shipped TypeScript or Go against the proven model. Use for formal proof, LAWS.bend or PROOF.bend, or acceptance criteria that must hold for every input.
- License 许可
- MIT
- 最近更新
- 2026-11-14
- Stars
- ★ 4
- Forks
- 1
01 前言 Front Matter
- name
- bend-laws
- paths
- [ "**/*.bend", "**/laws/**" ]
- description
- Prove business rules with Bend laws and check shipped TypeScript or Go against the proven model. Use for formal proof, LAWS.bend or PROOF.bend, or acceptance criteria that must hold for every input.
02 资源文件 3
- 参考文档REFERENCE.md4.9 KB
- 脚本templates/check.sh3.1 KB
- 脚本templates/install-bend.sh2.3 KB
03 SKILL.md 正文
When proving changed behavior or maintaining verification, read the Poteto adaptation.
A law is an acceptance criterion that a proof must meet for every input. Bend checks the proofs against a reference model of the rule. A table generated from that model ties the shipped code to the laws.
Fit
Use laws for rules that decide money, access, or safety and are finite or integer arithmetic: modes, permissions, statuses, thresholds, time windows, rounding. Route strings, parsers, JSON, floats (Bend's F32 is axiomatic and there is no F64), and UI to property tests (fast-check, rapid) instead; proving them costs more than it catches.
Ownership
File in laws/<rule>/ |
Owner |
|---|---|
LAWS.bend |
Human. The bend-laws-guard hook denies agent writes; a human opts a session in with BEND_LAWS_AUTHOR=1. |
policy.bend (model), PROOF.bend, oracle.bend |
Agent |
decisions.txt |
Generated by laws/check.sh --write |
Workflow
- Read the shipped rule and its tests. List every input and the decision it returns. Done when the input domain is enumerated (finite) or its boundaries are named.
- Draft the laws in a scratch directory as
LAWS_draft.bend(import paths allow only letters, digits,_and-), and prove them there. Give each law one plain-English comment. Done when the human has reviewed the draft and committed it asLAWS.bend.- Call only the functions under test. Define every helper a law uses inside
LAWS.bend, so the model cannot weaken a law by redefining its vocabulary. - State what must hold. Anything a law leaves open is whatever the model does, so pair each prohibition ("never runs X") with the requirement ("runs only what declares Y").
- Write imported constructors qualified and braced:
case P.Yes{}:. A barecase Yes:on an imported type binds every value and the law passes vacuously (bendlang/bend#1328);check.shand the hook reject it.
- Call only the functions under test. Define every helper a law uses inside
- Model the rule in
policy.bend, mirroring the shipped code's branch order, and prove each law inPROOF.bendasdef Laws.<law>(...). Done whenbend PROOF.bendprintsALL PROOFS CHECK. - Mutate the model once per law: change a branch the law guards and confirm
bend PROOF.bendprintsSOME PROOFS FAILat that law; then revert. Done when every law has rejected a mutant. A law no mutant fails is vacuous. - Write
oracle.bend, whosemainprints the# @generatedheader and one<inputs> <decision>line per input, then runlaws/check.sh --write. - Compare the shipped code: a unit test parses
decisions.txtand asserts the shipped function returns every row. For a finite domain, also assert each input appears once, with the domain derived from the code's types so a new value breaks the build. For an unbounded domain, generate inputs with property tests, seed the law boundaries, and compare against the model compiled withbend -o model.mjs. Done when a mutant in the shipped code fails the test. - Copy templates/install-bend.sh and
templates/check.sh into
laws/, then add a required CI job that runs both. Add CODEOWNERS forlaws/**/LAWS.bendandlaws/**/decisions.txt. Done when the job fails on a missingLAWS.bendand passes once it lands.
To change a rule: the human edits the law, the agent updates the model and proofs, runs
check.sh --write, then changes the shipped code until its unit test matches. Review
every decisions.txt diff as a behavior change.
Before writing Bend, run bend guide; read REFERENCE.md for the syntax
traps, proof patterns, --verdict setup and upgrades.
Guardrails
- Propose law changes to the human; never edit
LAWS.bendor work around the hook. - Keep
@unsafe,def f?and foreign code out of law directories: they switch off the soundness a proof relies on. Bend's gate andcheck.shboth reject them. - Keep the Bend version pinned in
install-bend.sh; upgrade deliberately and re-prove. - Keep source on the machine: sending code to BendAI or publishing to the Bend hub needs explicit approval.
04 同仓库更多 Skills
learn-taste
Turn a session's design corrections into scoped, reasoned rules for future agents. Use for /learn-taste or requests to remember design feedback, not general workflow retrospectives.
learn-taste
Turn a session's design corrections into scoped, reasoned rules for future agents. Use for /learn-taste or requests to remember design feedback, not general workflow retrospectives.
pull-requests
Use when finalizing a pull request or continuing an existing one; preserve the requested endpoint and draft state.
pull-requests
Use when finalizing a pull request or continuing an existing one; preserve the requested endpoint and draft state.
hill-climb
Optimize a defined outcome through bounded evaluation loops. Use for hill-climb requests or repeated improvement against an executable eval, benchmark, or visual comparison; not a one-pass review.
gestures
Build or fix web drag, swipe, sheet, reorder, and hold interactions: direct tracking, rubber banding, release velocity, momentum, snap points, and interruption. Not native React Native or Swift.