feat(orchestration): enforce verified completion and cross-department fan-out
Deploy Canina / deploy (push) Successful in 2m8s
Deploy Canina / deploy (push) Successful in 2m8s
This commit is contained in:
1 parent
624f58c723
commit
4c3f8de1fb
6 files changed
+551
-1
No files matched your search
@@ -0,0 +1,40 @@
|
||||
import { BadRequestException } from "@nestjs/common";
|
||||
|
||||
interface CompletabaleTask {
|
||||
deliverableUrl?: string | null;
|
||||
acceptanceCriteria?: unknown;
|
||||
executionLogs?: unknown;
|
||||
}
|
||||
|
||||
function hasAcceptanceCriteria(criteria: unknown): boolean {
|
||||
if (!criteria) return false;
|
||||
if (typeof criteria === "string") return criteria.trim().length > 0;
|
||||
if (Array.isArray(criteria)) return criteria.length > 0;
|
||||
if (typeof criteria === "object") {
|
||||
const value = criteria as Record<string, unknown>;
|
||||
const items = value.criteria;
|
||||
return Array.isArray(items) ? items.length > 0 : Object.keys(value).length > 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function hasQaEvidence(logs: unknown): boolean {
|
||||
if (!Array.isArray(logs)) return false;
|
||||
return logs.some((log) => {
|
||||
if (!log || typeof log !== "object") return false;
|
||||
const status = String((log as Record<string, unknown>).status || "").toUpperCase();
|
||||
return ["QA_PASSED", "VERIFIED", "PRODUCTION_VERIFIED"].includes(status);
|
||||
});
|
||||
}
|
||||
|
||||
export function assertTaskCanComplete(task: CompletabaleTask): void {
|
||||
if (!task.deliverableUrl?.trim()) {
|
||||
throw new BadRequestException("DONE requires a verifiable deliverable URL");
|
||||
}
|
||||
if (!hasAcceptanceCriteria(task.acceptanceCriteria)) {
|
||||
throw new BadRequestException("DONE requires explicit acceptance criteria");
|
||||
}
|
||||
if (!hasQaEvidence(task.executionLogs)) {
|
||||
throw new BadRequestException("DONE requires QA/production verification evidence");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user