Expand description
Persist an Improv Model in Postgres, in the improv.* catalog that the
pg_improv extension computes over (design:
docs/reviews/2026-10-14-pg-improv-design.md §2, §5).
PgModelStore mirrors improv_storage_mentat::ModelStore method for
method. The model is stored normalized: one row per category, item,
measure and view, input cells either in their bound fact table (an
improv.binding row maps a measure to SELECT dims…, value FROM rel) or,
when unbound, in improv.cell. improv.model_version is the optimistic
concurrency token.
Encoding (v1; the extension must read the same):
measure.formula: written as serde JSON of theFormulaAST (the DSL printer lives in the GUI crate); read as JSON or, failing that, as DSL text (Target = expr, what the extension’simprov.definewrites);measure.value_type:number | boolean | text | datetime | enum;cell.coord:{"<category id>": <item id>, …};- cell values: plain JSON scalars (number, bool, string; datetimes as RFC 3339 strings);
lambda.definition: written as serde JSON of theNamedLambda; read as JSON or asName = LAMBDA(…)text (whatimprov.definewrites);meta.blob:{external_fns, external_calls, scenarios, sql_sources}. Beforeimprov.lambdait also heldlambdas, still read for a model with noimprov.lambdarow.
Structs§
- PgModel
Store - A model store over one named model in a Postgres database.
- PgSnapshot
- What a
PgModelStorelast loaded or saved: the basesave_modeldiffs against, so a save writes only what this client changed. Carry it across handles withPgModelStore::set_snapshot, as withloaded_tx.
Enums§
Constants§
- CATALOG_
SQL - The catalog this client depends on (design §2), created when the
pg_improvextension is not installed so a plain Postgres works too.
Functions§
- split_
model_ url - Split
postgres://…?model=<name>[&…]into the connection string without themodelparameter and the model name (required).