@bongos/core 1.19.23 → 1.19.25

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/.bongos-core.json CHANGED
@@ -2,11 +2,11 @@
2
2
  "artifact": "bongos-core",
3
3
  "manifest_schema": 1,
4
4
  "generator": "scripts/gds/package-core.js",
5
- "core_version": "1.19.23",
6
- "core_contract": "1.19.23",
7
- "source_commit": "fcdc2c0100a2b96183b34980f7c33572b67c7d1f",
5
+ "core_version": "1.19.25",
6
+ "core_contract": "1.19.25",
7
+ "source_commit": "5946896ddb840e6d7a52eadf92a5e42d47d716fa",
8
8
  "source_ref": "HEAD",
9
- "built_at": "2026-08-11T01:44:34.493Z",
9
+ "built_at": "2026-08-11T13:18:22.297Z",
10
10
  "redaction": {
11
11
  "model": "docs-redacted+functional-verbatim",
12
12
  "docs_redacted": 285,
@@ -17,7 +17,7 @@
17
17
  "gate": "passed"
18
18
  },
19
19
  "file_count": 1510,
20
- "tree_sha256": "80499ca716f5acc869706f3832aba22ffa0facdf31abd6eca71baec9b273d628",
20
+ "tree_sha256": "159afabb8c0c958bde0c962fb152ab372f6c6e34333f2d6718a4b2f2e40dd47b",
21
21
  "files": [
22
22
  {
23
23
  "path": ".claude/skills/blocker-review/SKILL.md",
@@ -3362,7 +3362,7 @@
3362
3362
  {
3363
3363
  "path": "modules/lifecycle/github-push.js",
3364
3364
  "mode": "0000644",
3365
- "sha256": "200de3b5be6b1f3b0612dea91409f44aa3d5b76f8f90fb71e4e5ced43a0890fb"
3365
+ "sha256": "c8f356746096a6fe39e456b12367d29b6bbf4e39df1515c09144c95e239f1b49"
3366
3366
  },
3367
3367
  {
3368
3368
  "path": "modules/lifecycle/goal-advisory.js",
@@ -3417,7 +3417,7 @@
3417
3417
  {
3418
3418
  "path": "modules/lifecycle/publish-reconciler.js",
3419
3419
  "mode": "0000644",
3420
- "sha256": "7f42dfe5b16dff0e3833b0a586c5b04592aeaee1aa1f4f41c0255a16db1a14fc"
3420
+ "sha256": "964af2331007a4cfb9142e7245d7625cf21c973e4f885e0171855b9e188b9e95"
3421
3421
  },
3422
3422
  {
3423
3423
  "path": "modules/lifecycle/routes/analytics.js",
@@ -3457,7 +3457,7 @@
3457
3457
  {
3458
3458
  "path": "modules/lifecycle/routes/tasks.js",
3459
3459
  "mode": "0000644",
3460
- "sha256": "add6acd00adc842e90348ca789da0a473aa2dc68d949cf2b5586c68ef5eaa1be"
3460
+ "sha256": "f5041a43ea0a74bc6b16f8ceb6490c70090e7959e66f137c92040ee842db1ec0"
3461
3461
  },
3462
3462
  {
3463
3463
  "path": "modules/lifecycle/routes/versions.js",
@@ -4002,12 +4002,12 @@
4002
4002
  {
4003
4003
  "path": "package-lock.json",
4004
4004
  "mode": "0000644",
4005
- "sha256": "969211290cee8ccee357109c325ff4741c8cce3319d520b22506126099beea7e"
4005
+ "sha256": "61a5251f8c5ae2be0e5d3cce0dbff87afc4ec3b5327d128a04ad67b6283b23ba"
4006
4006
  },
4007
4007
  {
4008
4008
  "path": "package.json",
4009
4009
  "mode": "0000644",
4010
- "sha256": "b00d5423d5019e305bb488af793202ccb4d3089da6c129851e32f85ea4219904"
4010
+ "sha256": "11341042a94fdb5a03fd8d318a6471763f0b97d46efb13b00743f4abee686839"
4011
4011
  },
4012
4012
  {
4013
4013
  "path": "public-docs/index.html",
@@ -5197,7 +5197,7 @@
5197
5197
  {
5198
5198
  "path": "scripts/gds/ship.js",
5199
5199
  "mode": "0000644",
5200
- "sha256": "085a7feeff06fa7d2b833c483795161e2c4a6ee79630e2f09d7ae2f06eeb253c"
5200
+ "sha256": "1a00cb0c8ab216bab06b60b4ad1eaa18dc521eafd62ebe34f8fd35c7ff12e486"
5201
5201
  },
5202
5202
  {
5203
5203
  "path": "scripts/gds/smoke-batch-claim.sh",
@@ -5522,7 +5522,7 @@
5522
5522
  {
5523
5523
  "path": "src/bongos/routes/auth.js",
5524
5524
  "mode": "0000644",
5525
- "sha256": "2cacde2aa0984457904c0a29cc0dd0d41e32be89b7b6e401d885662805c3de5e"
5525
+ "sha256": "b1389bf7cb4d53a27d332106ddbcd9327d76521c2330b4763d4ed0919c52f2a5"
5526
5526
  },
5527
5527
  {
5528
5528
  "path": "src/bongos/routes/backup.js",
@@ -5627,7 +5627,7 @@
5627
5627
  {
5628
5628
  "path": "src/module-api.js",
5629
5629
  "mode": "0000644",
5630
- "sha256": "0e4203ec0098beb9a54a4ea56b3c5701cfca5bb02b6676114a9257f5b353aff5"
5630
+ "sha256": "3b6cabeb91e7181b5d83689bb3e81b4113e0c1a357e6b040fc0caecbf405802b"
5631
5631
  },
5632
5632
  {
5633
5633
  "path": "src/module-loader/loader.js",
@@ -5797,7 +5797,7 @@
5797
5797
  {
5798
5798
  "path": "tests/auth_error_brand.mjs",
5799
5799
  "mode": "0000644",
5800
- "sha256": "e28bdcf3149d3baa15fdd4d5a44276953abfa3633ff37923f75355be746fc840"
5800
+ "sha256": "e94cdcd827f8e981b62c4f9f403678d5dda0af6e5fb5cbf1cb667b94eb1bfc49"
5801
5801
  },
5802
5802
  {
5803
5803
  "path": "tests/auth_flow_slice1.mjs",
@@ -6387,7 +6387,7 @@
6387
6387
  {
6388
6388
  "path": "tests/github_push_land_proof.mjs",
6389
6389
  "mode": "0000644",
6390
- "sha256": "080a19cae0faf168b4b7fa31d1a68d0fe84b3d5b41c9bbfda1f5ecee34ad8ca4"
6390
+ "sha256": "c55433099e4681a8dd091873e9f8687f35e629b4a4ad3a3c3dd462860070fc59"
6391
6391
  },
6392
6392
  {
6393
6393
  "path": "tests/github_push_merge_driver.mjs",
@@ -7097,7 +7097,7 @@
7097
7097
  {
7098
7098
  "path": "tests/publish_branch_route.mjs",
7099
7099
  "mode": "0000644",
7100
- "sha256": "5f9a083a4fc9c54683a277afcd14aff10db0dda1082e65cb5032445b25026139"
7100
+ "sha256": "99572892490e209835aae6479370e97b49585bfaa719c788a4d06d92407a9a7d"
7101
7101
  },
7102
7102
  {
7103
7103
  "path": "tests/publish_manifest.mjs",
@@ -7107,7 +7107,7 @@
7107
7107
  {
7108
7108
  "path": "tests/publish_reconciler.mjs",
7109
7109
  "mode": "0000644",
7110
- "sha256": "fa54fe19a54153ce65f8a98ccce22c9aad7e2c928a648fb2fc621067168eb703"
7110
+ "sha256": "240337de03354de198d6baaaca9f33b267aceb40a8ba43d31303eb21fad9226c"
7111
7111
  },
7112
7112
  {
7113
7113
  "path": "tests/rank_gate.mjs",
@@ -7377,7 +7377,7 @@
7377
7377
  {
7378
7378
  "path": "tests/ship_ci_deploy.mjs",
7379
7379
  "mode": "0000644",
7380
- "sha256": "de59e8ed0d1a0e30b52994fe1bf3e1864706613a1329d967f74eeae277c1948e"
7380
+ "sha256": "e236bc3d6882bc6ddf5d389371a92a96aec62769f14c37bbca31810bcbea0d61"
7381
7381
  },
7382
7382
  {
7383
7383
  "path": "tests/ship_preflight.mjs",
@@ -465,6 +465,54 @@ function prReferencesTask(status, taskId) {
465
465
  return new RegExp(`\\btask\\s+#?${Number(taskId)}\\b`, 'i').test(hay);
466
466
  }
467
467
 
468
+ // task 1002645 — locate a task's PR by the "task <id>: …" TITLE convention, for when
469
+ // the reconciler cannot derive the branch. The sweep derives claude/<worktree_name>
470
+ // (the dev-box convention), but a laptop/wave ship pushes its own branch name
471
+ // (worktree-<worktree_name>), so the derived branch finds no PR and the sweep's whole
472
+ // PR path — the mergeIfGreen nudge (the ONLY green-PR merger where native auto-merge
473
+ // is repo-disallowed), conflict heal, land proof — never engages; the task strands at
474
+ // 'confirmed' (wave PRs 34/35/36). Both publish paths title their PR "task <id>: …"
475
+ // (openOrFindPullRequest above; ship.js buildPrCreateArgv), so a TITLE-PREFIX match
476
+ // positively binds a PR to its task. Deliberately TIGHTER than prReferencesTask
477
+ // (title+body word match): the search widens the candidate set from "this branch's
478
+ // own PR" to "recent PRs", and a body MENTION of a task must not bind it.
479
+ //
480
+ // Uses the REST pulls list (real-time — the search API lags on fresh PRs), newest
481
+ // first, and returns the first title match whose head is a same-repo, safe-named
482
+ // branch (a fork's head is invisible to the owner:branch lookups downstream):
483
+ // { branch, pr_number, pr_state, merged }. Null when nothing matches. Pure w.r.t.
484
+ // injected token/repoInfo/fetchImpl for tests.
485
+ async function findTaskPullRequest({ taskId }, deps = {}) {
486
+ if (!Number.isInteger(Number(taskId))) return null;
487
+ const token = await resolveToken(deps);
488
+ if (!token) throw err('PUSH_UNCONFIGURED');
489
+ const repoInfo = deps.repoInfo || loadRepoInfo();
490
+ if (!repoInfo || repoInfo.error) throw err('NO_REPO_INFO');
491
+ const { owner, repo } = repoInfo;
492
+ const doFetch = deps.fetchImpl || fetch;
493
+ const res = await doFetch(
494
+ `https://api.github.com/repos/${owner}/${repo}/pulls?state=all&sort=created&direction=desc&per_page=100`,
495
+ { headers: ghHeaders(token) }
496
+ );
497
+ if (!res.ok) throw err('STATUS_FETCH_FAILED', { status: res.status });
498
+ const prs = await res.json();
499
+ if (!Array.isArray(prs)) return null;
500
+ const titleRe = new RegExp(`^task\\s+#?${Number(taskId)}\\b`, 'i');
501
+ for (const pr of prs) {
502
+ if (!pr || !titleRe.test(String(pr.title || ''))) continue;
503
+ const head = pr.head || {};
504
+ if (!head.repo || head.repo.full_name !== `${owner}/${repo}`) continue;
505
+ if (!isSafeBranch(head.ref)) continue;
506
+ return {
507
+ branch: head.ref,
508
+ pr_number: pr.number || null,
509
+ pr_state: pr.state || null,
510
+ merged: !!pr.merged_at,
511
+ };
512
+ }
513
+ return null;
514
+ }
515
+
468
516
  // ---------------------------------------------------------------------------
469
517
  // Active merge driver (task 1162) — land a green PR the moment it's mergeable
470
518
  // instead of waiting on GitHub's auto-merge daemon.
@@ -1000,6 +1048,7 @@ module.exports = {
1000
1048
  landConfirmed,
1001
1049
  landProvenForTask,
1002
1050
  prReferencesTask,
1051
+ findTaskPullRequest,
1003
1052
  scrubCredential,
1004
1053
  isAncestorOfDefaultBranch,
1005
1054
  resolveToken,
@@ -240,20 +240,14 @@ async function runSweep(deps = {}) {
240
240
  }
241
241
  return flagged;
242
242
  };
243
- for (const r of rows) {
244
- const branch = r.worktree_name ? `claude/${r.worktree_name}` : null;
245
- if (branch) branchesSeen.add(branch);
246
- const branchUsable = !!branch && push.isSafeBranch(branch) && branchCount.get(branch) === 1;
247
- if (branch && branchCount.get(branch) > 1) {
248
- // A reused worktree_name maps a branch to >1 confirmed task, so a merged PR is
249
- // ambiguous — but each task's OWN head_sha is not, so we skip only the branch/PR
250
- // path and let the head_sha ancestry land-check below resolve it unambiguously.
251
- logFn(`[publish-reconciler] task ${r.task_id}: branch ${branch} maps to >1 confirmed task — using head_sha land-check only`);
252
- }
253
243
 
254
- let landed = false;
255
- let landNote = '';
256
- let branchStatus = null;
244
+ // task 1002645 — the per-branch PR path (merge nudge → conflict/stale heal →
245
+ // publish-status), extracted so it can run TWICE for one task: first on the
246
+ // derived claude/<worktree_name> branch (the dev-box convention), then — when
247
+ // that finds no PR — on the REAL branch adopted from the task's own PR
248
+ // (findTaskPullRequest). Mutates the sweep counters via closure; returns
249
+ // { status, prNotLanded }.
250
+ const sweepBranchPath = async (r, branch) => {
257
251
  // task 1002472 — set when a PR exists but has not fully landed. Classifies the
258
252
  // unprovable reason for the observability below (which the old bare `continue`
259
253
  // skipped). task 1002615: it no longer suppresses the land proof — the proof
@@ -261,8 +255,7 @@ async function runSweep(deps = {}) {
261
255
  // so an open PR still can't ship by reference, while a task whose WORK is
262
256
  // already on main (out-of-band merge) can now prove it by ancestry.
263
257
  let prNotLanded = false;
264
-
265
- if (branchUsable) {
258
+ {
266
259
  // Active merge driver (task 1162): GitHub's auto-merge fires on check-completion
267
260
  // EVENTS, so a PR whose auto-merge was re-armed AFTER its checks already went
268
261
  // green can sit open forever (the PR #125 stall). Before checking for a land,
@@ -399,7 +392,53 @@ async function runSweep(deps = {}) {
399
392
  // short-circuit that window.
400
393
  prNotLanded = true;
401
394
  }
402
- branchStatus = status;
395
+ return { status, prNotLanded };
396
+ }
397
+ };
398
+
399
+ for (const r of rows) {
400
+ let branch = r.worktree_name ? `claude/${r.worktree_name}` : null;
401
+ if (branch) branchesSeen.add(branch);
402
+ const branchUsable = !!branch && push.isSafeBranch(branch) && branchCount.get(branch) === 1;
403
+ if (branch && branchCount.get(branch) > 1) {
404
+ // A reused worktree_name maps a branch to >1 confirmed task, so a merged PR is
405
+ // ambiguous — but each task's OWN head_sha is not, so we skip only the branch/PR
406
+ // path and let the head_sha ancestry land-check below resolve it unambiguously.
407
+ logFn(`[publish-reconciler] task ${r.task_id}: branch ${branch} maps to >1 confirmed task — using head_sha land-check only`);
408
+ }
409
+
410
+ let landed = false;
411
+ let landNote = '';
412
+ let branchStatus = null;
413
+ let prNotLanded = false;
414
+
415
+ if (branchUsable) {
416
+ ({ status: branchStatus, prNotLanded } = await sweepBranchPath(r, branch));
417
+ }
418
+
419
+ // task 1002645 — the claude/<worktree_name> derivation is the DEV-BOX convention;
420
+ // a laptop/wave ship pushes its own branch name (worktree-<worktree_name>), so the
421
+ // derived branch finds no PR and the merge nudge / conflict heal / land proof all
422
+ // sat idle while the task stranded at 'confirmed' (wave PRs 34/35/36 — native
423
+ // auto-merge is repo-disallowed, so the sweep's mergeIfGreen is the only green-PR
424
+ // merger). When the derived branch yields no PR, find the task's PR by the
425
+ // "task <id>: …" TITLE convention and re-run the branch path on its real head
426
+ // branch. Best-effort: a search miss just waits for the next sweep.
427
+ if ((!branchStatus || branchStatus.pr_state === 'none')
428
+ && typeof push.findTaskPullRequest === 'function') {
429
+ try {
430
+ const found = await push.findTaskPullRequest({ taskId: r.task_id });
431
+ if (found && found.branch && found.branch !== branch && push.isSafeBranch(found.branch)) {
432
+ logFn(
433
+ `[publish-reconciler] task ${r.task_id}: no PR on ${branch || '(no derived branch)'} — adopted ${found.branch} from PR #${found.pr_number} by title convention`
434
+ );
435
+ branch = found.branch;
436
+ branchesSeen.add(branch);
437
+ ({ status: branchStatus, prNotLanded } = await sweepBranchPath(r, branch));
438
+ }
439
+ } catch (_) {
440
+ /* best-effort: a PR-search miss waits for the next sweep */
441
+ }
403
442
  }
404
443
 
405
444
  // task 1547 — prove the land belongs to THIS task before shipping. landConfirmed
@@ -1718,6 +1718,19 @@ module.exports = function buildTasksRouter() {
1718
1718
  if (!(await gateTaskOwnership(req, res, id))) return;
1719
1719
  const { head_sha: headSha } = req.body;
1720
1720
  if (!/^[0-9a-f]{7,64}$/.test(headSha)) return res.fail('bad_head_sha', 400);
1721
+ // task 1002645: the laptop ci-land pushes with the BUILDER's own credential, so
1722
+ // the server-mediated path that records claims.published_head_sha (task 1547)
1723
+ // never runs — landProvenForTask then has neither tip nor PR and the reconciler
1724
+ // strands the task at 'confirmed' forever (wave PRs 34/35/36). ship.js calls
1725
+ // this endpoint with the exact pushed tip at the moment of the push, so record
1726
+ // it here too. Sits BEFORE the credential 503 on purpose: the tip is true
1727
+ // regardless, and a later-provisioned credential lets the sweep heal
1728
+ // retroactively. Best-effort, mirroring publish-branch.
1729
+ try {
1730
+ await db.setClaimPublishedSha({ taskId: id, builderId: req.builder.id, sha: headSha });
1731
+ } catch (e) {
1732
+ console.error('[gds] setClaimPublishedSha via attest-gate (non-blocking)', id, e && e.message);
1733
+ }
1721
1734
  if (!githubPush.isConfigured()) {
1722
1735
  return res.fail('push_unconfigured', { status: 503, message: 'No server push credential (GitHub App / GITHUB_PUSH_TOKEN) to post the gate attestation. ' +
1723
1736
  'A gate-surface PR will need an owner review until the operator provisions it.' });
package/package-lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@bongos/core",
3
- "version": "1.19.23",
3
+ "version": "1.19.25",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@bongos/core",
9
- "version": "1.19.23",
9
+ "version": "1.19.25",
10
10
  "license": "AGPL-3.0-or-later",
11
11
  "dependencies": {
12
12
  "express": "^4.21.2",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bongos/core",
3
- "version": "1.19.23",
3
+ "version": "1.19.25",
4
4
  "description": "Cloud Bongos — the AI-first build platform core (GDS + platform surfaces + module system), installed as a versioned dependency (ADR 0108).",
5
5
  "license": "AGPL-3.0-or-later",
6
6
  "main": "src/platform-server.js",
@@ -1326,6 +1326,23 @@ function printLandPending(taskId, opts = {}) {
1326
1326
  for (const line of landPendingLines(taskId, opts)) console.log(line);
1327
1327
  }
1328
1328
 
1329
+ // task 1002645 — the honest close-out when the PR MERGED but the server refused the
1330
+ // confirmed→shipped flip (reconcile_blocked: the task-1547 land proof missed — a
1331
+ // wrong/missing published tip, or the matched PR doesn't reference this task). The
1332
+ // optimistic "NOT a failure" banner was a lie here: without proof the auto-land can
1333
+ // NEVER finish, and the wave-5 ships sat at 'confirmed' with their last signal
1334
+ // saying everything was fine. Name the refusal and the remedy instead. Pure +
1335
+ // exported so the wording is pinned by tests/ship_ci_deploy.mjs.
1336
+ function reconcileBlockedLines(taskId, reason) {
1337
+ return [
1338
+ ` ci-land: the PR MERGED, but the task did NOT flip to 'shipped' — the server could not prove the land is`,
1339
+ ` THIS task's: ${reason}.`,
1340
+ ` The server reconciler retries the proof every ~5 min, so a late-recorded tip or PR reference still lands`,
1341
+ ` on its own. Re-run \`node scripts/gds/ship.js ${taskId}\` to re-drive it; if it stays blocked the server`,
1342
+ ` flags the task needs_rebase and /builder-start will show the remedy.`,
1343
+ ];
1344
+ }
1345
+
1329
1346
  // One module-scope sleep command shared by both poll loops (task 1093 / C9). A
1330
1347
  // child `node -e setTimeout` is used (not `await new Promise`) so it blocks
1331
1348
  // identically in the SYNCHRONOUS pollCiDeploy and the async pollServerPublish —
@@ -1341,13 +1358,26 @@ const POLL_SLEEP_CMD = 'node -e "setTimeout(()=>{}, 10000)"';
1341
1358
  async function pollServerPublish(taskId, branch) {
1342
1359
  const TRIES = 54; // ~9 min at 10s — checks + auto-merge + Actions deploy
1343
1360
  console.log(' ci-land: waiting for auto-merge + prod deploy (polling the server)...');
1361
+ // task 1002645: GitHub can report merged+deployed while the SERVER refused the
1362
+ // confirmed→shipped flip (reconcile_blocked — the task-1547 land proof missed).
1363
+ // "Prod is live" + exit here was a lie that left the task stranded with no
1364
+ // signal. Say the real reason and keep polling — attest-gate now records the
1365
+ // pushed tip, so the proof usually heals within the window.
1366
+ let blockedReason = null;
1344
1367
  for (let i = 0; i < TRIES; i++) {
1345
1368
  const r = await (await cliClient()).tasks.getTasksIdPublishStatus({ id: taskId, query: { branch } });
1346
1369
  if (r.ok && r.data) {
1347
1370
  const outcome = classifyLandOutcome(r.data);
1348
1371
  if (outcome === 'shipped') {
1349
- console.log(` ci-land: merged (${String(r.data.merge_sha || '').slice(0, 8)}) + deploy-prod succeeded. Prod is live.`);
1350
- return landed();
1372
+ if (r.data.reconcile_blocked) {
1373
+ if (r.data.reconcile_blocked !== blockedReason) {
1374
+ blockedReason = r.data.reconcile_blocked;
1375
+ console.log(` ci-land: merged, but the server did NOT flip the task to shipped: ${blockedReason}. Still polling (the reconciler retries every sweep)...`);
1376
+ }
1377
+ } else {
1378
+ console.log(` ci-land: merged (${String(r.data.merge_sha || '').slice(0, 8)}) + deploy-prod succeeded. Prod is live.`);
1379
+ return landed();
1380
+ }
1351
1381
  }
1352
1382
  if (outcome === 'failed') {
1353
1383
  console.log(` ci-land: PR was CLOSED without merging (a required check failed, or it was closed manually). Fix it and re-run \`node scripts/gds/ship.js ${taskId}\` to resume. Task stays at 'confirmed'.`);
@@ -1356,6 +1386,11 @@ async function pollServerPublish(taskId, branch) {
1356
1386
  }
1357
1387
  shellOk(POLL_SLEEP_CMD);
1358
1388
  }
1389
+ if (blockedReason) {
1390
+ console.log('');
1391
+ for (const line of reconcileBlockedLines(taskId, blockedReason)) console.log(line);
1392
+ return landBailed(`the PR merged but the server could not prove the land is this task's: ${blockedReason}`, `node scripts/gds/ship.js ${taskId}`);
1393
+ }
1359
1394
  printLandPending(taskId);
1360
1395
  return landPending();
1361
1396
  }
@@ -4176,6 +4211,9 @@ module.exports = {
4176
4211
  // task 1002606: the success-pending banner lines, pure — pinned so the strand
4177
4212
  // detection story ("NOT a failure" + how you WILL find out if it fails) can't drift.
4178
4213
  landPendingLines,
4214
+ // task 1002645: the merged-but-proof-refused close-out lines (reconcile_blocked) —
4215
+ // pinned so this shape can never regress to the optimistic "NOT a failure" banner.
4216
+ reconcileBlockedLines,
4179
4217
  // #857: resolveDeployMode (env + committed config) so doctor.js reports the
4180
4218
  // active deploy mode exactly as ship will use it.
4181
4219
  resolveDeployMode,
@@ -21,6 +21,14 @@ function escapeHtml(s) {
21
21
  // subtitle — replaces the default header sub-line
22
22
  // cta — { href, label } for the primary button (default: retry sign-in)
23
23
  // note — replaces the default troubleshooting footnote
24
+ // The instance's own word for the admitting rank, for per-branch error strings
25
+ // (task 1002616, the 1439 follow-up): core error surfaces never hardcode
26
+ // "Archon" — a non-OTB instance names its own role (branding rankLabels.archon;
27
+ // ADR 0062 §3). Used as "the ${admitterLabel()}", so labels stay grammatical.
28
+ function admitterLabel() {
29
+ try { return branding().rankLabels?.archon || 'owner'; } catch { return 'owner'; }
30
+ }
31
+
24
32
  function renderAuthErrorPage(heading, detail, opts = {}) {
25
33
  // Every fixed string on this page — the tab-title suffix, epigraph, page
26
34
  // heading, sub-line, and retry button — is owned by the instance branding
@@ -500,7 +508,7 @@ module.exports = function buildAuthRouter() {
500
508
  if (!code || !state || state !== expectedState) {
501
509
  return res.status(400).type('text/html').send(renderAuthErrorPage(
502
510
  'State mismatch',
503
- 'The handshake-cookie did not match the state GitHub returned. This usually means the sign-in took too long (cookie expired after 10 minutes) or the request crossed an origin boundary. Start over and the gate will open.',
511
+ 'The handshake-cookie did not match the state GitHub returned. This usually means the sign-in took too long (cookie expired after 10 minutes) or the request crossed an origin boundary. Start over and sign in again.',
504
512
  ));
505
513
  }
506
514
  try {
@@ -584,18 +592,18 @@ module.exports = function buildAuthRouter() {
584
592
  }
585
593
  return res.status(403).type('text/html').send(renderAuthErrorPage(
586
594
  'This account is not approved yet',
587
- 'Signing in with GitHub is only for builders an Archon has already approved. If you are new, request access at the builders’ hall — an Archon will approve you, then this sign-in will let you in. If you were just approved, the Archon may still need to mark you invited; give it a moment and try again.',
595
+ `Signing in with GitHub is only for builders the ${admitterLabel()} has already approved. If you are new, request access at the builders’ hall — once the ${admitterLabel()} approves you, this sign-in will let you in. If you were just approved, it may take a moment to be marked invited; try again shortly.`,
588
596
  {
589
597
  subtitle: 'Sign-in is for approved builders. New here? Request access first.',
590
598
  cta: { href: '/builders', label: 'Go to the hall & request access' },
591
- note: 'Already approved and still blocked? Ask the Archon to confirm your request was marked “invited.”',
599
+ note: `Already approved and still blocked? Ask the ${admitterLabel()} to confirm your request was marked “invited.”`,
592
600
  },
593
601
  ));
594
602
  }
595
603
  console.error('[gds] web/callback', err);
596
604
  res.status(500).type('text/html').send(renderAuthErrorPage(
597
605
  'The handshake threw an error',
598
- `The server tried to exchange the auth code for a session and something went wrong: ${err.message}. Try again; if it persists, the Archon must investigate the server logs.`,
606
+ `The server tried to exchange the auth code for a session and something went wrong: ${err.message}. Try again; if it persists, ask the ${admitterLabel()} to investigate the server logs.`,
599
607
  ));
600
608
  }
601
609
  });
@@ -727,7 +735,7 @@ module.exports = function buildAuthRouter() {
727
735
  console.error('[gds] discord/callback', err);
728
736
  res.status(500).type('text/html').send(renderAuthErrorPage(
729
737
  'The Discord link threw an error',
730
- 'Linking failed unexpectedly. Try again; if it persists, the Archon must check the server logs.',
738
+ `Linking failed unexpectedly. Try again; if it persists, ask the ${admitterLabel()} to check the server logs.`,
731
739
  { cta: { href: '/builders', label: 'Back to the hall' } },
732
740
  ));
733
741
  }
@@ -1061,3 +1069,6 @@ module.exports.reqHost = reqHost;
1061
1069
  // The auth-error page renderer (task 1439): pure over the branding pack, so a
1062
1070
  // test can prove every visible string is brand-owned (no OTB lore baked in).
1063
1071
  module.exports.renderAuthErrorPage = renderAuthErrorPage;
1072
+ // The admitting-rank label for per-branch strings (task 1002616) — exported for
1073
+ // the same reason: the test proves the label is pack-owned, never "Archon".
1074
+ module.exports.admitterLabel = admitterLabel;
package/src/module-api.js CHANGED
@@ -473,8 +473,12 @@ const { validateOrRespond, LIMITS, parseId, asyncHandler, corsPublicGet, parsePa
473
473
  // landed since 1.19.21 with no explicit bump. run 31449168428. (task 1002620)
474
474
  // 1.19.23 — CI auto-patch (publish-on-merge, ADR 0161): carrier for merges
475
475
  // landed since 1.19.22 with no explicit bump. run 31450197816. (task 1002620)
476
+ // 1.19.24 — CI auto-patch (publish-on-merge, ADR 0161): carrier for merges
477
+ // landed since 1.19.23 with no explicit bump. run 31450459825. (task 1002620)
478
+ // 1.19.25 — CI auto-patch (publish-on-merge, ADR 0161): carrier for merges
479
+ // landed since 1.19.24 with no explicit bump. run 31495418623. (task 1002620)
476
480
  // ---------------------------------------------------------------------------
477
- const CORE_VERSION = '1.19.23'; // CI auto-patch carrier (ADR 0161); see changelog above
481
+ const CORE_VERSION = '1.19.25'; // CI auto-patch carrier (ADR 0161); see changelog above
478
482
 
479
483
  // A namespaced logger so a module's log lines are attributable + consistent.
480
484
  // Usage: const log = api.logger('dev-box'); log.info('mounted');
@@ -67,6 +67,33 @@ const escapeHtml = (s) => String(s ?? '').replace(/[&<>"']/g, (c) => ({
67
67
  '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;',
68
68
  }[c]));
69
69
 
70
+ // ---- task 1002616: the per-branch CALL-SITE strings are lore-free too ----
71
+ // Task 1439 made the TEMPLATE brand-aware but deliberately scoped out the
72
+ // heading/detail arguments each callback error branch passes in. Those still
73
+ // said "an Archon has already approved", "the Archon must investigate", and
74
+ // "the gate will open" — instance lore rendered on every instance.
75
+
76
+ test('call-site strings: no hardcoded Archon/gate lore in the auth error branches (task 1002616)', async () => {
77
+ const { readFileSync } = await import('node:fs');
78
+ const src = readFileSync(new URL('../src/bongos/routes/auth.js', import.meta.url), 'utf8');
79
+ // The four exact leaks, pinned so they cannot return verbatim…
80
+ assert.doesNotMatch(src, /gate will open/, 'state-mismatch branch must not carry gate lore');
81
+ assert.doesNotMatch(src, /an Archon has already approved|an Archon will approve/, 'NOT_APPROVED branch must not hardcode Archon');
82
+ assert.doesNotMatch(src, /Ask the Archon\b/, 'the NOT_APPROVED note must not hardcode Archon');
83
+ assert.doesNotMatch(src, /the Archon must (investigate|check)/, 'the 500 branches must not hardcode Archon');
84
+ // …and the label helper is actually what the branches interpolate.
85
+ assert.match(src, /admitterLabel\(\)/, 'branches resolve the instance label at render time');
86
+ });
87
+
88
+ test('admitterLabel: pack-owned with a neutral fallback (task 1002616)', () => {
89
+ const { admitterLabel } = authMod;
90
+ const label = admitterLabel();
91
+ const pack = loadBranding({ env: {} });
92
+ const expected = pack.rankLabels?.archon || 'owner';
93
+ assert.equal(label, expected, 'the label is the ambient pack’s rankLabels.archon');
94
+ assert.notEqual(label.trim(), '', 'never empty');
95
+ });
96
+
70
97
  test('renderAuthErrorPage interpolates the branding pack, not hardcoded lore', () => {
71
98
  // Whatever pack is ambient in this checkout, the rendered page must carry ITS
72
99
  // authError values and ITS worldName — that is the pack-driven property.
@@ -152,6 +152,95 @@ test('landProvenForTask: a non-sha published tip ("HEAD") falls back to the PR c
152
152
  assert.equal(compareCalled, false, 'a non-sha tip must never reach the compare API (would false-positive)');
153
153
  });
154
154
 
155
+ // --- task 1002645: findTaskPullRequest — the PR-title fallback locator --------
156
+ //
157
+ // The reconciler derives claude/<worktree_name> (dev-box convention); a laptop/wave
158
+ // ship pushes worktree-<worktree_name>, so the derived branch finds no PR and the
159
+ // sweep never engaged (wave PRs 34/35/36 stranded at 'confirmed'). This locates the
160
+ // task's PR by the "task <id>: …" TITLE-PREFIX convention — deliberately TIGHTER
161
+ // than prReferencesTask (title+body word match) because the search widens the
162
+ // candidate set from "this branch's own PR" to "recent PRs".
163
+
164
+ // A REST /pulls list response the locator pages through (newest first).
165
+ function depsWithPulls(pulls, { ok = true, status = 200 } = {}) {
166
+ return {
167
+ token: 'x',
168
+ repoInfo: { owner: 'o', repo: 'r' },
169
+ fetchImpl: async () => ({ ok, status, json: async () => pulls }),
170
+ };
171
+ }
172
+ const pull = (title, ref, { merged = false, state = 'closed', repo = 'o/r', number = 36 } = {}) => ({
173
+ number, title, state, merged_at: merged ? '2026-08-11T00:00:00Z' : null,
174
+ head: { ref, repo: { full_name: repo } },
175
+ });
176
+
177
+ test('findTaskPullRequest: "task <id>: …" title → returns the REAL head branch + PR meta', async () => {
178
+ const r = await gh.findTaskPullRequest(
179
+ { taskId: 1002616 },
180
+ depsWithPulls([
181
+ pull('task 1002620: unrelated newer', 'worktree-task-1002620'),
182
+ pull('task 1002616: denial speech', 'worktree-task-1002616', { merged: true }),
183
+ ])
184
+ );
185
+ assert.equal(r.branch, 'worktree-task-1002616');
186
+ assert.equal(r.merged, true);
187
+ assert.equal(r.pr_number, 36);
188
+ });
189
+
190
+ test('findTaskPullRequest: a body-only mention must NOT bind (tighter than prReferencesTask)', async () => {
191
+ const r = await gh.findTaskPullRequest(
192
+ { taskId: 55 },
193
+ depsWithPulls([{ ...pull('fix regression', 'other-branch'), body: 'this also touches task 55' }])
194
+ );
195
+ assert.equal(r, null, 'a PR that merely MENTIONS the task is not its PR');
196
+ });
197
+
198
+ test('findTaskPullRequest: word boundary — task 100 does not match "task 1002: …"', async () => {
199
+ const r = await gh.findTaskPullRequest(
200
+ { taskId: 100 },
201
+ depsWithPulls([pull('task 1002: other work', 'worktree-task-1002')])
202
+ );
203
+ assert.equal(r, null);
204
+ });
205
+
206
+ test('findTaskPullRequest: a FORK head is skipped (owner:branch lookups downstream cannot see it)', async () => {
207
+ const r = await gh.findTaskPullRequest(
208
+ { taskId: 7 },
209
+ depsWithPulls([pull('task 7: from a fork', 'their-branch', { repo: 'someone/else' })])
210
+ );
211
+ assert.equal(r, null);
212
+ });
213
+
214
+ test('findTaskPullRequest: an unsafe head ref is skipped (injection guard)', async () => {
215
+ const r = await gh.findTaskPullRequest(
216
+ { taskId: 8 },
217
+ depsWithPulls([pull('task 8: bad head', '-rf')])
218
+ );
219
+ assert.equal(r, null);
220
+ });
221
+
222
+ test('findTaskPullRequest: no match → null; bad task id → null before any fetch', async () => {
223
+ assert.equal(await gh.findTaskPullRequest({ taskId: 9 }, depsWithPulls([])), null);
224
+ assert.equal(
225
+ await gh.findTaskPullRequest(
226
+ { taskId: 'nope' },
227
+ { token: 'x', repoInfo: { owner: 'o', repo: 'r' }, fetchImpl: async () => { throw new Error('must not fetch'); } }
228
+ ),
229
+ null
230
+ );
231
+ });
232
+
233
+ test('findTaskPullRequest: API failure → STATUS_FETCH_FAILED; no credential → PUSH_UNCONFIGURED', async () => {
234
+ await assert.rejects(
235
+ () => gh.findTaskPullRequest({ taskId: 1 }, depsWithPulls([], { ok: false, status: 502 })),
236
+ (e) => e.code === 'STATUS_FETCH_FAILED'
237
+ );
238
+ await assert.rejects(
239
+ () => gh.findTaskPullRequest({ taskId: 1 }, { token: null, repoInfo: { owner: 'o', repo: 'r' } }),
240
+ (e) => e.code === 'PUSH_UNCONFIGURED'
241
+ );
242
+ });
243
+
155
244
  // --- scrubCredential ---------------------------------------------------------
156
245
 
157
246
  test('scrubCredential: strips the x-access-token push credential from captured output', () => {
@@ -311,6 +311,44 @@ await t('POST /tasks/:id/attest-gate: requireBuilder present, allowBoxScope ABSE
311
311
  assert.ok(!handles.includes(auth.allowBoxScope), 'must NOT carry allowBoxScope — a box session must reauth, never self-attest (#919)');
312
312
  });
313
313
 
314
+ // task 1002645: the attest call is the ONE moment the laptop ci-land tells the
315
+ // server its true pushed tip, so the route must record it on the claim
316
+ // (claims.published_head_sha) — without it landProvenForTask has neither tip nor
317
+ // PR and the reconciler strands the ship at 'confirmed' forever (wave PRs
318
+ // 34/35/36). Recorded BEFORE the push-credential 503 on purpose: an unconfigured
319
+ // server still captures the tip, so a later-provisioned credential heals the
320
+ // strand retroactively — which is exactly the shape this test drives.
321
+ await t('POST /tasks/:id/attest-gate records the pushed tip on the claim, even when push is unconfigured', async () => {
322
+ const dbMod = require('../modules/lifecycle/db.js');
323
+ const savedSet = dbMod.setClaimPublishedSha;
324
+ const recorded = [];
325
+ dbMod.setClaimPublishedSha = async (args) => { recorded.push(args); return 1; };
326
+ try {
327
+ await withEnv({
328
+ GITHUB_PUSH_TOKEN: undefined, GITHUB_APP_ID: undefined,
329
+ GITHUB_APP_INSTALLATION_ID: undefined, GITHUB_APP_PRIVATE_KEY: undefined,
330
+ }, async () => {
331
+ const router = buildTasksRouter();
332
+ const layer = findRouteLayer(router, '/tasks/:id/attest-gate', 'post');
333
+ const handler = layer.route.stack[layer.route.stack.length - 1].handle;
334
+ const out = { failCode: null, jsonBody: null };
335
+ const res = {
336
+ status() { return this; },
337
+ json(b) { out.jsonBody = b; return this; },
338
+ fail(code) { out.failCode = code; return this; },
339
+ };
340
+ // rank archon → gateTaskOwnership passes with no DB lookup, keeping the test hermetic.
341
+ const req = { params: { id: '77' }, body: { head_sha: 'a'.repeat(40) }, builder: { id: 95, rank: 'archon' } };
342
+ await handler(req, res);
343
+ assert.equal(out.failCode, 'push_unconfigured', 'no credential → still the usual 503 to the caller');
344
+ assert.deepEqual(recorded, [{ taskId: 77, builderId: 95, sha: 'a'.repeat(40) }],
345
+ 'the tip is recorded BEFORE the credential check — the wave-strand cure');
346
+ });
347
+ } finally {
348
+ dbMod.setClaimPublishedSha = savedSet;
349
+ }
350
+ });
351
+
314
352
  // ===========================================================================
315
353
  // GitHub App credential (task 1028 / ADR 0055 hardening): the server mints a
316
354
  // short-lived installation token from the App private key instead of holding a
@@ -52,13 +52,14 @@ function mkDeps({
52
52
  statusByBranch = {},
53
53
  mergeByBranch = {},
54
54
  ancestryBySha = {},
55
+ taskPrByTask = {},
55
56
  shipImpl,
56
57
  broadcastImpl,
57
58
  conflictResolveImpl,
58
59
  refreshStaleImpl,
59
60
  healAttempts = new Map(),
60
61
  } = {}) {
61
- const calls = { ship: [], broadcast: [], status: [], merge: [], ancestry: [], resolve: [], refresh: [], flag: [], events: [], logs: [], errors: [] };
62
+ const calls = { ship: [], broadcast: [], status: [], merge: [], ancestry: [], search: [], resolve: [], refresh: [], flag: [], events: [], logs: [], errors: [] };
62
63
  // isSafeBranch mirrors github-push's pattern enough for the test (rejects
63
64
  // option-like / traversal refs); we use the REAL module so the contract can't drift.
64
65
  const githubPush = require('../modules/lifecycle/github-push.js');
@@ -99,6 +100,16 @@ function mkDeps({
99
100
  if (s instanceof Error) throw s;
100
101
  return s || NONE;
101
102
  },
103
+ // task 1002645: the PR-title fallback locator. Default: nothing found (null),
104
+ // so pre-1002645 tests keep their exact behavior. Script per task id via
105
+ // taskPrByTask; an Error value throws (to prove the sweep swallows a search
106
+ // miss and continues).
107
+ findTaskPullRequest: async ({ taskId }) => {
108
+ calls.search.push(taskId);
109
+ const f = taskPrByTask[taskId];
110
+ if (f instanceof Error) throw f;
111
+ return f || null;
112
+ },
102
113
  // task 1313 head_sha land-check. Default: not on main. An Error value throws
103
114
  // (to prove a transient compare-API miss is swallowed, leaving it for next sweep).
104
115
  isAncestorOfDefaultBranch: async ({ sha }) => {
@@ -1077,6 +1088,106 @@ test('1002606 the aged stale strand now ALSO emits task.strand-flagged', async (
1077
1088
  assert.match(strandEvents[0].payload.reason, /^strand:no_branch_no_tip/);
1078
1089
  });
1079
1090
 
1091
+ // ---------------------------------------------------------------------------
1092
+ // task 1002645 — the reconciler was blind to laptop/wave ships. The sweep derives
1093
+ // claude/<worktree_name> (dev-box convention); a wave ship pushes
1094
+ // worktree-<worktree_name>, so getPublishStatus saw pr_state:'none' and the whole
1095
+ // PR path (mergeIfGreen nudge — the ONLY merger where native auto-merge is
1096
+ // repo-disallowed — conflict heal, land proof) never engaged. PRs 34/35/36 all
1097
+ // stranded at 'confirmed' until a manual flip. The fallback finds the task's PR by
1098
+ // the "task <id>: …" TITLE convention and re-runs the branch path on its REAL head.
1099
+ // ---------------------------------------------------------------------------
1100
+
1101
+ test('1002645 THE PIN: a worktree-named branch (laptop wave ship) lands UNATTENDED via the PR-title fallback', async () => {
1102
+ const deps = mkDeps({
1103
+ rows: [{ task_id: 2645, builder_id: 95, worktree_name: 'task-2645', published_head_sha: ON_MAIN }],
1104
+ statusByBranch: {
1105
+ 'claude/task-2645': NONE, // the derived dev-box branch has no PR
1106
+ 'worktree-task-2645': LANDED_NO_WORKFLOW, // the REAL branch: merged, pin-bump repo
1107
+ },
1108
+ taskPrByTask: { 2645: { branch: 'worktree-task-2645', pr_number: 36, pr_state: 'closed', merged: true } },
1109
+ ancestryBySha: { [ON_MAIN]: true },
1110
+ });
1111
+ const r = await reconciler.runSweep(deps);
1112
+ assert.equal(r.reconciled, 1, 'the wave-5 strand shape must land with NO human step (ADR 0162)');
1113
+ assert.deepEqual(deps._calls.ship, [{ taskId: 2645, builderId: 95 }]);
1114
+ assert.deepEqual(deps._calls.search, [2645], 'the fallback ran exactly once');
1115
+ assert.ok(deps._calls.merge.includes('worktree-task-2645'),
1116
+ 'the merge nudge engages on the REAL branch — the only merger when native auto-merge is disallowed');
1117
+ });
1118
+
1119
+ test('1002645 a green-but-unmerged PR on the real branch is server-merged via the fallback (no client poll needed)', async () => {
1120
+ const deps = mkDeps({
1121
+ rows: [{ task_id: 2646, builder_id: 95, worktree_name: 'task-2646' }],
1122
+ statusByBranch: { 'claude/task-2646': NONE, 'worktree-task-2646': PENDING },
1123
+ taskPrByTask: { 2646: { branch: 'worktree-task-2646', pr_number: 37, pr_state: 'open', merged: false } },
1124
+ mergeByBranch: { 'worktree-task-2646': { merged: true, merged_now: true, number: 37 } },
1125
+ });
1126
+ const r = await reconciler.runSweep(deps);
1127
+ assert.equal(r.merged, 1, 'the sweep merges the wave PR itself — the land no longer depends on a live ship.js poll');
1128
+ assert.equal(r.reconciled, 0, 'ships on a later sweep once deploy + proof confirm');
1129
+ });
1130
+
1131
+ test('1002645 a legacy laptop strand (no recorded tip) heals retroactively via the adopted PR reference', async () => {
1132
+ const deps = mkDeps({
1133
+ rows: [{ task_id: 2616, builder_id: 95, worktree_name: 'task-2616' }], // no published_head_sha
1134
+ statusByBranch: { 'claude/task-2616': NONE, 'worktree-task-2616': landedPrFor(2616) },
1135
+ taskPrByTask: { 2616: { branch: 'worktree-task-2616', pr_number: 36, pr_state: 'closed', merged: true } },
1136
+ });
1137
+ const r = await reconciler.runSweep(deps);
1138
+ assert.equal(r.reconciled, 1, 'the PRs-34/35/36 shape heals with no manual POST /ship');
1139
+ assert.deepEqual(deps._calls.ship, [{ taskId: 2616, builderId: 95 }]);
1140
+ });
1141
+
1142
+ test('1002645 the fallback does NOT fire when the derived branch already has a PR (dev-box path unchanged)', async () => {
1143
+ const deps = mkDeps({
1144
+ rows: [{ task_id: 900, builder_id: 1, worktree_name: 'wt-box' }],
1145
+ statusByBranch: { 'claude/wt-box': PENDING },
1146
+ taskPrByTask: { 900: new Error('search must not run') },
1147
+ });
1148
+ await reconciler.runSweep(deps);
1149
+ assert.equal(deps._calls.search.length, 0, 'a dev-box ship keeps the derived-branch path — no extra API call');
1150
+ });
1151
+
1152
+ test('1002645 a PR-search failure is swallowed — the sweep continues to the next task and retries next sweep', async () => {
1153
+ const deps = mkDeps({
1154
+ rows: [
1155
+ { task_id: 901, builder_id: 1, worktree_name: 'task-901' },
1156
+ { task_id: 902, builder_id: 1, worktree_name: 'wt-ok', published_head_sha: ON_MAIN },
1157
+ ],
1158
+ statusByBranch: { 'claude/task-901': NONE, 'claude/wt-ok': LANDED },
1159
+ taskPrByTask: { 901: new Error('GitHub 502') },
1160
+ ancestryBySha: { [ON_MAIN]: true },
1161
+ });
1162
+ const r = await reconciler.runSweep(deps);
1163
+ assert.equal(r.reconciled, 1, 'the healthy task still ships');
1164
+ assert.equal(r.errors, 0, 'a transient search miss is not an error');
1165
+ });
1166
+
1167
+ test('1002645 an unsafe adopted branch name is refused (the injection guard holds on the fallback)', async () => {
1168
+ const deps = mkDeps({
1169
+ rows: [{ task_id: 903, builder_id: 1, worktree_name: null, published_head_sha: null,
1170
+ confirmed_at: new Date().toISOString() }],
1171
+ taskPrByTask: { 903: { branch: '-rf', pr_number: 1, pr_state: 'open', merged: false } },
1172
+ });
1173
+ await reconciler.runSweep(deps);
1174
+ assert.equal(deps._calls.status.length, 0, 'a branch that fails isSafeBranch is never queried');
1175
+ assert.equal(deps._calls.merge.length, 0, 'nor merge-nudged');
1176
+ });
1177
+
1178
+ test('1002645 the reuse guard still holds through the fallback: adopted PR merged but tip NOT in main → NO ship', async () => {
1179
+ const deps = mkDeps({
1180
+ rows: [{ task_id: 904, builder_id: 1, worktree_name: 'task-904', published_head_sha: NOT_ON_MAIN,
1181
+ confirmed_at: new Date().toISOString() }],
1182
+ statusByBranch: { 'claude/task-904': NONE, 'worktree-task-904': LANDED_NO_WORKFLOW },
1183
+ taskPrByTask: { 904: { branch: 'worktree-task-904', pr_number: 40, pr_state: 'closed', merged: true } },
1184
+ ancestryBySha: { [NOT_ON_MAIN]: false },
1185
+ });
1186
+ const r = await reconciler.runSweep(deps);
1187
+ assert.equal(r.reconciled, 0, 'adopting the real branch must not weaken the task-1547 per-task proof');
1188
+ assert.equal(deps._calls.ship.length, 0);
1189
+ });
1190
+
1080
1191
  // Drain the microtask queue, then report + exit with the right code.
1081
1192
  setTimeout(() => {
1082
1193
  console.log(`\npublish reconciler (task 1134 + 1915) tests: ${passed} passed, ${failed} failed`);
@@ -607,6 +607,27 @@ test('1002606 landPendingLines: merged variant says deploy-only', () => {
607
607
  assert.match(unmerged, /GitHub will merge \+ deploy automatically/);
608
608
  });
609
609
 
610
+ // ---- task 1002645: the merged-but-proof-refused close-out (reconcile_blocked) ----
611
+ // GitHub can report merged+deployed while the SERVER refused the confirmed→shipped
612
+ // flip (the task-1547 land proof missed). pollServerPublish used to print "Prod is
613
+ // live" / the optimistic P-3 banner for that shape — a lie: without proof the
614
+ // auto-land can NEVER finish. The close-out must name the refusal and the remedy,
615
+ // and must never claim success or "NOT a failure".
616
+
617
+ test('1002645 reconcileBlockedLines: names the refusal reason + the re-drive command', () => {
618
+ const lines = ship.reconcileBlockedLines(2645, 'published tip abcd1234 not in main (branch-reuse/stale PR)').join('\n');
619
+ assert.match(lines, /did NOT flip|could not prove/i, 'says the flip was refused');
620
+ assert.match(lines, /published tip abcd1234 not in main/, 'carries the server\'s exact reason');
621
+ assert.match(lines, /node scripts\/gds\/ship\.js 2645/, 'the re-drive command names THIS task');
622
+ assert.match(lines, /needs_rebase/, 'names the flag that gates a stuck strand');
623
+ });
624
+
625
+ test('1002645 reconcileBlockedLines: never reads as success (no "NOT a failure", no "Prod is live")', () => {
626
+ const lines = ship.reconcileBlockedLines(1, 'x').join('\n');
627
+ assert.ok(!/NOT a failure/.test(lines), 'the optimistic reassurance must not appear on a blocked land');
628
+ assert.ok(!/Prod is live/.test(lines), 'nor the success line');
629
+ });
630
+
610
631
  console.log('');
611
632
  console.log(`ship_ci_deploy: ${passed} passed, ${failed} failed`);
612
633
  process.exit(failed === 0 ? 0 : 1);