Skip to main content

Module cal

Module cal 

Source
Expand description

A tiny CAL writer. The engine never parses CAL (that is the substrate’s job — validate_cal/execute_cal); it only emits the handful of statements built-in analyzers propose. Statements are newline-separated to form a batch. Keeping this a writer, not a parser, is what lets the engine claim zero CAL-grammar ownership (proposal §10).

Functions§

add
ADD <type> {json} — a Tier-1 non-destructive evolve write.
batch
Join statements into a batch.
contains_destructive
True if any statement is destructive: FORGET (single-grain or SUBJECT) or PURGE. Recommendation::destructive is stamped from this and the apply gate (admin scope + allow_destructive) keys off that stamp, so this list must cover every destructive statement a proposal could carry — LLM-enriched and --analyzer-cmd proposals are arbitrary CAL text, not just what this writer emits.
contains_forget
Cheap engine-side destructive check (defense in depth; the substrate’s validate_cal is authoritative). True if any statement is a FORGET.
forget
FORGET <hash> — the only destructive statement the writer emits, single-grain (§6.4).
parse_own_supersede
Round-trip a line this module’s own supersede emitted back into (target_hash, grain_type, fields). This is a strict inverse of the writer’s own output — not a CAL parser (any other shape returns None; the substrate’s grammar stays authoritative). The auto-apply gate uses it to value-verify a replacement against the grain it supersedes.
supersede
SUPERSEDE <hash> WITH <type> {json} — replace a head non-destructively.