Template-instance spawn pattern
When a user completes a recurring item (chore, ticket, inspection
round), the completion should be durable history while a fresh open
instance takes its place. This is the template→instance pattern:
template types hold the definition (name, points, tags); instance
types hold the state (completed, completed-by, completed-at, points
snapshot). A new registry action hook (spawn / complete-and-spawn)
closes the current instance and inserts the next one from the template,
copying declared fields and clearing state fields.
This is a general structural shape, not a chores special case — it covers tickets, inspections, checklists, recurring ops, any "do it again" workflow. The chores model is the pilot; Model Bank does not need this. Depends on the action hook protocol (done) and filtered rollups (item 10) for leaderboard reads over completed instances.
Implemented as a single :spawn action hook (per the plan's design
decision 1; the two-hook :spawn /=:complete-and-spawn= idea is dead).
One registry entry in lisp/model.lisp; valid-spawn-params
compile-time validation in compile-field's button branch;
spawn-close-data / spawn-data / spawn-inherit-roles runtime
helpers. Fixture models/test/spawn-test.lisp (identity field is
:type :uuid :identity t :default :generate-uuid so cleared
successors never collide on the identity index); suite
tests/spawn-tests.lisp (33 checks) + run-spawn-tests in helpers;
demo models/recurring.lisp; docs in hook-registry.md and
model-reference.md. Supporting engine fixes: value-type-p and
v-type now accept :generate-uuid on :uuid fields, db-value
generates a real UUID for it at bind time, and id-from-data skips
reserved default keywords when building dedupe filters. Full
(run-tests) green (1525 checks / 26 groups).
Plan: spawn-plan.org.
- Slot
- 26700
- Status
- 60 Done
- Tags
- mvp, backend, compiler
- Contributors
- Donnie