Skip to content

Decisions are extracted from the whole document as claims cited by quotes and checked against them - #277

Merged
zlareb1 merged 16 commits into
mainfrom
feat/decision-extract-whole-document
Nov 5, 2026
Merged

zlareb1 merged 16 commits into
mainfrom
feat/decision-extract-whole-document

Conversation

@zlareb1

@zlareb1 zlareb1 commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Improvement

Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):

loom decisions extract and the document-source sync read a design document whole and write each decision as a maintainer would, its outcome, reasons and rejected options in plain words, each claim cited by quotes of the document and checked against them before it is recorded.

Why

The extractor read a document in 6,000-character windows and kept a decision only when its reasoning and each rejected option's reason were one verbatim span of one chunk, a reasoning that said more than the outcome. A design document rarely writes a decision that way: the reason sits in another section than the choice (a problem slide, a list of missing cases, a measurement), the former approach a new design replaces is described rather than rejected in so many words, and some decisions are stated with no reason at all. On the design-rationale bench those decisions were never proposed, dropped by the span check, or kept with a fragment of the text as their "reason"; re-runs on a revised document also kept the old outcome, because the prompt showed it for reuse.

Design

  • Read: the whole document in one call when it fits memory_decision_extract_window_chars (new, LIVE, 24,000 characters), one window whatever its sections, otherwise windows of whole sections, as before. For each decision the model writes the outcome, the reasons the document gives and the options it rejects, in its own concise words; each claim cites one to three quotes. A decision with no reason is written with none. The known-decision list in the prompt shows category and scenario only (the key), never the old outcome.
  • Grounding (deterministic): each quote must be in the text, matched by find_span (whitespace, letter case and label lines aside); a reason or rejected option with no found quote is left out, a decision with no found outcome quote is dropped, and an outcome quote in a recap, summary or background section locates nothing.
  • Support check (one more call per window, decision_support output cap 8000): every kept claim is read with its quotes and kept only when the quotes state or directly imply it; adding a reason, cause, number, name or rejected option fails. It does not judge the stage. The same call reads the extractor's stored rows on the document: still stated, and which candidate restates it. This keeps the invariant that no reason reaches an agent that the document does not give, without the single-span rule.
  • Reconcile and retire on the verdict: a stored row is stated when any window's check states it; no longer stated only when every window says so in the first check and again in a second check without candidates; a split between the two checks, and anything else (a lost check, a reply that leaves it out, a row past the known-decision cap) is no verdict. A stated row is unchanged (recorded again in its stored words only for its files, source or tags); one no longer stated is revised, or flagged when pinned, attested or acted on, and deleted when the run did not emit it again; a restatement of a row not found gone is not written, under a new key or under the key of a stored row not found stated (not rewritten as a copy: a gone one is retired, one with no verdict keeps its stored words). A row with no verdict is never flagged, un-flagged or deleted (a revise of one keeps its source-changed tag); an unfrozen one is revised as the read words it only when the read gives its key in other words, and in its stored words and stage when only its files, source or tags changed. A restatement is named by a window that states the stored row when one does. A document with no window read (only image-only sections) judges nothing. The check reads a stored decision as its scenario, outcome, reasons and rejected options, without the stage verb or a realized outcome, and ignores a verdict on a key it was not asked about. A still-stated duplicate is never deleted. Another writer's row under a key is left alone, neither revised nor tagged: the check reads only the extractor's rows (before, such a row was tagged source-changed when its text differed).
  • Limit: in a document read in several windows (past 24,000 characters), each window's check reads only its text; a row counts as stated when any window states it, so a decision whose statement spans two windows can read as gone in each. A decision still stated keeps its stored words when a revision adds a reason or a rejected option to it: the check asks whether the text still says what the row says, not whether it says more.
  • Removed with the old contract: the single-span verbatim check, the restated-reasoning and reasonless-ban rules, inverted-alternative detection, the joined-reason re-read and the reasoning-prefix matching of the reconcile step.

Alternatives measured first, offline, with the same model: relaxing the span check with more text rules (tried before; unsafe for ordinary prose), and a union of several windowed reads (raises recall but keeps the fragment reasons). A whole-document read with cited claims raised recall the most without raising the invented-reason rate.

