feat(flows): draft paper structure from full page text in bounded windows - #152
Open
liyc-sys wants to merge 1 commit into
Open
feat(flows): draft paper structure from full page text in bounded windows#152liyc-sys wants to merge 1 commit into
liyc-sys wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the windowed full-page-text drafting direction recorded in #133. The structure draft model previously saw only the first
page_text_charscharacters (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 sharewindow_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 asdraft_so_farand 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 inPaperStructureTree.from_draft.page_text_charsstays 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 nowNone(full pages).PaperStructureProducerrecords the new input policy (orchestration: "windowed-v1",window_chars,window_overlap_pages, optionalpage_text_chars); the previous"single-pass-v1"literal and integerpage_text_charsremain valid so stored artifacts keep loading, and the changed producer identity versions new trees separately from old ones, as designed.prompt_versionbumps topaper-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.shpasses (ruff format/check, basedpyright, lint-imports, pytest: 494 passed, coverage 86%).draft_so_farthreading, full text across the seam, worst-quality aggregation), and the single-call path for small documents.python scripts/verify_structure_e2e.pywas not run locally (no provider credentials for the configured models); the path-filteredstructurejob ine2e.ymlcovers this change's paths.Checklist
type(scope): summary.bash scripts/verify.shpasses.