export interface WorkerLifecycleProjectionV1 { readonly body: string; readonly labels: readonly string[]; readonly context: { readonly orchestrator: { readonly version: 1; readonly name: "pi-amq"; readonly transport: "extension"; readonly event: "worker_lifecycle"; readonly task: { readonly id: string; readonly state: string }; }; }; } export function projectWorkerLifecycle( workerId: string, state: string, ): WorkerLifecycleProjectionV1 { const labels = ["orchestrator", "orchestrator:pi-amq", `task-state:${state}`]; if (state === "ready_for_review") labels.push("handoff"); if (state === "failed" || state === "interrupted" || state === "blocked") { labels.push("blocking"); } return { body: JSON.stringify({ workerId, state }), labels, context: { orchestrator: { version: 1, name: "pi-amq", transport: "extension", event: "worker_lifecycle", task: { id: workerId, state }, }, }, }; }