toolroll 0.9.117 → 0.9.119

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 (72) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/README.md +14 -14
  3. package/dist/agent-fence.js +54 -6
  4. package/dist/assignment.js +40 -29
  5. package/dist/browser/workspace.css +1 -1
  6. package/dist/browser/workspace.js +32 -31
  7. package/dist/builder.js +295 -237
  8. package/dist/central-recovery-stage.js +3 -3
  9. package/dist/check-failure.js +2 -2
  10. package/dist/check-levels.js +3 -0
  11. package/dist/check-report.js +58 -7
  12. package/dist/coding-context.js +16 -2
  13. package/dist/coding-provider.js +7 -3
  14. package/dist/coding-workspace.js +5 -5
  15. package/dist/contracts/console-api.js +4 -1
  16. package/dist/contracts/engine-api.js +1 -0
  17. package/dist/contracts/release-check.js +7 -4
  18. package/dist/contracts/release-terms.js +11 -2
  19. package/dist/contracts/verification-receipt.js +1 -1
  20. package/dist/deploy-gate.js +7 -1
  21. package/dist/direct-chat.js +3 -3
  22. package/dist/easy-start.js +8 -6
  23. package/dist/engine-reads.js +72 -0
  24. package/dist/flexible-conversation-schema.js +24 -0
  25. package/dist/flexible-conversation.js +162 -0
  26. package/dist/flexible-custody.js +3 -0
  27. package/dist/flexible-import.js +51 -0
  28. package/dist/flexible-session.js +84 -11
  29. package/dist/install-mode.js +1 -1
  30. package/dist/invoke.js +18 -6
  31. package/dist/local-landing.js +500 -0
  32. package/dist/local-owner.js +1 -0
  33. package/dist/operate.js +143 -22
  34. package/dist/passwordless.js +1 -1
  35. package/dist/planner.js +6 -1
  36. package/dist/project-delete.js +1 -0
  37. package/dist/project-skills.js +28 -13
  38. package/dist/rehearsal.js +27 -0
  39. package/dist/release-adapters.js +170 -2
  40. package/dist/release-approval.js +11 -8
  41. package/dist/release-card.js +7 -2
  42. package/dist/release-carry.js +1 -1
  43. package/dist/release-cli.js +115 -14
  44. package/dist/release-main-proof.js +49 -0
  45. package/dist/release-main.js +110 -0
  46. package/dist/release-recheck.js +10 -3
  47. package/dist/release.js +221 -33
  48. package/dist/reply-shape.js +6 -1
  49. package/dist/result-actions.js +7 -1
  50. package/dist/result-follow-ups.js +8 -4
  51. package/dist/scout.js +6 -2
  52. package/dist/serve.js +31 -14
  53. package/dist/server/direct-chat.js +88 -3
  54. package/dist/server/engine-api.js +43 -5
  55. package/dist/server/render-results.js +3 -1
  56. package/dist/server/render-tasks.js +10 -1
  57. package/dist/server/route-table.js +9 -0
  58. package/dist/server/settings.js +31 -7
  59. package/dist/server/task-views.js +15 -0
  60. package/dist/server/tasks.js +63 -3
  61. package/dist/settings-groups-ui.js +2 -2
  62. package/dist/skills-manifest.js +57 -0
  63. package/dist/store.js +29 -4
  64. package/dist/surface.js +9 -1
  65. package/dist/tui/darwin-arm64/toolroll-tui +0 -0
  66. package/dist/tui/darwin-x64/toolroll-tui +0 -0
  67. package/dist/tui/linux-arm64/toolroll-tui +0 -0
  68. package/dist/tui/linux-x64/toolroll-tui +0 -0
  69. package/dist/verification-evidence.js +17 -6
  70. package/dist/workspace-ui.js +1 -1
  71. package/package.json +3 -2
  72. package/scripts/release-proof.mjs +240 -0
