Lifecycle data-effect contract :compose-string hook
*Compose-String: Server-Side Computed Fields
Enables types with multi-part natural keys (e.g. author first/middle/last) to expose a single stored identity scalar for FK/M2M lookup and display. Model authors state the composition once; the compiler guarantees it runs before validation and writing on every insert and update.
Three layers shipped:
Lifecycle data-effect contract —
run-lifecycle-hooksnow returns the merged data plist. Pre-create/pre-update hooks run before validation inbe-insert,be-insert-internal, andbe-update, so hooks can fill required fields. Also fixedfull-datato respect explicit nil values (sentinel pattern).:compose-stringlifecycle hook — Registry hook with:format(template string with:field-keyplaceholders) and:into(destination field). Compile-time validation of placeholders and destination. New:stringparam type.:composefield sugar — Field attribute that expands to:compose-stringon:pre-create=/:pre-update=. Self-reference and duplicate-with-manual-hook are compile errors.
Files changed:
lisp/model.lisp—:stringparam type,:compose-stringregistration, helpers (compose-string-apply,compose-string-placeholders,valid-compose-placeholders,expand-compose-hooks), placeholder validation incompile-lifecycle-hooks,:composein field attr allow-list, lifecycle keys inpreliminary-model-checklisp/backend.lisp—merge-data-effect,run-lifecycle-hooksreturn value,be-insert=/=be-insert-internal=/=be-updatereorder,full-datasentinel fixtests/compose-tests.lisp— unit suite (bare) + behavioral suite (shared model context)tests/compose-sugar-tests.lisp— sugar compile-error suite + behavioral suitetests/helpers.lisp—run-compose-tests,run-compose-sugar-teststests/hook-registry-tests.lisp— two test hooks fixed to return nilmodels/test/compose-test.lisp,models/test/compose-sugar-test.lisp— fixturesdata-ui.asd— registered both test filesdocs/hook-registry.md,docs/model-reference.md,AGENT.md,~/workbench/data-ui-todo.org— documentation
907/907 tests green across 15 groups.
Design: ~/workbench/compose-string-investigation.org
Docs: docs/hook-registry.md (Registered Lifecycle Hooks), docs/model-reference.md
(:compose section, Identity fields guidance), AGENT.md (model features, hooks).
- Slot
- 24900
- Status
- 60 Done
- Tags
- mvp, backend, compiler
- Contributors
- Donnie