// engine/spec-state-machine/transition-spec.ts — SPEC-720
// Single, authoritative store-side entry point for all status writes.
// MUST only be called from src/tools/update-status/index.ts (enforced by ESLint).
import { specStore } from '../../storage/index.js';
// ---------------------------------------------------------------------------
// Core transition
// ---------------------------------------------------------------------------
/**
 * Performs the bare store write for a spec status transition.
 *
 * IMPORTANT: This function only writes the status. The CALLER (handleUpdateStatus)
 * is responsible for running all gates (DoD, validate, QA, security, etc.) BEFORE
 * invoking transitionSpec. transitionSpec never runs gates itself.
 *
 * Callable ONLY from `src/tools/update-status/index.ts`.
 */
export async function transitionSpec(projectId, specId, newStatus, ctx) {
    const before = await specStore.getSpec(projectId, specId);
    if (!before) {
        throw new Error(`Spec ${specId} not found in project ${projectId}`);
    }
    // Use the internal-only write path that bypasses the status guard
    const after = await specStore.__internalSetStatus(projectId, specId, newStatus);
    return {
        spec: after,
        fromStatus: before.status,
        toStatus: newStatus,
        trigger: ctx.trigger,
        actor: ctx.actor,
        viaSync: ctx.viaSync ?? false,
        timestamp: new Date().toISOString(),
    };
}
//# sourceMappingURL=transition-spec.js.map