package/dist/builder.js CHANGED
@@ -16,14 +16,15 @@ import { CHECK_INVENTORY_CAPTURE, CHECK_REPORT_CAPTURE, CheckBaselineUnverifiabl
16
16
  import { CHECK_LOAD_CAPTURE, CheckLoadWatch } from "./check-load.js";
17
17
  import { NOTHING_STARTED_ACTION, retriedInside } from "./check-failure.js";
18
18
  import { planTargetedRecheck, settleCoverage } from "./release-recheck.js";
19
- import { effectiveCheckFacts } from "./verification-evidence.js";
19
+ import { coveragePasses, effectiveCheckFacts } from "./verification-evidence.js";
20
20
  import { learningContext } from "./project-learning.js";
21
21
  import { knowledgeContext } from "./project-knowledge.js";
22
22
  import { flowGoalCuts } from "./flow-engine.js";
23
23
  import { readCodingHandoff, verifyCodingHandoffBase } from "./coding-handoff.js";
24
24
  import { PREPARED_EVIDENCE_FILE, preparedEvidenceGit, preparedScreenshotMatches, readPreparedEvidence, writePreparedEvidence } from "./prepared-evidence.js";
25
- import { accessSync, constants as fsConstants, existsSync, realpathSync, statSync, unlinkSync, writeFileSync } from "node:fs";
26
- import { homedir } from "node:os";
25
+ import { accessSync, chmodSync, constants as fsConstants, existsSync, mkdtempSync, realpathSync, rmSync, statSync, unlinkSync, writeFileSync } from "node:fs";
26
+ import { homedir, tmpdir } from "node:os";
27
+ import { purposeCheckMode } from "./contracts/release-terms.js";
27
28
  import { delimiter, isAbsolute, join, resolve } from "node:path";
28
29
  import { run, runClaudeStreamJsonl, runOwnerTag, streamsInput } from "./exec.js";
29
30
  import { stopRequestedFor, stopWords, underStopWatch } from "./task-control.js";
@@ -727,8 +728,11 @@ export async function build(store, request) {
727
728
  lastStates: new Map(),
728
729
  };
729
730
  let projectSkillContext;
731
+ let projectSkills;
730
732
  try {
731
- projectSkillContext = skillsContext(store, root, request.runId);
733
+ let manifest;
734
+ ({ text: projectSkillContext, manifest } = skillsContext(store, root, request.runId));
735
+ projectSkills = { root, manifest };
732
736
  }
733
737
  catch (error) {
734
738
  return { ok: false, reason: "skills-unavailable", message: `Project skills could not be loaded: ${error instanceof Error ? error.message : String(error)}` };
@@ -1016,6 +1020,7 @@ export async function build(store, request) {
1016
1020
  omitEnv: AGENT_ENV_DENYLIST,
1017
1021
  network: launchNetworkOf(store, request.taskRef, effective.profile),
1018
1022
  writes: launchWritesOf(effective.profile), sandbox: launchSandboxOf(effective.profile),
1023
+ skills: projectSkills,
1019
1024
  ...(agent === undefined ? {} : { runner: agent }),
1020
1025
  onSpawn: (pid) => { spawned = true; request.onProviderSpawn?.(pid); },
1021
1026
  onStreamEvent: (event) => liveLog.observe(event),
@@ -1061,6 +1066,7 @@ export async function build(store, request) {
1061
1066
  clock, fenced: () => fencedMidBuild,
1062
1067
  plan: { proposal, revision: planRevisionNumber, authority, progress: progressState },
1063
1068
  ...(liveSession === null ? {} : { live: { close: liveSession.closeReason, maxTurns: liveSession.maxTurns } }),
1069
+ skills: projectSkills,
1064
1070
  };
1065
1071
  return await settleProviderOutcome(captured, result);
1066
1072
  }
@@ -1197,6 +1203,7 @@ export async function settleProviderOutcome(captured, result) {
1197
1203
  }
1198
1204
  const parked = await ingestPark({
1199
1205
  profile: effective.profile,
1206
+ skills: captured.skills ?? null,
1200
1207
  store,
1201
1208
  request,
1202
1209
  agent,
@@ -1624,6 +1631,8 @@ async function settleProof(captured, statArtifactId, sealedHead) {
1624
1631
  const gateCommand = batched ? null : configured;
1625
1632
  let verifyCommand;
1626
1633
  let checkAttempt = null;
1634
+ let deployCopyDir = null;
1635
+ let deployCleanupProblem = null;
1627
1636
  let loadWatch = null;
1628
1637
  let releaseFacts = null;
1629
1638
  const verification = { last: null };
@@ -1674,186 +1683,92 @@ async function settleProof(captured, statArtifactId, sealedHead) {
1674
1683
  recordCheckNote("Verification did not start: this worker no longer owned the build.");
1675
1684
  }
1676
1685
  else {
1677
- const verifyRunner = request.verify ?? run;
1678
- const verifyShell = approvedCommandShell(configured.command);
1679
- let baselineUnverifiable = null;
1680
- if (repo !== null && chosenCheck?.level === "full" && (store.getScope(request.taskId)?.candidate ?? null) !== null) {
1681
- const access = checkLaunchOf(store, runId, captured.effective.profile).access;
1682
- const decision = planTargetedRecheck(store, root, { runId, taskId: request.taskId, repo, head: sealedHead, command: configured, access, now: now() });
1683
- const release = decision.authority !== null || releaseCheckScope(store.getScope(request.taskId));
1684
- loadWatch = new CheckLoadWatch(configured.timeoutMs, request.machine === undefined ? {} : { sample: request.machine });
1686
+ const removeDeployCopy = () => {
1687
+ if (deployCopyDir === null)
1688
+ return;
1689
+ const dir = deployCopyDir;
1690
+ deployCopyDir = null;
1685
1691
  try {
1686
- checkAttempt = prepareCheckAttempt(store, root, { runId, repo, head: sealedHead, command: configured, access, authority: decision.authority, limitMs: loadWatch?.limitMs,
1687
- ...(decision.mode === "targeted" ? { plan: decision.plan, snapshot: decision.snapshot } : {}), watch: decision.watch, release,
1688
- learn: learnRequestFor(store, repo, now(), runId).learn }, now());
1692
+ rmSync(dir, { recursive: true, force: true });
1689
1693
  }
1690
1694
  catch (error) {
1691
- if (!(error instanceof CheckBaselineUnverifiable))
1692
- throw error;
1693
- checkAttempt = null;
1694
- baselineUnverifiable = error.message;
1695
- recordCheckNote(error.message);
1696
- }
1697
- if (checkAttempt === null && loadWatch !== null) {
1698
- loadWatch.finish();
1699
- loadWatch = null;
1695
+ deployCleanupProblem = `its copy of this computer's database couldn't be deleted (${error instanceof Error ? error.message : String(error)})`;
1700
1696
  }
1701
- if (loadWatch !== null && loadWatch.limitMs !== configured.timeoutMs)
1702
- store.addRunNote(runId, "Toolroll", `The release check's time limit: ${loadWatch.why}.`, now());
1703
- if (checkAttempt !== null && decision.mode === "targeted")
1704
- store.addRunNote(runId, "Toolroll", `Re-running only what failed at run #${decision.plan.base}: ${decision.plan.units.length} unit files, ${decision.plan.groups.reduce((n, one) => n + one.groups.length, 0)} journey groups, ${decision.plan.versions.length} upgrade versions${decision.plan.parts.length > 0 ? `, and in full: ${decision.plan.parts.join(", ")}` : ""}.`, now());
1705
- }
1706
- else
1707
- checkAttempt = null;
1708
- const progressWrites = coalescedProgressWriter(snapshot => { store.saveCheckProgress(runId, snapshot, now()); });
1709
- const checkProgress = new CheckProgressTracker(snapshot => progressWrites.push(snapshot));
1710
- const runVerification = async (label, missing = null) => {
1711
- const streamed = { stdout: false, stderr: false };
1712
- if (missing === null)
1713
- checkConditions.last = captureCheckConditions({ repo, head: sealedHead, command: configured, access: checkLaunchOf(store, runId, captured.effective.profile).access, envNames: SETUP_ENV_ALLOWLIST });
1714
- const result = missing !== null
1715
- ? { code: 127, stdout: "", stderr: `Toolroll did not start the check: ${missing} wasn't found.`, timedOut: false, notFound: false }
1716
- : await underStopWatch(store, runId, () => {
1717
- loadWatch?.attemptStarted();
1718
- return runWithIsolatedDatabase(witnessedRunner(store, runId, now, commandRunner(store, runId, captured.effective.profile, verifyRunner)), verifyShell.file, verifyShell.args, {
1719
- cwd: worktree,
1720
- timeoutMs: loadWatch?.limitMs ?? configured.timeoutMs,
1721
- processGroup: true,
1722
- owner: runOwnerTag(store, runId),
1723
- beforeSpawn: () => !stopRequestedFor(store, runId, request.shouldStop),
1724
- onSpawn: pid => {
1725
- request.onProviderSpawn?.(pid);
1726
- if (stopRequestedFor(store, runId, request.shouldStop))
1727
- throw new Error("the attempt was stopped before spawn custody completed");
1728
- },
1729
- envAllowlist: SETUP_ENV_ALLOWLIST,
1730
- omitEnv: SETUP_ENV_DENYLIST,
1731
- ...(checkAttempt === null ? {} : { stdin: checkAttempt.stdin }),
1732
- onStdout: chunk => { streamed.stdout = true; checkProgress.feed(chunk, "stdout"); },
1733
- onStderr: chunk => { streamed.stderr = true; checkProgress.feed(chunk, "stderr"); },
1734
- }).finally(() => loadWatch?.attemptEnded());
1735
- });
1736
- if (missing !== null)
1737
- unstartedChecks.set(result, missing);
1738
- if (!streamed.stdout)
1739
- checkProgress.feed(result.stdout, "stdout");
1740
- if (!streamed.stderr)
1741
- checkProgress.feed(result.stderr, "stderr");
1742
- checkProgress.feed("\n", "stdout");
1743
- checkProgress.feed("\n", "stderr");
1744
- checkOutcomes.push(attemptOutcome(label, result));
1745
- noteCheckSuite(label, result);
1746
- checkLog.push(attemptLog(label, configured.command, result));
1747
- verification.last = result;
1748
- return result;
1697
+ if (deployCleanupProblem === null && existsSync(dir))
1698
+ deployCleanupProblem = `its copy of this computer's database is still at ${dir}`;
1699
+ if (deployCleanupProblem !== null)
1700
+ recordCheckNote(`The deploy check has no result: ${deployCleanupProblem}.`);
1749
1701
  };
1750
- const ownInstallIfChanged = async () => {
1751
- const depsRoot = sharedDepsRootOf(store);
1752
- if (depsRoot === null || repo === null)
1753
- return null;
1754
- const linked = linkedKey(worktree, depsRoot);
1755
- const live = linked === null ? null : store.liveWorktreeSetup(repo);
1756
- if (linked === null || live === null)
1757
- return null;
1758
- if (sharingFor({ repo, worktree, setup: live, root: depsRoot })?.key === linked && readyCopy(depsRoot, linked) !== null)
1759
- return null;
1760
- if (!store.proveRunnerCustodyForSpawn(runId, now()))
1761
- return "custody-lost";
1762
- detachShared(worktree, depsRoot);
1763
- const label = "Own install · approved project setup (package.json or lockfile changed)";
1764
- const setupShell = approvedCommandShell(live.command);
1765
- const installed = await underStopWatch(store, runId, () => runWithIsolatedDatabase(witnessedRunner(store, runId, now, commandRunner(store, runId, captured.effective.profile, request.setup ?? run)), setupShell.file, setupShell.args, {
1766
- cwd: worktree,
1767
- timeoutMs: live.timeoutMs,
1768
- processGroup: true,
1769
- owner: runOwnerTag(store, runId),
1770
- beforeSpawn: () => !stopRequestedFor(store, runId, request.shouldStop),
1771
- onSpawn: pid => {
1772
- request.onProviderSpawn?.(pid);
1773
- if (stopRequestedFor(store, runId, request.shouldStop))
1774
- throw new Error("the attempt was stopped before spawn custody completed");
1775
- },
1776
- envAllowlist: SETUP_ENV_ALLOWLIST,
1777
- omitEnv: SETUP_ENV_DENYLIST,
1778
- }));
1779
- checkOutcomes.push(attemptOutcome(label, installed));
1780
- noteCheckSuite(label, installed);
1781
- checkLog.push(attemptLog(label, live.command, installed));
1782
- if (installed.notFound || installed.timedOut || installed.code !== 0)
1783
- return "own-install-failed";
1784
- return await sealedTreeState(buildCheckoutGit(request.git ?? run, worktree)) === "clean" ? null : "setup-changed-files";
1785
- };
1786
- const ownInstall = baselineUnverifiable === null ? await ownInstallIfChanged() : null;
1787
- const missingProgram = configured.recoverySetupDigest === null ? null : approvedProgramMissing(configured.command, worktree, process.env["PATH"]);
1788
- const first = baselineUnverifiable === null && ownInstall === null ? await runVerification("Project check · attempt 1", missingProgram) : null;
1789
- if (first === null) {
1790
- verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: baselineUnverifiable !== null ? "baseline-unverifiable" : ownInstall ?? "own-install-failed" };
1791
- }
1792
- else if (first.notFound || first.timedOut) {
1793
- verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: first.timedOut ? "timed-out" : "spawn-failed" };
1794
- }
1795
- else if (first.stoppedByPlane === true) {
1796
- verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: "stopped-by-toolroll" };
1797
- }
1798
- else if (!launchFailedBeforeCheck(first, checkAttempt?.nonce ?? null, missingProgram)) {
1799
- verifyCommand = { configured: true, ran: true, exitCode: first.code };
1800
- }
1801
- else {
1802
- const recoveryDigest = configured.recoverySetupDigest;
1803
- const liveRecoverySetup = () => {
1804
- if (repo === null || recoveryDigest === null)
1805
- return null;
1806
- const liveVerify = store.liveVerifyCommand(configured.repo);
1807
- const liveSetup = store.liveWorktreeSetup(repo);
1808
- return liveVerify !== null &&
1809
- liveVerify.digest === configured.digest &&
1810
- liveVerify.recoverySetupDigest === recoveryDigest &&
1811
- liveSetup !== null &&
1812
- liveSetup.digest === recoveryDigest
1813
- ? liveSetup
1814
- : null;
1815
- };
1816
- const setup = liveRecoverySetup();
1817
- if (recoveryDigest === null) {
1818
- verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: "dependency-missing" };
1819
- }
1820
- else if (setup === null || setup.digest !== recoveryDigest) {
1821
- verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: "setup-stale" };
1822
- }
1823
- else if (!store.proveRunnerCustodyForSpawn(runId, now())) {
1824
- verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: "custody-lost" };
1702
+ try {
1703
+ const verifyRunner = request.verify ?? run;
1704
+ const verifyShell = approvedCommandShell(configured.command);
1705
+ let baselineUnverifiable = null;
1706
+ const deployCheck = repo !== null && chosenCheck?.level === "full" && purposeCheckMode(store.getScope(request.taskId)?.releaseCheck) === "deploy";
1707
+ if (deployCheck) {
1708
+ const access = checkLaunchOf(store, runId, captured.effective.profile).access;
1709
+ loadWatch = new CheckLoadWatch(configured.timeoutMs, request.machine === undefined ? {} : { sample: request.machine });
1710
+ try {
1711
+ const live = store.databaseFile();
1712
+ if (live === null)
1713
+ throw new Error("this plane's database has no file to copy");
1714
+ deployCopyDir = mkdtempSync(join(realpathSync(tmpdir()), "toolroll-deploy-check-"));
1715
+ chmodSync(deployCopyDir, 0o700);
1716
+ const copy = join(deployCopyDir, "orders.db");
1717
+ await (await import("./backup.js")).onlineCopy(live, copy);
1718
+ checkAttempt = prepareCheckAttempt(store, root, { runId, repo: repo, head: sealedHead, command: configured, access, authority: null, watch: [], release: true, limitMs: loadWatch.limitMs, deploy: { copy } }, now());
1719
+ if (checkAttempt === null)
1720
+ throw new Error("the release commit couldn't be read, so the deploy check couldn't be sealed");
1721
+ store.addRunNote(runId, "Toolroll", "The deploy check: build this commit, upgrade a copy of this computer's database with it and start it against that copy.", now());
1722
+ }
1723
+ catch (error) {
1724
+ checkAttempt = null;
1725
+ baselineUnverifiable = `The deploy check couldn't be prepared: ${error instanceof Error ? error.message : String(error)}.`;
1726
+ recordCheckNote(baselineUnverifiable);
1727
+ loadWatch.finish();
1728
+ loadWatch = null;
1729
+ }
1825
1730
  }
1826
- else {
1827
- const gitRunner = buildCheckoutGit(request.git ?? run, worktree);
1828
- const beforeSetup = await sealedTreeState(gitRunner);
1829
- if (beforeSetup === "head-moved") {
1830
- verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: "checkout-moved" };
1831
- recordCheckNote("Automatic recovery stopped before setup because HEAD no longer matched the built commit.");
1731
+ else if (repo !== null && chosenCheck?.level === "full" && (store.getScope(request.taskId)?.candidate ?? null) !== null) {
1732
+ const access = checkLaunchOf(store, runId, captured.effective.profile).access;
1733
+ const decision = planTargetedRecheck(store, root, { runId, taskId: request.taskId, repo, head: sealedHead, command: configured, access, now: now() });
1734
+ const release = decision.authority !== null || releaseCheckScope(store.getScope(request.taskId));
1735
+ loadWatch = new CheckLoadWatch(configured.timeoutMs, request.machine === undefined ? {} : { sample: request.machine });
1736
+ try {
1737
+ checkAttempt = prepareCheckAttempt(store, root, { runId, repo, head: sealedHead, command: configured, access, authority: decision.authority, limitMs: loadWatch?.limitMs,
1738
+ ...(decision.mode === "targeted" ? { plan: decision.plan, snapshot: decision.snapshot } : {}), watch: decision.watch, release,
1739
+ learn: learnRequestFor(store, repo, now(), runId).learn }, now());
1832
1740
  }
1833
- else if (beforeSetup === "unavailable") {
1834
- verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: "cleanliness-unavailable" };
1835
- recordCheckNote("Automatic recovery stopped before setup because checkout cleanliness could not be confirmed.");
1741
+ catch (error) {
1742
+ if (!(error instanceof CheckBaselineUnverifiable))
1743
+ throw error;
1744
+ checkAttempt = null;
1745
+ baselineUnverifiable = error.message;
1746
+ recordCheckNote(error.message);
1836
1747
  }
1837
- else if (beforeSetup === "changed") {
1838
- verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: "tracked-files-changed" };
1839
- recordCheckNote("Automatic recovery stopped before setup because tracked files no longer matched the built commit.");
1748
+ if (checkAttempt === null && loadWatch !== null) {
1749
+ loadWatch.finish();
1750
+ loadWatch = null;
1840
1751
  }
1841
- else {
1842
- const liveBeforeSetup = liveRecoverySetup();
1843
- if (liveBeforeSetup === null) {
1844
- verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: "setup-stale" };
1845
- recordCheckNote("Automatic recovery stopped before setup because its approval changed.");
1846
- }
1847
- else if (!store.proveRunnerCustodyForSpawn(runId, now())) {
1848
- verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: "custody-lost" };
1849
- recordCheckNote("Automatic recovery stopped before setup: this worker no longer owned the build.");
1850
- }
1851
- else {
1852
- const setupRunner = request.setup ?? run;
1853
- const setupShell = approvedCommandShell(liveBeforeSetup.command);
1854
- const restored = await underStopWatch(store, runId, () => runWithIsolatedDatabase(witnessedRunner(store, runId, now, commandRunner(store, runId, captured.effective.profile, setupRunner)), setupShell.file, setupShell.args, {
1752
+ if (loadWatch !== null && loadWatch.limitMs !== configured.timeoutMs)
1753
+ store.addRunNote(runId, "Toolroll", `The release check's time limit: ${loadWatch.why}.`, now());
1754
+ if (checkAttempt !== null && decision.mode === "targeted")
1755
+ store.addRunNote(runId, "Toolroll", `Re-running only what failed at run #${decision.plan.base}: ${decision.plan.units.length} unit files, ${decision.plan.groups.reduce((n, one) => n + one.groups.length, 0)} journey groups, ${decision.plan.versions.length} upgrade versions${decision.plan.parts.length > 0 ? `, and in full: ${decision.plan.parts.join(", ")}` : ""}.`, now());
1756
+ }
1757
+ else
1758
+ checkAttempt = null;
1759
+ const progressWrites = coalescedProgressWriter(snapshot => { store.saveCheckProgress(runId, snapshot, now()); });
1760
+ const checkProgress = new CheckProgressTracker(snapshot => progressWrites.push(snapshot));
1761
+ const runVerification = async (label, missing = null) => {
1762
+ const streamed = { stdout: false, stderr: false };
1763
+ if (missing === null)
1764
+ checkConditions.last = captureCheckConditions({ repo, head: sealedHead, command: configured, access: checkLaunchOf(store, runId, captured.effective.profile).access, envNames: SETUP_ENV_ALLOWLIST });
1765
+ const result = missing !== null
1766
+ ? { code: 127, stdout: "", stderr: `Toolroll did not start the check: ${missing} wasn't found.`, timedOut: false, notFound: false }
1767
+ : await underStopWatch(store, runId, () => {
1768
+ loadWatch?.attemptStarted();
1769
+ return runWithIsolatedDatabase(witnessedRunner(store, runId, now, commandRunner(store, runId, captured.effective.profile, verifyRunner)), verifyShell.file, verifyShell.args, {
1855
1770
  cwd: worktree,
1856
- timeoutMs: liveBeforeSetup.timeoutMs,
1771
+ timeoutMs: loadWatch?.limitMs ?? configured.timeoutMs,
1857
1772
  processGroup: true,
1858
1773
  owner: runOwnerTag(store, runId),
1859
1774
  beforeSpawn: () => !stopRequestedFor(store, runId, request.shouldStop),
@@ -1864,86 +1779,227 @@ async function settleProof(captured, statArtifactId, sealedHead) {
1864
1779
  },
1865
1780
  envAllowlist: SETUP_ENV_ALLOWLIST,
1866
1781
  omitEnv: SETUP_ENV_DENYLIST,
1867
- }));
1868
- checkOutcomes.push(attemptOutcome("Automatic recovery · approved project setup", restored));
1869
- noteCheckSuite("Automatic recovery · approved project setup", restored);
1870
- checkLog.push(attemptLog("Automatic recovery · approved project setup", liveBeforeSetup.command, restored));
1871
- if (restored.notFound || restored.timedOut || restored.code !== 0) {
1872
- verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: "setup-failed" };
1782
+ ...(checkAttempt === null ? {} : { stdin: checkAttempt.stdin }),
1783
+ onStdout: chunk => { streamed.stdout = true; checkProgress.feed(chunk, "stdout"); },
1784
+ onStderr: chunk => { streamed.stderr = true; checkProgress.feed(chunk, "stderr"); },
1785
+ }).finally(() => loadWatch?.attemptEnded());
1786
+ });
1787
+ if (missing !== null)
1788
+ unstartedChecks.set(result, missing);
1789
+ if (!streamed.stdout)
1790
+ checkProgress.feed(result.stdout, "stdout");
1791
+ if (!streamed.stderr)
1792
+ checkProgress.feed(result.stderr, "stderr");
1793
+ checkProgress.feed("\n", "stdout");
1794
+ checkProgress.feed("\n", "stderr");
1795
+ checkOutcomes.push(attemptOutcome(label, result));
1796
+ noteCheckSuite(label, result);
1797
+ checkLog.push(attemptLog(label, configured.command, result));
1798
+ verification.last = result;
1799
+ return result;
1800
+ };
1801
+ const ownInstallIfChanged = async () => {
1802
+ const depsRoot = sharedDepsRootOf(store);
1803
+ if (depsRoot === null || repo === null)
1804
+ return null;
1805
+ const linked = linkedKey(worktree, depsRoot);
1806
+ const live = linked === null ? null : store.liveWorktreeSetup(repo);
1807
+ if (linked === null || live === null)
1808
+ return null;
1809
+ if (sharingFor({ repo, worktree, setup: live, root: depsRoot })?.key === linked && readyCopy(depsRoot, linked) !== null)
1810
+ return null;
1811
+ if (!store.proveRunnerCustodyForSpawn(runId, now()))
1812
+ return "custody-lost";
1813
+ detachShared(worktree, depsRoot);
1814
+ const label = "Own install · approved project setup (package.json or lockfile changed)";
1815
+ const setupShell = approvedCommandShell(live.command);
1816
+ const installed = await underStopWatch(store, runId, () => runWithIsolatedDatabase(witnessedRunner(store, runId, now, commandRunner(store, runId, captured.effective.profile, request.setup ?? run)), setupShell.file, setupShell.args, {
1817
+ cwd: worktree,
1818
+ timeoutMs: live.timeoutMs,
1819
+ processGroup: true,
1820
+ owner: runOwnerTag(store, runId),
1821
+ beforeSpawn: () => !stopRequestedFor(store, runId, request.shouldStop),
1822
+ onSpawn: pid => {
1823
+ request.onProviderSpawn?.(pid);
1824
+ if (stopRequestedFor(store, runId, request.shouldStop))
1825
+ throw new Error("the attempt was stopped before spawn custody completed");
1826
+ },
1827
+ envAllowlist: SETUP_ENV_ALLOWLIST,
1828
+ omitEnv: SETUP_ENV_DENYLIST,
1829
+ }));
1830
+ checkOutcomes.push(attemptOutcome(label, installed));
1831
+ noteCheckSuite(label, installed);
1832
+ checkLog.push(attemptLog(label, live.command, installed));
1833
+ if (installed.notFound || installed.timedOut || installed.code !== 0)
1834
+ return "own-install-failed";
1835
+ return await sealedTreeState(buildCheckoutGit(request.git ?? run, worktree)) === "clean" ? null : "setup-changed-files";
1836
+ };
1837
+ const ownInstall = baselineUnverifiable === null ? await ownInstallIfChanged() : null;
1838
+ const missingProgram = configured.recoverySetupDigest === null ? null : approvedProgramMissing(configured.command, worktree, process.env["PATH"]);
1839
+ const first = baselineUnverifiable === null && ownInstall === null ? await runVerification("Project check · attempt 1", missingProgram) : null;
1840
+ if (first === null) {
1841
+ verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: baselineUnverifiable !== null ? "baseline-unverifiable" : ownInstall ?? "own-install-failed" };
1842
+ }
1843
+ else if (first.notFound || first.timedOut) {
1844
+ verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: first.timedOut ? "timed-out" : "spawn-failed" };
1845
+ }
1846
+ else if (first.stoppedByPlane === true) {
1847
+ verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: "stopped-by-toolroll" };
1848
+ }
1849
+ else if (!launchFailedBeforeCheck(first, checkAttempt?.nonce ?? null, missingProgram)) {
1850
+ verifyCommand = { configured: true, ran: true, exitCode: first.code };
1851
+ }
1852
+ else {
1853
+ const recoveryDigest = configured.recoverySetupDigest;
1854
+ const liveRecoverySetup = () => {
1855
+ if (repo === null || recoveryDigest === null)
1856
+ return null;
1857
+ const liveVerify = store.liveVerifyCommand(configured.repo);
1858
+ const liveSetup = store.liveWorktreeSetup(repo);
1859
+ return liveVerify !== null &&
1860
+ liveVerify.digest === configured.digest &&
1861
+ liveVerify.recoverySetupDigest === recoveryDigest &&
1862
+ liveSetup !== null &&
1863
+ liveSetup.digest === recoveryDigest
1864
+ ? liveSetup
1865
+ : null;
1866
+ };
1867
+ const setup = liveRecoverySetup();
1868
+ if (recoveryDigest === null) {
1869
+ verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: "dependency-missing" };
1870
+ }
1871
+ else if (setup === null || setup.digest !== recoveryDigest) {
1872
+ verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: "setup-stale" };
1873
+ }
1874
+ else if (!store.proveRunnerCustodyForSpawn(runId, now())) {
1875
+ verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: "custody-lost" };
1876
+ }
1877
+ else {
1878
+ const gitRunner = buildCheckoutGit(request.git ?? run, worktree);
1879
+ const beforeSetup = await sealedTreeState(gitRunner);
1880
+ if (beforeSetup === "head-moved") {
1881
+ verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: "checkout-moved" };
1882
+ recordCheckNote("Automatic recovery stopped before setup because HEAD no longer matched the built commit.");
1883
+ }
1884
+ else if (beforeSetup === "unavailable") {
1885
+ verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: "cleanliness-unavailable" };
1886
+ recordCheckNote("Automatic recovery stopped before setup because checkout cleanliness could not be confirmed.");
1887
+ }
1888
+ else if (beforeSetup === "changed") {
1889
+ verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: "tracked-files-changed" };
1890
+ recordCheckNote("Automatic recovery stopped before setup because tracked files no longer matched the built commit.");
1891
+ }
1892
+ else {
1893
+ const liveBeforeSetup = liveRecoverySetup();
1894
+ if (liveBeforeSetup === null) {
1895
+ verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: "setup-stale" };
1896
+ recordCheckNote("Automatic recovery stopped before setup because its approval changed.");
1897
+ }
1898
+ else if (!store.proveRunnerCustodyForSpawn(runId, now())) {
1899
+ verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: "custody-lost" };
1900
+ recordCheckNote("Automatic recovery stopped before setup: this worker no longer owned the build.");
1873
1901
  }
