Skip to content

Consumer reads over the catalog: the collapse as SQL, then the metric card, checks and bands #92

Description

@phas02

What it buys

A reader attached to the catalog, with no engine door, gets the consumer-facing surfaces: the metric card (definition, unit, formula, standing rulings, as-of), the declared checks with their band, and the band points with their breach. The rest of the quality surface — profiles, coverage, the landing account, open questions, lineage, rivals — stays the docket's.

Gated: a stable tree and a test bed with a second reader attached to the catalog. Nothing here is built before both stand.

What stands

  • crates/catalog/src/record.rs:183 — the record's relations are tables of the catalog's own database, glossql_<relation>; a reader reaches them by a second attach of that database, not through the lake's tables.
  • crates/glossary/src/store.rs:1294 — collapsed_read: the collapse (newest per subject, aspect, actor kind; human over agent; a witness's detector where one stands) is Rust; crates/session/src/reads.rs:389 — verdicts runs the detectors for it.
  • crates/session/reads/metric_surfaces.sql — the metric card's record row, in the engine's dialect.
  • crates/glossary/src/store.rs:439 — check outcomes and band points are rows of measurements, JSON; crates/scripts/functions/metric_bands.sql calls the kernel at measure time and re-runs at re-measure; crates/scripts/functions/band_breach.sql and crates/scripts/functions/rate_tolerance.sql are the judgments, SQL over slots at read.
  • crates/session/src/whatif.rs:63 — whatif_batch: a plan rewrite and a kernel call per read; nothing landed.
  • crates/catalog/src/tables.rs:62 — the catalog creates the macro tables; a macro carries one implementation per dialect (ducklake_macro_impl.dialect); nothing writes them.
  • crates/session/src/cube.rs:1231 — land_head_inner: a computed result landed under its key and replaced in one commit, the pattern a landed read would follow.

The change

Two roads, both through the collapse:

  • The collapse as SQL: collapsed_read and the detector run expressed as one query the engine plans, equal to the Rust collapse on every fixture. The first unit, and the only one without the gate.
  • Then, per surface, one of: a macro in the catalog with an implementation in the engine's dialect and one in the reader's, over the record's tables (two texts per rule, held equal by the test bed); or a landed read, one small table per dataset under the head mechanism, replaced when the measurements it reads move (one text, one landing per re-measure).
  • Whatif and a forecast stay out: they call the kernel per read, and whether a business reader needs them realtime or cached is measured first.

Done when

  • The collapse as SQL: the session suite holds it equal to the Rust collapse on the corpus fixtures, detectors included.
  • With the gate open: the metric card, the checks and the band points read from a second reader attached to the catalog, equal to the engine's reads on the finance fixture.
  • Whatif is unchanged.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions