toolroll 0.9.118 → 0.9.120
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/CHANGELOG.md +63 -0
- package/README.md +22 -22
- package/dist/assignment.js +43 -30
- package/dist/browser/workspace.css +1 -1
- package/dist/browser/workspace.js +32 -31
- package/dist/builder.js +288 -237
- package/dist/central-recovery-stage.js +3 -3
- package/dist/check-failure.js +2 -2
- package/dist/check-levels.js +3 -0
- package/dist/check-report.js +58 -7
- package/dist/cli-help.js +1 -0
- package/dist/codex-limits.js +40 -22
- package/dist/contracts/console-api.js +6 -1
- package/dist/contracts/engine-api.js +1 -0
- package/dist/contracts/release-check.js +7 -4
- package/dist/contracts/release-terms.js +11 -2
- package/dist/contracts/verification-receipt.js +1 -1
- package/dist/deploy-gate.js +7 -1
- package/dist/direct-chat.js +3 -3
- package/dist/easy-start.js +8 -6
- package/dist/engine-reads.js +74 -0
- package/dist/flexible-conversation-schema.js +24 -0
- package/dist/flexible-conversation.js +162 -0
- package/dist/flexible-custody.js +3 -0
- package/dist/flexible-import.js +89 -0
- package/dist/flexible-save.js +128 -0
- package/dist/flexible-session.js +93 -13
- package/dist/flexible-ship.js +3 -3
- package/dist/flexible-thread.js +2 -2
- package/dist/install-mode.js +1 -1
- package/dist/local-checks.js +32 -0
- package/dist/local-landing.js +758 -0
- package/dist/local-owner.js +3 -0
- package/dist/operate.js +165 -26
- package/dist/passwordless.js +1 -1
- package/dist/plan-limits-demand.js +48 -0
- package/dist/project-delete.js +1 -0
- package/dist/rehearsal.js +27 -0
- package/dist/release-adapters.js +170 -2
- package/dist/release-approval.js +11 -8
- package/dist/release-card.js +7 -2
- package/dist/release-carry.js +1 -1
- package/dist/release-cli.js +115 -14
- package/dist/release-main-proof.js +49 -0
- package/dist/release-main.js +110 -0
- package/dist/release-recheck.js +10 -3
- package/dist/release.js +221 -33
- package/dist/reply-shape.js +6 -1
- package/dist/result-actions.js +7 -1
- package/dist/result-follow-ups.js +30 -12
- package/dist/review-context.js +2 -1
- package/dist/serve.js +31 -14
- package/dist/server/direct-chat.js +109 -3
- package/dist/server/engine-api.js +65 -6
- package/dist/server/render-results.js +8 -4
- package/dist/server/render-tasks.js +10 -1
- package/dist/server/route-table.js +15 -1
- package/dist/server/send-back-build.js +4 -0
- package/dist/server/settings.js +33 -7
- package/dist/server/task-views.js +20 -0
- package/dist/server/tasks.js +108 -6
- package/dist/settings-groups-ui.js +3 -3
- package/dist/store.js +29 -4
- package/dist/subscription-usage.js +11 -5
- package/dist/surface.js +11 -2
- package/dist/task-base.js +23 -4
- package/dist/task-outcome-cli.js +10 -1
- package/dist/tui/darwin-arm64/toolroll-tui +0 -0
- package/dist/tui/darwin-x64/toolroll-tui +0 -0
- package/dist/tui/linux-arm64/toolroll-tui +0 -0
- package/dist/tui/linux-x64/toolroll-tui +0 -0
- package/dist/verification-evidence.js +20 -7
- package/dist/workspace-ui.js +1 -1
- package/package.json +2 -1
- package/scripts/release-proof.mjs +240 -0
package/dist/builder.js
CHANGED
|
@@ -4,6 +4,7 @@ import { agentSaidTail } from "./agent-said.js";
|
|
|
4
4
|
import { CHECK_ACCESS_DEFAULT, checkAccessHere, checkNetworkOf, localModeCap } from "./check-access.js";
|
|
5
5
|
import { localModeOn } from "./local-owner.js";
|
|
6
6
|
import { checkoutGit, refusal as gitRefusal } from "./teardown-git.js";
|
|
7
|
+
import { wholeChangeBaseOf } from "./task-base.js";
|
|
7
8
|
import { isAcpProvider } from "./acp-agents.js";
|
|
8
9
|
import { OBSERVATION_MAILBOX, observationBrief, parseObservationCases, collectObservations } from "./observations.js";
|
|
9
10
|
import { checkCommandFor, effectiveCheckLevel, recordRunCheckLevel } from "./check-levels.js";
|
|
@@ -16,14 +17,15 @@ import { CHECK_INVENTORY_CAPTURE, CHECK_REPORT_CAPTURE, CheckBaselineUnverifiabl
|
|
|
16
17
|
import { CHECK_LOAD_CAPTURE, CheckLoadWatch } from "./check-load.js";
|
|
17
18
|
import { NOTHING_STARTED_ACTION, retriedInside } from "./check-failure.js";
|
|
18
19
|
import { planTargetedRecheck, settleCoverage } from "./release-recheck.js";
|
|
19
|
-
import { effectiveCheckFacts } from "./verification-evidence.js";
|
|
20
|
+
import { coveragePasses, effectiveCheckFacts } from "./verification-evidence.js";
|
|
20
21
|
import { learningContext } from "./project-learning.js";
|
|
21
22
|
import { knowledgeContext } from "./project-knowledge.js";
|
|
22
23
|
import { flowGoalCuts } from "./flow-engine.js";
|
|
23
24
|
import { readCodingHandoff, verifyCodingHandoffBase } from "./coding-handoff.js";
|
|
24
25
|
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";
|
|
26
|
+
import { accessSync, chmodSync, constants as fsConstants, existsSync, mkdtempSync, realpathSync, rmSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
27
|
+
import { homedir, tmpdir } from "node:os";
|
|
28
|
+
import { purposeCheckMode } from "./contracts/release-terms.js";
|
|
27
29
|
import { delimiter, isAbsolute, join, resolve } from "node:path";
|
|
28
30
|
import { run, runClaudeStreamJsonl, runOwnerTag, streamsInput } from "./exec.js";
|
|
29
31
|
import { stopRequestedFor, stopWords, underStopWatch } from "./task-control.js";
|
|
@@ -1291,7 +1293,7 @@ export async function settleProviderOutcome(captured, result) {
|
|
|
1291
1293
|
.filter(line => line.trim() !== "" &&
|
|
1292
1294
|
!line.trimEnd().endsWith(LEASE_MARKER) &&
|
|
1293
1295
|
!(line.startsWith("?? ") && looksLikeProtocolFile(line.slice(3))));
|
|
1294
|
-
const pinnedBase = store
|
|
1296
|
+
const pinnedBase = wholeChangeBaseOf(store, taskRef, branch) ?? baseRevision;
|
|
1295
1297
|
if (handoff.status === "no-change") {
|
|
1296
1298
|
if (dirty.length > 0) {
|
|
1297
1299
|
return {
|
|
@@ -1630,6 +1632,8 @@ async function settleProof(captured, statArtifactId, sealedHead) {
|
|
|
1630
1632
|
const gateCommand = batched ? null : configured;
|
|
1631
1633
|
let verifyCommand;
|
|
1632
1634
|
let checkAttempt = null;
|
|
1635
|
+
let deployCopyDir = null;
|
|
1636
|
+
let deployCleanupProblem = null;
|
|
1633
1637
|
let loadWatch = null;
|
|
1634
1638
|
let releaseFacts = null;
|
|
1635
1639
|
const verification = { last: null };
|
|
@@ -1680,186 +1684,92 @@ async function settleProof(captured, statArtifactId, sealedHead) {
|
|
|
1680
1684
|
recordCheckNote("Verification did not start: this worker no longer owned the build.");
|
|
1681
1685
|
}
|
|
1682
1686
|
else {
|
|
1683
|
-
const
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
const decision = planTargetedRecheck(store, root, { runId, taskId: request.taskId, repo, head: sealedHead, command: configured, access, now: now() });
|
|
1689
|
-
const release = decision.authority !== null || releaseCheckScope(store.getScope(request.taskId));
|
|
1690
|
-
loadWatch = new CheckLoadWatch(configured.timeoutMs, request.machine === undefined ? {} : { sample: request.machine });
|
|
1687
|
+
const removeDeployCopy = () => {
|
|
1688
|
+
if (deployCopyDir === null)
|
|
1689
|
+
return;
|
|
1690
|
+
const dir = deployCopyDir;
|
|
1691
|
+
deployCopyDir = null;
|
|
1691
1692
|
try {
|
|
1692
|
-
|
|
1693
|
-
...(decision.mode === "targeted" ? { plan: decision.plan, snapshot: decision.snapshot } : {}), watch: decision.watch, release,
|
|
1694
|
-
learn: learnRequestFor(store, repo, now(), runId).learn }, now());
|
|
1693
|
+
rmSync(dir, { recursive: true, force: true });
|
|
1695
1694
|
}
|
|
1696
1695
|
catch (error) {
|
|
1697
|
-
|
|
1698
|
-
throw error;
|
|
1699
|
-
checkAttempt = null;
|
|
1700
|
-
baselineUnverifiable = error.message;
|
|
1701
|
-
recordCheckNote(error.message);
|
|
1702
|
-
}
|
|
1703
|
-
if (checkAttempt === null && loadWatch !== null) {
|
|
1704
|
-
loadWatch.finish();
|
|
1705
|
-
loadWatch = null;
|
|
1696
|
+
deployCleanupProblem = `its copy of this computer's database couldn't be deleted (${error instanceof Error ? error.message : String(error)})`;
|
|
1706
1697
|
}
|
|
1707
|
-
if (
|
|
1708
|
-
|
|
1709
|
-
if (
|
|
1710
|
-
|
|
1711
|
-
}
|
|
1712
|
-
else
|
|
1713
|
-
checkAttempt = null;
|
|
1714
|
-
const progressWrites = coalescedProgressWriter(snapshot => { store.saveCheckProgress(runId, snapshot, now()); });
|
|
1715
|
-
const checkProgress = new CheckProgressTracker(snapshot => progressWrites.push(snapshot));
|
|
1716
|
-
const runVerification = async (label, missing = null) => {
|
|
1717
|
-
const streamed = { stdout: false, stderr: false };
|
|
1718
|
-
if (missing === null)
|
|
1719
|
-
checkConditions.last = captureCheckConditions({ repo, head: sealedHead, command: configured, access: checkLaunchOf(store, runId, captured.effective.profile).access, envNames: SETUP_ENV_ALLOWLIST });
|
|
1720
|
-
const result = missing !== null
|
|
1721
|
-
? { code: 127, stdout: "", stderr: `Toolroll did not start the check: ${missing} wasn't found.`, timedOut: false, notFound: false }
|
|
1722
|
-
: await underStopWatch(store, runId, () => {
|
|
1723
|
-
loadWatch?.attemptStarted();
|
|
1724
|
-
return runWithIsolatedDatabase(witnessedRunner(store, runId, now, commandRunner(store, runId, captured.effective.profile, verifyRunner)), verifyShell.file, verifyShell.args, {
|
|
1725
|
-
cwd: worktree,
|
|
1726
|
-
timeoutMs: loadWatch?.limitMs ?? configured.timeoutMs,
|
|
1727
|
-
processGroup: true,
|
|
1728
|
-
owner: runOwnerTag(store, runId),
|
|
1729
|
-
beforeSpawn: () => !stopRequestedFor(store, runId, request.shouldStop),
|
|
1730
|
-
onSpawn: pid => {
|
|
1731
|
-
request.onProviderSpawn?.(pid);
|
|
1732
|
-
if (stopRequestedFor(store, runId, request.shouldStop))
|
|
1733
|
-
throw new Error("the attempt was stopped before spawn custody completed");
|
|
1734
|
-
},
|
|
1735
|
-
envAllowlist: SETUP_ENV_ALLOWLIST,
|
|
1736
|
-
omitEnv: SETUP_ENV_DENYLIST,
|
|
1737
|
-
...(checkAttempt === null ? {} : { stdin: checkAttempt.stdin }),
|
|
1738
|
-
onStdout: chunk => { streamed.stdout = true; checkProgress.feed(chunk, "stdout"); },
|
|
1739
|
-
onStderr: chunk => { streamed.stderr = true; checkProgress.feed(chunk, "stderr"); },
|
|
1740
|
-
}).finally(() => loadWatch?.attemptEnded());
|
|
1741
|
-
});
|
|
1742
|
-
if (missing !== null)
|
|
1743
|
-
unstartedChecks.set(result, missing);
|
|
1744
|
-
if (!streamed.stdout)
|
|
1745
|
-
checkProgress.feed(result.stdout, "stdout");
|
|
1746
|
-
if (!streamed.stderr)
|
|
1747
|
-
checkProgress.feed(result.stderr, "stderr");
|
|
1748
|
-
checkProgress.feed("\n", "stdout");
|
|
1749
|
-
checkProgress.feed("\n", "stderr");
|
|
1750
|
-
checkOutcomes.push(attemptOutcome(label, result));
|
|
1751
|
-
noteCheckSuite(label, result);
|
|
1752
|
-
checkLog.push(attemptLog(label, configured.command, result));
|
|
1753
|
-
verification.last = result;
|
|
1754
|
-
return result;
|
|
1698
|
+
if (deployCleanupProblem === null && existsSync(dir))
|
|
1699
|
+
deployCleanupProblem = `its copy of this computer's database is still at ${dir}`;
|
|
1700
|
+
if (deployCleanupProblem !== null)
|
|
1701
|
+
recordCheckNote(`The deploy check has no result: ${deployCleanupProblem}.`);
|
|
1755
1702
|
};
|
|
1756
|
-
|
|
1757
|
-
const
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
const
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
}));
|
|
1785
|
-
checkOutcomes.push(attemptOutcome(label, installed));
|
|
1786
|
-
noteCheckSuite(label, installed);
|
|
1787
|
-
checkLog.push(attemptLog(label, live.command, installed));
|
|
1788
|
-
if (installed.notFound || installed.timedOut || installed.code !== 0)
|
|
1789
|
-
return "own-install-failed";
|
|
1790
|
-
return await sealedTreeState(buildCheckoutGit(request.git ?? run, worktree)) === "clean" ? null : "setup-changed-files";
|
|
1791
|
-
};
|
|
1792
|
-
const ownInstall = baselineUnverifiable === null ? await ownInstallIfChanged() : null;
|
|
1793
|
-
const missingProgram = configured.recoverySetupDigest === null ? null : approvedProgramMissing(configured.command, worktree, process.env["PATH"]);
|
|
1794
|
-
const first = baselineUnverifiable === null && ownInstall === null ? await runVerification("Project check · attempt 1", missingProgram) : null;
|
|
1795
|
-
if (first === null) {
|
|
1796
|
-
verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: baselineUnverifiable !== null ? "baseline-unverifiable" : ownInstall ?? "own-install-failed" };
|
|
1797
|
-
}
|
|
1798
|
-
else if (first.notFound || first.timedOut) {
|
|
1799
|
-
verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: first.timedOut ? "timed-out" : "spawn-failed" };
|
|
1800
|
-
}
|
|
1801
|
-
else if (first.stoppedByPlane === true) {
|
|
1802
|
-
verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: "stopped-by-toolroll" };
|
|
1803
|
-
}
|
|
1804
|
-
else if (!launchFailedBeforeCheck(first, checkAttempt?.nonce ?? null, missingProgram)) {
|
|
1805
|
-
verifyCommand = { configured: true, ran: true, exitCode: first.code };
|
|
1806
|
-
}
|
|
1807
|
-
else {
|
|
1808
|
-
const recoveryDigest = configured.recoverySetupDigest;
|
|
1809
|
-
const liveRecoverySetup = () => {
|
|
1810
|
-
if (repo === null || recoveryDigest === null)
|
|
1811
|
-
return null;
|
|
1812
|
-
const liveVerify = store.liveVerifyCommand(configured.repo);
|
|
1813
|
-
const liveSetup = store.liveWorktreeSetup(repo);
|
|
1814
|
-
return liveVerify !== null &&
|
|
1815
|
-
liveVerify.digest === configured.digest &&
|
|
1816
|
-
liveVerify.recoverySetupDigest === recoveryDigest &&
|
|
1817
|
-
liveSetup !== null &&
|
|
1818
|
-
liveSetup.digest === recoveryDigest
|
|
1819
|
-
? liveSetup
|
|
1820
|
-
: null;
|
|
1821
|
-
};
|
|
1822
|
-
const setup = liveRecoverySetup();
|
|
1823
|
-
if (recoveryDigest === null) {
|
|
1824
|
-
verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: "dependency-missing" };
|
|
1825
|
-
}
|
|
1826
|
-
else if (setup === null || setup.digest !== recoveryDigest) {
|
|
1827
|
-
verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: "setup-stale" };
|
|
1828
|
-
}
|
|
1829
|
-
else if (!store.proveRunnerCustodyForSpawn(runId, now())) {
|
|
1830
|
-
verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: "custody-lost" };
|
|
1703
|
+
try {
|
|
1704
|
+
const verifyRunner = request.verify ?? run;
|
|
1705
|
+
const verifyShell = approvedCommandShell(configured.command);
|
|
1706
|
+
let baselineUnverifiable = null;
|
|
1707
|
+
const deployCheck = repo !== null && chosenCheck?.level === "full" && purposeCheckMode(store.getScope(request.taskId)?.releaseCheck) === "deploy";
|
|
1708
|
+
if (deployCheck) {
|
|
1709
|
+
const access = checkLaunchOf(store, runId, captured.effective.profile).access;
|
|
1710
|
+
loadWatch = new CheckLoadWatch(configured.timeoutMs, request.machine === undefined ? {} : { sample: request.machine });
|
|
1711
|
+
try {
|
|
1712
|
+
const live = store.databaseFile();
|
|
1713
|
+
if (live === null)
|
|
1714
|
+
throw new Error("this plane's database has no file to copy");
|
|
1715
|
+
deployCopyDir = mkdtempSync(join(realpathSync(tmpdir()), "toolroll-deploy-check-"));
|
|
1716
|
+
chmodSync(deployCopyDir, 0o700);
|
|
1717
|
+
const copy = join(deployCopyDir, "orders.db");
|
|
1718
|
+
await (await import("./backup.js")).onlineCopy(live, copy);
|
|
1719
|
+
checkAttempt = prepareCheckAttempt(store, root, { runId, repo: repo, head: sealedHead, command: configured, access, authority: null, watch: [], release: true, limitMs: loadWatch.limitMs, deploy: { copy } }, now());
|
|
1720
|
+
if (checkAttempt === null)
|
|
1721
|
+
throw new Error("the release commit couldn't be read, so the deploy check couldn't be sealed");
|
|
1722
|
+
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());
|
|
1723
|
+
}
|
|
1724
|
+
catch (error) {
|
|
1725
|
+
checkAttempt = null;
|
|
1726
|
+
baselineUnverifiable = `The deploy check couldn't be prepared: ${error instanceof Error ? error.message : String(error)}.`;
|
|
1727
|
+
recordCheckNote(baselineUnverifiable);
|
|
1728
|
+
loadWatch.finish();
|
|
1729
|
+
loadWatch = null;
|
|
1730
|
+
}
|
|
1831
1731
|
}
|
|
1832
|
-
else {
|
|
1833
|
-
const
|
|
1834
|
-
const
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1732
|
+
else if (repo !== null && chosenCheck?.level === "full" && (store.getScope(request.taskId)?.candidate ?? null) !== null) {
|
|
1733
|
+
const access = checkLaunchOf(store, runId, captured.effective.profile).access;
|
|
1734
|
+
const decision = planTargetedRecheck(store, root, { runId, taskId: request.taskId, repo, head: sealedHead, command: configured, access, now: now() });
|
|
1735
|
+
const release = decision.authority !== null || releaseCheckScope(store.getScope(request.taskId));
|
|
1736
|
+
loadWatch = new CheckLoadWatch(configured.timeoutMs, request.machine === undefined ? {} : { sample: request.machine });
|
|
1737
|
+
try {
|
|
1738
|
+
checkAttempt = prepareCheckAttempt(store, root, { runId, repo, head: sealedHead, command: configured, access, authority: decision.authority, limitMs: loadWatch?.limitMs,
|
|
1739
|
+
...(decision.mode === "targeted" ? { plan: decision.plan, snapshot: decision.snapshot } : {}), watch: decision.watch, release,
|
|
1740
|
+
learn: learnRequestFor(store, repo, now(), runId).learn }, now());
|
|
1838
1741
|
}
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1742
|
+
catch (error) {
|
|
1743
|
+
if (!(error instanceof CheckBaselineUnverifiable))
|
|
1744
|
+
throw error;
|
|
1745
|
+
checkAttempt = null;
|
|
1746
|
+
baselineUnverifiable = error.message;
|
|
1747
|
+
recordCheckNote(error.message);
|
|
1842
1748
|
}
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1749
|
+
if (checkAttempt === null && loadWatch !== null) {
|
|
1750
|
+
loadWatch.finish();
|
|
1751
|
+
loadWatch = null;
|
|
1846
1752
|
}
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1753
|
+
if (loadWatch !== null && loadWatch.limitMs !== configured.timeoutMs)
|
|
1754
|
+
store.addRunNote(runId, "Toolroll", `The release check's time limit: ${loadWatch.why}.`, now());
|
|
1755
|
+
if (checkAttempt !== null && decision.mode === "targeted")
|
|
1756
|
+
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());
|
|
1757
|
+
}
|
|
1758
|
+
else
|
|
1759
|
+
checkAttempt = null;
|
|
1760
|
+
const progressWrites = coalescedProgressWriter(snapshot => { store.saveCheckProgress(runId, snapshot, now()); });
|
|
1761
|
+
const checkProgress = new CheckProgressTracker(snapshot => progressWrites.push(snapshot));
|
|
1762
|
+
const runVerification = async (label, missing = null) => {
|
|
1763
|
+
const streamed = { stdout: false, stderr: false };
|
|
1764
|
+
if (missing === null)
|
|
1765
|
+
checkConditions.last = captureCheckConditions({ repo, head: sealedHead, command: configured, access: checkLaunchOf(store, runId, captured.effective.profile).access, envNames: SETUP_ENV_ALLOWLIST });
|
|
1766
|
+
const result = missing !== null
|
|
1767
|
+
? { code: 127, stdout: "", stderr: `Toolroll did not start the check: ${missing} wasn't found.`, timedOut: false, notFound: false }
|
|
1768
|
+
: await underStopWatch(store, runId, () => {
|
|
1769
|
+
loadWatch?.attemptStarted();
|
|
1770
|
+
return runWithIsolatedDatabase(witnessedRunner(store, runId, now, commandRunner(store, runId, captured.effective.profile, verifyRunner)), verifyShell.file, verifyShell.args, {
|
|
1861
1771
|
cwd: worktree,
|
|
1862
|
-
timeoutMs:
|
|
1772
|
+
timeoutMs: loadWatch?.limitMs ?? configured.timeoutMs,
|
|
1863
1773
|
processGroup: true,
|
|
1864
1774
|
owner: runOwnerTag(store, runId),
|
|
1865
1775
|
beforeSpawn: () => !stopRequestedFor(store, runId, request.shouldStop),
|
|
@@ -1870,86 +1780,227 @@ async function settleProof(captured, statArtifactId, sealedHead) {
|
|
|
1870
1780
|
},
|
|
1871
1781
|
envAllowlist: SETUP_ENV_ALLOWLIST,
|
|
1872
1782
|
omitEnv: SETUP_ENV_DENYLIST,
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1783
|
+
...(checkAttempt === null ? {} : { stdin: checkAttempt.stdin }),
|
|
1784
|
+
onStdout: chunk => { streamed.stdout = true; checkProgress.feed(chunk, "stdout"); },
|
|
1785
|
+
onStderr: chunk => { streamed.stderr = true; checkProgress.feed(chunk, "stderr"); },
|
|
1786
|
+
}).finally(() => loadWatch?.attemptEnded());
|
|
1787
|
+
});
|
|
1788
|
+
if (missing !== null)
|
|
1789
|
+
unstartedChecks.set(result, missing);
|
|
1790
|
+
if (!streamed.stdout)
|
|
1791
|
+
checkProgress.feed(result.stdout, "stdout");
|
|
1792
|
+
if (!streamed.stderr)
|
|
1793
|
+
checkProgress.feed(result.stderr, "stderr");
|
|
1794
|
+
checkProgress.feed("\n", "stdout");
|
|
1795
|
+
checkProgress.feed("\n", "stderr");
|
|
1796
|
+
checkOutcomes.push(attemptOutcome(label, result));
|
|
1797
|
+
noteCheckSuite(label, result);
|
|
1798
|
+
checkLog.push(attemptLog(label, configured.command, result));
|
|
1799
|
+
verification.last = result;
|
|
1800
|
+
return result;
|
|
1801
|
+
};
|
|
1802
|
+
const ownInstallIfChanged = async () => {
|
|
1803
|
+
const depsRoot = sharedDepsRootOf(store);
|
|
1804
|
+
if (depsRoot === null || repo === null)
|
|
1805
|
+
return null;
|
|
1806
|
+
const linked = linkedKey(worktree, depsRoot);
|
|
1807
|
+
const live = linked === null ? null : store.liveWorktreeSetup(repo);
|
|
1808
|
+
if (linked === null || live === null)
|
|
1809
|
+
return null;
|
|
1810
|
+
if (sharingFor({ repo, worktree, setup: live, root: depsRoot })?.key === linked && readyCopy(depsRoot, linked) !== null)
|
|
1811
|
+
return null;
|
|
1812
|
+
if (!store.proveRunnerCustodyForSpawn(runId, now()))
|
|
1813
|
+
return "custody-lost";
|
|
1814
|
+
detachShared(worktree, depsRoot);
|
|
1815
|
+
const label = "Own install · approved project setup (package.json or lockfile changed)";
|
|
1816
|
+
const setupShell = approvedCommandShell(live.command);
|
|
1817
|
+
const installed = await underStopWatch(store, runId, () => runWithIsolatedDatabase(witnessedRunner(store, runId, now, commandRunner(store, runId, captured.effective.profile, request.setup ?? run)), setupShell.file, setupShell.args, {
|
|
1818
|
+
cwd: worktree,
|
|
1819
|
+
timeoutMs: live.timeoutMs,
|
|
1820
|
+
processGroup: true,
|
|
1821
|
+
owner: runOwnerTag(store, runId),
|
|
1822
|
+
beforeSpawn: () => !stopRequestedFor(store, runId, request.shouldStop),
|
|
1823
|
+
onSpawn: pid => {
|
|
1824
|
+
request.onProviderSpawn?.(pid);
|
|
1825
|
+
if (stopRequestedFor(store, runId, request.shouldStop))
|
|
1826
|
+
throw new Error("the attempt was stopped before spawn custody completed");
|
|
1827
|
+
},
|
|
1828
|
+
envAllowlist: SETUP_ENV_ALLOWLIST,
|
|
1829
|
+
omitEnv: SETUP_ENV_DENYLIST,
|
|
1830
|
+
}));
|
|
1831
|
+
checkOutcomes.push(attemptOutcome(label, installed));
|
|
1832
|
+
noteCheckSuite(label, installed);
|
|
1833
|
+
checkLog.push(attemptLog(label, live.command, installed));
|
|
1834
|
+
if (installed.notFound || installed.timedOut || installed.code !== 0)
|
|
1835
|
+
return "own-install-failed";
|
|
1836
|
+
return await sealedTreeState(buildCheckoutGit(request.git ?? run, worktree)) === "clean" ? null : "setup-changed-files";
|
|
1837
|
+
};
|
|
1838
|
+
const ownInstall = baselineUnverifiable === null ? await ownInstallIfChanged() : null;
|
|
1839
|
+
const missingProgram = configured.recoverySetupDigest === null ? null : approvedProgramMissing(configured.command, worktree, process.env["PATH"]);
|
|
1840
|
+
const first = baselineUnverifiable === null && ownInstall === null ? await runVerification("Project check · attempt 1", missingProgram) : null;
|
|
1841
|
+
if (first === null) {
|
|
1842
|
+
verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: baselineUnverifiable !== null ? "baseline-unverifiable" : ownInstall ?? "own-install-failed" };
|
|
1843
|
+
}
|
|
1844
|
+
else if (first.notFound || first.timedOut) {
|
|
1845
|
+
verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: first.timedOut ? "timed-out" : "spawn-failed" };
|
|
1846
|
+
}
|
|
1847
|
+
else if (first.stoppedByPlane === true) {
|
|
1848
|
+
verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: "stopped-by-toolroll" };
|
|
1849
|
+
}
|
|
1850
|
+
else if (!launchFailedBeforeCheck(first, checkAttempt?.nonce ?? null, missingProgram)) {
|
|
1851
|
+
verifyCommand = { configured: true, ran: true, exitCode: first.code };
|
|
1852
|
+
}
|
|
1853
|
+
else {
|
|
1854
|
+
const recoveryDigest = configured.recoverySetupDigest;
|
|
1855
|
+
const liveRecoverySetup = () => {
|
|
1856
|
+
if (repo === null || recoveryDigest === null)
|
|
1857
|
+
return null;
|
|
1858
|
+
const liveVerify = store.liveVerifyCommand(configured.repo);
|
|
1859
|
+
const liveSetup = store.liveWorktreeSetup(repo);
|
|
1860
|
+
return liveVerify !== null &&
|
|
1861
|
+
liveVerify.digest === configured.digest &&
|
|
1862
|
+
liveVerify.recoverySetupDigest === recoveryDigest &&
|
|
1863
|
+
liveSetup !== null &&
|
|
1864
|
+
liveSetup.digest === recoveryDigest
|
|
1865
|
+
? liveSetup
|
|
1866
|
+
: null;
|
|
1867
|
+
};
|
|
1868
|
+
const setup = liveRecoverySetup();
|
|
1869
|
+
if (recoveryDigest === null) {
|
|
1870
|
+
verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: "dependency-missing" };
|
|
1871
|
+
}
|
|
1872
|
+
else if (setup === null || setup.digest !== recoveryDigest) {
|
|
1873
|
+
verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: "setup-stale" };
|
|
1874
|
+
}
|
|
1875
|
+
else if (!store.proveRunnerCustodyForSpawn(runId, now())) {
|
|
1876
|
+
verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: "custody-lost" };
|
|
1877
|
+
}
|
|
1878
|
+
else {
|
|
1879
|
+
const gitRunner = buildCheckoutGit(request.git ?? run, worktree);
|
|
1880
|
+
const beforeSetup = await sealedTreeState(gitRunner);
|
|
1881
|
+
if (beforeSetup === "head-moved") {
|
|
1882
|
+
verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: "checkout-moved" };
|
|
1883
|
+
recordCheckNote("Automatic recovery stopped before setup because HEAD no longer matched the built commit.");
|
|
1884
|
+
}
|
|
1885
|
+
else if (beforeSetup === "unavailable") {
|
|
1886
|
+
verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: "cleanliness-unavailable" };
|
|
1887
|
+
recordCheckNote("Automatic recovery stopped before setup because checkout cleanliness could not be confirmed.");
|
|
1888
|
+
}
|
|
1889
|
+
else if (beforeSetup === "changed") {
|
|
1890
|
+
verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: "tracked-files-changed" };
|
|
1891
|
+
recordCheckNote("Automatic recovery stopped before setup because tracked files no longer matched the built commit.");
|
|
1892
|
+
}
|
|
1893
|
+
else {
|
|
1894
|
+
const liveBeforeSetup = liveRecoverySetup();
|
|
1895
|
+
if (liveBeforeSetup === null) {
|
|
1896
|
+
verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: "setup-stale" };
|
|
1897
|
+
recordCheckNote("Automatic recovery stopped before setup because its approval changed.");
|
|
1898
|
+
}
|
|
1899
|
+
else if (!store.proveRunnerCustodyForSpawn(runId, now())) {
|
|
1900
|
+
verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: "custody-lost" };
|
|
1901
|
+
recordCheckNote("Automatic recovery stopped before setup: this worker no longer owned the build.");
|
|
1879
1902
|
}
|
|
1880
1903
|
else {
|
|
1881
|
-
const
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1904
|
+
const setupRunner = request.setup ?? run;
|
|
1905
|
+
const setupShell = approvedCommandShell(liveBeforeSetup.command);
|
|
1906
|
+
const restored = await underStopWatch(store, runId, () => runWithIsolatedDatabase(witnessedRunner(store, runId, now, commandRunner(store, runId, captured.effective.profile, setupRunner)), setupShell.file, setupShell.args, {
|
|
1907
|
+
cwd: worktree,
|
|
1908
|
+
timeoutMs: liveBeforeSetup.timeoutMs,
|
|
1909
|
+
processGroup: true,
|
|
1910
|
+
owner: runOwnerTag(store, runId),
|
|
1911
|
+
beforeSpawn: () => !stopRequestedFor(store, runId, request.shouldStop),
|
|
1912
|
+
onSpawn: pid => {
|
|
1913
|
+
request.onProviderSpawn?.(pid);
|
|
1914
|
+
if (stopRequestedFor(store, runId, request.shouldStop))
|
|
1915
|
+
throw new Error("the attempt was stopped before spawn custody completed");
|
|
1916
|
+
},
|
|
1917
|
+
envAllowlist: SETUP_ENV_ALLOWLIST,
|
|
1918
|
+
omitEnv: SETUP_ENV_DENYLIST,
|
|
1919
|
+
}));
|
|
1920
|
+
checkOutcomes.push(attemptOutcome("Automatic recovery · approved project setup", restored));
|
|
1921
|
+
noteCheckSuite("Automatic recovery · approved project setup", restored);
|
|
1922
|
+
checkLog.push(attemptLog("Automatic recovery · approved project setup", liveBeforeSetup.command, restored));
|
|
1923
|
+
if (restored.notFound || restored.timedOut || restored.code !== 0) {
|
|
1924
|
+
verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: "setup-failed" };
|
|
1901
1925
|
}
|
|
1902
1926
|
else {
|
|
1903
|
-
const
|
|
1904
|
-
if (
|
|
1905
|
-
verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: "
|
|
1927
|
+
const afterSetup = await sealedTreeState(gitRunner);
|
|
1928
|
+
if (afterSetup === "head-moved") {
|
|
1929
|
+
verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: "checkout-moved" };
|
|
1930
|
+
recordCheckNote("Automatic recovery stopped: setup moved HEAD away from the built commit.");
|
|
1931
|
+
}
|
|
1932
|
+
else if (afterSetup === "unavailable") {
|
|
1933
|
+
verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: "cleanliness-unavailable" };
|
|
1934
|
+
recordCheckNote("Automatic recovery stopped after setup because checkout cleanliness could not be confirmed.");
|
|
1906
1935
|
}
|
|
1907
|
-
else if (
|
|
1908
|
-
verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: "
|
|
1936
|
+
else if (afterSetup === "changed") {
|
|
1937
|
+
verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: "setup-changed-files" };
|
|
1938
|
+
recordCheckNote("Automatic recovery stopped: setup changed tracked files after the build.");
|
|
1909
1939
|
}
|
|
1910
|
-
else if (
|
|
1911
|
-
verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: "
|
|
1940
|
+
else if (!store.proveRunnerCustodyForSpawn(runId, now())) {
|
|
1941
|
+
verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: "custody-lost" };
|
|
1942
|
+
recordCheckNote("Automatic recovery stopped before retry: this worker no longer owned the build.");
|
|
1943
|
+
}
|
|
1944
|
+
else if (liveRecoverySetup() === null) {
|
|
1945
|
+
verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: "setup-stale" };
|
|
1946
|
+
recordCheckNote("Automatic recovery stopped before retry because its approval changed.");
|
|
1912
1947
|
}
|
|
1913
1948
|
else {
|
|
1914
|
-
|
|
1949
|
+
const retried = await runVerification("Project check · retry after setup");
|
|
1950
|
+
if (retried.timedOut) {
|
|
1951
|
+
verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: "retry-timed-out" };
|
|
1952
|
+
}
|
|
1953
|
+
else if (retried.notFound) {
|
|
1954
|
+
verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: "retry-spawn-failed" };
|
|
1955
|
+
}
|
|
1956
|
+
else if (verificationExecutableMissing(retried)) {
|
|
1957
|
+
verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: "dependency-still-missing" };
|
|
1958
|
+
}
|
|
1959
|
+
else {
|
|
1960
|
+
verifyCommand = { configured: true, ran: true, exitCode: retried.code, setupReplayed: true, firstAttempt: { class: "launch", program: missingProgram, exitCode: first.code } };
|
|
1961
|
+
}
|
|
1915
1962
|
}
|
|
1916
1963
|
}
|
|
1917
1964
|
}
|
|
1918
1965
|
}
|
|
1919
1966
|
}
|
|
1920
1967
|
}
|
|
1921
|
-
|
|
1922
|
-
try {
|
|
1923
|
-
checkProgress.finish();
|
|
1924
|
-
}
|
|
1925
|
-
catch { }
|
|
1926
|
-
if (loadWatch !== null) {
|
|
1927
|
-
const record = loadWatch.finish();
|
|
1968
|
+
removeDeployCopy();
|
|
1928
1969
|
try {
|
|
1929
|
-
|
|
1970
|
+
checkProgress.finish();
|
|
1930
1971
|
}
|
|
1931
|
-
catch
|
|
1932
|
-
|
|
1972
|
+
catch { }
|
|
1973
|
+
if (loadWatch !== null) {
|
|
1974
|
+
const record = loadWatch.finish();
|
|
1975
|
+
try {
|
|
1976
|
+
sealJson(store, root, runId, "check-load.json", record, CHECK_LOAD_CAPTURE, now());
|
|
1977
|
+
}
|
|
1978
|
+
catch (error) {
|
|
1979
|
+
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());
|
|
1980
|
+
}
|
|
1981
|
+
}
|
|
1982
|
+
if (!progressWrites.flush())
|
|
1983
|
+
progressWrites.flush();
|
|
1984
|
+
const last = verification.last;
|
|
1985
|
+
let sealedReport = null;
|
|
1986
|
+
if (checkAttempt !== null && last !== null && !last.notFound) {
|
|
1987
|
+
sealedReport = settledReport = sealCheckOutcome(store, root, checkAttempt, { stdout: last.stdout, exitCode: last.timedOut ? null : last.code }, now());
|
|
1988
|
+
keepCheckTimeline(store, { runId, taskId: request.taskId, report: sealedReport, stdout: last.stdout, now: now() });
|
|
1989
|
+
}
|
|
1990
|
+
if (checkAttempt !== null) {
|
|
1991
|
+
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; });
|
|
1992
|
+
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; };
|
|
1993
|
+
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 });
|
|
1994
|
+
verifyCommand = effective.result;
|
|
1995
|
+
releaseFacts = effective.facts;
|
|
1996
|
+
}
|
|
1997
|
+
else if (verifyCommand.configured && verifyCommand.ran && chosenCheck?.level === "full" && releaseCheckScope(store.getScope(request.taskId))) {
|
|
1998
|
+
verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: "no-result" };
|
|
1999
|
+
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.");
|
|
1933
2000
|
}
|
|
1934
2001
|
}
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
const last = verification.last;
|
|
1938
|
-
let sealedReport = null;
|
|
1939
|
-
if (checkAttempt !== null && last !== null && !last.notFound) {
|
|
1940
|
-
sealedReport = settledReport = sealCheckOutcome(store, root, checkAttempt, { stdout: last.stdout, exitCode: last.timedOut ? null : last.code }, now());
|
|
1941
|
-
keepCheckTimeline(store, { runId, taskId: request.taskId, report: sealedReport, stdout: last.stdout, now: now() });
|
|
1942
|
-
}
|
|
1943
|
-
if (checkAttempt !== null) {
|
|
1944
|
-
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; });
|
|
1945
|
-
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; };
|
|
1946
|
-
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 });
|
|
1947
|
-
verifyCommand = effective.result;
|
|
1948
|
-
releaseFacts = effective.facts;
|
|
1949
|
-
}
|
|
1950
|
-
else if (verifyCommand.configured && verifyCommand.ran && chosenCheck?.level === "full" && releaseCheckScope(store.getScope(request.taskId))) {
|
|
1951
|
-
verifyCommand = { configured: true, ran: false, attemptFailed: true, failure: "no-result" };
|
|
1952
|
-
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.");
|
|
2002
|
+
finally {
|
|
2003
|
+
removeDeployCopy();
|
|
1953
2004
|
}
|
|
1954
2005
|
}
|
|
1955
2006
|
if (configured !== null && checkLog.length > 0) {
|
|
@@ -1968,7 +2019,7 @@ async function settleProof(captured, statArtifactId, sealedHead) {
|
|
|
1968
2019
|
}
|
|
1969
2020
|
if (configured !== null && checkLog.length > 0)
|
|
1970
2021
|
sealVerificationReceipt(store, root, runId, sealedHead, configured, verifyCommand, now(), undefined, releaseFacts ?? undefined);
|
|
1971
|
-
const uncovered = releaseFacts !== null && releaseFacts.coverage
|
|
2022
|
+
const uncovered = releaseFacts !== null && !coveragePasses(releaseFacts.coverage);
|
|
1972
2023
|
const checkStatus = verifyCommand.configured === false ? "not-run"
|
|
1973
2024
|
: uncovered ? "failed"
|
|
1974
2025
|
: verifyCommand.ran ? verifyCommand.exitCode === 0 ? "passed" : "failed"
|