Skip to content

Add document chunking with citation metadata - #40

Merged
xquantize merged 2 commits into
developfrom
agent/stage-3-chunk-document
Oct 28, 2026
Merged

xquantize merged 2 commits into
developfrom
agent/stage-3-chunk-document

Conversation

@xquantize

Copy link
Copy Markdown
Owner

XQU-15: Slice 2 chunks a cleaned document into overlapping word-budget spans that carry citation metadata.

Acceptance criteria:

  • tests/test_chunk.py (synthetic documents only) covers: short section is one chunk; no chunk exceeds max_words except the documented exceptions; overlap between neighbouring chunks in a section is overlap_words words except where shortened by the cap rule; no chunk crosses a section boundary and section matches the heading; a short tail is merged; ids <document_id>#<index> run 0..n-1 across sections; metadata matches the RawDocument; identical output and hashes on repeat calls; overlap_words >= max_words raises ValueError; a document with no sections returns []
  • config.py adds only chunk_words=300 and chunk_overlap_words=50
  • No test does I/O, network or LLM calls; no text copied from data/raw/
  • docs/plans/stage-3.md has only the Slice 2 box ticked
  • bash scripts/check.sh prints CHECK PASSED
  • Only these files changed vs develop: src/swellsense/processing/models.py, src/swellsense/processing/chunk.py, src/swellsense/config.py, tests/test_chunk.py, docs/plans/stage-3.md

Round-2 fixes verified:

  • max_words wins over overlap (repro [10, 10] / max 10 / overlap 3; prefix shortened in (max-overlap, max])
  • Real split-then-merge tail test ([10, 9, 3] / max 20 / overlap 5)
  • _merge_short_tail uses recorded prefix lengths

Review: all checks passed. check.sh: CHECK PASSED locally.

Made with Cursor

xquantize and others added 2 commits October 28, 2026 15:47
Overlapping word-budget chunks preserve section boundaries and carry
RawDocument fields needed for retrieval citations in slice 4.

Co-authored-by: Cursor <cursoragent@cursor.com>
Record overlap prefix lengths for tail merge instead of re-detecting by word match; add reviewer repro and real tail-merge tests.

Co-authored-by: Cursor <cursoragent@cursor.com>
@xquantize
xquantize merged commit 3b9a019 into develop Oct 28, 2026
1 check passed
@xquantize
xquantize deleted the agent/stage-3-chunk-document branch October 28, 2026 02:57
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