Expand description
Decision layer (D1): versioned project decisions in .leanctx/decisions/*.toml.
A decision record names what was decided, by whom, where it applies (repos,
path globs, symbols) and, optionally, machine-checkable [[check]]s. This
module loads and validates the records (strictly: an unknown key, a bad
glob or a bad regex is an error naming the file), answers scope queries and
renders the deterministic context suffix for reads (#498: no timestamps,
no counters, stable header, sorted by id). check evaluates the checks
against a change; crate::core::pre_edit runs them before an edit.
LeanCTX only detects, reports and hints. Refusing an edit is opt-in
([decisions] enforce = "refuse"); enforcing a land belongs to Weave.
Re-exports§
pub use check::OtherFiles;pub use check::Violation;pub use check::evaluate_change;pub use check::evaluate_change_with;
Modules§
- check
- Evaluate decision
[[check]]s against one file change.
Structs§
- Check
- A validated
[[check]].pathsempty means “the decision’s scope”. - Decision
- A validated decision record.
- Decision
Set - Every record of one project, sorted by id, plus the files that failed.
Enums§
Constants§
- DECISIONS_
DIR - Directory, relative to the project root, that holds one record per file.
- SUFFIX_
HEADER - Header of the read/compose suffix. Stable: prompt caches key on it.
Functions§
- describe
- Full, multi-line description of one decision (CLI
show,ctx_knowledge). - find_
root - The nearest ancestor of
path(itself included when a directory) that holds a.leanctx/decisionsdirectory, stopping at the first git root. - from_
records - A set from record texts (
(root-relative file, text or read error)), e.g. read from a base commit.repo_rootanswersscope.repos. The set knows no working tree, sorequire_regexneeds an explicitcheck::OtherFiles(evaluate_change_with). - id_
from_ slug dec-<slug>from free text: lower-case ASCII words joined by-.- load
- Load (cached by file list, sizes and mtimes) the records under
root. A project without.leanctx/decisionsyields an empty set. - parse_
decision - Parse and validate one record.
file_stemmust equal the record’sid;rel_fileis kept for reporting. Errors name the offending key. - query_
text - The decision query of
ctx_knowledge action=decisionsandlean-ctx decisions list: bypath(decisions whose scope covers it), else bysymbol, else all records; invalid records are listed after them. - relative_
path pathrelative torootwith forward slashes;Noneoutsideroot.- render_
lines - One line per decision:
id: title — statement. - scaffold
- A fresh record for
lean-ctx decisions newthat parses as written. - suffix_
for_ compose - The suffix for a
ctx_composeanswer: decisions covering the files it names (path:line …andFile: pathlines that exist underroot). - suffix_
for_ file - The suffix for a read of
file(absolute or root-relative). Empty when the file is outside every project with decisions. - suffix_
for_ paths - Deterministic suffix for a read of
rel_paths(deduplicated, sorted): empty when no active decision covers any of them. - suffix_
for_ read - The read suffix for a tool reply (
ctx_read,ctx_compose): empty while a gateway policy is active, since decision records are repository text that the policy did not admit as a source of this reply. - suffix_
for_ root_ paths - The suffix for paths a compose answer named, relative to
root.