Repository navigation
Decision extraction keeps stated bans, reads an empty or stitched reply again, and drops recaps and inverted alternatives - #177
Merged
Conversation
…ly again, and drops recaps and inverted alternatives - The prompt no longer tells the model to skip a heading, an image or a captioned image; the image-only filter alone decides that. - A window whose reply holds no decision, though its text is more than a caption, is read once more and the second reply is used. A window whose candidate has its quote in the text but a reasoning or rejected reason that is not is read once more with those spans named. A window gets at most one extra call; each is reported as "read again". - A restating candidate the model marks as a constraint, whose quote holds a ban word, is kept with its reasoning as its outcome. decision.record's statement and context.pack read a reasoning equal to the outcome as no stated reason: "Decided X." with no "because". - A candidate whose quote sits under a recap, recall, summary or background heading is dropped; the section stays in the window. - A rejected option whose words all sit in one sentence with no negation or contrast word, other than the sentence giving its rejection reason, is left out of the record and reported. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
The prompt said a decision whose text gives no reason is not emitted, which kept the model from offering the reason-less bans the restatement check now keeps. A ban or an invariant stated without a reason may now be emitted with is_constraint true and its own sentence as the reasoning; every other decision still needs a stated reason. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…lost, and reads wrapped sentences whole - A lost second read for a joined reason is a "read again" line, not a refused drop: the window was answered, its first reply's decisions are recorded and the exit code is unchanged. - Sentences for the inverted-option check end at . ! ? before whitespace, a blank line or a list item; a single line break joins, so a hard-wrapped negation stays with its sentence. - The joined-reason read fires only for a span not in the text, never when a span is under the 12-character floor. - A statement with no stated reason gives the outcome the reasoning's room too, so a long ban keeps its end. - Retries are their own Retried rows; the key check returns the key. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…no longer treats recall as a recap heading - states_a_ban tests the reasoning, the span that is stored, not the quote: a reasoning fragment without a ban word stays dropped. - recap, summary and background mark a recap section; recall is a normal heading word in a search system. - The CLI help names the image-only skip next to the window count and all three recap words; cli.md and the snapshots are regenerated. - A recap candidate with a missing reasoning is not read again (test). 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]>
…s a ban whose outcome is shorter than its sentence - A rejected option is left out only when the candidate's own quote states it as part of the choice; a document that names an option in one sentence and rejects it in the next keeps its alternative. - A ban whose reasoning is its whole quote is kept with no reason even when the model's outcome is shorter than the sentence. - The report test covers the "read again" lines; comments, the window loop's docstring and the CLI help string are tidied. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…es a repeated decision once - The inverted-option check treats over, against, versus, vs, unlike, replace*, favor/favour and dropped as contrast words, so "We chose X over Y" keeps Y as rejected. - Of a second read for a joined reason, only candidates that repair a failed decision are checked: a kept decision given again under a reworded scenario is dropped and reported. - A no-reason ban whose reasoning is over decision.record's outcome limit is judged as any other candidate. - _read_window takes answered_already explicitly; the docs say a window read again costs a second call. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
… error - The "no window was read" error also names a window that answered nothing and failed when read again. - The docs limit "loses its window only" to a window's first call or its second after an empty reply; a failed second read for a joined reason loses nothing. - Test: a stitched second read answered by the fallback fake model is a "read again" line, not a refused drop. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
- A second read's repeat of a kept decision is reported under the section its quote is in, not the window's first. - The statement docs and states_reason say a reasoning equal to the outcome is read case, whitespace and closing punctuation aside. - Tests: a repeat in the window's second section is named there; a repair with a reworded outcome and a new reasoning is recorded. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
- states_a_ban's docstring stops at the marker words; the keep rule is reasonless_ban's. - The restated-reasoning exception says a ban's reasoning must fit an outcome (1000 characters) to be kept with no reason. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
- A second read's candidate is a repair when its outcome matches a failed one with whitespace runs collapsed. - The window's first section is computed once and passed to each read. - Tests: a repair whose failed outcome had a line break is recorded; an empty window whose second read is unreadable or answered by the fallback fake is a refused drop, exit 2. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…punctuation aside - states_reason drops a closing ., !, ? or ellipsis on both sides, so "Never retry!" over "Never retry" reads "Decided Never retry." - The docs name the recap exception of the joined-reason second read and say a second reply's candidate is checked, not read. - Test: a reason-less ban reads unchanged on a re-run, emitted or not. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ban whole - The inverted-option check also treats favor*/favour*, prefer*, outperform*, beat(s) and compared as contrast words, so "We prefer X to Y" keeps Y as rejected; the docs state why the list leans wide. - A reason-less ban whose reasoning is a fragment of its outcome is stored as its quote when the quote holds a ban word too. - The second-read note says "An earlier reply gave these decisions...". - Test: a joined rejected-option reason is asked for again, named in the note, and recorded repaired. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ecision's section The read-again line for a joined reason, and its lost-read line, name the section of the first failed decision rather than the window's first section; the empty-reply line keeps the window's first section. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Retried's docstring and _read_window's `section` parameter (was `first`) say what they hold: the section a read, or its loss, is reported under. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ejection words
- A sentence of the inverted-option check does not end after "vs.",
"e.g." or "i.e.".
- fail, reject, avoid, compare and drop count in any form ("rejects",
"avoids", "comparison", "drops").
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
8 of 9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related: #174
Related: #176
Changelog category (leave one):
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 extractkeeps a ban the document states without a reason, reads a window again when its reply holds no decision or a reason joined from two places, drops decisions quoted from recap, summary or background sections, and leaves out a rejected option the document states as part of the choice. A decision whose reasoning is its outcome now readsDecided X.with no "because".Why
Six ways the extractor loses or misstates a document's decisions:
{"decisions": []}) loses the whole document.Scope and risk
The rules live in
server/memory/domain/decision_extract.py;server/memory/app/decision_extract.pyapplies them in the window loop, which is split into_candidates(the calls),_check_window(one reply's candidates),_duplicate_or_unfit(the existing key, pair, fit and per-section checks, unchanged) and_drop_inverted.is_constrainttrue and its own sentence as the reasoning; every other decision still needs a stated reason.more_than_a_caption, the same 80-character measureimage_onlyuses, now shared), the window is read once more with the same prompt and the second reply is the window's. An unreadable or failed first call is not retried: it is lost as before. The no-window-read and partial-read exit rules read the final outcome, so a second call that fails loses the window (exit 2, or exit 1 when no window was read).reasonless_ban) whenis_constraintis true, its reasoning, the span that is stored, holdsonly,no,never,must,not,always,at mostorat leastas a word (states_a_ban), and that reasoning restates its outcome or is its whole quote (an outcome shorter than the ban sentence would otherwise store "Decided because "), and that reasoning fits decision.record's 1000-character outcome limit; a longer one is judged as any other candidate. Its outcome is set to its reasoning, the document's span on one line (without_reason); a reasoning with fewer words than the outcome (a fragment such as "no server retry setting") gives way to the quote when the quote holds a ban word too, so the stored ban is whole. Representation:decision.recordrequires a non-emptyreasoning, and the retire step must find the reasoning in the document, so the reasoning stays the document's span. The marker is the record itself: a reasoning equal to the outcome, case, whitespace and closing punctuation aside, states no reason.memory_value(server/memory/domain/decision_statement.py,states_reason) then writesDecided <outcome>.without "because", the outcome clipped to the outcome and reasoning budgets together so a long ban keeps its end, andcontext.pack's decision line drops its(because …). I chose this over a tag because the statement is rebuilt from the record alone (bydecision.recordand again bydecision.outcome), so a tag on the row would not reach it without a schema or wire change, and becausedecision.precedentsandmemory.getshow the record as it is. This is also a change for any otherdecision.recordcaller whose reasoning equals its outcome: such a statement used to read "Decided X because X.", which said nothing more. Every other restating candidate is still dropped;is_constraintalone is not enough, since models mark plain descriptions as constraints.recap,summaryorbackgroundas a word at any level (case-insensitive; notrecall, a normal heading word in a search system) is dropped with the linethe quote is in a recap, summary or background section. The section stays in the window and the prompt, so its text can still give another decision's reason (a test covers this)..,!or?before whitespace, except aftervs.,e.g.ori.e., at a blank line or before a list item; a single line break joins, so a hard-wrapped negation stays with its sentence) and that sentence has none ofnot no never cannot can't instead rather without fail* reject* than avoid* slow, norover against versus vs unlike replace* favor*/favour* prefer* outperform* beat beats compar* drop*, so "We chose sorted runs over a plain set on disk." and "We prefer sorted runs to a plain set on disk." keep their alternative. The list leans wide on purpose: a missed contrast word drops a true alternative'sRejected:part, while an inverted option kept would mislead an agent about the chosen design. Deviation from the rule as first stated: the sentence that holds the option's own rejection reason is not read. Without that, the canonical case "A plain set on disk costs random reads." (option "a plain set on disk", reason "costs random reads") has no marker and would lose a correct alternative, which breaks existing behaviour and tests. The cost: if the model gives as an inverted option's reason a span of the very sentence that states it, the option is kept. Only the quote is read: a document often names an option in one sentence and rejects it in the next ("We looked at a plain set on disk. Each lookup costs a random read.", a list of options, "benchmarked … against …"), and reading the whole window dropped such correct alternatives. The dropped line saysthe quote states it as part of the choice.unfound_reason), the window is read once more with a note before the text naming each such decision's outcome and span and asking for those decisions again with one contiguous span, or none (stitched_note). The first reply's other candidates stand; the failed ones are reported as dropped as before. Of the second reply, only a candidate with a failed decision's outcome, or with a reasoning none of the window's kept decisions has, goes through the checks: a kept decision given again under a reworded scenario would otherwise be written twice, and is reported asthe second read repeats a decision the first reply gave. A candidate in a recap section does not trigger it. The window is answered already, so a second read that fails or comes back unreadable is aread againline, not a refused drop: the first reply's decisions are recorded and the exit code is unchanged.A window gets at most one extra call in total: a window already read again for an empty reply is not read a third time for a stitched reason. Each extra call is reported in a new
retriedlist, printed as- read again [<section>] <why>; it does not change the exit code.Left alone: reconcile, retire, ownership, races, the verbatim check itself, and the fake model.
Compatibility, rollout and rollback
decision.recordwrites for a record whose reasoning equals its outcome changes from "Decided X because X." to "Decided X.".loom decisions extract's help text and report gain the second-read lines.decision.outcomeon such a row rebuilds the statement with "because X", which an N write restores.Tests
tests/unit/test_decision_extract.py(fake model, stubbed planes; the test model can now serve a sequence of replies or raise): an empty reply read again and its second reply recorded; an empty reply over a caption of text not read again; a failed second read losing the window (exit 1); a stitched reasoning asked for again with the span named and the second reply recorded; at most one extra call per window; an unquoted failure not read again;states_a_banover bans, plain constraints,cannot/nothing, and a ban not flagged as a constraint; a reason-less ban recorded with reasoning equal to outcome, theconstrainttag and the statementDecided <ban>.; a restating candidate that is no ban still dropped;in_recapat each breadcrumb level,SUMMARY, andRecalling,Improving recall in hybrid searchandCurrent designnot matching; a recap candidate with a missing reasoning not read again; a ban word only in the quote, not the stored reasoning, still dropped; a recap quote dropped while the recap's text gives the next decision its reason;inverted_optionson the deferred-sharding, cannot-evict, rejection-sentence,thanand filler-only cases; an inverted alternative left out with the decision kept; a hard-wrapped negation on the next line keeping the alternative; a list item read as its own sentence; a short quote or reasoning not read again; a stitched re-read that raises or returns an unreadable reply keeping the first reply's decision, exit 0; a ban over 200 characters keeping its end in the statement.[]now expect the second, identical call;test_a_dropped_candidate_with_a_rewrapped_quote_names_the_quotes_sectionnow sees the window read again for its missing reasoning and the drop reported once per reply;test_the_prompt_asks_for_the_reason_and_skips_recaps_and_superseded_textasserts the prompt no longer mentions images or captions, and that it allows a reason-less ban as a constraint resting on its own sentence. Every other existing test passes unchanged.tests/unit/test_decision_statement.py: a reasoning equal to the outcome, case, whitespace and closing punctuation aside (other case, line breaks, a closing!), readsDecided X.; a reason-less ban readsunchangedon a re-run and neither reconcile nor retire touches it (test_decision_extract.py);tests/unit/test_context_pack_decisions.py: such a decision's line has no "because".Recapsection with the recap line, then readunchangedon a re-run; a one-sentence document was read again after the fake model's empty reply;decision.recordover HTTP with reasoning equal to outcome stored the value... Decided Client-side retries only; no server retry setting..tests/integration/test_decision_record_source.pyandtest_memory_for_file_decisions.pypass against that server.make format lint typecheck, the function-length gate,docs_reference.py(docs/reference/cli.mdand the hand-refreshed help intests/unit/snapshots/cli_tree.json), the CLI help snapshot,test_doc_links,test_public_copy,test_package_contracts,test_llm_stage_registry, and the unit files of the context-pack and decision modules pass.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. Checked: each rule with unit tests on the fake model and an end-to-end run on a private server.
I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist
make format-check,make lint,make typecheckandmake test-unitpass; the integration suite passes if server behaviour changed. (format, lint and typecheck pass locally, with the unit files of every touched module and the decision integration files; the full suites run in CI)docs/reference/configuration.mdand thedocs/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).main; no merged migration is edited.hooks/,lib/,bin/,skills/,.mcp.json, the Codexplugin-defaults.json) bumps both plugin manifests' version, and no other open PR uses that version.npm --prefix frontend run build) and its tests pass, iffrontend/changed.docs/describe the system as it now is, and this description names any operator steps and wire changes.tests/unit/test_public_copy.py).git commit -s), as CONTRIBUTING.md asks.🤖 Generated with Claude Code