Checkpoint recovered orchestration core with tested fail-closed boundaries

This commit is contained in:
devops committed 2026-10-23 08:01:08 +00:00
1 parent c7f1d25e98
commit 0952a482fb
18 files changed
+1918 -129

No files matched your search

@@ -1,24 +1,47 @@
import { BadRequestException, ConflictException, ForbiddenException } from "@nestjs/common";
import { assertTransition, nextStateForGateDecision, OperationMode, WorkflowState } from "./orchestration.domain";
import {
BadRequestException,
ConflictException,
ForbiddenException,
} from '@nestjs/common';
import {
assertTransition,
nextStateForGateDecision,
OperationMode,
WorkflowState,
} from './orchestration.domain';
describe("orchestration domain", () => {
it("allows only declared workflow transitions", () => {
expect(() => assertTransition(WorkflowState.DRAFT, WorkflowState.GATE1_PENDING)).not.toThrow();
expect(() => assertTransition(WorkflowState.DRAFT, WorkflowState.RUNNING)).toThrow(BadRequestException);
describe('orchestration domain', () => {
it('allows only declared workflow transitions', () => {
expect(() =>
assertTransition(WorkflowState.DRAFT, WorkflowState.GATE1_PENDING),
).not.toThrow();
expect(() =>
assertTransition(WorkflowState.DRAFT, WorkflowState.RUNNING),
).toThrow(BadRequestException);
});
it("keeps gate 1 as execution authorization rather than release authorization", () => {
expect(nextStateForGateDecision(1, "APPROVED")).toBe(WorkflowState.GATE1_APPROVED);
expect(nextStateForGateDecision(2, "APPROVED")).toBe(WorkflowState.GATE2_APPROVED);
it('keeps gate 1 as execution authorization rather than release authorization', () => {
expect(nextStateForGateDecision(1, 'APPROVED')).toBe(
WorkflowState.GATE1_APPROVED,
);
expect(nextStateForGateDecision(2, 'APPROVED')).toBe(
WorkflowState.GATE2_APPROVED,
);
});
it("rejects an unsupported gate decision", () => {
expect(() => nextStateForGateDecision(1, "PENDING" as never)).toThrow(BadRequestException);
it('rejects an unsupported gate decision', () => {
expect(() => nextStateForGateDecision(1, 'PENDING' as never)).toThrow(
BadRequestException,
);
});
it("classifies production mutation separately from observe and prepare", () => {
expect(OperationMode.OBSERVE).toBe("OBSERVE");
expect(OperationMode.PREPARE).toBe("PREPARE");
expect(OperationMode.MUTATE_PRODUCTION).toBe("MUTATE_PRODUCTION");
it.each([WorkflowState.GATE1_PENDING, WorkflowState.GATE2_PENDING])('does not revive an expired proposal into %s', (state) => {
expect(() => assertTransition(WorkflowState.EXPIRED,state)).toThrow(BadRequestException);
});
it('classifies production mutation separately from observe and prepare', () => {
expect(OperationMode.OBSERVE).toBe('OBSERVE');
expect(OperationMode.PREPARE).toBe('PREPARE');
expect(OperationMode.MUTATE_PRODUCTION).toBe('MUTATE_PRODUCTION');
});
});