@rasensio/aidlc 2.1.0 → 2.3.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.
@@ -16,6 +16,7 @@
16
16
  * @module
17
17
  */
18
18
  import { type EffectiveRates } from '../cost/rates.js';
19
+ import { type Host } from '../core/host.js';
19
20
  import type { Notice } from './notify.js';
20
21
  import type { AutopilotConfig, AutopilotItem, AutopilotPaths, AutopilotState, ItemStep, TypedLaunch } from './state.js';
21
22
  import { type PausePhase, type Stops } from './stops.js';
@@ -111,6 +112,11 @@ export interface Budget {
111
112
  export declare const CONFLICT_FIX_LIMIT = 2;
112
113
  export declare class RateLimited extends Error {
113
114
  }
115
+ /**
116
+ * How the item's change request is named: `pull request #7`, or `merge request !7` on
117
+ * GitLab, in messages, notices and prompts alike (autopilot-gitlab-merge-requests/AC-17).
118
+ */
119
+ export declare function ref(host: Host, n: number | null): string;
114
120
  /**
115
121
  * @param pauses - `AIDLC_PAUSE_AFTER` as the agent will see it. Empty adds nothing,
116
122
  * so an item with no pauses gets the prompt it always did.
@@ -121,11 +127,11 @@ export declare function agentPrompt(item: {
121
127
  export declare function fixPrompt(item: {
122
128
  name: string;
123
129
  pr: number | null;
124
- }, failing: string[]): string;
130
+ }, failing: string[], host?: Host): string;
125
131
  export declare function conflictPrompt(item: {
126
132
  name: string;
127
133
  pr: number | null;
128
- }): string;
134
+ }, host?: Host): string;
129
135
  /** The stops an item is held to: those recorded when it started (autopilot-stop-controls/AC-6). */
130
136
  export declare function itemStops(item: AutopilotItem): Stops;
131
137
  /**
@@ -185,7 +191,7 @@ export type ApproveOutcome = {
185
191
  * Approve the phase an item is waiting on. Touches only autopilot's own state; the
186
192
  * next pass carries the item on (autopilot-stop-controls/AC-16, AC-17).
187
193
  */
188
- export declare function approveItem(state: AutopilotState, name: string): ApproveOutcome;
194
+ export declare function approveItem(state: AutopilotState, name: string, host?: Host): ApproveOutcome;
189
195
  /** One pass. Returns the new state; the caller saves it (not in a dry run). */
190
196
  export declare function tick(ctx: DriverCtx, state: AutopilotState, budget?: Budget): AutopilotState;
191
197
  /** Each item's step by name, to compare against after a change (autopilot-live-progress/AC-11). */
@@ -204,5 +210,5 @@ export declare function markStepChanges(state: AutopilotState, before: Map<strin
204
210
  */
205
211
  export declare function driverLine(stopped: boolean, state: AutopilotState, now: number, lastPass?: (iso: string) => string): string;
206
212
  export declare function queueLine(state: AutopilotState): string | null;
207
- export declare function statusLines(ctx: Pick<DriverCtx, 'fs' | 'paths' | 'now'>, state: AutopilotState): string[];
213
+ export declare function statusLines(ctx: Pick<DriverCtx, 'fs' | 'paths' | 'now'>, state: AutopilotState, host?: Host): string[];
208
214
  //# sourceMappingURL=driver.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"driver.d.ts","sourceRoot":"","sources":["../../src/autopilot/driver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,EAA0B,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAI/E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAe1C,OAAO,KAAK,EACV,eAAe,EACf,aAAa,EACb,cAAc,EACd,cAAc,EACd,QAAQ,EAGR,WAAW,EACZ,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAuD,KAAK,UAAU,EAAE,KAAK,KAAK,EAAE,MAAM,YAAY,CAAC;AAY9G,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,MAA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ED,+EAA+E;AAC/E,wBAAgB,IAAI,CAAC,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,cAAc,CAiC3F;AAED,mGAAmG;AACnG,wBAAgB,OAAO,CAAC,KAAK,EAAE,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;AAYD;;;;;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;AAED,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,CAYhI"}
@@ -20,6 +20,7 @@ import { microToUsd, priceUnits } from '../cost/rates.js';
20
20
  import { MODEL_ID_RE } from '../cost/types.js';
21
21
  import { hostFromConfigText } from '../core/host.js';
22
22
  import { classify, jobRef, parseRunJobs } from './ci-jobs.js';
23
+ import { GLAB_READ_RE, TAG_PIPELINES_ARGS, classifyJobs, jobsArgs, mergeArgs, mergedAnswer, mrCreateArgs, mrNumber, mrViewArgs, parseJobs, parseMr, releaseInFlight, retryArgs, } from './gitlab.js';
23
24
  import { REASON_MAX, RESET_WAIT_MAX_MS, codexEnd, emptyCodexProgress, firstLine, readClaudeResult, readCodexEvents, refusalSuffix, resetAt, stoppedBy, summaryLines, } from './result.js';
24
25
  import { capInForce, tokensLeft } from './cap.js';
25
26
  import { fmtTokens } from '../commands/cost.js';
@@ -49,6 +50,9 @@ function isReadOnly(cmd, args) {
49
50
  // (ci-infra-failure-reads-as-code-failure/AC-11); `run rerun` stays off the list.
50
51
  if (cmd === 'gh')
51
52
  return /^(pr checks|run list|pr view)\b/.test(a) || JOBS_READ_RE.test(a);
53
+ // The retry and the merge carry `--method`, so a dry run prints them (autopilot-gitlab-merge-requests/AC-16).
54
+ if (cmd === 'glab')
55
+ return a === '--version' || GLAB_READ_RE.test(a);
52
56
  if (cmd === 'git')
53
57
  return /^(rev-parse|status|merge-base)\b/.test(a);
54
58
  return /\broadmap next\b/.test(a) || (/\bcost\b/.test(a) && /--json/.test(a));
@@ -102,6 +106,18 @@ function transitionFailure(r) {
102
106
  }
103
107
  return r;
104
108
  }
109
+ /**
110
+ * How the item's change request is named: `pull request #7`, or `merge request !7` on
111
+ * GitLab, in messages, notices and prompts alike (autopilot-gitlab-merge-requests/AC-17).
112
+ */
113
+ export function ref(host, n) {
114
+ return host === 'gitlab' ? `merge request !${n}` : `pull request #${n}`;
115
+ }
116
+ /** `ref` at the start of a sentence. */
117
+ const Ref = (host, n) => {
118
+ const r = ref(host, n);
119
+ return r[0].toUpperCase() + r.slice(1);
120
+ };
105
121
  /**
106
122
  * @param pauses - `AIDLC_PAUSE_AFTER` as the agent will see it. Empty adds nothing,
107
123
  * so an item with no pauses gets the prompt it always did.
@@ -116,14 +132,14 @@ export function agentPrompt(item, pauses = '') {
116
132
  `the rule's review boundary: commit, release your claim, and stop.`
117
133
  : ''));
118
134
  }
119
- export function fixPrompt(item, failing) {
135
+ export function fixPrompt(item, failing, host = 'github') {
120
136
  return (`You are running unattended (AIDLC_UNATTENDED=1). Follow .aidlc/resources/rules/unattended.md. ` +
121
- `CI failed on pull request #${item.pr} for the AIDLC instance "${item.name}": ${failing.join(', ')}. ` +
137
+ `CI failed on ${ref(host, item.pr)} for the AIDLC instance "${item.name}": ${failing.join(', ')}. ` +
122
138
  `Find the cause, fix it on this branch, run the tests, commit, and stop. Do not push, merge or release.`);
123
139
  }
124
- export function conflictPrompt(item) {
140
+ export function conflictPrompt(item, host = 'github') {
125
141
  return (`You are running unattended (AIDLC_UNATTENDED=1). Follow .aidlc/resources/rules/unattended.md. ` +
126
- `Pull request #${item.pr} for the AIDLC instance "${item.name}" conflicts with main. Run ` +
142
+ `${Ref(host, item.pr)} for the AIDLC instance "${item.name}" conflicts with main. Run ` +
127
143
  `\`git fetch origin main\` and \`git merge origin/main\` on this branch, resolve every conflict keeping ` +
128
144
  `the intent of both sides, run the tests, commit the merge, and stop. Do not push, merge or release.`);
129
145
  }
@@ -938,16 +954,36 @@ function openPullRequest(ctx, io, state, item, budget) {
938
954
  failItem(ctx, state, item, `push failed: ${fail(push)}`, 'building');
939
955
  return;
940
956
  }
941
- // Off GitHub the pushed branch is the end: every later step is a `gh` call, and the work
942
- // itself succeeded, so the item is dropped rather than parked (gitlab-and-plain-git/AC-15, design D3).
957
+ // On plain git, and on GitLab without `glab`, the pushed branch is the end: the work itself
958
+ // succeeded, so the item is dropped rather than parked (gitlab-and-plain-git/AC-15, design D3).
959
+ // Upgrading without `glab` must not fail worse than that (autopilot-gitlab-merge-requests/AC-3, design D5).
943
960
  const host = hostOf(ctx);
944
- if (host !== 'github') {
945
- const said = `pushed ${item.branch} — host is ${host}, so autopilot opens no pull request; open and merge it yourself`;
946
- tell(ctx, item, said);
947
- notice(ctx, 'branch pushed', `${item.name}: ${said}`);
961
+ const stop = host === 'git'
962
+ ? `pushed ${item.branch} — host is git, so autopilot opens no pull request; open and merge it yourself`
963
+ : host === 'gitlab' && io.call('glab', ['--version'], { cwd: ctx.repo }).status !== 0
964
+ ? `pushed ${item.branch} — glab is not available, so autopilot opens no merge request; open and merge it yourself`
965
+ : null;
966
+ if (stop !== null) {
967
+ tell(ctx, item, stop);
968
+ notice(ctx, 'branch pushed', `${item.name}: ${stop}`);
948
969
  drop(state, item, budget);
949
970
  return;
950
971
  }
972
+ if (host === 'gitlab') {
973
+ if (!item.pr) {
974
+ // In the worktree, like `gh pr create`: glab reads host and project from its remote (AC-18).
975
+ const mr = io.call('glab', mrCreateArgs(item.branch), { cwd: item.worktree });
976
+ const n = mrNumber(mr.stdout);
977
+ if (mr.status !== 0 || (n === null && !mr.dry)) {
978
+ failItem(ctx, state, item, `mr create failed: ${fail(mr)}`, 'building');
979
+ return;
980
+ }
981
+ item.pr = n;
982
+ }
983
+ item.step = 'pr-open';
984
+ tell(ctx, item, `${ref(host, item.pr)} open`);
985
+ return;
986
+ }
951
987
  if (!item.pr) {
952
988
  const pr = io.call('gh', ['pr', 'create', '--base', 'main', '--head', item.branch, '--fill'], { cwd: item.worktree });
953
989
  const n = /\/pull\/(\d+)/.exec(pr.stdout)?.[1];
@@ -960,8 +996,15 @@ function openPullRequest(ctx, io, state, item, budget) {
960
996
  item.step = 'pr-open';
961
997
  tell(ctx, item, `pull request #${item.pr} open`);
962
998
  }
963
- /** `gh pr view`, or null when it cannot be read. Read-only, so a dry run makes it too. */
999
+ /**
1000
+ * `gh pr view`, or on GitLab the merge request read in GitHub's words; null when it
1001
+ * cannot be read. Read-only, so a dry run makes it too (autopilot-gitlab-merge-requests/AC-4, AC-5).
1002
+ */
964
1003
  function prView(ctx, io, item) {
1004
+ if (hostOf(ctx) === 'gitlab') {
1005
+ const mr = io.call('glab', mrViewArgs(item.pr ?? 0), { cwd: ctx.repo });
1006
+ return mr.status === 0 ? parseMr(mr.stdout) : null;
1007
+ }
965
1008
  const r = io.call('gh', ['pr', 'view', String(item.pr), '--json', 'state,mergeable'], { cwd: ctx.repo });
966
1009
  if (r.status !== 0)
967
1010
  return null;
@@ -980,7 +1023,7 @@ function prView(ctx, io, item) {
980
1023
  function droppedIfMerged(ctx, state, item, view, budget) {
981
1024
  if (view?.state !== 'MERGED')
982
1025
  return false;
983
- tell(ctx, item, `pull request #${item.pr} was merged outside autopilot — no longer tracked`);
1026
+ tell(ctx, item, `${ref(hostOf(ctx), item.pr)} was merged outside autopilot — no longer tracked`);
984
1027
  drop(state, item, budget);
985
1028
  return true;
986
1029
  }
@@ -995,7 +1038,7 @@ function answeredByPerson(ctx, io, state, item, view, budget) {
995
1038
  return true;
996
1039
  }
997
1040
  if (view?.state === 'CLOSED') {
998
- tell(ctx, item, `pull request #${item.pr} was closed without merging — no longer tracked`);
1041
+ tell(ctx, item, `${ref(hostOf(ctx), item.pr)} was closed without merging — no longer tracked`);
999
1042
  drop(state, item, budget);
1000
1043
  return true;
1001
1044
  }
@@ -1023,8 +1066,8 @@ function closeOut(ctx, io, state, item, budget) {
1023
1066
  // Closed by hand already: nothing to transition, and a second close-out commit
1024
1067
  // would fail on an empty index (autopilot-stop-controls/AC-22).
1025
1068
  if (COMPLETE_RE.test(ctx.fs.read(`${ctx.repo}/.aidlc/state/${item.name}/phase-deployment.yaml`) ?? '')) {
1026
- tell(ctx, item, `pull request #${item.pr} merged, and already closed on main — no longer tracked`);
1027
- notice(ctx, 'item closed', `${item.name}: pull request #${item.pr} merged, and already closed on main`);
1069
+ tell(ctx, item, `${ref(hostOf(ctx), item.pr)} merged, and already closed on main — no longer tracked`);
1070
+ notice(ctx, 'item closed', `${item.name}: ${ref(hostOf(ctx), item.pr)} merged, and already closed on main`);
1028
1071
  drop(state, item, budget);
1029
1072
  return;
1030
1073
  }
@@ -1037,8 +1080,8 @@ function closeOut(ctx, io, state, item, budget) {
1037
1080
  return;
1038
1081
  }
1039
1082
  }
1040
- tell(ctx, item, `pull request #${item.pr} merged by you, and closed`);
1041
- notice(ctx, 'item closed', `${item.name}: pull request #${item.pr} merged by you, and closed`);
1083
+ tell(ctx, item, `${ref(hostOf(ctx), item.pr)} merged by you, and closed`);
1084
+ notice(ctx, 'item closed', `${item.name}: ${ref(hostOf(ctx), item.pr)} merged by you, and closed`);
1042
1085
  drop(state, item, budget);
1043
1086
  }
1044
1087
  /** Close the instance on main. Shared by both close-outs so they cannot drift. */
@@ -1085,7 +1128,7 @@ function handleConflict(ctx, io, state, item, budget) {
1085
1128
  dequeue(state, item);
1086
1129
  item.step = 'building';
1087
1130
  tell(ctx, item, `conflicts with main — relaunching the agent to resolve it (attempt ${tries + 1} of ${CONFLICT_FIX_LIMIT})`);
1088
- launchAgent(ctx, io, state, item, conflictPrompt(item), budget);
1131
+ launchAgent(ctx, io, state, item, conflictPrompt(item, hostOf(ctx)), budget);
1089
1132
  }
1090
1133
  /**
1091
1134
  * The two `merge=union` cost ledgers a worktree collects between commits. `name` is
@@ -1193,24 +1236,21 @@ function advancePr(ctx, io, state, item, budget) {
1193
1236
  // A person merging before CI finishes is still the merge the stop asked for.
1194
1237
  if (atPr ? answeredByPerson(ctx, io, state, item, view, budget) : droppedIfMerged(ctx, state, item, view, budget))
1195
1238
  return;
1196
- const r = io.call('gh', ['pr', 'checks', String(item.pr), '--json', 'name,bucket,link'], { cwd: ctx.repo });
1197
- let checks = [];
1198
- try {
1199
- checks = JSON.parse(r.stdout || '[]');
1200
- }
1201
- catch {
1239
+ const host = hostOf(ctx);
1240
+ const read = readChecks(ctx, io, item, host, view);
1241
+ if (read === null)
1202
1242
  return;
1203
- }
1243
+ const { checks } = read;
1204
1244
  if (checks.length === 0) {
1205
1245
  item.ci = 'waiting';
1206
1246
  // GitHub runs no pull_request checks on a PR that conflicts, so "no checks
1207
1247
  // yet" would otherwise be waited on forever (AC-12).
1208
1248
  if (view?.mergeable === 'CONFLICTING') {
1209
- tell(ctx, item, `pull request #${item.pr} conflicts with main and has no checks`);
1249
+ tell(ctx, item, `${ref(hostOf(ctx), item.pr)} conflicts with main and has no checks`);
1210
1250
  upToDateWithMain(ctx, io, state, item, 'pr-open', budget);
1211
1251
  return;
1212
1252
  }
1213
- tell(ctx, item, `pull request #${item.pr} — waiting for checks to start`);
1253
+ tell(ctx, item, `${ref(hostOf(ctx), item.pr)} — waiting for checks to start`);
1214
1254
  return;
1215
1255
  }
1216
1256
  if (checks.some((c) => c.bucket === 'pending')) {
@@ -1223,8 +1263,8 @@ function advancePr(ctx, io, state, item, budget) {
1223
1263
  item.ci = 'passed';
1224
1264
  if (atPr) {
1225
1265
  item.step = 'awaiting-merge';
1226
- tell(ctx, item, `CI green — pull request #${item.pr} waits for you to merge it`);
1227
- notice(ctx, 'merge needed', `${item.name}: pull request #${item.pr} waits for you to merge it`);
1266
+ tell(ctx, item, `CI green — ${ref(hostOf(ctx), item.pr)} waits for you to merge it`);
1267
+ notice(ctx, 'merge needed', `${item.name}: ${ref(hostOf(ctx), item.pr)} waits for you to merge it`);
1228
1268
  return;
1229
1269
  }
1230
1270
  item.step = 'queued';
@@ -1233,7 +1273,7 @@ function advancePr(ctx, io, state, item, budget) {
1233
1273
  tell(ctx, item, 'CI green, queued for merge');
1234
1274
  return;
1235
1275
  }
1236
- if (waitedOnRunner(ctx, io, item, failed))
1276
+ if (waitedOnRunner(ctx, io, item, failed, read.gitlab))
1237
1277
  return;
1238
1278
  item.ci = 'failed';
1239
1279
  const failures = (item.ci_failures ?? 0) + 1;
@@ -1252,7 +1292,33 @@ function advancePr(ctx, io, state, item, budget) {
1252
1292
  item.ci_failures = failures;
1253
1293
  tell(ctx, item, `CI failed (${failing.join(', ')}), relaunching the agent once`);
1254
1294
  item.step = 'building';
1255
- launchAgent(ctx, io, state, item, fixPrompt(item, failing), budget);
1295
+ launchAgent(ctx, io, state, item, fixPrompt(item, failing, hostOf(ctx)), budget);
1296
+ }
1297
+ /**
1298
+ * The item's checks, or null to do nothing with it this pass. On GitLab, the jobs of the
1299
+ * merge request's head pipeline, read as `gh pr checks` reads checks; no current head
1300
+ * pipeline is no checks yet (autopilot-gitlab-merge-requests/AC-6..AC-8).
1301
+ */
1302
+ function readChecks(ctx, io, item, host, view) {
1303
+ if (host === 'gitlab') {
1304
+ // No merge request read, no pipeline to read: wait for the next pass (AC-5).
1305
+ if (view === null)
1306
+ return null;
1307
+ if (view.pipeline === null || view.pipeline === undefined)
1308
+ return { checks: [] };
1309
+ const r = io.call('glab', jobsArgs(view.pipeline), { cwd: ctx.repo });
1310
+ const jobs = r.status === 0 ? parseJobs(r.stdout) : null;
1311
+ if (jobs === null)
1312
+ return null;
1313
+ return { checks: jobs.jobs, gitlab: { id: view.pipeline, ...jobs } };
1314
+ }
1315
+ const r = io.call('gh', ['pr', 'checks', String(item.pr), '--json', 'name,bucket,link'], { cwd: ctx.repo });
1316
+ try {
1317
+ return { checks: JSON.parse(r.stdout || '[]') };
1318
+ }
1319
+ catch {
1320
+ return null;
1321
+ }
1256
1322
  }
1257
1323
  /**
1258
1324
  * When no failing check tested the code — no runner took the job, or the runner went away
@@ -1261,24 +1327,17 @@ function advancePr(ctx, io, state, item, budget) {
1261
1327
  * (ci-infra-failure-reads-as-code-failure/AC-3, AC-4, AC-10). Returns false when the
1262
1328
  * failure is to be counted as before (AC-8, AC-9).
1263
1329
  */
1264
- function waitedOnRunner(ctx, io, item, failed) {
1265
- const runs = new Map();
1266
- for (const check of failed) {
1267
- const ref = jobRef(check.link);
1268
- if (ref === null || runs.has(ref.run))
1269
- continue;
1270
- // One read per run, not per check (AC-1).
1271
- const read = io.call('gh', ['api', `repos/{owner}/{repo}/actions/runs/${ref.run}/jobs`], { cwd: ctx.repo });
1272
- runs.set(ref.run, read.status === 0 ? parseRunJobs(read.stdout) : null);
1273
- }
1274
- const verdict = classify(failed, runs);
1330
+ function waitedOnRunner(ctx, io, item, failed, gitlab) {
1331
+ const verdict = gitlab === undefined ? githubVerdict(ctx, io, failed) : gitlabVerdict(gitlab);
1275
1332
  if (verdict.kind === 'tested')
1276
1333
  return false;
1277
1334
  item.ci = 'untested';
1278
1335
  const names = verdict.checks.join(', ');
1279
1336
  let refused = null;
1280
1337
  for (const run of verdict.fresh) {
1281
- const rerun = io.call('gh', ['run', 'rerun', run, '--failed'], { cwd: ctx.repo });
1338
+ const rerun = gitlab === undefined
1339
+ ? io.call('gh', ['run', 'rerun', run, '--failed'], { cwd: ctx.repo })
1340
+ : io.call('glab', retryArgs(run), { cwd: ctx.repo });
1282
1341
  if (rerun.status !== 0) {
1283
1342
  refused = fail(rerun);
1284
1343
  break;
@@ -1294,11 +1353,28 @@ function waitedOnRunner(ctx, io, item, failed) {
1294
1353
  // it — including a re-run that failed again between two passes, where item.ci already
1295
1354
  // read untested (AC-5, design D4).
1296
1355
  if (item.last_event?.text !== text) {
1297
- notice(ctx, 'runner needed', `${item.name}: pull request #${item.pr} — CI did not run its tests (${names})`);
1356
+ notice(ctx, 'runner needed', `${item.name}: ${ref(hostOf(ctx), item.pr)} — CI did not run its tests (${names})`);
1298
1357
  }
1299
1358
  tell(ctx, item, text);
1300
1359
  return true;
1301
1360
  }
1361
+ /** Whether the failing checks' Actions jobs ran a step that failed (ci-infra-failure-reads-as-code-failure). */
1362
+ function githubVerdict(ctx, io, failed) {
1363
+ const runs = new Map();
1364
+ for (const check of failed) {
1365
+ const ref = jobRef(check.link);
1366
+ if (ref === null || runs.has(ref.run))
1367
+ continue;
1368
+ // One read per run, not per check (AC-1).
1369
+ const read = io.call('gh', ['api', `repos/{owner}/{repo}/actions/runs/${ref.run}/jobs`], { cwd: ctx.repo });
1370
+ runs.set(ref.run, read.status === 0 ? parseRunJobs(read.stdout) : null);
1371
+ }
1372
+ return classify(failed, runs);
1373
+ }
1374
+ /** The same question from jobs already read: GitLab names the reason (autopilot-gitlab-merge-requests/AC-9..AC-11). */
1375
+ function gitlabVerdict(p) {
1376
+ return classifyJobs(p.jobs.filter((j) => j.bucket === 'fail' || j.bucket === 'cancel'), p.id, p.retried);
1377
+ }
1302
1378
  /**
1303
1379
  * Mark the deployment artifact complete so `aidlc transition` can close the
1304
1380
  * instance — whatever status the agent left it in; replacing only
@@ -1318,6 +1394,34 @@ function markDeploymentComplete(ctx, name) {
1318
1394
  ctx.fs.write(file, next);
1319
1395
  return true;
1320
1396
  }
1397
+ /** The last `release.yml` run is queued or running; unreadable is nothing in flight. */
1398
+ function githubReleaseInFlight(ctx, io) {
1399
+ const runs = io.call('gh', ['run', 'list', '--workflow=release.yml', '-L', '1', '--json', 'status'], { cwd: ctx.repo });
1400
+ try {
1401
+ const status = JSON.parse(runs.stdout || '[]')[0]?.status;
1402
+ return status === 'queued' || status === 'in_progress';
1403
+ }
1404
+ catch {
1405
+ // unreadable — treat as nothing in flight; the release command checks the tree itself
1406
+ return false;
1407
+ }
1408
+ }
1409
+ /** The latest tag pipeline is still going (autopilot-gitlab-merge-requests/AC-12, design D4). */
1410
+ function gitlabReleaseInFlight(ctx, io) {
1411
+ const r = io.call('glab', [...TAG_PIPELINES_ARGS], { cwd: ctx.repo });
1412
+ return r.status === 0 && releaseInFlight(r.stdout);
1413
+ }
1414
+ /**
1415
+ * Merge exactly `sha`, and only call it merged when GitLab says so: a merge answered
1416
+ * before it finished must not pull a `main` without it and release that
1417
+ * (autopilot-gitlab-merge-requests/AC-13, AC-14).
1418
+ */
1419
+ function gitlabMerge(ctx, io, item, sha) {
1420
+ const r = io.call('glab', mergeArgs(item.pr ?? 0, sha || 'HEAD'), { cwd: ctx.repo });
1421
+ if (r.status !== 0 || r.dry || mergedAnswer(r.stdout))
1422
+ return r;
1423
+ return { ...r, status: 1, stderr: `GitLab did not report ${ref('gitlab', item.pr)} merged` };
1424
+ }
1321
1425
  function serveQueue(ctx, io, state, budget) {
1322
1426
  const name = state.queue[0];
1323
1427
  if (!name)
@@ -1334,16 +1438,10 @@ function serveQueue(ctx, io, state, budget) {
1334
1438
  }
1335
1439
  if (droppedIfMerged(ctx, state, item, prView(ctx, io, item), budget))
1336
1440
  return;
1337
- const runs = io.call('gh', ['run', 'list', '--workflow=release.yml', '-L', '1', '--json', 'status'], { cwd: ctx.repo });
1338
- try {
1339
- const status = JSON.parse(runs.stdout || '[]')[0]?.status;
1340
- if (status === 'queued' || status === 'in_progress') {
1341
- tell(ctx, item, 'waiting — a release is already in flight');
1342
- return;
1343
- }
1344
- }
1345
- catch {
1346
- // unreadable — treat as nothing in flight; the release command checks the tree itself
1441
+ const host = hostOf(ctx);
1442
+ if (host === 'gitlab' ? gitlabReleaseInFlight(ctx, io) : githubReleaseInFlight(ctx, io)) {
1443
+ tell(ctx, item, 'waiting — a release is already in flight');
1444
+ return;
1347
1445
  }
1348
1446
  const branch = io.call('git', ['rev-parse', '--abbrev-ref', 'HEAD'], { cwd: ctx.repo });
1349
1447
  if (branch.stdout.trim() !== 'main' && !ctx.dryRun) {
@@ -1363,7 +1461,9 @@ function serveQueue(ctx, io, state, budget) {
1363
1461
  const steps = [
1364
1462
  [
1365
1463
  'merge',
1366
- () => io.call('gh', ['pr', 'merge', String(item.pr), '--merge', '--match-head-commit', sha || 'HEAD'], { cwd: ctx.repo }),
1464
+ () => host === 'gitlab'
1465
+ ? gitlabMerge(ctx, io, item, sha)
1466
+ : io.call('gh', ['pr', 'merge', String(item.pr), '--merge', '--match-head-commit', sha || 'HEAD'], { cwd: ctx.repo }),
1367
1467
  ],
1368
1468
  ['pull', () => io.call('git', ['pull', '--rebase', '--autostash'], { cwd: ctx.repo })],
1369
1469
  ];
@@ -1542,13 +1642,13 @@ export function forgetItem(state, name) {
1542
1642
  * Approve the phase an item is waiting on. Touches only autopilot's own state; the
1543
1643
  * next pass carries the item on (autopilot-stop-controls/AC-16, AC-17).
1544
1644
  */
1545
- export function approveItem(state, name) {
1645
+ export function approveItem(state, name, host = 'github') {
1546
1646
  const item = state.items.find((i) => i.name === name);
1547
1647
  if (item === undefined) {
1548
1648
  return { ok: false, reason: `autopilot is not tracking "${name}" — \`aidlc autopilot status\` lists what it tracks` };
1549
1649
  }
1550
1650
  if (item.step === 'awaiting-merge') {
1551
- return { ok: false, reason: `${name} is waiting for you to merge pull request #${item.pr} — merging it is the approval` };
1651
+ return { ok: false, reason: `${name} is waiting for you to merge ${ref(host, item.pr)} — merging it is the approval` };
1552
1652
  }
1553
1653
  if (item.step !== 'awaiting-review' || item.review === undefined) {
1554
1654
  return { ok: false, reason: `${name} is not waiting for a review (it is ${item.step})` };
@@ -1615,14 +1715,14 @@ export function markStepChanges(state, before, now) {
1615
1715
  }
1616
1716
  }
1617
1717
  /** What a person is being waited on for, in words (autopilot-stop-controls/AC-14, AC-20). */
1618
- function waitingFor(i) {
1718
+ function waitingFor(i, host) {
1619
1719
  if (i.step === 'awaiting-review') {
1620
1720
  return ` — waiting for your review after ${i.review ?? 'a phase'} in ${i.worktree}; approve with \`aidlc autopilot approve ${i.name}\``;
1621
1721
  }
1622
1722
  if (i.step === 'approved')
1623
1723
  return ` — ${i.review ?? 'phase'} approved; carries on at the next pass with a free build slot`;
1624
1724
  if (i.step === 'awaiting-merge')
1625
- return ` — waiting for you to merge pull request #${i.pr}`;
1725
+ return ` — waiting for you to merge ${ref(host, i.pr)}`;
1626
1726
  return '';
1627
1727
  }
1628
1728
  /**
@@ -1641,13 +1741,13 @@ export function driverLine(stopped, state, now, lastPass = (iso) => iso) {
1641
1741
  export function queueLine(state) {
1642
1742
  return state.queue.length > 0 ? `merge queue: ${state.queue.join(' → ')}` : null;
1643
1743
  }
1644
- export function statusLines(ctx, state) {
1744
+ export function statusLines(ctx, state, host = 'github') {
1645
1745
  const lines = [driverLine(ctx.fs.exists(ctx.paths.stop), state, ctx.now())];
1646
1746
  if (state.items.length === 0)
1647
1747
  lines.push('no items in flight');
1648
1748
  for (const i of state.items) {
1649
1749
  lines.push(`${i.name}: ${i.step}${i.pr ? ` PR #${i.pr}` : ''} — CI failures ${i.ci_failures ?? 0}` +
1650
- `${waitingFor(i)}${i.error ? ` — last error: ${i.error}` : ''}`);
1750
+ `${waitingFor(i, host)}${i.error ? ` — last error: ${i.error}` : ''}`);
1651
1751
  }
1652
1752
  const queue = queueLine(state);
1653
1753
  if (queue !== null)