import type { TypeExpr } from "./types.js"; export type { TypeExpr } from "./types.js"; /** * The 5 canonical concrete effect categories. * A function definition's signature includes which concrete effects it may perform. */ export type ConcreteEffect = "pure" | "reads" | "writes" | "io" | "fails"; /** * Effect variable — a placeholder for an unknown set of effects. * Used in FunctionType to express effect polymorphism for higher-order functions. * Only valid in type annotations (fn_type), NOT in function/tool definitions. * Names must be single uppercase ASCII letters (e.g., "E", "F"). */ export interface EffectVariable { kind: "effect_var"; name: string; } /** * An effect is either a concrete effect literal or an effect variable. * Concrete effects appear in function/tool definitions. * Effect variables appear only in FunctionType (type annotations for callbacks). */ export type Effect = ConcreteEffect | EffectVariable; /** * Type guard: is this effect a concrete string literal? */ export declare function isConcreteEffect(e: Effect): e is ConcreteEffect; /** * Type guard: is this effect an effect variable? */ export declare function isEffectVariable(e: Effect): e is EffectVariable; export declare const VALID_EFFECTS: readonly ConcreteEffect[]; /** * Retry backoff strategy for tool calls. */ export type BackoffKind = "fixed" | "linear" | "exponential"; export declare const VALID_BACKOFF_KINDS: readonly BackoffKind[]; /** * Retry policy for tool calls — how often and how to back off. */ export interface RetryPolicy { maxRetries: number; backoff: BackoffKind; } /** * Approval scope controls how often approval must be re-obtained. */ export type ApprovalScope = "per_call" | "per_session" | "per_module"; export declare const VALID_APPROVAL_SCOPES: readonly ApprovalScope[]; /** * Approval gate on a function — requires explicit host approval before execution. * Propagates through call chains: if a callee requires approval, the caller must too. */ export interface ApprovalGate { required: boolean; scope: ApprovalScope; reason: string; } /** * Structured blame / provenance annotation. * Tracks which agent produced a module or function, when, and with what confidence. */ export interface BlameAnnotation { author: string; generatedAt: string; confidence: number; sourcePrompt?: string; } /** * A complete Edict program / module. */ export interface EdictModule { kind: "module"; id: string; name: string; schemaVersion?: string; imports: Import[]; definitions: Definition[]; budget?: ComplexityConstraints; blame?: BlameAnnotation; minConfidence?: number; capabilities?: string[]; } /** * A composable program fragment. * Agents can validate fragments independently and compose them into a module. */ export interface EdictFragment { kind: "fragment"; id: string; provides: string[]; requires: string[]; imports: Import[]; definitions: Definition[]; blame?: BlameAnnotation; } /** * Import names from another module. */ export interface Import { kind: "import"; id: string; module: string; names: string[]; types?: Record; } export type Definition = FunctionDef | TypeDef | RecordDef | EnumDef | ConstDef | ToolDef; /** * Function definition with effects, contracts, and body. */ export interface FunctionDef { kind: "fn"; id: string; name: string; params: Param[]; effects: ConcreteEffect[]; returnType?: TypeExpr; contracts: Contract[]; constraints?: ComplexityConstraints; intent?: IntentDeclaration; approval?: ApprovalGate; blame?: BlameAnnotation; body: Expression[]; } /** * Structured intent — what the function is trying to accomplish. * Agents use this for re-synthesis, blame tracking, and specification diffing. * Invariants reuse Expression and SemanticAssertion types for automated matching. */ export interface IntentDeclaration { goal: string; inputs: string[]; outputs: string[]; invariants: IntentInvariant[]; } /** * A structured invariant that can be automatically matched against contracts. * Reuses existing Expression and SemanticAssertionKind — zero new vocabulary. */ export type IntentInvariant = ExpressionInvariant | SemanticInvariant; export interface ExpressionInvariant { kind: "expression"; expression: Expression; } export interface SemanticInvariant { kind: "semantic"; assertion: SemanticAssertionKind; target: string; args?: string[]; } /** * Type alias definition. */ export interface TypeDef { kind: "type"; id: string; name: string; definition: TypeExpr; blame?: BlameAnnotation; } /** * Record (struct) definition. */ export interface RecordDef { kind: "record"; id: string; name: string; fields: RecordField[]; blame?: BlameAnnotation; } /** * A field in a record definition. */ export interface RecordField { kind: "field"; id: string; name: string; type: TypeExpr; defaultValue?: Expression; } /** * Enum (tagged union / sum type) definition. */ export interface EnumDef { kind: "enum"; id: string; name: string; variants: EnumVariant[]; blame?: BlameAnnotation; } /** * A variant of an enum. Fields are empty for unit variants (e.g., None). */ export interface EnumVariant { kind: "variant"; id: string; name: string; fields: RecordField[]; } /** * Constant definition. */ export interface ConstDef { kind: "const"; id: string; name: string; type: TypeExpr; value: Expression; blame?: BlameAnnotation; } /** * Tool definition — declares a named external tool with a typed interface. * The host provides the actual implementation at runtime. * Tool names are in scope like functions; tool_call expressions reference them by name. */ export interface ToolDef { kind: "tool"; id: string; name: string; uri: string; params: Param[]; returnType: TypeExpr; effects: ConcreteEffect[]; blame?: BlameAnnotation; } /** * Function parameter. */ export interface Param { kind: "param"; id: string; name: string; type?: TypeExpr; } /** * Pre/post contract on a function. * Must have exactly one of `condition` (manual expression) or `semantic` (pre-built assertion). * `semantic` is only valid on `post` contracts (v1). */ export interface Contract { kind: "pre" | "post"; id: string; condition?: Expression; semantic?: SemanticAssertion; } /** * A pre-built semantic assertion that translates to a proven-correct Z3 encoding. * Agents use these instead of manually writing Z3-verifiable expressions. */ export interface SemanticAssertion { assertion: SemanticAssertionKind; target: string; args?: string[]; } /** * The 7 built-in semantic assertion kinds. */ export type SemanticAssertionKind = "sorted" | "permutation_of" | "subset_of" | "sum_preserved" | "no_duplicates" | "length_preserved" | "bounded"; export declare const VALID_SEMANTIC_ASSERTIONS: readonly SemanticAssertionKind[]; /** * Bounds on token complexity and program size to prevent runaway agents. */ export interface ComplexityConstraints { kind: "constraints"; maxAstNodes?: number; maxCallDepth?: number; maxBranches?: number; } export type Expression = Literal | Identifier | BinaryOp | UnaryOp | Call | IfExpr | LetExpr | MatchExpr | ArrayExpr | TupleExpr | RecordExpr | EnumConstructor | FieldAccess | LambdaExpr | BlockExpr | StringInterp | ForallExpr | ExistsExpr | ToolCallExpr; export interface Literal { kind: "literal"; id: string; value: number | string | boolean; type?: TypeExpr; } export interface Identifier { kind: "ident"; id: string; name: string; } export type BinaryOperator = "+" | "-" | "*" | "/" | "%" | "==" | "!=" | "<" | ">" | "<=" | ">=" | "and" | "or" | "implies"; export declare const VALID_BINARY_OPS: readonly BinaryOperator[]; export interface BinaryOp { kind: "binop"; id: string; op: BinaryOperator; left: Expression; right: Expression; } export type UnaryOperator = "not" | "-"; export declare const VALID_UNARY_OPS: readonly UnaryOperator[]; export interface UnaryOp { kind: "unop"; id: string; op: UnaryOperator; operand: Expression; } export interface Call { kind: "call"; id: string; fn: Expression; args: Expression[]; } export interface IfExpr { kind: "if"; id: string; condition: Expression; then: Expression[]; else?: Expression[]; } export interface LetExpr { kind: "let"; id: string; name: string; type?: TypeExpr; value: Expression; } export interface MatchExpr { kind: "match"; id: string; target: Expression; arms: MatchArm[]; } export interface MatchArm { kind: "arm"; id: string; pattern: Pattern; body: Expression[]; } export type Pattern = LiteralPattern | WildcardPattern | BindingPattern | ConstructorPattern; export interface LiteralPattern { kind: "literal_pattern"; value: number | string | boolean; } export interface WildcardPattern { kind: "wildcard"; } export interface BindingPattern { kind: "binding"; name: string; } export interface ConstructorPattern { kind: "constructor"; name: string; fields: Pattern[]; } export interface ArrayExpr { kind: "array"; id: string; elements: Expression[]; } export interface TupleExpr { kind: "tuple_expr"; id: string; elements: Expression[]; } export interface RecordExpr { kind: "record_expr"; id: string; name: string; fields: FieldInit[]; } export interface EnumConstructor { kind: "enum_constructor"; id: string; enumName: string; variant: string; fields: FieldInit[]; } /** * Field initialization in record expressions and enum constructors. * Gives these inline objects a proper `kind` discriminator like every other AST node. */ export interface FieldInit { kind: "field_init"; name: string; value: Expression; } export interface FieldAccess { kind: "access"; id: string; target: Expression; field: string; } export interface LambdaExpr { kind: "lambda"; id: string; params: Param[]; body: Expression[]; } export interface BlockExpr { kind: "block"; id: string; body: Expression[]; } /** * String interpolation — desugars to string_concat chains at compile time. * All parts must evaluate to String. */ export interface StringInterp { kind: "string_interp"; id: string; parts: Expression[]; } /** * Universal quantifier — contract-only. * forall variable in [range.from, range.to): body * Translates to Z3 ForAll. Body must evaluate to Bool. */ export interface ForallExpr { kind: "forall"; id: string; variable: string; range: { from: Expression; to: Expression; }; body: Expression; } /** * Existential quantifier — contract-only. * exists variable in [range.from, range.to): body * Translates to Z3 Exists. Body must evaluate to Bool. */ export interface ExistsExpr { kind: "exists"; id: string; variable: string; range: { from: Expression; to: Expression; }; body: Expression; } /** * Tool call expression — invokes a declared tool by name. * Named args via FieldInit (same pattern as RecordExpr/EnumConstructor). * Always returns Result where T is the tool's returnType. */ export interface ToolCallExpr { kind: "tool_call"; id: string; tool: string; args: FieldInit[]; timeout?: number; retryPolicy?: RetryPolicy; fallback?: Expression; } export declare const VALID_DEFINITION_KINDS: readonly ["fn", "type", "record", "enum", "const", "tool"]; export declare const VALID_EXPRESSION_KINDS: readonly ["literal", "ident", "binop", "unop", "call", "if", "let", "match", "array", "tuple_expr", "record_expr", "enum_constructor", "access", "lambda", "block", "string_interp", "forall", "exists", "tool_call"]; export declare const VALID_TYPE_KINDS: readonly ["basic", "array", "option", "result", "unit_type", "refined", "fn_type", "named", "tuple", "confidence", "provenance", "capability", "fresh", "type_var"]; export declare const VALID_PATTERN_KINDS: readonly ["literal_pattern", "wildcard", "binding", "constructor"]; export declare const VALID_BASIC_TYPE_NAMES: readonly ["Int", "Int64", "Float", "String", "Bool"]; export declare const ALL_VALID_KINDS: readonly ["module", "fragment", "import", "fn", "type", "record", "enum", "const", "tool", "param", "field", "variant", "pre", "post", "arm", "field_init", "constraints", "effect_var", "literal", "ident", "binop", "unop", "call", "if", "let", "match", "array", "tuple_expr", "record_expr", "enum_constructor", "access", "lambda", "block", "string_interp", "forall", "exists", "tool_call", "basic", "array", "option", "result", "unit_type", "refined", "fn_type", "named", "tuple", "confidence", "provenance", "capability", "fresh", "type_var", "literal_pattern", "wildcard", "binding", "constructor"]; //# sourceMappingURL=nodes.d.ts.map