Commit 51f9035
feat(core): L1 formula context — pure λδ with
## What this is
The first step of **surfacing λδ in the product** (the "make it visible"
work). This PR lands the load-bearing **core** piece — the UI "fx" field
will sit directly on it — while staying small, pure, and
headless-testable.
A **formula** evaluation context (spec §5): `eval_formula(nb, self_id,
src)` runs a λδ expression with **`self`** bound to a note's snapshot
map and **only the reader builtins in scope**. Mutators are deliberately
absent, so a formula *cannot* change the notebook — formulas are pure by
construction.
## Changes
- Split the notebook host's `register` into **`register_readers`** /
**`register_mutators`**, so each context grants exactly the surface spec
§5 allows:
- formula / agent-predicate → readers only;
- action (on-create / agent-action / stamp) → readers + mutators.
- **`eval_formula`** — binds `self`, installs readers, evaluates,
returns the value.
- **`WasmNotebook::evalFormula(note_id, src)`** — the browser
entrypoint; read-only, returns the printed result (notebook reclaimed
unchanged).
## Proven end-to-end
A host test exercises the whole stack:
- `(count (words (content self)))` → the note's word count;
- `(:title self)` → the title (note map is `self`, keyword access
works);
- `(set-title! (:id self) "X")` → **Unbound** (mutators absent), and the
notebook is verified **unchanged**.
## What this deliberately does NOT include
No UI and no formula **persistence** yet — where a note's formulas live
is a data-model decision that touches the sensitive `Note` schema, so it
deserves its own PR (and a heads-up before I touch it). This PR is
purely the safe, reusable capability.
## Verification
`cargo test` — **82 lib tests** green (+1 formula) + host + golden +
invariants + doc-tests. `cargo clippy --all-targets -- -D warnings`
clean (default + `--features wasm`). `cargo fmt --check` clean.
Production code panic-free.
> Estate governance `workflow_audit` findings are pre-existing estate
policy, out of scope; `rust-ci` is the gate.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01PAEqVP7Y3bZDhtAaPUTbps
---
_Generated by [Claude
Code](https://claude.ai/code/session_01PAEqVP7Y3bZDhtAaPUTbps)_
Co-authored-by: Claude <noreply@anthropic.com>self (the fx-field enabler) (#48)1 parent 94e5fa8 commit 51f9035
3 files changed
Lines changed: 106 additions & 27 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| |||
46 | 46 | | |
47 | 47 | | |
48 | 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 | | - | |
| 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 | + | |
75 | 101 | | |
76 | 102 | | |
77 | 103 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
175 | 175 | | |
176 | 176 | | |
177 | 177 | | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
225 | 225 | | |
226 | 226 | | |
227 | 227 | | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
228 | 248 | | |
229 | 249 | | |
230 | 250 | | |
| |||
0 commit comments