Repository navigation
The verbatim check reads a span across interleaved label lines and letter case, and stores the document's words without the labels - #182
Merged
Conversation
…tter case find_span now matches a span with letter case ignored and with up to three short label lines (one to three words, each on a line of its own) between two of its words, as slides and diagrams converted to text put box labels between a sentence's two halves. The returned span is still the chunk's own text, labels included, so it stays a substring of the live document. Each gap is an atomic group, so a failed match costs linear time. The restatement check reads the model's spans, so label words in the document's span add no reason, and the second read's repeat check compares the document's span of a reasoning. A short section (at most a caption of text, no subsections) whose heading names a recap, summary or background now opens a recap span over the sections after it, until the next short section or a heading above its level. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…where the text's does find_span reads a line across only when it is a label: not a list item, fence, table row, heading, quote or definition, and holding no ban, contrast or n't word, checked on the match's groups. Each word but the last must end where a document word ends, so a short word never takes the start of a label. The retire step's reasoning key and the reason-less ban's whole-quote check ignore case as find_span does, the inverted-option check finds its reason in any case, and a breadcrumb that also names a section outside a recap span is not covered. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…bel, and the fewest labels are read The last line of a wrapped paragraph ends in sentence punctuation, so a span no longer reads across a paragraph break. Setext underlines and HTML tag lines, which the retire step meets in the whole document text, are no labels either. A gap reads the fewest label lines that reach the next word, so a later line reading as that word is not swallowed as a label. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
… no sentence A kept candidate's quote, reasoning, rejected reasons and a reason-less ban's outcome are stored as the document's words and case on one line, the label lines the match read across left out (stored_span). The retire step reads the stored span across the same labels again. The ban checks run on the model's spans before the document's replace them, and the retire step's held key ignores case in the outcome too. A recap divider's body only titles what follows: image-only, or a short line with no sentence punctuation and no link, so a one-line summary section no longer drops the sections after it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…sections A line starting lower case continues a narrow-wrapped sentence and is no label. A recap divider's span ends at the first section longer than a slide (600 characters), so a design document's lone diagram or empty Background heading covers nothing. Candidates differing only in the case of their outcome across windows are one decision. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…e document's lines The recap divider span is removed: a rule that can drop a design document's decisions must fail toward keeping them, and the heading-named recap rule stays as it was. The inverted-option check reads the document's raw match of the quote and its reasons, so a list item or a blank line still ends a sentence although the stored quote is on one line. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
… sentence end The inverted-option check reads the document's match with its label lines left out and its other line breaks kept (unlabelled_span), so a label naming a rejected option no longer reads as the quote choosing it. A label gap is refused after a word ending in sentence punctuation: a label sits inside a sentence, and a heading between two paragraphs is no label. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…e is told apart The restatement and reason-less ban checks run after document_spans, as on main: the stored span is the model's words up to case. A label gap is refused after a sentence mark followed by closing brackets, quotes or emphasis; a `___` rule is no label, and a number such as 2.5 GB is no list marker. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…tested by span length A line starting `-`, `*` or `+` is a list item only with a space after the marker, and `---`, `***` and `___` are rules, so emphasised box titles and signed numbers are labels. The structure cases use lines of at most three tokens, so each fails without its prefix rule, and a test doubles the span's words against one text, which an exponential matcher fails. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
The chunker reads any run of `-` under a line as a Setext underline, so a one- or two-dash line is structure too, and a numbered marker alone (`3)`) stays one. The text-length timing test's comment says what it pins. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…tence end is no label A label line's first letter or digit, after any markup, must be upper case or a digit, so a line of a script without case is never read across. A line ending in a sentence mark followed by closing brackets, quotes or emphasis is no label. Tests pin each word list, the blank lines removed around a label in the inverted check, and the partial last-word limit is documented. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
The no-label fixtures pass the title-like check, so each fails with only its own rule removed. The underline and rule branches are dropped: a line with no letter or digit is never a label. The partial last-word limit is documented and pinned. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
… is stated A line holding rarely, unless, but, however and similar hedges is no label, nor is a line starting with a Unicode bullet. The docs and the find_span docstring state the trade-off: a label is recognised by its shape and word lists, and the stored span is the document's words, checkable against it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
_same_decision and _same_reasons compare the reasoning and the rejected reasons with letter case aside, as the verbatim check, the retire step and the held keys already do, so a pinned row is not tagged source-changed for a capitalised word. The wrapped-paragraph test now pins the sentence-end rule. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
_repairs compares the failed outcomes with case aside, as the held keys and pairs do. _drop_inverted remaps only the quote through unlabelled_span: the stored reasons have the same words. The docs drop a stray sentence and say duplicate candidates are compared with whitespace and case aside. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
zlareb1
force-pushed
the
feat/decision-extract-span-labels
branch
from
November 3, 2026 03:52
3ba9176 to
6915d23
Compare
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.
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 extractnow accepts a quoted span whose letter case differs from the document or that skips up to three short label lines a converted slide or diagram puts inside a sentence, and records the document's own words and case on one line, without the labels.Why
Slides and diagrams converted to Markdown put short label lines (box titles, arrow labels) on lines of their own between a sentence's two halves, and a model copying a span skips them and often capitalises a sentence's first word. The verbatim check read both as "not in the document text" and dropped decisions the document states.
Scope and risk
server/memory/domain/decision_extract.py:find_spanmatches withre.IGNORECASEand, between two words, either a whitespace run or a line break, one to three label lines and the next word on its own line. A label line is one to three words on a line of their own (blank lines around it allowed) that is title-like (its first letter or digit, after any markup, is an upper-case letter or a digit: a lower-case line of narrow-wrapped prose, "We keep the / old / index", continues its sentence, and a line of a script without case is never read across), does not start as a list item (-,*,+,1.or1)followed by a space, so**Proxy**and+3 nodesare labels), a fence or code, a rule (---,***,___), a table row, a heading or a heading's underline (===,---), an HTML tag, a quote or a definition; does not end in.,!,?or;(or their full-width forms, closing brackets, quotes and emphasis after the mark aside), as the last line of a wrapped paragraph does; and holds no ban word (states_a_ban's list), no contrast word (inverted_options' list), no hedge (rarely,unless,but,howeverand the like, a list used only here) and no word ending inn't. A bullet (•,◦,▪,‣,·,‧) and a line starting with=(an AsciiDoc heading) are structure too. The trade-off, stated once in the docs and the docstring: a label is recognised by its shape and these word lists, so a short line of another kind that the sentence needs can still be read across; the stored span is the document's words, so a reader can check it against the source. So "Retries are / not / safe" never reads as "Retries are safe", and a paragraph break never reads as a label. A fourth label line, a four-word line, a line that is no label, or a label inside a line ends the match, and no label is read after a word ending in sentence punctuation (closing brackets, quotes and emphasis after the mark aside): a label sits inside a sentence, and a join across a sentence end (a heading between two paragraphs) is the stitched quote the check refuses. Between two words the fewest label lines that reach the next word are read, so a later line reading as that word is not swallowed as a label. One chunk only, the first chunk wins, as before.(?>...), Python 3.11+), so once the next word is found the gap is not re-read another way: a failed match costs time linear in the span's words at each start position. Each word but the last must end where a document word ends ((?=\s)), sosonever takes the start of a labelSomethingand then fails. The plain whitespace reading is tried before labels, and labels are as few as reach the next word. A stored span is label-free (seedocument_spansbelow), andfind_spanre-finds its document text across the same labels, so the retire step keeps a row on an unchanged document. A second limit, stated in the docstring and the docs and pinned by a test: a last word that would end inside a document word is tried after the label reading of its gap, so a rejected label reading there leaves that start unmatched ("cache plan" over "cache / plans / not / plan"); a retry at the same start without the label alternative was not added, as it would need a second pattern per span for a shape this rare. The main limit: a label line whose first word reads as the next word ("The proxy" over "the nearest replica") is taken as that word and the span is not found, which the docs and the docstring state and a test pins. The last word prefers a word end, then the label reading, then a partial end as before (a CJK span has no spaces to end at). Whether the lines read across are labels is checked on the match's groups, not inside the pattern, where the word lists would be tried at every character of every line read as a label; a rejected match retries from the next start.detect_sectionssplits on headings andchunk_documentwindows inside each body); a#line inside a chunk is a fenced or HTML block's text. The retire step also searches the whole document text, which holds heading lines: an ATX heading (#), a Setext underline (===,---) and an HTML tag line (<h2>…) are all lines that are no label, so a span never reads across a heading there either.MIN_SPAN_CHARSis still measured on the span as the model gave it (unchanged)._drop_invertedreads the inverted-option check onunlabelled_spanof the quote (the stored reasons already have the same words, which is all their match reads): the document's match with its label lines (and the blank lines around them) left out and its other line breaks kept. A list item or blank line still ends a sentence there, and a label naming a rejected option ("Shard by tenant" inside "We shard by time / so joins stay local") states nothing. Removing a label's blank lines with it is deliberate: a label sits inside one sentence, and a blank line left in its place would end that sentence. Chunk breadcrumbs aredetect_sectionspaths (chunk_documentsets each chunk'ssection_pathfrom the section it windows), soquote_sectionnames sections as the image-only filter does.Every
find_spancaller, checked against the wider match:verbatim_failure,unfound_reason: only ask whether a span is found; a case-differing or label-split span now passes, which is the change.document_spansnow storesstored_span: the document's own span with the label lines it read across left out and whitespace collapsed onto one line, its words and case. The same matchfind_spanmakes, with the label lines removed through the pattern's groups. Quote, reasoning, every rejected reason and a reason-less ban's outcome are stored this way, so the label lines the match read across are left out of the record and a re-run writes the same text. Rows written before this change kept line breaks;_same_decisioncompares with whitespace collapsed, so a re-run leaves them unchanged._check_window: unchanged order:document_spansfirst, thenreasonless_ban,restates_outcomeandwithout_reasonon the stored spans.stored_spangives the model's words up to case (a label the model copied stays in both, one it skipped leaves both), and these checks ignore case in their word comparisons, so they judge the same words the model gave; a reason-less ban's outcome is the stored reasoning on one line.quote_section(w, find_span(quote) or quote):find_spanreturns the raw text with labels, a substring of its chunk, soquote in c.textnames its section; a stored label-free quote is passed throughfind_spanfirst at both call sites._repairsalso compares the failed outcomes with letter case aside, as the held keys and pairs do, so a repair whose outcome differs in case is not dropped as a repeat (test added)._repairs: compared the model's raw reasoning, whitespace collapsed, with the kept candidates' document spans. A repeat copied in another case would have slipped past and been written under a reworded scenario and outcome; it now compares the stored span (stored_span) (test added, fails without the fix)._retire_one:find_span(stored reasoning, live_texts). The stored reasoning holds the document's words in order;find_spanreads across the same labels again, so an unchanged document keeps the row and a changed one retires it (tests for both). A document whose only change is letter case no longer retires the row. Theheldmap and the retire lookup key the outcome and the reasoning with whitespace and case aside (_held_key, a casefold;find_spanusesre.IGNORECASE, which differs only for one-to-many folds such as ß/ss), so a case-only change under a reworded scenario replaces the old row, for a reason-less ban too._same_decisionand_same_reasons(Reconcile) compare the stored reasoning and rejected reasons with letter case aside, as the verbatim check, the retire step and the held keys do, so a case-only change in the document leaves a pinned or attested row unchanged instead of tagging itsource-changeddepending on the model's reply (test added)._states_as_chosenbuilds its own pattern from a reason over the quote, bothunlabelled_span(_drop_inverted); it now ignores case too, so a reason the quote holds in another case is still the sentence that rejects it.memory_valuereads the stored parts, which leave out the label lines the match read across;states_reasoncompares the reasoning and outcome case-folded, and a reason-less ban's outcome is its stored reasoning, so it still reads as no stated reason.Left alone: the cross-chunk rule (no joins across chunks), the window and prompt, and the recap rule (a heading that names a recap, summary or background).
Compatibility, rollout and rollback
loom decisions extractover a converted deck may now record decisions it dropped before.decision.recordwrites.Tests
tests/unit/test_decision_extract.py(fake LLM): a span split by 1, 2 and 3 label lines is found and returned as the text's own; 4 label lines, a 4-word label line, and labels inside a line are not found; a case-differing span is found as written; a span across two chunks is not found; 200,000 lines that all read as span words or labels, and 200,000 where every match is rejected, each cost under 60x the time of a tenth of the input, both the best of three runs (quadratic time would be about 100x); twice the span's words against one text costs under 20x (about 1.5x here; with the atomic groups removed, about 190x); labels starting like the next word (Something/so,API/a,Index/a) are read across;not,don't,never twice, a list item, a numbered item, a fence, a table row, a heading and a quote are not skipped; a label line whose first word reads as the next word is not found (pinned, two cases); the fewest label lines reaching the next word are read; a wrapped paragraph's last line is no label; every documented non-label prefix and sentence end is parametrized; a reasonless ban whose document span holds a label is stored without it, whole-quote and fragment cases; a lower-case line (wrapped prose,shard a) is no label; a case-only outcome difference across overlapping windows is one decision; a stored label-free span retires nothing on an unchanged document and retires on a changed one; a found span with labels finds itself; a case-only change under a reworded scenario replaces the old row; a ban copied in another case is still its whole quote; a reason in another case keeps its option rejected; a run stores a case-differing, label-split reasoning as the document's text and the retire step keeps that row while retiring one whose reasoning left; label words do not save a restating reasoning; a repeat copied in another case on the second read is dropped as a repeat; a run leaves out a rejected option that a list item of the quote states as chosen; a label naming a rejected option keeps it rejected; the blank lines around a label are dropped with it in the inverted check; a CJK line between two CJK halves is not read across;Only,Always,Instead,Rather,Rarely,Unless,• Shard A,Costs.)and**Done.**are no labels; each no-label fixture fails with only its own rule removed: the structure, sentence-end and word-list fixtures pass the title-like check, while***,___,---,-,--and代理pin the title-like rule itself (===is caught by both the title-like rule and the=prefix, andNotandNever twiceare in both word lists, so each of these fails only with both of its rules removed); a heading between two paragraphs is not read across, after.,.),."or.*; a___rule is no label and2.5 GB, a dotted version number and3 replicasare labels.test_a_span_differing_only_in_whitespace_is_the_documentsandtest_a_span_with_other_line_breaks_is_recorded_on_one_line(renamed) now expect the stored span on one line. The_Worldfixture gained acontentattribute so a test can set the document text the retire step reads.make format lint typecheck: pass.tests/unit/test_doc_links.py tests/unit/test_public_copy.py: pass.pytest tests/unit -q -p no:randomly) on the branch rebased onto main: 25281 passed, 20 skipped, 1 xfailed, and 1 failed,test_profile_redaction.py::test_a_retried_redact_scrubs_the_profile_rows_a_failed_one_left, which passes run alone (9 passed) and does not reach the extractor.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; every
find_spancaller listed above and the regex's backtracking bound were checked by reading the code and by the tests named above.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.main; no merged migration is edited (none).frontend/changed (not changed).docs/describe the system as it now is:docs/features/tasks-and-decisions.md, the verbatim check, reason-less bans and the retire step.git commit -s).🤖 Generated with Claude Code