1874
1902
  else {
1875
- const afterSetup = await sealedTreeState(gitRunner);
1876
- if (afterSetup === "head-moved") {
1877
- verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: "checkout-moved" };
1878
- recordCheckNote("Automatic recovery stopped: setup moved HEAD away from the built commit.");
1879
- }
1880
- else if (afterSetup === "unavailable") {
1881
- verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: "cleanliness-unavailable" };
1882
- recordCheckNote("Automatic recovery stopped after setup because checkout cleanliness could not be confirmed.");
1883
- }
1884
- else if (afterSetup === "changed") {
1885
- verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: "setup-changed-files" };
1886
- recordCheckNote("Automatic recovery stopped: setup changed tracked files after the build.");
1887
- }
1888
- else if (!store.proveRunnerCustodyForSpawn(runId, now())) {
1889
- verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: "custody-lost" };
1890
- recordCheckNote("Automatic recovery stopped before retry: this worker no longer owned the build.");
1891
- }
1892
- else if (liveRecoverySetup() === null) {
1893
- verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: "setup-stale" };
1894
- recordCheckNote("Automatic recovery stopped before retry because its approval changed.");
1903
+ const setupRunner = request.setup ?? run;
1904
+ const setupShell = approvedCommandShell(liveBeforeSetup.command);
1905
+ const restored = await underStopWatch(store, runId, () => runWithIsolatedDatabase(witnessedRunner(store, runId, now, commandRunner(store, runId, captured.effective.profile, setupRunner)), setupShell.file, setupShell.args, {
1906
+ cwd: worktree,
1907
+ timeoutMs: liveBeforeSetup.timeoutMs,
1908
+ processGroup: true,
1909
+ owner: runOwnerTag(store, runId),
1910
+ beforeSpawn: () => !stopRequestedFor(store, runId, request.shouldStop),
1911
+ onSpawn: pid => {
1912
+ request.onProviderSpawn?.(pid);
1913
+ if (stopRequestedFor(store, runId, request.shouldStop))
1914
+ throw new Error("the attempt was stopped before spawn custody completed");
1915
+ },
1916
+ envAllowlist: SETUP_ENV_ALLOWLIST,
1917
+ omitEnv: SETUP_ENV_DENYLIST,
1918
+ }));
1919
+ checkOutcomes.push(attemptOutcome("Automatic recovery · approved project setup", restored));
1920
+ noteCheckSuite("Automatic recovery · approved project setup", restored);
1921
+ checkLog.push(attemptLog("Automatic recovery · approved project setup", liveBeforeSetup.command, restored));
1922
+ if (restored.notFound || restored.timedOut || restored.code !== 0) {
1923
+ verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: "setup-failed" };
1895
1924
  }
