Skip to content

Extract shared compiler crates: weft-model, weft-expr, weft-backend, weft-postgresql-emit - #70

Merged
easel merged 6 commits into
mainfrom
claude/quirky-rhodes-c21c30
Nov 16, 2026
Merged

easel merged 6 commits into
mainfrom
claude/quirky-rhodes-c21c30

Conversation

@easel

@easel easel commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

Splits weft's UMF model, expression and backend layers into crates another compiler can depend on. Fireweed (a queue data plane) is the first such caller: its compiler will use UMF for its schemas and lower a typed IR to PostgreSQL, SQLite and Turso.

New crates

Each crate starts at 0.1.0, is versioned separately from weft, and has a README that states its public surface.

Crate Contents Depends on
weft-model UMF loading, name and identity resolution, logical types, descriptors, exact literals and instants, bounded JSON, diagnostics, core_literal field-domain checks —
weft-expr typed operands, comparisons, exact arithmetic, the weft.update-selection/1 predicate format (CONTRACT-009) weft-model
weft-backend the CONTRACT-002 boundary: manifests, Frontend, Backend<F> with an associated Artifact, NoArtifact, the compile pipeline, Registry, the SQL Emission carrier weft-model
weft-postgresql-emit identifier quoting, parameter slots, string literals, typed casts with the C collation, result decoders weft-model, weft-backend

What stays the same for weft

  • weft-core re-exports the moved items under their old module paths. Backends, runtime, Python and WASM compile without edits.
  • weft_core::backend becomes weft's frontend and keeps its Backend trait, Context, Registry, Compilation and type paths. Check order, refusal codes, diagnostic codes and the Compilation wire shape are unchanged.
  • Emitted SQL is unchanged, and the generated fixtures don't drift. weft-postgresql now calls the shared cast, literal and decoder helpers instead of five copies of them. The Truss storage layout stays in weft-postgresql.
  • The closed four-family Family still types every weft profile, so weft-sql 0.1–0.3 can't represent timestamps or floats.

Opt-in additions (experimental)

  • ScalarFamily adds UMF timestamp (exact UTC instants) and float (finite binary64). Callers reach it through field_as and the *_as descriptors. Admission::nullable_fields types fields that may be absent as nullable.
  • PostgreSQL emission adds timestamptz and float8 casts for those families.
  • The SQL carrier adds result decoders: utc-instant for timestamps and ieee754-binary64-hex for floats. Emission, Column and Representation take a family-set parameter that defaults to Family, so weft's own emissions can't carry these columns.

These additions have unit tests only, and no weft frontend uses them yet.

Tooling and CI

  • The four crates are workspace members, are covered by both module-boundary policies, and appear in a generated boundary inventory (scripts/module-boundaries-update.ts). They are added to the architecture table and CHANGELOG.
  • check-release-version.py --shared-crates checks the shared crates' versions and now runs in the checks job (.github/workflows/ci.yml).
  • The job that tests against the latest UMF also tests weft-model.

Verification (local)

  • cargo test --workspace --locked: 1,136 tests passed.
  • The nightly feature set that covers the changed PostgreSQL code: 1,170 tests passed.
  • The bun spec and module checks and the Python wheel quickstart passed.
  • The generated SQL fixtures are byte-identical.
  • The "qualified registrations" CI job wasn't run in full locally; its feature set compiled.

🤖 Generated with Claude Code

easel and others added 6 commits November 16, 2026 02:42
Move UMF document preparation, name and identity resolution, logical types,
descriptors, exact literals, exact instants, bounded JSON and diagnostics out
of weft-core into a new crate, weft-model 0.1.0 (own semver; README states
its public surface). weft-core depends on it and re-exports it under the old
module paths, so backends, runtime, Python and WASM compile unchanged.

- Catalog admission flags become an explicit Admission profile
  (prepare_with, admit, admission); documents are read via documents().
- LogicalType is generic over a FamilySet. weft profiles keep the closed
  four-family Family, so weft-sql 0.1-0.3 cannot represent timestamps or
  floats. ScalarFamily adds UMF timestamp (exact UTC instants) and float
  (finite binary64 tokens) for opt-in callers (field_as, *_as descriptors);
  Admission::nullable_fields types absent-allowed Fields as nullable.
- Exact decimal coefficient arithmetic moves to weft_model::exact.
- Tooling: workspace member, both module-boundary policies, a generator
  for the boundary inventory (scripts/module-boundaries-update.ts), a
  shared-crate version check in check-release-version.py run by CI, the
  UMF canary job tests weft-model, architecture table and CHANGELOG.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ate-selection

