Skip to content

feat(flows): draft paper structure from full page text in bounded windows - #152

Open
liyc-sys wants to merge 1 commit into
LLMQuant:masterfrom
liyc-sys:feat/structure-windowed-full-text
Open

feat(flows): draft paper structure from full page text in bounded windows#152
liyc-sys wants to merge 1 commit into
LLMQuant:masterfrom
liyc-sys:feat/structure-windowed-full-text

Conversation

@liyc-sys

Copy link
Copy Markdown

Summary

Implements the windowed full-page-text drafting direction recorded in #133. The structure draft model previously saw only the first page_text_chars characters (default 1,200) of each page in a single pass, so section starts in the lower part of a dense page and structure that must be inferred from body prose were invisible at drafting time, and node summaries were written from the same truncated view.

Drafting now follows the PageIndex-style input policy the issue describes: pages are packed complete into character-bounded windows (window_chars, default 80,000 ≈ 20k tokens, matching the reference implementation's window size at ~4 chars/token), consecutive windows share window_overlap_pages (default 1) trailing pages for continuity, and a document larger than one window is drafted across chained calls in which the model receives the prior draft as draft_so_far and returns the complete extended hierarchy. A page is never split; an oversized page forms its own window; window packing always advances at least one page, so it terminates. The returned draft keeps the worst quality rating seen across windows, so one unreliable window still routes the document to the existing deterministic flat fallback in PaperStructureTree.from_draft.

page_text_chars stays available as an explicit per-page clip for cost control on sparse inputs, per the issue's "document when truncation is safe" note, but the default is now None (full pages). PaperStructureProducer records the new input policy (orchestration: "windowed-v1", window_chars, window_overlap_pages, optional page_text_chars); the previous "single-pass-v1" literal and integer page_text_chars remain valid so stored artifacts keep loading, and the changed producer identity versions new trees separately from old ones, as designed. prompt_version bumps to paper-structure-v3.

The issue's remaining directions — a title-verification pass and a dedicated summary pass over full section text — are not in this PR; they change the draft acceptance and call-count contracts and seem better reviewed as their own slices on top of this input-policy change.

Related Issue

Part of #133.

Verification

  • bash scripts/verify.sh passes (ruff format/check, basedpyright, lint-imports, pytest: 494 passed, coverage 86%).
  • New offline tests: window packing (single window, overlap coverage, oversized page, forward progress under large overlap), full-text vs clipped page payloads, multi-window chained drafting (window metadata, draft_so_far threading, full text across the seam, worst-quality aggregation), and the single-call path for small documents.
  • python scripts/verify_structure_e2e.py was not run locally (no provider credentials for the configured models); the path-filtered structure job in e2e.yml covers this change's paths.

Checklist

  • The title uses English Conventional Commit format: type(scope): summary.
  • The related issue or design discussion is linked when applicable.
  • bash scripts/verify.sh passes.
  • Every applicable live-network component smoke test passes, or this PR states why none applies (stated above: structure e2e left to the path-filtered CI job).
  • Public behavior has focused tests, an example, and documentation where applicable.
  • The PR is complete, small, and contains no unrelated changes.

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