Skip to content

feat(core): L1 formula context — pure λδ with self (the fx-field enabler)#48

Merged
hyperpolymath merged 2 commits into
mainfrom
claude/project-scope-planning-5zoaze
Jul 17, 2026
Merged

feat(core): L1 formula context — pure λδ with self (the fx-field enabler)#48
hyperpolymath merged 2 commits into
mainfrom
claude/project-scope-planning-5zoaze

Conversation

@hyperpolymath

Copy link
Copy Markdown
Owner

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 test82 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.ai/code/session_01PAEqVP7Y3bZDhtAaPUTbps


Generated by Claude Code

…abler

The first step of surfacing λδ in the product: 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** — no
mutators — so a formula can never change the notebook. This is the load-bearing
core piece the UI "fx" field will sit on.

- Split the notebook host's `register` into `register_readers` /
  `register_mutators`, so a context can grant exactly the surface spec §5 allows
  (formula/agent-predicate = readers only; action = readers + mutators).
- `WasmNotebook::evalFormula(note_id, src)` — the browser entrypoint; read-only,
  returns the printed result (the notebook is reclaimed unchanged).

Proven end-to-end by a test: `(count (words (content self)))` → the word count;
`(:title self)` → the title; and `(set-title! (:id self) …)` fails with
Unbound (mutators absent), with the notebook verified unchanged.

Verification: `cargo test` 82 lib tests green (+1 formula); clippy `-D warnings`
clean (default + wasm); fmt clean; `cargo check --features wasm` clean;
production code panic-free.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PAEqVP7Y3bZDhtAaPUTbps
@github-actions

Copy link
Copy Markdown

🔍 Hypatia Security Scan

Findings: 68 issues detected

Severity Count
🔴 Critical 1
🟠 High 37
🟡 Medium 30

⚠️ Action Required: Critical security issues found!

View findings
[
  {
    "reason": "Issue in scorecard.yml",
    "type": "missing_workflow",
    "file": "scorecard.yml",
    "action": "create",
    "rule_module": "workflow_audit",
    "severity": "high"
  },
  {
    "reason": "Issue in boj-build.yml",
    "type": "missing_timeout_minutes",
    "file": "boj-build.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in casket-pages.yml",
    "type": "missing_timeout_minutes",
    "file": "casket-pages.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in casket-pages.yml",
    "type": "missing_timeout_minutes",
    "file": "casket-pages.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in codeql.yml",
    "type": "missing_timeout_minutes",
    "file": "codeql.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in dogfood-gate.yml",
    "type": "missing_timeout_minutes",
    "file": "dogfood-gate.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in dogfood-gate.yml",
    "type": "missing_timeout_minutes",
    "file": "dogfood-gate.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in dogfood-gate.yml",
    "type": "missing_timeout_minutes",
    "file": "dogfood-gate.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in dogfood-gate.yml",
    "type": "missing_timeout_minutes",
    "file": "dogfood-gate.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in dogfood-gate.yml",
    "type": "missing_timeout_minutes",
    "file": "dogfood-gate.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  }
]

Powered by Hypatia Neurosymbolic CI/CD Intelligence

@hyperpolymath
hyperpolymath marked this pull request as ready for review July 17, 2026 05:03
@hyperpolymath
hyperpolymath merged commit 51f9035 into main Jul 17, 2026
22 checks passed
@hyperpolymath
hyperpolymath deleted the claude/project-scope-planning-5zoaze branch July 17, 2026 05:03
@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

🔍 Hypatia Security Scan

Findings: 68 issues detected

Severity Count
🔴 Critical 1
🟠 High 37
🟡 Medium 30

⚠️ Action Required: Critical security issues found!

View findings
[
  {
    "reason": "Issue in scorecard.yml",
    "type": "missing_workflow",
    "file": "scorecard.yml",
    "action": "create",
    "rule_module": "workflow_audit",
    "severity": "high"
  },
  {
    "reason": "Issue in boj-build.yml",
    "type": "missing_timeout_minutes",
    "file": "boj-build.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in casket-pages.yml",
    "type": "missing_timeout_minutes",
    "file": "casket-pages.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in casket-pages.yml",
    "type": "missing_timeout_minutes",
    "file": "casket-pages.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in codeql.yml",
    "type": "missing_timeout_minutes",
    "file": "codeql.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in dogfood-gate.yml",
    "type": "missing_timeout_minutes",
    "file": "dogfood-gate.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in dogfood-gate.yml",
    "type": "missing_timeout_minutes",
    "file": "dogfood-gate.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in dogfood-gate.yml",
    "type": "missing_timeout_minutes",
    "file": "dogfood-gate.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in dogfood-gate.yml",
    "type": "missing_timeout_minutes",
    "file": "dogfood-gate.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in dogfood-gate.yml",
    "type": "missing_timeout_minutes",
    "file": "dogfood-gate.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  }
]

Powered by Hypatia Neurosymbolic CI/CD Intelligence

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants