Expand description
Rule and flow body parsing: a real AST over body text.
Bodies were historically re-scanned line-by-line at lowering time, which
made whitespace load-bearing and let unknown statement forms slip through
silently. This module is the statement-form gate: every body must parse
into BodyAst, unknown tokens are spanned errors, and lowering consumes
structure instead of strings.
Structs§
- Access
Grant - Access grant metadata (
with access to <resource> { <grant clauses> }) on an effect. Ontell, it narrows the turn’s effective authority per Proposal A (spec/agent-harness.md). Oninvoke, it is the explicit start-grant surface for narrowing the child workflow’s authority. - Access
Grant Op - One operation clause inside a turn-access grant block — an operation name with its
optional
for <target>reference and/or["glob", …]path patterns (e.g.recall for issue,read ["docs/**"]). - After
Block - BodyAst
- Case
Block - Case
Branch - Construct
UseField - Effect
Stmt - Exec
Parse - The
->ingestion contract on anexec: stdout must parse asschema(one object) or, witheach, as a JSONL/array stream ofschema. - Field
Assign - Prompt
- Record
Stmt - Region
Block - DR-0043 Decision 5: a
during <cond> { … } on lapse [as x] { … }region (until <cond>is the negated polarity). The region’s steps commit only while the condition holds — checked atomically inside each advancing commit — and the first advancing commit under a broken condition commits the lapse arm instead, exactly once. Statements after the region are the point of no return. - Split
Field Assignment - A field assignment extracted from a record/payload body without braces.
valueisNonefor shorthand-copy fields; otherwise it is the exact source text of the value expression. - Terminal
Stmt
Enums§
Functions§
- blank_
full_ line_ comments - Blanks full-line
#comments in rule-body TEXT, byte-preservingly: every byte of a comment line except its newline becomes a space, so all spans and offsets downstream still point at the original source. Raw-string (""") interiors are untouched – a markdown heading inside a prompt is content, not a comment. The compile path runs this once per rule body before action/thenexpansion, so the kernel and every line-based analysis see comment-free text, whilewhip fmt(which re-emits the raw body text) preserves the comments. - is_
iso8601_ instant - Structural ISO-8601 instant check (
YYYY-MM-DDTHH:MM:SS[.fff](Z|±HH:MM)) fortimeliterals, with calendar-field range validation. Kept dependency-free: the runtime compares instants via SQLitestrftime. - parse_
first_ statement - Parses exactly ONE statement from the front of
source(used bythenexpansion to consume the chained effect statement without parsing — and spuriously diagnosing — the remainder of the enclosing block). Returns the statement and only the diagnostics that single parse produced. - parse_
rule_ body - parse_
short_ duration_ seconds - Parses short durations:
<integer><unit>with units,m,h, ord. - split_
field_ assignments - Token-level field splitting for record/terminal/table-row bodies. The
structure comes from tokens, never from line breaks, so single-line and
multi-line blocks behave identically. Shorthand (bare name,
fromblocks only at the call site) is line-delimited: a name with no same-line value is shorthand.