1896
1925
  else {
1897
- const retried = await runVerification("Project check · retry after setup");
1898
- if (retried.timedOut) {
1899
- verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: "retry-timed-out" };
1926
+ const afterSetup = await sealedTreeState(gitRunner);
1927
+ if (afterSetup === "head-moved") {
1928
+ verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: "checkout-moved" };
1929
+ recordCheckNote("Automatic recovery stopped: setup moved HEAD away from the built commit.");
1930
+ }
1931
+ else if (afterSetup === "unavailable") {
1932
+ verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: "cleanliness-unavailable" };
1933
+ recordCheckNote("Automatic recovery stopped after setup because checkout cleanliness could not be confirmed.");
1900
1934
  }
1901
- else if (retried.notFound) {
1902
- verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: "retry-spawn-failed" };
1935
+ else if (afterSetup === "changed") {
1936
+ verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: "setup-changed-files" };
1937
+ recordCheckNote("Automatic recovery stopped: setup changed tracked files after the build.");
1903
1938
  }
1904
- else if (verificationExecutableMissing(retried)) {
1905
- verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: "dependency-still-missing" };
1939
+ else if (!store.proveRunnerCustodyForSpawn(runId, now())) {
1940
+ verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: "custody-lost" };
1941
+ recordCheckNote("Automatic recovery stopped before retry: this worker no longer owned the build.");
1942
+ }
1943
+ else if (liveRecoverySetup() === null) {
1944
+ verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: "setup-stale" };
1945
+ recordCheckNote("Automatic recovery stopped before retry because its approval changed.");
1906
1946
  }
