Skip to content

feat(entity-framework): Postgres DDL emitter + org/job control entities (Phase 3a) - #125

Merged
athvin merged 1 commit into
mainfrom
feat/entity-framework-phase3a-control-ddl
Oct 16, 2026
Merged

athvin merged 1 commit into
mainfrom
feat/entity-framework-phase3a-control-ddl

Conversation

@athvin

@athvin athvin commented Oct 16, 2026

Copy link
Copy Markdown
Owner

What

Brings the control plane under the entity framework. Unlike the lake (NOT NULL only), control tables carry the constraints the dispatcher's correctness depends on.

  • Postgres DDL emitter (er-entity-gen): CREATE TABLE public.<rel> with each column's type / NOT NULL / DEFAULT / REFERENCES, accepted_values → a CHECK, the primary key from the entity key, and secondary indexes (including partial unique indexes with a WHERE). The Rust struct emitter now emits arrow_schema() only for Arrow-wire entities — control entities are JSON-only.
  • entities/org, entities/job — the orgs and jobs tables as entities. The generated jobs DDL matches the hand-written pg.rs schema, with the five 32-bit integer columns (priority/attempt/max_attempts, orgs.active_config_version) widened to bigint — the vocabulary has no i32, which is exactly the one migration the design calls for. org.state renders its accepted_values as a CHECK.
  • Index gains a required name (Postgres indexes are named objects).

Verification

Generated Org/Job structs compile (serde + utoipa, no arrow). Tests cover the widened integers, the REFERENCES, the partial unique index, and the CHECK.

Next (3b)

The pg-clause rewrite (strip RETURNING/ON CONFLICT/FOR UPDATE SKIP LOCKED), the control query functions (map tokio_postgres::Row into the struct by name — deletes job_from_row), and the Postgres oracle (prepare_typed, gated on ER_TEST_PG_DSN).

🤖 Generated with Claude Code

…es (Phase 3a)

Brings the control plane under the entity framework. Unlike the lake (NOT NULL
only), control tables carry the constraints the dispatcher depends on.

- er-entity-gen gains a Postgres DDL emitter: CREATE TABLE public.<rel> with each
  column's type/NOT NULL/DEFAULT/REFERENCES, accepted_values as a CHECK, the
  primary key from the entity key, and secondary indexes (incl. partial unique
  indexes with a WHERE). The Rust struct emitter now emits arrow_schema() only for
  entities that cross the Arrow wire — control entities are JSON-only.
- entities/org and entities/job: the orgs and jobs tables as entities. The
  generated jobs DDL matches the hand-written pg.rs schema, with the five 32-bit
  integer columns (priority/attempt/max_attempts, orgs.active_config_version)
  widened to bigint — the vocabulary has no i32, exactly the one migration the
  design calls for. org.state renders its accepted_values as a CHECK.
- Index gains a required `name` (Postgres indexes are named objects).

Generated Org/Job structs compile (serde + utoipa, no arrow). Tests cover the
widened integers, the reference, the partial unique index and the CHECK. The pg
rewrite (RETURNING/ON CONFLICT/FOR UPDATE), control query functions and the
Postgres oracle follow in 3b.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@athvin
athvin merged commit 5c7a0e0 into main Oct 16, 2026
7 checks passed
@athvin
athvin deleted the feat/entity-framework-phase3a-control-ddl branch October 16, 2026 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants