chain-rdeveloper portal
build

The decision record

The decision record is one page per governed turn, an answer or a skill run, that says everything the platform recorded about it. That covers:

  • what was asked and what came back;

  • the configuration that answered;

  • every rule that ran;

  • the quality check and any human input;

  • what a reviewer was asked and decided;

  • the steps, model calls and tool calls;

  • the cost.

It is what "Why did it do this?" opens.

GET /app/decisions/{invocation_id}

The pieces used to sit in five places that did not join. They join on one id. Every answer, skill run, and evaluation or dashboard cell mints an invocation_id (rule_engine.new_invocation_id), and everything the turn writes carries it:

WhereColumnSince
A skill runskill_runs.invocation_id (a UUID since 91)migration 68
Every rule evaluatedgovernance_events.invocation_idmigration 54
The spendgovernance_usage.invocation_idmigration 91
Review flagsreview_flags.invocation_idmigration 91
svc-ai's model and tool callscore_invocation_id on llm_invocations / tool_invocationssvc-ai migration 26

svc-core tells svc-ai the id with an X-Invocation-Id header, set around a turn's calls with ai_client.in_invocation / use_invocation. svc-ai's CoreContextMiddleware reads it beside X-Workspace.

Rows svc-core writes take the id as an argument rather than from the contextvar. Most are written in a run_in_executor thread, and those threads do not inherit contextvars. tests/test_invocation_ids.py fails on a record_usage or record_flags call that leaves it out.

Sections

app/services/decisions/sections.py holds the sections, one class each, in reading order. Each has a typed model in schema.py, discriminated by key.

KeyWhat it holdsSource
answerThe answer or the run's output, its outcome, the blocking rule, or the Output rule that withheld it (withheld_by, with a note — the content is then the rule's message, and the answer itself is only on its review item)the assistant's message, the run
configurationAgent and revision, skill and revision, modelmessage meta, the run, svc-ai for a direct prompt
rulesEvery rule evaluated, with its outcomegovernance_events
web_sourcesEach web search the turn made (what it asked, what came back, what each engine said, what each check removed) and what each Tools rule did to them; empty when the agent did not search the web, and a note for searches recorded before they kept a report (25 October 2026)svc-ai GET /stats/turns/{id} (tool_calls[].report), the turn's Tools rows (web_search_summary.summarise)
quality_checkThe evaluator's outcome, score, critique and gaps (answers only)message meta
human_inputEvery pause and its answer, or the pause still waitingmeta.hitl, the run's responses / interrupt
reviewsFlags raised on the turn and their decisionsreview_flags
outcomeThe verdict a person gave (accepted, corrected or rejected), every earlier one, and the dataset cases the turn becamedecision_outcomes, test_cases.source_invocation_id
stepsThe nodes the turn ran through, with tokens and tools. A knowledge lane's step (__domain_retrieval__, __temporal_retrieval__, __reasoning_retrieval__) also names its kind and role, and counts its knowledge bases, queries, passages found, judged, ruled out, out of the window, handed on and packed, with a failed judge or search (lane; counts only, never a query or a passage)the stored trace's node_end frames, each lane's result frame and the join's packing, the run's steps
model_callsEvery model call: model, node, tokens, latency, costsvc-ai GET /stats/turns/{id}
tool_callsEvery tool call, its arguments, output (cut at 4,000 characters), citations, and a web search's reportsvc-ai GET /stats/turns/{id}
costThe ledger rows and their totalgovernance_usage
readsWho other than the owner has opened the record, when, and through which flagdecision_reads

A gap reads as a gap

A section never shows an empty list where nothing was recorded. Its status (DecisionEnum.SectionStatus) says which case it is, and its note says why:

StatusMeaning
emptyRecorded, and there was nothing: no rule applied, no tool was called.
not_recordedThe turn did not record this.
unavailableThe source could not be read: svc-ai was unreachable, or the section failed to build. The rest of the record still renders.

Known not_recorded cases:

  • Turns from before 12 October 2026. Migration 91 gave older answers a rule ran on their id, through governance_events.message_id. It stamped the answer only, so the record finds the question by timestamp. Their ledger rows, flags and svc-ai's calls name no turn.

  • The HTTP prompt endpoint (POST /app/agents/{id}/prompt) stores no quality check and no steps, only the rules a turn ran.

Who can read it

The record holds a person's whole question and answer, so two kinds of reader may open it. The response's access field says which one applies.

  • owner: the person whose turn it was, meaning the conversation's owner or the user who started the skill run. That is how conversations and skill runs are read.

  • reviewer: whoever may open and resolve a flag raised on the turn. The rule is the review queue's own, review.may_review:

    • a superuser;

    • the governance editors of the organisation or project the flag is filed under;

    • for a flag an organisation's rule raised in one of its projects, that organisation's governance editors.

    Judging a flagged answer needs the question it answered and how it got there, not only the excerpt the queue shows. A turn nobody flagged is not open to reviewers, superusers included.

