Skip to main content

lean_ctx/core/context_store/
mod.rs

1// SPDX-License-Identifier: Apache-2.0
2//! The Context Store: one access contract over the stores that already hold
3//! LeanCTX state. It is a logical layer, not another database.
4//!
5//! | State | Authoritative store |
6//! |---|---|
7//! | decisions, plans, invocations, outcomes | execution ledger (`core::execution_ledger`) |
8//! | what reached the model, under which policy | Decision Receipts (`core::context_admission::receipt_store`) |
9//! | learned planner state | `context_kernel::autopilot::learning_store` |
10//! | knowledge | `core::knowledge` (`KnowledgeStore`) |
11//! | relations | `core::property_graph` |
12//! | per-task runtime signals (bounce, expand, edit failure) | `task_signals` |
13//!
14//! Search, graph and vector indexes are derived from these and rebuildable.
15//! Modules here read and join; they never become a second copy of that state.
16//! `lean-ctx engine context-lineage` and `context-policy-evidence` expose the
17//! joins read-only (docs/contracts/engine-context-store-v1.md).
18
19use lean_ctx_protocol::{ProjectId, TenantId};
20
21pub mod lineage;
22pub mod task_signals;
23
24/// The tenant/project scope a task belongs to, as one opaque key. Task-keyed
25/// state (receipt indexes, learning) is always looked up under this scope, so
26/// equal task ids in different projects never meet.
27pub fn task_scope(tenant: Option<&TenantId>, project: &ProjectId) -> String {
28    serde_json::to_string(&(tenant, project)).expect("identifiers serialize")
29}