fix(orchestration): atomically queue approvals with optional not-before schedule
Deploy Canina / deploy (push) Successful in 4m56s

This commit is contained in:
devops committed 2026-10-24 06:16:20 +00:00
1 parent ab2f330eb8
commit 50d0df822c
15 files changed
+216 -65

No files matched your search

@@ -4,7 +4,7 @@ import {
Injectable,
NotFoundException,
} from '@nestjs/common';
import { IsObject, IsUUID } from 'class-validator';
import { IsInt, Min, IsNotEmpty, IsString, IsObject, IsUUID } from 'class-validator';
import { createHash } from 'crypto';
import {
PrepareWorkflowService,
@@ -16,6 +16,10 @@ import { EDITORIAL_PILOT_KIND } from './editorial-bridge';
export class EditorialClaimDto {
@IsUUID() taskId!: string;
}
export class EditorialQueueDto extends EditorialClaimDto {
@IsInt() @Min(1) expectedVersion!: number;
@IsString() @IsNotEmpty() idempotencyKey!: string;
}
export class EditorialResultDto extends EditorialClaimDto {
@IsUUID() runId!: string;
@IsUUID() leaseToken!: string;
@@ -266,6 +270,18 @@ export class EditorialExecutionService {
};
});
}
async queue(a: WorkflowIdentity, dto: EditorialQueueDto) {
this.pmo(a);
return this.db.$transaction(async (tx:any)=>{
await this.lock(tx,dto.taskId,true);
const core=new PrepareWorkflowService(new Proxy(tx, {get(target,key){
if(key==='$transaction') return (fn:any)=>fn(tx);
const value=target[key]; return typeof value==='function'?value.bind(target):value;
}}),{workerIds:['pmo'],stageCiIds:[]});
const t=await core.enqueueApproved(a,dto);
return {taskId:t.id,state:t.state,version:t.version};
});
}
async claim(a: WorkflowIdentity, dto: EditorialClaimDto) {
this.pmo(a);
return this.db.$transaction(async (tx: any) => {