Skip to content

Stop the legal-form prose matcher returning the jurisdiction clause - #289

Merged
sroussey merged 1 commit into
mainfrom
claude/keen-knuth-onotd9-prose-legal-forms
Aug 15, 2026
Merged

Stop the legal-form prose matcher returning the jurisdiction clause#289
sroussey merged 1 commit into
mainfrom
claude/keen-knuth-onotd9-prose-legal-forms

Conversation

@sroussey

Copy link
Copy Markdown
Contributor

The bug

The shared prose alternation (legalFormProseSuffixAlternation) case-folded every legal-form spelling, so corporation matched 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:

Agreement and Plan of Merger, by and among Acme Acquisition Corp., a Delaware corporation ("Company"), and Target Holdings, Inc., a Delaware corporation.

matches
hand-written alternation the helper replaced ["Acme Acquisition Corp.", "Target Holdings, Inc."]
legalFormProseSuffixAlternation (before) ["Acme Acquisition Corp.", "Delaware corporation", "Target Holdings, Inc.", "Delaware corporation."]

extractMergerCounterparty therefore returned "Delaware corporation", which is persisted as the definitive_agreement event's detail.

A second bug reproduced alongside it: nothing anchored the left edge, so the two-letter AG spelling matched the Ag of Agreement and "Business Combination Agreement" yielded the party name "Business Combination Ag".

The fix

spellingToProsePattern in src/util/legalForms.ts, two rules:

  1. Ordinary English-word spellings (Corporation, Company, Limited, Incorporated, Trust) 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 — filers really do write Barclays plc and TARGET HOLDINGS, INC. alike.
  2. Each alternative is bracketed \b(?[A-Za-z]). The leading boundary closes the Ag-inside-Agreement hole. The trailing guard is a negative lookahead and not \b on purpose: a word boundary after the optional dot would refuse to consume it and silently truncate Blackstone Holdings L.P. to Blackstone Holdings L.P.

Fixed in the shared helper, not at the call sites. There are exactly two (LEGAL_NAME and WITH_NAMED, both in spac8kMilestones.ts), which need no change and any future call site inherits the guard. caseInsensitiveLetters stays — the short forms still use it.

Verified corpus

sentence matches
the regressed sentence above ["Acme Acquisition Corp.", "Target Holdings, Inc."]
…Pono Capital Corp., a Delaware corporation, and Horizon Space Ltd. both names
…BIG SPAC CORP., MERGER SUB INC., and TARGET HOLDINGS, INC., a Delaware corporation all three
…Rockley Photonics Holdings plc, an English public limited company the plc name
…Blackstone Holdings L.P., a Delaware limited partnership keeps the trailing dot
Business Combination Agreement, by and among … no Business Combination Ag

Known narrowing

A counterparty written with an entirely lowercase multi-letter formFoo 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 matching a Delaware corporation on essentially every de-SPAC 8-K, which is strictly worse. Short forms are unaffected (Foo Holdings ltd still matches).

Tests

spac8kMilestones.test.ts — the verbatim regressed sentence, the Business Combination Agreement prefix case, an ALL-CAPS party list, a lowercase plc, and Blackstone 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 :62 passes 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, since Incorporated is no longer spelled [Ii][Nn][Cc][Oo]…. Adds a case-sensitivity test (corporation/company/limited/incorporated rejected; CORPORATION/COMPANY/INC./plc accepted) and a word-prefix test.

$ bun run test -- src/util/legalForms.test.ts src/sec/forms/miscellaneous-filings/spac8kMilestones.test.ts
 Test Files  2 passed (2)
      Tests  46 passed (46)

$ npx tsc --noEmit   # exit 0

Generated by Claude Code

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
@sroussey
sroussey merged commit 3ce552e into main Aug 15, 2026
1 check 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