Skip to content
This repository was archived by the owner on Nov 25, 2026. It is now read-only.

Polish emit command - and CLI in general - #6

Merged
wmadden merged 48 commits into
mainfrom
emit-polish
Nov 13, 2025
Merged

wmadden merged 48 commits into
mainfrom
emit-polish

Conversation

@wmadden

@wmadden wmadden commented Nov 13, 2025

Copy link
Copy Markdown
Contributor

No description provided.

@wmadden
wmadden merged commit 0631662 into main Nov 13, 2025
@aqrln
aqrln deleted the emit-polish branch December 15, 2025 13:54
jkomyno added a commit that referenced this pull request Feb 25, 2026
… actions

Address wmadden's PR #168 review feedback (blocking issue #2):

- Add DDL generation test: verifies the planner outputs ON DELETE CASCADE
  and ON UPDATE RESTRICT clauses when planning from a contract with
  referential actions against an empty database.
- Add runtime behavior tests for all five ON DELETE actions:
  CASCADE (removes children), RESTRICT (blocks delete), SET NULL
  (nullifies FK), SET DEFAULT (applies default), NO ACTION (blocks).
- Add ON UPDATE CASCADE test: propagates PK changes to children.

These tests close the spec-mandated E2E coverage gap for the referential
action matrix (spec lines 158-203, acceptance criteria #5-#6).
wmadden added a commit that referenced this pull request Mar 30, 2026
…arget

Polymorphism is a cross-family concern — SQL needs single-table
inheritance and enum-discriminated rows, MongoDB needs polymorphic
collections, embedded fields, and mixed-type arrays. Both require
discriminated unions in the contract type system.

Rewrites design question #6 to cover both families with concrete storage
mapping patterns and defines minimum April validation scope: contract
can express discriminated unions, emitter produces narrowed TS types,
ORM queries return narrowed types, STI storage mapping works for both
families.
wmadden added a commit that referenced this pull request Mar 30, 2026
Promote design principles (self-describing domain model, domain/persistence
separation, scoped family details, facts-not-instructions) to cross-cutting
learnings. Update contract-symmetry with domain/storage separation proposal.
Update design questions #1 (embedding as relation property), #6 (discriminator
+ variants), #10 (domain level as shared contract surface) with concrete
design answers. Update overview with redesign summary.
wmadden added a commit that referenced this pull request Mar 30, 2026
Lead with the answer for resolved questions instead of preserving
the historical options/insights/redesign layers. Mark headings with
resolved/open status so readers know immediately.
wmadden added a commit that referenced this pull request Mar 30, 2026
Phase 3 (minimal Mongo ORM) proved the contract shape. Comparative
analysis with the SQL ORM revealed the Collection chaining API,
CollectionState, and row type inference are shared architectural
patterns. Record this finding:

- ADR 4: shared Collection interface with fluent chaining, family-
  specific compilation at terminal methods, spike-then-extract approach
- Cross-cutting learning #6: shared ORM surface enumeration
- Mongo Overview: Phase 3 complete, DQ #7 resolved, ADR 4 referenced
- PoC plan: Phase 3 moved to completed, Phase 4 rewritten for
  Collection interface direction
wmadden added a commit that referenced this pull request Mar 30, 2026
…arget

Polymorphism is a cross-family concern — SQL needs single-table
inheritance and enum-discriminated rows, MongoDB needs polymorphic
collections, embedded fields, and mixed-type arrays. Both require
discriminated unions in the contract type system.

Rewrites design question #6 to cover both families with concrete storage
mapping patterns and defines minimum April validation scope: contract
can express discriminated unions, emitter produces narrowed TS types,
ORM queries return narrowed types, STI storage mapping works for both
families.
wmadden added a commit that referenced this pull request Mar 30, 2026
Promote design principles (self-describing domain model, domain/persistence
separation, scoped family details, facts-not-instructions) to cross-cutting
learnings. Update contract-symmetry with domain/storage separation proposal.
Update design questions #1 (embedding as relation property), #6 (discriminator
+ variants), #10 (domain level as shared contract surface) with concrete
design answers. Update overview with redesign summary.
wmadden added a commit that referenced this pull request Mar 30, 2026
Lead with the answer for resolved questions instead of preserving
the historical options/insights/redesign layers. Mark headings with
resolved/open status so readers know immediately.
wmadden added a commit that referenced this pull request Mar 30, 2026
Phase 3 (minimal Mongo ORM) proved the contract shape. Comparative
analysis with the SQL ORM revealed the Collection chaining API,
CollectionState, and row type inference are shared architectural
patterns. Record this finding:

- ADR 4: shared Collection interface with fluent chaining, family-
  specific compilation at terminal methods, spike-then-extract approach
