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) => {
@@ -33,7 +33,7 @@ import {
} from "../orchestration/prepare-workflow.service";
import { EditorialProposalBridge, EditorialProposalDto, isEditorialProposal } from "./editorial-bridge";
import { EditorialExecutionService, EditorialClaimDto, EditorialResultDto } from './editorial-execution';
import { EditorialExecutionService, EditorialClaimDto, EditorialQueueDto, EditorialResultDto } from './editorial-execution';
import { admittedTechTask, TECH_PILOT_KIND, techArtifact, validateTechSource } from "./tech-pilot-validator";
// This is reviewed static configuration, not a URL fetched by the transport.
@@ -324,6 +324,9 @@ class WorkerTransportController {
@Get('editorial-proposals/:taskId') editorialStatus(@Req() req: any, @Param('taskId') taskId: string) {
return this.execution.status(req.workerIdentity, taskId);
}
@Post('editorial-queue') editorialQueue(@Req() req: any, @Body() dto: EditorialQueueDto) {
return this.execution.queue(req.workerIdentity, dto);
}
@Post('editorial-claim') editorialClaim(@Req() req: any, @Body() dto: EditorialClaimDto) {
return this.execution.claim(req.workerIdentity, dto);
}