UNPKG

kestrel.markets

Version:

A typed, token-efficient language + runtime for agentic trading: agents author bounded plans, the runtime fires them at the tick. CLI + typed library + MCP server.

51 lines 4.06 kB
/** * # session/armed-plan-terms — capture the ARMED plans' enforced terms for the watcher (kestrel-wa0j.29) * * The watcher is asked to judge a plan's PREMISE ("the plan armed on a thesis — is it still true?") yet * it NEVER sees the armed document's text: the WHEN/DO/TP/EXIT/INVALIDATE clauses live in the supersede * action on the bus and are never rendered into any frame — the kernel carries only the plan's lifecycle * NAME + STATE (frame/types.ts PlanStateEntry). This module closes that gap by capturing, from the armed * document ASTs the driver ALREADY holds, the TYPED terms the `armed-plan` pane renders. * * ## Attribution honesty (ADR-0041 §1: a pane invents no value) * Every term is a TYPED value from the plan AST printed through the SAME canonical printer the * round-trip is defined by ({@link ../lang/print.ts planClause}/{@link ../lang/print.ts printTrigger}/ * {@link ../lang/print.ts budgetStr}) — a typed value → its byte-stable text, NEVER a hand-rolled * restatement, never the rendered pane bytes. The data enters the frame THROUGH the frame input, exactly * as the `delta`/`prior-session` panes' data does. * * ## Which plans (absent-not-hidden, ADR-0041 §3) * ONLY plans in an ENFORCED lifecycle state — `armed` / `fired` / `managing` — carry terms the watcher * is actively enforcing; an `authored` (not yet armed) or `done` plan is excluded. An empty enforced set * is threaded as ABSENT ({@link armedPlanTermsOf} returns `undefined`), never an empty list — so the pane * fails closed to exactly one absent-with-reason line, byte-identical to a frame without the field. * * Pure: no clock, no RNG. A same-name replacement's LATEST armed AST wins (the driver's arm order). */ import type { ArmedPlanTerms, ArmedPlanTermsEntry } from "../frame/types.ts"; import type { PlanStatement } from "../lang/index.ts"; /** The plan lifecycle states in which the watcher is ENFORCING the plan's terms (kestrel-wa0j.29) — the * plan has committed (or is committing) capital and the WHEN/TP/EXIT/INVALIDATE are live. An `authored` * plan (awaiting its arm gate) and a `done` plan (terminal) carry no terms the watcher enforces NOW. */ export declare const ENFORCED_PLAN_STATES: ReadonlySet<string>; /** Capture ONE armed plan's enforced terms as a typed {@link ArmedPlanTermsEntry}: the arming premise * (top-level `WHEN`), the entry/exit/invalidation clause runs, and the size envelope (`budget`) — each * printed through the canonical printer, each optional-honest (an absent field is a clause the plan does * not have, NEVER a fabricated one). Per-leg expiries are date-blinded against `sessionDate` FIRST * ({@link dateBlindClause}, kestrel-wa0j.74) so an absolute `exp 2026-08-21` renders as a relative * `<n>dte` and no iso-date crosses the agent boundary. Pure. */ export declare function armedPlanEntryOf(p: PlanStatement, sessionDate: string): ArmedPlanTermsEntry; /** * Capture the ARMED plans' enforced terms from the armed document ASTs, filtered to the plans whose * CURRENT lifecycle state (per the frame's kernel PlanStateEntry set) is enforced — or `undefined` when * NONE is enforced (absent-not-hidden: the pane then fails closed to absent-with-reason, and a frame * without the field is byte-identical). Preserves the driver's arm order; a same-name replacement's * LATEST AST wins (the last-armed document is the one whose terms are live). Pure. * * @param asts every armed plan statement the driver holds, in arm order. * @param enforcedNames the plan NAMES currently in an enforced lifecycle state (from the kernel plan set). * @param sessionDate the tape's `session_date` — the reference an absolute per-leg `exp` is blinded to * a relative `<n>dte` against (kestrel-wa0j.74), so no iso-date reaches the frame. */ export declare function armedPlanTermsOf(asts: readonly PlanStatement[], enforcedNames: ReadonlySet<string>, sessionDate: string): ArmedPlanTerms | undefined; //# sourceMappingURL=armed-plan-terms.d.ts.map