/**
 * src/skill-loop/candidate.ts
 *
 * Reflexion-style deterministic skill candidate extraction.
 *
 * Key invariant: extraction is deterministic — SHA-256(cycleId + domain) is the
 * sole source of entropy. No LLM calls. Replay produces bit-identical output.
 *
 * @module skill-loop/candidate
 */
import { sha256 } from "../proof/sha256.js";
// ---------------------------------------------------------------------------
// Extraction
// ---------------------------------------------------------------------------
/**
 * Extract a SkillCandidate from a high-scoring cycle's outcome text.
 *
 * Deterministic: SHA-256(cycleId + domain) seeded extraction, no LLM calls.
 * Replay with the same arguments produces bit-identical output.
 *
 * @param cycleId      - Source cycle identifier.
 * @param instructions - Raw skill instructions text extracted from the cycle.
 * @param domain       - Domain key for the skill.
 * @param scores       - Constitutional and outcome scores from the cycle.
 * @returns            - Fully populated SkillCandidate (async due to SHA-256).
 */
export async function extractCandidate(cycleId, instructions, domain, scores) {
    // Deterministic id: SHA-256(cycleId + ":" + domain)
    const id = await sha256(`${cycleId}:${domain}`);
    // replayRoot: SHA-256 of the full source context (cycle trace)
    const replayRoot = await sha256(`${cycleId}:${domain}:${instructions}`);
    return {
        id,
        extractedFrom: cycleId,
        domain,
        instructions,
        constitutionalScore: scores.constitutional,
        outcomeScore: scores.outcome,
        version: "1.0.0",
        replayRoot,
    };
}
//# sourceMappingURL=candidate.js.map