{"version":3,"file":"execution.d.ts","sourceRoot":"","sources":["../../../src/core/reliability/execution.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAE,KAAK,sBAAsB,EAA0B,MAAM,uBAAuB,CAAC;AAC5F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,uBAAuB,EAAE,WAAW,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAExG,MAAM,WAAW,2BAA4B,SAAQ,sBAAsB;IAC1E,uEAAuE;IACvE,WAAW,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;CAC9D;AAED,MAAM,MAAM,qBAAqB,GAC9B;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,MAAM,EAAE,cAAc,CAAC;IAAC,QAAQ,EAAE,eAAe,CAAA;CAAE,GACvE;IAAE,IAAI,EAAE,qBAAqB,CAAC;IAAC,OAAO,EAAE,uBAAuB,CAAA;CAAE,GACjE;IAAE,IAAI,EAAE,iBAAiB,CAAC;IAAC,OAAO,EAAE,uBAAuB,CAAA;CAAE,GAC7D;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,MAAM,EAAE,OAAO,CAAC,WAAW,EAAE,cAAc,CAAC,CAAA;CAAE,CAAC;AAEtE;;;;GAIG;AACH,wBAAsB,kBAAkB,CACvC,OAAO,EAAE,cAAc,EACvB,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,2BAA2B,GAC9B,OAAO,CAAC,qBAAqB,CAAC,CA+BhC","sourcesContent":["/**\n * Reliability execution step — a Jensen-owned decode/validate/execute/record\n * pipeline over raw model output.\n *\n * This is the authority boundary in code form: raw output is decoded into an\n * AgentAction, validated against the tool registry/boundary/policy, and only\n * then executed. Evidence is recorded by Jensen from the observed outcome.\n *\n * The deterministic Reliability Suite drives the kernel through this function\n * with a scripted model and tool harness. The LIVE agent loop integrates with\n * the same decoder/validator/evidence/gate primitives through\n * {@link ReliabilitySessionBridge} (wired by ReliabilitySessionController as\n * Agent beforeToolCall/afterToolCall/onTurnEnd hooks) rather than through this\n * function, so the live loop is not duplicated and adversarial behavior cannot\n * bypass the kernel by taking a different code path.\n */\n\nimport { decodeAction } from \"./action-decoder.js\";\nimport { type ActionValidatorContext, validateToolCallAction } from \"./action-validator.js\";\nimport type { MissionRuntime } from \"./mission-runtime.js\";\nimport type { ActionValidationFailure, AgentAction, MissionEvidence, ToolCallAction } from \"./types.js\";\n\nexport interface ReliabilityExecutionContext extends ActionValidatorContext {\n\t/** Execute a validated tool action and return the observed outcome. */\n\texecuteTool(action: ToolCallAction): Promise<MissionEvidence>;\n}\n\nexport type ReliabilityStepResult =\n\t| { kind: \"executed\"; action: ToolCallAction; evidence: MissionEvidence }\n\t| { kind: \"validation_rejected\"; failure: ActionValidationFailure }\n\t| { kind: \"decode_rejected\"; failure: ActionValidationFailure }\n\t| { kind: \"non_tool\"; action: Exclude<AgentAction, ToolCallAction> };\n\n/**\n * Decode, validate, and (if valid) execute a single raw model output as a\n * Jensen-owned action. Never executes an invalid action. Never throws for\n * invalid model output — failures are returned as structured results.\n */\nexport async function executeAgentAction(\n\truntime: MissionRuntime,\n\traw: unknown,\n\tctx: ReliabilityExecutionContext,\n): Promise<ReliabilityStepResult> {\n\tconst decoded = decodeAction(raw);\n\tif (!decoded.ok) {\n\t\truntime.recorder.record(\"action_decode_failure\", { message: decoded.failure.message });\n\t\treturn { kind: \"decode_rejected\", failure: decoded.failure };\n\t}\n\n\tconst action = decoded.action;\n\truntime.recorder.record(\"action_proposed\", { type: action.type });\n\n\tif (action.type !== \"tool_call\") {\n\t\treturn { kind: \"non_tool\", action };\n\t}\n\n\tconst validated = validateToolCallAction(action, ctx);\n\tif (!validated.ok) {\n\t\truntime.recorder.record(\"action_validation_failure\", {\n\t\t\ttool: action.tool,\n\t\t\tcategory: validated.failure.category,\n\t\t});\n\t\treturn { kind: \"validation_rejected\", failure: validated.failure };\n\t}\n\n\tconst evidence = await ctx.executeTool(validated.action);\n\truntime.recordToolEvidence(evidence);\n\tif (evidence.success === false) {\n\t\truntime.recorder.record(\"tool_failed\", { tool: action.tool });\n\t} else {\n\t\truntime.recorder.record(\"tool_executed\", { tool: action.tool });\n\t}\n\treturn { kind: \"executed\", action: validated.action, evidence };\n}\n"]}