- Cross-cutting learning #6: shared ORM surface enumeration
- Mongo Overview: Phase 3 complete, DQ #7 resolved, ADR 4 referenced
- PoC plan: Phase 3 moved to completed, Phase 4 rewritten for
  Collection interface direction
wmadden added a commit that referenced this pull request Mar 31, 2026
…arget

Polymorphism is a cross-family concern — SQL needs single-table
inheritance and enum-discriminated rows, MongoDB needs polymorphic
collections, embedded fields, and mixed-type arrays. Both require
discriminated unions in the contract type system.

Rewrites design question #6 to cover both families with concrete storage
mapping patterns and defines minimum April validation scope: contract
can express discriminated unions, emitter produces narrowed TS types,
ORM queries return narrowed types, STI storage mapping works for both
families.
wmadden added a commit that referenced this pull request Mar 31, 2026
Promote design principles (self-describing domain model, domain/persistence
separation, scoped family details, facts-not-instructions) to cross-cutting
learnings. Update contract-symmetry with domain/storage separation proposal.
Update design questions #1 (embedding as relation property), #6 (discriminator
+ variants), #10 (domain level as shared contract surface) with concrete
design answers. Update overview with redesign summary.
wmadden added a commit that referenced this pull request Mar 31, 2026
Lead with the answer for resolved questions instead of preserving
the historical options/insights/redesign layers. Mark headings with
resolved/open status so readers know immediately.
wmadden added a commit that referenced this pull request Mar 31, 2026
Phase 3 (minimal Mongo ORM) proved the contract shape. Comparative
analysis with the SQL ORM revealed the Collection chaining API,
CollectionState, and row type inference are shared architectural
patterns. Record this finding:

- ADR 4: shared Collection interface with fluent chaining, family-
  specific compilation at terminal methods, spike-then-extract approach
- Cross-cutting learning #6: shared ORM surface enumeration
- Mongo Overview: Phase 3 complete, DQ #7 resolved, ADR 4 referenced
- PoC plan: Phase 3 moved to completed, Phase 4 rewritten for
  Collection interface direction
jkomyno pushed a commit that referenced this pull request Apr 1, 2026
…arget

Polymorphism is a cross-family concern — SQL needs single-table
inheritance and enum-discriminated rows, MongoDB needs polymorphic
collections, embedded fields, and mixed-type arrays. Both require
discriminated unions in the contract type system.

Rewrites design question #6 to cover both families with concrete storage
mapping patterns and defines minimum April validation scope: contract
can express discriminated unions, emitter produces narrowed TS types,
ORM queries return narrowed types, STI storage mapping works for both
families.
jkomyno pushed a commit that referenced this pull request Apr 1, 2026
Promote design principles (self-describing domain model, domain/persistence
separation, scoped family details, facts-not-instructions) to cross-cutting
learnings. Update contract-symmetry with domain/storage separation proposal.
Update design questions #1 (embedding as relation property), #6 (discriminator
+ variants), #10 (domain level as shared contract surface) with concrete
design answers. Update overview with redesign summary.
jkomyno pushed a commit that referenced this pull request Apr 1, 2026
Lead with the answer for resolved questions instead of preserving
the historical options/insights/redesign layers. Mark headings with
resolved/open status so readers know immediately.
jkomyno pushed a commit that referenced this pull request Apr 1, 2026
Phase 3 (minimal Mongo ORM) proved the contract shape. Comparative
analysis with the SQL ORM revealed the Collection chaining API,
CollectionState, and row type inference are shared architectural
patterns. Record this finding:

- ADR 4: shared Collection interface with fluent chaining, family-
  specific compilation at terminal methods, spike-then-extract approach
- Cross-cutting learning #6: shared ORM surface enumeration
- Mongo Overview: Phase 3 complete, DQ #7 resolved, ADR 4 referenced
- PoC plan: Phase 3 moved to completed, Phase 4 rewritten for
  Collection interface direction
jkomyno added a commit that referenced this pull request May 8, 2026
…-less reload

Resolves todos #2-#6 from the PR #440 multi-agent review:

* #2 — Add unit tests for the new returning-capability requirement
  on updateCount() / deleteCount(). Both throw with an explanatory
  message when the contract lacks the returning capability, locking
  the breaking-change behavior introduced in M1.

* #3 — Pass a single trivial column to compileUpdateReturning /
  compileDeleteReturning in updateCount() / deleteCount() instead of
  the previous undefined (which expanded to "every column"). New
  helper pickCountReturningColumn() in collection-contract.ts prefers
  the first PK column when present (always non-null) and falls back
  to any storage column for id-less tables.

* #4 — Stream-count the RETURNING result instead of materializing
  the full row buffer via .toArray(). Both count helpers now use
  for-await + counter, dropping memory cost from O(N×W) to O(1).

* #5 — Add integration test covering the id-less mutation reload
  code path: nested update() on an id-less Users contract (PK
  stripped, UNIQUE (email) retained) routes through
  buildRowIdentityCriterion id-less branch and reloads the row via
  the row-identity criterion. New createIdlessUsersCollection helper.

