Skip to content

ogar-emitter: add write_adapter — the CRUD write twin of emit_projection_adapters#225

Merged
AdaWorldAPI merged 1 commit into
mainfrom
claude/promote-write-emitter-to-core
Jul 22, 2026
Merged

ogar-emitter: add write_adapter — the CRUD write twin of emit_projection_adapters#225
AdaWorldAPI merged 1 commit into
mainfrom
claude/promote-write-emitter-to-core

Conversation

@AdaWorldAPI

Copy link
Copy Markdown
Owner

What

The read arm (emit_projection_adapters, projection_adapter.rs) generates real impl From<Row> for Domain read projections. There was no Core write equivalent: the only write-side emitter here, emit_do_adapters, is deliberately signature-only (unimplemented!() bodies — thinking lives upstream). A CRUD statement is a mechanical persistence leaf, exactly the regular, falsifiable body the read arm already proves is emittable.

This promotes the write emitter (prototyped + proven in the medcare-rs consumer across MedCare PRs #233/#234/#235) into the Core, so consumers stop carrying their own copy — the Core-first home, matching the read arm.

write_adapter.rs

  • WriteValue / WriteColumn + typed constructors: bind / lit / bind_expr / bind_cast / bind_opt_cast / bind_clone / bind_bool_flag — the write inverse of the read arm's FieldSource variants.
  • InsertClass + emit_insert_adaptersINSERT … VALUES … last_insert_id.
  • UpdateClass + SoftDeleteClass + emit_update_adaptersUPDATE … SET … WHERE id = ? (with an optional COALESCE(<col>,0)=0 soft-delete filter) and the SET <flag>=1, <date>=NOW() tombstone. Both DbResult<()>.

Corpus-agnostic (only typed recipes in; no domain data). Deterministic (recipe order preserved) so a consumer byte-guards its committed generated file against a fresh emit. Generic vs the medcare prototype: the soft-delete columns and the not-deleted filter column are parameterized (flag_column / date_column / not_deleted_column), not hardcoded to pf_*.

Verified

  • 6 self-contained tests over a synthetic t_event recipe (SQL/bind consistency, id-bind-last + soft-delete filter, filter toggle, tombstone shape, multi-line doc, determinism).
  • cargo test -p ogar-emitter → 45/45.
  • cargo clippy -p ogar-emitter --all-targets -- -D warnings → exit 0.
  • do_adapter.rs left untouched — it carries a pre-existing rustfmt-version-skew diff unrelated to this change; OGAR CI gates on cargo test, not fmt.

Follow-up

medcare-rs refactors its insert_codegen to consume these types instead of its local copy (the consumer PR, once this lands on OGAR main).

🤖 Generated with Claude Code

…ion_adapters

The read arm (`emit_projection_adapters`, `projection_adapter.rs`) generates
real `impl From<Row> for Domain` read projections. There was no Core write
equivalent: the only write-side emitter here, `emit_do_adapters`, is
deliberately signature-only (`unimplemented!()` bodies — thinking lives
upstream). A CRUD statement is a mechanical persistence leaf, exactly the
regular, falsifiable body the read arm already proves is emittable.

This promotes the write emitter (prototyped + proven in the medcare-rs
consumer) into the Core, so consumers stop carrying their own copy — the
Core-first home, matching the read arm.

`write_adapter.rs`:
- `WriteValue` / `WriteColumn` (+ typed constructors: bind / lit / bind_expr /
  bind_cast / bind_opt_cast / bind_clone / bind_bool_flag — the write inverse
  of the read arm's `FieldSource` variants).
- `InsertClass` + `emit_insert_adapters` — `INSERT … VALUES … last_insert_id`.
- `UpdateClass` + `SoftDeleteClass` + `emit_update_adapters` — `UPDATE … SET …
  WHERE id = ?` (with an optional `COALESCE(<col>,0)=0` soft-delete filter) and
  the `SET <flag>=1, <date>=NOW()` tombstone. Both `DbResult<()>`.

Corpus-agnostic (only typed recipes in; no domain data). Deterministic (recipe
order preserved) so a consumer byte-guards its committed generated file against
a fresh emit. Generic vs the medcare prototype: the soft-delete columns and the
not-deleted filter column are parameterized (`flag_column` / `date_column` /
`not_deleted_column`), not hardcoded to `pf_*`.

6 self-contained tests over a synthetic `t_event` recipe (SQL/bind consistency,
id-bind-last + soft-delete filter, filter toggle, tombstone shape, multi-line
doc, determinism). `cargo test -p ogar-emitter` 45/45; `cargo clippy
-p ogar-emitter --all-targets -- -D warnings` exit 0. (do_adapter.rs left
untouched — it carries a pre-existing rustfmt-version-skew diff unrelated to
this change; OGAR CI gates on `cargo test`, not fmt.)

Follow-up: medcare-rs refactors its `insert_codegen` to consume these types
instead of its local copy (the consumer PR, once this lands on OGAR main).

Generated by Claude Code.
@cursor

cursor Bot commented Jul 22, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_37f4954b-40ec-46ec-8c26-c73882d2f667)

@AdaWorldAPI
AdaWorldAPI marked this pull request as ready for review July 22, 2026 02:34
@AdaWorldAPI
AdaWorldAPI merged commit be076ee into main Jul 22, 2026
2 checks passed
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