/** * Agent-work-contract lifecycle state machine. * * Defines allowed transitions and provides 4 transition functions * for managing contract status through its lifecycle. * * @module lifecycle */ import type { AgentWorkStatus } from "../../schema-kernel/agent-work-contract.schema.js"; /** * Formal state machine defining which status transitions are allowed. * * Each key is a source status, and the value is an array of valid target statuses. * Empty arrays indicate terminal states (completed, cancelled). */ export declare const ALLOWED_TRANSITIONS: Record; /** * Transition a contract from created→running. * * @param projectRoot - Trusted project root. * @param contractId - Contract to transition. * @returns Updated contract. * @throws {Error} When the contract doesn't exist or the transition is invalid. */ export declare function startContract(projectRoot: string, contractId: string): { id: string; status: "running" | "completed" | "cancelled" | "created" | "blocked"; owner: { agent: string; sessionId?: string | undefined; parentSessionId?: string | undefined; }; scope: { taskBoundary: string; allowedSurfaces: string[]; dependencies: string[]; nonGoals: string[]; }; evidence: { requiredProof: string[]; minimumEvidenceLevel: "L1_RUNTIME_PROOF" | "L2_AUTOMATED_TEST" | "L3_STATIC_REVIEW" | "L4_IMPLEMENTATION_TRACE" | "L5_DOCUMENTATION"; verificationCommands: string[]; blockedStateRules: string[]; }; compaction: { briefing: string; summary: string; anchors: string[]; reinjectionPayload: string; sourceRefs: string[]; }; createdAt: number; updatedAt: number; trajectoryId?: string | undefined; trajectoryEvidenceRef?: string | undefined; }; /** * Transition a contract from running→blocked. * * @param projectRoot - Trusted project root. * @param contractId - Contract to transition. * @param reason - Reason for blocking. * @returns Updated contract. * @throws {Error} When the contract doesn't exist or the transition is invalid. */ export declare function blockContract(projectRoot: string, contractId: string, reason: string): { id: string; status: "running" | "completed" | "cancelled" | "created" | "blocked"; owner: { agent: string; sessionId?: string | undefined; parentSessionId?: string | undefined; }; scope: { taskBoundary: string; allowedSurfaces: string[]; dependencies: string[]; nonGoals: string[]; }; evidence: { requiredProof: string[]; minimumEvidenceLevel: "L1_RUNTIME_PROOF" | "L2_AUTOMATED_TEST" | "L3_STATIC_REVIEW" | "L4_IMPLEMENTATION_TRACE" | "L5_DOCUMENTATION"; verificationCommands: string[]; blockedStateRules: string[]; }; compaction: { briefing: string; summary: string; anchors: string[]; reinjectionPayload: string; sourceRefs: string[]; }; createdAt: number; updatedAt: number; trajectoryId?: string | undefined; trajectoryEvidenceRef?: string | undefined; }; /** * Transition a contract from running→completed. * * Evidence gating: if contract.evidence.requiredProof is non-empty, a proof * string must be provided. Throws with a descriptive error listing required proofs. * * @param projectRoot - Trusted project root. * @param contractId - Contract to transition. * @param proof - Required completion proof (mandatory when requiredProof is non-empty). * @returns Updated contract. * @throws {Error} When the contract doesn't exist, the transition is invalid, * or requiredProof is non-empty and no proof provided. */ export declare function completeContract(projectRoot: string, contractId: string, proof?: string): { id: string; status: "running" | "completed" | "cancelled" | "created" | "blocked"; owner: { agent: string; sessionId?: string | undefined; parentSessionId?: string | undefined; }; scope: { taskBoundary: string; allowedSurfaces: string[]; dependencies: string[]; nonGoals: string[]; }; evidence: { requiredProof: string[]; minimumEvidenceLevel: "L1_RUNTIME_PROOF" | "L2_AUTOMATED_TEST" | "L3_STATIC_REVIEW" | "L4_IMPLEMENTATION_TRACE" | "L5_DOCUMENTATION"; verificationCommands: string[]; blockedStateRules: string[]; }; compaction: { briefing: string; summary: string; anchors: string[]; reinjectionPayload: string; sourceRefs: string[]; }; createdAt: number; updatedAt: number; trajectoryId?: string | undefined; trajectoryEvidenceRef?: string | undefined; }; /** * Transition a contract from any active state to cancelled. * * @param projectRoot - Trusted project root. * @param contractId - Contract to transition. * @param reason - Reason for cancellation. * @returns Updated contract. * @throws {Error} When the contract doesn't exist or the transition is invalid. */ export declare function cancelContract(projectRoot: string, contractId: string, reason: string): { id: string; status: "running" | "completed" | "cancelled" | "created" | "blocked"; owner: { agent: string; sessionId?: string | undefined; parentSessionId?: string | undefined; }; scope: { taskBoundary: string; allowedSurfaces: string[]; dependencies: string[]; nonGoals: string[]; }; evidence: { requiredProof: string[]; minimumEvidenceLevel: "L1_RUNTIME_PROOF" | "L2_AUTOMATED_TEST" | "L3_STATIC_REVIEW" | "L4_IMPLEMENTATION_TRACE" | "L5_DOCUMENTATION"; verificationCommands: string[]; blockedStateRules: string[]; }; compaction: { briefing: string; summary: string; anchors: string[]; reinjectionPayload: string; sourceRefs: string[]; }; createdAt: number; updatedAt: number; trajectoryId?: string | undefined; trajectoryEvidenceRef?: string | undefined; }; //# sourceMappingURL=lifecycle.d.ts.map