* #6 — Remove dead code: compileDeleteCount has no callers post-M1.
  Drops the function from query-plan-mutations.ts, the export from
  query-plan.ts, and the corresponding test fixture.

Mark todos 002-006 as complete in the todos/ directory.
wmadden added a commit that referenced this pull request May 27, 2026
Spec + plan for S1.E: namespace-aware enum planning (TML-2686).
Follow-on correctness fix surfaced by CodeRabbit on PR #595 — the
Postgres migration planner keys enum lookups by bare TypeScript name
across namespaces, so two namespaces holding enum.<sameName> collide
silently. Pre-existing bug, surfaced by S1.B's slot rename touching
the line.

Sized L per drive/calibration/sizing.md; decomposed into 5 dispatches
(M/M/M/S/S). Sequenced after S1.D per operator decision (could
parallelise with S1.C/D but reviewer attention stays on the critical
path until the structural slices close).

Project plan adjustments:
- At-a-glance: four → five slices
- New S1.E section under Stack with Purpose/Dispatches/Scope/Linear
- Parallel groups: extended stack thread + sequencing rationale
- Sequencing visualisation: S1.E node added
- Realistic budget: × 4 structural + ~0.5 day S1.E = ~10.5-12.5 days
- PDoD1 row: 4 → 5 slices (no new PDoD added; S1.E satisfies none)
- Risk #6: SchemaIssue shape blast radius (goldens regen at D4)

No commits to follow on this branch — slice execution starts after S1.D
closes. Documenting here so the deferred follow-up is discoverable.

Linear: TML-2686 (relatedTo TML-2584 parent project; relatedTo TML-2623
S1.B PR that surfaced this).

Signed-off-by: Will Madden <[email protected]>
wmadden added a commit that referenced this pull request May 27, 2026
Spec + plan for S1.E: namespace-aware enum planning (TML-2686).
Follow-on correctness fix surfaced by CodeRabbit on PR #595 — the
Postgres migration planner keys enum lookups by bare TypeScript name
across namespaces, so two namespaces holding enum.<sameName> collide
silently. Pre-existing bug, surfaced by S1.B's slot rename touching
the line.

Sized L per drive/calibration/sizing.md; decomposed into 5 dispatches
(M/M/M/S/S). Sequenced after S1.D per operator decision (could
parallelise with S1.C/D but reviewer attention stays on the critical
path until the structural slices close).

Project plan adjustments:
- At-a-glance: four → five slices
- New S1.E section under Stack with Purpose/Dispatches/Scope/Linear
- Parallel groups: extended stack thread + sequencing rationale
- Sequencing visualisation: S1.E node added
- Realistic budget: × 4 structural + ~0.5 day S1.E = ~10.5-12.5 days
- PDoD1 row: 4 → 5 slices (no new PDoD added; S1.E satisfies none)
- Risk #6: SchemaIssue shape blast radius (goldens regen at D4)

No commits to follow on this branch — slice execution starts after S1.D
closes. Documenting here so the deferred follow-up is discoverable.

Linear: TML-2686 (relatedTo TML-2584 parent project; relatedTo TML-2623
S1.B PR that surfaced this).

Signed-off-by: Will Madden <[email protected]>
wmadden-electric added a commit that referenced this pull request Jun 26, 2026
… caller-side whitelist

Policies now nest under a PostgresTableNode (database root → table → policy),
so a policy’s id() is just its wire name — unique among its table’s policies —
instead of folding namespace/table into the key. Same-wire-name policies on
different tables stay distinct via their table nodes.

The framework differ becomes total: an unmatched non-leaf node emits its own
issue and descends, emitting one per node in the missing/extra subtree. So an
initial migration (every table missing) still surfaces the policies beneath
the missing tables. Coalescing a parent change over its children is the
planner’s job.

Ownership and node-type selection leave the differ. diffPostgresSchema(expected,
actual) takes two built IRs, runs the total diff, whitelists policy-subject
issues (isPostgresRlsPolicy), and drops extra policies in namespaces expected
does not own. filterSchemaIssuesByOwnership is removed from framework
schema-diff.ts — the differ is pure.

namespaceId is resolved to its DDL schema name once, at derivation
(collectContractRlsPolicies), via the existing resolveDdlSchemaForNamespaceStorage,
so expected and actual table nodes pair by id(). The degraded resolveNamespaceId
duplicate is deleted.

Also completes the coordinate→path migration missed in 6bd0f25: the family-sql
filterSchemaDiffIssues test and the supabase skeleton test referenced the removed
.coordinate field (CI Test + Type Check were red on that tip).

Addresses review comments #2, #5, #6; #3 (id()) landed separately; #4 (rename the
root off "IR") deferred as its own leveling change.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant