Skip to content

fix: null-page probe bounds and printed-page offset backfill - #315

Merged
EricNGOntos merged 7 commits into
mainfrom
feat/wuchengke/2026-08-20
Aug 22, 2026
Merged

fix: null-page probe bounds and printed-page offset backfill#315
EricNGOntos merged 7 commits into
mainfrom
feat/wuchengke/2026-08-20

Conversation

@EricNGOntos

Copy link
Copy Markdown
Contributor

Summary

  • Blind-write remaining printed TOC nodes from nearest regime offset after bulk/bisect (counts toward bulk_count before ReAct).
  • Replace the 22-page left-cap with a preorder max-confirmed cursor so nested null-page nodes (e.g. Appendices children) keep a usable search window.
  • Clean obsolete parent-only backfill / last_leaf_start_under helpers and update anchoring contracts.

Test plan

  • pytest apps/worker/tests/contract/test_structure_anchoring_contract.py
  • make check
  • Sydney Streets Code: Stage0+1 clean rebuild; calibrate TOC#1/ci: run checks only on pull requests #2/fix: address CodeQL security findings #3 in isolation
    • TOC#1: Appendices backfill → 261; A/B/E/F ReAct ok; C/D fail on VLM cover rejection
    • TOC#2: 1/2/3.2 ReAct ok; 3/3.1 fail (VLM / no whole-line title)
    • TOC#3: all printed backfill, no ReAct needed

Made with Cursor

EricNGOntos and others added 6 commits August 21, 2026 19:22
… and normalize_match_text

- Updated multiple files to replace instances of normalize_heading_text with the new function normalize_heading_label for improved heading normalization.
- Introduced normalize_match_text for consistent text matching, ensuring CJK-aware spacing and case-insensitivity.
- Adjusted related functions and tests to reflect these changes, enhancing overall text processing accuracy.
- Replaced the read_page_texts function with read_page_text_bands to extract page content, header, and footer as structured PageTextBands.
- Updated ProfileCoordinator and related services to accommodate the new text extraction method, ensuring compatibility with existing workflows.
- Adjusted the blackboard state to include page_text_search_view and modified tests to validate the new structure and functionality.
- Enhanced overall text processing by introducing a more granular approach to handling page content.
…functionality

- Updated the null-page locating logic to differentiate between leaves and parents, improving the handling of null-page nodes.
- Introduced a new function, locate_null_page_parent_overrides, to locate null-page parents using sibling windows, enhancing the accuracy of parent-child relationships.
- Adjusted existing functions to accommodate the new parent locating logic, ensuring compatibility with the overall document structure.
- Refined test cases to validate the new functionality and ensure robustness in null-page handling.
- Updated the strip_margin_text function to support edge-specific margin stripping for headers and footers, improving content extraction accuracy.
- Introduced a new utility function, apply_null_page_locates_and_prune, to streamline null-page processing and enhance the handling of parent-child relationships in document structures.
- Refactored related functions and tests to ensure compatibility with the new logic, improving overall robustness in null-page handling and text processing.
- Enhanced test coverage for edge cases in margin stripping and null-page processing to validate the new functionality.
…indows

- Refactored the anchor_hierarchy_from_regimes function to enhance clarity and maintainability, specifically in the handling of structural parent paths.
- Introduced a new function, progressive_page_windows, to generate non-overlapping page windows for scanning, improving the efficiency of page inspections.
- Updated scan_title_forward to utilize the new progressive page windows function, ensuring better management of page scanning logic.
- Adjusted related tests to validate the new functionality and ensure robustness in null-page processing and page window generation.
Anchor all remaining printed nodes from nearest regime offset before
null-page ReAct, and use preorder max confirmed pages for probe left
bounds so nested appendices keep a usable search window.

Co-authored-by: Cursor <cursoragent@cursor.com>
Comment thread apps/worker/app/services/document_agent/pdf_text.py
Comment thread apps/worker/tests/contract/test_structure_anchoring_contract.py
Comment thread apps/worker/tests/contract/test_structure_anchoring_contract.py
Avoid PageTextBands class-identity mismatch when a prior contract fixture
clears app.* modules mid-suite.

Co-authored-by: Cursor <cursoragent@cursor.com>
@EricNGOntos
EricNGOntos merged commit dee214e into main Aug 22, 2026
6 checks passed
@EricNGOntos
EricNGOntos deleted the feat/wuchengke/2026-08-20 branch August 22, 2026 15:09
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