Skip to main content
T4 epic · research / any corpus one window cannot hold: context folding. A fast pass plans a focus per file from the paths alone, each document is carded in its own fresh window, jq assembles and ranks the deck, a thinking pass answers from the cards. No model window ever holds two documents.

The job

« What do these forty documents actually establish? » is either one giant prompt that rots halfway through, or it is this pipeline: the corpus stays in the dataflow, each model call sees one slice, and the synthesis reads a deck of typed cards it can actually hold.

The shape

The file

corpus-digest.nika.yaml

How it works

1

The window never scales with the corpus

Ten documents cost ten small windows plus one deck-sized synthesis, not one window ten documents deep. The fold is the point: adding a file adds an iteration, it never grows a prompt.
2

The model plans the focus, the filesystem stays the authority

The planner sees paths, never contents, and its assignments join the glob list by path in jq. A hallucinated path joins nothing and drives nothing; a skipped file falls back to the question itself.
3

A card cannot be misfiled

The card schema has no path field on purpose: the model summarizes, transpose re-attaches identity deterministically. The deck the synthesis reads is everything it was allowed to see, and the typed outputs: expose that deck for inspection.

Constructs you just used

Make it yours

  • Point const.corpus_root and the matching permits.fs.read entry at your real folder · the two move together (NIKA-AUTH-007).
  • Chunk instead of file-split: for documents that are each too big for a window, add a jq task that slices texts into sections and fan out over the sections · the fold works at any grain.
  • Feed the deck onward: the typed outputs: make this callable, so a parent workflow can consume {brief, deck} as a contract · pair it with Deep research brief to digest what the agent fetched.

Next · Deep research brief

The same plan-then-execute skeleton with an agent middle: when the work needs judgment calls between fetches, the loop earns its place.