1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
//! Seventh agentic recipe — driving Formal AI to *promote an approved lesson into
//! its learning ledger* and record the approved learning record in our data
//! (issue #558).
//!
//! Issue #558 asks the system, after a self-healing lesson passes its tests and a
//! human accepts it, to promote the improvement *"to mainline history as an approved
//! learning record"*. [`crate::learning_ledger`] realises that terminal, human-gated
//! promotion step. This module makes it reachable *through the agentic interface*:
//! an external agent CLI (`Codex`, `OpenCode`, `Gemini`, `Agent CLI`) — or the
//! in-repo driver — asks Formal AI to record its approved learning ledger, and the
//! deterministic planner walks a write → verify → final recipe that emits the ledger
//! as Links Notation, exactly like the self-healing, self-AST, source-graph, and
//! diagram recipes emit their self-inspection documents.
//!
//! Promotion into the ledger already required *both* a green benchmark gate and an
//! explicit human approval ([`crate::learning_ledger::LearningLedger::promote`]), so
//! the emitted document is a record of an *already-approved* decision — nothing here
//! adopts anything new. The "recompile and reattach" guardrail (observable,
//! testable, reversible, human-approved) is preserved. Neural inference stays a
//! NON-GOAL — the document is a deterministic function of the canonical ledger.
use OnceLock;
use crate;
/// The workspace path the planner writes the generated ledger document to.
pub const LEDGER_PATH: &str = "learning-ledger.lino";
/// The canonical, human-approved learning ledger, computed once per process.
///
/// Building it promotes the canonical self-healing case, which parses a real module
/// through the CST/AST engine; the recipe touches it several times per run (planner
/// write step, verify step, final answer) and a server may serve it repeatedly, so
/// memoising keeps the loop responsive without changing its deterministic result.
/// A *differently worded* request for the learning-ledger recipe.
///
/// The router recognises the intent from the words, not a hardcoded string.
/// Deliberately avoids the self-healing keywords ("self-heal", "auto learning",
/// "repair case") so the two auto-learning recipes never collide: this recipe is
/// the *promotion* step that follows an already-reviewed repair case.
pub const LEDGER_TASK: &str =
"Promote the approved lesson into your learning ledger and record the approved \
learning record in Links Notation so a repeated failure is answered from the \
ledger next time.";
/// Keywords that mark a user turn as the learning-ledger promotion recipe.
///
/// Deliberately narrow and disjoint from the self-healing keywords (which own
/// "auto learning" / "auto-learning") so the promotion recipe never captures a
/// self-healing request or vice versa.
const LEDGER_KEYWORDS: = ;
/// Whether `prompt` asks the system to promote an approved lesson into / record its
/// learning ledger (issue #558's promotion step).
/// Render the learning-ledger document (Links Notation) for the canonical approved
/// ledger. Deterministic and ends with exactly one trailing newline.
///
/// The output is what the Agent CLI writes to [`LEDGER_PATH`] and what
/// `data/meta/learning-ledger.lino` is committed as, asserted byte-for-byte in the
/// issue-#558 tests.
/// The canonical approved ledger backing the recipe. Exposed so tests can assert the
/// promotion reached a recorded, human-approved lesson without rebuilding it.
/// The self-contained final answer: a natural-language summary plus the generated
/// ledger document inline.