diff --git a/src/resources/extensions/sf/auto-post-unit.js b/src/resources/extensions/sf/auto-post-unit.js index 73fd51458..192c40013 100644 --- a/src/resources/extensions/sf/auto-post-unit.js +++ b/src/resources/extensions/sf/auto-post-unit.js @@ -370,6 +370,7 @@ export async function autoCommitUnit(basePath, unitType, unitId, ctx) { * - "dispatched" — a signal caused stop/pause * - "continue" — proceed normally * - "retry" — artifact verification failed, s.pendingVerificationRetry set for loop re-iteration + * - unexpected execute-task file changes pause autonomy before verification/advance */ export async function postUnitPreVerification(pctx, opts) { const { @@ -979,6 +980,20 @@ export async function postUnitPreVerification(pctx, opts) { dedupe_key: `safety:file-change:${s.currentUnit.id}`, }, ); + if (taskRow.status === "complete") { + updateTaskStatus(sMid, sSid, sTid, "pending", null); + } + ctx.ui.notify( + `Safety: pausing ${s.currentUnit.type} ${s.currentUnit.id} because it changed files outside the task plan.`, + "error", + { + kind: "progress", + source: "safety", + dedupe_key: `safety:file-change-pause:${s.currentUnit.id}`, + }, + ); + await pauseAuto(ctx, pi); + return "dispatched"; } } }