1907
1947
  else {
1908
- verifyCommand = { configured: true, ran: true, exitCode: retried.code, setupReplayed: true, firstAttempt: { class: "launch", program: missingProgram, exitCode: first.code } };
1948
+ const retried = await runVerification("Project check · retry after setup");
1949
+ if (retried.timedOut) {
1950
+ verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: "retry-timed-out" };
1951
+ }
1952
+ else if (retried.notFound) {
1953
+ verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: "retry-spawn-failed" };
1954
+ }
1955
+ else if (verificationExecutableMissing(retried)) {
1956
+ verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: "dependency-still-missing" };
1957
+ }
1958
+ else {
1959
+ verifyCommand = { configured: true, ran: true, exitCode: retried.code, setupReplayed: true, firstAttempt: { class: "launch", program: missingProgram, exitCode: first.code } };
1960
+ }
1909
1961
  }
1910
1962
  }
1911
1963
  }
1912
1964
  }
1913
1965
  }
1914
1966
  }
1915
- }
1916
- try {
1917
- checkProgress.finish();
1918
- }
1919
- catch { }
1920
- if (loadWatch !== null) {
1921
- const record = loadWatch.finish();
1967
+ removeDeployCopy();
1922
1968
  try {
1923
- sealJson(store, root, runId, "check-load.json", record, CHECK_LOAD_CAPTURE, now());
1969
+ checkProgress.finish();
1924
1970
  }
1925
- catch (error) {
1926
- store.addRunNote(runId, "Toolroll", `This check's load record wasn't kept (${redactSecretText(error instanceof Error ? error.message : String(error))}), so a timeout in it can't be called the machine's own.`, now());
1971
+ catch { }
1972
+ if (loadWatch !== null) {
1973
+ const record = loadWatch.finish();
1974
+ try {
1975
+ sealJson(store, root, runId, "check-load.json", record, CHECK_LOAD_CAPTURE, now());
1976
+ }
1977
+ catch (error) {
1978
+ store.addRunNote(runId, "Toolroll", `This check's load record wasn't kept (${redactSecretText(error instanceof Error ? error.message : String(error))}), so a timeout in it can't be called the machine's own.`, now());
1979
+ }
1980
+ }
1981
+ if (!progressWrites.flush())
1982
+ progressWrites.flush();
1983
+ const last = verification.last;
1984
+ let sealedReport = null;
1985
+ if (checkAttempt !== null && last !== null && !last.notFound) {
1986
+ sealedReport = settledReport = sealCheckOutcome(store, root, checkAttempt, { stdout: last.stdout, exitCode: last.timedOut ? null : last.code }, now());
1987
+ keepCheckTimeline(store, { runId, taskId: request.taskId, report: sealedReport, stdout: last.stdout, now: now() });
1988
+ }
1989
+ if (checkAttempt !== null) {
1990
+ const settled = settleCoverage(store, root, { runId, taskId: request.taskId, exitCode: last === null || last.notFound || last.timedOut ? null : last.code, now: now() }, run => { const gate = verificationEvidence(store, root, run); return gate.ok ? gate.digest : null; });
1991
+ const sha = (capture) => { const found = store.artifactsFor(runId).filter(a => a.kind === "structured-output" && a.capture === capture); return found.length === 1 ? found[0].sha256 : null; };
1992
+ const effective = effectiveCheckFacts(verifyCommand, { coverage: deployCleanupProblem !== null ? "no-result" : settled.coverage, check: { attempt: checkAttempt.mode === "deploy" ? "full" : checkAttempt.mode, report: sha(CHECK_REPORT_CAPTURE), inventory: sha(CHECK_INVENTORY_CAPTURE), retried: retriedInside(sealedReport) }, composed: settled.composed });
1993
+ verifyCommand = effective.result;
1994
+ releaseFacts = effective.facts;
1995
+ }
1996
+ else if (verifyCommand.configured && verifyCommand.ran && chosenCheck?.level === "full" && releaseCheckScope(store.getScope(request.taskId))) {
1997
+ verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: "no-result" };
1998
+ recordCheckNote("The release check ran without a sealed attempt (its commit couldn't be read before it ran), so it has no result that can count.");
1927
1999
  }
1928
2000
  }