New crate weft-expr 0.1.0 (own semver; README states its public surface),
depending only on weft-model:

- operand: Field<F> and Value<F> (moved from application_ir; wire shapes
  unchanged).
- compare: CompareOp (eq ne lt le gt ge) with the typing rule (same domain,
  no ordering on booleans) and weft-sql 0.3's ComparisonOperator (moved
  from arithmetic_plan).
- arithmetic: exact Domain/Expression/Kind, Domain::of_field and
  token_domain (moved from arithmetic_resolve; resolve() stays with the
  weft-sql parser).
- selection: the weft.update-selection/1 predicate format (CONTRACT-009):
  a pre-order walk with caller domain checks, encode, comparisons,
  first-use dependencies and connective splicing. The mutation frontend
  builds selections with it; inspect_selection and the PostgreSQL mutation
  lowering decode with it instead of two hand-written walks. Refusal
  messages are unchanged.

weft-core re-exports the moved types under their old paths. weft-postgresql
depends on weft-expr directly. Tooling: workspace member, both boundary
policies and the regenerated inventory, shared-crate release check,
architecture table, CONTRACT-009 note, CHANGELOG.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
security_literals (CoreLiteral checks against a UMF Field's facets, widths,
ranges, allowed values, examples and defaults) and the field-domain
normalizer from security_ontology move to weft_model::core_literal.
weft_core::security_literals and security_ontology::domain re-export them;
diagnostic codes (WFT-SECURITY-LITERAL, WFT-SECURITY-ONTOLOGY) are
unchanged. Adds weft-model unit tests, README row, inventory and CHANGELOG.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
New crate weft-backend 0.1.0 (own semver; README states its surface),
depending only on weft-model:

- manifest: Manifest, profiles, capabilities, obligations and structural
  validation; accepted interface versions and language/IR pairs come from
  the frontend's ManifestRules.
- boundary: Frontend (typed program, selection, binding reader, preflight,
  catalog admission), Backend<F> with an associated Artifact returned by
  emit, TargetArtifact (merges obligations, checks itself), NoArtifact for
  backends that emit nothing, the checked compile pipeline, Registry<F, A>.
- sql: the SQL Emission carrier (parameter slots, columns, representations,
  carriers, decoders, NativeMetadata) as one artifact type.

weft_core::backend becomes weft's frontend (WeftPlans: plans, 0.2.x
manifest rules, Truss binding reader, capability preflights, emission
checks) and keeps its Backend trait, Context, Registry, Compilation and
type paths, so every backend implementation compiles unchanged. Check
order, refusal codes and the Compilation wire shape are unchanged.
Tooling: workspace member, both boundary policies, inventory, shared-crate
release check, architecture table, CONTRACT-002 note, CHANGELOG.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
New crate weft-postgresql-emit 0.1.0 (own semver; README states its
surface), depending on weft-model and weft-backend: quoted identifiers
(Identifier, qualified), numbered parameter slots (Parameters,
CatalogDomain, now with slots() and set_origin()), standard and escape
string literals, typed casts with the C collation (typed, cast_type,
collate_c; timestamptz and float8 for opt-in families), and exact result
decoders (decoder, decoder_for).

weft-postgresql re-exports Identifier, qualified, Parameters and
CatalogDomain, and its Truss runtime, candidate and mutation lowerings
call the shared cast, literal and decoder helpers instead of five
duplicated copies. Emitted SQL is unchanged (generated fixtures do not
drift). The Truss storage layout stays in weft-postgresql.

Tooling: workspace member, both boundary policies, inventory, shared-crate
release check, architecture table, CONTRACT-002 note, CHANGELOG.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
ScalarDecoder gains utc-instant (YYYY-MM-DDTHH:MM:SS.ffffffZ) for the opt-in
timestamp family and ieee754-binary64-hex (the binary64 bit pattern) for float,
with ScalarDecoder::exact picking a family's decoder. Emission, Column and
Representation take a family-set parameter defaulting to Family, so weft's
emissions cannot carry these columns; Emission<ScalarFamily> can. SqlChecks is
generic over the same parameter.

weft-postgresql-emit: decoder_for returns a decoder for every family, and
decodable projects an expression to its decoder's text (to_char in UTC,
encode(float8send(..), 'hex')). Experimental: unit tests only.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@easel
easel merged commit 745b003 into main Nov 16, 2026
9 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.

1 participant