Skip to content

Keep Markdown heading filtering from blocking Worker heartbeats - #592

Merged
suguanYang merged 3 commits into
mainfrom
fix/wangbinqi/isolate-markdown-heading-filtering
Nov 28, 2026
Merged

suguanYang merged 3 commits into
mainfrom
fix/wangbinqi/isolate-markdown-heading-filtering

Conversation

@suguanYang

@suguanYang suguanYang commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Markdown heading prediction
  Prepare candidates in one bounded subprocess per Worker
    Batch writes to heading levels and reasons
    Reap the child on timeout or cancellation
  Run hierarchy prediction and reuse prepared rules on model failure
  Apply predictions by line ID

Worker health still measures whether the gevent loop can schedule its heartbeat.

Evidence

  • Before. With 195,735 synthetic Markdown lines, the health probe reported a stale heartbeat at the 45-second threshold during the second rule pass. The scheduling regression test also failed before the fix.
  • After. The same input finished heading prediction and relocation in 77.7 seconds in local Docker with simulated model responses. All 770 health probes passed. The oldest heartbeat observed was 20.6 seconds.
  • All 14 targeted tests and Ruff passed, including subprocess imports from outside the worker directory and the model-failure fallback. A local cancellation probe also verified that two concurrent calls shared one slot and that each child was reaped before the slot was reused.

Merge Danger

Two-way door. A revert restores the previous parser code. The change requires no migration.

Blast radius. Worker Markdown heading prediction and the shared rule pass used by DOCX.

A large Markdown document could starve the gevent heartbeat while the heading rules rewrote candidate rows one at a time. Run those rules in a bounded subprocess, batch candidate updates, and look up predictions by line ID.
Pass the current worker import path to the child and reuse precomputed Markdown rules when the model fails. Exercise both paths in regression tests.
@suguanYang
suguanYang merged commit 5aadf07 into main Nov 28, 2026
6 checks 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