Documentation

Docs / Reference

ADR 0053 - Python model syntax payload

Status: Accepted (delegated review, 2026-11-09)

Context

Milestone M2 of the project plan names SQLModel/SQLAlchemy models as a schema source, and the T018 schema plan (the T018 task record (internal)) splits that work into T018c1 (capture the syntax, cache only) and T018c2 (emit model-defined table/column nodes). T018a needed nine reviews because its claimed surface was open, so T018c1 closed the surface first (rule 33): a finite claim contract (61 rows, docs/lang/python-models.md), an inventory of every model form in the ten corpora (the investigation, the T018c1 task record (internal)) and an oracle (SQLAlchemy's own MetaData after import) against which the contract's reference model had 0 disagreements. Revision 2 (2026-11-09) replaced the prediction of import failures with the assumption that model modules import, as they do when the application runs (V7), and keeps failures the source proves as diagnostics (P1).

Model linking needs more than the existing cached Python facts hold: class keywords (table=True), the class body (annotations, Field(...) and Column(...) arguments, __tablename__, __table_args__), Core Table(...) calls and the sites that mutate a table after its definition. The cache must hold syntax only (rule 31: no cross-file claim in a per-file cache), the smallest payload that keeps every real target (rule 32), and a versioned shape (rule 28).

Options considered

  1. Reuse PythonBinding values only. Class bindings already keep bases and module bindings keep a trimmed value. They drop class keywords, the class body and every call argument model linking reads; widening them would change every Python file's cache and every consumer of bindings.
  2. A full class-body payload for every class. Simple to describe, but it caches bodies of thousands of classes that are not models (langflow has far more classes than the 63 table and chain classes) and every expression's text, against rule 32.
  3. A gated, reduced payload (chosen). A new additive field captured only in files that import sqlmodel or sqlalchemy, with bodies only for classes that can be models, and reduced expressions.

Decision

Consequences

Known gaps

Review notes (delegated review, 2026-11-09)

Accepted together with ADR 0054 after T018c1 Revisions 1-3 and T018c2 Revisions 3-3.3 (records: the T018c1 task record (internal), the T018c2 task record (internal)).

Report a problem with this pageSource: docs/adr/0053-python-model-syntax-payload.md