Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
2d32be7
Test that a household job's unconfirmed commit answers 500 (failing)
anth-volk Nov 17, 2026
0b344e6
Answer 500 when a household job's commit may have been applied
anth-volk Nov 17, 2026
5d14580
Share the failing-transaction fakes, and test only the log the servic…
anth-volk Nov 17, 2026
18a9741
Merge main into C1 · 33, after #1074, #1070 and #1078 landed
anth-volk Nov 17, 2026
acf03f1
Test that database code may use only the SQLAlchemy ORM (failing)
anth-volk Nov 17, 2026
77befa9
Require the SQLAlchemy ORM for database code, ratcheted
anth-volk Nov 17, 2026
9782327
Look for Core, not for the ORM, in the ORM rule's check
anth-volk Nov 17, 2026
e6eda93
Resolve Core tables per module, and report every reference to one
anth-volk Nov 17, 2026
3925a58
Follow Core tables through module paths, mappers and attributes
anth-volk Nov 17, 2026
bd50226
Follow tables in class attributes and tuple assignments
anth-volk Nov 17, 2026
53b9cec
Follow a class attribute's table only within its own module
anth-volk Nov 17, 2026
f42de58
Report every .table read in modules that use SQLAlchemy
anth-volk Nov 17, 2026
6cab37f
Say how to name an attribute that holds a mapped class
anth-volk Nov 17, 2026
696df10
Tighten the ORM rule's wording, and accept SQL text in check constraints
anth-volk Nov 17, 2026
91c3ebf
Name the ORM conversion's tasks in the baseline header
anth-volk Nov 18, 2026
dc73a59
Add failing tests for the ORM table models and sessions
anth-volk Nov 18, 2026
b2bdce5
Count a name assigned from a mapped class's table as a Core table
anth-volk Nov 18, 2026
3470c43
Map every table sim models to a typed ORM class
anth-volk Nov 18, 2026
24bda7e
Add failing tests for writing results with INSERT alone
anth-volk Nov 18, 2026
e2f88d3
Let result classes insert with INSERT alone
anth-volk Nov 18, 2026
68450d5
Add a failing test that a written result stays readable
anth-volk Nov 18, 2026
e542d32
Read result defaults back, and state the check's limits exactly
anth-volk Nov 18, 2026
669502f
Add failing tests for session writes on real grants and defaults
anth-volk Nov 18, 2026
7b6f9ba
Align session writes with API v1's grants and defaults
anth-volk Nov 18, 2026
58ac2e2
Add failing tests for the Modal stores on ORM sessions
anth-volk Nov 18, 2026
d0cd3d0
Add failing tests for household stores on ORM sessions
anth-volk Nov 18, 2026
f64a2d6
Run household jobs and reports on ORM sessions
anth-volk Nov 18, 2026
b4f71c5
Run the Modal stores on ORM sessions and mapped classes
anth-volk Nov 18, 2026
2cb1c31
Type the sweep's activity time and note how to retry opening a session
anth-volk Nov 18, 2026
433f9f6
Test failures inside a household re-run's savepoint on a session
anth-volk Nov 18, 2026
4471b17
Add a failing test that the deployment check holds one connection at …
anth-volk Nov 18, 2026
40a86b7
Release the check's connection before it inspects the schema
anth-volk Nov 18, 2026
55fb2ec
Make the household savepoint tests prove what they claim
anth-volk Nov 18, 2026
29a74d4
Check forced household re-runs insert forced rows
anth-volk Nov 18, 2026
d2a605e
Add failing tests that the deployment check survives refused connections
anth-volk Nov 18, 2026
8c1cfa2
Retry each deployment check step when a connection is refused
anth-volk Nov 18, 2026
edb4726
Add failing tests for economy code on ORM sessions
anth-volk Nov 18, 2026
d777faa
Run economy reports and re-runs on ORM sessions
anth-volk Nov 18, 2026
86ae59a
Add failing tests for the privilege check on ORM sessions
anth-volk Nov 18, 2026
33ed15b
Run the privilege check on ORM sessions and mapped catalog classes
anth-volk Nov 18, 2026
e2b8a9c
Add a failing test that no project locks SQLModel
anth-volk Nov 18, 2026
6a6825c
Cover the deployment check's refusals and each session's closing
anth-volk Nov 18, 2026
fdba986
Remove the unused SQLModel dependency
anth-volk Nov 18, 2026
4ffd973
Add failing tests for session factories built from a database URL
anth-volk Nov 18, 2026
d9925c9
Build session factories directly from a database URL
anth-volk Nov 18, 2026
33e0196
Render the rules page for the SQLModel lock check
anth-volk Nov 18, 2026
a969a3d
Merge C1 · 33d's Modal store conversion
anth-volk Nov 18, 2026
03f26f6
Add failing tests for shared store creates and year runs
anth-volk Nov 18, 2026
8278c07
Share how stores run creates and keep year-run NULLs
anth-volk Nov 18, 2026
7eec7e1
Name API v1 in the remaining economy docstrings
anth-volk Nov 18, 2026
211c13f
Merge C1 · 33c's economy conversion
anth-volk Nov 18, 2026
348c56f
Merge pull request #1101 from PolicyEngine/v2plan/c1-33a-orm-table-mo…
anth-volk Nov 18, 2026
42b1f3e
Add failing tests for enforcing the ORM rule with no baseline
anth-volk Nov 18, 2026
2bac83e
Enforce sim.persistence.orm-only with no baseline
anth-volk Nov 18, 2026
93c81fd
Describe the enforced ORM rule and session factories
anth-volk Nov 18, 2026
a3bb297
Update the executor tests for mapped result classes
anth-volk Nov 18, 2026
cf783f9
Add a failing test that execute runs only on a session
anth-volk Nov 18, 2026
114305e
Report execute on anything but a session
anth-volk Nov 18, 2026
a4d3621
List the ORM check's remaining limits
anth-volk Nov 18, 2026
5ef91fb
Merge pull request #1104 from PolicyEngine/v2plan/c1-33b-orm-households
anth-volk Nov 18, 2026
357c7de
Merge pull request #1107 from PolicyEngine/v2plan/c1-33c-orm-economy
anth-volk Nov 18, 2026
b114881
Merge #1090's branch, with C1 · 33b and 33c, into C1 · 33d
anth-volk Nov 18, 2026
6514024
Merge pull request #1106 from PolicyEngine/v2plan/c1-33d-orm-modal-st…
anth-volk Nov 18, 2026
6a14ccb
Merge the ORM stack's base branch
anth-volk Nov 18, 2026
58eb1ab
Add failing tests for reporting Core tables where they start
anth-volk Nov 18, 2026
b3228d6
Update two executor tests for ResultRows.model
anth-volk Nov 18, 2026
d715e4b
Report Core tables where they start, without following their names
anth-volk Nov 18, 2026
2850dfd
Add failing tests for quoted annotations and the __table__ exception
anth-volk Nov 18, 2026
a69bbe1
Report quoted table annotations and narrow the __table__ exception
anth-volk Nov 18, 2026
c697f7a
Add failing tests that annotations are read as before
anth-volk Nov 18, 2026
83f854c
Read annotations as the check did before
anth-volk Nov 18, 2026
a8e797b
Add a failing test that a bare __table__ read is reported
anth-volk Nov 18, 2026
25181c1
Report reads of the bare name __table__
anth-volk Nov 18, 2026
c85e5fc
Merge the ORM stack's base branch
anth-volk Nov 18, 2026
c31748f
Wrap the ORM check's description
anth-volk Nov 18, 2026
efc1890
Cover a bare __table__ read outside SQLAlchemy modules
anth-volk Nov 18, 2026
12f6499
Add failing tests that the deployment check uses one real connection
anth-volk Nov 18, 2026
c8cd309
Run the deployment check on one pooled connection
anth-volk Nov 18, 2026
e06d70a
Add failing tests for a stalled deployment check
anth-volk Nov 18, 2026
c23c0a3
End a deployment check that stops responding
anth-volk Nov 18, 2026
85176a2
Add failing tests for the deployment check's time limit
anth-volk Nov 18, 2026
5617d7e
Give the deployment check's time limit room for every retry
anth-volk Nov 18, 2026
1982dcd
Add failing tests for lost connections and a blocked error stream
anth-volk Nov 18, 2026
53d4e17
Retry every lost connection in the deployment check
anth-volk Nov 18, 2026
0dd7074
Merge pull request #1109 from PolicyEngine/v2plan/c1-33e-orm-enforce
anth-volk Nov 18, 2026
345d095
Test that the table modules export no Core table names
anth-volk Nov 18, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ To add or change a rule, read `docs/engineering/skills/rules-registry.md`.

### Service and package boundaries

- Checked: `sim.boundaries.sqlalchemy-and-alembic-only`
- Checked: `sim.boundaries.sqlalchemy-and-alembic-only`, `sim.persistence.orm-only`
- `sim.boundaries.gateway-executor-decoupled`: The gateway and executor never import each other; they communicate only through the models and state helpers in policyengine-simulation-contract. (doc-only, not checked: follow it yourself)
- `sim.boundaries.unit-tests-need-no-services`: Unit tests never require real network credentials, Modal, Hugging Face, GCP or deployed services; those seams are mocked. (doc-only, not checked: follow it yourself)

Expand Down
1 change: 1 addition & 0 deletions changelog.d/1103.changed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The v2 Modal runtime's database stores now run on SQLAlchemy ORM sessions. They send the same statements as before, plus one `SELECT true` that checks out each operation's connection. Only that opening step is retried, so a write is never repeated. The Stage 12 deployment check now repeats a step when the database refuses or loses a connection.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
`POST /household-calculations` answers 500 `internal_error`, not 503 `database_unavailable`, when the database fails after the household job's row was inserted, since PostgreSQL may have applied the commit and the job may exist. It logs the failure as `household_job_outcome_unknown` with the commit error's type, and still answers 503 `database_unavailable` when no job was written.
1 change: 1 addition & 0 deletions changelog.d/c1-33-orm-only-rule.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The rule `sim.persistence.orm-only` requires database code to declare tables as SQLAlchemy ORM mapped classes and to run every statement through an ORM Session. The unused `policyengine_fastapi.database` module is removed.
1 change: 1 addition & 0 deletions changelog.d/deployment-check-one-connection.changed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The Stage 12 deployment check now uses one database connection for its role check, schema reads and rolled-back test writes, so it needs one free client slot on the database pooler. The check now fails after 15 minutes if the database stops responding.
1 change: 1 addition & 0 deletions changelog.d/orm-economy-stores.changed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Run the simulation service's economy reports, simulations, re-runs and budget windows on SQLAlchemy ORM sessions and mapped classes.
1 change: 1 addition & 0 deletions changelog.d/orm-household-stores.changed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Run the simulation service's household job and household report stores on SQLAlchemy ORM sessions and mapped classes.
1 change: 1 addition & 0 deletions changelog.d/orm-only-enforced.changed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Require SQLAlchemy ORM sessions and mapped classes in all of sim's database code, run the database privilege check on them, and remove the unused SQLModel dependency.
1 change: 1 addition & 0 deletions changelog.d/orm-table-models.changed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Described the database tables as SQLAlchemy ORM mapped classes and added ORM sessions with a per-transaction statement timeout. The schema and the service's behaviour don't change.
139 changes: 137 additions & 2 deletions docs/engineering/skills/database-access.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,141 @@ It builds on the Stage 12 rules:
of its own; policyengine-api migrates the Stage 12 tables.
- `sim.stage12.persistence-typed-dml-only` and
`sim.stage12.deployment-uses-api-schema`: the Stage 12 persistence
library uses typed SQLAlchemy Core DML only, with no raw SQL text.
library uses typed SQLAlchemy statements only, with no raw SQL text.

## ORM

`sim.persistence.orm-only` requires the SQLAlchemy ORM, not Core: code that
reads or writes database rows declares tables only as mapped classes and runs
every statement through an ORM `Session` against them. The rule is enforced
with no baseline, so any finding fails.

What the ORM means here:

- **Models** are SQLAlchemy 2.0 typed declarative classes (`Mapped[...]`,
`mapped_column`). Each derives from a `DeclarativeBase` in its library's
`orm_base.py`, the only module that builds a `MetaData`, with its schema. A
library has one base per `MetaData` it needs. A `MetaData` holds one table of
each name, so `policyengine-simulation-persistence` has `ServiceBase`,
`ReferencedBase`, `InputBase` and `ResultBase`, because its read-only models
and its key targets describe some of the same tables, and `CatalogBase` for
the PostgreSQL catalog tables the privilege check reads. A key to another
base's table names that class's attribute, such as `ReportRun.id`.
`policyengine-stage12-persistence` has `ComparisonBase`. Constraints and
indexes go in `__table_args__` under API v1's names. Use SQLAlchemy's own
ORM, not SQLModel.
- **Sessions:** only a library's `engine.py` creates or holds an `Engine`, and
no public function there returns one or a `Connection`. It hands out a
`sessionmaker` with `expire_on_commit=False`:
`create_simulation_session_factory` for the simulation service's connection
pool, `create_unpooled_session_factory` for the v2 Modal calls and
`create_single_connection_session_factory` for a short task that should take
one pooler slot, all from a database URL. `dispose_session_factory` closes a
factory's connections.
Everything else receives a `sessionmaker` or a `Session`, and runs a
transaction as `with session_factory.begin() as session:`, or as `with
bounded_session(session_factory, statement_timeout_milliseconds=...) as
session:` to limit its statements.
The classes declare no relationships, so a flush doesn't order inserts by
foreign key: flush the referenced row first. An attribute set to a SQL
expression, such as `func.now()`, must be refreshed before the session closes
if it will be read afterwards. To retry a refused connection without any risk
of repeating a write, retry only a first statement that changes nothing, which
makes the session check out its connection, as `StoreSessions` in
`policyengine_stage12_persistence.engine` does.
- **Statements** name mapped classes or their attributes: `session.get`,
`session.add`, `session.scalars(select(Model))`, and ORM-enabled
`update(Model)`, `insert(Model)` or
`postgresql.insert(Model).on_conflict_do_nothing()` run with
`session.execute`. The single-statement forms keep conditional updates, such
as claiming a pending job only while it has no Modal call ID, and
find-or-create inserts atomic.
- **SQL text** appears only as a model's server default, a partial index's
condition or a check constraint's condition.
- **Names:** an attribute or field that holds a mapped class is named after
what it holds, such as `model`, never `table`: every `.table` read in a
module that imports sqlalchemy is reported, because that is how a column
reaches its Core table.
- **PostgreSQL's catalog** is read through mapped classes too: `PgClass`,
`PgNamespace` and `PgAttribute` in `catalog_tables.py`.
- **Schema inspection**, for the deployment check that compares the live
schema with the models, reads the live schema through
`inspect_live_schema(session_factory)` in the Stage 12 library's `engine.py`,
which needs no Connection. An inspector on an engine takes a connection for
each read, so the check's factory has a one-connection pool
(`create_single_connection_session_factory`). It reads the models' columns
and keys from their mappers (`inspect(Model).columns`, `.primary_key`) and
`__table_args__`, none of which is reported.

