/** * Assignment Foundation — domain-facing persistence port (2.11.0). * * Pure types + validation only. No filesystem, process, provider, scheduler, * or worker-daemon machinery. The concrete file store writes one small record * per assignment and keeps the "current assignment" flag on the record itself; * the current-assignment invariant is enforced by the per-mission cross-process * mutation lock, not by a separate mutable pointer file. * * Authority model: * - An assignment records logical designation (mission → executor). * - It is never execution ownership, never runtime incarnation, and never a * MissionResult. Canonical mission completion remains authoritative. */ import { type AssignmentRecord } from "./assignment-types.js"; export declare const ASSIGNMENT_SCHEMA_VERSION: 1; export type AssignmentLoadResult = { status: "ok"; record: AssignmentRecord; } | { status: "missing"; } | { status: "corrupt"; assignmentId: string; diagnostic: string; }; /** The assignment records for one mission, plus the current designation. */ export interface MissionAssignmentIndex { missionId: string; /** All assignments for the mission, oldest first. */ records: AssignmentRecord[]; /** The record with `current === true`, when one exists. */ current?: AssignmentRecord; } /** A store-level atomic mutation of a mission's assignment history. */ export type AssignmentMutation = { kind: "write"; records: AssignmentRecord[]; value: T; } | { kind: "noop"; value: T; }; export type AssignmentMutateResult = { status: "ok"; value: T; } | { status: "corrupt"; diagnostic: string; }; /** Bulk read result: all healthy records plus structurally-surfaced corrupt ids. */ export interface AssignmentListRecordsResult { records: AssignmentRecord[]; corrupt: { assignmentId: string; diagnostic: string; }[]; } /** * Canonical assignment persistence port. Implementations must be crash-conscious * (atomic record replacement, schema validation on load, deterministic corrupt * handling) and must never fabricate a current assignment. */ export interface AssignmentStore { readonly storeId: string; /** Load a single assignment by its durable id. */ load(assignmentId: string): Promise; /** All assignment ids (any mission), for scan-based listing. */ listAssignments(): Promise; /** Bulk load every healthy record and surface corrupt ids structurally. */ listRecords(): Promise; /** * Atomically mutate a mission's assignment history across processes. The * callback receives the mission's current records (oldest first) and its * current assignment, and returns the replacement record set. The store * serializes mutations per mission and enforces the current invariant. */ mutate(missionId: string, mutation: (index: MissionAssignmentIndex) => AssignmentMutation): Promise>; } export type AssignmentParseResult = { ok: true; record: AssignmentRecord; } | { ok: false; diagnostic: string; }; export declare function validateMissionRequirements(value: unknown): string | undefined; /** * Validate an untrusted persisted value into an AssignmentRecord. Corruption is * surfaced structurally (`ok: false`), never silently dropped or fabricated. */ export declare function parseAssignmentRecord(value: unknown): AssignmentParseResult; export interface CreateAssignmentRecordInput { assignmentId: string; missionId: string; executorId: string; now?: number; assignedBy?: string; requirementsSnapshot?: AssignmentRecord["requirementsSnapshot"]; compatibilitySnapshot?: AssignmentRecord["compatibilitySnapshot"]; executionMode?: AssignmentRecord["executionMode"]; remoteTargetId?: AssignmentRecord["remoteTargetId"]; executorRuntimeAtAssignment?: AssignmentRecord["executorRuntimeAtAssignment"]; } /** Build an initial ASSIGNED + current record. */ export declare function createAssignmentRecord(input: CreateAssignmentRecordInput): AssignmentRecord; /** True when a record represents a canonical terminal assignment outcome. */ export declare function isTerminalAssignmentRecord(record: AssignmentRecord): boolean; //# sourceMappingURL=assignment-store.d.ts.map