Elffuss BraidHub

kikocis/utopia public

dev · 5.5 KiBSourceRawPermalink

0011 · A mapping is configuration

The problem

The semantic layer stored "business concept → data asset definition" as a fact: subject a concept entity (Metric / Dimension), predicate mapped_to — a row in relation_types beside works_at — object an object_value JSON { source, table?, expr?, sql?, unit?, summary? }, confidence 0.6 proposed / 1.0 confirmed. review_routes picked it up as a low-confidence fact (< 0.75), Confirm set 1.0, and chat.rs read confirmed_mappings (≥ 0.75) into the query prompt.

The reuse was deliberate and bought three real things: a Review flow with zero new UI, bitemporal history for free, and an evidence chain like any other fact's. Splitting means rebuilding all three.

Dead ends

Decisions

  1. Its own table, concept_mappings: concept entity id → definition, fields as columns, UNIQUE (kb_id, concept_id, source) (a constraint; id is the primary key), plus a derived column for derived metrics. mapped_to leaves relation_types, DEFAULT_RELATION_TYPES empties, and a new KB seeds no relations at all.
  2. Review without borrowing the low-confidence tier. A proposal is configuration, not a knowledge assertion. Built first as its own Review group, then (#140) as a standalone Data Mappings page, with Review keeping only a count and a link (#148: a mapping is neither a queue nor a history). The approval endpoints stay in review_routes, where the mapping.decided audit stream lives.
  3. History as revisions. created_at / confirmed_at / confirmed_by on the row, full snapshots in concept_mapping_revisions written by revise(), and a History drawer on the page.
  4. Evidence recorded separately — a mapping's evidence is "which table's schema the LLM read", not "which sentence". Not built: concept_mappings has no such column, and exploration proposals leave no evidence.
  5. No data migration. Mock data only; the old mapped_to facts stay in the ledger unread (as with #125). After release this convenience is gone.
  6. Two things that landed unplanned. propose() uses ON CONFLICT … DO UPDATE … WHERE status = 'proposed', so rerunning exploration does not erase a human rejection (when the WHERE fails, RETURNING yields zero rows). Visibility is tiered: a Viewer can read the list, revise needs Editor — seeing the answer without the definition means trusting an algorithm you are not shown.

Revisions

Open questions