Skip to main content

Module ctx_knowledge

Module ctx_knowledge 

Source

Structs§

KnowledgeConsolidationReport
RestoreOptions
Parsed restore request.

Constants§

DEFAULT_RESTORE_LIMIT
Default cap on how many items a single restore call rehydrates, across all requested stores. Generous enough to undo a normal reclaim, bounded so a restore with no query cannot resurrect an unbounded archive in one shot.

Functions§

capture_remembered
Record the capture fields (Hive capture gate: type, steps, commands, refs, evidence) a remember named on the fact it stored. Shapes are checked here; whether the fact may leave is the gate’s decision at capture time.
consolidate_all_project_knowledge_with
consolidate --all: consolidate every stored project, with explicit options (e.g. ConsolidateOptions::into_dry_run for a preview).
consolidate_project_knowledge
Explicit CLI / MCP consolidate: import the whole session, run the fact lifecycle and losslessly reclaim every store. Thin wrapper over the canonical consolidate_project_knowledge_with.
consolidate_project_knowledge_with
Canonical consolidation engine (#995 Phase 4). Every driver — CLI/MCP, the scheduled post-dispatch pass (crate::core::consolidation_engine::consolidate_latest), and startup auto-consolidate — funnels through here, parameterised by ConsolidateOptions, so session import, fact keys, lifecycle and the lossless per-store capacity reclaim behave identically. Session loads are project-scoped (cwd bug #2362), and opts.dry_run previews without mutating knowledge, archives or the session.
format_all_consolidation_reports
format_consolidation_report
format_restore_report
Deterministic, human-readable restore summary (no timestamps — #498).
handle
Dispatches knowledge base actions (remember, recall, pattern, timeline, etc.).
handle_export_okf
Exports the project’s current knowledge as an Open Knowledge Format (OKF) bundle — a directory of Markdown files, portable and vendor-neutral. Renders from the shared lean_ctx::core::knowledge::KnowledgeSnapshot, so it never disagrees with a ctxpkg export on what the knowledge is. out is the target directory (defaults to the data dir’s exports/okf/<hash>).
handle_import
Imports knowledge from path. A directory is treated as an OKF bundle; a file falls back to the native JSON / simple-array / JSONL import.
handle_outcome
handle with a typed outcome: Ok is the reply, Err is the text of a failed call — the same text handle answers, after the same gates.
load_policy_or_error
The effective memory policy (config + active profile overrides), validated; Err is the user-facing error text naming the config file to fix.
run_restore
Restore archived items into the live stores. Facts/history/patterns share one locked knowledge write. Archives of the retired procedure store stay on disk untouched and are never restored.