`projects/policyengine-simulation-entry/tests/test_orm_only.py` runs the checks
in `orm_access_support.py` over the same files as the guard below. They look
for Core rather than for the ORM, so a statement on mapped classes passes,
including one on expressions, labels, subqueries and aliases.

Each file is checked on its own, through its own imports. A Core table is
reported where it starts, not at each later use, because the first finding
already fails the rule: where it is declared, where it is read from a mapped
class, mapper or `MetaData` or as the bare name `__table__`, and where an
annotation names `Table` or `TableClause`.

Each finding is one of:

- **Core table declaration:** a `Table(...)`, `Column(...)`, `table(...)`,
`column(...)`, `TableClause(...)`, `ColumnClause(...)` or `MetaData(...)`
call, apart from `MetaData` in an `orm_base.py`.
- **Core table access:** a parameter, variable, attribute or return annotated
`Table` or `TableClause`, unquoted or wholly quoted, apart from a class's bare
`__table__` annotation in an `orm_base.py`;
`__table__`, `local_table`, `persist_selectable` or `sorted_tables` anywhere,
and a read of the bare name `__table__`;
`tables` or
`selectable` of a mapper (`__mapper__`, `.mapper`, or `inspect(...)`,
`class_mapper(...)` or `object_mapper(...)`, called or held in a name, or a
name assigned `__mapper__` or `.mapper`) or of a MetaData (a name bound to
`MetaData(...)` or ending in `metadata`); and any `.table` read, which is
how a column or mapped attribute reaches its table, as in
`HouseholdJob.id.table`. A called `.table`, such as `sa.table(...)`, isn't
a read.
- **Core engine or connection:** `Connection` or `AsyncConnection` from
SQLAlchemy in any module; `Engine`, `create_engine` and the like outside a
library's `engine.py`, imported or referenced as `sa.Engine`; any
`.connect()`, `.connection()`, `.raw_connection()` or `.get_bind()` call;
`.begin()` on an engine (a name annotated as `Engine`, bound to
`create_engine(...)`, or named `engine` or ending in `_engine`); `.execute`
on anything not named `session` or ending in `_session`; `.scalar`,
`.scalars`, `.stream` or `.stream_scalars` on a name that is `connection` or
`conn` or ends in `_connection` or `_conn` (a query result has `.scalar` and
`.scalars` too); a public function of a library's `engine.py` whose return annotation
names an `Engine` or `Connection`; and `factory.kw["bind"]`, the engine
behind a `sessionmaker`, outside a library's `engine.py`. A library's
`engine.py` opens sessions, not connections.
- **Raw SQL:** `text(...)`, `TextClause(...)` or `literal_column(...)`
anywhere but a server default, an index's `postgresql_where` or a
`CheckConstraint`'s condition, or `exec_driver_sql` or `.cursor()`.
- **sqlmodel import.**

