knowledge-vault/skills/context-management-policy.md

151 lines
4.6 KiB
Markdown

# Knowledge Vault Context Management Policy
## 1. Purpose
Long discussion files can exceed a single model context and degrade judgment quality. Knowledge Vault workflows must process long sources through file-based ranges, worker threads, and continuation handoffs.
## 2. Main Rule
The main session must not load or reason over an entire long source document when the task can be split by source range.
The main session is responsible for:
```text
- source registration
- output directory creation
- invocation packet creation
- worker dispatch
- returned-output collection
- cross-range consistency checks
- user confirmation gates
```
For long sources that fit a high-context participant, Knowledge Vault should first run a real whole-source gestalt sub-session before range splitting. This does not relax the main-session rule: the main session prepares the invocation, records the returned output, and uses the user-confirmed gestalt as orientation.
The whole-source gestalt sub-session is responsible for:
```text
- reading the full source when it fits the agreed high-context limit
- judging whether the source is coherent, mixed, or fragmented
- producing the global topic portrait, main structure, core tensions, and model-evolution line
- flagging parent/child/tool/case/action-layer distinctions that range workers may flatten
- giving segmentation guidance for downstream workers
```
Step 0 is an alignment loop. Its output must pass human inspection before downstream worker automation treats it as a structure lens.
Mode selection:
```text
coherent -> workers receive the confirmed global portrait as a required structure lens
mixed -> split into macro-topics before worker extraction
fragmented -> workers remain minimally biased and discover flat topics locally
```
Worker sessions are responsible for:
```text
- one H1 round
- one source block batch
- one bounded participant task
- one topic document material extraction group
- one explicit output contract
```
## 3. Default Split Strategy
Use this sequence:
```text
0. Run or record an exception to the whole-source gestalt pass.
1. Split by Markdown H1 round.
2. If a round is too large, split by H2 section.
3. If a section is still too large, split by source block batch.
4. Assign stable range ids such as R01, R04-S02, or R04-B001-B030.
```
## 4. Thread Strategy
Use worker threads when a processing pass needs to read large source ranges or preserve participant focus.
Each worker thread should receive a thread-start packet and return a thread-return packet.
Worker thread-start packets should include the confirmed whole-source gestalt summary in coherent mode. Workers may challenge that global portrait, but must label the challenge and cite local evidence. In fragmented mode, worker packets should not force a hierarchy lens.
Run-specific packet paths:
```text
handoff/thread-start-packets/
handoff/thread-return-packets/
```
Worker outputs must be written to files before the main session synthesizes them.
For topic-doc generation and material extraction, the main session should prefer worker/sub-session execution when any of these are true:
```text
- the worker must read many source blocks directly
- reusable material units are being extracted from source text
- quote-level evidence is required
- multiple topic documents can be processed independently
```
The main session may still write orchestration files, integrate worker returns, update indexes, perform bounded checks, and record human confirmations.
## 5. Continuation Handoff
Create a continuation handoff when any condition is met:
```text
- a major pass is complete
- several large source ranges have been read
- a participant boundary changes
- the run is blocked waiting for external output
- a user confirmation gate is reached
- context pressure may affect judgment quality
- the next session must continue without relying on chat history
```
Recommended path:
```text
handoff/continuation/{date}-{stage}.md
```
## 6. What The Main Session May Read
The main session may read:
```text
- source-map
- topic-map
- routing-log indexes
- worker return summaries
- audit summaries
- unresolved issue lists
- bounded excerpts needed to verify a claim
```
The main session should avoid repeatedly loading:
```text
- full original source
- all worker outputs at once
- all topic documents at once
- all external returned outputs at once
```
## 7. Quality Gate
Before starting a large pass, the run must define:
```text
- input range
- output path
- expected record file
- acceptance check
- continuation point
```
If these are missing, pause and create the missing run-control files first.