Skip to content

idx=13: freeze (47 records) — Cotiviti First Amendment (no-space /s/ + PASS-3 IWW body check) - #86

Open
arthrod wants to merge 1 commit into
redo/idx-12from
redo/idx-13
Open

idx=13: freeze (47 records) — Cotiviti First Amendment (no-space /s/ + PASS-3 IWW body check)#86
arthrod wants to merge 1 commit into
redo/idx-12from
redo/idx-13

Conversation

@arthrod

@arthrod arthrod commented May 17, 2026

Copy link
Copy Markdown
Owner

User description

Summary

Fourteenth stacked PR. Adds idx=13 (FIRST AMENDMENT AGREEMENT, Cotiviti Holdings / Cotiviti Corporation, April 7, 2017) as the fourteenth verified frozen baseline on top of idx=12 (PR #85).

Parser changes (2 surgical, shape-driven)

  1. Relaxed /s/\s+\w+/s/\s*\w+ in both _SIGN_OFF_RE and _SIG_TITLE_ANCHOR_RE (~lines 3614, 3618). Detects typesetter no-space sig form like /s/Jonathan Olefson. Regression-safe (no frozen idx 0..12 carries this form, verified byte-identical shasums).

  2. PASS-3 IWW guard widened (~line 4214) to mirror PASS-2's body-IWW check: _is_iww_clause(span) or _is_iww_clause(body). Keeps the IWW carrier at L1 when doc2dict packs page-chrome filler (e.g. [Remainder of page intentionally left blank.]) into the title and the IWW operating sentence into the body. The strict ^\s*IN\s+WITNESS anchor still applies — cannot match mid-text IWW phrases.

Verified output for idx=13

  • 47 records, distribution {L0:1, L1:22, L2:24} (max depth 2)
  • Reconstruction: word_coverage 97.7%, char_ratio 99.6%

Top structure

o=0  L0: FIRST AMENDMENT AGREEMENT
o=1  L1: This FIRST AMENDMENT to the Credit Agreement referred to below... COTIVITI CORPORATION, a Delaware corporation as a borrower...
o=2  L1: RECITALS / WHEREAS, the Borrowers, Holdings, the several Lenders...
o=3  L1: SECTION 1. Amendments to Credit Agreement.
o=9  L1: SECTION 2. Continuation of Existing Term Loans; Non-Consenting Lenders; Other Terms and Agreements.
o=13 L1: SECTION 3. Conditions of Effectiveness.
...
o=38 L1: [Remainder of page intentionally left blank.] / IN WITNESS WHEREOF, the parties hereto have caused this First Amendment...   ← IWW packed with sig content by doc2dict (pinned L1 by PASS-3 widened check)
o=39 L1: ANNEX I INITIAL TERM B LENDER CONSENT TO                            ← subdoc header at L1
o=40 L2: <ANNEX I body with +1 subdoc penalty>
o=42 L1: ANNEX II FORM OF MASTER ASSIGNMENT AND ASSUMPTION AGREEMENT          ← subdoc header at L1
o=43 L2: <ANNEX II body (10997 chars) with +1 subdoc penalty>
o=46 L2: <remaining sig fragments — Holdings, Subsidiary Guarantors, JPMORGAN as Administrative Agent + Replacement Lender>

Both subdocs handled correctly

  • ANNEX I: header at L1 (o=39), body at L2 (o=40) with +1 subdoc penalty
  • ANNEX II: header at L1 (o=42), body at L2 (o=43) with +1 subdoc penalty

Known minor quirks (deferred to polish round, non-blocking)

  • o=41 ("Annex I") and o=45 ("ANNEX II-2") are page-banner records that doc2dict classified as cls="annex". They survive the title-as-root scope rule because they descend from the title structurally. Pure page chrome, content-empty.
  • o=44 ("ANNEX II-1\n3.General Provisions...") carries 677 chars of legitimate continuation text from the Standard Terms section that doc2dict assigned to the page-footer banner node. Content preserved (no data loss), just structurally misattributed.

Future polish round can coalesce cls=annex page banners (regex ^(Annex\s+[IVX]|ANNEX\s+[IVX]+(-\d+)?)$ with empty body) into their preceding siblings. Not blocking — reconstruction at 97.7%/99.6%.

Test plan

  • uv run scripts/parse_doc2dict_with_config.py --limit 14 --no-truncate --output-dir data/auto_parse exits 0 with ok 14
  • uv run scripts/level_loop/freeze.py 13 --force reports word_coverage ≥ 90% (97.7%)
  • uv run scripts/level_loop/regress.py reports all 14 frozen idxs OK
  • Inspector verified both fixes; idx=0..12 byte-identical via shasum
  • Inspector verified ANNEX I + ANNEX II both at L1 header / L2 body (+1 penalty)
  • Inspector confirmed /s/Jonathan Olefson no-space form now detected (was previously invisible)

Source

http://www.sec.gov/Archives/edgar/data/1657197/000155837017003407/cotv-20170331ex1010f7ed3.htm

🤖 Generated with Claude Code


CodeAnt-AI Description

Handle no-space signature lines and keep IWW clauses at the right level

What Changed

  • Signature lines like /s/JonathanOlefson are now recognized, not just /s/ Name
  • The IWW clause stays at the top signature-page level even when its text is split between the title and body
  • idx=13 is added as a frozen baseline with 47 records

Impact

✅ Fewer missed signatures in scanned agreements
✅ Correct placement of witness clauses
✅ More stable frozen parser baselines

🔄 Retrigger CodeAnt AI Review

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

…edit Agreement: relax /s/ regex to allow no-space form, fix PASS-3 IWW-body check

Cotiviti Holdings idx=13 (1066-row corpus, 14th row) is a First
Amendment to Credit Agreement with two ANNEX form templates. Two
shape-based fixes were needed:

1. Typesetter omits the space between `/s/` and the signatory name
   (`/s/Jonathan Olefson`). The `_SIGN_OFF_RE` regex required `\s+\w+`
   after `/s/`, so doc2dict-fragmented sig nodes carrying only the
   no-space form were never detected as sig carriers and stayed at L1.
   Relaxed to `\s*\w+` so both `/s/ Name` and `/s/Name` match. No
   frozen idx 0..12 carries the no-space form so this change is
   regression-safe.

2. The IWW-carrier guard in PASS 3 of `_explode_signature_block_lines`
   only checked the combined span starts with "IN WITNESS WHEREOF",
   but doc2dict packed the IWW sentence into the body of a node whose
   title is `[Remainder of page intentionally left blank.]`. PASS 2
   correctly identified this as the IWW carrier and pinned it to L1
   via body match; PASS 3's span-only check then demoted it to L2.
   Mirror the PASS-2 detection (span OR body) so the IWW carrier
   stays L1 regardless of where doc2dict placed the IWW sentence.

Stats: 47 records, levels {0:1, 1:22, 2:24}, max depth 2,
reconstruction 97.7% word coverage / 99.6% char ratio. All 14 idxs
0..13 pass regression.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@blocksorg

blocksorg Bot commented May 17, 2026

Copy link
Copy Markdown

Mention Blocks like a regular teammate with your question or request:

@blocks review this pull request
@blocks make the following changes ...
@blocks create an issue from what was mentioned in the following comment ...
@blocks explain the following code ...
@blocks are there any security or performance concerns?

Run @blocks /help for more information.

Workspace settings | Disable this message

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hi @arthrod! 👋

Your private repo does not have access to Sourcery.

Please upgrade to continue using Sourcery ✨

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@codeant-ai

codeant-ai Bot commented May 17, 2026

Copy link
Copy Markdown

CodeAnt AI is reviewing your PR.

@coderabbitai

coderabbitai Bot commented May 17, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 96b66894-5a9b-437b-9286-cdf44c9006e6

📥 Commits

Reviewing files that changed from the base of the PR and between 402a056 and 1ac070d.

📒 Files selected for processing (3)
  • data/auto_parse/level_freeze/frozen/idx_13.jsonl
  • data/auto_parse/level_freeze/state.json
  • scripts/parse_doc2dict_with_config.py
📜 Recent review details
🧰 Additional context used
📓 Path-based instructions (2)
**/*.py

📄 CodeRabbit inference engine (Custom checks)

**/*.py: Run smoke test for Python web servers: start server, wait for ready signal, hit GET /health or GET /, assert HTTP 200. Timeout: 30s. Fail if smoke test fails.
Run smoke test for Python CLI: run <cli> --help, assert exit code 0. Fail if smoke test fails.
Run uv run pytest --cov=<src_package> --cov-report=term-missing --cov-branch --cov-fail-under=80 -q for Python coverage. Fail if exit code is non-zero, branch coverage < 70%, or line coverage < 80%.
Run uv run ruff check . --diff for Python linting. Fail if exit code is non-zero and list each violation.
Run uv run ruff format --check --diff . for Python formatting. Fail if exit code is non-zero and list each unformatted file.
Scan diffs for newly added Python suppression comments (# noqa, # type: ignore). Each suppression must have an inline justification comment. Fail if any new suppression lacks justification. Warn if total new suppressions > 3 in a single PR.
Run uv run ruff check --select I,F401 . to verify Python import ordering and detect unused imports. Fail if violations found.
Run the full Python test suite: uv run pytest --tb=line -q on origin/main to capture baseline pass/fail counts, and uv run pytest --tb=short -q on PR branch. Fail immediately if exit code is non-zero.
Run uv run typy check for Python type checking if .py files exist in diff or project has py.typed marker. Fail if exit code is non-zero. If typy is not available, use configured mypy or pyright instead. Fail with 'No Python type checker configured' if none is found.
Scan diffs for new bare type: ignore comments (without error codes) in Python files and cast() calls without explanatory comments. Warn for each. Fail if bare type: ignore count > 3.

Files:

  • scripts/parse_doc2dict_with_config.py
**/*.{py,ts,tsx}

📄 CodeRabbit inference engine (Custom checks)

For each changed production file, verify at least one corresponding test file exists or already exists in the repo with assertions covering changed symbols. Fail if a changed production file has zero associated test file and introduces new exported functions, classes, or public methods. Exempt: config files, type declaration files (.d.ts), migrations, and generated code.

Files:

  • scripts/parse_doc2dict_with_config.py
🔍 Remote MCP

Based on my search attempts, I've found contextual information about Cotiviti Holdings as a company, but the Repository-specific tools (DeepWiki and Context7) encountered limitations. Let me provide you with a summary of the relevant context I was able to gather:

Review Context Summary

Document Source Verification

The source document contains a signature from Jonathan Olefson, Esq., which aligns with the PR's mention of handling the /s/Jonathan Olefson signature format without spaces.

Cotiviti Corporate Context

Cotiviti is a leading provider of analytics-driven payment accuracy solutions, focused primarily on the healthcare sector. The First Amendment Agreement being parsed in idx=13 is a material agreement reflecting amendments to credit facilities or operational terms.

PR Changes Assessment

1. Signature Handling (Regex Changes)
The PR relaxes signature detection regex from /s/\s+\w+ to /s/\s*\w+ to handle no-space signature formats like /s/Jonathan Olefson. This is a backward-compatible improvement—the pattern change makes whitespace optional rather than required, so existing properly-spaced signatures will continue to match.

2. IWW (In Witness Whereof) Clause Detection
The second parser change expands the PASS-3 guard checking from just signature spans to also check the body text directly. This prevents incorrect demotion of "IN WITNESS WHEREOF" clauses that may be placed in the node body rather than as a standalone span—a real issue that could occur with complex document layouts.

3. Validation Metrics
The PR shows strong parsing results:

  • 47 records with proper hierarchical distribution (1 L0, 22 L1, 24 L2)
  • Word coverage: 97.7% (high fidelity)
  • Character ratio: 99.6% (excellent reconstruction)
  • Subdoc handling: Both ANNEX sections properly treated as separate document chunks

Risk Assessment

  • Regression safety: Changes to idx 0-12 unaffected (as stated in PR summary)
  • Known quirks deferred: Minor attribution issues (page banners, footers) marked for future polish round
  • Test coverage: All parsing, freeze, regression, and inspector checks reported as passing
🔇 Additional comments (3)
scripts/parse_doc2dict_with_config.py (1)

3610-3614: LGTM!

Also applies to: 3618-3618, 4538-4545

data/auto_parse/level_freeze/frozen/idx_13.jsonl (1)

1-47: LGTM!

data/auto_parse/level_freeze/state.json (1)

16-17: LGTM!

Also applies to: 210-221


📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Added support for processing "FIRST AMENDMENT AGREEMENT" documents with complete structural parsing.
  • Bug Fixes

    • Improved signature mark recognition to handle variant formatting.
    • Enhanced parsing logic to prevent incorrect document structure depth assignment in specific layout scenarios.

Walkthrough

Parser signature detection is improved to handle compact /s/ markers and strengthen IWW clause protection in title/body layouts. Document idx 13 (First Amendment to Credit Agreement) is then successfully frozen, with extracted clauses stored as JSONL data and freeze history tracked in state.

Changes

Document Freeze with Parser Improvements

Layer / File(s) Summary
Signature parsing improvements
scripts/parse_doc2dict_with_config.py
Regex patterns for /s/ signature marks are loosened to match compact format without space after marker. IWW clause protection in PASS 3 is strengthened by checking both record span and body-only text, preventing incorrect depth demotion in title/body-layout edge cases.
Freeze data and state for idx 13
data/auto_parse/level_freeze/frozen/idx_13.jsonl, data/auto_parse/level_freeze/state.json
Document idx 13 (First Amendment to Credit Agreement) is frozen with extracted amendment sections, Annex forms, and signature blocks stored in JSONL. The frozen state array is extended to include idx 13, and two freeze history records are appended with operation timestamps and record counts.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested labels

Feat2

Poem

🐰 A frozen agreement takes form,
Where clauses find shelter and warm—
/s/ marks now slack,
IWW guard's got your back,
Amendment idx 13, all born!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main changes: adding idx=13 as a frozen baseline and identifying the two surgical parser fixes (no-space /s/ signature detection and PASS-3 IWW body check).
Description check ✅ Passed The description is directly related to the changeset, explaining the two parser modifications, verified output metrics, and the addition of idx=13 as a new frozen baseline.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Comment @coderabbitai help to get the list of available commands and usage tips.

@codeant-ai codeant-ai Bot added the size:M This PR changes 30-99 lines, ignoring generated files label May 17, 2026
@coderabbitai coderabbitai Bot added the Feat2 label May 17, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request updates the document parser to handle signature lines where the space between the marker and the name is omitted and improves the detection of 'In Witness Whereof' (IWW) clauses when they are preceded by page-chrome filler text. Feedback identifies that the regex updates for signature lines are incomplete, as other critical patterns still require mandatory whitespace. Additionally, the IWW detection logic needs to be applied to the signature line consolidation step to prevent signature fragments from being misaligned in the document structure. Finally, a duplicate entry for index 13 was found in the state history log, and an unused regex constant was identified for removal.

# Typesetters sometimes omit the space between the "/s/" marker and the
# signatory's name. The pattern matches either form (zero or more
# whitespace between the marker and the first name word).
_SIGN_OFF_RE = re.compile(r"/s/\s*\w+")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

The relaxation of the whitespace requirement to \s* is correct for detecting no-space signature forms (e.g., /s/JonathanOlefson), but the fix is incomplete. Several other critical regexes still require mandatory whitespace:

  1. _SIG_LINE_RE (line 445): r"/s/\s+\w+". Used in _find_signature_cutoff (line 516). Missing this means the signature block cutoff might be misidentified for documents using the no-space form.
  2. _STRUCTURAL_LEVELS entry (line 341): r"^/s/\s". Missing this means no-space signature titles won't be correctly remapped to Level 1.

These should be updated to use \s* for consistency and correctness across the parser.

# left blank.]") and whose body starts with IWW is still the
# IWW operating clause and stays L1.
r_body_pass3 = (r.get("body_direct") or "").strip()
if _is_iww_clause(_span_text(r)) or _is_iww_clause(r_body_pass3):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

The widening of the IWW check to include the body alone is a necessary fix for records where the title contains page chrome (e.g., "[Remainder of page intentionally left blank.]"). However, this fix is incomplete as it was not applied to _consolidate_sig_lines_after_iww (line 4695).

In idx=13, this causes the remaining signature fragments (order=46) to be appended at the end of the document (after the Annexes) instead of being anchored immediately after the IWW clause (order=38), which violates the contiguous signature block rubric. Please apply the same widened check to the anchor logic.

# A "signature anchor" is a record whose TITLE or BODY contains a /s/
# signature line. Detected by SHAPE only — no party-name matching.
_SIG_TITLE_ANCHOR_RE = re.compile(r"^\s*/s/\s+\w+")
_SIG_TITLE_ANCHOR_RE = re.compile(r"^\s*/s/\s*\w+")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

_SIG_TITLE_ANCHOR_RE appears to be unused in this script. If it is not required for external tools or planned future work, it should be removed to keep the codebase clean.

Comment on lines +211 to 222
{
"ts": "2026-05-17T09:04:40",
"action": "freeze",
"idx": 13,
"n_records": 47
},
{
"ts": "2026-05-17T09:05:18",
"action": "freeze",
"idx": 13,
"n_records": 47
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

There is a duplicate entry for idx: 13 in the history log with slightly different timestamps. Only one entry per freeze action is needed.

    {
      "ts": "2026-05-17T09:05:18",
      "action": "freeze",
      "idx": 13,
      "n_records": 47
    }

@codeant-ai

codeant-ai Bot commented May 17, 2026

Copy link
Copy Markdown

CodeAnt AI finished reviewing your PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feat2 size:M This PR changes 30-99 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant