Entity / One domain declaration
Who owns what across the domain
| Responsibility | Owner |
|---|---|
| Product fields, relations, derived counts | foldkit-entity (define, relate, derived) |
| Single-field format rules | Effect Schema on the field |
| Cross-field and transition invariants | foldkit-entity (Entity.invariant) |
| Named lifecycle states | foldkit-entity (Entity.refine) |
| Operation-level writes and preconditions | Declared Write (Mutation.update / Write) |
| Filtered and sorted queries | Query and Expr declarations |
| Read and write authorization rules | foldkit-guard using the same Expr |
| SQL tables and column mappings | Server (foldkit-remote-drizzle's bind) |
| Browser row cache and optimistic layers | Client (foldkit-remote in Model) |
| Form drafts and submit validation | foldkit-form in parent Model |
| Editor open state and save status | foldkit-crud reading Remote |
Two boundaries keep the domain predictable:
- Declarations stay explicit: Adding an Entity or relation adds no automatic endpoints or CRUD lists; every query and write exists only where you declare it.
- The server writer decides: Client evaluations and forms compute early hints and optimistic layers from the same rules, while the server's database statement makes the binding decision.