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
// SPDX-License-Identifier: Apache-2.0
//! Value surface: makes what lean-ctx did visible outside the dashboard —
//! subtly, outside the model's context, and with every number provable.
//!
//! * [`snapshot`] — a tiny per-session file the MCP server keeps current, so
//! status lines and prompt segments render in microseconds without touching
//! the ledger.
//! * [`mod@format`] — the shared renderers (one dim line; the branded status line).
//! * [`host`] — which agent process a session serves, so concurrent agents in
//! one project each see their own numbers.
//! * [`proof`] — recomputes each number from the hash-chained savings ledger
//! and audit trail and verifies both chains (`lean-ctx value`).
//! * [`recap`] — when a host hook speaks up (turn and session recaps, weekly
//! digest), always as a user-only message, never into the model's context.
//! * [`milestones`] — a native desktop notification ([`notify`]) when a
//! verified lifetime threshold is first crossed; at most one a day.
use RwLock;
static CURRENT_SESSION: = new;
/// Marks `id` as the session this process is serving. Ledger events and
/// security events recorded afterwards commit it into their hashes.
/// The session this process is serving, if it is an MCP server that has
/// handled a tool call. `None` for CLI, hook and proxy processes.
/// Whether any value display is on (`[value_display] mode`, overridable via
/// `LEAN_CTX_VALUE_DISPLAY`). The proof chains are written regardless; this
/// only gates the display snapshot and the user-facing channels.