Skip to content

fix: don't let //-comment stripping corrupt string values containing URLs#78

Merged
LegalMarc merged 2 commits into
mainfrom
fix/json-comment-strip-url-corruption
Jul 15, 2026
Merged

fix: don't let //-comment stripping corrupt string values containing URLs#78
LegalMarc merged 2 commits into
mainfrom
fix/json-comment-strip-url-corruption

Conversation

@LegalMarc

Copy link
Copy Markdown
Owner

Summary

  • Root-causes the nightly/tag E2E failure streak: the //-comment-stripping regex in parse_llm_response() (src/python/marcut/model.py) was blindly stripping anything after //, which corrupted any LLM-extracted entity whose value contained a URL (e.g. https://...).
  • Replaces it with a string-aware comment stripper that only strips real // comments outside of string literals, leaving URL-bearing values intact.
  • Adds 2 regression tests to tests/test_model.py covering entities with URL values.
  • Updates docs/BACKLOG.md to defer PR ci: switch workflows to self-hosted local macOS runner #34 (self-hosted runner work) with rationale, since it was blocked behind this same investigation.

Test plan

  • Full Python suite passes: 557 passed / 6 skipped
  • Reproduced the original bug in isolation: 15/15 failures before the fix
  • Confirmed the fix in isolation: 15/15 successes after the fix
  • Verified end-to-end through the real GUI app with the production model (qwen2.5:14b)

🤖 Generated with Claude Code

Marc Mandel and others added 2 commits July 15, 2026 11:06
…URLs

parse_llm_response()'s comment-stripping regex (re.sub(r'(?m)//.*$', '', ...))
matched `//` anywhere on a line, including inside JSON string values. Any LLM-
extracted entity whose text contains "//" -- most commonly a URL like
"https://legal.example" -- had everything from the `//` to end-of-line
stripped, corrupting the JSON and making a genuinely valid response
unparseable.

Root cause of the nightly/tag E2E red streak since 2026-07-10: the fixed
CI test document contains "https://legal.example", which llama3.2:1b
reliably extracts as an entity, so every extraction attempt for that chunk
hit this corruption and failed after retries. Before the A4 fail-closed
hardening (#58, 2026-07-09), the same chunk failure was silently swallowed
and the run still reported success; A4 correctly started failing closed on
it instead of shipping an incompletely-scanned document, which is what
surfaced this as a hard CI failure. Reproduced deterministically outside
CI (isolated local Ollama instance, 15/15 failures before the fix, 15/15
successes after) -- not CI-infra flakiness.

Replaced the naive regex with a string-aware line-comment stripper that
tracks JSON string-literal state (respecting \" escapes) and only treats
`//` as a comment start outside of one.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Not needed for CI green: the nightly/tag E2E red streak that would have
been the reason to revisit it turned out to have a deterministic root
cause unrelated to runner choice (see fix/json-comment-strip-url-corruption).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@LegalMarc
LegalMarc merged commit 04d8df0 into main Jul 15, 2026
3 checks passed
@LegalMarc
LegalMarc deleted the fix/json-comment-strip-url-corruption branch July 15, 2026 18:41
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.

1 participant