Problem Statement
The codebase has these mutating entrypoints: initialize, donate, end_campaign, cancel_campaign, extend_deadline, release_milestone, release_milestone_multi_asset, claim_refund, freeze, unfreeze, upgrade. Each has its own auth, freeze, status, and reentrancy posture. There is no single document that maps out: "When the contract is X, who can do Y?".
Why it matters
Internal docs (in docs/events.md, code comments) cover individual entrypoints but lack a unified matrix. New contributors and security auditors have to read every function signature to reconstruct the model. A matrix-style table is the difference between 30 minutes and 3 minutes of audit time.
Expected Outcome
A new docs/state-machine.md that contains:
- A 2D table with fields: row = entrypoint; columns = "auth required", "freeze gates writes?", "status gate", "reentrancy lock acquired?", "mutates storage?", "emits events?", "events emitted".
- A state diagram (Mermaid or similar) showing all transitions.
- A freeze module documentation with the ordering invariant (freeze-before-auth).
- A "post-upgrade contract migration" checklist for upgrade events.
Acceptance Criteria
docs/state-machine.md exists and is referenced from README.md.
- Each entrypoint row in the table is verified by at least one existing test name.
- The state diagram is valid Mermaid that renders correctly in GitHub preview.
- Inline
/// doc comments on each entrypoint reference this doc.
Implementation Notes
- Place in
docs/state-machine.md next to events.md and deployment.md.
- Use a markdown table — GitHub renders it nicely.
- Reference existing issue numbers for ownership.
Affected Files / Modules
docs/state-machine.md (new)
README.md (link)
campaign/src/lib.rs (doc-comment cross-references)
Dependencies — None.
Problem Statement
The codebase has these mutating entrypoints:
initialize,donate,end_campaign,cancel_campaign,extend_deadline,release_milestone,release_milestone_multi_asset,claim_refund,freeze,unfreeze,upgrade. Each has its own auth, freeze, status, and reentrancy posture. There is no single document that maps out: "When the contract is X, who can do Y?".Why it matters
Internal docs (in
docs/events.md, code comments) cover individual entrypoints but lack a unified matrix. New contributors and security auditors have to read every function signature to reconstruct the model. A matrix-style table is the difference between 30 minutes and 3 minutes of audit time.Expected Outcome
A new
docs/state-machine.mdthat contains:Acceptance Criteria
docs/state-machine.mdexists and is referenced fromREADME.md.///doc comments on each entrypoint reference this doc.Implementation Notes
docs/state-machine.mdnext toevents.mdanddeployment.md.Affected Files / Modules
docs/state-machine.md(new)README.md(link)campaign/src/lib.rs(doc-comment cross-references)Dependencies — None.