Files
canvas-frontend/src/lib/flowCuration.ts
T
shad 11e8442a93 fix(curation): blacklist source_contexts of un-startable backfill seeds
Oracle round-6 watch-out closure. The Assistant's list_processes was
returning PO Approval + Purchase Order Approval, both of which return
500 transaction_creation_failed on /api/runtime/transactions because
they were backfilled into the catalogue without view/data attachments.

Added 5 source_context exclusions matching the seed-time markers of
those flows: D2 live backfill / EA2 runtime reference seed /
atlas-f1-fresh-proof / EA2 seed payload via POST /api/process /
fm-process-mining-conformance-reseed.

The canonical pr_to_po_def (source_context fm06-t10-demo-reset-v2,
display 'Purchase Requisition to PO') survives — it is the only
runtime-startable flow in the tenant today.
2026-06-14 14:19:49 +04:00

76 lines
2.0 KiB
TypeScript

export interface RawFlow {
_key: string;
display_name?: string;
name?: string;
description?: string;
source_context?: string;
status?: string;
kind?: string;
}
const DEV_ARTEFACT_PATTERNS = [
/^rv[_\s]/i,
/^orphan/i,
/^atlas[_\s]?f1/i,
/\batlas-f1-fresh\b/i,
/mcp[_\s]?sdx[_\s]?smoke/i,
/\bcodex[_\s]?test\b/i,
/\bsidekick\b/i,
/^process_\d{10,}$/i,
/\bbackfill\b/i,
/\bsmoke[_\s]?test\b/i,
/\bprobe\b/i,
/\bfixture\b/i,
/\bea2\b/i,
/\bsdx\b/i,
/\bruntime reference\b/i,
/\bdemo\b/i,
/\btest\b/i,
];
const NON_BUSINESS_SOURCE_CONTEXTS = new Set([
"EA2_CHAT_THREAD",
"EA2_CHAT_MSG",
"CANVAS_CHAT_THREAD",
"CANVAS_CHAT_MSG",
"CANVAS_CHAT_INBOX",
"CANVAS_ATTENDANCE_ROOT",
"CANVAS_ATTENDANCE_SITE",
"CANVAS_SEED_PROCESS",
"CANVAS_SEED_STEP",
"EA2_WIZARD_STEP",
"EA2_DRAFT_PROCESS:process_creation",
"D2 live backfill 2026-04-25; derived from seed fields, existing description/content, and graph name.",
"EA2 runtime reference seed",
"atlas-f1-fresh-proof",
"EA2 seed payload via POST /api/process",
"fm-process-mining-conformance-reseed",
]);
const HEX32 = /[a-f0-9]{32}/gi;
const HEX_SUFFIX = /[_-][a-f0-9]{8,}$/i;
export function isDevArtefact(f: RawFlow): boolean {
if (f.source_context && NON_BUSINESS_SOURCE_CONTEXTS.has(f.source_context)) return true;
const haystack = `${f.display_name || ""} ${f.name || ""} ${f.description || ""}`;
return DEV_ARTEFACT_PATTERNS.some((p) => p.test(haystack));
}
export function curatedPublishedFlows<T extends RawFlow>(items: T[]): T[] {
return items.filter(
(it) => it.status === "published" && it.kind === "definition" && !!it.display_name && !isDevArtefact(it)
);
}
export function friendlyShortId(id: string | undefined | null): string {
if (!id) return "";
const trimmed = id.replace(HEX_SUFFIX, "");
if (trimmed.length < id.length && trimmed.length > 0) return trimmed;
if (HEX32.test(id)) return `ref-${id.slice(0, 4)}`;
return id;
}
export function scrubIdsFromText(text: string): string {
return text.replace(HEX32, "");
}