Implement Chunker trait emitting chunker_version = "md-heading-v1". Block-aware: respect heading boundaries, never split code/table, propagate heading_path and merged source_spans.
Why now / why this size
The first concrete Chunker. Establishes how subsequent chunkers (PDF page chunker, audio segment chunker) are scoped: per-medium chunker version label. Independent of any store/embed.
Allowed dependencies
kebab-core
kebab-config
serde
blake3 (policy_hash)
serde-json-canonicalizer
thiserror
Forbidden dependencies
kebab-source-fs, kebab-parse-md, kebab-normalize (consumes CanonicalDocument only via kebab-core), kebab-store-*, kebab-embed*, kebab-search, kebab-llm*, kebab-rag, kebab-tui, kebab-desktop
policy_hash = blake3(canonical_json(policy)) hex truncated to 16 chars.
Behavior contract
Priority order (per design §0 / report §14):
heading boundary first
never split a code block
table stays in a single chunk if possible
long sections split by paragraph
propagate heading_path from blocks
carry merged source_spans (each chunk lists every contributing block's span)
record chunker_version = "md-heading-v1" and policy_hash
target_tokens and overlap_tokens from ChunkPolicy. Token estimate is byte-based proxy until a real tokenizer is introduced (note in Chunk.token_estimate).
chunk_id per design §4.2: tagged tuple of (doc_id, chunker_version, block_ids, policy_hash).
block_ids listed in document order (significant — affects ID).
ImageRef / AudioRef blocks are emitted as their own chunks (text portion = alt + caption preview if present, else empty string with token_estimate=0). They still receive chunk_id so future image/audio search can locate them.
Storage / wire effects
None directly. Outputs feed p1-6.
Test plan
kind
description
fixture / data
unit
heading boundary respected (no chunk crosses H2 → H2)
inline
unit
code block of 800 tokens stays in one chunk even when target=500
inline
unit
table block stays single chunk if size < 2× target
inline
unit
long paragraph split with overlap_tokens applied
inline
unit
ImageRefBlock produces a chunk with token_estimate=0
Token estimate proxy: a real tokenizer (e.g., sentencepiece for the embedding model) replaces this in P3. The proxy must err toward overestimation so chunks fit in real tokenizer budget.
Changing chunker_version invalidates all downstream embedding records. Bump only with PR documenting the migration plan (design §9).