toolroll 0.9.125 → 0.9.127

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 (69) hide show
  1. package/CHANGELOG.md +64 -0
  2. package/README.md +1 -1
  3. package/dist/agent-detect.js +23 -3
  4. package/dist/assignment.js +14 -4
  5. package/dist/bounded-spawn.js +5 -36
  6. package/dist/browser/workspace.css +1 -1
  7. package/dist/browser/workspace.js +29 -29
  8. package/dist/browser-open.js +49 -0
  9. package/dist/chat-acceptance.js +1 -1
  10. package/dist/check-only.js +1 -1
  11. package/dist/cli.js +2 -2
  12. package/dist/connect-cli.js +2 -8
  13. package/dist/contracts/engine-api.js +8 -0
  14. package/dist/direct-chat.js +26 -18
  15. package/dist/doctor.js +30 -3
  16. package/dist/easy-start.js +44 -17
  17. package/dist/engine-reads.js +34 -1
  18. package/dist/evals.js +17 -19
  19. package/dist/first-run.js +5 -1
  20. package/dist/flexible-conversation.js +79 -1
  21. package/dist/flexible-import.js +162 -4
  22. package/dist/flexible-save.js +51 -4
  23. package/dist/flexible-session.js +34 -8
  24. package/dist/flexible-start.js +2 -1
  25. package/dist/flow-code.js +2 -2
  26. package/dist/invoke.js +4 -4
  27. package/dist/landed-rows.js +138 -0
  28. package/dist/laptop-background.js +2 -11
  29. package/dist/linux-packages.js +46 -0
  30. package/dist/local-landing.js +46 -7
  31. package/dist/merge-checklist.js +62 -8
  32. package/dist/operate.js +90 -33
  33. package/dist/preflight.js +14 -0
  34. package/dist/process-identity.js +155 -0
  35. package/dist/quick-start.js +6 -1
  36. package/dist/release.js +8 -0
  37. package/dist/result-follow-ups.js +8 -1
  38. package/dist/revision-catch-up.js +98 -0
  39. package/dist/runner-process.js +9 -25
  40. package/dist/sandbox-launch.js +3 -2
  41. package/dist/sandbox-runtime.js +115 -15
  42. package/dist/sandbox-tools.js +91 -6
  43. package/dist/server/direct-chat.js +4 -3
  44. package/dist/server/engine-api.js +13 -8
  45. package/dist/server/merge-ready-view.js +4 -2
  46. package/dist/server/pages.js +5 -2
  47. package/dist/server/render-pages.js +1 -0
  48. package/dist/server/render-results.js +9 -7
  49. package/dist/server/render-tasks.js +2 -2
  50. package/dist/server/task-views.js +16 -9
  51. package/dist/server/tasks.js +2 -2
  52. package/dist/shown-text.js +14 -0
  53. package/dist/skill-library.js +2 -12
  54. package/dist/status-probe.js +32 -0
  55. package/dist/task-base.js +13 -2
  56. package/dist/task-status.js +18 -8
  57. package/dist/teardown-git.js +6 -0
  58. package/dist/telegram-status.js +1 -1
  59. package/dist/toolroll-update-cli.js +2 -1
  60. package/dist/toolroll-update.js +4 -0
  61. package/dist/trust-repair.js +187 -0
  62. package/dist/tui/darwin-arm64/toolroll-tui +0 -0
  63. package/dist/tui/darwin-x64/toolroll-tui +0 -0
  64. package/dist/tui/linux-arm64/toolroll-tui +0 -0
  65. package/dist/tui/linux-x64/toolroll-tui +0 -0
  66. package/dist/unreachable.js +15 -0
  67. package/dist/work-index.js +51 -3
  68. package/dist/workspace-ui.js +4 -2
  69. package/package.json +1 -1
package/dist/task-base.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { taskBranches } from "./names.js";
1
2
  import { viewedGitSync } from "./teardown-git.js";
