Skip to content

The correction loop

Someone spots a wrong answer. In dst it ends as a fix in your files plus a test that proves the mistake stays fixed.

Raise for review: a doubted answer becomes a ticket carrying the full trace, an AI judge triages, a human rules — never auto-merged — and the ruling lands as files in your repo

The loop has four steps, and a person is in the middle of it:

  1. Someone doubts an answer. They flag it — or dst flags it itself.
  2. dst opens a ticket with everything needed to judge the answer: the question, the SQL, the rows, the answer, and how it was verified.
  3. An AI does the paperwork, a person decides. The AI compares and triages. A human approves or rejects it. Nothing is ever applied without a person's approval.
  4. The fix becomes a file and a test. The file goes in your repo like any other change. The test re-runs every time you publish, so the same mistake cannot quietly come back.

The rest of this page is those four steps in detail.

A wrong answer becomes a ticket

Two ways a ticket opens:

  • A caller flags an answer. Their AI calls the send_for_review tool (or POST /v1/reviews) with a note, and optionally the SQL they believe is right. Both are recorded as a proposed correction, not just a complaint.
  • dst flags itself. Set auto_review: unverified (or partial, which covers both) in lens.yaml and low-confidence answers open tickets on their own. The queue watches the lens, not just its callers.

What lands in the ticket is the whole story — question, SQL, answer, row count, verification report — so the reviewer judges the answer, not a summary of it.

If a very similar question has already been certified, its known-good SQL is attached for comparison, and an AI judge takes a first pass: an answer the judge explicitly approves is closed automatically, and everything else goes to a human — every other verdict, and every unparseable or empty reply. (With no AI model configured, everything goes to a human, full stop; with no embedding provider, no certified SQL is attached to compare against.)

People rule from the dashboard or the terminal:

dst rule <ticket> --verdict approve|changes|reject [--certify]

--certify does two things in one move: files the ruling and saves the question with the SQL that was served as a certified answer — an answer dst will from now on serve exactly as approved, and test on every publish. It snapshots the traced request, not the correction's proposed SQL, so use it when the served SQL was right; take a corrected query through the patch path below instead.

dst correct: the correction filed with its kind and target, straight from the terminal

A ruling becomes a fix in your files

Once a ticket is ruled on, the fix is written where it belongs. A person approves; there is no auto-merge.

  • A certified answer is server-side state: dst rule --certify promotes it in the same act, and it takes effect immediately.
  • A definition or instruction lives in your files, and your files win on every dst apply. So the fix is a change in your working tree, written by you or your AI from the ticket: an amended definition page, a sentence in lens.yaml instructions. You review it like any code change (git diff), commit it, and apply. Until then it is not live.

Add a behavioral test case for the corrected question to evals/cases.yaml, so it re-runs on every dst apply. A certified fix needs no case: the certified corpus already re-tests it.

An outside-lens answer becomes a lens

An answer read from a table a lens exposes without definitions, through the sql tool with a question or through query, is eligible for review like any other. Its ticket carries what the reviewer rules on: the question, the SQL as it ran, the tables it read, and every check with what it decided (grain, data end, join conservation, clocks, reconciliation against a certified number). Approval has two outcomes:

  • dst rule <ticket> --verdict approve --certify writes a certified pair, pinned to the blueprints of the tables it read, so a changed grain, key or clock re-tests it. On a lens served through Cube, --cube-query '<json>' supplies the Cube query that is the governed reading; dst certifies it only when its rows equal the answer's, and the command writes the kind: cube pair to the lens's certified_answers.yaml.
  • dst seed-lens <ticket> scaffolds an entity file per table read and a lens over them, with the question as a must-answer case. The files say where the definitions go; the slots they cannot fill from the ticket are marked TODO for the author.

Either way the next time the question is asked, it is a governed answer.

After the fix lands

The corrected question is served from its approved SQL from then on — the same answer every time, cheaper and faster than generating it again. And because every fix carries a test that re-runs on every publish, a mistake you have caught cannot ship again unnoticed.

Tickets are not the only thing that feeds this loop: bootstrapping from history seeds your definitions before the loop even starts. Everything goes through the same discipline: a draft, a human approval, a file.