Scope and risk

  • server/memory/app/decision_extract.py, server/memory/domain/decision_extract.py, the fake model's answers to both prompts, the CLI help, the decision_support LLM stage beside decision_extract (server/observability/genai.py), the bench harness's extraction estimate, docs.
  • Builds on A search excerpt serves a decision or constraint row as stored #276 (decision rows served whole in search excerpts), now merged: the measurements below ran with it.
  • Window size: the read writes about as many output tokens as the window holds on a dense design document (0.8-1.1 times its input tokens over the measured reads), so the 24,000-character default keeps the reply inside the 12,000-token decision_extract cap. A reply cut at the cap loses its window, and the dropped line names the cap, --window-chars and the setting the sync reads. Every measured document is under 14,000 characters, so the measurements read each one whole, as the default does.
  • Cost per document: one read and one support check per window (one window for most documents), plus one more check per window when a stored row looks gone. Measured with the default model on the development set's first versions: about $0.002 per document read and checked (the token counts of the read and support calls over five documents, at the model's list price).
  • Time: a 13,700-character document runs end to end in about 23 s (CLI dry run: one read, one check, reconcile); a 24,000-character one about twice that. The sync reads a document until 30 s before the pass's deadline; one that runs out after starting with at least 0.75 × (pass − 30 s) of read time (427 s at the default knowledge_source_sync_max_pass_seconds of 600, 112 s at the 180 s floor) is given up as too_large_for_pass, and one started later in a pass waits for the next pass. A 24,000-character document fits well inside either.
  • A re-run's verdicts come from a model, so a flake can revise a row's wording; deletion needs two agreeing checks, and a lost check deletes nothing.
  • No schema, auth or tenant change; rows are written through decision.record as before.

