Intelligence

Artifacts

Browse the repository, read documents, and manage the governance folders. Source, runtime, and infrastructure are read-only.

Repository
README.md
CONSTITUTION_COMPLIANCE_AUDIT_V1.mdREADME.md
repositories/aaf-holdings/hq01/lib/missions/lifecycle.ts
1.5 KB
import type { MissionStatus } from "./types";

/**
 * Mission lifecycle state machine (PASS M1). Pure (no filesystem), so both the
 * server manager and the client UI can share one definition of what is legal.
 */

/** The only transitions a mission may make, from each state. */
export const VALID_TRANSITIONS: Record<MissionStatus, MissionStatus[]> = {
  Draft: ["Proposed"],
  Proposed: ["Approved", "Cancelled"],
  Approved: ["Planning"],
  Planning: ["Active", "Cancelled"],
  Active: ["Blocked", "Review"],
  Blocked: ["Active", "Cancelled"],
  Review: ["Completed", "Active"],
  Completed: ["Archived"],
  Archived: [], // terminal
  Cancelled: ["Archived"],
};

/** States from which a mission may be dispatched (CEO approval reached). */
export const EXECUTABLE_STATES: MissionStatus[] = ["Approved", "Planning", "Active"];

/** Human action label for transitioning *to* a given state. */
export const TRANSITION_LABEL: Record<MissionStatus, string> = {
  Draft: "Reset to Draft",
  Proposed: "Propose",
  Approved: "Approve",
  Planning: "Move to Planning",
  Active: "Activate",
  Blocked: "Block",
  Review: "Send to Review",
  Completed: "Complete",
  Archived: "Archive",
  Cancelled: "Cancel",
};

export function allowedNextStates(status: MissionStatus): MissionStatus[] {
  return VALID_TRANSITIONS[status] ?? [];
}

export function canTransition(from: MissionStatus, to: MissionStatus): boolean {
  return allowedNextStates(from).includes(to);
}

export function isExecutable(status: MissionStatus): boolean {
  return EXECUTABLE_STATES.includes(status);
}

root · /srv/aaf