2
3
  export const readGit = (cwd, args) => {
3
4
  try {
@@ -9,9 +10,9 @@ export const readGit = (cwd, args) => {
9
10
  }
10
11
  };
11
12
  const commits = (count) => `${count} commit${count === 1 ? "" : "s"}`;
12
- export function baseStandingWords(view) {
13
+ export function baseStandingWords(view, landed = false) {
13
14
  const short = view.family === true ? `Whole change since ${view.base.slice(0, 8)} (includes earlier attempts' work that's still in it)` : view.base.slice(0, 8);
14
- if (view.main === null || view.behind === null)
15
+ if (landed || view.main === null || view.behind === null)
15
16
  return short;
16
17
  return view.behind === 0 ? `${short} · Up to date with ${view.main}` : `${short} · Behind ${view.main} by ${commits(view.behind)}`;
17
18
  }
@@ -25,6 +26,16 @@ export function familyStartOf(store, taskRef) {
25
26
  const root = ancestry.problem !== null || rootId === undefined || rootId === id ? null : store.lookupRef(rootId);
26
27
  if (root === null || root.repo !== ref.repo)
27
28
  return null;
29
+ for (const member of ancestry.chain.slice(0, -1)) {
30
+ const memberRef = store.lookupRef(member);
31
+ if (memberRef === null)
32
+ continue;
33
+ for (const branch of taskBranches(member)) {
34
+ const moved = store.latestBranchBaseMove(memberRef.id, branch);
35
+ if (moved !== null && store.firstBuilderBase(memberRef.id, branch) === moved.from)
36
+ return moved.to;
37
+ }
38
+ }
28
39
  const first = store.runsFor(root.id).filter(one => one.role === "builder" && one.branch !== null && one.baseRevision !== null).sort((a, b) => a.id - b.id)[0];
29
40
  if (first === undefined || first.branch === null)
30
41
  return null;
@@ -57,13 +57,15 @@ export function approvedCheckStateOf(checks) {
57
57
  if (checksUnderway(checks) || checks.status === "running")
58
58
  return "running";
59
59
  if (checks.status === "unavailable")
60
- return "unreadable";
60
+ return checks.cause === "command-changed" ? "stale" : "unreadable";
61
61
  if (checks.status === "passed")
62
62
  return "passed";
63
63
  if (checks.level === "off")
64
64
  return checks.release != null ? "passed" : "off";
65
65
  return "not-run";
66
66
  }
67
+ export const CHECKS_STALE_ROW = "Out of date: the check command changed since they ran";
68
+ export const CHECKS_OUT_OF_DATE = "Checks out of date";
67
69
  export const CHECK_UNREADABLE = "The check result couldn't be read.";
68
70
  export const CHECK_UNREADABLE_ASK = `${CHECK_UNREADABLE} Run checks on it, or open the result to see why.`;
69
71
  export const CHECK_COMMAND_CHANGED = "The check command changed since this check; run checks again.";
@@ -92,7 +94,8 @@ function resultAsk(facts) {
92
94
  const req = facts.requirements;
93
95
  if (req != null && facts.accepted !== true && req.unverified !== true && (req.yours > 0 || (req.unshown ?? 0) > 0) && req.ask != null)
94
96
  return req.ask;
95
- if (facts.accepted !== true && approvedCheckStateOf(facts.checks) === "unreadable")
97
+ const check = approvedCheckStateOf(facts.checks);
98
+ if (facts.accepted !== true && (check === "unreadable" || check === "stale"))
96
99
  return unreadableAsk(facts.checks);
97
100
  return null;
98
101
  }
@@ -193,7 +196,7 @@ function detailsOf(headline, facts) {
193
196
  else if (checks.status === "passed")
194
197
  row("checks", CHECKS_LABEL, `${quick ? "Quick checks passed" : "Passed"}${sha === null ? "" : ` on ${sha}`}`, "ok", quick && runChecks !== null && headline !== "Complete" ? { href: checksHref, action: { label: "Run full checks", href: runChecks.href } } : { href: checksHref });
195
198
  else if (checks.status === "failed")
196
- row("checks", CHECKS_LABEL, `${quick ? "Quick checks failed" : "Failed"}${checks.exitCode === null ? "" : ` (exit ${checks.exitCode})`}`, problem(headline), headline === "Failed" ? { href: checksHref } : { action: { label: "See what failed", href: checksHref } });
199
+ row("checks", CHECKS_LABEL, `${quick ? "Quick checks failed" : "Failed"}${checks.exitCode === null ? "" : ` (exit ${checks.exitCode})`}`, problem(headline), headline === "Failed" ? { href: checksHref } : runChecks !== null ? { href: checksHref, action: runChecks } : { action: { label: "See what failed", href: checksHref } });
197
200
  else if (checks.status === "running")
198
201
  row("checks", CHECKS_LABEL, "Running", "running");
199
202
  else if (checks.level === "off" && checks.release != null)
@@ -203,7 +206,7 @@ function detailsOf(headline, facts) {
203
206
  else if (checks.status === "not-run")
204
207
  row("checks", CHECKS_LABEL, "Didn't run", "none", runChecks === null ? {} : { action: runChecks });
205
208
  else if (checks.cause === "command-changed")
206
- row("checks", CHECKS_LABEL, "Check command changed since", "note", { action: runChecks ?? { label: OPEN_RESULT, href: facts.links?.result ?? null }, why: CHECK_COMMAND_CHANGED });
209
+ row("checks", CHECKS_LABEL, CHECKS_STALE_ROW, "note", { action: runChecks ?? { label: OPEN_RESULT, href: facts.links?.result ?? null }, why: CHECK_COMMAND_CHANGED });
207
210
  else
208
211
  row("checks", CHECKS_LABEL, "Couldn't be read", "note", { action: runChecks ?? { label: OPEN_RESULT, href: facts.links?.result ?? null } });
209
212
  }
@@ -237,9 +240,10 @@ function detailsOf(headline, facts) {
237
240
  row("requirements", "Requirements", "Unverified", "none");
238
241
  else if (req != null && req.total > 0) {
239
242
  const atRelease = req.atRelease ?? 0;
240
- const unmet = req.total - req.met - req.yours - atRelease;
241
- const text = `${req.met} of ${req.total} met${atRelease > 0 ? ` · ${atRelease} at release` : ""}${req.yours > 0 ? ` · You check ${req.yours}` : ""}`;
242
- row("requirements", "Requirements", text, unmet > 0 ? problem(headline) : req.met === req.total ? "ok" : "none", unmet > 0 && headline !== "Failed" ? { action: { label: "See which", href: facts.links?.checks ?? facts.links?.result ?? null } } : {});
243
+ const yours = headline === "Complete" && facts.personCompleted === true ? 0 : req.yours, met = req.met + req.yours - yours;
244
+ const unmet = req.total - met - yours - atRelease;
245
+ const text = `${met} of ${req.total} met${atRelease > 0 ? ` · ${atRelease} at release` : ""}${yours > 0 ? ` · You check ${yours}` : ""}`;
246
+ row("requirements", "Requirements", text, unmet > 0 ? problem(headline) : met === req.total ? "ok" : "none", unmet > 0 && headline !== "Failed" ? { action: { label: "See which", href: facts.links?.checks ?? facts.links?.result ?? null } } : {});
243
247
  }
244
248
  const evidence = facts.evidence;
245
249
  if (evidence != null) {
@@ -453,6 +457,11 @@ export function checksFactOf(checks, head) {
453
457
  export function receiptChecksOf(receipt) {
454
458
  return approvedCheckOf(receipt.proof?.verdict ?? null, receipt.proof?.reasons ?? [], checksFactOf(receipt.checks, receipt.head));
455
459
  }
460
+ export function completedByOf(completion) {
461
+ if (completion !== null && completion.person !== undefined)
462
+ return completion.person;
463
+ return completion === null || completion.landed !== undefined ? null : completion.lead === true ? "the lead" : completion.actor.replace(/^(?:operator|coordinator|lead):/, "");
464
+ }
456
465
  export function assignmentStatusFacts(assignment, options = {}) {
457
466
  const { stage, need, wait } = assignmentStageOf(assignment, options.work ?? null, options.planning ?? false);
458
467
  const build = assignment.need?.build ?? null;
@@ -476,7 +485,8 @@ export function assignmentStatusFacts(assignment, options = {}) {
476
485
  ...(withResult && receipt?.proofAcceptance != null ? { accepted: true } : {}),
477
486
  ...(withResult && (assignment.readiness?.blockers.length ?? 0) > 0 ? { blockers: assignment.readiness.blockers } : {}),
478
487
  evidence: withResult ? options.evidence ?? evidenceOf(receipt, [...(receipt?.caveats ?? []), ...assignment.attention]) : null,
479
- completedBy: assignment.completion === null || assignment.completion.landed !== undefined ? null : assignment.completion.lead === true ? "the lead" : assignment.completion.actor.replace(/^(?:operator|coordinator|lead):/, ""),
488
+ completedBy: completedByOf(assignment.completion),
489
+ ...(assignment.completion?.person !== undefined ? { personCompleted: true } : {}),
480
490
  ...(assignment.completion?.landed === undefined ? {} : { landed: assignment.completion.landed }),
481
491
  action: options.action ?? null,
482
492
  ...(options.links === undefined ? {} : { links: options.links }),
@@ -1075,6 +1075,12 @@ function plainBranch(name) {
1075
1075
  export function syncWriteArgv(args) {
1076
1076
  if (args.length === 3 && args[0] === "branch" && args[1] === "-D" && plainBranch(args[2]))
1077
1077
  return ["branch", "-D", args[2]];
1078
+ if (args.length === 5 && args[0] === "update-ref" && args[1] === "--no-deref" && args[2].startsWith("refs/heads/") && plainBranch(args[2].slice("refs/heads/".length))) {
1079
+ const [ref, next, old] = [args[2], args[3], args[4]];
1080
+ if (!/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/.test(next) || next.length !== old.length || !/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/.test(old) || next === old || /^0+$/.test(old) || /^0+$/.test(next))
1081
+ return null;
1082
+ return ["update-ref", "--no-deref", "-m", "toolroll: branch moved by compare-and-swap", ref, next, old];
1083
+ }
1078
1084
  if (args.length !== 5 || args[0] !== "fetch" || args[1] !== "--no-tags" || args[2] !== "--no-write-fetch-head")
1079
1085
  return null;
1080
1086
  const path = args[3], refspec = args[4];
@@ -225,7 +225,7 @@ export function phoneTaskView(store, repos, id, now, root) {
225
225
  const checkNow = root === undefined || proof?.verdict !== "verified" ? null
226
226
  : approvedCheckStateOf(approvedCheckOf(proof.verdict, proof.reasons, checksFactOf(assignmentChecksForRun(store, root, result.id, now), result.headRevision)));
227
227
  const verifiedWords = root === undefined ? "Open the result to see its checks" : checkNow === "passed" ? "Checks passed at completion"
228
- : checkNow === "failed" ? "Checks failed" : checkNow === "running" ? "Checks running" : "The check result couldn't be read";
228
+ : checkNow === "failed" ? "Checks failed" : checkNow === "running" ? "Checks running" : checkNow === "stale" ? "The check command changed since they ran" : "The check result couldn't be read";
229
229
  const proofWords = { verified: verifiedWords, attested: "Checks reported by the agent, not run by Toolroll", short: "Required saved material is missing", refuted: "The saved result doesn't match the approved plan" };
230
230
  lines.push(`Checks: ${proof === null ? "No completion record saved" : manualReviewOnly(proof) ? accepted ? "Accepted by a person; the recorded checks are unchanged" : "A person must inspect this result; no recorded check failed" : proofWords[proof.verdict]}.`);
231
231
  if (manualReviewOnly(proof) && !accepted)
@@ -4,6 +4,7 @@ import { createRequire } from "node:module";
4
4
  import { installMethod } from "./install-method.js";
5
5
  import { isNewer, latestVersionNow } from "./releases.js";
6
6
  import { databasePath } from "./store.js";
7
+ import { neverAnswered, unreachableWhy } from "./unreachable.js";
7
8
  import { PACKAGE_VERSION } from "./version.js";
8
9
  import { currentRuntime, lastCompletedUpdate, machineSystem, readRuntimeUpdate, requestRuntimeUpdateCancel, resumeRuntimeUpdate, retireUpdateJob, startRuntimeRollback, startRuntimeUpdate, } from "./toolroll-update.js";
9
10
  function sqlite() {
@@ -121,7 +122,7 @@ export async function runUpdateCommand(args, write, deps = {}) {
121
122
  version = (await (deps.latest ?? latestVersionNow)()).version;
122
123
  }
123
124
  catch (error) {
124
- write(`Could not read the latest release: ${error.message}`);
125
+ write(neverAnswered(error) ? `Couldn't reach the release server: ${unreachableWhy(error, 10)}. Nothing was changed.` : `Could not read the latest release: ${error.message}. Nothing was changed.`);
125
126
  return 1;
126
127
  }
127
128
  }
@@ -27,6 +27,7 @@ import { V173_ADDED_COLUMNS } from "./plan-problems-schema.js";
27
27
  import { V159_ADDED_COLUMNS } from "./one-step-chat-schema.js";
28
28
  import { isNewer, REGISTRY } from "./releases.js";
29
29
  import { markNeverIndex } from "./never-index.js";
30
+ import { protectTree } from "./trust-repair.js";
30
31
  import { readRuntimeUpdateJournal, RUNTIME_PHASES, RUNTIME_UPDATE_STEPS, stagedStartedAt, updaterStartingOf } from "./contracts/update-journal.js";
31
32
  import { sleep } from "./sleep.js";
32
33
  function sqlite() {
@@ -856,6 +857,8 @@ export function prepareRuntimeUpdate(o, now) {
856
857
  return { refused: `${o.version} is not a release version (x.y.z).` };
857
858
  if (!o.allowDowngrade && !isNewer(o.version, o.current.version))
858
859
  return { refused: `Toolroll ${o.version} is not newer than ${o.current.version}. To go back to an older release, run toolroll update --version ${o.version} --allow-downgrade.` };
860
+ if (!existsSync(o.databaseFile))
861
+ return { refused: `Toolroll isn't set up on this computer yet (there's no database at ${o.databaseFile}), so there's nothing to update. Nothing was changed. To get the newest command, run npm install -g toolroll@latest.` };
859
862
  try {
860
863
  assertNoneActive(o.stateDir);
861
864
  keepCompletedUpdate(o.stateDir);
@@ -1430,6 +1433,7 @@ export function machineSystem(home = homedir(), env = process.env, seams = {}) {
1430
1433
  const installed = sh("npm", ["install", "--omit=dev", "--ignore-scripts", "--no-audit", "--no-fund", "--no-color", registry], { cwd: runtime });
1431
1434
  if (installed.status !== 0)
1432
1435
  throw new Refusal(`npm could not install Toolroll ${release.version}: ${(installed.stderr || installed.stdout).trim().slice(-400)} Nothing was changed.`);
1436
+ protectTree(join(runtime, "node_modules"));
1433
1437
  let locked;
1434
1438
  try {
1435
1439
  locked = JSON.parse(readFileSync(join(runtime, "package-lock.json"), "utf8")).packages?.[`node_modules/${NAME}`];
@@ -0,0 +1,187 @@
1
+ import { spawnSync } from "node:child_process";
2
+ import { chmodSync, lstatSync, readdirSync, readFileSync, realpathSync } from "node:fs";
3
+ import { dirname, join, sep } from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+ import { hasUnsafeText, shownText } from "./shown-text.js";
6
+ import { aclVerdictOf } from "./trusted-path.js";
7
+ const quote = (path) => `'${path.replace(/'/g, `'\\''`)}'`;
8
+ const inside = (path, root) => path === root || path.startsWith(root.endsWith(sep) ? root : `${root}${sep}`);
9
+ export function platformAclMark(platform = process.platform) {
10
+ return path => {
11
+ if (/[\u0000-\u001f\u007f]/.test(path))
12
+ return "unknown";
13
+ const ran = spawnSync("/bin/ls", platform === "darwin" ? ["-lde", "--", path] : ["-ld", "--", path], { encoding: "utf8", timeout: 2_000, env: { LC_ALL: "C", PATH: "/usr/bin:/bin" }, stdio: ["ignore", "pipe", "ignore"] });
14
+ if (ran.status !== 0 || typeof ran.stdout !== "string" || ran.stdout === "")
15
+ return "unknown";
16
+ if (platform === "darwin")
17
+ return aclVerdictOf(ran.stdout).ok ? "none" : "acl";
18
+ const mode = /^[-dlbcpsw][-rwxsStT]{9}([+.@]?) /.exec(ran.stdout);
19
+ return mode === null ? "unknown" : mode[1] === "+" ? "acl" : "none";
20
+ };
21
+ }
22
+ export function trustFaults(path, options) {
23
+ let real;
24
+ try {
25
+ real = realpathSync(path);
26
+ }
27
+ catch {
28
+ return null;
29
+ }
30
+ const acl = options.acl ?? platformAclMark(options.platform);
31
+ const faults = [];
32
+ try {
33
+ const base = lstatSync(real).isDirectory() ? real : dirname(real);
34
+ for (let at = real;; at = dirname(at)) {
35
+ const info = lstatSync(at);
36
+ if (!options.owners.includes(info.uid))
37
+ faults.push({ path: at, kind: "owner", owner: info.uid });
38
+ const sticky = info.isDirectory() && (info.mode & 0o1000) !== 0;
39
+ const stickyPass = options.stickyAbove === true && sticky && at !== real && at !== base;
40
+ if (stickyPass) {
41
+ if (dirname(at) === at)
42
+ break;
43
+ continue;
44
+ }
45
+ const groupWrite = (info.mode & 0o020) !== 0;
46
+ if ((info.mode & 0o002) !== 0)
47
+ faults.push({ path: at, kind: "world-write" });
48
+ else if (groupWrite)
49
+ faults.push({ path: at, kind: "group-write" });
50
+ const darwin = (options.platform ?? process.platform) === "darwin";
51
+ if ((darwin || groupWrite) && acl(at) === "acl")
52
+ faults.push({ path: at, kind: "acl" });
53
+ if (dirname(at) === at)
54
+ break;
55
+ }
56
+ }
57
+ catch {
58
+ return null;
59
+ }
60
+ return faults;
61
+ }
62
+ export function trustRepair(paths, options) {
63
+ const seen = new Set();
64
+ const faults = [];
65
+ for (const path of typeof paths === "string" ? [paths] : paths) {
66
+ for (const fault of trustFaults(path, options) ?? []) {
67
+ if (seen.has(`${fault.kind}\0${fault.path}`))
68
+ continue;
69
+ seen.add(`${fault.kind}\0${fault.path}`);
70
+ faults.push(fault);
71
+ }
72
+ }
73
+ if (faults.length === 0)
74
+ return null;
75
+ const platform = options.platform ?? process.platform;
76
+ const euid = options.euid ?? process.geteuid?.() ?? -1;
77
+ const own = options.ownTree ?? null;
78
+ const commands = [];
79
+ const notes = [];
80
+ const ownerOf = (path) => { try {
81
+ return lstatSync(path).uid;
82
+ }
83
+ catch {
84
+ return null;
85
+ } };
86
+ const sudo = (path) => ownerOf(path) === 0 && euid !== 0 ? "sudo " : "";
87
+ const unsafe = faults.filter(one => hasUnsafeText(one.path));
88
+ if (unsafe.length > 0) {
89
+ notes.push("A path has a control or invisible character in its name, so no command is printed for it: reinstall that program into a plain folder you own.");
90
+ }
91
+ const fixable = faults.filter(one => !unsafe.includes(one));
92
+ const planned = [];
93
+ const inOwn = own === null ? [] : fixable.filter(one => inside(one.path, own) && one.kind !== "owner");
94
+ if (own !== null && inOwn.some(one => one.kind === "acl"))
95
+ planned.push({ at: own, command: platform === "darwin" ? `${sudo(own)}chmod -R -N ${quote(own)}` : `${sudo(own)}setfacl -R -b ${quote(own)}` });
96
+ if (own !== null && inOwn.length > 0)
97
+ planned.push({ at: own, command: `${sudo(own)}chmod -R go-w ${quote(own)}` });
98
+ const rest = fixable.filter(one => !inOwn.includes(one));
99
+ for (const at of new Set(rest.map(one => one.path))) {
100
+ const kinds = new Set(rest.filter(one => one.path === at).map(one => one.kind));
101
+ if (kinds.has("owner")) {
102
+ const owner = rest.find(one => one.path === at && one.kind === "owner")?.owner;
103
+ notes.push(`${shownText(at)} belongs to another user (uid ${owner ?? "unknown"}), so what is in it can't be trusted: reinstall into a folder that you or root own.`);
104
+ }
105
+ if (kinds.has("acl"))
106
+ planned.push({ at, command: platform === "darwin" ? `${sudo(at)}chmod -N ${quote(at)}` : `${sudo(at)}setfacl -b ${quote(at)}` });
107
+ if (kinds.has("group-write") || kinds.has("world-write") || (kinds.has("acl") && platform !== "darwin"))
108
+ planned.push({ at, command: `${sudo(at)}chmod go-w ${quote(at)}` });
109
+ }
110
+ const depth = (path) => path.split(sep).length;
111
+ commands.push(...planned.map((one, index) => ({ ...one, index })).sort((a, b) => depth(a.at) - depth(b.at) || a.index - b.index).map(one => one.command));
112
+ if (faults.some(one => one.kind !== "owner")) {
113
+ notes.push("Others could change these files until now. If anyone else uses this computer, reinstall from a trusted source too.");
114
+ const mask = currentUmask();
115
+ if (mask !== null && (mask & 0o022) !== 0o022)
116
+ notes.push(`New files here are made writable by others (umask ${mask.toString(8).padStart(4, "0")}): run \`umask 022\` before installing, or add it to your shell profile.`);
117
+ }
118
+ return { faults, commands, notes };
119
+ }
120
+ function currentUmask() {
121
+ try {
122
+ return process.umask();
123
+ }
124
+ catch {
125
+ return null;
126
+ }
127
+ }
128
+ export function trustFaultWords(fault) {
129
+ const path = shownText(fault.path);
130
+ return fault.kind === "owner" ? `${path} belongs to another user`
131
+ : fault.kind === "world-write" ? `everyone can change ${path}`
132
+ : fault.kind === "group-write" ? `its group can change ${path}`
133
+ : `${path} has an extended ACL`;
134
+ }
135
+ export function trustRepairLines(repair) {
136
+ const listed = repair.faults.filter(fault => fault.kind !== "owner").slice(0, 5);
137
+ return [
138
+ ...(repair.commands.length > 0 ? ["Fix it with:", ...repair.commands.map(one => ` ${one}`)] : listed.map(fault => ` ${trustFaultWords(fault)}`)),
139
+ ...repair.notes,
140
+ ].map(shownText);
141
+ }
142
+ export function toolrollPackageRoot(from = fileURLToPath(import.meta.url)) {
143
+ let at;
144
+ try {
145
+ at = realpathSync(dirname(from));
146
+ }
147
+ catch {
148
+ return null;
149
+ }
150
+ for (;;) {
151
+ try {
152
+ if (lstatSync(join(at, "package.json")).isFile()) {
153
+ const name = JSON.parse(readFileSync(join(at, "package.json"), "utf8")).name;
154
+ return name === "toolroll" || name === "standing-orders" ? at : null;
155
+ }
156
+ }
157
+ catch { }
158
+ const up = dirname(at);
159
+ if (up === at)
160
+ return null;
161
+ at = up;
162
+ }
163
+ }
164
+ export function protectTree(root) {
165
+ const walk = (at) => {
166
+ const info = lstatSync(at);
167
+ if (info.isSymbolicLink())
168
+ return;
169
+ if ((info.mode & 0o022) !== 0)
170
+ chmodSync(at, info.mode & 0o7755);
171
+ if (info.isDirectory())
172
+ for (const name of readdirSync(at))
173
+ walk(join(at, name));
174
+ };
175
+ walk(root);
176
+ }
177
+ export function mergeRepairs(a, b) {
178
+ if (a === null || b === null)
179
+ return a ?? b;
180
+ const once = (list, key) => { const seen = new Set(); return list.filter(one => { const k = key(one); if (seen.has(k))
181
+ return false; seen.add(k); return true; }); };
182
+ return {
183
+ faults: once([...a.faults, ...b.faults], one => `${one.kind}\0${one.path}`),
184
+ commands: once([...a.commands, ...b.commands], one => one),
185
+ notes: once([...a.notes, ...b.notes], one => one),
186
+ };
187
+ }
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,15 @@
1
+ export function unreachableWhy(error, timeoutSeconds) {
2
+ const cause = error?.cause;
3
+ const code = typeof cause?.code === "string" ? cause.code : "";
4
+ if (error?.name === "TimeoutError")
5
+ return `it didn't answer within ${timeoutSeconds} seconds`;
6
+ if (code === "ENOTFOUND" || code === "EAI_AGAIN")
7
+ return "its address couldn't be looked up (this computer may be offline)";
8
+ if (code === "ECONNREFUSED" || code === "ECONNRESET" || code === "EPERM" || code === "EACCES")
9
+ return "the connection was refused or blocked";
10
+ return "the connection failed (this computer may be offline, or a firewall blocks it)";
11
+ }
12
+ export function neverAnswered(error) {
13
+ const name = error?.name;
14
+ return name === "TimeoutError" || (error instanceof TypeError && error.message === "fetch failed");
15
+ }
@@ -473,7 +473,7 @@ function readWorkIndexPage(store, now, access, options, taskId = null) {
473
473
  )${kept ? `, led AS MATERIALIZED (
474
474
  -- The page's results' own check-level and check-request lines, read in one pass: each row's lookups below then
475
475
  -- read this short list instead of scanning its project's ledger (their filters and order are unchanged).
476
- SELECT id,repo,run_id,action,outcome FROM action_ledger WHERE action IN ('checks used','checks requested')
476
+ SELECT id,repo,run_id,action,outcome,detail FROM action_ledger WHERE action IN ('checks used','checks requested')
477
477
  AND run_id IN (SELECT page_result_id FROM page WHERE is_row AND page_result_id IS NOT NULL)
478
478
  )` : ''}
479
479
  SELECT is_row,is_project,repo_rank,repo,${PAGE_TOTAL_NAMES.join(',')},${PROJECT_TOTAL_NAMES.join(',')},CASE WHEN is_row THEN json_object('archived',archived,'archived_by',(SELECT by FROM task_archive WHERE task_ref=page.ref_id),
@@ -484,9 +484,16 @@ function readWorkIndexPage(store, now, access, options, taskId = null) {
484
484
  'publication_url',(SELECT pr_url FROM publication WHERE run=page_result_id),
485
485
  'result_role',(SELECT role FROM run WHERE id=page_result_id),'result_head',(SELECT head_revision FROM run WHERE id=page_result_id),'live_role',(SELECT role FROM run WHERE id=page.live_run),
486
486
  'check_status',(SELECT status FROM run_check WHERE run=page_result_id),
487
+ 'check_commands',CASE WHEN code='complete' THEN json_object('started',(SELECT started_at FROM run WHERE id=page_result_id),
488
+ 'full',(SELECT approved_at FROM verify_command WHERE repo IS page.repo AND revoked_at IS NULL),
489
+ 'quick',(SELECT approved_at FROM verify_command WHERE repo='quick:'||page.repo AND revoked_at IS NULL)) END,
487
490
  'check_level',(SELECT outcome FROM ${kept ? 'led' : 'action_ledger'} WHERE repo IS page.repo AND run_id=page_result_id AND action='checks used' ORDER BY id DESC LIMIT 1),
488
491
  'check_follows',(SELECT json_group_array(q.outcome||' '||COALESCE((SELECT substr(f.outcome,instr(f.outcome,':')+1) FROM action_ledger f WHERE f.repo IS page.repo AND f.run_id=page_result_id
489
- AND f.action='checks finished' AND f.outcome LIKE q.id||':%' LIMIT 1),'open')) FROM (SELECT id,outcome FROM ${kept ? 'led' : 'action_ledger'} WHERE repo IS page.repo AND run_id=page_result_id AND action='checks requested' ORDER BY id) q),
492
+ AND f.action='checks finished' AND f.outcome LIKE q.id||':%' LIMIT 1),'open')
493
+ -- Whether the request was bound to the full and to the quick check command as each stands now (its digest).
494
+ ||' '||COALESCE((SELECT q.detail LIKE '% · '||digest FROM verify_command WHERE repo IS page.repo AND revoked_at IS NULL),0)
495
+ ||COALESCE((SELECT q.detail LIKE '% · '||digest FROM verify_command WHERE repo='quick:'||page.repo AND revoked_at IS NULL),0))
496
+ FROM (SELECT id,outcome,detail FROM ${kept ? 'led' : 'action_ledger'} WHERE repo IS page.repo AND run_id=page_result_id AND action='checks requested' ORDER BY id) q),
490
497
  'proof_verdict',(SELECT COALESCE(machine_verdict,verdict) FROM proof_verdict WHERE run=page_result_id),
491
498
  'proof_failed_check',(SELECT verdict='refuted' AND reasons_json LIKE '%approved verification command exited%' FROM proof_verdict WHERE run=page_result_id),'code',code,'ask_group',ask_group,'needs',needs,'person_need',person_need,'lead_claim',lead_claim,'family_running',family_running,'rank',rank,'ask_rank',ask_rank,'list_order',${ORDER},'sort_at',sort_at,
492
499
  'checked_actor',checked_actor,'checked_at',checked_at,'checked_digest',checked_digest,'checked_detail',checked_detail,'question_id',question_id,
@@ -593,6 +600,44 @@ function listChecksOf(own, level, follows) {
593
600
  return null;
594
601
  return { status: read.status, exitCode: null, head: null, level: read.level, running: read.running };
595
602
  }
603
+ export function currentChecksOf(own, level, follows, commands) {
604
+ let parsed = [];
605
+ try {
606
+ parsed = (typeof follows === 'string' ? JSON.parse(follows) : Array.isArray(follows) ? follows : []).map(String);
607
+ }
608
+ catch {
609
+ parsed = [];
610
+ }
611
+ let at = {};
612
+ try {
613
+ at = (typeof commands === 'string' ? JSON.parse(commands) : commands ?? {});
614
+ }
615
+ catch {
616
+ at = {};
617
+ }
618
+ const started = typeof at.started === 'string' ? at.started : null;
619
+ const full = typeof at.full === 'string' ? at.full : null, quick = typeof at.quick === 'string' ? at.quick : null;
620
+ const ran = isCheckLevel(level) ? level : null;
621
+ const ownCommand = ran === 'quick' ? quick ?? full : full;
622
+ const ownCurrent = started !== null && ownCommand !== null && ownCommand <= started;
623
+ const counted = parsed.flatMap(one => {
624
+ const [ask, said, bound = '00'] = one.split(' ');
625
+ if (ask !== 'quick' && ask !== 'full')
626
+ return [];
627
+ const state = said === 'passed' || said === 'failed' ? said : said === 'open' ? 'waiting' : null;
628
+ if (state === null)
629
+ return [];
630
+ if (state !== 'waiting' && bound[ask === 'full' ? 0 : 1] !== '1')
631
+ return [];
632
+ return [{ level: ask, state, head: '', exitCode: null }];
633
+ });
634
+ const base = own === 'failed' ? 'failed' : own === 'passed' ? ownCurrent ? 'passed' : 'unavailable' : 'not-run';
635
+ const read = withFollowUps({ status: base, level: ran, exitCode: null, head: null }, counted);
636
+ if (own === null && read.status === 'not-run' && ran !== 'off' && read.running === null)
637
+ return null;
638
+ return { status: read.status, exitCode: null, head: null, level: read.level, running: read.running,
639
+ ...(read.status === 'unavailable' && ownCommand !== null ? { cause: 'command-changed' } : {}) };
640
+ }
596
641
  function unreadChecksOf(checks) {
597
642
  if (checks === null)
598
643
  return null;
@@ -791,7 +836,8 @@ function itemOf(row, principal, probe, leadName, readiness, readable = false, no
791
836
  const checkStatus = s(row, 'check_status'), verdict = s(row, 'proof_verdict');
792
837
  const finished = reading.stage === 'finished' || reading.stage === 'complete';
793
838
  const own = checkStatus === 'failed' || n(row, 'proof_failed_check') === 1 ? 'failed' : checkStatus === 'passed' ? 'passed' : null;
794
- const recordedChecks = !finished ? null : listChecksOf(own, s(row, 'check_level'), row['check_follows']);
839
+ const recordedChecks = !finished ? null : code === 'complete' ? currentChecksOf(own, s(row, 'check_level'), row['check_follows'], row['check_commands'])
840
+ : listChecksOf(own, s(row, 'check_level'), row['check_follows']);
795
841
  const listedChecks = readable ? recordedChecks : unreadChecksOf(recordedChecks);
796
842
  const ready = reading.stage === 'finished' && readiness !== undefined ? readiness(row, recordedChecks) : null;
797
843
  const landed = code === 'complete' ? landedReasonOf(s(row, 'checked_actor'), s(row, 'checked_detail')) : null;
@@ -835,7 +881,9 @@ function itemOf(row, principal, probe, leadName, readiness, readable = false, no
835
881
  views.push('queued');
836
882
  if (archived === null && code === 'complete')
837
883
  views.push('completed');
884
+ const after = code === 'complete' && (shared.check === 'failed' || shared.check === 'stale' || shared.check === 'unreadable') ? shared.check : null;
838
885
  return { rootId: String(row['root_id']), activeTaskId: id, title: String(row['root_title']), repo: s(row, 'repo'),
886
+ ...(after === null ? {} : { check: after }),
839
887
  state: String(row['state']), assignmentState, createdAt: String(row['created_at']), updatedAt: String(row['sort_at']),
840
888
  versionCount: n(row, 'version_count'), earlierActiveCount: n(row, 'earlier_active'), familyProblem: n(row, 'broken') ? FAMILY_PROBLEM : null,
841
889
  liveRunId: n(row, 'live_run') || null, unfinishedRunId: n(row, 'unfinished') || null, resultRunId: n(row, 'result_id') || null, resultTaskId: n(row, 'result_id') ? id : null,
@@ -2,7 +2,7 @@ import { lastIncludedWords } from './memory-use.js';
2
2
  import { ACCEPT_NEEDS_REASON, FAILED_CHECK, cantAcceptYetOf, evidenceProblemOf } from "./result-acts.js";
3
3
  export { ACCEPT_NEEDS_REASON, cantAcceptYetOf, evidenceProblemOf };
4
4
  import { manualReviewOnly, plainReasonWords } from "./proof.js";
5
- import { CHECK_COMMAND_CHANGED, CHECK_UNREADABLE, OPEN_RESULT, approvedCheckOf, approvedCheckStateOf, plainReasonOf, stageOfCode, taskStatusOf, workToneOf } from "./task-status.js";
5
+ import { CHECK_COMMAND_CHANGED, CHECK_UNREADABLE, CHECKS_OUT_OF_DATE, OPEN_RESULT, approvedCheckOf, approvedCheckStateOf, plainReasonOf, stageOfCode, taskStatusOf, workToneOf } from "./task-status.js";
6
6
  import { whenUtc } from "./when-html.js";
7
7
  import { NEEDS } from "./needs-you.js";
8
8
  import { wasInterrupted } from "./run-ending.js";
@@ -574,7 +574,9 @@ export function stepRowsOf(view) {
574
574
  if (step.state === "skipped")
575
575
  return { sentence: said === "Checks not run" ? "The checks didn't run" : said === "Checks at release" ? "Checks deferred to release" : "No checks were recorded", at: null };
576
576
  if (step.state === "stuck")
577
- return { sentence: step.needsYou && said === null ? "" : said === "Checks unreadable" ? "The checks couldn't be read" : said === "Checks failed" ? headline === "Complete" ? "The checks failed when they ran again" : "The checks failed" : stoppedWord, at: null };
577
+ return { sentence: step.needsYou && said === null ? "" : said === "Checks unreadable" ? "The checks couldn't be read"
578
+ : said === CHECKS_OUT_OF_DATE ? "The check command changed since they ran"
579
+ : said === "Checks failed" ? headline === "Complete" ? "The checks failed when they ran again" : "The checks failed" : stoppedWord, at: null };
578
580
  if (step.state === "current")
579
581
  return { sentence: said === "Checks running" ? "The checks are running" : step.needsYou ? "" : "Waiting for the checks", at: null };
580
582
  return { sentence: "The project's checks run on the result", at: null };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "toolroll",
3
- "version": "0.9.125",
3
+ "version": "0.9.127",
4
4
  "description": "Your agents build. You decide. A control plane for coding agents — Claude Code, Codex, Gemini: approve the exact scope once, get results back Ready with the diff, the passing check and screenshots. Runs on your machine.",
5
5
  "directories": {
6
6
  "doc": "docs"