Compatibility, rollout and rollback

  • Wire: no op or field changes. loom decisions extract --window-chars defaults to the new setting instead of 6000.
  • Operator steps: none. New LIVE setting memory_decision_extract_window_chars (24,000); decision_extract output cap 4000 → 12000 and a new decision_support cap (8000), both overridable through LOOM_LLM_MAX_TOKENS_OVERRIDES.
  • Mixed versions: rows written by either build are ordinary decision rows; a run of N reads rows N-1 wrote as stored decisions and judges them like its own. A run of N-1 on a document N mined retires the rows whose reasoning is not a span of the text, which is most rows N wrote (their reasons are in the model's words): it deletes the unpinned ones and tags the pinned, attested or acted-on ones source-changed, then writes its own. The rows are the extractor's own and the next run by N writes them again; written down as rule 30 of docs/architecture/rolling-upgrades.md. No gate holds the rollout.
  • Rollback: revert; rows written stay valid decision rows, and the first N-1 run on each changed document replaces them as above.

Tests

  • tests/unit/test_decision_extract.py rewritten for the contract: grounding (found, left out, stored as the document's words, across labels and case), the support check (unsupported outcome and claims, a lost, unreadable or cut check and the cap it names, reply parsing), the confirmation read before a retire and a second check that overturns the first, verdicts over two windows (one window stating, one leaving the row out, a second check leaving it out), a verdict that is not true or false read as none, a restatement naming a dropped duplicate, a pinned row with no verdict gaining the repository tag, an unjudged row recorded again in its stored words and stage, a long rejected option read as the same words once cut, a window without a row's text naming no heir for it, a lost second check on a flagged pinned row, a missing verdict on a frozen or acted-on row, a document under the window read as one window across its sections, a still-stated row keeping its words when a revision adds a reason, a restatement under a gone or unjudged row's key, restatements and duplicates, another writer's pinned row, the stage note, and every reconcile, retire, repository, refusal and race path the old suite covered. The fake support check in the test world judges a stored row stated when its reasoning is in the text or restated by a candidate.

  • tests/unit/test_bench_design_rationale.py: the extraction estimate counts the support check and the second check (an estimate, not a bound: the extraction leg can spend past --max-usd); the stored-statement bound reads decision.record's field limits. make format lint typecheck pass. Full unit suite on the merge head: everything passes except four cases of test_the_delimiter_is_sniffed_in_bounded_time, a timing test that fails the same way on main on the machine that ran it.

  • Measured on the design-rationale bench (bench/design_rationale/), K = 3, one judge, the default model for extraction, answers and judging; arm 3 is hand-written gold rows, arm 4 the extracted rows, both served through the pre-edit block and loom_search. Two task sets: a private development set (five design documents, 10 why-questions, 15 change tasks, 10 supersession and abstention tasks), and a held-out set of five public design proposals of a public repository (10 why-questions, 12 change tasks, 6 supersession and abstention tasks, three revised documents), with gold rows written once from each text before this change was tuned. Both runs serve decision rows whole in search excerpts (the change in A search excerpt serves a decision or constraint row as stored #276), so the delta here is the extractor's.

    Held-out, arm 4 minus arm 3:

    A precision A recall A misleading (arm 4 / arm 3) B avoids C states current (arm 4 / arm 3)
    main's extractor -22.4 -53.8 24.2 / 15.0 -16.0 33.3 / 100
    this change +0.6 -11.5 10.0 / 11.7 -6.2 100 / 100

    Development set, arm 4 minus arm 3: main's extractor A precision -18.3, A recall -45.6, B avoids -13.0, C states current 50 / 100; this change -17.5, -30.9, -30.9, 63.3 / 100 (A recall and B avoids both measure -30.9; B is worse than main's). The development set's change tasks depend on the pre-edit block (arm 3 is served it on 27 of the 30 tasks with gold rows, both arm 4 builds on 1-5): its gold rows name files of features not yet on the indexed branch, which no extractor can link, and the B difference is inside its interval (MDE about 30 points at this size). Extraction-only scores against the gold rows (a stronger model judging each gold decision found, and each extracted row correct), development set: main's rows cover 20% of gold decisions in full and 40% of their reasons, this change 57% and 75%, invented reasons 0-6% of rows in both.
    The change itself, arm 4 on this branch minus arm 4 on main with A search excerpt serves a decision or constraint row as stored #276, per task, bootstrapped over documents (95% interval; the harness's paired bootstrap):

    A precision A recall A misleading B avoids C passed
    held-out +23.3 [-1.2, +51.4] +42.3 [+20.3, +72.0] -14.2 [-31.7, +3.3] +9.7 [+0.0, +30.0] +4.2 [-10.0, +15.6]
    development -0.1 [-10.0, +12.7] +14.2 [-11.4, +43.4] +6.7 [+0.0, +12.1] -11.9 [-30.0, +6.4] +12.5 [+0.0, +42.9]

    Held-out A recall is the one delta whose lower bound clears zero. On the development set A misleading rises (its lower bound is zero) and B avoids falls with an interval that spans zero: five documents and the 14 change tasks scored in both runs cannot decide B.

  • Reproduce: python -m bench.design_rationale run <taskset> --arms 3,4 --k 3 --code-index <url> --code-index-org <org> --code-index-namespace <ns> ..., then score.

AI assistance in the code (leave one; writing this description with AI is fine):

  • AI-generated (an agent wrote most of the diff): Claude Code; I checked the grounding and verdict paths against the reconcile and retire rules, ran the tests, and measured on both task sets.

  • I can explain every line of this diff and how it interacts with the rest of Loom.

Checklist

  • make format-check, make lint, make typecheck and make test-unit pass; the integration suite passes if server behaviour changed. (format, lint, typecheck and the touched unit tests pass; the full unit suite runs before merge; tests/integration/test_decision_extract_repo.py passes (2) against a private ClickHouse with the fake model.)
  • Generated files are regenerated in this PR, not by hand: the SDK op tables, docs/reference/configuration.md and the docs/reference/ tables (python scripts/codegen/docs_reference.py), the reach manifest, schemas/schema.sql (make schema-dump) and the Codex plugin copies (python3 scripts/codegen/agent_plugin_sync.py).
  • A new migration is additive and numbered after the latest on main; no merged migration is edited.
  • A behaviour change to any file a plugin ships (hooks/, lib/, bin/, skills/, .mcp.json, the Codex plugin-defaults.json) bumps both plugin manifests' version, and no other open PR uses that version.
  • The frontend builds (npm --prefix frontend run build) and its tests pass, if frontend/ changed.
  • Docs under docs/ describe the system as it now is, and this description names any operator steps and wire changes.
  • Repository text has no dates, people, host names, internal namespaces, ticket or decision numbers; the history goes in this description (tests/unit/test_public_copy.py).
  • Commits are signed off (git commit -s), as CONTRIBUTING.md asks.

🤖 Generated with Claude Code

@zlareb1
zlareb1 force-pushed the feat/decision-extract-whole-document branch 2 times, most recently from 5f11f84 to d808f42 Compare November 5, 2026 15:05
zlareb1 and others added 15 commits November 5, 2026 16:44
…otes and checked against them

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…cal extraction output fits a whole read

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…environment variable

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…; the docstring limits the stored-words re-record to unfrozen rows

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…) cannot read names nothing

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…the reconcile read

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…e source-changed clearing

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…nd counts

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…t reads as one phrase

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…tractor and harness

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
@zlareb1
zlareb1 force-pushed the feat/decision-extract-whole-document branch from 15e849c to 85356f3 Compare November 5, 2026 16:46
@zlareb1
zlareb1 merged commit 1fc1d63 into main Nov 5, 2026
22 of 24 checks passed
@zlareb1
zlareb1 deleted the feat/decision-extract-whole-document branch November 5, 2026 17:23
@zlareb1 zlareb1 mentioned this pull request Nov 12, 2026
3 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant