Skip to content

A definition can be written by hand #562

Description

@WaylandYang

Today a row in concept_mappings has exactly one way in: exploration proposes it, a person confirms it. A person can revise or reject, and cannot write one from nothing.

That is the wrong way round for the case that matters. A data team mounting a warehouse usually already has its definitions — a metrics doc, a dbt semantic layer, the SQL behind last quarter’s report. #520 measured what those definitions are worth once they are in the prompt: on the wide corpus, 1 of 18 right answers without them, 17 of 18 with them. What is missing is not a structure (0011 built the table) and not exploration (0 of 18 on that corpus, and it cannot see a convention that is not in the schema). It is a door.

Capability

  • POST /kbs/{id}/mappings — a person writes a definition: concept name, kind (metric / dimension), mounted source, and the same table_name / expr / sql / unit / summary / derived the revise form takes. Written rows land confirmed with the author in a new written_by column (migration 0046), so a hand-written row and an exploration-proposed one stay distinguishable; decided_by cannot tell them apart, since a confirmed proposal has one too.
  • Same validation as revise: at least one of table, expression, SQL. The source must be mounted. One definition per (concept, source), as the table already constrains; a clash is a conflict, not a silent overwrite.
  • Exploration cannot clobber a written definition: propose only refreshes proposed rows, which is the same rule that protects a rejection.
  • POST /kbs/{id}/mappings/preview — run a definition through the read-only gate on its source and return the first row. The person writing sees the number it produces before saving, which is exactly the judgement the bench makes (A mapping proposal has never been scored #501, A chat answer is never checked against the data #520), moved onto the page.

The concept still becomes an entity of the builtin Metric / Dimension class, because that is the table’s current shape. 0035 retires that shape (#556) and keeps the table, rendering into it; a written SQL survives the move.

Interface, after

A New definition entry on the Data Mappings page reusing the revise form plus a concept name, a preview before save, and a chip on the list saying written or proposed. Waits for #552 (bulk actions, external) to land, since both touch Mappings.tsx. Follows web/DESIGN.md and the existing FormDialog.

Measured by

ask.mjs --seed already simulates this door by writing the truth straight into the table (17/18). Once the endpoint exists the seed goes through it instead of raw SQL, so the bench exercises the same path a person uses.

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