Task: Generate the entity part of each component's SQL aggregates
Table of Contents
This page documents a task in the Complete the ORE report configuration story. It captures the goal, current status, acceptance, and any notes or results.
1. Goal
A new entity reaches the database with no hand-edited aggregate. Codegen owns the list of a component's entity files; people own only the hand-written files and the prose around them.
2. Status
| Field | Value |
|---|---|
| State | BACKLOG |
| Parent story | Complete the ORE report configuration |
| Now | Not yet started. |
| Waiting on | Nothing. |
| Next | Begin implementation. |
| Last touched | 2026-10-02 |
3. Acceptance
- Codegen emits, per component, a create fragment listing each entity table then its notify trigger, and a drop fragment listing each notify trigger drop then its table drop.
- Each component's hand-written create and drop aggregate includes its fragment once, and no longer lists a generated entity file itself.
- A database recreate succeeds, and the set of tables, functions, triggers and policies it builds is identical to the set before the change.
- Adding an entity to a component needs no aggregate edit, and the drift check fails when a fragment is stale.
4. Plan
(Implementation strategy. Written when work starts; key decisions
are distilled into the parent story's * Decisions at close, but the
plan itself stays — it is the historical record of what we did.)
5. Measurements
Every number this task claims about a tree, with the command that produced it
and the commit it was measured at. A number without both is not a measurement,
because a clean-up record describes a tree and trunk moves under a branch: a
consumer count, a gate's component count and a suite's size all change with no
code changing, and the reader of a bare number cannot tell which tree it came
from. Where the raw output matters, put it in an evidence/ file beside the
task and name that file in the Command column.
| What | Value | Command | Commit |
|---|---|---|---|
6. Notes
From the hand-written SQL census in Find why so much SQL is hand-written and generate what codegen can.
Order inside a component does not depend on soft foreign keys: 88 tables are
already created before the parent their insert trigger checks, and every
recreate succeeds. What does need order: a table before its notify trigger, the
trigger drop before the table drop, functions from earlier components (the root
create.sql already orders those), and hand-written files that name a table
when they are created (SQL-language functions, views, alter scripts), which
must come after the fragment.
First check, before changing any aggregate: recreate a scratch database with one component's aggregate reordered to the planned shape, and compare its catalogue with the current one.
7. Test Scenarios
Manual QA scenarios (scaffolded via compass add test_scenario)
that verify this task. Link
new ones here as they're created; the scenario doc itself links back
via its "Verifies task" field.
| Scenario | State | Notes |
|---|---|---|
8. PRs
| PR | Title |
|---|---|
9. Review
| Comment summary | File | Decision | Notes |
|---|---|---|---|