benignswarm 0.12.166 → 0.12.168

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/ux-jobs.js CHANGED
@@ -17,6 +17,18 @@ import { writeFileAtomic } from "./shared-file.js";
17
17
  import { runMergeTrainWorkflow } from "./merge-train.js";
18
18
  import { retryGitFetch } from "./git-fetch.js";
19
19
  import { recordMachineNetworkRequest } from "./machine-network-health.js";
20
+ function jobSubjectLabel(job) {
21
+ return job.work_unit_number !== null && job.work_unit_number !== undefined
22
+ ? `WU #${job.work_unit_number}`
23
+ : `branch ${job.target_branch ?? job.branch}`;
24
+ }
25
+ function jobFileTag(job) {
26
+ if (job.work_unit_number !== null && job.work_unit_number !== undefined) {
27
+ return `wu${job.work_unit_number}`;
28
+ }
29
+ const branchTag = (job.target_branch ?? job.branch).replace(/[^A-Za-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "") || "target";
30
+ return branchTag;
31
+ }
20
32
  const SLUG_RE = /^[a-z0-9]+(-[a-z0-9]+)*$/;
21
33
  const SHA_RE = /^[0-9a-f]{7,64}$/i;
22
34
  const MAX_UX_JOB_LOG_TAIL = 2000;
@@ -1127,13 +1139,13 @@ export async function executeUxJob(machineClient, job, ctx, deps = {}, resume, c
1127
1139
  ? `gate ${status === "succeeded" ? "PASSED" : "FAILED"}`
1128
1140
  : [job.task, job.compare_screen ? `compare-${job.compare_screen}` : null].filter(Boolean).join(" ");
1129
1141
  const claim = jobKind === "gate"
1130
- ? `Complete-suite gate run (${status === "succeeded" ? "PASSED" : "FAILED"}) on ${ctx.machineName} at ${head} for WU #${job.work_unit_number}`
1131
- : `Seeded UX run (${jobTaskLabel}) on ${ctx.machineName} at ${head} for WU #${job.work_unit_number}`;
1142
+ ? `Complete-suite gate run (${status === "succeeded" ? "PASSED" : "FAILED"}) on ${ctx.machineName} at ${head} for ${jobSubjectLabel(job)}`
1143
+ : `Seeded UX run (${jobTaskLabel}) on ${ctx.machineName} at ${head} for ${jobSubjectLabel(job)}`;
1132
1144
  return {
1133
1145
  project: job.project,
1134
1146
  project_id: job.project_id,
1135
1147
  filename: `remote-job-${job.id}.log`,
1136
- label: `WU #${job.work_unit_number} ${head} ${taskTag} remote-job-${job.id}.log`,
1148
+ label: `${jobSubjectLabel(job)} ${head} ${taskTag} remote-job-${job.id}.log`,
1137
1149
  claim,
1138
1150
  idempotency_key: uxEvidenceIdempotencyKey(job.id, "diagnostic-log"),
1139
1151
  };
@@ -1182,8 +1194,8 @@ export async function executeUxJob(machineClient, job, ctx, deps = {}, resume, c
1182
1194
  ? `gate ${status === "succeeded" ? "PASSED" : "FAILED"}`
1183
1195
  : [job.task, job.compare_screen ? `compare-${job.compare_screen}` : null].filter(Boolean).join(" ");
1184
1196
  const claim = jobKind === "gate"
1185
- ? `Complete-suite gate run (${status === "succeeded" ? "PASSED" : "FAILED"}) on ${ctx.machineName} at ${(resolvedHead ?? job.head ?? "unknown").slice(0, 9)} for WU #${job.work_unit_number}`
1186
- : `Seeded UX run (${jobTaskLabel}) on ${ctx.machineName} at ${(resolvedHead ?? job.head ?? "unknown").slice(0, 9)} for WU #${job.work_unit_number}`;
1197
+ ? `Complete-suite gate run (${status === "succeeded" ? "PASSED" : "FAILED"}) on ${ctx.machineName} at ${(resolvedHead ?? job.head ?? "unknown").slice(0, 9)} for ${jobSubjectLabel(job)}`
1198
+ : `Seeded UX run (${jobTaskLabel}) on ${ctx.machineName} at ${(resolvedHead ?? job.head ?? "unknown").slice(0, 9)} for ${jobSubjectLabel(job)}`;
1187
1199
  for (const artifact of artifacts) {
1188
1200
  const alreadyUploaded = uploadedArtifacts.get(artifact.path);
1189
1201
  if (alreadyUploaded) {
@@ -1193,7 +1205,7 @@ export async function executeUxJob(machineClient, job, ctx, deps = {}, resume, c
1193
1205
  fullLogEvidenceId = alreadyUploaded;
1194
1206
  continue;
1195
1207
  }
1196
- const label = `WU #${job.work_unit_number} ${(resolvedHead ?? job.head ?? "unknown").slice(0, 9)} ${taskTag} ${artifact.filename}`;
1208
+ const label = `${jobSubjectLabel(job)} ${(resolvedHead ?? job.head ?? "unknown").slice(0, 9)} ${taskTag} ${artifact.filename}`;
1197
1209
  const artifactIdentity = artifact.path === diagnosticLogPath ? "diagnostic-log" : relative(jobArtifactDir, artifact.path);
1198
1210
  const evidenceId = await uploadEvidence(agentCreds, job.project, {
1199
1211
  ...artifact,
@@ -1491,7 +1503,7 @@ export async function executeUxJob(machineClient, job, ctx, deps = {}, resume, c
1491
1503
  scanner.push("", true);
1492
1504
  const logDir = join(jobArtifactDir, "gate");
1493
1505
  mkdirSync(logDir, { recursive: true });
1494
- gateLogFile = join(logDir, `gate-wu${job.work_unit_number}-${shortHead}.log`);
1506
+ gateLogFile = join(logDir, `gate-${jobFileTag(job)}-${shortHead}.log`);
1495
1507
  writeFileSync(gateLogFile, fullOutput || `${gateRes.stdout}\n${gateRes.stderr}` || `exit ${gateRes.status ?? 1}\n`);
1496
1508
  return { exit_code: gateRes.status ?? 1, ...scanner.result() };
1497
1509
  }
@@ -1531,20 +1543,35 @@ export async function executeUxJob(machineClient, job, ctx, deps = {}, resume, c
1531
1543
  }
1532
1544
  }
1533
1545
  }
1534
- const { res: seedRes } = await runLockedStep("seed", npmBin, ["run", "ux:seed"], { timeoutMs: 300_000 });
1535
- if (seedRes.status !== 0)
1536
- return seedRes.status ?? 1;
1537
- if (job.task) {
1538
- const { res: taskRes } = await runLockedStep("task", npmBin, ["run", "ux:task", "--", job.task], { timeoutMs: 600_000 });
1539
- if (taskRes.status !== 0)
1540
- return taskRes.status ?? 1;
1546
+ try {
1547
+ const { res: seedRes } = await runLockedStep("seed", npmBin, ["run", "ux:seed"], { timeoutMs: 300_000 });
1548
+ if (seedRes.status !== 0)
1549
+ return seedRes.status ?? 1;
1550
+ if (job.task) {
1551
+ const { res: taskRes } = await runLockedStep("task", npmBin, ["run", "ux:task", "--", job.task], { timeoutMs: 600_000 });
1552
+ if (taskRes.status !== 0)
1553
+ return taskRes.status ?? 1;
1554
+ }
1555
+ if (job.compare_screen) {
1556
+ const { res: compareRes } = await runLockedStep("compare", npmBin, ["run", "ux:compare", "--", job.compare_screen, "--unit", String(job.work_unit_number), "--widths", "1440,375"], { timeoutMs: 600_000 });
1557
+ if (compareRes.status !== 0)
1558
+ return compareRes.status ?? 1;
1559
+ }
1560
+ return 0;
1541
1561
  }
1542
- if (job.compare_screen) {
1543
- const { res: compareRes } = await runLockedStep("compare", npmBin, ["run", "ux:compare", "--", job.compare_screen, "--unit", String(job.work_unit_number), "--widths", "1440,375"], { timeoutMs: 600_000 });
1544
- if (compareRes.status !== 0)
1545
- return compareRes.status ?? 1;
1562
+ finally {
1563
+ // Older historical checkouts used D1 and have no PostgreSQL fixture to drop.
1564
+ if (existsSync(join(jobWorktreeDir, "scripts", "ux-postgres.mjs"))) {
1565
+ // Cleanup is job-scoped and must still run after cancellation or lease loss.
1566
+ const res = await diagnosticRunner("node", ["scripts/ux-console.mjs", "cleanup"], {
1567
+ cwd: jobWorktreeDir, env: lockedEnv, timeoutMs: 60_000, signal: new AbortController().signal,
1568
+ onStdoutChunk: chunk => lockContext?.onOutput?.(chunk),
1569
+ onStderrChunk: chunk => lockContext?.onOutput?.(chunk),
1570
+ });
1571
+ if (res.status !== 0)
1572
+ throw stepFailure("UX PostgreSQL fixture cleanup", res);
1573
+ }
1546
1574
  }
1547
- return 0;
1548
1575
  }
1549
1576
  finally {
1550
1577
  if (heartbeatTimer)
@@ -1616,7 +1643,7 @@ export async function executeUxJob(machineClient, job, ctx, deps = {}, resume, c
1616
1643
  }, ctx.sessions);
1617
1644
  if (completion === "cancelled")
1618
1645
  return { id: job.id, status: "cancelled", evidence_ids: [], resolved_head: resolvedHead };
1619
- ctx.log(`${jobKind} job ${job.id}: completed (${uploadedIds.length} artifact(s) posted for WU #${job.work_unit_number} at ${shortHead})`);
1646
+ ctx.log(`${jobKind} job ${job.id}: completed (${uploadedIds.length} artifact(s) posted for ${jobSubjectLabel(job)} at ${shortHead})`);
1620
1647
  return { id: job.id, status: "succeeded", evidence_ids: uploadedIds, resolved_head: resolvedHead };
1621
1648
  }
1622
1649
  catch (error) {
package/dist/version.js CHANGED
@@ -1,3 +1,3 @@
1
- export const CLI_VERSION = "0.12.166";
1
+ export const CLI_VERSION = "0.12.168";
2
2
  /** First release allowed to consume single-use join tokens with the save-before-install flow. */
3
3
  export const CLI_JOIN_MIN_VERSION = "0.12.159";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "benignswarm",
3
- "version": "0.12.166",
3
+ "version": "0.12.168",
4
4
  "description": "b9s: chat, status board and evidence store for coding agents (benignswarm.org)",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {