host: relations-as-posts slice 5 — refinement types (schemas on the type-post)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 22s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 22s
A type-post carries its schema in a :schema slot (a list of {:block :msg} rules — a
refinement {x : T | x has these blocks}). host/blog-schema-of reads it off the post;
the hardcoded host/blog-type-schemas table is gone. A NEW refinement type is pure
data: give a type-post a :schema and its instances are validated on save — no code
(tested with a 'guide' type requiring a 'pre' block). article's schema is migrated
onto the article post at boot (host/blog--set-schema!, a single read+write).
host/blog-put! now MERGES over the previous record, so editing a post's
title/content doesn't nuke its :schema/:rel metadata (also closes the Slice 2
'edit drops :rel' gap). schema-of reads the post (a durable read) — only the SAVE
path calls it (a write request, never a render that would VmSuspend).
conformance 299/299 (+4: article h1 enforced from the post, a new refinement type
validates its instances, schema read off the post, edit preserves :schema).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -100,11 +100,21 @@ relation-subtype closure when relations get subtyped; the boot title cache above
|
||||
with constraints-as-posts. (Process note: a sibling loop running heavy conformance saturates
|
||||
the box; host conformance can EXIT 124 purely from CPU contention — use `timeout 1200`.)
|
||||
|
||||
### Slice 5 — constraints as posts + validation
|
||||
- Promote the schema/`:constraint` slot to **constraint-posts** (a predicate expr +
|
||||
message), attachable to any type. Save-time validation evaluates the constraints of a
|
||||
post's full (transitive) type set. Relation cardinality (`is-a` single-valued? `tagged`
|
||||
many?) becomes a declared constraint too.
|
||||
### Slice 5 — refinement types (schemas ON the type-post) — DONE
|
||||
- A type-post carries its schema in a `:schema` slot (a list of `{:block :msg}` rules —
|
||||
a refinement `{x : T | x has these blocks}`). `host/blog-schema-of` reads it off the
|
||||
post; the hardcoded `host/blog-type-schemas` table is gone. A NEW refinement type is pure
|
||||
data: give a type-post a `:schema` (`host/blog--set-schema!`) and its instances are
|
||||
validated on save against it — no code. Tested with a `guide` type requiring a `pre` block.
|
||||
- Save-time validation (`type-issues`/`type-valid?`, the only callers, in the SAVE request)
|
||||
unions the schemas of a post's full transitive type set — unchanged, just sourced from the
|
||||
posts. `schema-of` reads the post (a durable read) — fine in the save request, never render.
|
||||
- `host/blog-put!` now MERGES over the previous record, so editing a post's title/content
|
||||
doesn't nuke its `:schema` / `:rel` metadata (also closes the Slice 2 "edit drops :rel" gap).
|
||||
- `article`'s schema migrated onto the article post (`set-schema!` at boot — a single
|
||||
read+write, not a loop, so boot-JIT-safe; idempotent, handles the already-seeded article).
|
||||
- FUTURE: arbitrary predicate constraints (not just required blocks); constraints as their
|
||||
own posts; relation cardinality (`is-a` single-valued?) as a declared constraint.
|
||||
|
||||
## Open design questions (track as we go)
|
||||
1. **Subject-end declarations** — who may be the *source* of a relation (a root `Thing`?).
|
||||
|
||||
Reference in New Issue
Block a user