1929
- if (!progressWrites.flush())
1930
- progressWrites.flush();
1931
- const last = verification.last;
1932
- let sealedReport = null;
1933
- if (checkAttempt !== null && last !== null && !last.notFound) {
1934
- sealedReport = settledReport = sealCheckOutcome(store, root, checkAttempt, { stdout: last.stdout, exitCode: last.timedOut ? null : last.code }, now());
1935
- keepCheckTimeline(store, { runId, taskId: request.taskId, report: sealedReport, stdout: last.stdout, now: now() });
1936
- }
1937
- if (checkAttempt !== null) {
1938
- const settled = settleCoverage(store, root, { runId, taskId: request.taskId, exitCode: last === null || last.notFound || last.timedOut ? null : last.code, now: now() }, run => { const gate = verificationEvidence(store, root, run); return gate.ok ? gate.digest : null; });
1939
- const sha = (capture) => { const found = store.artifactsFor(runId).filter(a => a.kind === "structured-output" && a.capture === capture); return found.length === 1 ? found[0].sha256 : null; };
1940
- const effective = effectiveCheckFacts(verifyCommand, { coverage: settled.coverage, check: { attempt: checkAttempt.mode, report: sha(CHECK_REPORT_CAPTURE), inventory: sha(CHECK_INVENTORY_CAPTURE), retried: retriedInside(sealedReport) }, composed: settled.composed });
1941
- verifyCommand = effective.result;
1942
- releaseFacts = effective.facts;
1943
- }
1944
- else if (verifyCommand.configured && verifyCommand.ran && chosenCheck?.level === "full" && releaseCheckScope(store.getScope(request.taskId))) {
1945
- verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: "no-result" };
1946
- recordCheckNote("The release check ran without a sealed attempt (its commit couldn't be read before it ran), so it has no result that can count.");
2001
+ finally {
2002
+ removeDeployCopy();
1947
2003
  }
