From 96f15b7cf0666e340ccb35e04a4c59dda310ea21 Mon Sep 17 00:00:00 2001 From: Keshav Date: Thu, 19 Nov 2026 07:39:25 -0800 Subject: [PATCH] Self-drive: a mission held in a protected lane waits for a person, no agent blocker task A mission paused for protected-lane-security (or any protected-lane-*) was filed as "get X moving again: protected lane security" and handed to an agent, asking it to undo a hold only a human may lift. handleMissionBlocker and recover's human_blocking flag now share isHumanBlockingReason, which treats every protected-lane-* reason as human-blocking. Co-authored-by: Atris <299057014+atris-builder[bot]@users.noreply.github.com> --- commands/recover.js | 6 ++-- lib/self-drive.js | 11 ++++-- test/self-drive--protected-lane-hold.test.js | 36 ++++++++++++++++++++ 3 files changed, 48 insertions(+), 5 deletions(-) create mode 100644 test/self-drive--protected-lane-hold.test.js diff --git a/commands/recover.js b/commands/recover.js index 619acea16..b28288e15 100644 --- a/commands/recover.js +++ b/commands/recover.js @@ -3,7 +3,7 @@ const fs = require('node:fs'); const path = require('node:path'); const { spawnSync } = require('node:child_process'); -const { reasonClass, HUMAN_BLOCKING_REASONS } = require('../lib/self-drive'); +const { reasonClass, isHumanBlockingReason } = require('../lib/self-drive'); const { missionLockRecords } = require('../lib/loop-doctor'); const { loadMissionMap, @@ -83,7 +83,7 @@ function classifyRecovery(value) { reason, happened: entry.happened, apply: entry.apply, - human_blocking: HUMAN_BLOCKING_REASONS.has(reason), + human_blocking: isHumanBlockingReason(reason), }; } return { @@ -91,7 +91,7 @@ function classifyRecovery(value) { reason, happened: `the mission stopped for "${reason}"`, apply: null, - human_blocking: HUMAN_BLOCKING_REASONS.has(reason), + human_blocking: isHumanBlockingReason(reason), }; } diff --git a/lib/self-drive.js b/lib/self-drive.js index ccbb5a595..1b10997a8 100644 --- a/lib/self-drive.js +++ b/lib/self-drive.js @@ -7,6 +7,13 @@ const { openHumanAsks } = require('./mission-human-asks'); const HUMAN_BLOCKING_REASONS = new Set(['auth-required', 'model-unavailable', 'rate-limit-exceeded-wall']); const OPEN_TASK_STATUSES = new Set(['open', 'claimed', 'review']); +// A mission held in a protected lane (security, money, deploys, a diff that +// needs review) waits for a person by design. Filing an agent task to "get it +// moving again" asks an agent to undo a hold only a human may lift. +function isHumanBlockingReason(reason) { + return HUMAN_BLOCKING_REASONS.has(reason) || /^protected-lane-/.test(String(reason || '')); +} + const SWARLO_HUB = process.env.SWARLO_HUB_URL || process.env.SWARLO_HUB || 'http://localhost:8090'; const SWARLO_HUB_ID = process.env.SWARLO_HUB_ID || 'atris'; const SWARLO_FLEET_TIMEOUT_MS = 3000; @@ -210,7 +217,7 @@ function projectTasks(taskDb, db, workspaceRoot) { function handleMissionBlocker({ mission, stopReason, workspaceRoot, appendEvent }, injected = {}) { if (!mission || !mission.id) return { taskId: null, dispatched: false, engine: null, reason: 'missing mission' }; const blockerClass = reasonClass(stopReason || mission.stop_reason || mission.last_tick_reason); - if (HUMAN_BLOCKING_REASONS.has(blockerClass) || openHumanAsks(mission.human_asks).length) { + if (isHumanBlockingReason(blockerClass) || openHumanAsks(mission.human_asks).length) { return { taskId: null, dispatched: false, engine: null, reason: 'human-blocking' }; } if (['ready', 'complete', 'stopped'].includes(String(mission.status || '').toLowerCase())) { @@ -371,4 +378,4 @@ function handleMissionBlocker({ mission, stopReason, workspaceRoot, appendEvent } } -module.exports = { handleMissionBlocker, reasonClass, HUMAN_BLOCKING_REASONS, loadSwarloApiKey }; +module.exports = { handleMissionBlocker, reasonClass, HUMAN_BLOCKING_REASONS, isHumanBlockingReason, loadSwarloApiKey }; diff --git a/test/self-drive--protected-lane-hold.test.js b/test/self-drive--protected-lane-hold.test.js new file mode 100644 index 000000000..7d086c325 --- /dev/null +++ b/test/self-drive--protected-lane-hold.test.js @@ -0,0 +1,36 @@ +'use strict'; +require('./helpers/clean-temp'); + +const test = require('node:test'); +const assert = require('node:assert/strict'); + +const { handleMissionBlocker, isHumanBlockingReason } = require('../lib/self-drive'); +const { classifyRecovery } = require('../commands/recover'); + +// A mission paused in a protected lane waits for a person. Self-drive used to +// file "get X moving again: protected lane security" and hand it to an agent. +test('a protected-lane pause files no blocker task and dispatches nothing', () => { + for (const reason of ['protected-lane-security', 'protected-lane-billing', 'protected-lane-declared', 'protected-lane-review']) { + const result = handleMissionBlocker({ + mission: { id: 'mission-replay', objective: 'As Replay Lead, find the saved earlier replay', status: 'paused' }, + stopReason: reason, + workspaceRoot: process.cwd(), + }, { + taskDb: { + open: () => { throw new Error('task db must not be opened for a human hold'); }, + }, + resolveEngineForRole: () => { throw new Error('no engine may be picked'); }, + }); + assert.deepEqual(result, { taskId: null, dispatched: false, engine: null, reason: 'human-blocking' }, reason); + } +}); + +test('protected-lane reasons read as human-blocking everywhere, other reasons do not', () => { + assert.equal(isHumanBlockingReason('protected-lane-security'), true); + assert.equal(isHumanBlockingReason('auth-required'), true); + assert.equal(isHumanBlockingReason('repeated-error:runner-failed'), false); + assert.equal(isHumanBlockingReason('lane-security'), false); + assert.equal(isHumanBlockingReason(undefined), false); + assert.equal(classifyRecovery('protected-lane-security').human_blocking, true); + assert.equal(classifyRecovery('protected-lane-security').apply, null); +});