fix(fleet): bump the M0 queue gate when a draft/queued job is edited

updateDraft changes caps/deps/priority (and body) without a stage change, so it
did not bump fleet_queue_state — gated factories (AQ_FLEET_GATE=1) would not
re-evaluate claimability until the safety interval. Bump the gate on edit so an
edit that makes a job claimable wakes factories promptly.

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
saravanakumardb1 2026-06-01 00:58:45 -07:00
parent 14e982d04f
commit e4c84acf29
2 changed files with 6 additions and 0 deletions

View File

@ -1342,6 +1342,7 @@ describe('fleet coordinator — draft lifecycle (save / edit / submit)', () => {
it('updateDraft edits the prompt + config while draft (content hash changes)', async () => {
const { job } = await coord.submitJob(PID, input({ draft: true }));
const before = (await repo.getJob(job.id, PID))!.contentHash;
const verBefore = await repo.getQueueVersion(PID);
const res = await coord.updateDraft(job.id, PID, {
bodyMd: '# edited prompt',
repo: 'learning_ai_notes',
@ -1357,6 +1358,8 @@ describe('fleet coordinator — draft lifecycle (save / edit / submit)', () => {
expect(res.doc.contentHash).not.toBe(before);
expect(res.doc.stage).toBe('draft'); // editing doesn't submit it
}
// the edit bumps the M0 queue gate so gated factories re-evaluate promptly
expect(await repo.getQueueVersion(PID)).toBeGreaterThan(verBefore);
});
it('submitDraft promotes draft → queued, then it is claimable', async () => {

View File

@ -346,6 +346,9 @@ export async function updateDraft(
const updated = await repo.updateJob(jobId, productId, updates);
if (!updated) return { ok: false, reason: 'not_found' };
// Editing caps/deps/priority changes what's claimable, so bump the M0 gate to
// wake gated factories now instead of waiting for the safety interval.
await repo.bumpQueueVersion(productId);
await repo.appendEvent({
jobId,
productId,