1948
2004
  }
1949
2005
  if (configured !== null && checkLog.length > 0) {
@@ -1962,7 +2018,7 @@ async function settleProof(captured, statArtifactId, sealedHead) {
1962
2018
  }
1963
2019
  if (configured !== null && checkLog.length > 0)
1964
2020
  sealVerificationReceipt(store, root, runId, sealedHead, configured, verifyCommand, now(), undefined, releaseFacts ?? undefined);
1965
- const uncovered = releaseFacts !== null && releaseFacts.coverage !== "full" && releaseFacts.coverage !== "composed";
2021
+ const uncovered = releaseFacts !== null && !coveragePasses(releaseFacts.coverage);
1966
2022
  const checkStatus = verifyCommand.configured === false ? "not-run"
1967
2023
  : uncovered ? "failed"
1968
2024
  : verifyCommand.ran ? verifyCommand.exitCode === 0 ? "passed" : "failed"
@@ -2127,6 +2183,7 @@ async function resumeUnhandedWork(captured, sessionId) {
2127
2183
  omitEnv: AGENT_ENV_DENYLIST,
2128
2184
  network: launchNetworkOf(store, request.taskRef, effective.profile),
2129
2185
  writes: launchWritesOf(effective.profile), sandbox: launchSandboxOf(effective.profile),
2186
+ skills: captured.skills ?? null,
2130
2187
  ...(agent === undefined ? {} : { runner: agent }),
2131
2188
  ...(request.onProviderSpawn === undefined ? {} : { onSpawn: request.onProviderSpawn }),
2132
2189
  clock,
@@ -2373,6 +2430,7 @@ async function ingestPark(args) {
2373
2430
  : { timeoutMs: args.profile !== undefined ? args.profile.repairTimeoutSeconds * 1000 : REPAIR_TIMEOUT_MS }),
2374
2431
  omitEnv: AGENT_ENV_DENYLIST,
2375
2432
  ...(args.profile === undefined ? {} : { network: launchNetworkOf(store, request.taskRef, args.profile), writes: launchWritesOf(args.profile), sandbox: launchSandboxOf(args.profile) }),
2433
+ skills: resumableRepair ? (args.skills ?? null) : null,
2376
2434
  ...(agent === undefined ? {} : { runner: agent }),
2377
2435
  ...(request.onProviderSpawn === undefined ? {} : { onSpawn: request.onProviderSpawn }),
2378
2436
  clock,