Those that go by a method or attribute name alone apply only in modules that
import sqlalchemy: any `.table` read, `kw["bind"]`, the statement methods above,
and the `.connect()`, `.connection()`, `.raw_connection()`,
`.get_bind()`, `.begin()`, `.cursor()` and `.exec_driver_sql()` calls.

The checks read source, not types, and guard against ordinary Core use, not
against deliberate evasion. They miss imports through `importlib`; engines and
connections passed around without an `Engine` or `Connection` annotation, so a
connection held under a name such as `session` isn't reported; a statement method
passed without being called, such as `run(connection.execute, statement)`; a
function that returns an engine with no return annotation; the engine an
`Inspector` holds in `bind` or `engine`; a quoted name inside an annotation, such
as `Optional["Table"]`; `Table` under another local name, such as `Jobs = Table`;
names from `from sqlalchemy import *`; a `.table` read in a module that doesn't
import sqlalchemy; and a Session's `bind` attribute. `.tables` of a `MetaData`
isn't reported when the name holding it doesn't end in `metadata` and wasn't
assigned `MetaData(...)`.

`test_every_table_is_mapped_by_a_class` also imports both persistence libraries
and reports every table they hold that no mapped class maps, and
`test_no_project_installs_sqlmodel` fails if the `uv.lock` of any project with
a `pyproject.toml` holds SQLModel.

