Skip to content

feat: TOC physical rehome + page_memory render scope isolation - #336

Merged
EricNGOntos merged 7 commits into
mainfrom
feat/wuchengke/2026-08-24
Aug 27, 2026
Merged

EricNGOntos merged 7 commits into
mainfrom
feat/wuchengke/2026-08-24

Conversation

@EricNGOntos

Copy link
Copy Markdown
Contributor

Summary

  • Add TOC physical rehome before classify (closed-interval leaf rehome, prune/skip rules, resolve two-phase for rehomed leaves).
  • Isolate page_memory PNG writes under pages/{scope_id}/page-{n}.png to stop concurrent boundary-page truncate races; reject empty image base64 before VLM.
  • Soften pymupdf EXIT_DELAY: join before closing queue, no kill on success path (debug-only), keep main’s empty-queue retry.
  • Fix outline skeleton toc_pages plumbing and stage5 extract_toc_nodes import for lint/CI.

Test plan

  • make check (ruff + pyright)
  • Focused contracts: page renderer scope path, node assembler citation promote, calibration scan, toc rehome (42 passed)
  • EN_medical page_memory stage0–3 clean rerun: no base64 empty; EXIT_DELAY only DEBUG

Made with Cursor

EricNGOntos and others added 7 commits August 26, 2026 10:53
- Introduced new functions for rehoming calibrated forests and handling pending records in the TOC anchoring process.
- Updated the `compute_fat_leaf_pages` function to exclude TOC pages from the fat span test, ensuring accurate page calculations.
- Refactored various functions to utilize the new `pages_excluding_toc` utility for consistent TOC page exclusion across multiple components.
- Removed the deprecated `TocPagePolicy` class, streamlining the codebase.
- Added tests to validate the exclusion of TOC pages in fat leaf calculations.
- Updated the hierarchy locator to better handle rehome matches and leaf nodes, ensuring accurate page range resolution.
- Introduced new functions for managing rehome ranges and structural leaf identification, improving the clarity and efficiency of the code.
- Enhanced the TOC anchoring process to support global paged-leaf rehome, allowing for more robust handling of TOC structures.
- Refactored tests to validate the new rehome logic and ensure correct behavior in various scenarios.
- Updated the rendering logic to support a new naming convention for PNG files, allowing for better organization based on the presence of a prefix.
- Refactored the inspection process to render pages serially before conducting concurrent inspections, improving efficiency and clarity in the workflow.
- Adjusted the handling of rendered pages in the inspection function to ensure proper coverage and error handling.
- Enhanced tests to validate the new rendering and inspection behavior, ensuring robustness in various scenarios.
Unblocks make check before PR sync.

Co-authored-by: Cursor <cursoragent@cursor.com>
- Integrated token tracking into the concurrent page inspection process, allowing for detailed tracking of token usage during parsing.
- Updated the summarization functions for DOCX and Excel formats to include usage task metadata, improving the granularity of token usage reporting.
- Refactored the debug scripts to better manage token ledger operations, including loading and recording token usage across different stages.
- Enhanced unit tests to validate the new token tracking features and ensure accurate reporting of token usage in various scenarios.
Patching _calibrate_pending_tocs by string path was unreliable in the full
contract suite, so the real path tried to render a missing pdf and dropped
the pending graft record. Align with toc_graft stubs instead.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@EricNGOntos
EricNGOntos merged commit 38e04c0 into main Aug 27, 2026
6 checks passed
@EricNGOntos
EricNGOntos deleted the feat/wuchengke/2026-08-24 branch August 27, 2026 14:23
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