Stop the legal-form prose matcher returning the jurisdiction clause - #289
Merged
Merged
Conversation
The shared prose alternation case-folded every legal-form spelling, so
`corporation` in "a Delaware corporation" matched as if it were a party
name. On a de-SPAC 8-K the party scan then returned "Delaware
corporation" as the merger counterparty, and that string was persisted
as the `definitive_agreement` event's `detail`.
Word-shaped spellings (Corporation, Company, Limited, Incorporated,
Trust) now keep the filing's capitalisation plus an ALL-CAPS variant for
filers who shout their exhibits; short abbreviations (Plc, Inc, Ltd,
LLC, N.V.) stay case-folded because filers write "Barclays plc" and
"TARGET HOLDINGS, INC." alike.
Each alternative is also bracketed by `\b` … `(?![A-Za-z])`. The leading
boundary stops a short form matching inside a longer word ("Business
Combination **Ag**reement"); the trailing lookahead — deliberately not
`\b` — is what lets the optional dot of "Corp." be consumed instead of
truncating the extracted name.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UW1Qr5mxetAQr61YKEY9nz
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.
The bug
The shared prose alternation (
legalFormProseSuffixAlternation) case-folded every legal-form spelling, socorporationmatched as if it were part of a party name. It is not — lowercased, it is the jurisdiction clause that follows one.Verified by execution on:
["Acme Acquisition Corp.", "Target Holdings, Inc."]legalFormProseSuffixAlternation(before)["Acme Acquisition Corp.", "Delaware corporation", "Target Holdings, Inc.", "Delaware corporation."]extractMergerCounterpartytherefore returned"Delaware corporation", which is persisted as thedefinitive_agreementevent'sdetail.A second bug reproduced alongside it: nothing anchored the left edge, so the two-letter
AGspelling matched theAgofAgreementand"Business Combination Agreement"yielded the party name"Business Combination Ag".The fix
spellingToProsePatterninsrc/util/legalForms.ts, two rules:Barclays plcandTARGET HOLDINGS, INC.alike.\b…(?[A-Za-z]). The leading boundary closes theAg-inside-Agreementhole. The trailing guard is a negative lookahead and not\bon purpose: a word boundary after the optional dot would refuse to consume it and silently truncateBlackstone Holdings L.P.toBlackstone Holdings L.P.Fixed in the shared helper, not at the call sites. There are exactly two (
LEGAL_NAMEandWITH_NAMED, both inspac8kMilestones.ts), which need no change and any future call site inherits the guard.caseInsensitiveLettersstays — the short forms still use it.Verified corpus
["Acme Acquisition Corp.", "Target Holdings, Inc."]…Pono Capital Corp., a Delaware corporation, and Horizon Space Ltd.…BIG SPAC CORP., MERGER SUB INC., and TARGET HOLDINGS, INC., a Delaware corporation…Rockley Photonics Holdings plc, an English public limited company…Blackstone Holdings L.P., a Delaware limited partnershipBusiness Combination Agreement, by and among …Business Combination AgKnown narrowing
A counterparty written with an entirely lowercase multi-letter form —
Foo Holdings limited— no longer matches. That is a real loss of coverage, accepted deliberately: it was checked against seven realistic sentences with zero misses, and the alternative is matchinga Delaware corporationon essentially every de-SPAC 8-K, which is strictly worse. Short forms are unaffected (Foo Holdings ltdstill matches).Tests
spac8kMilestones.test.ts— the verbatim regressed sentence, theBusiness Combination Agreementprefix case, an ALL-CAPS party list, a lowercaseplc, andBlackstone Holdings L.P.(which pins that the trailing dot survives — the reason the guard is a lookahead).legalForms.test.ts— the suffix-anchored test at:62passes unchanged (all 15 true and 2 false cases). The ordering test is rewritten to assert the property that actually holds — ordering by first index of an alternative that matches the spelling — rather than the literal pattern text it used to pin, sinceIncorporatedis no longer spelled[Ii][Nn][Cc][Oo]…. Adds a case-sensitivity test (corporation/company/limited/incorporatedrejected;CORPORATION/COMPANY/INC./plcaccepted) and a word-prefix test.Generated by Claude Code