@rasensio/aidlc 2.21.0 → 2.23.0
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/autopilot/answers.d.ts +2 -0
- package/dist/autopilot/answers.d.ts.map +1 -1
- package/dist/autopilot/answers.js +11 -5
- package/dist/autopilot/answers.js.map +1 -1
- package/dist/autopilot/check.d.ts +135 -0
- package/dist/autopilot/check.d.ts.map +1 -0
- package/dist/autopilot/check.js +220 -0
- package/dist/autopilot/check.js.map +1 -0
- package/dist/autopilot/decisions.d.ts +10 -1
- package/dist/autopilot/decisions.d.ts.map +1 -1
- package/dist/autopilot/decisions.js +16 -2
- package/dist/autopilot/decisions.js.map +1 -1
- package/dist/autopilot/driver.d.ts +4 -1
- package/dist/autopilot/driver.d.ts.map +1 -1
- package/dist/autopilot/driver.js +419 -32
- package/dist/autopilot/driver.js.map +1 -1
- package/dist/autopilot/gitlab.d.ts +6 -0
- package/dist/autopilot/gitlab.d.ts.map +1 -1
- package/dist/autopilot/gitlab.js +8 -0
- package/dist/autopilot/gitlab.js.map +1 -1
- package/dist/autopilot/main-home.d.ts +23 -0
- package/dist/autopilot/main-home.d.ts.map +1 -0
- package/dist/autopilot/main-home.js +45 -0
- package/dist/autopilot/main-home.js.map +1 -0
- package/dist/autopilot/open-decisions.d.ts +7 -0
- package/dist/autopilot/open-decisions.d.ts.map +1 -1
- package/dist/autopilot/open-decisions.js +101 -1
- package/dist/autopilot/open-decisions.js.map +1 -1
- package/dist/autopilot/pause.js +3 -3
- package/dist/autopilot/pause.js.map +1 -1
- package/dist/autopilot/pending.d.ts +14 -0
- package/dist/autopilot/pending.d.ts.map +1 -1
- package/dist/autopilot/pending.js +57 -7
- package/dist/autopilot/pending.js.map +1 -1
- package/dist/autopilot/presets.d.ts +4 -0
- package/dist/autopilot/presets.d.ts.map +1 -1
- package/dist/autopilot/presets.js +19 -4
- package/dist/autopilot/presets.js.map +1 -1
- package/dist/autopilot/proposal.d.ts +4 -2
- package/dist/autopilot/proposal.d.ts.map +1 -1
- package/dist/autopilot/proposal.js +9 -4
- package/dist/autopilot/proposal.js.map +1 -1
- package/dist/autopilot/result.d.ts +12 -3
- package/dist/autopilot/result.d.ts.map +1 -1
- package/dist/autopilot/result.js +11 -4
- package/dist/autopilot/result.js.map +1 -1
- package/dist/autopilot/review.d.ts +7 -0
- package/dist/autopilot/review.d.ts.map +1 -1
- package/dist/autopilot/review.js +46 -11
- package/dist/autopilot/review.js.map +1 -1
- package/dist/autopilot/state.d.ts +37 -2
- package/dist/autopilot/state.d.ts.map +1 -1
- package/dist/autopilot/state.js.map +1 -1
- package/dist/autopilot/stops.d.ts +4 -3
- package/dist/autopilot/stops.d.ts.map +1 -1
- package/dist/autopilot/stops.js +5 -3
- package/dist/autopilot/stops.js.map +1 -1
- package/dist/autopilot/typed.d.ts +13 -9
- package/dist/autopilot/typed.d.ts.map +1 -1
- package/dist/autopilot/typed.js +7 -7
- package/dist/autopilot/typed.js.map +1 -1
- package/dist/autopilot/watch-view.d.ts.map +1 -1
- package/dist/autopilot/watch-view.js +2 -1
- package/dist/autopilot/watch-view.js.map +1 -1
- package/dist/commands/autopilot.d.ts.map +1 -1
- package/dist/commands/autopilot.js +2 -1
- package/dist/commands/autopilot.js.map +1 -1
- package/dist/console/operator/panels.js +1 -1
- package/dist/console/operator/panels.js.map +1 -1
- package/dist/roadmap/view-assets.d.ts.map +1 -1
- package/dist/roadmap/view-assets.js +21 -6
- package/dist/roadmap/view-assets.js.map +1 -1
- package/dist/roadmap/view-html.d.ts +12 -0
- package/dist/roadmap/view-html.d.ts.map +1 -1
- package/dist/roadmap/view-html.js +81 -7
- package/dist/roadmap/view-html.js.map +1 -1
- package/dist/roadmap/view-model.d.ts +28 -1
- package/dist/roadmap/view-model.d.ts.map +1 -1
- package/dist/roadmap/view-model.js +48 -4
- package/dist/roadmap/view-model.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"driver.d.ts","sourceRoot":"","sources":["../../src/autopilot/driver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAKH,OAAO,EAA0B,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAE/E,OAAO,EAAsB,KAAK,IAAI,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"driver.d.ts","sourceRoot":"","sources":["../../src/autopilot/driver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAKH,OAAO,EAA0B,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAE/E,OAAO,EAAsB,KAAK,IAAI,EAAE,MAAM,iBAAiB,CAAC;AA+BhE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAgB1C,OAAO,KAAK,EACV,eAAe,EACf,aAAa,EACb,cAAc,EACd,cAAc,EACd,QAAQ,EAIR,WAAW,EACZ,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAuD,KAAK,UAAU,EAAE,KAAK,KAAK,EAAE,MAAM,YAAY,CAAC;AAc9G,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAED,yEAAyE;AACzE,MAAM,WAAW,SAAS;IACxB,mCAAmC;IACnC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,0BAA0B;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,6HAA6H;IAC7H,MAAM,EAAE,MAAM,CAAC;IACf,kGAAkG;IAClG,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,GAAG,IAAI,MAAM,CAEn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,cAAc,GAAG,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAEpE;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAKvG;AAgBD,oGAAoG;AACpG,wBAAgB,SAAS,CAAC,CAAC,EAAE,aAAa,GAAG,MAAM,CAOlD;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CACxB,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,cAAc,EACrB,GAAG,EAAE,MAAM,EACX,QAAQ,GAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAqB,GAC/C,MAAM,CAIR;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM,GAAG,IAAI,CAE9D;AAYD,wBAAgB,WAAW,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,GAAG,OAAO,GAAG,KAAK,CAAC,EAAE,KAAK,EAAE,cAAc,EAAE,IAAI,GAAE,IAAe,GAAG,MAAM,EAAE,CAahI"}
|
package/dist/autopilot/driver.js
CHANGED
|
@@ -15,14 +15,15 @@
|
|
|
15
15
|
*
|
|
16
16
|
* @module
|
|
17
17
|
*/
|
|
18
|
-
import {
|
|
18
|
+
import { join, resolve } from 'node:path';
|
|
19
19
|
import { mapUnits } from '../cost/providers/codex.js';
|
|
20
20
|
import { microToUsd, priceUnits } from '../cost/rates.js';
|
|
21
21
|
import { MODEL_ID_RE } from '../cost/types.js';
|
|
22
22
|
import { hostFromConfigText } from '../core/host.js';
|
|
23
|
+
import { DIFF_MAX, DIFF_PATHSPEC, VERDICT_SCHEMA, changedSince, checkerPrompt, fingerprint, parseVerdict, readCriteria, rejectPrompt, renderVerdict, } from './check.js';
|
|
23
24
|
import { classify, jobRef, parseRunJobs } from './ci-jobs.js';
|
|
24
|
-
import { GLAB_READ_RE, TAG_PIPELINES_ARGS, classifyJobs, jobsArgs, mergeArgs, mergedAnswer, mrCreateArgs, mrNumber, mrViewArgs, parseJobs, parseMr, releaseInFlight, retryArgs, } from './gitlab.js';
|
|
25
|
-
import { REASON_MAX, RESET_WAIT_MAX_MS, codexEnd, emptyCodexProgress, firstLine, readClaudeResult, readCodexEvents, refusalSuffix, resetAt, stoppedBy, summaryLines, } from './result.js';
|
|
25
|
+
import { GLAB_READ_RE, TAG_PIPELINES_ARGS, classifyJobs, jobsArgs, mergeArgs, mergedAnswer, mrCreateArgs, mrNumber, mrViewArgs, noteArgs, parseJobs, parseMr, releaseInFlight, retryArgs, } from './gitlab.js';
|
|
26
|
+
import { REASON_MAX, RESET_WAIT_MAX_MS, codexEnd, emptyCodexProgress, firstLine, lastClaudeResult, readClaudeResult, readCodexEvents, refusalSuffix, resetAt, stoppedBy, summaryLines, } from './result.js';
|
|
26
27
|
import { capInForce, tokensLeft } from './cap.js';
|
|
27
28
|
import { fmtTokens } from '../commands/cost.js';
|
|
28
29
|
import { LEGACY_STOPS, pauseEnv, pendingReview, stopsInForce } from './stops.js';
|
|
@@ -77,8 +78,9 @@ function isReadOnly(cmd, args) {
|
|
|
77
78
|
// The retry and the merge carry `--method`, so a dry run prints them (autopilot-gitlab-merge-requests/AC-16).
|
|
78
79
|
if (cmd === 'glab')
|
|
79
80
|
return a === '--version' || GLAB_READ_RE.test(a);
|
|
81
|
+
// `diff` and `ls-remote` read what the pull request check is given (pr-checker-earns-merge/AC-2, AC-5).
|
|
80
82
|
if (cmd === 'git')
|
|
81
|
-
return /^(rev-parse|status|merge-base)\b/.test(a);
|
|
83
|
+
return /^(rev-parse|status|merge-base|diff|ls-remote)\b/.test(a);
|
|
82
84
|
return /\broadmap next\b/.test(a) || (/\bcost\b/.test(a) && /--json/.test(a));
|
|
83
85
|
}
|
|
84
86
|
/** `args` past `cli`'s own, when `cmd args` is an `aidlc` invocation; else undefined. */
|
|
@@ -245,8 +247,12 @@ function dequeue(state, item) {
|
|
|
245
247
|
}
|
|
246
248
|
/** At most two at once, whatever the config says. */
|
|
247
249
|
const buildSlots = (ctx) => Math.min(2, Math.max(1, ctx.config?.max_parallel ?? 2));
|
|
248
|
-
/**
|
|
249
|
-
|
|
250
|
+
/**
|
|
251
|
+
* Only an item running an agent holds a slot; one waiting for a person does not
|
|
252
|
+
* (autopilot-stop-controls/AC-15). A pull request checker runs the project's tests, so it
|
|
253
|
+
* holds one like a build (pr-checker-earns-merge, design D3).
|
|
254
|
+
*/
|
|
255
|
+
const building = (state) => state.items.filter((i) => i.step === 'building' || i.step === 'checking').length;
|
|
250
256
|
/** The stops an item is held to: those recorded when it started (autopilot-stop-controls/AC-6). */
|
|
251
257
|
export function itemStops(item) {
|
|
252
258
|
return item.stops ?? LEGACY_STOPS;
|
|
@@ -323,7 +329,7 @@ const logFile = (ctx, item) => `${ctx.paths.logs}/${item.name}.log`;
|
|
|
323
329
|
*
|
|
324
330
|
* @param budget - the run's item budget, which a park here must reach.
|
|
325
331
|
*/
|
|
326
|
-
function launchAgent(ctx, io, state, item, prompt, budget, resume) {
|
|
332
|
+
function launchAgent(ctx, io, state, item, prompt, budget, resume, kind = 'build') {
|
|
327
333
|
if (launchBlocked(state, ctx.now()) !== null)
|
|
328
334
|
return false;
|
|
329
335
|
const capSet = capInForce(ctx.config);
|
|
@@ -349,25 +355,19 @@ function launchAgent(ctx, io, state, item, prompt, budget, resume) {
|
|
|
349
355
|
argv = command.map((a) => (a === '{prompt}' ? prompt : a));
|
|
350
356
|
}
|
|
351
357
|
else {
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
const gitCommonDir = dirname(dirname(ctx.paths.dir));
|
|
358
|
-
// Checked before the id, so the two park reasons stay apart (design, Interfaces).
|
|
359
|
-
if (harness === 'codex' && !isAbsolute(gitCommonDir)) {
|
|
360
|
-
park(ctx, io, state, item, 'agent launch — no git common dir', budget);
|
|
361
|
-
return false;
|
|
362
|
-
}
|
|
358
|
+
// A checker ends with its verdict, not the build's outcome, and cannot use the edit
|
|
359
|
+
// tools; it never resumes (pr-checker-earns-merge/AC-1, AC-4, AC-6, design D5).
|
|
360
|
+
const check = kind === 'check';
|
|
361
|
+
const outcomeFile = `${ctx.paths.dir}/outcomes/${item.name}${check ? '.check' : ''}.json`;
|
|
362
|
+
const schemaFile = `${ctx.paths.dir}/${check ? 'check' : 'outcome'}-schema.json`;
|
|
363
363
|
const typed = typedArgv(command, {
|
|
364
364
|
harness,
|
|
365
|
-
prompt: withOutcomeContract(prompt),
|
|
365
|
+
prompt: check ? prompt : withOutcomeContract(prompt),
|
|
366
366
|
schemaFile,
|
|
367
367
|
outcomeFile,
|
|
368
|
-
gitCommonDir,
|
|
369
368
|
maxBudgetCents: harness === 'claude' ? cents : null,
|
|
370
|
-
resume: resume?.session ?? null,
|
|
369
|
+
resume: check ? null : resume?.session ?? null,
|
|
370
|
+
...(check ? { schema: VERDICT_SCHEMA, disallowedTools: ['Edit', 'Write', 'NotebookEdit'] } : {}),
|
|
371
371
|
});
|
|
372
372
|
if (typed === null) {
|
|
373
373
|
park(ctx, io, state, item, `${resume?.label ?? 'session'} — no usable session id`, budget);
|
|
@@ -391,7 +391,7 @@ function launchAgent(ctx, io, state, item, prompt, budget, resume) {
|
|
|
391
391
|
launch.rollout_at = resume.from.rollout_at ?? resume.from.at;
|
|
392
392
|
}
|
|
393
393
|
if (harness === 'codex' && !ctx.dryRun) {
|
|
394
|
-
ctx.fs.write(schemaFile, `${JSON.stringify(OUTCOME_SCHEMA, null, 2)}\n`);
|
|
394
|
+
ctx.fs.write(schemaFile, `${JSON.stringify(check ? VERDICT_SCHEMA : OUTCOME_SCHEMA, null, 2)}\n`);
|
|
395
395
|
ctx.fs.write(outcomeFile, '');
|
|
396
396
|
}
|
|
397
397
|
}
|
|
@@ -401,8 +401,9 @@ function launchAgent(ctx, io, state, item, prompt, budget, resume) {
|
|
|
401
401
|
// Where the unattended rule's review boundaries are (autopilot-stop-controls/AC-11).
|
|
402
402
|
AIDLC_PAUSE_AFTER: itemPauses(item),
|
|
403
403
|
};
|
|
404
|
+
const who = kind === 'check' ? 'checker' : 'agent';
|
|
404
405
|
if (ctx.dryRun) {
|
|
405
|
-
ctx.say(`[dry-run] (in ${item.worktree}) launch
|
|
406
|
+
ctx.say(`[dry-run] (in ${item.worktree}) launch ${who}: ${argv[0]} … (${argv.length} args${harness === null ? '' : `, typed ${harness}`})`);
|
|
406
407
|
return true;
|
|
407
408
|
}
|
|
408
409
|
if (launch === undefined) {
|
|
@@ -420,7 +421,7 @@ function launchAgent(ctx, io, state, item, prompt, budget, resume) {
|
|
|
420
421
|
item.pid_started_at = new Date(ctx.now()).toISOString();
|
|
421
422
|
if (!isPid(item.pid)) {
|
|
422
423
|
// Its error arrives after this pass; the next one parks it (agent-binary-missing-crashes-loop/AC-3).
|
|
423
|
-
tell(ctx, item,
|
|
424
|
+
tell(ctx, item, `${who} did not start`);
|
|
424
425
|
return true;
|
|
425
426
|
}
|
|
426
427
|
const id = ctx.identify?.(item.pid);
|
|
@@ -429,7 +430,7 @@ function launchAgent(ctx, io, state, item, prompt, budget, resume) {
|
|
|
429
430
|
item.pid_boot = id.boot;
|
|
430
431
|
item.pid_ns = id.ns;
|
|
431
432
|
}
|
|
432
|
-
tell(ctx, item,
|
|
433
|
+
tell(ctx, item, `${who} started (pid ${item.pid})`);
|
|
433
434
|
return true;
|
|
434
435
|
}
|
|
435
436
|
function drop(state, item, budget) {
|
|
@@ -776,7 +777,12 @@ function appendSummary(ctx, item, lines) {
|
|
|
776
777
|
const lead = last !== undefined && last.length === 1 && last[0] !== 0x0a ? '\n' : '';
|
|
777
778
|
append(log, `${lead}${lines.join('\n')}\n`);
|
|
778
779
|
}
|
|
779
|
-
|
|
780
|
+
/**
|
|
781
|
+
* While the item's agent — a build or a pull request checker — is alive: fold a Codex log
|
|
782
|
+
* and hold it to the cap, parking the item when it is past. True while it runs
|
|
783
|
+
* (pr-checker-earns-merge/AC-18).
|
|
784
|
+
*/
|
|
785
|
+
function agentRunning(ctx, io, state, item, budget) {
|
|
780
786
|
if (isPid(item.pid) && ctx.isAlive(item.pid)) {
|
|
781
787
|
const launch = item.launch;
|
|
782
788
|
if (launch?.harness === 'codex')
|
|
@@ -784,7 +790,7 @@ function advanceBuilding(ctx, io, state, item, budget) {
|
|
|
784
790
|
const capSet = capInForce(ctx.config);
|
|
785
791
|
if (capSet !== null) {
|
|
786
792
|
if (launch?.harness === 'codex' && stoppedAtCap(ctx, io, state, item, launch, capSet, budget))
|
|
787
|
-
return;
|
|
793
|
+
return true;
|
|
788
794
|
// Every agent, typed or not: the ledger's view of the cap stands (autopilot-reads-agent-result/AC-22),
|
|
789
795
|
// in the unit the cap is set in (cost-in-tokens/AC-16).
|
|
790
796
|
const r = io.cli(['cost', item.name, '--json']);
|
|
@@ -811,8 +817,13 @@ function advanceBuilding(ctx, io, state, item, budget) {
|
|
|
811
817
|
park(ctx, io, state, item, reason, budget);
|
|
812
818
|
}
|
|
813
819
|
}
|
|
814
|
-
return;
|
|
820
|
+
return true;
|
|
815
821
|
}
|
|
822
|
+
return false;
|
|
823
|
+
}
|
|
824
|
+
function advanceBuilding(ctx, io, state, item, budget) {
|
|
825
|
+
if (agentRunning(ctx, io, state, item, budget))
|
|
826
|
+
return;
|
|
816
827
|
// A launch that never started had no session to read: unmarked, its log would gain the
|
|
817
828
|
// summary of a session that "ended with no readable result" (agent-binary-missing-crashes-loop/AC-4).
|
|
818
829
|
if (neverStarted(item) && item.launch !== undefined && item.launch.end === undefined)
|
|
@@ -1227,7 +1238,8 @@ function dirtyPaths(ctx, io, prefix) {
|
|
|
1227
1238
|
.map((rec) => rec.slice(3))
|
|
1228
1239
|
.map((p) => (p.startsWith(prefix) ? p.slice(prefix.length) : p));
|
|
1229
1240
|
}
|
|
1230
|
-
|
|
1241
|
+
/** Written in the worktree after its last commit; `pr-check.md` by the pull request check (pr-checker-earns-merge/AC-17). */
|
|
1242
|
+
const LATE_FILES = ['costs.ndjson', 'unattended-stops.md', 'pr-check.md'];
|
|
1231
1243
|
/** `t` without its `**Review:**` lines — the line `withVerdict` inserts or replaces. */
|
|
1232
1244
|
const withoutVerdicts = (t) => t
|
|
1233
1245
|
.split('\n')
|
|
@@ -1380,7 +1392,7 @@ function handleConflict(ctx, io, state, item, budget) {
|
|
|
1380
1392
|
dequeue(state, item);
|
|
1381
1393
|
item.step = 'building';
|
|
1382
1394
|
tell(ctx, item, `conflicts with main — relaunching the agent to resolve it (attempt ${tries + 1} of ${CONFLICT_FIX_LIMIT})`);
|
|
1383
|
-
|
|
1395
|
+
relaunchBuild(ctx, io, state, item, conflictPrompt(item, hostOf(ctx)), budget);
|
|
1384
1396
|
}
|
|
1385
1397
|
/**
|
|
1386
1398
|
* The two `merge=union` cost ledgers a worktree collects between commits. `name` is
|
|
@@ -1510,6 +1522,348 @@ function pushed(ctx, io, state, item) {
|
|
|
1510
1522
|
function openQuestions(ctx, item) {
|
|
1511
1523
|
return unreviewedOpenQuestions(ctx.fs.read(stopsLogPath(item.worktree, item.name)));
|
|
1512
1524
|
}
|
|
1525
|
+
/**
|
|
1526
|
+
* Relaunch the build agent on an open pull request — a CI fix, a conflict, a REJECT — and
|
|
1527
|
+
* discard the check, so the head autopilot merges is one a check passed. Autopilot's own
|
|
1528
|
+
* update from main does not come here, and keeps it (pr-checker-earns-merge/AC-12).
|
|
1529
|
+
*/
|
|
1530
|
+
function relaunchBuild(ctx, io, state, item, prompt, budget) {
|
|
1531
|
+
delete item.check;
|
|
1532
|
+
return launchAgent(ctx, io, state, item, prompt, budget);
|
|
1533
|
+
}
|
|
1534
|
+
const short = (sha) => sha.slice(0, 12) || 'none';
|
|
1535
|
+
/**
|
|
1536
|
+
* The tracked files that differ from the head, by content hash, keyed by their path from
|
|
1537
|
+
* the repository's top — what porcelain prints, for a project below the root as well — or
|
|
1538
|
+
* git's failure (pr-checker-earns-merge/AC-5, design D4).
|
|
1539
|
+
*/
|
|
1540
|
+
function trackedSnapshot(ctx, io, item, also = []) {
|
|
1541
|
+
const wt = { cwd: item.worktree };
|
|
1542
|
+
const top = io.call('git', ['rev-parse', '--show-toplevel'], wt);
|
|
1543
|
+
if (top.status !== 0)
|
|
1544
|
+
return { failed: `git rev-parse: ${fail(top)}` };
|
|
1545
|
+
const prefix = io.call('git', ['rev-parse', '--show-prefix'], wt);
|
|
1546
|
+
if (prefix.status !== 0)
|
|
1547
|
+
return { failed: `git rev-parse: ${fail(prefix)}` };
|
|
1548
|
+
const status = io.call('git', ['status', '--porcelain=v1', '-z', '--no-renames', '--untracked-files=no'], wt);
|
|
1549
|
+
if (status.status !== 0)
|
|
1550
|
+
return { failed: `git status: ${fail(status)}` };
|
|
1551
|
+
const dirty = status.stdout
|
|
1552
|
+
.split('\0')
|
|
1553
|
+
.filter((rec) => rec.length > 3)
|
|
1554
|
+
.map((rec) => rec.slice(3));
|
|
1555
|
+
const paths = [...new Set([...dirty, ...also])];
|
|
1556
|
+
return { snap: fingerprint(ctx.fs.read, top.stdout.trim(), paths), prefix: prefix.stdout.trim() };
|
|
1557
|
+
}
|
|
1558
|
+
/** The remote branch's head, '' when it has none, or git's failure. */
|
|
1559
|
+
function remoteHead(io, item) {
|
|
1560
|
+
const r = io.call('git', ['ls-remote', 'origin', `refs/heads/${item.branch}`], { cwd: item.worktree });
|
|
1561
|
+
if (r.status !== 0)
|
|
1562
|
+
return { failed: `git ls-remote: ${fail(r)}` };
|
|
1563
|
+
return r.stdout.trim().split(/\s+/)[0] ?? '';
|
|
1564
|
+
}
|
|
1565
|
+
/**
|
|
1566
|
+
* Launch the pull request check of the head CI just passed on (pr-checker-earns-merge/AC-1..AC-4).
|
|
1567
|
+
* In order, each failing step deciding the pass: no preset or no criteria leaves a blocked
|
|
1568
|
+
* check for the person (AC-3, AC-7); no free agent slot or a session-limit wait leaves the
|
|
1569
|
+
* item where it is, saying so (design D3); then the change is read and the checker
|
|
1570
|
+
* launched as one more launch, under the cap like any other (AC-18, design D1).
|
|
1571
|
+
*/
|
|
1572
|
+
function launchCheck(ctx, io, state, item, budget) {
|
|
1573
|
+
const n = (item.checks_run ?? 0) + 1;
|
|
1574
|
+
const blocked = (why) => {
|
|
1575
|
+
item.check = { n, head: '', remote: '', baseline: {}, given: [], blocked: why };
|
|
1576
|
+
};
|
|
1577
|
+
if (typedHarness(ctx.config?.agent_command ?? []) === null) {
|
|
1578
|
+
blocked('the agent command is not a preset autopilot reads a result from');
|
|
1579
|
+
return;
|
|
1580
|
+
}
|
|
1581
|
+
const stateDir = `${item.worktree}/.aidlc/state/${item.name}`;
|
|
1582
|
+
const { criteria } = readCriteria(ctx.fs.read, stateDir);
|
|
1583
|
+
if (criteria.length === 0) {
|
|
1584
|
+
blocked('no acceptance criteria found in requirements.md or roadmap-item.md');
|
|
1585
|
+
return;
|
|
1586
|
+
}
|
|
1587
|
+
if (building(state) >= buildSlots(ctx)) {
|
|
1588
|
+
tell(ctx, item, 'CI green — the pull request check waits for a free agent slot');
|
|
1589
|
+
return;
|
|
1590
|
+
}
|
|
1591
|
+
const limit = launchBlocked(state, ctx.now());
|
|
1592
|
+
if (limit !== null) {
|
|
1593
|
+
tell(ctx, item, `CI green — the pull request check waits for the session limit to reset at ${limit}`);
|
|
1594
|
+
return;
|
|
1595
|
+
}
|
|
1596
|
+
const wt = { cwd: item.worktree };
|
|
1597
|
+
const fetch = io.call('git', ['fetch', 'origin', 'main'], wt);
|
|
1598
|
+
if (fetch.status !== 0) {
|
|
1599
|
+
blocked(`could not read the change: git fetch: ${fail(fetch)}`);
|
|
1600
|
+
return;
|
|
1601
|
+
}
|
|
1602
|
+
const range = 'origin/main...HEAD';
|
|
1603
|
+
let diff = io.call('git', ['diff', '--no-color', '--no-ext-diff', range, ...DIFF_PATHSPEC], wt);
|
|
1604
|
+
let truncated = false;
|
|
1605
|
+
if (diff.status === 0 && diff.stdout.length > DIFF_MAX) {
|
|
1606
|
+
diff = io.call('git', ['diff', '--stat', '--no-color', range, ...DIFF_PATHSPEC], wt);
|
|
1607
|
+
truncated = true;
|
|
1608
|
+
}
|
|
1609
|
+
if (diff.status !== 0) {
|
|
1610
|
+
blocked(`could not read the change: git diff: ${fail(diff)}`);
|
|
1611
|
+
return;
|
|
1612
|
+
}
|
|
1613
|
+
const head = io.call('git', ['rev-parse', 'HEAD'], wt);
|
|
1614
|
+
if (head.status !== 0) {
|
|
1615
|
+
blocked(`could not read the change: git rev-parse: ${fail(head)}`);
|
|
1616
|
+
return;
|
|
1617
|
+
}
|
|
1618
|
+
const remote = remoteHead(io, item);
|
|
1619
|
+
if (typeof remote !== 'string') {
|
|
1620
|
+
blocked(`could not read the change: ${remote.failed}`);
|
|
1621
|
+
return;
|
|
1622
|
+
}
|
|
1623
|
+
const snapshot = trackedSnapshot(ctx, io, item);
|
|
1624
|
+
if ('failed' in snapshot) {
|
|
1625
|
+
blocked(`could not read the change: ${snapshot.failed}`);
|
|
1626
|
+
return;
|
|
1627
|
+
}
|
|
1628
|
+
const prRef = ref(hostOf(ctx), item.pr);
|
|
1629
|
+
const prompt = checkerPrompt({
|
|
1630
|
+
name: item.name,
|
|
1631
|
+
prRef,
|
|
1632
|
+
criteria,
|
|
1633
|
+
tasks: ctx.fs.read(`${stateDir}/tasks.md`),
|
|
1634
|
+
diff: { text: diff.stdout, base: 'origin/main', head: head.stdout.trim(), truncated },
|
|
1635
|
+
});
|
|
1636
|
+
const check = { n, head: head.stdout.trim(), remote, baseline: snapshot.snap, given: criteria.map((c) => c.id) };
|
|
1637
|
+
const step = item.step;
|
|
1638
|
+
item.check = check;
|
|
1639
|
+
item.checks_run = n;
|
|
1640
|
+
item.step = 'checking';
|
|
1641
|
+
tell(ctx, item, `CI green — checking ${prRef} against its ${criteria.length} criteria with an agent that did not build it`);
|
|
1642
|
+
if (!launchAgent(ctx, io, state, item, prompt, budget, undefined, 'check') && state.items.includes(item)) {
|
|
1643
|
+
// Not launched and not parked: nothing ran, so nothing is counted.
|
|
1644
|
+
delete item.check;
|
|
1645
|
+
item.checks_run = n - 1;
|
|
1646
|
+
item.step = step;
|
|
1647
|
+
}
|
|
1648
|
+
}
|
|
1649
|
+
/**
|
|
1650
|
+
* What the checker changed during its session, in words, or null: the branch head, the
|
|
1651
|
+
* remote branch, or a tracked file other than the two cost ledgers, measured against the
|
|
1652
|
+
* snapshot taken at launch (pr-checker-earns-merge/AC-5, design D4).
|
|
1653
|
+
*/
|
|
1654
|
+
function checkerChanged(ctx, io, item, check) {
|
|
1655
|
+
const head = io.call('git', ['rev-parse', 'HEAD'], { cwd: item.worktree });
|
|
1656
|
+
if (head.status !== 0)
|
|
1657
|
+
return `the branch head cannot be read (${fail(head)})`;
|
|
1658
|
+
if (head.stdout.trim() !== check.head)
|
|
1659
|
+
return `the branch head (${short(check.head)} → ${short(head.stdout.trim())})`;
|
|
1660
|
+
const remote = remoteHead(io, item);
|
|
1661
|
+
if (typeof remote !== 'string')
|
|
1662
|
+
return `the remote branch cannot be read (${remote.failed})`;
|
|
1663
|
+
if (remote !== check.remote)
|
|
1664
|
+
return `the remote branch (${short(check.remote)} → ${short(remote)})`;
|
|
1665
|
+
const now = trackedSnapshot(ctx, io, item, Object.keys(check.baseline));
|
|
1666
|
+
if ('failed' in now)
|
|
1667
|
+
return `the tracked files cannot be read (${now.failed})`;
|
|
1668
|
+
const changed = changedSince(check.baseline, now.snap, ledgerPaths(item.name).map((p) => `${now.prefix}${p}`));
|
|
1669
|
+
return changed.length === 0 ? null : `tracked files: ${changed.slice(0, 5).join(', ')}${changed.length > 5 ? ` and ${changed.length - 5} more` : ''}`;
|
|
1670
|
+
}
|
|
1671
|
+
/** The checker's structured output, or undefined when it wrote none (pr-checker-earns-merge/AC-6). */
|
|
1672
|
+
function checkerOutput(ctx, item) {
|
|
1673
|
+
const launch = item.launch;
|
|
1674
|
+
const { readRange, size } = ctx.fs;
|
|
1675
|
+
if (launch === undefined || readRange === undefined || size === undefined)
|
|
1676
|
+
return undefined;
|
|
1677
|
+
if (launch.harness === 'claude') {
|
|
1678
|
+
const log = logFile(ctx, item);
|
|
1679
|
+
const total = size(log);
|
|
1680
|
+
const start = Math.max(launch.log_offset, total - RESULT_TAIL_BYTES);
|
|
1681
|
+
return lastClaudeResult(readRange(log, start, Math.max(0, total - start)).toString('utf8')).found?.structured_output;
|
|
1682
|
+
}
|
|
1683
|
+
if (launch.outcome_file === undefined)
|
|
1684
|
+
return undefined;
|
|
1685
|
+
const text = readRange(launch.outcome_file, 0, OUTCOME_FILE_BYTES).toString('utf8').trim();
|
|
1686
|
+
try {
|
|
1687
|
+
return text === '' ? undefined : JSON.parse(text);
|
|
1688
|
+
}
|
|
1689
|
+
catch {
|
|
1690
|
+
return undefined;
|
|
1691
|
+
}
|
|
1692
|
+
}
|
|
1693
|
+
/**
|
|
1694
|
+
* The checker has exited: record its spend, then decide what its session counts for — first
|
|
1695
|
+
* match wins (pr-checker-earns-merge/AC-5..AC-7, AC-18, design D9). Every ending that could
|
|
1696
|
+
* not judge goes to the person, never to the builder. The integrity check comes before the
|
|
1697
|
+
* verdict, so a checker that edited and then said PASS is never read.
|
|
1698
|
+
*/
|
|
1699
|
+
function advanceChecking(ctx, io, state, item, budget) {
|
|
1700
|
+
if (agentRunning(ctx, io, state, item, budget))
|
|
1701
|
+
return;
|
|
1702
|
+
const check = item.check;
|
|
1703
|
+
if (check === undefined) {
|
|
1704
|
+
// Hand-edited state: CI is read again and a check launched.
|
|
1705
|
+
item.step = 'pr-open';
|
|
1706
|
+
return;
|
|
1707
|
+
}
|
|
1708
|
+
if (neverStarted(item) && item.launch !== undefined && item.launch.end === undefined)
|
|
1709
|
+
item.launch.end = null;
|
|
1710
|
+
if (item.launch !== undefined && item.launch.end === undefined && !endSession(ctx, item, item.launch))
|
|
1711
|
+
return;
|
|
1712
|
+
const end = item.launch?.end ?? null;
|
|
1713
|
+
const spent = item.spent_micro_usd ?? 0;
|
|
1714
|
+
item.step = 'pr-open';
|
|
1715
|
+
check.at = new Date(ctx.now()).toISOString();
|
|
1716
|
+
if (end?.limit === 'budget') {
|
|
1717
|
+
const cap = item.launch?.cap_usd;
|
|
1718
|
+
park(ctx, io, state, item, cap === undefined ? `budget reached — spent ${microToUsd(spent)}` : capReached(cap, spent), budget);
|
|
1719
|
+
return;
|
|
1720
|
+
}
|
|
1721
|
+
if (end === null) {
|
|
1722
|
+
check.blocked = launchFailure(ctx, item)?.replace(/^agent/, 'checker') ?? 'the checker ended with no readable result';
|
|
1723
|
+
return;
|
|
1724
|
+
}
|
|
1725
|
+
if (end.error !== null) {
|
|
1726
|
+
check.blocked = `checker session failed: ${firstLine(end.error, REASON_MAX) ?? 'error'}`;
|
|
1727
|
+
return;
|
|
1728
|
+
}
|
|
1729
|
+
const changed = checkerChanged(ctx, io, item, check);
|
|
1730
|
+
if (changed !== null) {
|
|
1731
|
+
check.blocked = `the checker changed ${changed} — verdict discarded`;
|
|
1732
|
+
return;
|
|
1733
|
+
}
|
|
1734
|
+
const output = checkerOutput(ctx, item);
|
|
1735
|
+
const read = output === undefined ? { ok: false, reason: 'the checker gave no verdict' } : parseVerdict(output, check.given);
|
|
1736
|
+
if (!read.ok) {
|
|
1737
|
+
check.blocked = `the verdict cannot be read: ${read.reason}`;
|
|
1738
|
+
return;
|
|
1739
|
+
}
|
|
1740
|
+
check.verdict = read.verdict;
|
|
1741
|
+
tell(ctx, item, `check ${check.n}: ${read.verdict.verdict}${notMetText(check)}`);
|
|
1742
|
+
recordCheck(ctx, item, check);
|
|
1743
|
+
postCheck(ctx, io, item, check);
|
|
1744
|
+
}
|
|
1745
|
+
/** ` (not met: AC-2, AC-5)`, or '' when every criterion is met. */
|
|
1746
|
+
function notMetText(check) {
|
|
1747
|
+
const ids = (check.verdict?.criteria ?? []).filter((c) => !c.met).map((c) => c.id);
|
|
1748
|
+
return ids.length === 0 ? '' : ` (not met: ${ids.join(', ')})`;
|
|
1749
|
+
}
|
|
1750
|
+
const checkText = (check) => renderVerdict(check.verdict, { n: check.n, head: check.head, at: check.at ?? '' });
|
|
1751
|
+
/**
|
|
1752
|
+
* Append the verdict to `pr-check.md` in the worktree, a later verdict below the earlier,
|
|
1753
|
+
* in the text the comment carries (pr-checker-earns-merge/AC-17).
|
|
1754
|
+
*/
|
|
1755
|
+
function recordCheck(ctx, item, check) {
|
|
1756
|
+
if (check.recorded === true || check.verdict === undefined || ctx.dryRun)
|
|
1757
|
+
return;
|
|
1758
|
+
const path = `${item.worktree}/.aidlc/state/${item.name}/pr-check.md`;
|
|
1759
|
+
const before = ctx.fs.read(path);
|
|
1760
|
+
const head = before === null ? `# Pull request check — ${item.name}\n` : before.endsWith('\n') ? '' : '\n';
|
|
1761
|
+
const text = `${head}\n${checkText(check)}`;
|
|
1762
|
+
if (before !== null && ctx.fs.append !== undefined)
|
|
1763
|
+
ctx.fs.append(path, text);
|
|
1764
|
+
else
|
|
1765
|
+
ctx.fs.write(path, `${before ?? ''}${text}`);
|
|
1766
|
+
check.recorded = true;
|
|
1767
|
+
}
|
|
1768
|
+
/**
|
|
1769
|
+
* Post the verdict as one comment on the pull request — `gh` from the primary checkout,
|
|
1770
|
+
* with the body in a file under the autopilot directory, never through a shell; a note
|
|
1771
|
+
* through `glab api` on GitLab. A failure is said and tried again on the next pass
|
|
1772
|
+
* (pr-checker-earns-merge/AC-15, AC-16).
|
|
1773
|
+
*/
|
|
1774
|
+
function postCheck(ctx, io, item, check) {
|
|
1775
|
+
if (check.posted === true)
|
|
1776
|
+
return true;
|
|
1777
|
+
if (check.verdict === undefined)
|
|
1778
|
+
return false;
|
|
1779
|
+
const host = hostOf(ctx);
|
|
1780
|
+
const text = checkText(check);
|
|
1781
|
+
let r;
|
|
1782
|
+
if (host === 'gitlab') {
|
|
1783
|
+
r = io.call('glab', noteArgs(item.pr ?? 0, text), { cwd: ctx.repo });
|
|
1784
|
+
}
|
|
1785
|
+
else {
|
|
1786
|
+
const body = `${ctx.paths.dir}/checks/${item.name}.md`;
|
|
1787
|
+
if (!ctx.dryRun)
|
|
1788
|
+
ctx.fs.write(body, text);
|
|
1789
|
+
r = io.call('gh', ['pr', 'comment', String(item.pr), '--body-file', body], { cwd: ctx.repo });
|
|
1790
|
+
}
|
|
1791
|
+
if (r.status !== 0) {
|
|
1792
|
+
tell(ctx, item, `could not post check ${check.n} on ${ref(host, item.pr)}: ${fail(r)} — trying again next pass; nothing merges until it is posted`);
|
|
1793
|
+
return false;
|
|
1794
|
+
}
|
|
1795
|
+
check.posted = true;
|
|
1796
|
+
return true;
|
|
1797
|
+
}
|
|
1798
|
+
/**
|
|
1799
|
+
* Act on the check of the head CI passed on (pr-checker-earns-merge/AC-8..AC-11, design D7).
|
|
1800
|
+
* A check that could not decide waits for a person under either stop. Nothing is acted on
|
|
1801
|
+
* before its verdict is posted. Under `pr` the item then waits whatever the verdict; under
|
|
1802
|
+
* `checked-merge` a first REJECT relaunches the build once, a second parks the item, and a
|
|
1803
|
+
* PASS joins the merge queue unless an open question waits for a person.
|
|
1804
|
+
*/
|
|
1805
|
+
function actOnCheck(ctx, io, state, item, check, budget) {
|
|
1806
|
+
const host = hostOf(ctx);
|
|
1807
|
+
const prRef = ref(host, item.pr);
|
|
1808
|
+
if (check.blocked !== undefined) {
|
|
1809
|
+
item.step = 'awaiting-merge';
|
|
1810
|
+
const text = `CI green — the pull request check could not decide: ${check.blocked}; ${prRef} waits for you to merge it`;
|
|
1811
|
+
tell(ctx, item, text);
|
|
1812
|
+
if (check.told !== true)
|
|
1813
|
+
notice(ctx, 'merge needed', `${item.name}: ${text}`);
|
|
1814
|
+
check.told = true;
|
|
1815
|
+
return;
|
|
1816
|
+
}
|
|
1817
|
+
const verdict = check.verdict;
|
|
1818
|
+
if (verdict === undefined) {
|
|
1819
|
+
// A check with neither verdict nor reason outside `checking`: hand-edited state. Check again.
|
|
1820
|
+
delete item.check;
|
|
1821
|
+
return;
|
|
1822
|
+
}
|
|
1823
|
+
recordCheck(ctx, item, check);
|
|
1824
|
+
if (!postCheck(ctx, io, item, check))
|
|
1825
|
+
return;
|
|
1826
|
+
const said = `check ${check.n}: ${verdict.verdict}${notMetText(check)}`;
|
|
1827
|
+
if (itemStops(item).stop_at === 'pr') {
|
|
1828
|
+
item.step = 'awaiting-merge';
|
|
1829
|
+
tell(ctx, item, `CI green, ${said} — ${prRef} waits for you to merge it`);
|
|
1830
|
+
notice(ctx, 'merge needed', `${item.name}: ${said} — ${prRef} waits for you to merge it`);
|
|
1831
|
+
return;
|
|
1832
|
+
}
|
|
1833
|
+
if (verdict.verdict === 'REJECT') {
|
|
1834
|
+
const notMet = verdict.criteria.filter((c) => !c.met);
|
|
1835
|
+
const rejects = item.check_rejects ?? 0;
|
|
1836
|
+
if (rejects >= 1) {
|
|
1837
|
+
item.check_rejects = rejects + 1;
|
|
1838
|
+
const ids = notMet.length > 0 ? notMet.map((c) => c.id).join(', ') : 'no criterion marked';
|
|
1839
|
+
park(ctx, io, state, item, `pull request check rejected twice: ${ids} not met — evidence in .aidlc/state/${item.name}/pr-check.md in its worktree and on ${prRef}`, budget);
|
|
1840
|
+
return;
|
|
1841
|
+
}
|
|
1842
|
+
const limit = launchBlocked(state, ctx.now());
|
|
1843
|
+
if (limit !== null) {
|
|
1844
|
+
tell(ctx, item, `${said} — the fix waits for the session limit to reset at ${limit}`);
|
|
1845
|
+
return;
|
|
1846
|
+
}
|
|
1847
|
+
item.check_rejects = 1;
|
|
1848
|
+
item.step = 'building';
|
|
1849
|
+
tell(ctx, item, `${said} — relaunching the agent once with the findings`);
|
|
1850
|
+
// A REJECT that marks nothing not met still carries the evidence of each criterion.
|
|
1851
|
+
relaunchBuild(ctx, io, state, item, rejectPrompt(item, prRef, notMet.length > 0 ? notMet : verdict.criteria), budget);
|
|
1852
|
+
return;
|
|
1853
|
+
}
|
|
1854
|
+
const open = openQuestions(ctx, item);
|
|
1855
|
+
if (open > 0) {
|
|
1856
|
+
item.step = 'awaiting-merge';
|
|
1857
|
+
const questions = `${open} open question${open === 1 ? '' : 's'}`;
|
|
1858
|
+
tell(ctx, item, `CI green, ${said} — ${questions} wait${open === 1 ? 's' : ''} for you: run aidlc autopilot review ${item.name}, then merge ${prRef}`);
|
|
1859
|
+
notice(ctx, 'open questions', `${item.name}: ${questions} — ${prRef} waits for you to merge it`);
|
|
1860
|
+
return;
|
|
1861
|
+
}
|
|
1862
|
+
item.step = 'queued';
|
|
1863
|
+
if (!state.queue.includes(item.name))
|
|
1864
|
+
state.queue.push(item.name);
|
|
1865
|
+
tell(ctx, item, `CI green, ${said}, queued for merge`);
|
|
1866
|
+
}
|
|
1513
1867
|
function advancePr(ctx, io, state, item, budget) {
|
|
1514
1868
|
const view = prView(ctx, io, item);
|
|
1515
1869
|
// An open question makes this pass a stop at the pull request: opened and watched, closed
|
|
@@ -1545,6 +1899,17 @@ function advancePr(ctx, io, state, item, budget) {
|
|
|
1545
1899
|
const failing = failed.map((c) => c.name);
|
|
1546
1900
|
if (failing.length === 0) {
|
|
1547
1901
|
item.ci = 'passed';
|
|
1902
|
+
// Before the open questions: under `checked-merge` they are read once the check passed,
|
|
1903
|
+
// and under `pr` the item waits whatever (pr-checker-earns-merge/AC-1, AC-8, AC-11, AC-13).
|
|
1904
|
+
const stop = itemStops(item).stop_at;
|
|
1905
|
+
if (stop === 'pr' || stop === 'checked-merge') {
|
|
1906
|
+
if (item.check === undefined)
|
|
1907
|
+
launchCheck(ctx, io, state, item, budget);
|
|
1908
|
+
// A check that could not start is acted on in the same pass; a launched one waits for its verdict.
|
|
1909
|
+
if (item.check !== undefined && item.step === 'pr-open')
|
|
1910
|
+
actOnCheck(ctx, io, state, item, item.check, budget);
|
|
1911
|
+
return;
|
|
1912
|
+
}
|
|
1548
1913
|
if (open > 0) {
|
|
1549
1914
|
item.step = 'awaiting-merge';
|
|
1550
1915
|
const questions = `${open} open question${open === 1 ? '' : 's'}`;
|
|
@@ -1583,7 +1948,7 @@ function advancePr(ctx, io, state, item, budget) {
|
|
|
1583
1948
|
item.ci_failures = failures;
|
|
1584
1949
|
tell(ctx, item, `CI failed (${failing.join(', ')}), relaunching the agent once`);
|
|
1585
1950
|
item.step = 'building';
|
|
1586
|
-
|
|
1951
|
+
relaunchBuild(ctx, io, state, item, fixPrompt(item, failing, hostOf(ctx)), budget);
|
|
1587
1952
|
}
|
|
1588
1953
|
/**
|
|
1589
1954
|
* The item's checks, or null to do nothing with it this pass. On GitLab, the jobs of the
|
|
@@ -1729,6 +2094,14 @@ function serveQueue(ctx, io, state, budget) {
|
|
|
1729
2094
|
}
|
|
1730
2095
|
if (droppedIfMerged(ctx, state, item, prView(ctx, io, item), budget))
|
|
1731
2096
|
return;
|
|
2097
|
+
// The net under the verdict's discard: only a head a posted check passed is merged
|
|
2098
|
+
// (pr-checker-earns-merge/AC-12, AC-16, design D7).
|
|
2099
|
+
if (itemStops(item).stop_at === 'checked-merge' && !(item.check?.verdict?.verdict === 'PASS' && item.check.posted === true)) {
|
|
2100
|
+
dequeue(state, item);
|
|
2101
|
+
item.step = 'pr-open';
|
|
2102
|
+
tell(ctx, item, 'no posted PASS from the pull request check for this head — back to CI and the check');
|
|
2103
|
+
return;
|
|
2104
|
+
}
|
|
1732
2105
|
const host = hostOf(ctx);
|
|
1733
2106
|
if (host === 'gitlab' ? gitlabReleaseInFlight(ctx, io) : githubReleaseInFlight(ctx, io)) {
|
|
1734
2107
|
tell(ctx, item, 'waiting — a release is already in flight');
|
|
@@ -2007,6 +2380,8 @@ export function tick(ctx, state, budget) {
|
|
|
2007
2380
|
// `awaiting-review` is passed over: nothing to read until a person approves.
|
|
2008
2381
|
if (item.step === 'building')
|
|
2009
2382
|
advanceBuilding(ctx, io, state, item, budget);
|
|
2383
|
+
else if (item.step === 'checking')
|
|
2384
|
+
advanceChecking(ctx, io, state, item, budget);
|
|
2010
2385
|
else if (item.step === 'approved')
|
|
2011
2386
|
advanceApproved(ctx, io, state, item, budget);
|
|
2012
2387
|
else if (item.step === 'pr-open')
|
|
@@ -2060,6 +2435,18 @@ function waitingFor(i, host) {
|
|
|
2060
2435
|
return ` — waiting for you to merge ${ref(host, i.pr)}`;
|
|
2061
2436
|
return '';
|
|
2062
2437
|
}
|
|
2438
|
+
/** The item's pull request check in words, or '' when it has none (pr-checker-earns-merge/AC-8). */
|
|
2439
|
+
export function checkNote(i) {
|
|
2440
|
+
const c = i.check;
|
|
2441
|
+
if (c === undefined)
|
|
2442
|
+
return '';
|
|
2443
|
+
if (c.blocked !== undefined)
|
|
2444
|
+
return ` — check could not decide: ${c.blocked}`;
|
|
2445
|
+
if (c.verdict === undefined)
|
|
2446
|
+
return i.step === 'checking' ? ` — check ${c.n} running` : '';
|
|
2447
|
+
const notMet = c.verdict.criteria.filter((x) => !x.met).map((x) => x.id);
|
|
2448
|
+
return ` — check ${c.n}: ${c.verdict.verdict}${notMet.length > 0 ? ` (not met: ${notMet.join(', ')})` : ''}${c.posted ? '' : ', not posted yet'}`;
|
|
2449
|
+
}
|
|
2063
2450
|
/**
|
|
2064
2451
|
* The driver's line, shared by `status` and the watch view.
|
|
2065
2452
|
*
|
|
@@ -2092,7 +2479,7 @@ export function statusLines(ctx, state, host = 'github') {
|
|
|
2092
2479
|
lines.push('no items in flight');
|
|
2093
2480
|
for (const i of state.items) {
|
|
2094
2481
|
lines.push(`${i.name}: ${i.step}${i.pr ? ` PR #${i.pr}` : ''} — CI failures ${i.ci_failures ?? 0}` +
|
|
2095
|
-
`${waitingFor(i, host)}${i.error ? ` — last error: ${i.error}` : ''}`);
|
|
2482
|
+
`${checkNote(i)}${waitingFor(i, host)}${i.error ? ` — last error: ${i.error}` : ''}`);
|
|
2096
2483
|
lines.push(...decisionCards(ctx, i));
|
|
2097
2484
|
}
|
|
2098
2485
|
const queue = queueLine(state);
|