{"version":3,"file":"release.d.ts","sourceRoot":"","sources":["../../src/evolve/release.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACnF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,gBAAgB,CAAC;AAEjE,MAAM,MAAM,sBAAsB,GAC/B,SAAS,GACT,OAAO,GACP,0BAA0B,GAC1B,gBAAgB,GAChB,UAAU,GACV,QAAQ,CAAC;AAEZ,MAAM,WAAW,sBAAsB;IACtC,MAAM,EAAE,sBAAsB,CAAC;IAC/B,QAAQ,EAAE,QAAQ,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CACf;AAED,iGAAiG;AACjG,eAAO,MAAM,yBAAyB;;;;;;;CAOqB,CAAC;AAE5D,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAErE;AAED;;;GAGG;AACH,wBAAsB,2BAA2B,CAAC,OAAO,EAAE;IAC1D,OAAO,EAAE,UAAU,CAAC;IACpB,MAAM,EAAE,gBAAgB,CAAC;IACzB,QAAQ,EAAE,QAAQ,CAAC;IACnB,OAAO,EAAE,0BAA0B,CAAC;IACpC,gBAAgB,EAAE,mBAAmB,CAAC;IACtC,kEAAkE;IAClE,QAAQ,EAAE,WAAW,CAAC,cAAc,CAAC,SAAS,CAAC,EAAE,cAAc,CAAC,CAAC;CACjE,GAAG,OAAO,CAAC,sBAAsB,CAAC,CA0FlC","sourcesContent":["import { proposalApproval } from \"../proposal.ts\";\nimport type { EvoService } from \"../service.ts\";\nimport type { EvoControlConfig, EvoEvidenceStrategy, Proposal } from \"../types.ts\";\nimport type { ProfileReceipt } from \"./check-profiles.ts\";\nimport type { EvolutionEvaluationVerdict } from \"./evaluator.ts\";\n\nexport type EvolutionReleaseAction =\n\t| \"applied\"\n\t| \"trial\"\n\t| \"awaiting-canary-approval\"\n\t| \"needs-evidence\"\n\t| \"rejected\"\n\t| \"review\";\n\nexport interface EvolutionReleaseResult {\n\taction: EvolutionReleaseAction;\n\tproposal: Proposal;\n\treason: string;\n}\n\n/** Canonical run status for each release action; shared by the cycle and evidence resumption. */\nexport const RELEASE_ACTION_RUN_STATUS = {\n\t\"awaiting-canary-approval\": \"awaiting-canary-approval\",\n\t\"needs-evidence\": \"awaiting-evidence\",\n\ttrial: \"trialing\",\n\treview: \"awaiting-decision\",\n\tapplied: \"completed\",\n\trejected: \"completed\",\n} as const satisfies Record<EvolutionReleaseAction, string>;\n\nexport function changesComponentSelection(proposal: Proposal): boolean {\n\treturn proposal.kind === \"data\" && proposal.changedPaths.includes(\"policy.json\") && proposal.targetAbi !== undefined;\n}\n\n/**\n * Deterministic standing policy. Models supply evidence and a bounded verdict,\n * but cannot write registry pointers themselves.\n */\nexport async function applyEvolutionReleasePolicy(options: {\n\tservice: EvoService;\n\tconfig: EvoControlConfig;\n\tproposal: Proposal;\n\tverdict: EvolutionEvaluationVerdict;\n\tevidenceStrategy: EvoEvidenceStrategy;\n\t/** Execution receipts written by the code that ran each check. */\n\treceipts: ReadonlyMap<ProfileReceipt[\"profile\"], ProfileReceipt>;\n}): Promise<EvolutionReleaseResult> {\n\tconst { proposal, verdict, config, service } = options;\n\tif (verdict === \"unsupported\" || verdict === \"invalid\") {\n\t\tconst rejected = await service.reject(\n\t\t\tproposal.id,\n\t\t\tverdict === \"invalid\"\n\t\t\t\t? \"Autonomous validation found the candidate or frozen experiment invalid\"\n\t\t\t\t: \"Executed comparative evidence found the frozen experiment unsupported\",\n\t\t);\n\t\treturn { action: \"rejected\", proposal: rejected, reason: `Evaluator verdict was ${verdict}` };\n\t}\n\tconst requiredProfiles = [\n\t\t...(options.evidenceStrategy.offline.mode === \"required\" ? options.evidenceStrategy.offline.profiles : []),\n\t\t...(options.evidenceStrategy.historicalReplay.mode === \"required\"\n\t\t\t? options.evidenceStrategy.historicalReplay.profiles\n\t\t\t: []),\n\t];\n\tconst missingProfiles = requiredProfiles.filter((profile) => options.receipts.get(profile)?.passed !== true);\n\tif (missingProfiles.length > 0) {\n\t\treturn {\n\t\t\taction: \"needs-evidence\",\n\t\t\tproposal,\n\t\t\treason: `Required evidence profiles have no passing execution receipt: ${missingProfiles.join(\", \")}`,\n\t\t};\n\t}\n\tif (options.evidenceStrategy.rollout === \"shadow-first\") {\n\t\treturn {\n\t\t\taction: \"needs-evidence\",\n\t\t\tproposal,\n\t\t\treason: \"The frozen evidence strategy requires shadow execution before release\",\n\t\t};\n\t}\n\tif (proposal.requiresNewAbi) {\n\t\treturn {\n\t\t\taction: \"review\",\n\t\t\tproposal,\n\t\t\treason: \"New ABI and host-seam proposals always require explicit human review\",\n\t\t};\n\t}\n\tif (proposal.kind === \"code\") {\n\t\treturn {\n\t\t\taction: \"review\",\n\t\t\tproposal,\n\t\t\treason: \"Arbitrary code proposals remain isolated for human integration\",\n\t\t};\n\t}\n\tif (proposal.tier === \"T0\") {\n\t\tif (verdict === \"verified\" && config.release.autoApplyT0) {\n\t\t\tconst approved = await service.approve(proposal.id, proposalApproval(proposal));\n\t\t\treturn { action: \"applied\", proposal: approved, reason: \"Standing policy allowed verified T0\" };\n\t\t}\n\t\treturn { action: \"review\", proposal, reason: \"T0 automatic application is disabled or evidence is uncertain\" };\n\t}\n\tconst component = changesComponentSelection(proposal);\n\tif (component) {\n\t\tif (options.evidenceStrategy.online.mode !== \"canary\") {\n\t\t\treturn {\n\t\t\t\taction: \"needs-evidence\",\n\t\t\t\tproposal,\n\t\t\t\treason: \"Component activation requires a bounded Canary evidence strategy\",\n\t\t\t};\n\t\t}\n\t\treturn config.release.autoStartComponentTrial\n\t\t\t? {\n\t\t\t\t\taction: \"awaiting-canary-approval\",\n\t\t\t\t\tproposal,\n\t\t\t\t\treason: \"Component Canary is enabled and requires explicit Enter confirmation\",\n\t\t\t\t}\n\t\t\t: {\n\t\t\t\t\taction: \"review\",\n\t\t\t\t\tproposal,\n\t\t\t\t\treason: \"Component Canary is disabled by local release policy\",\n\t\t\t\t};\n\t}\n\tif (config.release.autoStartDataTrial) {\n\t\tconst approved = await service.approve(proposal.id, proposalApproval(proposal));\n\t\treturn {\n\t\t\taction: \"trial\",\n\t\t\tproposal: approved,\n\t\t\treason: \"Standing policy started a data trial\",\n\t\t};\n\t}\n\treturn {\n\t\taction: verdict === \"needs-evidence\" ? \"needs-evidence\" : \"review\",\n\t\tproposal,\n\t\treason:\n\t\t\tverdict === \"needs-evidence\"\n\t\t\t\t? \"The valid candidate is waiting for replay or trial evidence\"\n\t\t\t\t: \"Automatic data trials are disabled\",\n\t};\n}\n"]}