{"version":3,"file":"long-horizon.d.ts","sourceRoot":"","sources":["../../../src/core/routing/long-horizon.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEhF,MAAM,MAAM,kBAAkB,GAC3B,kBAAkB,GAClB,oBAAoB,GACpB,cAAc,GACd,yBAAyB,GACzB,YAAY,GACZ,aAAa,CAAC;AAEjB,wEAAwE;AACxE,eAAO,MAAM,qBAAqB,EAAE,SAAS,kBAAkB,EAO9D,CAAC;AAEF,MAAM,WAAW,qBAAqB;IACrC,+EAA+E;IAC/E,qBAAqB,EAAE,OAAO,CAAC;IAC/B,+DAA+D;IAC/D,mBAAmB,EAAE,OAAO,CAAC;IAC7B,uEAAuE;IACvE,kBAAkB,EAAE,MAAM,EAAE,CAAC;IAC7B,wDAAwD;IACxD,6BAA6B,EAAE,OAAO,CAAC;CACvC;AAED,MAAM,WAAW,gBAAgB;IAChC,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,kBAAkB,CAAC,EAAE,sBAAsB,CAAC;IAC5C,OAAO,EAAE;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,SAAS,EAAE,OAAO,CAAC;QAAC,iBAAiB,EAAE,MAAM,CAAA;KAAE,CAAC;CAC7E;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAC5B,QAAQ,EAAE,kBAAkB,EAC5B,SAAS,EAAE,qBAAqB,EAChC,OAAO,EAAE;IAAE,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAAC,iBAAiB,CAAC,EAAE,SAAS,kBAAkB,EAAE,CAAA;CAAE,GAC7F,gBAAgB,CAgClB","sourcesContent":["/**\n * Long-horizon integration.\n *\n * Routing reconsiders model/topology/retrieval/budget/review at governed phase\n * boundaries — never after every tool call. Phase state remains authoritative;\n * routing changes never rewrite history; the current transaction completes or\n * rolls back before an incompatible strategy change; cleanup obligations\n * survive routing changes; context handoff is bounded and validated.\n */\n\nimport type { OrchestrationCandidate, OrchestrationDecision } from \"./types.js\";\n\nexport type ReconsiderBoundary =\n\t| \"initial_planning\"\n\t| \"post_investigation\"\n\t| \"pre_mutation\"\n\t| \"post_validation_failure\"\n\t| \"pre_review\"\n\t| \"pre_release\";\n\n/** All governed boundaries. Routing never reconsiders between these. */\nexport const RECONSIDER_BOUNDARIES: readonly ReconsiderBoundary[] = [\n\t\"initial_planning\",\n\t\"post_investigation\",\n\t\"pre_mutation\",\n\t\"post_validation_failure\",\n\t\"pre_review\",\n\t\"pre_release\",\n];\n\nexport interface LongHorizonConstraint {\n\t/** A transaction is in progress; an incompatible strategy change must wait. */\n\ttransactionInProgress: boolean;\n\t/** TODOs remain advisory (never authoritative for routing). */\n\ttodoRemainsAdvisory: boolean;\n\t/** Outstanding cleanup obligations must survive any routing change. */\n\tcleanupObligations: string[];\n\t/** Configured and resolved model must stay distinct. */\n\tconfiguredAndResolvedDistinct: boolean;\n}\n\nexport interface ReconsiderResult {\n\tboundary: ReconsiderBoundary;\n\tallowed: boolean;\n\treasonCodes: string[];\n\tpreferredCandidate?: OrchestrationCandidate;\n\thandoff: { bounded: boolean; validated: boolean; contextPacketSize: number };\n}\n\n/**\n * Decide whether routing may reconsider at a given boundary.\n * - Routing reconsiders only at governed boundaries.\n * - If a transaction is in progress, an incompatible strategy change is held\n *   until the transaction completes or rolls back (allowed=false with reason).\n */\nexport function canReconsider(\n\tboundary: ReconsiderBoundary,\n\t_decision: OrchestrationDecision,\n\toptions: { transactionInProgress?: boolean; allowedBoundaries?: readonly ReconsiderBoundary[] },\n): ReconsiderResult {\n\tconst allowedBoundaries = options.allowedBoundaries ?? RECONSIDER_BOUNDARIES;\n\tconst reasonCodes: string[] = [];\n\n\tif (!allowedBoundaries.includes(boundary)) {\n\t\treasonCodes.push(\"boundary_not_governed\");\n\t\treturn {\n\t\t\tboundary,\n\t\t\tallowed: false,\n\t\t\treasonCodes,\n\t\t\thandoff: { bounded: false, validated: false, contextPacketSize: 0 },\n\t\t};\n\t}\n\n\tif (options.transactionInProgress) {\n\t\treasonCodes.push(\"transaction_in_progress_held_for_completion_or_rollback\");\n\t\treturn {\n\t\t\tboundary,\n\t\t\tallowed: false,\n\t\t\treasonCodes,\n\t\t\thandoff: { bounded: false, validated: false, contextPacketSize: 0 },\n\t\t};\n\t}\n\n\t// Routing changes never rewrite history: they only affect the next phase.\n\treasonCodes.push(\"routing_change_affects_next_phase_only\");\n\treturn {\n\t\tboundary,\n\t\tallowed: true,\n\t\treasonCodes,\n\t\thandoff: { bounded: true, validated: true, contextPacketSize: 128 },\n\t};\n}\n"]}