@tablation/crew 0.133.0 → 0.133.2

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.
Files changed (2) hide show
  1. package/dist/cli.js +71 -2
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -2827,6 +2827,9 @@ function tablationEndpoint(url) {
2827
2827
  return { host, port };
2828
2828
  }
2829
2829
  var CREW_BIN = "/opt/crew/bin";
2830
+ var CREW_PNPM_STORE = "/opt/crew/pnpm-store";
2831
+ var CREW_PNPM_HOME = "/opt/crew/pnpm";
2832
+ var CREW_CACHE = "/opt/crew/cache";
2830
2833
  var TOOL_BINARIES = ["/usr/bin/curl", `${CREW_BIN}/node`, "/usr/bin/node", "/usr/local/bin/node", "/usr/bin/npm", "/usr/local/bin/npm", "/usr/local/bin/pnpm", "/usr/bin/corepack", "/usr/local/bin/corepack"];
2831
2834
  var GIT_BINARIES = ["/usr/bin/git", "/usr/lib/git-core/git-remote-http", "/usr/lib/git-core/git-remote-https"];
2832
2835
  function policyGroups(input) {
@@ -2873,7 +2876,8 @@ function generateSandboxPolicy(input) {
2873
2876
  filesystem_policy: {
2874
2877
  include_workdir: true,
2875
2878
  read_only: ["/usr", "/lib", "/proc", "/dev/urandom", "/app", "/etc", "/var/log", "/opt/crew", mirror],
2876
- read_write: ["/sandbox", "/tmp", "/dev/null", work]
2879
+ // The pnpm store is writable though /opt/crew is not; /opt/crew/bin (the binaries a run executes) stays read-only.
2880
+ read_write: ["/sandbox", "/tmp", "/dev/null", work, CREW_PNPM_STORE, CREW_PNPM_HOME, CREW_CACHE]
2877
2881
  },
2878
2882
  // A host that cannot enforce fails the run instead of running unconfined.
2879
2883
  landlock: { compatibility: "hard_requirement" },
@@ -6432,6 +6436,16 @@ function repoFindings(o) {
6432
6436
  for (const g of o.sandboxGaps ?? []) {
6433
6437
  problems.push({ severity: "attention", kind: "hook_missing", ...at, hook: g.hook, command: g.command, message: g.message, remedy: g.remedy });
6434
6438
  }
6439
+ if (o.sandboxStoreProblem !== void 0) {
6440
+ if (o.sandboxStoreProblem === null) passed++;
6441
+ else problems.push({
6442
+ severity: "attention",
6443
+ kind: "sandbox_store_unwritable",
6444
+ ...at,
6445
+ message: `${o.route}/${o.repo}: the pnpm store in its sandbox image cannot be written, so every offline \`pnpm install\` in a run fails (${o.sandboxStoreProblem})`,
6446
+ remedy: `rebuild the image with \`crew sandbox build ${o.repo}\`; the store at /opt/crew/pnpm-store must be owned by the sandbox user`
6447
+ });
6448
+ }
6435
6449
  for (const hook2 of o.sandboxGaps ? [] : HOOK_NAMES2) {
6436
6450
  const script = o.hooks[hook2];
6437
6451
  const command2 = script ? hookCommand(script) : null;
@@ -9618,7 +9632,14 @@ function heldByLiveOtherShip(t, a) {
9618
9632
  const holder = ticketHolderShipId(t, a.contract);
9619
9633
  if (!holder || holder === a.myShipId) return false;
9620
9634
  const owner = a.ships.find((s) => s.id === holder);
9621
- return shipIsAlive(owner, a.now ?? Date.now());
9635
+ const now = a.now ?? Date.now();
9636
+ return shipIsAlive(owner, now) || shipEngagedOn(owner, t, now);
9637
+ }
9638
+ var ENGAGED_TRUST_MS = 6 * 60 * 60 * 1e3;
9639
+ function shipEngagedOn(ship, t, now) {
9640
+ if (!ship?.engaged || ship.engaged_ticket_id !== t.id) return false;
9641
+ const since2 = ship.engaged_since ? Date.parse(ship.engaged_since) : NaN;
9642
+ return Number.isFinite(since2) && now - since2 <= ENGAGED_TRUST_MS;
9622
9643
  }
9623
9644
  function shipName(ships, id) {
9624
9645
  if (!id) return "an unknown ship";
@@ -10096,6 +10117,15 @@ async function enforceHandoff(i) {
10096
10117
  return { kind: "failed", why };
10097
10118
  }
10098
10119
  }
10120
+ function lostTicketReason(t, contract, myShipId) {
10121
+ if (closedStatuses(contract).includes(t.status)) return `the ticket is ${t.status}`;
10122
+ const holder = ticketHolderShipId(t, contract);
10123
+ const st = contract.statuses;
10124
+ if (holder && myShipId && holder !== myShipId && [st.building, st.approved].includes(t.status)) {
10125
+ return "another ship holds the ticket now";
10126
+ }
10127
+ return null;
10128
+ }
10099
10129
  async function guardRunHandoff(route2, ship, tracker, role, workingId, log, since2) {
10100
10130
  const replayed = await replayRoutePending(route2, ship, tracker, log, role);
10101
10131
  if (!workingId || role !== "dev" && role !== "design" && role !== "qa") return null;
@@ -10108,6 +10138,11 @@ async function guardRunHandoff(route2, ship, tracker, role, workingId, log, sinc
10108
10138
  if (!resolved) return null;
10109
10139
  const { target, cfg } = resolved;
10110
10140
  checkoutDir = target.dir;
10141
+ const lost = lostTicketReason(t, tracker.contract, (await tracker.claimAffinity())?.shipId);
10142
+ if (lost && role !== "qa") {
10143
+ log.warn(`${t.issue_id}: run ended without a push \u2014 ${lost}`, { ticket: t.issue_id, step: "handoff" });
10144
+ return { kind: "unverified", why: lost };
10145
+ }
10111
10146
  if (role === "qa") {
10112
10147
  await retireRunWorktree(tracker, target.dir, cfg, t, role, seatId, ship.name, log);
10113
10148
  return null;
@@ -14099,6 +14134,14 @@ function sandboxHookGaps(o) {
14099
14134
  }
14100
14135
  return gaps;
14101
14136
  }
14137
+ var imageStoreProblem = (engine = "docker", exec = realExec) => (image) => {
14138
+ try {
14139
+ exec(engine, ["run", "--rm", "--entrypoint", "sh", image, "-c", 'd=/opt/crew/pnpm-store; test -d $d && t=$(mktemp -p $d) && rm -f "$t"'], { timeoutMs: 6e4 });
14140
+ return null;
14141
+ } catch (e) {
14142
+ return e.message.split("\n")[0] || "write test failed";
14143
+ }
14144
+ };
14102
14145
 
14103
14146
  // src/doctor-checks.ts
14104
14147
  import { execFileSync as execFileSync10, spawnSync as spawnSync8 } from "child_process";
@@ -17893,6 +17936,21 @@ async function resolveOne(tracker, t, seat, approvedStatus, buildingStatus, affi
17893
17936
  throw e;
17894
17937
  }
17895
17938
  }
17939
+ async function claimStillHeld(tracker, t, buildingStatus, affinity) {
17940
+ if (!tracker.ticket) return null;
17941
+ let now;
17942
+ try {
17943
+ now = await tracker.ticket(t.id);
17944
+ } catch {
17945
+ return null;
17946
+ }
17947
+ const holder = affinity ? now[affinity.column] : null;
17948
+ if (affinity && typeof holder === "string" && holder && holder !== affinity.shipId) {
17949
+ return `${t.issue_id} is held by another ship now`;
17950
+ }
17951
+ if (now.status !== buildingStatus) return `${t.issue_id} is at ${now.status}, not ${buildingStatus}`;
17952
+ return null;
17953
+ }
17896
17954
 
17897
17955
  // src/repo-refresh.ts
17898
17956
  import { existsSync as existsSync38, mkdirSync as mkdirSync26, readFileSync as readFileSync36, writeFileSync as writeFileSync29 } from "fs";
@@ -25134,6 +25192,13 @@ async function runRoleAgentLocked(role, decision, ctx, hooks, held) {
25134
25192
  emit.emit(`${role} skipped this cycle \u2014 every candidate was already claimed elsewhere`);
25135
25193
  return;
25136
25194
  }
25195
+ if (role !== "qa") {
25196
+ const lost = await claimStillHeld(tracker, result.ticket, claimStatuses(role, contract).building, await tracker.claimAffinity());
25197
+ if (lost) {
25198
+ emit.warn(`${role} run refused: ${lost}`, { step: "select", role });
25199
+ return;
25200
+ }
25201
+ }
25137
25202
  if (result.claimed) {
25138
25203
  const idx = decision.tickets.findIndex((t) => t.id === result.ticket.id);
25139
25204
  if (idx >= 0) decision.tickets[idx] = result.ticket;
@@ -32093,6 +32158,10 @@ watermark: ${state.watermark()}
32093
32158
  image: sandboxImageForRun(readSandboxState(cfg.ship.stateDir), r.name, Boolean(r.config.sandbox)),
32094
32159
  hasBinary: imageHasBinary()
32095
32160
  }) : void 0,
32161
+ sandboxStoreProblem: cfg.ship.runner === "sandbox" ? (() => {
32162
+ const image = sandboxImageForRun(readSandboxState(cfg.ship.stateDir), r.name, Boolean(r.config.sandbox));
32163
+ return image ? imageStoreProblem()(image) : void 0;
32164
+ })() : void 0,
32096
32165
  mapFile: mapFilePath(r.config.hooks.map) ? inspectMapFile(r.dir, mapFilePath(r.config.hooks.map)) : void 0,
32097
32166
  intelSyntax: r.config.hooks.intel && !intelFlavor(r.config.hooks.intel) ? checkHookSyntax(r.config.hooks.intel, r.config.shell) : void 0,
32098
32167
  intelFlavor: intelFlavor(r.config.hooks.intel) ? { name: intelFlavor(r.config.hooks.intel), missing: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tablation/crew",
3
- "version": "0.133.0",
3
+ "version": "0.133.2",
4
4
  "description": "A standing team of headless agents that picks work off a Tablation board, does it on a machine you control, and reports back.",
5
5
  "type": "module",
6
6
  "license": "MIT",