Anyone else gets 404, the same as for an id that does not exist, so the endpoint does not reveal whose turns exist.

Every reviewer read is logged. A decision_reads row (migration 93) records whose turn it was, who read it, the flag that let them in, and when. The row is committed before the record is served. If it cannot be written, the request fails with a 503 and serves nothing, because somebody else's record is not shown unless the log says who saw it. The owner's own reads are not logged.

The log is shown on the record as its last section, so the owner can see who has looked. It is also in the owner's data export.

Verdicts and the flywheel

Whoever may read a record may also give the turn a verdict:

  • accepted: the answer was right as it stood;

  • edited: it was right once corrected, and the corrected text is kept;

  • rejected: it was wrong.

A verdict can carry a free-text business-outcome label ("refund issued") and a note. Each verdict is an append-only decision_outcomes row (migration 94). A changed mind is a new row, and the newest is the turn's verdict, so the record keeps who said what and when. The monthly statement will count these as verified decisions.

POST /app/decisions/{id}/outcome   {verdict, corrected_text?, label?, note?}
POST /app/decisions/{id}/case      {test_suite_id, redact_pii = true}

Verdicts come from three places:

  • The chat. Accept / Correct / Reject (VerdictBar). Accept and Reject take one click, so that a verdict costs less than ignoring the answer, and a reloaded chat shows the verdict given (ConversationMessageRead.verdict). The chat puts the verdict in view only when the answer calls for it:

    • a rule blocked, redacted or flagged it;

    • its quality check failed or did not run;

    • it already has a verdict.

    This is util/decisionAttention.ts needsAttention, read from the answer's stored rule trace and meta. On any other answer, a greeting included, it is one hover away ("Judge this answer"). Every answer is recorded either way: what is quiet is the chat, never the record.

  • The record's Verdict card. Any verdict, with its label and note.

  • Resolving a review flag (PATCH /app/reviews/{id}, verdict). The flag can be warranted and the answer still right. That verdict's source is review and it names the flag.

Add to dataset turns a turn with a verdict into a case in a dataset the person can change, never a gold dataset. Its verdict decides the label:

VerdictThe case gets
editedthe correction as its reference answer
rejectedthe answer as an example graded 0, with the note as its reason

The question becomes the case's prompt. A skill run's prompt is its task, and an answer's earlier conversation (up to 40 messages) becomes the case's situation.history.

Personal data is redacted by default with the governance rules' own detectors (rules/pii.py, bare placeholders). The response says how many values of each kind were removed.

The case is validated by the same schema as a hand-written one. It is tagged from-decision plus its verdict, and names its turn (TestCase.source_invocation_id, not part of the dataset's content version). The dataset takes a version as for any case added (dataset_versions.record_suite_version). A turn with no verdict yet is refused with a 409.

Adding a section

  1. Add a model to schema.py with key: Literal["…"], give every field a default, and add it to DecisionSection.

  2. Add a SectionBuilder in sections.py with @register, its key, title, model and kinds.

  3. Report what the turn did not record through status and note, never as an empty list.

tests/test_decision_record.py checks that every registered section has its own model and that the response union is exactly the registered models.

In fe-core

The page is apps/user/pages/decisions/Decision.tsx, at /governance/decisions/id/<id> (decisionHref(invocationId)). Every workspace mounts it, so a link from an organisation's or a project's pages stays in that workspace. It is a DetailPage with no edit history, because nothing in it is ever edited.

  • One card per section, in the order svc-core sends them. Each card shows its status only when the section is not simply recorded ("None", "Not recorded", "Unavailable"; the DECISION_SECTION scale) and always shows its note. A key the page does not know yet still shows its title, status and note, so a new section is never lost. objects/Decision.tsx's DECISION_SECTION_KEYS is pinned to the registry by svc-core's tests/test_decision_record.py.

  • The rules read as on Governance → Rules → Activity. Both draw a rule with components/governance/RuleEventRow.

  • A reviewer is told so. When access is reviewer, a note says the read has been logged and that its owner can see it.

  • The Verdict card draws its controls before any verdict exists (always on its renderer). These are Give a verdict (VerdictModal) and Add to dataset (AddToDatasetModal), which is disabled until there is a verdict. Both modals live in components/decisions, beside the chat's VerdictBar.

"Why did it do this?" opens it from four places:

WhereShown when
A skill run's pagethe run has an invocation_id
A review card (Governance → Rules → Reviews)the flag has an invocation_id; opening it is a logged reviewer read
A Governance → Rules → Activity card ("Why?")the turn is an answer or a skill run, and it is the viewer's own (useCurrentUserId); an editor sees members' turns there, which open to them only through a flag

The same change fixed the quality check badge on agent answers. It reads meta.eval_outcome, but the stream's response frame did not carry it and the chat's history loader dropped it, so no agent answer, live or reloaded, had ever shown one.