fix: uncited-case dedupe collapse + appendix-title path collision (closes #202)#206
Merged
Merged
Conversation
Two correctness bugs from code review (#202): 1. Uncited cases collapsed to one. deduplicateCases keyed on normalizeCitation(citation); empty citations all normalize to '', so distinct CourtListener opinions lacking a structured citation were dropped as duplicates of each other. Add dedupeKey(): cases with a citation still collapse on the normalized citation; uncited cases fall back to a composite caseName|date|sourceUrl key so distinct opinions are retained. 2. Appendix titles collided with the main title. findTitleNumber only matched /\/t(\d+)$/, so "/us/usc/t18a" fell through to "18" and Title 18 Appendix sections were written under title-18/, colliding with main Title 18. Capture the optional appendix letter (/\/t(\d+[a-zA-Z]?)$/ and the num fallback) so t18a → "18a" and sections land under title-18a/. Frontmatter usc_title stays numeric (parseInt → 18) per the Zod schema. New tests cover both. annotator: 82 pass; transformer: 67 pass; monorepo builds. Closes #202 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Closes #202 (two confirmed correctness bugs from code review).
1. Uncited cases collapsed to one
deduplicateCases(packages/annotator/src/citation-utils.ts) keyed onnormalizeCitation(citation). CourtListener results frequently lack a structured citation, andnormalizeCitation('') === '', so the first uncited case was kept and all other distinct uncited opinions were dropped as duplicates.Fix: new
dedupeKey()— cases with a citation still collapse on the normalized citation (real duplicates still merge); uncited cases fall back to a compositecaseName|date|sourceUrlkey so distinct opinions survive.2. Appendix titles collided with the main title
findTitleNumber(packages/transformer/src/parser.ts) only matched/\/t(\d+)$/, so/us/usc/t18afell through to"18"and Title 18 Appendix sections were written undertitle-18/, colliding with main Title 18 (the fetcher already preserves the suffix as18a).Fix: capture the optional appendix letter (
/\/t(\d+[a-zA-Z]?)$/, plus thenumfallback) sot18a → "18a"and appendix sections land undertitle-18a/. Frontmatterusc_titlestays numeric (parseInt → 18) per the Zod schema — no schema change.Tests
/us/usc/t18ayields title"18a"and a path undertitle-18a/, distinct fromtitle-18/.Verification: annotator 82 pass, transformer 67 pass,
pnpm build8/8.🤖 Generated with Claude Code