All checks were successful
CD Pipeline / workflow-shape (push) Successful in 0s
CD Pipeline / cancel-stale-cd (push) Has been skipped
CD Pipeline / tests (push) Successful in 6m10s
CD Pipeline / build-and-deploy (push) Successful in 8m50s
CD Pipeline / post-deploy-checks (push) Successful in 3m1s
48 lines
1.3 KiB
TypeScript
48 lines
1.3 KiB
TypeScript
const MONOTONIC_CLOSED_PROGRAM_WORK_ITEM_IDS = [
|
|
"AIA-P0-001",
|
|
"AIA-P0-011",
|
|
"AIA-P0-002",
|
|
"AIA-P0-003",
|
|
"AIA-P0-004",
|
|
"AIA-P0-005",
|
|
] as const;
|
|
|
|
type PriorityWorkOrderProjection = {
|
|
commander_inserted_requirement_work_items?: unknown[] | null;
|
|
ai_automation_program_ledger?: {
|
|
work_items?: Array<{
|
|
id?: string | null;
|
|
status?: string | null;
|
|
}> | null;
|
|
summary?: {
|
|
done_count?: number | null;
|
|
completion_percent?: number | null;
|
|
} | null;
|
|
} | null;
|
|
};
|
|
|
|
export function isMonotonicPriorityWorkOrderProjection(
|
|
projection: PriorityWorkOrderProjection | null | undefined
|
|
): boolean {
|
|
if (!projection?.commander_inserted_requirement_work_items?.length) {
|
|
return false;
|
|
}
|
|
|
|
const program = projection.ai_automation_program_ledger;
|
|
const workItems = program?.work_items ?? [];
|
|
const statusById = new Map(
|
|
workItems.map((item) => [item.id ?? "", item.status ?? ""])
|
|
);
|
|
const closureFloorSatisfied = MONOTONIC_CLOSED_PROGRAM_WORK_ITEM_IDS.every(
|
|
(workItemId) => statusById.get(workItemId) === "done"
|
|
);
|
|
const doneCount = Number(program?.summary?.done_count ?? 0);
|
|
const completionPercent = Number(program?.summary?.completion_percent ?? 0);
|
|
|
|
return (
|
|
closureFloorSatisfied &&
|
|
doneCount >= MONOTONIC_CLOSED_PROGRAM_WORK_ITEM_IDS.length &&
|
|
completionPercent >= 30
|
|
);
|
|
}
|