Skip to content

fix(notes): find a one-word quote inside a word only from three letters - #666

Merged
Valtora merged 6 commits into
Valtora:mainfrom
thebeline:pr/notes-b3d-followups
Oct 23, 2026
Merged

Valtora merged 6 commits into
Valtora:mainfrom
thebeline:pr/notes-b3d-followups

Conversation

@thebeline

@thebeline thebeline commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Pull Request

Description

Addresses #488: the one-word follow-up from #659. The overlap-lane change is left out (see thread).

  • One-word quotes match inside a longer word only from three letters, so "a" never lands on "and"; a whole word still wins. On the calibration sets (2 s, 0.5), wrong marks fall from 124 to 119 of 7,500 selections and from 39 to 18 of 3,000 drags; 105 drags of one or two letters go unanchored. Most wrong marks left (92) are the same word said again nearby.
  • Test generator. The property tests' generator overflowed 53 bits and repeated after ~10,000 draws, a few dozen cases per test. It is now mulberry32; the identity property runs 1,000 cases to fit CI's time.

Type of change

  • Bug fix

Checks run

  • Frontend gates; file-size, docs and whitespace scripts.

Migration impact

  • No database migration.

Documentation impact

  • docs/ARCHITECTURE.md (highlight rule).

Security impact

  • No security-sensitive change.

Manual verification

Three new tests fail on main; all 6 mutants fail one. Resolver only; no browser pass.

… "and"

A drag from inside one speaker's line into an overlapping line of another
is quoted in time order (Valtora#616), so the second line's first words come
before the first line's last. No order of whole lines puts them next to
each other, so the resolver marked unchanged words as changed, on partly
wrong words. Where lines overlap in time and are drawn side by side, a
match may now move from one line to another as such a drag does: inside a
group of overlapping lines from any word to any word, and into the next
group from a line's last word to a line's first. A move is a tie-break,
like a part-word match, and each line's part may start or end inside a
word, as the quote's ends may. None of the 10,500 calibration selections
crosses lanes, and every one resolves as before.

A one-word quote matched inside any longer word, so "a" landed on "and" as
an exact match once the original "a" was gone. It now matches inside a
word only when it is three letters or more; a whole word still wins. On
the calibration sets (2 s, 0.5), wrong marks fall from 124 to 119 of the
7,500 selections and from 39 to 18 of the 3,000 drags, and 105 drags that
took one or two letters of a word are now unanchored. Two letters would
keep 46 of those and leave 10 more wrong marks; four would lose 30 more
right ones for 7 fewer wrong. Most of the wrong marks left (92 of 119) are
one-word quotes found whole on the same word said again within 2 s, which
no length rule reaches.

The property tests' seeded generator overflowed a double's 53 bits and
repeated after about 10,000 draws, a few dozen distinct cases per test.
It is now mulberry32. With it, the test that never marks words once the
quoted ones are gone fails on the old resolver ("a" inside another word).
The identity test now meets a selection that starts on the punctuation
after a word the same as the one picked, which a one-word quote can't tell
apart, and accepts either.

Addresses Valtora#488.
…e hold to let go

With distinct cases the identity property resolves a 2,000-character quote
in a third of them, and took 5.3 s on CI against its 5 s limit (about 2 s
here; the resolver's share is 1.6 s against 1.3 s before the line moves).
It now runs 1,000 cases with a 20 s limit, its floors scaled to match.

The editor releases the page in its unmount effect, which React may run
after the commit that removes the dialog, so the leave check after a save
could still see the hold. It now waits for the hold to go, as it waited for
the dialog; it failed 1 run in 20 under load before, none after.
@thebeline

Copy link
Copy Markdown
Contributor Author

Update on the two follow-ups: we're keeping the one-word rule and dropping the overlap-lane change from this PR.

Letting the match step between overlapping lines fixed your drag, but our review found it also turns a reworded single-line quote into an "exact" match by borrowing a word from the other speaker's line (about 40% of probe cases inside an overlap group, against under 2% before), and it is slow in crosstalk (4 s against 28 ms for a long quote with 20 overlapping speakers). Constraining it to drag-shaped matches works but needs a rework of the search for the speed. Overlapping lines are rare in finished transcripts (none in the 4,933 lines our calibration resolves against), so we'd rather leave the lane case unhandled until someone hits it than add that machinery now. The PR is the three-letter rule and the test generator fix.

— nullcat (Claudette)

The moves between lines drawn side by side found a drag across two
speakers' lines, but they also let a single-line quote with one word
changed borrow that word from an overlapping line and read as exact
(about 40% of probe cases inside an overlap group, against under 2%
before), and they were slow in crosstalk: 4 s against 28 ms for a
350-word quote with 20 speakers in one group. Holding them to drag-shaped
matches needs a rework of the search for the speed, and overlapping lines
are rare in finished transcripts (none of the 4,933 lines the calibration
resolves against), so the lane case is left until someone meets it.

The resolver is upstream's again, with the three-letter minimum for a
one-word quote; its calibration figures are unchanged (the moves never
fired there). `selectionRange.ts` is upstream's, and the lane tests and
the ARCHITECTURE sentence go. A new test keeps a one-line quote with a word
changed fuzzy on its own line while another speaker's line beside it says
that word; it passes on the old resolver and failed with the moves. The
identity property's exemption for a selection started on a twin word's
punctuation now requires that the selection took only that punctuation.
@thebeline thebeline changed the title fix(notes): find a drag across overlapping lines, and keep "a" out of "and" fix(notes): find a one-word quote inside a word only from three letters Oct 23, 2026
@thebeline
thebeline marked this pull request as ready for review October 23, 2026 19:42
@thebeline
thebeline requested a review from Valtora as a code owner October 23, 2026 19:42

@Valtora Valtora left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved. The three-letter floor only touches one-word part-word matches, a whole word still wins, and the mulberry32 generator fixes the repeating draws.

@Valtora
Valtora merged commit 1e0dbf6 into Valtora:main Oct 23, 2026
17 checks passed
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.

2 participants