Expand description
Shared tool lifecycle — ensures CLI and MCP paths have identical side effects.
The MCP server dispatcher handles session, ledger, heatmap, intent detection, and knowledge consolidation inline (via in-memory state). When the daemon is unavailable, CLI commands call functions here to achieve the same coverage by loading/saving state from disk.
NOTE: When the daemon IS running, CLI routes through daemon_client which
calls the MCP server — these functions are NOT called in that path.
Functions§
- flush_
all - Flush every buffered telemetry sink to disk.
- flush_
all_ at_ exit flush_allfor a process that is about to exit: first commits the provisional bounces still waiting for their edit window, so a bounce detected just before shutdown reaches the ledger and the path memory thatflush_allthen persists. Not part offlush_allitself, which also runs after single tool executions where committing early would book a read-before-edit as a bounce.- ir_
excerpt - First 200 chars of
texton a UTF-8 boundary — the exact excerpt bound the MCP dispatcher applies before handing content to the IR store (server/call_tool.rs), kept identical so CLI- and MCP-recorded IR items are byte-compatible.ContextIrV1::recordredacts and further caps it. - record_
file_ read - Record a file-read operation with full Context OS side effects.
- record_
file_ read_ accounting - Compatibility accounting without IR persistence or an independent flush. The CLI lifecycle calls this once in its accounting stage.
- record_
file_ read_ projection - record_
search_ accounting - Existing search bookkeeping, separated from the IR writer for stage ownership.
- record_
tree - Record a tree/ls operation with full Context OS side effects.