Repository navigation
fix: citation-placement bugs from the PR #403 review - #410
Merged
Merged
Conversation
…ntext The precedingIdentifier heuristic in migrateLegacyCitationMarkers fired for any word directly followed by [n], which is also the shape of a normal, unlinked citation marker (e.g. "documentation[1] explains"). Rely on the existing backtick-based inline-code check instead; array-index-style text now needs backticks to be preserved as code.
_SENTENCE_END_PATTERN was punctuation-only, so a marker landed right after a title or 'et al.' (e.g. "Dr.[1] Smith") instead of the real sentence end. Add a fixed abbreviation-exception list (Dr., Mr., Mrs., Ms., Prof., vs., etc., i.e., e.g., et al.) applied everywhere the pattern is used to find a sentence boundary.
PR #403 added a frontend-tests CI job (test.yml and tests.yml) that runs frontend/test-citation-markers.js and frontend/test-streaming.js with Bun. Update comments that still claimed no JS runtime is available in CI.
Contributor
Preview Deployment
This preview will be updated automatically when you push new commits. |
The abbreviation exception treated every listed abbreviation as never sentence-final, forward-searching past it unconditionally. That's right for titles (Dr., Mr., ...), which are always followed by a name in the same sentence, but wrong for etc./e.g./et al., which frequently do end a sentence -- especially in enumerative technical prose (HED/BIDS/EEGLAB docs list features, tags, etc.). A marker after one of those was silently relocated into the next, unrelated sentence. Split the exception into two kinds: titles always skip forward; etc./al/ e.g./i.e. only skip forward when the text right after the period is lowercase, the signal that the same sentence continues. Otherwise their own boundary is accepted.
…cross one
Two rounds of heuristic each fixed the reported misplacement while causing
the opposite one: a marker relocated into a different, unrelated sentence.
Even the seemingly reliable 'title + capitalized word' signal fails ('she
became a Dr. Her family...' has a capitalized word after the period too,
and it is not a name). No cheap local signal reliably distinguishes an
abbreviation's period from a real sentence end in both directions.
Replace the heuristic with a conservative default: never relocate a marker
across an abbreviation's period into a different sentence. A marker left
right after 'Dr.' or 'et al.' is imprecisely placed but still within (or
adjacent to) the sentence it supports -- an accepted, bounded degradation,
not a misattribution to the wrong claim. 'vs.' is the sole exception,
confirmed across two review passes to not occur as a genuine sentence end
in natural prose, so it still skips forward.
Test matrix covers both directions for each abbreviation family (title,
et al., etc., e.g.) plus the title-as-standalone-noun edge case, using
domain-flavored HED/BIDS/EEGLAB-style prose.
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.
Summary
Addresses the citation-placement/marker-logic findings from the PR #403 review:
migrateLegacyCitationMarkers's code-context exception was over-broad (fired for any word directly touching[n], which is also the shape of a normal unlinked marker). Narrowed to rely on the existing backtick-based inline-code check. Behavior change: array-index-style text (arr[1]) now needs backticks to be preserved as code, matching how the already-passing backtick-wrapped case works; updatedfrontend/test-streaming.jsaccordingly._SENTENCE_END_PATTERNhad no abbreviation exception, so a marker landed mid-title ("Dr.[1] Smith") instead of at the real sentence end.frontend/test-citation-markers.js,tests/test_frontend/test_widget_citations.py, andtests/test_frontend/test_widget_drift.py— PR Release: Anthropic Claude Platform migration and citation quality fixes #403 added a realfrontend-testsBun CI job.Design history on Important #7 (three rounds, ended in a different design than started):
etc./e.g./et al.frequently do end a sentence, and the lowercase-character proxy got it wrong in both directions (relocated a marker into an unrelated sentence, or left it stuck one sentence too early)."she became a Dr. Her family..."has a capitalized word after the period too, and it is not a name).Final design: stop guessing. Never relocate a marker across an abbreviation's period into a different sentence. A marker left right after
Dr.oret al.is imprecisely placed but still within (or immediately adjacent to) the sentence it supports — a bounded, honest degradation, not a misattribution to the wrong claim, in keeping with this project's "precision over features" principle.vs.is the sole exception: across two review passes nobody could construct natural prose where it genuinely ends a sentence, so it still skips forward to the real end. Test matrix (TestNormalizeCitationMarkersAbbreviations) covers both directions for each abbreviation family (title, et al., etc., e.g.) plus the title-as-standalone-noun edge case, using domain-flavored HED/BIDS/EEGLAB-style prose (lowercase filenames, capitalized tool names, CLI flags) since that's where this project's actual risk concentrates.Reviewer note (not a blocker): there's a negligible residual risk that the frontend fix (Important #5) mis-migrates un-backticked
word[N]array-index-shaped text. Checked against the real HED docs corpus and this shape does not actually occur there — accepted as a documented limitation rather than fixed further.Test plan
uv run pytest tests/test_agents/test_content.py tests/test_frontend/ -v- 91 passedbun frontend/test-streaming.js- 69 passedbun frontend/test-citation-markers.js- 10 passeduv run ruff check/ruff formatclean