{"version":3,"file":"cli-helpers.d.ts","sourceRoot":"","sources":["../../../src/core/routing/cli-helpers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD,MAAM,WAAW,kBAAkB;IAClC,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,wBAAgB,kBAAkB,IAAI,kBAAkB,CAWvD;AAED;;;;GAIG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CA0BnE;AAED,sEAAsE;AACtE,wBAAgB,yBAAyB,IAAI,OAAO,CAanD;AAED,sEAAsE;AACtE,wBAAgB,mBAAmB,IAChC;IACA,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACzD,qBAAqB,CAAC,EAAE,MAAM,EAAE,CAAC;CAChC,GACD,SAAS,CAWX","sourcesContent":["/**\n * CLI helper functions: active policy status, fixture evidence, and policy\n * generation used by the routing CLI. These are inherently deterministic and\n * offline (no providers, no network) so normal CI never touches a paid API.\n */\n\nimport { generateRoutingPolicy } from \"./optimizer.js\";\nimport { loadActivePolicyPointer, readPolicy } from \"./store.js\";\nimport type { CandidateEvidence } from \"./types.js\";\n\nexport interface ActivePolicyStatus {\n\tactive: boolean;\n\tpolicyId?: string;\n\tpolicyVersion?: number;\n\thash?: string;\n\tactivatedAt?: string;\n\tpreviousPolicyId?: string;\n}\n\nexport function activePolicyStatus(): ActivePolicyStatus {\n\tconst pointer = loadActivePolicyPointer();\n\tif (!pointer) return { active: false };\n\treturn {\n\t\tactive: true,\n\t\tpolicyId: pointer.policyId,\n\t\tpolicyVersion: pointer.policyVersion,\n\t\thash: pointer.hash,\n\t\tactivatedAt: pointer.activatedAt,\n\t\tpreviousPolicyId: pointer.previousPolicyId,\n\t};\n}\n\n/**\n * Deterministic fixture evidence set used for offline CLI paths (decide,\n * generate, promote). Uses fixture candidate IDs and a fixed evaluation\n * fingerprint so results are reproducible across runs and platforms.\n */\nexport function fixtureEvidence(): Record<string, CandidateEvidence> {\n\tconst ev: Record<string, CandidateEvidence> = {};\n\tconst base = (candidateId: string, sampleCount: number): CandidateEvidence => ({\n\t\tcandidateId,\n\t\tevaluatorVersion: \"1.0.0-fixture\",\n\t\tscenarioVersion: \"routing-pack-v1\",\n\t\tevidenceHash: `${candidateId}-fixture-v1`,\n\t\tsampleCount,\n\t\tcorrectnessRate: 0.9,\n\t\tsafetyRate: 0.98,\n\t\treliabilityRate: 0.92,\n\t\tmedianLatencyMs: 1200,\n\t\tavgCostUsd: 0.3,\n\t\tflakyRate: 0.05,\n\t\tcompatibility: { promptTemplateId: \"fixture\", toolSchemaVersion: \"1\" },\n\t\tcollectedAt: \"2026-01-01T00:00:00.000Z\",\n\t\tversion: 1,\n\t});\n\tconst ids = [\n\t\t\"c-fixture-fixture-deterministic-single_agent-lexical-small\",\n\t\t\"c-fixture-fixture-deterministic-single_agent-hybrid-standard\",\n\t\t\"c-fixture-fixture-deterministic-single_agent_with_reviewer-hybrid-large\",\n\t\t\"c-fixture-fixture-deterministic-cavecrew-hybrid-release\",\n\t];\n\tfor (const id of ids) ev[id] = base(id, 25);\n\treturn ev;\n}\n\n/** Generate a policy from fixture evidence and return its summary. */\nexport function generatePolicyFromFixture(): unknown {\n\tconst evidenceById = fixtureEvidence();\n\tconst candidateIds = Object.keys(evidenceById);\n\tconst result = generateRoutingPolicy(candidateIds, evidenceById, \"1.0.0-fixture\", \"dataset-fixture-hash\");\n\treturn {\n\t\tpolicyId: result.policy.policyId,\n\t\tpolicyVersion: result.policy.policyVersion,\n\t\tsourceDatasetHash: result.policy.sourceDatasetHash,\n\t\tstatus: result.policy.status,\n\t\tranked: result.ranked,\n\t\tdominatedCandidateIds: result.dominatedCandidateIds,\n\t\tevidenceGaps: result.evidenceGaps,\n\t};\n}\n\n/** Resolve the active policy's preferences for engine consumption. */\nexport function activePolicyContext():\n\t| {\n\t\t\tpolicyId: string;\n\t\t\tpolicyVersion: number;\n\t\t\tpreferences?: { candidateId: string; quality: number }[];\n\t\t\tdominatedCandidateIds?: string[];\n\t  }\n\t| undefined {\n\tconst pointer = loadActivePolicyPointer();\n\tif (!pointer) return undefined;\n\tconst policy = readPolicy(pointer.policyId);\n\tif (!policy) return undefined;\n\treturn {\n\t\tpolicyId: policy.policyId,\n\t\tpolicyVersion: policy.policyVersion,\n\t\tpreferences: policy.preferences ?? undefined,\n\t\tdominatedCandidateIds: policy.dominatedCandidateIds,\n\t};\n}\n"]}