## Who owns the schema

Expand All @@ -44,7 +178,8 @@ and this repository has no migration chain of its own
`policies`, `parameters`, `parameter_values`, `tax_benefit_models` and
`tax_benefit_model_versions`), which the simulation service only reads.
Their read-only models in that library's `input_tables.py` name only the
columns the service reads, apart from the models of the tables it writes.
columns the service reads and each table's primary key, apart from the
models of the tables it writes.
- the run tables the v2 Modal coordinator, workers, household functions and
stuck-run sweep write as the Modal worker role: `report_runs`,
`simulation_runs`, `budget_window_runs`, the result tables and
Expand Down
11 changes: 8 additions & 3 deletions docs/generated/rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ Every rule that governs `policyengine-sim-api` is listed here with how it is enf

| Tier | enforced | ratcheted | advisory | doc-only | Total |
| --- | ---: | ---: | ---: | ---: | ---: |
| mechanical | 64 | 0 | 0 | 14 | 78 |
| mechanical | 65 | 0 | 0 | 14 | 79 |
| metric | 1 | 0 | 0 | 0 | 1 |
| judgment | 0 | 0 | 0 | 0 | 0 |

**Blocking:** 65 of 79 rules.
**Blocking:** 66 of 80 rules.

## Gaps

Expand Down Expand Up @@ -82,6 +82,7 @@ Every rule that governs `policyengine-sim-api` is listed here with how it is enf
| `sim.boundaries.gateway-executor-decoupled` | The gateway and executor never import each other; they communicate only through the models and state helpers in policyengine-simulation-contract. | mechanical | doc-only | no | nothing | — | — |
| `sim.boundaries.sqlalchemy-and-alembic-only` | Code connects to databases only through SQLAlchemy engines and connections, never by importing a database driver directly, and runtime code never changes the schema, which changes only through Alembic migrations. | mechanical | enforced | yes | pytest `projects/policyengine-simulation-entry/tests/test_database_access_boundaries.py` | `pr.yml:test` | yes |
| `sim.boundaries.unit-tests-need-no-services` | Unit tests never require real network credentials, Modal, Hugging Face, GCP or deployed services; those seams are mocked. | mechanical | doc-only | no | nothing | — | — |
| `sim.persistence.orm-only` | Code that reads or writes database rows declares tables only as SQLAlchemy ORM mapped classes and runs every statement through an ORM Session against those classes, never through Core Table objects or Connections. | mechanical | enforced | yes | pytest `projects/policyengine-simulation-entry/tests/test_database_access_boundaries.py`, `projects/policyengine-simulation-entry/tests/test_orm_only.py` | `pr.yml:test` | yes |

```mermaid
flowchart LR
Expand All @@ -91,10 +92,14 @@ flowchart LR
e_pytest_projects_policyengine_simulation_entry_tests_test_database_access_boundaries_py["pytest projects/policyengine-simulation-entry/tests/test_database_access_boundaries.py"]
j_CI_pr_yml_test["CI pr.yml:test"]
r_sim_boundaries_unit_tests_need_no_services("sim.boundaries.unit-tests-need-no-services (doc-only)")
r_sim_persistence_orm_only("sim.persistence.orm-only (enforced)")
e_pytest_projects_policyengine_simulation_entry_tests_test_database_access_boundaries_py__projects_policyengine_simulation_entry_tests_test_orm_only_py["pytest projects/policyengine-simulation-entry/tests/test_database_access_boundaries.py, projects/policyengine-simulation-entry/tests/test_orm_only.py"]
r_sim_boundaries_gateway_executor_decoupled -.-> gap_unenforced
r_sim_boundaries_sqlalchemy_and_alembic_only --> e_pytest_projects_policyengine_simulation_entry_tests_test_database_access_boundaries_py
e_pytest_projects_policyengine_simulation_entry_tests_test_database_access_boundaries_py --> j_CI_pr_yml_test
r_sim_boundaries_unit_tests_need_no_services -.-> gap_unenforced
r_sim_persistence_orm_only --> e_pytest_projects_policyengine_simulation_entry_tests_test_database_access_boundaries_py__projects_policyengine_simulation_entry_tests_test_orm_only_py
e_pytest_projects_policyengine_simulation_entry_tests_test_database_access_boundaries_py__projects_policyengine_simulation_entry_tests_test_orm_only_py --> j_CI_pr_yml_test
```

