You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#213 fixed the schema/write half of FR-024 §7 (entity read-views): meta migrate now excludes derived (origin.*) fields from the write table and emits the replica view, and the write-side codegen (Drizzle table + Insert/Update Zod schemas) excludes them too (verified end-to-end by a real-PG round-trip). But the read half of the §7 contract is still unimplemented — spec §7 says derived fields are "excluded from INSERT/UPDATE, write codecs, and create/update inputs; reads route to the view", and only the first clause shipped.
The gaps (read side)
For a write-through entity (isWriteThrough — a writable table source + a non-primary read-only view source + derived fields):
Reads route to the TABLE, not the replica view.codegen-ts/src/templates/queries-file.ts special-cases only isProjection (→ renderProjectionQueriesFile); a write-through entity (isProjection is false) falls to the vanilla path, whose findById/list select from the entity's own collection = the write table. So a derived column (e.g. customerName) is never returned — the view exists but nothing reads it.
Introduce a shared MetaField.isDerived() per port (TS already has it, metadata/src/core/field/meta-field.ts) as the SSOT for "read-only, view-side only".
Write-through entity codegen (all ports): exclude derived fields from the write table / ORM entity / write DTOs (as TS now does); route the generated read path (findById/list/repo reads) to the replica view; make the entity's read type/DTO carry the derived fields (read shape = the view's columns).
Keep the write path (create/update) targeting the table with the derived fields absent — the same write-through dispatch projections/entities already model.
A flattened field.object on a write-through entity is not yet handled in the entity-host view SELECT (scalars + derived joins are) — track as a sub-item or a separate note.
Summary
#213 fixed the schema/write half of FR-024 §7 (entity read-views):
meta migratenow excludes derived (origin.*) fields from the write table and emits the replica view, and the write-side codegen (Drizzle table + Insert/Update Zod schemas) excludes them too (verified end-to-end by a real-PG round-trip). But the read half of the §7 contract is still unimplemented — spec §7 says derived fields are "excluded from INSERT/UPDATE, write codecs, and create/update inputs; reads route to the view", and only the first clause shipped.The gaps (read side)
For a write-through entity (
isWriteThrough— a writabletablesource + a non-primary read-onlyviewsource + derived fields):codegen-ts/src/templates/queries-file.tsspecial-cases onlyisProjection(→renderProjectionQueriesFile); a write-through entity (isProjectionis false) falls to the vanilla path, whosefindById/listselect from the entity's own collection = the write table. So a derived column (e.g.customerName) is never returned — the view exists but nothing reads it.<Entity>type (inferred from the table select) no longer carries the derived field — but a read through the view returns it. The read type and the wire shape disagree.SpringDtoGenerator/repo, Kotlin Exposed, C#EntityGenerator/EF, Python) map fields to columns/DTO members with no derived-field exclusion, and none route reads to the replica view. This is a coordinated 5-port change.Proposed shape
MetaField.isDerived()per port (TS already has it,metadata/src/core/field/meta-field.ts) as the SSOT for "read-only, view-side only".findById/list/repo reads) to the replica view; make the entity's read type/DTO carry the derived fields (read shape = the view's columns).Not in scope
field.objecton a write-through entity is not yet handled in the entity-host view SELECT (scalars + derived joins are) — track as a sub-item or a separate note.Refs
docs/superpowers/specs/2026-06-12-fr-024-entity-surfaces-projections-design.md), ADR-0028 (derived ⇒ read-only), ADR-0015 (schema TS-owned; runtime/codegen per-port).