agents-relay 2.0.208 → 2.0.210
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters.js +2 -1
- package/dist/agent-shortcut.js +113 -41
- package/dist/browser-worker-runtime.js +7 -2
- package/dist/chatgpt-platform-fallback.js +30 -0
- package/dist/cli-help.js +10 -4
- package/dist/cli-prompt.js +2 -1
- package/dist/cli-revision.js +49 -0
- package/dist/cli-shortcut-local.js +49 -0
- package/dist/cli-shortcut.js +81 -19
- package/dist/cli-worker-task.js +15 -0
- package/dist/cli.js +19 -5
- package/dist/dashboard-html.js +2 -2
- package/dist/dependency-revision-execution.js +152 -0
- package/dist/dependency-validity.js +17 -0
- package/dist/final-review-role.js +17 -0
- package/dist/force-restate-validation.js +6 -3
- package/dist/job-execution-slot.js +4 -1
- package/dist/job-pr-number-migration.js +2 -1
- package/dist/managed-worker-input.js +2 -1
- package/dist/model-routing.js +8 -0
- package/dist/planner-agent-roles.js +18 -0
- package/dist/planner-runtime.js +7 -1
- package/dist/planner-task-ids.js +1 -0
- package/dist/planner.js +11 -6
- package/dist/reconciler-review.js +110 -109
- package/dist/reconciler-runtime.js +56 -58
- package/dist/reconciler.js +33 -13
- package/dist/relay-job-snapshot-reads.js +5 -2
- package/dist/relay-store.js +2 -0
- package/dist/relay-workflow-operations.js +1 -1
- package/dist/relayd-control.js +31 -0
- package/dist/review-evidence.js +44 -0
- package/dist/review-generation-fence.js +2 -1
- package/dist/review-revision-execution.js +86 -0
- package/dist/review-revision-merge.js +15 -0
- package/dist/review-revision-model.js +191 -0
- package/dist/review-revision-policy.js +49 -0
- package/dist/review-revision-settlement.js +54 -0
- package/dist/review-revision-stale.js +57 -0
- package/dist/reviewer-thread.js +41 -1
- package/dist/runtime-status.js +24 -8
- package/dist/shortcut-node-worker.js +128 -0
- package/dist/shortcut-stage-contract.js +50 -0
- package/dist/shortcut-worker-runner.js +73 -0
- package/dist/single-job-task-control.js +1 -1
- package/dist/task-actions.js +4 -13
- package/dist/task-context.js +3 -2
- package/dist/task-inactivity-watchdog.js +7 -0
- package/dist/terminal-event-recovery.js +13 -0
- package/dist/worker-failure-recovery.js +90 -0
- package/dist/workflow/contracts.js +4 -0
- package/dist/workflow/definitions-v2.js +2 -0
- package/dist/workflow/dependency-revision-v2.js +16 -0
- package/dist/workflow/entity-creation.js +2 -0
- package/dist/workflow/review-v2.js +6 -2
- package/dist/workflow/revision-v2.js +32 -0
- package/dist/workflow/runtime.js +30 -0
- package/dist/workflow/task-reconcile.js +3 -0
- package/dist/workflow/task-resolution.js +1 -4
- package/package.json +4 -3
- package/skills/agents-relay/agents/job-acceptance-reviewer.agent.md +41 -0
- package/skills/agents-relay/agents/planner.agent.md +18 -5
- package/skills/agents-relay/agents/reviewer.agent.md +2 -0
- package/skills/agents-relay/contracts/event-contract.md +7 -0
- package/skills/agents-relay/contracts/orchestrator-workflows.md +6 -0
- package/skills/agents-relay/contracts/task-job-contract.md +10 -0
- package/workflow/dependency-revision.mmd +30 -0
- package/workflow/force-restate-validation.mmd +1 -1
- package/workflow/review-lifecycle.mmd +41 -10
- package/workflow/revision-lifecycle.mmd +68 -0
- package/workflow/task-lifecycle.mmd +13 -12
- package/workflow/task-resolution.mmd +1 -6
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/** Optional project-declared Stage completion gate. Runs after any code/model
|
|
2
|
+
* node reports COMPLETED and before the canonical DAG accepts its result. */
|
|
3
|
+
import { readFile, realpath } from 'node:fs/promises';
|
|
4
|
+
import { resolve, relative, isAbsolute, sep, join } from 'node:path';
|
|
5
|
+
const within = (root, target) => { const rel = relative(root, target); return rel === '' || (rel !== '..' && !rel.startsWith('..' + sep) && !isAbsolute(rel)); };
|
|
6
|
+
export async function validateShortcutStageGate(options) {
|
|
7
|
+
const root = await realpath(options.projectPath);
|
|
8
|
+
let manifest;
|
|
9
|
+
try {
|
|
10
|
+
manifest = JSON.parse(await readFile(join(root, 'project.run.json'), 'utf8'));
|
|
11
|
+
}
|
|
12
|
+
catch (error) {
|
|
13
|
+
if (error.code === 'ENOENT')
|
|
14
|
+
return;
|
|
15
|
+
throw error;
|
|
16
|
+
}
|
|
17
|
+
const config = manifest?.stageValidation;
|
|
18
|
+
if (!config || typeof config !== 'object' || Array.isArray(config))
|
|
19
|
+
return;
|
|
20
|
+
const declaration = config;
|
|
21
|
+
if (!declaration.agents || typeof declaration.agents !== 'object' || Array.isArray(declaration.agents))
|
|
22
|
+
throw new Error('Invalid Stage validator agent mapping');
|
|
23
|
+
const stage = declaration.agents[options.agent];
|
|
24
|
+
if (stage === undefined)
|
|
25
|
+
return;
|
|
26
|
+
if (typeof stage !== 'string' || !/^[-a-z]+$/.test(stage))
|
|
27
|
+
throw new Error('Invalid declared Stage ID');
|
|
28
|
+
const script = declaration.script;
|
|
29
|
+
if (typeof script !== 'string' || !/^scripts\/[a-zA-Z0-9._-]+\.mjs$/.test(script))
|
|
30
|
+
throw new Error('Invalid Stage validator script');
|
|
31
|
+
const file = await realpath(resolve(root, script));
|
|
32
|
+
if (!within(root, file))
|
|
33
|
+
throw new Error('Stage validator escaped project root');
|
|
34
|
+
const run = await realpath(options.runPath);
|
|
35
|
+
if (!within(await realpath(resolve(root, 'runs')), run) || run === root)
|
|
36
|
+
throw new Error('Stage validator run escaped project runs');
|
|
37
|
+
const response = await options.execute([process.execPath, file, stage, run], root);
|
|
38
|
+
let outcome;
|
|
39
|
+
try {
|
|
40
|
+
outcome = JSON.parse(response.stdout);
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
throw new Error('Stage validator did not return a structured contract result');
|
|
44
|
+
}
|
|
45
|
+
const report = outcome;
|
|
46
|
+
if (response.code !== 0 || report.stage !== stage || report.status !== 'PASS' || (Array.isArray(report.errors) && report.errors.length > 0)) {
|
|
47
|
+
const detail = Array.isArray(report.errors) ? JSON.stringify(report.errors).slice(0, 1200) : response.stderr.slice(0, 1200);
|
|
48
|
+
throw new Error('STAGE_CONTRACT_FAILED ' + stage + ': ' + detail);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { dispatchJobLifecycleSync } from './workflow/lifecycle.js';
|
|
2
|
+
/** One foreground owner drives all Worker fallback and Troubleshooter Tasks.
|
|
3
|
+
* No background scheduler may mutate a Shortcut Job. */
|
|
4
|
+
export async function driveShortcutWorkers(options) {
|
|
5
|
+
const { store, jobId, reconciler, taskId } = options;
|
|
6
|
+
if (!store.mutateJob)
|
|
7
|
+
throw new Error('Foreground Worker fallback requires atomic Relay SQLite');
|
|
8
|
+
const initial = await store.mutateJob(jobId, job => {
|
|
9
|
+
if (job.executionMode !== 'shortcut' || job.contentOnly !== true || job.state !== 'ACTIVE')
|
|
10
|
+
throw new Error('Not an active Shortcut Job');
|
|
11
|
+
if (!job.tasks.find(task => task.id === taskId))
|
|
12
|
+
throw new Error('Shortcut parent Task missing');
|
|
13
|
+
const now = Date.now();
|
|
14
|
+
if (!job.shortcutExecutionStartedAt)
|
|
15
|
+
job.shortcutExecutionStartedAt = new Date(now).toISOString();
|
|
16
|
+
const first = Date.parse(job.shortcutExecutionStartedAt);
|
|
17
|
+
if (!Number.isFinite(first))
|
|
18
|
+
throw new Error('Invalid original Shortcut start time');
|
|
19
|
+
const deadline = new Date(first + 20 * 60_000).toISOString();
|
|
20
|
+
if (job.shortcutExecutionDeadlineAt && job.shortcutExecutionDeadlineAt !== deadline)
|
|
21
|
+
throw new Error('Shortcut deadline changed');
|
|
22
|
+
job.shortcutExecutionDeadlineAt = deadline;
|
|
23
|
+
return job;
|
|
24
|
+
});
|
|
25
|
+
const deadline = Date.parse(initial.shortcutExecutionDeadlineAt);
|
|
26
|
+
const last = new Map();
|
|
27
|
+
const stopWatching = await reconciler.watch(jobId);
|
|
28
|
+
const observe = (job) => {
|
|
29
|
+
for (const task of job.tasks) {
|
|
30
|
+
const key = `${task.state}:${task.attempt}:${task.error ?? ''}`;
|
|
31
|
+
if (last.get(task.id) !== key) {
|
|
32
|
+
last.set(task.id, key);
|
|
33
|
+
options.onTask?.(task);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
try {
|
|
38
|
+
while (true) {
|
|
39
|
+
if (options.signal?.aborted)
|
|
40
|
+
return { status: 'INTERRUPTED', job: await store.load(jobId) };
|
|
41
|
+
if (Date.now() >= deadline)
|
|
42
|
+
return { status: 'TIMED_OUT', job: await store.load(jobId) };
|
|
43
|
+
await reconciler.reconcile(jobId);
|
|
44
|
+
let job = await store.load(jobId);
|
|
45
|
+
observe(job);
|
|
46
|
+
if (job.state === 'COMPLETED')
|
|
47
|
+
return { status: 'COMPLETED', job };
|
|
48
|
+
if (job.state === 'CANCELLED')
|
|
49
|
+
return { status: 'FAILED', job };
|
|
50
|
+
if (job.tasks.every(task => task.state === 'SUCCEEDED')) {
|
|
51
|
+
job = await store.mutateJob(jobId, current => {
|
|
52
|
+
if (current.state !== 'ACTIVE' || !current.tasks.length || !current.tasks.every(task => task.state === 'SUCCEEDED')
|
|
53
|
+
|| current.prNumber !== 0 || current.localMerge || current.autoMerge !== false || current.reviewEnabled !== false || current.review || current.plans?.length)
|
|
54
|
+
throw new Error('Shortcut completion requires all durable Tasks and content-only policy');
|
|
55
|
+
const decision = dispatchJobLifecycleSync(current, 'shortcut.completed', { shortcutCompletionAllowed: true });
|
|
56
|
+
if (!decision.accepted || decision.target !== 'COMPLETED')
|
|
57
|
+
throw new Error('Job Graph rejected Shortcut completion');
|
|
58
|
+
return current;
|
|
59
|
+
});
|
|
60
|
+
return { status: 'COMPLETED', job };
|
|
61
|
+
}
|
|
62
|
+
if (job.tasks.some(task => task.state === 'BLOCKED'))
|
|
63
|
+
return { status: 'WAITING_EVENT', job };
|
|
64
|
+
if (job.tasks.some(task => task.agentName === 'troubleshooter' && task.state === 'FAILED' && task.attempt >= task.maxAttempts))
|
|
65
|
+
return { status: 'FAILED', job };
|
|
66
|
+
await new Promise(resolve => setTimeout(resolve, 350));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
finally {
|
|
70
|
+
await stopWatching();
|
|
71
|
+
await reconciler.close();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -17,7 +17,7 @@ export async function createSingleJobTaskControl(jobId, store, reconciler, bus)
|
|
|
17
17
|
unblockTask: unblock.unblockTask,
|
|
18
18
|
publishTaskUnblocked, dispatchTaskAction,
|
|
19
19
|
});
|
|
20
|
-
const allowed = new Set(['task.unblock', 'task.recover', 'task.escalate', 'task.resume-troubleshooter', 'task.classify']);
|
|
20
|
+
const allowed = new Set(['task.unblock', 'task.recover', 'task.escalate', 'task.resume-troubleshooter', 'task.classify', 'task.revise']);
|
|
21
21
|
return async (body) => {
|
|
22
22
|
if (!allowed.has(String(body.command ?? '')))
|
|
23
23
|
throw new Error('Single-Job control command not supported');
|
package/dist/task-actions.js
CHANGED
|
@@ -47,11 +47,6 @@ function clearExecution(task) {
|
|
|
47
47
|
task.leaseExpiresAt = null;
|
|
48
48
|
task.executionId = null;
|
|
49
49
|
}
|
|
50
|
-
function markShortcutWorkerFallback(task) {
|
|
51
|
-
const data = task.result?.data ?? {};
|
|
52
|
-
const shortcut = data.shortcut && typeof data.shortcut === 'object' ? data.shortcut : {};
|
|
53
|
-
task.result = { summary: task.result?.summary ?? 'Troubleshooter selected original Worker recovery', data: { ...data, shortcut: { ...shortcut, workerFallback: true } } };
|
|
54
|
-
}
|
|
55
50
|
function applyTaskRetrySnapshot(task, policy = {}) {
|
|
56
51
|
if (task.kind === 'planner')
|
|
57
52
|
throw new Error(`Legacy planner Task ${task.id} is read-only; retry the Plan instead`);
|
|
@@ -227,11 +222,9 @@ export async function dispatchTaskAction(store, request) {
|
|
|
227
222
|
if (!recovery.executionId)
|
|
228
223
|
throw new Error(`Troubleshooter ${recovery.id} has no current execution for a fresh resolution`);
|
|
229
224
|
const proposal = { path: 'exact_original_retry', targetTaskId: task.id, recoveryExecutionId: recovery.executionId, rootCause: task.failureReason ?? task.error ?? 'durable failure', solution: `Recover exact original Task via ${request.recoveryTaskId}` };
|
|
230
|
-
const activateRecovery = (
|
|
231
|
-
markShortcutWorkerFallback(task); recordRecoveryRouting(task, request); task.resolution = { ...materializeResolution(task, proposal, 'troubleshooter'), state: 'resolved' }; };
|
|
225
|
+
const activateRecovery = () => { applyTaskRetrySnapshot(task, { extendBudget: true }); recordRecoveryRouting(task, request); task.resolution = { ...materializeResolution(task, proposal, 'troubleshooter'), state: 'resolved' }; };
|
|
232
226
|
const decision = dispatchTaskResolutionSync(task, proposal, 'troubleshooter', {
|
|
233
|
-
activateRecovery
|
|
234
|
-
activateShortcutWorkerFallback: () => activateRecovery(true),
|
|
227
|
+
activateRecovery,
|
|
235
228
|
});
|
|
236
229
|
if (!decision.accepted)
|
|
237
230
|
throw new Error(`Task resolution graph rejected exact-original recovery for ${task.id}`);
|
|
@@ -268,11 +261,9 @@ export async function dispatchTaskAction(store, request) {
|
|
|
268
261
|
if (!recovery.executionId)
|
|
269
262
|
throw new Error(`Troubleshooter ${recovery.id} has no current execution for a fresh resolution`);
|
|
270
263
|
const proposal = { path: 'exact_original_retry', targetTaskId: task.id, recoveryExecutionId: recovery.executionId, rootCause: task.failureReason ?? task.error ?? 'durable failure', solution: `Recover exact original Task via ${request.recoveryTaskId}` };
|
|
271
|
-
const activateRecovery = (
|
|
272
|
-
markShortcutWorkerFallback(task); recordRecoveryRouting(task, request); task.resolution = { ...materializeResolution(task, proposal, 'troubleshooter'), state: 'resolved' }; };
|
|
264
|
+
const activateRecovery = () => { applyTaskRetrySnapshot(task, { extendBudget: true }); recordRecoveryRouting(task, request); task.resolution = { ...materializeResolution(task, proposal, 'troubleshooter'), state: 'resolved' }; };
|
|
273
265
|
const decision = dispatchTaskResolutionSync(task, proposal, 'troubleshooter', {
|
|
274
|
-
activateRecovery
|
|
275
|
-
activateShortcutWorkerFallback: () => activateRecovery(true),
|
|
266
|
+
activateRecovery,
|
|
276
267
|
});
|
|
277
268
|
if (!decision.accepted)
|
|
278
269
|
throw new Error(`Task resolution graph rejected exact-original recovery for ${task.id}`);
|
package/dist/task-context.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isFinalReviewAgent } from './final-review-role.js';
|
|
1
2
|
/** Resolve the execution-scoped contract from the authoritative Job snapshot. */
|
|
2
3
|
export function taskExecutionContext(job, taskId, executionId) {
|
|
3
4
|
if (!executionId)
|
|
@@ -9,7 +10,7 @@ export function taskExecutionContext(job, taskId, executionId) {
|
|
|
9
10
|
throw new Error(`Stale Task execution ${taskId}/${executionId}; current state ${task.state}`);
|
|
10
11
|
const relevant = task.agentName === 'troubleshooter'
|
|
11
12
|
? job.tasks.filter(item => item.id === task.parentTaskId)
|
|
12
|
-
: task.agentName
|
|
13
|
+
: isFinalReviewAgent(task.agentName) ? task.dependencies.map(id => job.tasks.find(item => item.id === id)).filter((item) => Boolean(item)) : [];
|
|
13
14
|
return { job: { id: job.id, repository: job.repository, title: job.title, objective: job.objective,
|
|
14
15
|
projectPath: job.projectPath, state: job.state }, task, currentState: task.state, resolution: task.resolution ?? null, escalation: task.escalation ?? null,
|
|
15
16
|
comments: task.comments ?? [], relevantTasks: relevant.map(item => ({ id: item.id, title: item.title, state: item.state, attempt: item.attempt, executionId: item.executionId, resolution: item.resolution ?? null, escalation: item.escalation ?? null, comments: item.comments ?? [], result: item.result, error: item.error, failureReason: item.failureReason })),
|
|
@@ -18,7 +19,7 @@ export function taskExecutionContext(job, taskId, executionId) {
|
|
|
18
19
|
}
|
|
19
20
|
/** Runtime-only task history; durable task.input remains the stable objective. */
|
|
20
21
|
export function taskAgentHistoryContext(job, task) {
|
|
21
|
-
if (task.agentName !== 'troubleshooter' && task.agentName
|
|
22
|
+
if (task.agentName !== 'troubleshooter' && !isFinalReviewAgent(task.agentName))
|
|
22
23
|
return '';
|
|
23
24
|
const related = task.agentName === 'troubleshooter'
|
|
24
25
|
? job.tasks.filter(item => item.id === task.parentTaskId)
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { executionEventSource, eventSourceId } from './execution-event-identity.js';
|
|
2
|
+
/** A foreground Shortcut Graph parent is not a Worker: its elapsed budget
|
|
3
|
+
* belongs to the direct runner. Real Worker child Tasks keep standard timeouts. */
|
|
4
|
+
export function requiresWorkerInactivityWatchdog(job, task) {
|
|
5
|
+
const shortcut = task.result?.data?.shortcut;
|
|
6
|
+
return !(job.executionMode === 'shortcut' && job.contentOnly === true
|
|
7
|
+
&& Boolean(task.agentGraph) && shortcut?.workerFallback !== true);
|
|
8
|
+
}
|
|
2
9
|
export function isRecoverableWatchdogFailure(task) {
|
|
3
10
|
if (['worker_start_timeout', 'terminal_event_timeout', 'worker_exit_before_start', 'worker_exit_without_terminal_event', 'worker_delivery_after_start'].includes(task.failureReason ?? ''))
|
|
4
11
|
return true;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Shared, adapter-neutral terminal-event recovery policy.
|
|
2
|
+
* A recovery turn is not a Task retry, progress event, or completion proof.
|
|
3
|
+
* Only an existing resumable conversation for the ORIGINAL execution qualifies.
|
|
4
|
+
*/
|
|
5
|
+
export const MAX_TERMINAL_RECOVERY_TURNS = 1;
|
|
6
|
+
export function terminalRecoveryEligible(facts) {
|
|
7
|
+
return facts.hasSession && facts.hasThread && !facts.terminalObserved
|
|
8
|
+
&& !facts.outcomeUncertain && !facts.cancelled
|
|
9
|
+
&& facts.recoveryAttempts < MAX_TERMINAL_RECOVERY_TURNS;
|
|
10
|
+
}
|
|
11
|
+
export function terminalRecoveryPrompt(executionId) {
|
|
12
|
+
return `[Relay terminal-event recovery: ${executionId}]\nThis is ONE reminder for the ORIGINAL Task execution, not a new task or authorization to restart work. Inspect the authoritative Task context, Neo event history, and actual output. If a correlated terminal event already exists, do not publish a duplicate. If work is complete with verified evidence, publish task.completed with the ORIGINAL execution identity. If unfinished or unverified, publish task.failed with the real reason; do not claim success. Follow the canonical event contract. Do not emit task.progress merely because this reminder arrived.`;
|
|
13
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { isFinalReviewAgent } from './final-review-role.js';
|
|
2
|
+
import { hasSafeAlternativeWorker } from './browser-worker-routing.js';
|
|
3
|
+
import { codexNoStartFallbackRoute, persistChatGptPlatformFailure } from './chatgpt-platform-fallback.js';
|
|
4
|
+
import { classifyChatGptPlatformFailure } from './worker-rejection.js';
|
|
5
|
+
import { recordLaunchRouteOutcome } from './route-outcome-recording.js';
|
|
6
|
+
import { eventFor } from './events.js';
|
|
7
|
+
export async function handleWorkerLaunchFailure(ports, jobId, taskId, executionId, failure, phase = 'launch') {
|
|
8
|
+
const message = failure instanceof Error ? failure.message : String(failure);
|
|
9
|
+
const currentJob = await ports.store.load(jobId);
|
|
10
|
+
const currentTask = currentJob.tasks.find(task => task.id === taskId);
|
|
11
|
+
const agents = await ports.store.listAgents();
|
|
12
|
+
const usage = ports.usageSnapshotProvider ? await ports.usageSnapshotProvider() : undefined;
|
|
13
|
+
const alternative = hasSafeAlternativeWorker(currentTask, ports.adapters, agents, usage);
|
|
14
|
+
const activeExecution = ports.live(taskId);
|
|
15
|
+
const noStarted = currentTask?.state === 'QUEUED'
|
|
16
|
+
&& currentTask.executionId === executionId
|
|
17
|
+
&& !currentTask.lastProgressEventAt
|
|
18
|
+
&& !activeExecution?.workerStarted;
|
|
19
|
+
const canRetryNoStart = noStarted && currentJob.executionMode !== 'shortcut'
|
|
20
|
+
&& (currentTask?.adapter === 'chatgpt' || currentTask?.adapter === 'z')
|
|
21
|
+
&& !isFinalReviewAgent(currentTask.agentName)
|
|
22
|
+
&& currentTask.agentName !== 'troubleshooter' && currentTask.kind !== 'planner'
|
|
23
|
+
&& !currentTask.noStartFallback && currentTask.attempt < currentTask.maxAttempts;
|
|
24
|
+
const codexFallback = canRetryNoStart
|
|
25
|
+
? await codexNoStartFallbackRoute(currentTask, ports.adapters, agents, usage)
|
|
26
|
+
: null;
|
|
27
|
+
const noStartFallbackAllowed = Boolean(canRetryNoStart && codexFallback);
|
|
28
|
+
const platformFailure = (currentTask?.adapter === 'chatgpt' || currentTask?.adapter === 'z')
|
|
29
|
+
? classifyChatGptPlatformFailure(failure, phase === 'process' || phase === 'terminal' ? 'delivery' : phase)
|
|
30
|
+
: undefined;
|
|
31
|
+
const unknownOutcome = phase === 'start-ack' || ['outcome_unknown', 'start_ack_timeout'].includes(platformFailure?.classification ?? '')
|
|
32
|
+
|| (phase === 'launch' && activeExecution?.executionId === executionId)
|
|
33
|
+
|| (phase === 'delivery' && activeExecution?.executionId === executionId && activeExecution.workerStarted);
|
|
34
|
+
const failureReason = phase === 'start-ack' ? 'worker_start_timeout'
|
|
35
|
+
: /WEBHELM_UNAVAILABLE|webhelm runtime dependency unavailable|webhelm session start returned no session_id|no close frame received or sent/i.test(message)
|
|
36
|
+
? 'browser_workspace_unavailable'
|
|
37
|
+
: undefined;
|
|
38
|
+
const claim = executionId ?? `${jobId}:${taskId}`;
|
|
39
|
+
if (ports.launchFailureClaims.has(claim))
|
|
40
|
+
return;
|
|
41
|
+
ports.launchFailureClaims.add(claim);
|
|
42
|
+
const cleanup = setTimeout(() => ports.launchFailureClaims.delete(claim), 60000);
|
|
43
|
+
cleanup.unref();
|
|
44
|
+
const workflowEvent = noStartFallbackAllowed ? 'worker.no_start_failed'
|
|
45
|
+
: platformFailure ? 'worker.platform_failure'
|
|
46
|
+
: phase === 'start-ack' ? 'worker.start_ack_failed' : 'worker.delivery_failed';
|
|
47
|
+
const transition = await ports.taskTransitions.apply(jobId, taskId, workflowEvent, {
|
|
48
|
+
eligible: (_job, task) => task.executionId === executionId,
|
|
49
|
+
facts: () => ({
|
|
50
|
+
platformFallbackSafe: platformFailure?.safeToReroute === true && alternative,
|
|
51
|
+
noStartFallbackAllowed: noStartFallbackAllowed && !currentTask?.noStartFallback,
|
|
52
|
+
}),
|
|
53
|
+
mutate: (_job, task, decision) => {
|
|
54
|
+
if (platformFailure && workflowEvent !== 'worker.no_start_failed')
|
|
55
|
+
persistChatGptPlatformFailure(task, currentTask, executionId, platformFailure.classification, platformFailure.evidence, platformFailure.safeToReroute);
|
|
56
|
+
if (workflowEvent === 'worker.no_start_failed' && task.noStartFallback)
|
|
57
|
+
task.noStartFallback.reason = message;
|
|
58
|
+
task.error = decision.target === 'QUEUED' ? null : `Worker ${phase} failed: ${message}`;
|
|
59
|
+
task.failureReason = decision.target === 'QUEUED' ? undefined : unknownOutcome
|
|
60
|
+
? 'worker_outcome_unknown' : platformFailure ? 'worker_platform_failure' : failureReason;
|
|
61
|
+
task.leaseOwner = null;
|
|
62
|
+
task.leaseExpiresAt = null;
|
|
63
|
+
task.executionId = null;
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
if (!transition)
|
|
67
|
+
return;
|
|
68
|
+
if (!transition.decision.accepted) {
|
|
69
|
+
await ports.emit(eventFor(jobId, taskId, transition.task.parentTaskId, 'task.process.delivery_failed', 'failed', `Worker ${phase} reported after lifecycle moved to ${transition.from}: ${message}`, 'orchestrator', { phase, authoritative: false, executionId, workflowEvent }, { agent: 'relay', component: 'agents-relay' }));
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
await recordLaunchRouteOutcome(ports.decisionAuditStore, currentTask ?? transition.task, message, phase === 'process' || phase === 'terminal' ? 'delivery' : phase, executionId, unknownOutcome);
|
|
73
|
+
if (executionId) {
|
|
74
|
+
const live = ports.live(taskId);
|
|
75
|
+
if (live?.executionId === executionId) {
|
|
76
|
+
live.controller.abort();
|
|
77
|
+
live.execution.cancel();
|
|
78
|
+
ports.clearExecution(taskId, executionId);
|
|
79
|
+
}
|
|
80
|
+
// Browser after-terminal waits must not outlive this failed generation:
|
|
81
|
+
// otherwise they could reject a legitimate terminal event from Codex.
|
|
82
|
+
ports.clearTerminalWaiter(taskId, executionId);
|
|
83
|
+
}
|
|
84
|
+
const event = eventFor(jobId, taskId, transition.task.parentTaskId, transition.task.state === 'QUEUED' && workflowEvent === 'worker.no_start_failed'
|
|
85
|
+
? 'worker.no_start_fallback' : transition.task.state === 'QUEUED' ? 'worker.pre_submission_rejected' : 'task.failed', transition.task.state === 'QUEUED' ? 'queued' : 'failed', transition.task.error ?? `Worker ${phase} failed: ${message}`, 'user', { phase, reason: transition.task.failureReason ?? failureReason, workflowEvent,
|
|
86
|
+
...(transition.task.noStartFallback ? { noStartFallback: transition.task.noStartFallback } : {}),
|
|
87
|
+
...(transition.task.platformFailure ? { platformFailure: transition.task.platformFailure } : {}) }, { agent: 'relay', component: 'agents-relay', watchdog: true });
|
|
88
|
+
ports.detach(ports.emit(event), jobId, taskId, 'worker failure event');
|
|
89
|
+
ports.wake(jobId, taskId, `worker-${phase}-failure`);
|
|
90
|
+
}
|
|
@@ -50,6 +50,7 @@ export const WORKFLOW_EVENT_NAMES = [
|
|
|
50
50
|
'worker.delivery_failed',
|
|
51
51
|
'worker.start_ack_failed',
|
|
52
52
|
'worker.platform_failure',
|
|
53
|
+
'worker.no_start_failed',
|
|
53
54
|
];
|
|
54
55
|
export const WORKFLOW_FACT_NAMES = [
|
|
55
56
|
'dependenciesSatisfied',
|
|
@@ -59,6 +60,7 @@ export const WORKFLOW_FACT_NAMES = [
|
|
|
59
60
|
'shortcutExecution',
|
|
60
61
|
'shortcutFallback',
|
|
61
62
|
'shortcutHasGraph',
|
|
63
|
+
'shortcutDirectInvocation',
|
|
62
64
|
'shortcutEffectsSafe',
|
|
63
65
|
'shortcutResultCorrelated',
|
|
64
66
|
'notMerged',
|
|
@@ -74,6 +76,7 @@ export const WORKFLOW_FACT_NAMES = [
|
|
|
74
76
|
'headAvailable',
|
|
75
77
|
'mergeCapable',
|
|
76
78
|
'platformFallbackSafe',
|
|
79
|
+
'noStartFallbackAllowed',
|
|
77
80
|
];
|
|
78
81
|
export const WORKFLOW_MUTATION_NAMES = [
|
|
79
82
|
'mutation.clearError',
|
|
@@ -87,6 +90,7 @@ export const WORKFLOW_MUTATION_NAMES = [
|
|
|
87
90
|
'mutation.markShortcutWorkerFallback',
|
|
88
91
|
'mutation.markShortcutRecoveryRequired',
|
|
89
92
|
'mutation.preparePlatformFallback',
|
|
93
|
+
'mutation.prepareNoStartFallback',
|
|
90
94
|
'mutation.quarantinePlatformFailure',
|
|
91
95
|
];
|
|
92
96
|
export const WORKFLOW_EFFECT_NAMES = [
|
|
@@ -32,6 +32,7 @@ export const taskLifecycleV2 = load('task-lifecycle', TASK_STATES, {
|
|
|
32
32
|
shortcutExecution: facts => facts.durableFacts.shortcutExecution === true,
|
|
33
33
|
shortcutFallback: facts => facts.durableFacts.shortcutFallback === true,
|
|
34
34
|
shortcutHasGraph: facts => facts.durableFacts.shortcutHasGraph === true,
|
|
35
|
+
shortcutDirectInvocation: facts => facts.durableFacts.shortcutDirectInvocation === true,
|
|
35
36
|
shortcutEffectsSafe: facts => facts.durableFacts.shortcutEffectsSafe === true,
|
|
36
37
|
shortcutResultCorrelated: facts => facts.durableFacts.shortcutResultCorrelated === true,
|
|
37
38
|
recoverableExecution: boolGuard('recoverableExecution'),
|
|
@@ -40,6 +41,7 @@ export const taskLifecycleV2 = load('task-lifecycle', TASK_STATES, {
|
|
|
40
41
|
awaitingInteractiveDecision: facts => facts.durableFacts.awaitingInteractiveDecision === true,
|
|
41
42
|
retryAvailable: boolGuard('retryAvailable'),
|
|
42
43
|
platformFallbackSafe: facts => facts.durableFacts.platformFallbackSafe === true,
|
|
44
|
+
noStartFallbackAllowed: facts => facts.durableFacts.noStartFallbackAllowed === true,
|
|
43
45
|
});
|
|
44
46
|
export const jobLifecycleV2 = load('job-lifecycle', JOB_STATES, {
|
|
45
47
|
notMerged: boolGuard('notMerged'),
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { GraphRuntime } from './graph-v2.js';
|
|
3
|
+
import { dispatchWorkflowGraphSync } from './dispatcher.js';
|
|
4
|
+
const boolGuard = (key) => (context) => context.durableFacts[key] === true;
|
|
5
|
+
export const dependencyRevisionLifecycle = new GraphRuntime(readFileSync(new URL('../../workflow/dependency-revision.mmd', import.meta.url), 'utf8'), {
|
|
6
|
+
states: new Set(['NONE', 'PROPOSED', 'VERIFIED', 'STALE']),
|
|
7
|
+
guards: Object.fromEntries(['upstreamEvidenceChanged', 'explicitValidityPolicy', 'allInputsSettled', 'notAlreadyRecorded', 'rerunRequired'].map(key => [key, boolGuard(key)])),
|
|
8
|
+
actions: { 'dependencyRevision.createRerun': { id: 'dependencyRevision.createRerun' }, 'dependencyRevision.createRevalidation': { id: 'dependencyRevision.createRevalidation' }, 'dependencyRevision.markStale': { id: 'dependencyRevision.markStale' } },
|
|
9
|
+
events: { 'dependency.reconcile': { id: 'dependency.reconcile' }, 'dependency.verified': { id: 'dependency.verified' }, 'dependency.stale': { id: 'dependency.stale' } },
|
|
10
|
+
});
|
|
11
|
+
export function decideDependencyRevision(event, facts = {}, state = 'NONE') {
|
|
12
|
+
return dispatchWorkflowGraphSync(dependencyRevisionLifecycle, {
|
|
13
|
+
graphName: 'dependency-revision', initialState: state,
|
|
14
|
+
input: { transport: 'event', id: event, payload: {} }, durableFacts: facts,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { dispatchJobLifecycleSync, dispatchTaskLifecycleSync } from './lifecycle.js';
|
|
2
2
|
import { deriveTaskTitle } from '../task-title.js';
|
|
3
|
+
import { validateDependencyValidity } from '../dependency-validity.js';
|
|
3
4
|
function dependenciesSatisfied(job, dependencies) {
|
|
4
5
|
if (dependencies.length === 0)
|
|
5
6
|
return true;
|
|
@@ -13,6 +14,7 @@ function validateTaskRequirements(value) {
|
|
|
13
14
|
if (value.workerRequirements && !Array.isArray(value.workerRequirements.capabilities)) {
|
|
14
15
|
throw new Error(`Task ${value.id} workerRequirements.capabilities must be an array`);
|
|
15
16
|
}
|
|
17
|
+
validateDependencyValidity(value.dependencies, value.dependencyValidity, `Task ${value.id} dependencyValidity`);
|
|
16
18
|
}
|
|
17
19
|
/**
|
|
18
20
|
* Canonical creation boundary for new Task entities.
|
|
@@ -17,9 +17,13 @@ export const reviewLifecycleV2 = new GraphRuntime(source, {
|
|
|
17
17
|
noApprovedCurrentReview: boolGuard('noApprovedCurrentReview'),
|
|
18
18
|
autoMerge: boolGuard('autoMerge'),
|
|
19
19
|
reviewUnblocked: boolGuard('reviewUnblocked'),
|
|
20
|
+
targetedRevisionRequestsReady: boolGuard('targetedRevisionRequestsReady'),
|
|
21
|
+
targetedRevisionsVerified: boolGuard('targetedRevisionsVerified'),
|
|
22
|
+
reviewRoundWithinLimit: boolGuard('reviewRoundWithinLimit'),
|
|
23
|
+
reviewNoProgressWithinLimit: boolGuard('reviewNoProgressWithinLimit'),
|
|
20
24
|
},
|
|
21
|
-
actions: Object.fromEntries(['review.create', 'review.cancelStale', 'review.
|
|
22
|
-
events: Object.fromEntries(['reconcile', 'review.started', 'review.approved', 'review.changes_required', 'review.legacy_blocked', 'review.retry', 'head.changed'].map(id => [id, { id }])),
|
|
25
|
+
actions: Object.fromEntries(['review.create', 'review.cancelStale', 'review.awaitTargetedRevisions', 'review.requireOwnerResolution', 'review.requestMerge', 'review.prepareRereview'].map(id => [id, { id }])),
|
|
26
|
+
events: Object.fromEntries(['reconcile', 'review.started', 'review.approved', 'review.changes_required', 'review.legacy_blocked', 'review.retry', 'head.changed', 'revision.settled'].map(id => [id, { id }])),
|
|
23
27
|
});
|
|
24
28
|
export function reviewGraphState(outcome) {
|
|
25
29
|
if (!outcome)
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { GraphRuntime } from './graph-v2.js';
|
|
3
|
+
import { dispatchWorkflowGraph, dispatchWorkflowGraphSync } from './dispatcher.js';
|
|
4
|
+
const source = readFileSync(new URL('../../workflow/revision-lifecycle.mmd', import.meta.url), 'utf8');
|
|
5
|
+
const boolGuard = (name) => (context) => context.durableFacts[name] === true;
|
|
6
|
+
export const revisionLifecycle = new GraphRuntime(source, {
|
|
7
|
+
states: new Set(['NONE', 'REQUESTED', 'QUEUED', 'RUNNING', 'VERIFIED', 'FAILED', 'STALE']),
|
|
8
|
+
guards: {
|
|
9
|
+
reviewerAuthorized: boolGuard('reviewerAuthorized'),
|
|
10
|
+
reviewHeadCurrent: boolGuard('reviewHeadCurrent'),
|
|
11
|
+
originalTaskSucceeded: boolGuard('originalTaskSucceeded'),
|
|
12
|
+
changesRequiredRecorded: boolGuard('changesRequiredRecorded'),
|
|
13
|
+
taskRetryQueued: boolGuard('taskRetryQueued'),
|
|
14
|
+
},
|
|
15
|
+
actions: Object.fromEntries([
|
|
16
|
+
'revision.recordRequest', 'revision.queueTask', 'revision.recordVerified',
|
|
17
|
+
'revision.recordFailed', 'revision.markStale',
|
|
18
|
+
].map(id => [id, { id }])),
|
|
19
|
+
events: Object.fromEntries([
|
|
20
|
+
'revision.submit', 'revision.queue', 'revision.started', 'revision.verified',
|
|
21
|
+
'revision.failed', 'revision.retry', 'review.head_changed', 'review.execution_changed',
|
|
22
|
+
].map(id => [id, { id }])),
|
|
23
|
+
});
|
|
24
|
+
function args(state, event, facts) {
|
|
25
|
+
return { initialState: state, input: { transport: 'event', id: event, payload: {} }, durableFacts: facts, graphName: 'revision-lifecycle' };
|
|
26
|
+
}
|
|
27
|
+
export function decideRevisionLifecycle(state, event, facts = {}) {
|
|
28
|
+
return dispatchWorkflowGraphSync(revisionLifecycle, args(state, event, facts));
|
|
29
|
+
}
|
|
30
|
+
export async function dispatchRevisionLifecycle(state, event, facts = {}, executeAction) {
|
|
31
|
+
return dispatchWorkflowGraph(revisionLifecycle, { ...args(state, event, facts), executeAction });
|
|
32
|
+
}
|
package/dist/workflow/runtime.js
CHANGED
|
@@ -47,6 +47,36 @@ export function applyTaskMutation(task, mutation) {
|
|
|
47
47
|
if (mutation === 'mutation.markShortcutRecoveryRequired') {
|
|
48
48
|
task.failureReason = 'shortcut_requires_recovery';
|
|
49
49
|
}
|
|
50
|
+
if (mutation === 'mutation.prepareNoStartFallback') {
|
|
51
|
+
const route = task.routing;
|
|
52
|
+
if (task.adapter !== 'chatgpt' && task.adapter !== 'z')
|
|
53
|
+
throw new Error('No-start fallback is only legal for ChatGPT/Z Workers');
|
|
54
|
+
const originalAdapter = task.adapter;
|
|
55
|
+
const workerId = task.workerSelection?.workerId ?? originalAdapter;
|
|
56
|
+
const failedAt = new Date().toISOString();
|
|
57
|
+
task.noStartFallback = {
|
|
58
|
+
failedExecutionId: task.executionId ?? 'missing',
|
|
59
|
+
failedAttempt: task.attempt,
|
|
60
|
+
previous: { adapter: originalAdapter, workerId,
|
|
61
|
+
provider: route?.provider ?? 'unknown', model: route?.model ?? 'unknown',
|
|
62
|
+
...(route?.profile ? { profile: route.profile } : {}) },
|
|
63
|
+
reason: task.error ?? 'Worker failed without an accepted task.started event',
|
|
64
|
+
at: failedAt,
|
|
65
|
+
};
|
|
66
|
+
task.routingExclusions = [...(task.routingExclusions ?? []), {
|
|
67
|
+
adapter: originalAdapter, workerId, provider: route?.provider ?? 'unknown',
|
|
68
|
+
model: route?.model ?? 'unknown',
|
|
69
|
+
...(route?.profile ? { profile: route.profile } : {}),
|
|
70
|
+
reason: 'no_started_event', at: failedAt,
|
|
71
|
+
}];
|
|
72
|
+
task.error = null;
|
|
73
|
+
task.failureReason = undefined;
|
|
74
|
+
task.routing = undefined;
|
|
75
|
+
task.workerSelection = undefined;
|
|
76
|
+
task.leaseOwner = null;
|
|
77
|
+
task.leaseExpiresAt = null;
|
|
78
|
+
task.executionId = null;
|
|
79
|
+
}
|
|
50
80
|
if (mutation === 'mutation.preparePlatformFallback') {
|
|
51
81
|
task.error = null;
|
|
52
82
|
task.failureReason = undefined;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { revisionRequestReady } from '../review-revision-execution.js';
|
|
1
2
|
import { dispatchTaskLifecycleSync } from './lifecycle.js';
|
|
2
3
|
export function dependencyReady(task, tasks) {
|
|
3
4
|
return task.dependencies.every(id => tasks.get(id)?.state === 'SUCCEEDED');
|
|
@@ -27,6 +28,8 @@ export function reconcileTaskDependencies(job) {
|
|
|
27
28
|
for (const task of scopedTasks) {
|
|
28
29
|
if (task.kind === 'planner')
|
|
29
30
|
continue;
|
|
31
|
+
if (!revisionRequestReady(job, task))
|
|
32
|
+
continue;
|
|
30
33
|
if (task.state === 'DRAFT' && task.unblock)
|
|
31
34
|
continue;
|
|
32
35
|
const ready = dependencyReady(task, tasks);
|
|
@@ -11,7 +11,6 @@ export const taskResolutionV2 = new GraphRuntime(source, {
|
|
|
11
11
|
guards: {
|
|
12
12
|
recoveryOwnerAvailable: boolGuard('recoveryOwnerAvailable'), plannerOwnerAvailable: boolGuard('plannerOwnerAvailable'),
|
|
13
13
|
exactOriginalRetry: boolGuard('exactOriginalRetry'), sameJobDependency: boolGuard('sameJobDependency'),
|
|
14
|
-
shortcutInterrupted: boolGuard('shortcutInterrupted'),
|
|
15
14
|
blockerJobDependency: boolGuard('blockerJobDependency'), escalationGate: boolGuard('escalationGate'), genuinelyObsolete: boolGuard('genuinelyObsolete'),
|
|
16
15
|
freshRecoveryExecution: boolGuard('freshRecoveryExecution'),
|
|
17
16
|
classifiableFailure: boolGuard('classifiableFailure'),
|
|
@@ -65,9 +64,7 @@ export function validateResolutionProposal(job, original, proposal) {
|
|
|
65
64
|
export function resolutionFacts(task, proposal, owner) {
|
|
66
65
|
const freshRecoveryExecution = owner !== 'troubleshooter' || proposal.path !== 'exact_original_retry' || (Boolean(proposal.recoveryExecutionId)
|
|
67
66
|
&& proposal.recoveryExecutionId !== task.resolution?.recoveryExecutionId);
|
|
68
|
-
|
|
69
|
-
const shortcutInterrupted = owner === 'troubleshooter' && Boolean(shortcut && typeof shortcut === 'object' && Object.keys(shortcut.inFlight ?? {}).length > 0);
|
|
70
|
-
return { recoveryOwnerAvailable: owner === 'troubleshooter', plannerOwnerAvailable: owner !== null && owner !== 'troubleshooter', exactOriginalRetry: proposal.path === 'exact_original_retry' && task.state === 'FAILED', shortcutInterrupted, sameJobDependency: proposal.path === 'same_job_dependency' && owner !== null && proposal.targetTaskId !== task.id, blockerJobDependency: proposal.path === 'blocker_job_dependency' && owner !== null && Boolean(proposal.targetJobId && proposal.mode), escalationGate: proposal.path === 'escalation_gate' && owner === 'troubleshooter' && Boolean(proposal.rootCause && proposal.solution), genuinelyObsolete: proposal.path === 'cancel_supersede' && Boolean(proposal.rootCause), freshRecoveryExecution, unresolved: unresolvedTask(task) };
|
|
67
|
+
return { recoveryOwnerAvailable: owner === 'troubleshooter', plannerOwnerAvailable: owner !== null && owner !== 'troubleshooter', exactOriginalRetry: proposal.path === 'exact_original_retry' && task.state === 'FAILED', sameJobDependency: proposal.path === 'same_job_dependency' && owner !== null && proposal.targetTaskId !== task.id, blockerJobDependency: proposal.path === 'blocker_job_dependency' && owner !== null && Boolean(proposal.targetJobId && proposal.mode), escalationGate: proposal.path === 'escalation_gate' && owner === 'troubleshooter' && Boolean(proposal.rootCause && proposal.solution), genuinelyObsolete: proposal.path === 'cancel_supersede' && Boolean(proposal.rootCause), freshRecoveryExecution, unresolved: unresolvedTask(task) };
|
|
71
68
|
}
|
|
72
69
|
export function decideTaskResolution(task, proposal, owner) {
|
|
73
70
|
return checkedResolutionDecision(dispatchWorkflowGraphSync(taskResolutionV2, { initialState: 'unresolved', input: { transport: 'event', id: 'resolution.propose', payload: proposal }, durableFacts: resolutionFacts(task, proposal, owner), graphName: 'task-resolution', isTransientState: state => ['check_owner', 'check_path', 'check_fresh_execution'].includes(state), maxSteps: 8 }));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agents-relay",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.210",
|
|
4
4
|
"description": "Durable async agent jobs coordinated through GitHub pull requests",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -17,8 +17,9 @@
|
|
|
17
17
|
"test:chatgpt-temp-quality": "AGENTS_RELAY_RUN_CHATGPT_TEMP_QUALITY=1 sh -c \"npm run build && node test/quality/run-temporary-chat.mjs\"",
|
|
18
18
|
"dev": "tsx src/cli.ts",
|
|
19
19
|
"test:publish": "npm run build && node --import ./test/test-store-env.mjs --test --test-concurrency=1 --test-force-exit test/*.test.js",
|
|
20
|
-
"test:
|
|
21
|
-
"test:
|
|
20
|
+
"test:shortcut:dags": "npm run build && node --import ./test/test-store-env.mjs --test --test-concurrency=1 test/verification/shortcut-dag-matrix.test.mjs test/agent-shortcut.test.js",
|
|
21
|
+
"test:fast": "npm run build && node --import ./test/test-store-env.mjs --test --test-concurrency=2 test/workflow-lifecycle.test.js test/workflow-v2-lifecycle-parity.test.js test/workflow-effects.test.js test/relay-store.test.js test/local-authority.test.js test/local-jobid-routing.test.js test/local-sqlite-jobid.test.js test/no-github.test.js test/reconcile-coordinator.test.js test/service-publication.test.js test/github-webhook.test.js test/verification/shortcut-dag-matrix.test.mjs",
|
|
22
|
+
"test:full": "npm run build && node --import ./test/test-store-env.mjs --test --test-concurrency=1 test/*.test.js test/verification/shortcut-dag-matrix.test.mjs && npm run test:verification:l3",
|
|
22
23
|
"test:verification:l1": "npm run build && node --test test/verification/harness.test.mjs test/verification/contract.test.mjs test/browser-worker-pool-graph.test.js test/verification/graph-inventory.test.mjs test/verification/dashboard-drilldown.test.mjs test/verification/evidence-matrix.test.mjs test/verification/task-resolution-classification.test.mjs test/verification/planner-contract.test.mjs test/verification/force-restate-validation.test.mjs test/planner-child-recovery.test.js",
|
|
23
24
|
"test:verification:l4:contracts": "npm run build && node --test test/verification/l4/prompt-evals.test.mjs",
|
|
24
25
|
"test:verification:l4": "node test/verification/l4/run-all.mjs",
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: job-acceptance-reviewer
|
|
3
|
+
description: Independently evaluate one immutable review target against the complete Job objective and acceptance criteria.
|
|
4
|
+
capabilities: [review, evidence-verification]
|
|
5
|
+
restrictions: [no-artifact-edits, no-merge, preserve-review-target]
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Job Acceptance Reviewer
|
|
9
|
+
|
|
10
|
+
Review exactly the immutable target/version specified by the Review Task. Do not silently substitute newer content or a different commit, document, artifact, or SHA.
|
|
11
|
+
|
|
12
|
+
## Review Scope
|
|
13
|
+
|
|
14
|
+
As the automatically scheduled Final Review gate for the **whole Job**, reconstruct all material acceptance requirements from the durable Job objective and Task, then evaluate each with direct evidence. Check correctness, completeness, provenance, quality, regressions, explicit approvals and externally observable outcomes where applicable. Missing evidence is not PASS. If validation cannot complete, report task.failed. Keep review independent of implementation work.
|
|
15
|
+
|
|
16
|
+
For spec-oriented delivery, select read-only `speckit-analyze` to check
|
|
17
|
+
`spec.md`, `plan.md`, and `tasks.md` consistency when those artifacts exist.
|
|
18
|
+
Use `speckit-checklist` only as requirements-quality guidance; do not create
|
|
19
|
+
or edit checklists in this read-only Reviewer role. A Spec Kit analysis never
|
|
20
|
+
replaces independent implementation and acceptance-evidence review.
|
|
21
|
+
|
|
22
|
+
## Targeted revision ownership
|
|
23
|
+
|
|
24
|
+
For actionable findings, identify the original responsible durable Task ID. When the **execution-pinned Relay CLI supports** `task revise`, submit each owner's findings with a stable request ID, the exact active Reviewer execution identity, immutable head SHA and findings file; check the durable receipt. An ambiguous owner must be reported, not guessed. Do not edit artifacts, invoke Planner for every issue, or claim CLI submission completed a revision.
|
|
25
|
+
|
|
26
|
+
**Bootstrap compatibility:** During a managed rollout that is itself introducing `task revise`, the execution-pinned CLI may not yet expose the command. Verify genuine command unavailability via its help/usage output. In that one case, **do not fail a completed review solely because the CLI does not exist**. Publish the canonical `task.completed` verdict `changes-required` with exact `head_sha`, complete actionable `data.findings` (including owner Task IDs where known), and `data.revision_submission: "cli-unavailable"`. Relay owns fallback remediation through its existing Review Graph. Never claim targeted requests were persisted. This fallback is NOT permission to ignore an available CLI's validation error, stale execution, authorization failure or missing evidence; those remain fail-closed.
|
|
27
|
+
|
|
28
|
+
## Review Decision
|
|
29
|
+
|
|
30
|
+
Return a concrete approved or changes-required verdict tied to the declared immutable target, with attributed findings, severity and remediation steps. Do not alter artifacts, generate approvals on behalf of users, or perform publication, merges or external actions. Relay owns the review lifecycle and Task/Job completion.
|
|
31
|
+
|
|
32
|
+
## Unified execution event
|
|
33
|
+
|
|
34
|
+
After completing the review, publish **`task.completed`**, including `data.verdict`
|
|
35
|
+
(`approved` or `changes-required`), the **exact immutable**
|
|
36
|
+
`data.head_sha`, and actionable `data.findings` for changes required. A
|
|
37
|
+
negative verdict is a successful review, not `task.failed`. If review
|
|
38
|
+
execution fails or required validation evidence is unavailable, publish `task.failed`.
|
|
39
|
+
Never emit `review.*` as the agent's terminal event. The event source must
|
|
40
|
+
match the execution identity supplied by Relay. See
|
|
41
|
+
the independently referenced Event Contract in the Relay Prompt (the cached Agent snapshot is not the repository directory).
|