## Stage 12 persistence
Expand All @@ -106,7 +111,7 @@ flowchart LR
| `sim.stage12.no-migration-chain` | This repository has no schema migration chain (no Alembic); Stage 12 tables are migrated by policyengine-api. | mechanical | enforced | yes | pytest `projects/policyengine-simulation-entry/tests/test_stage12_schema_authority.py` | `pr.yml:test` | **unproven** |
| `sim.stage12.no-production-user-associations` | Stage 12 runtime modules never create production user associations (user_simulations or user_reports). | mechanical | enforced | yes | pytest `projects/policyengine-simulation-entry/tests/test_stage12_schema_authority.py` | `pr.yml:test` | **unproven** |
| `sim.stage12.no-schema-ddl` | Simulation runtimes and the Stage 12 persistence library contain no schema DDL (CREATE, ALTER, DROP or TRUNCATE of tables, types, schemas or databases, or create_all); policyengine-api owns the schema. | mechanical | enforced | yes | pytest `projects/policyengine-simulation-entry/tests/test_stage12_schema_authority.py` | `pr.yml:test` | yes |
| `sim.stage12.persistence-typed-dml-only` | The Stage 12 persistence library and runtime use typed SQLAlchemy Core DML only: no raw SQL text, driver-level SQL or schema operations. | mechanical | enforced | yes | pytest `libs/policyengine-stage12-persistence/tests/test_source_boundaries.py` | `pr.yml:test` | **unproven** |
| `sim.stage12.persistence-typed-dml-only` | The Stage 12 persistence library and runtime use typed SQLAlchemy statements only: no raw SQL text, driver-level SQL or schema operations. | mechanical | enforced | yes | pytest `libs/policyengine-stage12-persistence/tests/test_source_boundaries.py` | `pr.yml:test` | **unproven** |
| `sim.stage12.production-lock-has-db-runtime` | The production lock file includes the direct Stage 12 database runtime dependencies. | mechanical | enforced | yes | pytest `projects/policyengine-simulation-entry/tests/test_deployment_assets_traffic.py` | `pr.yml:test` | **unproven** |

```mermaid
Expand Down
1 change: 0 additions & 1 deletion libs/policyengine-fastapi/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ dependencies = [
"fastapi[standard] >=0.115.8,<0.116.0",
"pyjwt >=2.10.1,<3.0.0",
"opentelemetry-sdk >=1.44.0,<2.0.0",
"sqlmodel >=0.0.22,<0.0.23",
"python-json-logger >=3.2.1,<4.0.0",
"opentelemetry-instrumentation-logging >=0.65b0,<0.66",
"opentelemetry-exporter-gcp-trace >=1.9.0,<2.0.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Reusable FastAPI and SQLModel building blocks that are independent of any one app."""
"""Reusable FastAPI building blocks that are independent of any one app."""

from .observability import (
ObservabilityConfig as ObservabilityConfig,
Expand Down
41 changes: 0 additions & 41 deletions libs/policyengine-fastapi/src/policyengine_fastapi/database.py

This file was deleted.

Loading
Loading