Repository navigation
Decision extraction drops restated reasons, matches spans whitespace aside and skips captioned images - #176
Merged
Merged
Conversation
zlareb1
force-pushed
the
feat/decisions-extract-quality
branch
from
November 2, 2026 10:37
2854388 to
c8bc450
Compare
…kips captioned images A candidate whose reasoning has no content word its outcome lacks is dropped: it is the decision in the document's words, not its reason. Spans match the chunk with whitespace runs read as one space, and the chunk's own span is what gets recorded; retire reads the live text the same way. A body holding an image and at most a caption's worth of text is image-only. The prompt asks for the reason behind each choice and skips recap sections and superseded behaviour. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…tement check A long section's last chunk holding an image and a short tail of text is sent again: only the chunks of image-only sections are skipped, the sections the image-only line reports. The restatement check drops a final "e" and undoubles a final consonant after cutting an ending, so stored meets store and running meets run. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Reconcile compares the stored reasoning with whitespace runs collapsed, so a confirmed row or one with a recorded outcome is not tagged source-changed when the document only re-wrapped a line, and an unconfirmed row keeps its stored span, which retire still finds. The retire step's map of held decisions keys on the collapsed reasoning on both sides, so a re-wrapped reasoning under a reworded key still replaces the old row. Rejected options' reasons are stored collapsed already. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
The 12-character floor is measured with whitespace runs collapsed, as the span is matched and stored, so padding a short span with spaces no longer lifts it over the floor. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…pace aside A section whose own text is a picture and its caption is reported and not sent, whether or not it has subsections; a heading alone over its subsections is still not one. A link such as [image tiles](tiles.md) is no image placeholder. Two candidates whose reasoning differs only in whitespace are one decision. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…s image-only [image1], [image_1], [images] and [pictures] are placeholders again; link text and words such as [imagine ...] are not. The text above the first heading, or a document with no heading, is image-only when it holds a picture and at most a caption: it is not sent and is reported as (untitled). Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Every form of a filler word is skipped by the restatement check (deciding, choosing, were), since words are compared as stems against the fillers' own stems. Spans are read stripped like the other fields: the verbatim check matches whitespace aside, so stripping cannot make a span match. 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 links as text A chunk stored with an empty section path is skipped only when its own text is image-only too, so a document chunked without headings is not dropped whole because its preamble is a picture. [image][1] and [image]: x.png are links, not placeholders. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
![diagram][fig1] is an image, and a linked image such as a build badge is matched whole with its link, so its target is not counted as caption text. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
A caption's length is counted after images, HTML tags, link targets, reference labels and bare URLs are removed, so a badge wrapped in an HTML or Markdown link adds no text, whatever form it takes. The help of loom decisions extract says the reasoning must say more than the outcome and that a captioned image is skipped. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…without its reason A caption drops a lower-case tag on one line, so comparisons such as x < 10k and y > 80% and generics such as Option<A> stay text, and a decision beside a diagram is no longer read as a caption. The prompt asks for the outcome without the reason, since an outcome that carries its reason leaves the reasoning nothing to add. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
[the diagram][image] is a link: a placeholder never follows a closing bracket. A heading-less document of one captioned picture is reported as (untitled) and not sent. 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]>
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]>
… a re-wrapped quote's section The restatement check compares Snowball stems, the stemmer search already uses, in place of a hand-rolled one. A caption no longer counts the empty brackets a link around an image leaves. A dropped candidate whose quote is re-wrapped in the document names the quote's section. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
… as an image "Because we spill into sorted runs." restates its outcome. ![spill flow] is an image, so a caption under it is image-only. 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]>
vec![0; n] or ![a, b] in a code span or a fenced block is code, so a short section holding a decision is no longer skipped as image-only; the code still counts as text beside a real image. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
zlareb1
force-pushed
the
feat/decisions-extract-quality
branch
from
November 2, 2026 11:31
3d18314 to
790b975
Compare
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Image markup inside a code span or fence no longer makes a preamble or a parent heading image-only in the report. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
![spill flow] is no longer an image: in prose it is indistinguishable from a macro such as vec![0; n], and telling them apart would need the document's link definitions. image_only and image_only_sections share has_image, which looks outside code. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
[image tiles] and [images and charts are in the appendix] are text: a placeholder is the word alone, with a number, or with a colon and its caption. 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]>
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]>
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
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 extractdrops a candidate whose reasoning only restates its outcome, accepts a span whose whitespace runs differ from the document's (and records the document's own text), and treats a section holding an image and a caption as image-only. The prompt now asks for the reason behind each choice and skips recap sections and superseded behaviour.Why
The verbatim check accepts any span of the document, so a
reasoningthat is the decision in the document's own words ("We spill into sorted runs.") passes, and an agent reads "Decided X because X". Such rows are the main source of weak extracted decisions. The same check dropped good candidates whose span differed from the chunk only in line breaks or doubled spaces, which models drop when they copy. A recap section, or one that describes an old default as history, produced rows stated as current. And a diagram with a one-line caption had words, so it was sent to the model, which then built a rationale out of the caption.Scope and risk
The rules live in
server/memory/domain/decision_extract.py.server/memory/app/decision_extract.pychanges in seven places: the section skip before the model call, the retire step's held key, the duplicate-pair key,_same_decision, the retire step'sfind_span, thedocument_spans/restates_outcomecall in the candidate loop, andquote_sectionreading the document's span of the quote, so a dropped line names the right section:restates_outcome): a candidate is dropped when every content word of its reasoning is a word of its outcome. Words are compared lower case, without punctuation, as Snowball stems (server/memory/domain/lemmatize.py, the stemmer search already uses;storedmeetsstore,runningmeetsrun), and a short list of filler words (we,the,will,decide,chose,use,instead,because,since,picked,opted,decision, ...) is skipped in any form, compared as stems. The prompt asks for the outcome without its reason: an outcome that carries the reason leaves the reasoning nothing to add, and such a candidate is dropped (a test pins this). The dropped line saysreasoning only restates the outcome: it has no word the outcome lacks. I chose a subset test over containment or a similarity score: it explains itself in one line, needs no threshold, and errs towards keeping. A reasoning with even one word the outcome lacks stays. It runs after the verbatim check, on the document's spans.find_span): each span is matched with every whitespace run read as one space, through a regex built from the span's words joined by\s+. A candidate that passes is rewritten with the chunk's own spans (document_spans), so whatdecision.recordstores is the document's text, line breaks included, and the quote's section is looked up from that text. The retire step uses the samefind_spanagainst the live text, so a re-wrapped line does not retire a row. Reconcile compares the stored reasoning with whitespace collapsed (collapse_ws), so a whitespace-only change is no change for every row: a confirmed row or one with a recorded outcome is not taggedsource-changed, and an unconfirmed row keeps its stored span rather than being re-recorded. The retire step's map of decisions this run holds keys on the collapsed reasoning on both sides, so a re-wrapped reasoning under a reworded key still replaces the old row. Rejected options' reasons need no change:decision.recordstores them collapsed already. Storing the document's span rather than the model's means the stored reasoning is still an exact substring for a build that tests within, so N-1 agrees with N on every row N writes during a rolling upgrade. A row N keeps unchanged after a whitespace-only change in the document is, to an N-1 run, which compares exactly, a changed decision: N-1 may re-record it, delete it (an unconfirmed row its model does not emit again), or tag itsource-changed(a confirmed row or one with a recorded outcome). N-1 already behaves this way on any whitespace change today. A later N run reads the row unchanged and clears that tag again. For an operator command this is harmless.image_onlynow also holds for a body with an image and at mostCAPTION_MAX_CHARS(80) characters of other text. The existing "no letters" rule is kept asno_words. Image markup inside a code span or a fenced block (or<img>in code) is text: its markup characters are blanked, so the code still counts as text beside a real image. An image is also a reference-style Markdown image (![diagram][fig1]). A shortcut reference (![spill flow]) is not read, since it looks like a macro such asvec![0; n]in prose. The caption's characters are counted after images, HTML tags (a lower-case tag name on one line, sox < 10kandOption<A>stay text), link targets, reference labels, the empty brackets a link around an image leaves, and bare URLs are removed, so a badge wrapped in an HTML or Markdown link adds no text whatever form it takes; whether the body has an image at all is tested on the image forms alone. The image placeholder now matches[image],[Image 3],[image: ...],[image1],[image_1],[images]and[pictures], and no longer matches link text such as[image tiles](tiles.md), a reference link[image][1]or definition[image]: x.png, or a word such as[imagine ...]. Loom's own parsers emit no placeholder; these come from exported documents. The rule is judged on each section's own text (image_only_sections): a leaf, or a parent whose own text is a picture and its caption, while a heading alone over its subsections is not one. The text above the first heading, or a document with no heading, counts when it holds a picture and at most a caption; it is reported as(untitled). A chunk stored with an empty section path is skipped only when its own text is image-only too, so a document chunked without headings is not dropped whole. The chunks of those sections are the ones not sent, and the same list gives the report line, so a captioned diagram is reported with theimage-only, rationale not extractedline rather than skipped silently, and a long section's last chunk holding an image and a short tail of text is still sent. A chunk with no words is not sent, as before. Text of that length with no image is still sent.server/llm/fake.py: the fake model's answer to the extraction prompt used the first sentence as both outcome and reasoning, which the new check drops. It now takes the first sentence as the outcome, the second as the reasoning, and the span through both as the quote, and emits nothing for a section with one sentence.server/cli/decisions.py: the help says the reasoning must say more than the outcome and that a heading over only an image and its caption is skipped; the CLI snapshots anddocs/reference/cli.mdare refreshed (help text only).Left alone: reconcile, retire ownership, races and exit codes. Rows written before this change whose reasoning restates their outcome are not retired: retire still deletes only rows whose reasoning left the document or which this run recorded under another key. A re-run drops the restating candidate and leaves the old row as it is.
Compatibility, rollout and rollback
Tests
tests/unit/test_decision_extract.py, fake model and stubbed planes: the restatement rule over pairs (restated, restated with inflection and filler, filler words in other forms such aswere chosenandare choosing,store/stored,run/running,process/processes, a reason); a restating candidate dropped with its line and nothing recorded; a span with other whitespace passing, withfind_spanreturning the document's text and rejecting a missing space; a candidate recorded with the chunk's line break in its reasoning; a row whose stored reasoning was re-wrapped not retired; a re-wrapped reasoning under a reworded key replacing the old row; a pinned row whose document only re-wrapped left untagged; a rejected reason the document re-wrapped read as no change; the prompt's new rules;image_onlyon a captioned image, a placeholder and caption, an image with real text, and short text with no image; a captioned diagram neither sent nor missed from the image-only list; a long section's last chunk with an image and a short tail still sent; the fake model resting its decision on the second sentence (replacing the earlier fake-model test,test_the_fake_model_returns_candidates_that_pass_the_check, which it covers). Two existing tests change where the new rules intend it:test_a_blank_reason_drops_the_alternative_and_a_reason_is_read_as_writtenis nowtest_a_blank_reason_drops_the_alternative_and_a_reason_is_read_strippedand expects the reason"costs random reads"where it expected" costs random reads"(spans are read stripped, since the verbatim check matches whitespace aside); andtest_a_span_too_short_to_rest_a_decision_on_is_droppedgains three cases, a quote, a reasoning and a rejected reason of 12 or more characters as the model wrote them but under 12 once whitespace runs are collapsed, each dropped. Every other existing test passes unchanged.--apply, re-run. A section with a reason was recorded and thenunchanged; a section whose second sentence restated the first was dropped with the restatement line; a section with an image and a caption got theimage-onlyline.make format lint typecheck,test_doc_links,test_public_copy,test_llm_stage_registry,test_package_contractsand the fake model's tests 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 new rule with unit tests and an end-to-end run on the fake model.
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; the full unit suite runs 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