toolroll 0.9.118 → 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 (63) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/README.md +14 -14
  3. package/dist/assignment.js +40 -29
  4. package/dist/browser/workspace.css +1 -1
  5. package/dist/browser/workspace.js +32 -31
  6. package/dist/builder.js +286 -236
  7. package/dist/central-recovery-stage.js +3 -3
  8. package/dist/check-failure.js +2 -2
  9. package/dist/check-levels.js +3 -0
  10. package/dist/check-report.js +58 -7
  11. package/dist/contracts/console-api.js +4 -1
  12. package/dist/contracts/engine-api.js +1 -0
  13. package/dist/contracts/release-check.js +7 -4
  14. package/dist/contracts/release-terms.js +11 -2
  15. package/dist/contracts/verification-receipt.js +1 -1
  16. package/dist/deploy-gate.js +7 -1
  17. package/dist/direct-chat.js +3 -3
  18. package/dist/easy-start.js +8 -6
  19. package/dist/engine-reads.js +72 -0
  20. package/dist/flexible-conversation-schema.js +24 -0
  21. package/dist/flexible-conversation.js +162 -0
  22. package/dist/flexible-custody.js +3 -0
  23. package/dist/flexible-import.js +51 -0
  24. package/dist/flexible-session.js +84 -11
  25. package/dist/install-mode.js +1 -1
  26. package/dist/local-landing.js +500 -0
  27. package/dist/local-owner.js +1 -0
  28. package/dist/operate.js +143 -22
  29. package/dist/passwordless.js +1 -1
  30. package/dist/project-delete.js +1 -0
  31. package/dist/rehearsal.js +27 -0
  32. package/dist/release-adapters.js +170 -2
  33. package/dist/release-approval.js +11 -8
  34. package/dist/release-card.js +7 -2
  35. package/dist/release-carry.js +1 -1
  36. package/dist/release-cli.js +115 -14
  37. package/dist/release-main-proof.js +49 -0
  38. package/dist/release-main.js +110 -0
  39. package/dist/release-recheck.js +10 -3
  40. package/dist/release.js +221 -33
  41. package/dist/reply-shape.js +6 -1
  42. package/dist/result-actions.js +7 -1
  43. package/dist/result-follow-ups.js +8 -4
  44. package/dist/serve.js +31 -14
  45. package/dist/server/direct-chat.js +88 -3
  46. package/dist/server/engine-api.js +43 -5
  47. package/dist/server/render-results.js +3 -1
  48. package/dist/server/render-tasks.js +10 -1
  49. package/dist/server/route-table.js +9 -0
  50. package/dist/server/settings.js +31 -7
  51. package/dist/server/task-views.js +15 -0
  52. package/dist/server/tasks.js +63 -3
  53. package/dist/settings-groups-ui.js +2 -2
  54. package/dist/store.js +29 -4
  55. package/dist/surface.js +9 -1
  56. package/dist/tui/darwin-arm64/toolroll-tui +0 -0
  57. package/dist/tui/darwin-x64/toolroll-tui +0 -0
  58. package/dist/tui/linux-arm64/toolroll-tui +0 -0
  59. package/dist/tui/linux-x64/toolroll-tui +0 -0
  60. package/dist/verification-evidence.js +17 -6
  61. package/dist/workspace-ui.js +1 -1
  62. package/package.json +2 -1
  63. package/scripts/release-proof.mjs +240 -0
package/dist/release.js CHANGED
@@ -4,6 +4,7 @@ import { dirname, join } from "node:path";
4
4
  import { personProof } from "./person-proof.js";
5
5
  import { RELEASE_CI_RUNNING_WORDS as CI_RUNNING_WORDS } from "./release-ci-hold.js";
6
6
  import { transientFailure } from "./release-net.js";
7
+ import { changelogHas, harnessChanges, mainJournalFile, mainResumeCommand, releaseBranchFor, sameRelease, VERSION_PATTERN } from "./release-main.js";
7
8
  export const REQUIRED_PR_CHECKS = [
8
9
  "node 24 · ubuntu-latest",
9
10
  "linux native containment · delegated cgroup v2",
@@ -159,8 +160,9 @@ export function tagChecksVerdict(runs) {
159
160
  return checksVerdict(runs.filter(run => names.includes(run.name) && run.app === "github-actions" && workflowIs(run.workflowPath, RELEASE_TAG_WORKFLOW)), RELEASE_TAG_CHECKS);
160
161
  }
161
162
  export async function runRelease(options, adapters) {
162
- const file = journalFile(options.stateDir, options.branch);
163
- const resume = resumeCommand(options.branch, options.checkout);
163
+ const fromMain = options.version !== undefined;
164
+ const file = fromMain ? mainJournalFile(options.stateDir, options.version) : journalFile(options.stateDir, options.branch);
165
+ const resume = fromMain ? mainResumeCommand(options.version, options.checkout) : resumeCommand(options.branch, options.checkout);
164
166
  const limits = { ...RELEASE_LIMITS, ...options.limits };
165
167
  const pollMs = options.pollMs ?? POLL_MS;
166
168
  const say = adapters.say;
@@ -231,6 +233,8 @@ export async function runRelease(options, adapters) {
231
233
  try {
232
234
  journal = readJournal(file);
233
235
  if (journal !== null && options.fresh === true && journal.step !== "done") {
236
+ if (journal.mode === "main" && (journal.intents.tag !== undefined || journal.tagged !== null))
237
+ throw new Stop("tagging", `The release of ${journal.candidate.sha.slice(0, 7)} already began tagging ${journal.tag}; finish it with \`${resume}\` instead of starting over.`);
234
238
  if (journal.intents.merge !== undefined)
235
239
  throw new Stop("merging", `The release of ${journal.candidate.sha.slice(0, 7)} already began merging; finish it with \`${resume}\` instead of starting over.`);
236
240
  await recoverDeploy();
@@ -250,8 +254,10 @@ export async function runRelease(options, adapters) {
250
254
  const finishingHomebrew = journal !== null && journal.step === "homebrew" && journal.published !== null && options.fresh !== true;
251
255
  if (!await adapters.github.authenticated())
252
256
  throw new Stop("github-auth", "GitHub CLI is not signed in: run `gh auth login`, then rerun.");
257
+ let provenNow = false;
253
258
  if (journal === null) {
254
- journal = await begin(options, adapters, adapters.now());
259
+ journal = fromMain ? await beginMain(options, adapters, adapters.now()) : await begin(options, adapters, adapters.now());
260
+ provenNow = fromMain;
255
261
  if (freshApproval || journal.candidate.sha === stoppedCheck) {
256
262
  const base = journal.task.id;
257
263
  const suffix = supersededTask === null ? null : supersededTask === base ? 1 : supersededTask.startsWith(`${base}-`) ? Number(supersededTask.slice(base.length + 1)) : null;
@@ -272,6 +278,11 @@ export async function runRelease(options, adapters) {
272
278
  else
273
279
  say(`Resuming the release of ${journal.tag} (${journal.candidate.sha.slice(0, 7)}) at ${journal.step}.`);
274
280
  const j = journal;
281
+ if ((j.mode === "main") !== fromMain)
282
+ throw new Stop("usage", j.mode === "main" ? `This journal is the release of ${j.packageVersion} from main: run \`${mainResumeCommand(j.packageVersion, j.checkout)}\`.` : `This journal is a branch release; run \`${resumeCommand(j.branch, j.checkout)}\`.`);
283
+ const isMain = j.mode === "main";
284
+ if (isMain && j.full !== true && options.full === true)
285
+ throw new Stop("usage", `The release of ${j.packageVersion} was filed with the deploy check; to run the full check instead, start it again with \`toolroll release ${j.packageVersion} --full --new\`.`);
275
286
  if (j.ciAhead === true && j.ciBeforeDeploy !== true)
276
287
  j.ciBeforeDeploy = true;
277
288
  if (j.checkout !== options.checkout)
@@ -487,8 +498,54 @@ export async function runRelease(options, adapters) {
487
498
  if (!answer.ok)
488
499
  throw new Stop("nightly-debt", `${answer.why} Nothing was ${phase === "deploy" ? "deployed" : phase === "merge" ? "merged" : "tagged or published"}; rerun the release once it passes.`);
489
500
  };
490
- const watch = async (action) => { if (rel !== undefined)
491
- await identity(action, true); };
501
+ const watch = async (action) => {
502
+ if (isMain) {
503
+ if (await adapters.repo.github() !== j.github)
504
+ throw new Stop("drift", `The release's repository is no longer ${j.github}.`);
505
+ return;
506
+ }
507
+ if (rel !== undefined)
508
+ await identity(action, true);
509
+ };
510
+ const mainProof = async (nothing) => {
511
+ try {
512
+ return await proveMain(nothing);
513
+ }
514
+ catch (error) {
515
+ if (j.task.scopeDigest !== null && rel?.proofFailed !== undefined) {
516
+ const why = error instanceof Error ? error.message : String(error);
517
+ await rel.proofFailed({ taskId: j.task.id, version: j.packageVersion, why: why.slice(0, 280) });
518
+ }
519
+ throw error;
520
+ }
521
+ };
522
+ const proveMain = async (nothing) => {
523
+ const main = adapters.github.main;
524
+ if (main === undefined)
525
+ throw new Stop("usage", "This build of Toolroll can't release from main.");
526
+ const short = j.candidate.sha.slice(0, 7);
527
+ const proven = await main.prove(j.github, j.candidate.sha);
528
+ if (!proven.ok)
529
+ throw new Stop("proof", mainProofWords(j.packageVersion, short, proven.why, nothing));
530
+ const drift = sameRelease({ sha: j.candidate.sha, tree: j.candidate.tree, pr: j.pr, head: j.main.head, branch: j.main.branch }, proven);
531
+ if (drift !== null)
532
+ throw new Stop("drift", `${drift}. ${nothing}; this release stays bound to what it was approved for. Start it again with \`toolroll release ${j.packageVersion} --new\`.`);
533
+ const placed = await main.firstParent(j.github, j.candidate.sha);
534
+ if (!placed.ok)
535
+ throw new Stop("drift", `${short} is no longer on main's history (${placed.why}): main was rewritten or the commit removed. ${nothing}.`);
536
+ const verdict = prChecksVerdict(await adapters.github.checks(j.github, j.main.head), j.main.head, REQUIRED_PR_CHECKS, { workflow: REQUIRED_PR_CHECKS_WORKFLOW });
537
+ if (verdict.state !== "passed")
538
+ throw new Stop("ci-failed", mainProofWords(j.packageVersion, short, `the checks on pull request #${j.pr}'s head ${j.main.head.slice(0, 7)} aren't all passing: ${(verdict.state === "failed" ? verdict.failed : verdict.waiting).join(", ")}`, nothing));
539
+ if (j.task.scopeDigest !== null)
540
+ await rel?.proved?.({ taskId: j.task.id, version: j.packageVersion, proof: { sha: j.candidate.sha, tree: j.candidate.tree, pr: j.pr, head: j.main.head, branch: j.main.branch } });
541
+ if (placed.after.join() !== j.main.after.join()) {
542
+ j.main = { ...j.main, after: placed.after };
543
+ save();
544
+ }
545
+ if (placed.after.length > 0)
546
+ say(` ${placed.after.length} later commit${placed.after.length === 1 ? "" : "s"} on main go${placed.after.length === 1 ? "es" : ""} in the next release`);
547
+ return placed.after;
548
+ };
492
549
  const updateFromMain = async () => {
493
550
  const update = adapters.github.updateBranch;
494
551
  if (update === undefined)
@@ -614,11 +671,22 @@ export async function runRelease(options, adapters) {
614
671
  if (!owner.ok)
615
672
  throw new Stop("approval", `Task ${j.task.id}: ${owner.why}. An active approver must approve the release scope.`);
616
673
  };
674
+ const checkFailed = (input) => isMain
675
+ ? `The ${j.full === true ? "full release check" : "deploy check"} of ${j.candidate.sha.slice(0, 7)} failed (run ${input.run}): ${input.why}. Nothing was deployed, tagged or published; Toolroll here is unchanged. Fix it on main, merge a release pull request for ${j.packageVersion} again, then run \`toolroll release ${j.packageVersion} --new\`.`
676
+ : checkFailedWords({ sha: j.candidate.sha, ...input, branch: j.branch, checkout: j.checkout, taskId: j.task.id });
617
677
  const fullCheck = (gate) => {
618
678
  if (gate.result?.level !== "full")
619
679
  throw new Stop("check-level", `A Full check is required for this release (run ${gate.result?.run ?? "unknown"}: ${gate.result?.level ?? "unknown"}). Quick and Off checks cannot release a build.`);
620
680
  if (gate.result.check !== "passed")
621
- throw new Stop("check-failed", checkFailedWords({ sha: j.candidate.sha, run: gate.result.run, class: null, why: `its check reads ${gate.result.check}`, branch: j.branch, checkout: j.checkout, taskId: j.task.id }));
681
+ throw new Stop("check-failed", checkFailed({ run: gate.result.run, class: null, why: `its check reads ${gate.result.check}` }));
682
+ if (isMain) {
683
+ const coverage = gate.result.coverage ?? null;
684
+ const wanted = j.full === true ? ["full"] : ["deploy", "full"];
685
+ if (coverage === null || !wanted.includes(coverage))
686
+ throw new Stop("check-level", `Run ${gate.result.run}'s check of ${j.candidate.sha.slice(0, 7)} covered ${coverage ?? "something this Toolroll doesn't name"}, not the ${j.full === true ? "full release check" : "deploy check"} this release was approved for. Update Toolroll here, then run \`toolroll release ${j.packageVersion} --new\`.`);
687
+ }
688
+ else if (gate.result.coverage === "deploy")
689
+ throw new Stop("check-level", `Run ${gate.result.run} ran only the deploy check, which releases from main alone may use.`);
622
690
  };
623
691
  const builtHead = () => j.check?.head ?? j.candidate.sha;
624
692
  const checked = async (gate, action = "dispatch") => {
@@ -637,7 +705,12 @@ export async function runRelease(options, adapters) {
637
705
  try {
638
706
  switch (j.step) {
639
707
  case "gate": {
640
- await pinned();
708
+ if (isMain) {
709
+ if (!provenNow)
710
+ await mainProof("Nothing was checked, deployed, tagged or published");
711
+ }
712
+ else
713
+ await pinned();
641
714
  if (rel !== undefined && j.freshTask !== true) {
642
715
  const base = gateTaskId(j.packageVersion, j.candidate.sha);
643
716
  for (let n = 1; n < 50; n++) {
@@ -652,19 +725,21 @@ export async function runRelease(options, adapters) {
652
725
  }
653
726
  }
654
727
  }
655
- try {
656
- await containsMain(adapters, j, "Nothing was filed or sent for approval");
657
- }
658
- catch (error) {
659
- if (!(error instanceof Stop) || error.reason !== "base-moved")
660
- throw error;
661
- const head = await updateFromMain();
662
- if (head === null)
663
- throw error;
664
- throw new Restart(head, true);
728
+ if (!isMain) {
729
+ try {
730
+ await containsMain(adapters, j, "Nothing was filed or sent for approval");
731
+ }
732
+ catch (error) {
733
+ if (!(error instanceof Stop) || error.reason !== "base-moved")
734
+ throw error;
735
+ const head = await updateFromMain();
736
+ if (head === null)
737
+ throw error;
738
+ throw new Restart(head, true);
739
+ }
740
+ if (j.intents.gate === undefined)
741
+ await mainProtection(adapters, j, false, "Nothing was filed or sent for approval");
665
742
  }
666
- if (j.intents.gate === undefined)
667
- await mainProtection(adapters, j, false, "Nothing was filed or sent for approval");
668
743
  const existing = await adapters.toolroll.gate(j.task.id);
669
744
  if (existing.exists && j.freshTask === true && j.intents.gate === undefined)
670
745
  throw new Stop("approval", `Task ${j.task.id} appeared before this release filed it; rerun with --new.`);
@@ -674,7 +749,7 @@ export async function runRelease(options, adapters) {
674
749
  j.task.scopeDigest = existing.scopeDigest;
675
750
  }
676
751
  else {
677
- const settled = await earlyChecks(adapters, j, (what, probe) => waitFor("gate", what, probe), { pendingIsEnough: true, seen: (runs, verdict) => noteCi(runs, verdict) });
752
+ const settled = isMain ? true : await earlyChecks(adapters, j, (what, probe) => waitFor("gate", what, probe), { pendingIsEnough: true, seen: (runs, verdict) => noteCi(runs, verdict) });
678
753
  if (!settled)
679
754
  await rel?.auto?.ciRunning?.(j.task.id, j.candidate.sha);
680
755
  j.ciAhead = !settled;
@@ -686,13 +761,21 @@ export async function runRelease(options, adapters) {
686
761
  }
687
762
  intend("gate");
688
763
  await adapters.repo.sync(j.branch);
689
- const filed = await adapters.toolroll.fileGate({
764
+ const filed = await adapters.toolroll.fileGate(isMain ? {
765
+ taskId: j.task.id, title: `Release ${j.packageVersion}`, checkout: j.checkout, candidate: j.candidate.sha,
766
+ goal: mainGoalWords(j),
767
+ acceptance: `The ${j.full === true ? "full release check" : "deploy check"} passes on the release commit|check`,
768
+ release: { version: j.packageVersion, pr: j.pr, branch: j.branch, noCarry: true, main: { full: j.full === true } },
769
+ } : {
690
770
  taskId: j.task.id, title: `Release ${j.packageVersion}`, checkout: j.checkout, candidate: j.candidate.sha,
691
771
  goal: `Verify ${j.packageName} ${j.packageVersion} (${j.branch} at ${j.candidate.sha}) passes the approved release check before it is deployed, merged, tagged and published.`,
692
772
  acceptance: "The approved release check passes on the candidate commit|check",
693
773
  ...(rel === undefined ? {} : { release: { version: j.packageVersion, pr: j.pr, branch: j.branch, noCarry: options.noCarry === true } }),
694
774
  });
695
775
  j.task.scopeDigest = filed.scopeDigest;
776
+ save();
777
+ if (isMain)
778
+ await rel?.proved?.({ taskId: j.task.id, version: j.packageVersion, proof: { sha: j.candidate.sha, tree: j.candidate.tree, pr: j.pr, head: j.main.head, branch: j.main.branch } });
696
779
  const seen = currentCi();
697
780
  if (seen !== null)
698
781
  await tell(ready => ready.ci({ taskId: j.task.id, ...seen }));
@@ -702,7 +785,7 @@ export async function runRelease(options, adapters) {
702
785
  }
703
786
  case "approval": {
704
787
  const auto = rel?.auto;
705
- if (auto !== undefined && j.freshTask !== true && j.auto?.state !== "refused" && j.task.scopeDigest !== null && await auto.setting(j.task.id)) {
788
+ if (!isMain && auto !== undefined && j.freshTask !== true && j.auto?.state !== "refused" && j.task.scopeDigest !== null && await auto.setting(j.task.id)) {
706
789
  await watch("dispatch");
707
790
  const gate = await adapters.toolroll.gate(j.task.id);
708
791
  if (gate.scopeDigest !== j.task.scopeDigest)
@@ -725,7 +808,7 @@ export async function runRelease(options, adapters) {
725
808
  await ciWhileRunning("Nothing was deployed or merged", true);
726
809
  await tell(ready => ready.asked(j.task.id));
727
810
  say(` The release scope needs your approval: \`toolroll task approve ${j.task.id} --digest ${j.task.scopeDigest}\`, or open the task in the console.`);
728
- say(` Or approve it from here: \`toolroll release approve ${releaseBranchArg(j.branch)}\`.`);
811
+ say(` Or approve it from here: \`toolroll release approve ${isMain ? j.packageVersion : releaseBranchArg(j.branch)}\`.`);
729
812
  if (j.ciAhead === true)
730
813
  say(` ${CI_RUNNING_WORDS}`);
731
814
  const approved = await waitFor("approval", `a person to approve task ${j.task.id}`, async () => {
@@ -770,10 +853,10 @@ export async function runRelease(options, adapters) {
770
853
  say(` run ${gate.result.run} failed: ${answer.why}. Toolroll confirmed it as its own infrastructure, so the check runs again on ${j.candidate.sha.slice(0, 7)} under the same approval`);
771
854
  return null;
772
855
  }
773
- throw new Stop("check-failed", checkFailedWords({ sha: j.candidate.sha, run: gate.result.run, class: answer.class, why: answer.why, branch: j.branch, checkout: j.checkout, taskId: j.task.id }));
856
+ throw new Stop("check-failed", checkFailed({ run: gate.result.run, class: answer.class, why: answer.why }));
774
857
  }
775
858
  if (gate.failed !== null)
776
- throw new Stop("check-failed", `The release build of ${j.task.id} failed: ${gate.failed}. Fix it and release the new commit with --new.`, true);
859
+ throw new Stop("check-failed", isMain ? checkFailed({ run: gate.result?.run ?? 0, class: null, why: `its build failed: ${gate.failed}` }) : `The release build of ${j.task.id} failed: ${gate.failed}. Fix it and release the new commit with --new.`, true);
777
860
  if (gate.result === null || gate.result.check === "running" || gate.result.check === "pending")
778
861
  return null;
779
862
  const head = gate.result.head;
@@ -786,7 +869,7 @@ export async function runRelease(options, adapters) {
786
869
  if (rel?.standing !== undefined) {
787
870
  const standing = await rel.standing(j.task.id, gate.result.run);
788
871
  if (!standing.ok)
789
- throw new Stop("check-failed", `Run ${gate.result.run} passed on ${j.candidate.sha.slice(0, 7)}, but ${standing.why}: approve this commit again with \`toolroll release ${j.branch} --repo ${j.checkout} --new\`, or fix the branch and release the new commit the same way.`);
872
+ throw new Stop("check-failed", isMain ? `Run ${gate.result.run} passed on ${j.candidate.sha.slice(0, 7)}, but ${standing.why}. Nothing was deployed, tagged or published: run \`toolroll release ${j.packageVersion} --new\` to check it again.` : `Run ${gate.result.run} passed on ${j.candidate.sha.slice(0, 7)}, but ${standing.why}: approve this commit again with \`toolroll release ${j.branch} --repo ${j.checkout} --new\`, or fix the branch and release the new commit the same way.`);
790
873
  if (standing.retried === null)
791
874
  say(` run ${gate.result.run} passed, but its report can't be read, so whether anything passed only on a retry is unknown`);
792
875
  else if (standing.retried.length > 0)
@@ -883,6 +966,8 @@ export async function runRelease(options, adapters) {
883
966
  }
884
967
  case "deploy": {
885
968
  const check = j.check;
969
+ if (isMain && j.intents.deploy !== undefined)
970
+ await mainProof("The interrupted deploy wasn't finished; nothing was tagged or published");
886
971
  await recoverDeploy();
887
972
  await checked(await adapters.toolroll.gate(j.task.id), "deploy");
888
973
  let runtime = await served(adapters, builtHead());
@@ -902,10 +987,16 @@ export async function runRelease(options, adapters) {
902
987
  }
903
988
  }
904
989
  if (runtime === null) {
905
- await personCiBeforeDeploy();
906
- await watch("deploy");
907
- await pinned();
908
- await autoCiHolds("the deploy");
990
+ if (isMain) {
991
+ await watch("deploy");
992
+ await mainProof("Nothing was deployed, tagged or published");
993
+ }
994
+ else {
995
+ await personCiBeforeDeploy();
996
+ await watch("deploy");
997
+ await pinned();
998
+ await autoCiHolds("the deploy");
999
+ }
909
1000
  await nightlyHolds("deploy");
910
1001
  let operation, secret = "";
911
1002
  if (rel !== undefined && j.authority && epoch !== null) {
@@ -960,7 +1051,12 @@ export async function runRelease(options, adapters) {
960
1051
  if (everywhere !== runtime)
961
1052
  throw new Stop("mixed-runtime", `After relinking, the console, worker and both CLI names don't all run ${runtime} at ${j.candidate.sha.slice(0, 7)}.`);
962
1053
  say(` toolroll and standing-orders run ${join(runtime, "bin.js")}`);
963
- advance("ci");
1054
+ if (isMain) {
1055
+ await tell(ready => ready.verified({ taskId: j.task.id, merge: j.candidate.sha }));
1056
+ advance("tag");
1057
+ }
1058
+ else
1059
+ advance("ci");
964
1060
  break;
965
1061
  }
966
1062
  case "ci": {
@@ -1059,7 +1155,10 @@ export async function runRelease(options, adapters) {
1059
1155
  if (at !== null && at !== merge.sha)
1060
1156
  throw new Stop("conflict", `${j.tag} already points at ${at.slice(0, 7)}, not the merge ${merge.sha.slice(0, 7)}.`);
1061
1157
  if (at === null) {
1062
- await autoCiHolds("the tag");
1158
+ if (isMain)
1159
+ await mainProof("It runs here; nothing was tagged or published");
1160
+ else
1161
+ await autoCiHolds("the tag");
1063
1162
  await nightlyHolds("tag");
1064
1163
  intend("tag");
1065
1164
  await adapters.github.createTag(j.github, j.tag, merge.sha);
@@ -1108,7 +1207,9 @@ export async function runRelease(options, adapters) {
1108
1207
  }
1109
1208
  }
1110
1209
  const left = homebrewLeft;
1111
- if (left === null)
1210
+ if (left === null && isMain)
1211
+ say(`Released ${j.tag} from main at ${j.candidate.sha.slice(0, 7)}: deployed here, tagged, published and ${j.homebrew?.state === "superseded" ? `left Homebrew as it is (${j.homebrew.why ?? "the tap names a newer version"})` : "on Homebrew"}.`);
1212
+ else if (left === null)
1112
1213
  say(`Released ${j.tag}: deployed, merged as ${j.merge.sha.slice(0, 7)}, tagged, published and ${j.homebrew?.state === "superseded" ? `left Homebrew as it is (${j.homebrew.why ?? "the tap names a newer version"})` : "on Homebrew"}.`);
1113
1214
  else
1114
1215
  say(`Published ${j.tag} (deployed, merged as ${j.merge.sha.slice(0, 7)}, tagged, on npm and GitHub); Homebrew ${left.state}${left.why === null ? "" : `: ${left.why}`}. Finish it with \`${resume}\`.`);
@@ -1184,6 +1285,93 @@ async function begin(options, adapters, now) {
1184
1285
  merge: null, tagged: null, published: null, homebrew: null, intents: {}, stopped: null, createdAt: at, updatedAt: at,
1185
1286
  };
1186
1287
  }
1288
+ export function mainProofWords(version, short, why, nothing) {
1289
+ return `${version} can't be released from ${short}: ${why.replace(/\.$/, "")}. ${nothing}. Merge a release pull request for ${version} (\`toolroll release prepare ${version}\`), then run \`toolroll release ${version}\`.`;
1290
+ }
1291
+ export function mainGoalWords(j) {
1292
+ const check = j.full === true
1293
+ ? "runs the full release check on this Mac (about 40 minutes)"
1294
+ : "runs the deploy check on this Mac: it builds it, upgrades a copy of your database and starts it against that copy (about 4 minutes)";
1295
+ return `Release ${j.packageName} ${j.packageVersion} from main at ${j.candidate.sha} (pull request #${j.pr}). GitHub ran every required check on this tree on #${j.pr} (its head ${j.main?.head ?? "unknown"}). After your approval Toolroll ${check}, then deploys it here, tags ${j.tag} and publishes to npm and Homebrew. ${j.full === true ? "The check runs this commit's code with full access to this computer." : "The deploy check's own scripts run this commit's code with this project's check access (for Toolroll, full access to this computer); its build, the upgraded copy and the console run fenced: no network but their own loopback port, nothing written outside a throwaway folder."}`;
1296
+ }
1297
+ async function beginMain(options, adapters, now) {
1298
+ const version = options.version;
1299
+ const { checkout } = options;
1300
+ if (!VERSION_PATTERN.test(version))
1301
+ throw new Stop("usage", `${version} isn't a version: \`toolroll release <major.minor.patch>\`.`);
1302
+ const main = adapters.github.main;
1303
+ if (main === undefined)
1304
+ throw new Stop("usage", "This build of Toolroll can't release from main.");
1305
+ const installed = await adapters.toolroll.installed();
1306
+ const runtimes = new Set([...installed.services, ...installed.clis.map(one => one.runtime ?? "(not linked)")]);
1307
+ if (installed.services.length === 0 || runtimes.size !== 1) {
1308
+ throw new Stop("mixed-runtime", `The console, worker and CLI names don't run one build (${[...installed.services.map(one => `service ${one}`), ...installed.clis.map(one => `${one.name} ${one.runtime ?? "not linked"}`)].join("; ")}). Update them to one verified build first.`);
1309
+ }
1310
+ const github = await adapters.repo.github();
1311
+ const nothing = "Nothing was checked, deployed, tagged or published";
1312
+ const pull = await main.pull(github, version);
1313
+ if (pull.kind === "none")
1314
+ throw new Stop("no-release-commit", mainProofWords(version, "main", `no pull request from ${releaseBranchFor(version)} has merged into main`, nothing));
1315
+ if (pull.kind === "open")
1316
+ throw new Stop("not-merged", `Releases now go from main. Merge #${pull.pr} like any pull request once its checks pass, then run \`toolroll release ${version}\`.`);
1317
+ const short = pull.sha.slice(0, 7);
1318
+ const proven = await main.prove(github, pull.sha);
1319
+ if (!proven.ok)
1320
+ throw new Stop("proof", mainProofWords(version, short, proven.why, nothing));
1321
+ if (proven.sha !== pull.sha || proven.pr !== pull.pr)
1322
+ throw new Stop("proof", mainProofWords(version, short, `the proof names pull request #${proven.pr} at ${proven.sha.slice(0, 7)}`, nothing));
1323
+ if (proven.branch !== releaseBranchFor(version))
1324
+ throw new Stop("proof", mainProofWords(version, short, `pull request #${proven.pr} came from ${proven.branch}, not ${releaseBranchFor(version)} (where Node 22 runs)`, nothing));
1325
+ const placed = await main.firstParent(github, pull.sha);
1326
+ if (!placed.ok)
1327
+ throw new Stop("proof", mainProofWords(version, short, `it isn't on main's history (${placed.why})`, nothing));
1328
+ const verdict = prChecksVerdict(await adapters.github.checks(github, proven.head), proven.head, REQUIRED_PR_CHECKS, { workflow: REQUIRED_PR_CHECKS_WORKFLOW });
1329
+ if (verdict.state !== "passed")
1330
+ throw new Stop("ci-failed", mainProofWords(version, short, `the checks on pull request #${proven.pr}'s head ${proven.head.slice(0, 7)} aren't all passing: ${(verdict.state === "failed" ? verdict.failed : verdict.waiting).join(", ")}`, nothing));
1331
+ await adapters.repo.sync(releaseBranchFor(version));
1332
+ if (await adapters.repo.tree(pull.sha) !== proven.tree)
1333
+ throw new Stop("proof", mainProofWords(version, short, "this checkout's copy of it doesn't have the tree GitHub proved", nothing));
1334
+ const manifest = await adapters.repo.fileAt(pull.sha, "package.json");
1335
+ let pkg = null;
1336
+ try {
1337
+ pkg = manifest === null ? null : JSON.parse(manifest);
1338
+ }
1339
+ catch {
1340
+ pkg = null;
1341
+ }
1342
+ if (typeof pkg?.name !== "string" || pkg.version !== version)
1343
+ throw new Stop("version", mainProofWords(version, short, `its package.json names ${typeof pkg?.version === "string" ? pkg.version : "no version"}`, nothing));
1344
+ if (!changelogHas(await adapters.repo.fileAt(pull.sha, "CHANGELOG.md") ?? "", version))
1345
+ throw new Stop("changelog", mainProofWords(version, short, `its CHANGELOG.md has no "## ${version}" entry`, nothing));
1346
+ const tag = `v${version}`;
1347
+ if (await adapters.github.tag(github, tag) !== null)
1348
+ throw new Stop("version", `${tag} already exists. ${nothing}.`);
1349
+ if (await adapters.registry.published(pkg.name, version))
1350
+ throw new Stop("version", `${pkg.name}@${version} is already on npm. ${nothing}.`);
1351
+ const previous = previousVersion(version);
1352
+ const changed = previous === null || main.changedSince === undefined ? null : await main.changedSince(github, `v${previous}`, pull.sha);
1353
+ const harness = changed === null ? null : harnessChanges(changed.filter(path => path !== "package.json" && path !== "package-lock.json" && path !== "CHANGELOG.md"));
1354
+ const at = now.toISOString();
1355
+ adapters.say(`Releasing ${pkg.name} ${version} from main at ${short} (pull request #${proven.pr}).`);
1356
+ if (harness !== null && harness.length > 0 && options.full !== true) {
1357
+ adapters.say(` CI's own rules, the build or the test harness changed since ${previous} (${harness.slice(0, 5).join(", ")}${harness.length > 5 ? `, and ${harness.length - 5} more` : ""}). \`toolroll release ${version} --full --new\` runs the full check on this Mac first, about 40 minutes.`);
1358
+ }
1359
+ if (placed.after.length > 0)
1360
+ adapters.say(` ${placed.after.length} later commit${placed.after.length === 1 ? "" : "s"} on main go${placed.after.length === 1 ? "es" : ""} in the next release.`);
1361
+ return {
1362
+ version: 1, id: randomUUID(), github, checkout, branch: proven.branch, candidate: { sha: pull.sha, tree: proven.tree }, packageName: pkg.name, packageVersion: version, tag, pr: proven.pr,
1363
+ step: "gate", task: { id: gateTaskId(version, pull.sha), scopeDigest: null }, approval: null, check: null, completion: null, deploy: null, ci: null,
1364
+ merge: { sha: pull.sha, tree: proven.tree }, tagged: null, published: null, homebrew: null, intents: {}, stopped: null, createdAt: at, updatedAt: at,
1365
+ mode: "main", ...(options.full === true ? { full: true } : {}),
1366
+ main: { head: proven.head, branch: proven.branch, previousTag: previous === null ? null : `v${previous}`, harness, after: placed.after },
1367
+ };
1368
+ }
1369
+ export function previousVersion(version) {
1370
+ const match = /^(\d+)\.(\d+)\.(\d+)$/.exec(version);
1371
+ if (match === null || Number(match[3]) === 0)
1372
+ return null;
1373
+ return `${match[1]}.${match[2]}.${Number(match[3]) - 1}`;
1374
+ }
1187
1375
  function deployStop(reason, message, stop) {
1188
1376
  if (stop.gate === undefined)
1189
1377
  return new Stop(reason, message);
@@ -113,9 +113,14 @@ function limitBold(text, state) {
113
113
  .replace(/\*\*([^*\n]+?)\*\*/g, (_, inner) => anchor(inner))
114
114
  .replace(/(^|[^*\w])\*(?![\s*])([^*\n]*?[^\s*])\*(?![*\w])/g, "$1$2");
115
115
  }
116
+ function ownPageLinks(text, appOrigin) {
117
+ const origins = appOrigin === null || appOrigin === undefined ? [] : typeof appOrigin === "string" ? [appOrigin] : appOrigin;
118
+ const origin = origins.find((one) => typeof one === "string" && /^https?:\/\/[^\s/]+$/.test(one.replace(/\/$/, ""))) ?? null;
119
+ return text.replace(/\[([^\]\n]{1,120})\]\((\/direct-chats\/[a-f0-9]{32})\)/g, (_all, label, path) => origin === null ? label : `[${label}](${origin.replace(/\/$/, "")}${path})`);
120
+ }
116
121
  function holdAside(text, options) {
117
122
  const held = [];
118
- const body = text.replace(/\r\n?/g, "\n").replace(PROTECTED, (match) => {
123
+ const body = ownPageLinks(text, options.appOrigin).replace(/\r\n?/g, "\n").replace(PROTECTED, (match) => {
119
124
  if (match.startsWith("`")) {
120
125
  held.push(match);
121
126
  return HOLD(held.length - 1);
@@ -143,6 +143,11 @@ export function createResultRevision(store, evidenceRoot, input, now) {
143
143
  if (consumers.size > 0) {
144
144
  return fail(409, `some of these notes were already sealed into revision ${[...consumers].join(", ")}; the others are still waiting — reload the result to see the current batch`);
145
145
  }
146
+ if (input.approveNow !== undefined) {
147
+ const stale = input.currentResult === undefined ? "Reload the result before sending it back to build." : input.currentResult();
148
+ if (stale !== null)
149
+ return fail(409, stale);
150
+ }
146
151
  if (postedSource !== revisionSourceOf(sourceScope?.digest ?? null)) {
147
152
  return fail(409, "the task's terms changed since this page was shown — reload the result and read the current terms before creating a revision");
148
153
  }
@@ -214,7 +219,8 @@ export function createResultRevision(store, evidenceRoot, input, now) {
214
219
  store.raw().prepare("UPDATE task SET title = ? WHERE id = ?").run(title, result.id);
215
220
  recordRevisionOrigin(store, result.id, input.origin);
216
221
  }
217
- if (result.ok && coverage === null) {
222
+ const approvedNow = result.ok && coverage === null && input.approveNow !== undefined && input.approveNow(result.id);
223
+ if (result.ok && coverage === null && !approvedNow) {
218
224
  const ref = store.lookupRef(result.id);
219
225
  if (ref !== null)
220
226
  store.requestPlan(ref.id, now);
@@ -6,6 +6,7 @@ import { actualCheckAccess, checkoutLaunchOf, checkoutRunner, ranAtLine, widestR
6
6
  import { mkdtempSync, rmSync } from "node:fs";
7
7
  import { tmpdir } from "node:os";
8
8
  import { join } from "node:path";
9
+ import { verifyCommandAt } from "./store.js";
9
10
  import { refArchived } from "./task-archive.js";
10
11
  import { belongsToRelease } from "./release-authority.js";
11
12
  import { run as execRun } from "./exec.js";
@@ -13,7 +14,7 @@ import { hardenedGit } from "./teardown-git.js";
13
14
  import { approvedCommandShell, SETUP_ENV_ALLOWLIST, SETUP_ENV_DENYLIST } from "./builder.js";
14
15
  import { runWithIsolatedDatabase } from "./child-database.js";
15
16
  import { boundStreamHeadTail, readVerifiedArtifact, redactSecretLines, scanForSecrets, storeEvidence } from "./evidence.js";
16
- import { CHECK_LEVEL_WORDS, checkCommandFor, repoClause, repoOfRun, runCheckLevel } from "./check-levels.js";
17
+ import { CHECK_LEVEL_WORDS, checkCommandFor, quickVerifyKey, repoClause, repoOfRun, runCheckLevel } from "./check-levels.js";
17
18
  import { fileTaskProposal } from "./proposal.js";
18
19
  export const CHECKS_REQUESTED = "checks requested";
19
20
  export const CHECKS_STARTED = "checks started";
@@ -30,8 +31,8 @@ function ledgerFor(store, runId) {
30
31
  .map(row => ({ id: Number(row["id"]), actor: String(row["actor"]), at: String(row["at"]), outcome: String(row["outcome"]),
31
32
  detail: row["detail"] === null ? null : String(row["detail"]), action: String(row["action"]) }));
32
33
  }
33
- export function followUpChecksOf(store, runId, now = new Date(), root) {
34
- const rows = ledgerFor(store, runId);
34
+ export function followUpChecksOf(store, runId, now = new Date(), root, asOf) {
35
+ const rows = asOf === undefined ? ledgerFor(store, runId) : ledgerFor(store, runId).filter(row => Date.parse(row.at) <= asOf.getTime());
35
36
  const receipts = new Map();
36
37
  if (root !== undefined) {
37
38
  for (const artifact of store.artifactsFor(runId).filter(one => one.kind === "structured-output" && one.capture === FOLLOW_UP_RECEIPT)) {
@@ -61,7 +62,10 @@ export function followUpChecksOf(store, runId, now = new Date(), root) {
61
62
  if (repo === null)
62
63
  return false;
63
64
  try {
64
- return checkCommandFor(store, repo, level).command?.digest === digest;
65
+ if (asOf === undefined)
66
+ return checkCommandFor(store, repo, level).command?.digest === digest;
67
+ const then = (level === "quick" ? verifyCommandAt(store, quickVerifyKey(repo), asOf) : null) ?? verifyCommandAt(store, repo, asOf);
68
+ return then?.digest === digest;
65
69
  }
66
70
  catch {
67
71
  return false;
package/dist/serve.js CHANGED
@@ -64,6 +64,7 @@ import {} from "./tools-ui.js";
64
64
  import { WORK_INDEX_MAX_LIMIT, workCountsByProject, workIndexPage } from "./work-index.js";
65
65
  import { withWorkReads } from "./work-reads.js";
66
66
  import { createEngineHandlers } from "./server/engine-api.js";
67
+ import { enterRehearsal } from "./rehearsal.js";
67
68
  import { WORKSPACE_MOTION_SCRIPT } from "./workspace-motion.js";
68
69
  import { prepareWorkspaceRevision, WorkspaceValidatorCache } from "./workspace-revision.js";
69
70
  import { createHash, randomBytes } from "node:crypto";
@@ -146,6 +147,16 @@ import { loadConsoleUrl } from "./webhooks.js";
146
147
  import { reviewFactsOf } from "./workspace-ui.js";
147
148
  import { WorktreePool } from "./worktree.js";
148
149
  export function createDecisionServer(options) {
150
+ const leaveRehearsal = options.rehearsal === true ? enterRehearsal() : null;
151
+ try {
152
+ return buildDecisionServer(options, leaveRehearsal);
153
+ }
154
+ catch (error) {
155
+ leaveRehearsal?.();
156
+ throw error;
157
+ }
158
+ }
159
+ function buildDecisionServer(options, leaveRehearsal) {
149
160
  const identities = options.identities ?? syncProjectIdentities();
150
161
  const { projectFamilyPeek, familiesInView, familyTasksInView, revisionDestination, runIsLive, runIsTaskResult, revisionViewOf, taskViewData, routeViewOf, taskChatFocus, pullRequestTargetOf, failureOf, explainAttempt, taskScreen, armTaskResume, planViewOf, planContractViewOf, revisionDocOf, revisionLedgerOf, resultDetailOf } = createTaskViews({
151
162
  get store() { return store; },
@@ -566,8 +577,12 @@ export function createDecisionServer(options) {
566
577
  }
567
578
  });
568
579
  });
569
- server.once('listening', () => store.telemetry.start());
570
- server.once('close', () => store.telemetry.stop());
580
+ if (options.rehearsal !== true) {
581
+ server.once('listening', () => store.telemetry.start());
582
+ server.once('close', () => store.telemetry.stop());
583
+ }
584
+ if (leaveRehearsal !== null)
585
+ server.once('close', leaveRehearsal);
571
586
  const publicOrigin = (() => {
572
587
  if (options.publicUrl === undefined)
573
588
  return null;
@@ -598,7 +613,8 @@ export function createDecisionServer(options) {
598
613
  const flushBudget = () => { try {
599
614
  requestBudget.flush();
600
615
  }
601
- catch { } engineHandlers.upkeep(); };
616
+ catch { } if (options.rehearsal !== true)
617
+ engineHandlers.upkeep(); };
602
618
  const timer = setInterval(flushBudget, REQUEST_BUDGET_FLUSH_MS);
603
619
  timer.unref?.();
604
620
  server.on("close", () => { clearInterval(timer); flushBudget(); });
@@ -1708,19 +1724,20 @@ export function createDecisionServer(options) {
1708
1724
  }
1709
1725
  let leadMaintenance = null;
1710
1726
  let leadClosing = false;
1711
- server.once('listening', () => consoleFolders(options, identities, () => {
1712
- team.start();
1713
- personalQueue.start();
1714
- leadMaintenance = startMaintenance({ intervalMs: 5_000, shouldStop: () => leadClosing,
1715
- run: () => runLeadFollowPass({ store, repos: managedRepos, evidenceRoot, clock,
1716
- provider: () => { const enabled = chatEnablement(); return enabled.ok ? { config: enabled.config, key: enabled.key } : null; },
1717
- fetcher: chatFetcher, ...(options.subscriptionChatRunner ? { subscriptionRunner: options.subscriptionChatRunner } : {}) }),
1718
- onError: error => recordLeadFollowFailure(store, error, clock()),
1719
- });
1720
- }));
1727
+ if (options.rehearsal !== true)
1728
+ server.once('listening', () => consoleFolders(options, identities, () => {
1729
+ team.start();
1730
+ personalQueue.start();
1731
+ leadMaintenance = startMaintenance({ intervalMs: 5_000, shouldStop: () => leadClosing,
1732
+ run: () => runLeadFollowPass({ store, repos: managedRepos, evidenceRoot, clock,
1733
+ provider: () => { const enabled = chatEnablement(); return enabled.ok ? { config: enabled.config, key: enabled.key } : null; },
1734
+ fetcher: chatFetcher, ...(options.subscriptionChatRunner ? { subscriptionRunner: options.subscriptionChatRunner } : {}) }),
1735
+ onError: error => recordLeadFollowFailure(store, error, clock()),
1736
+ });
1737
+ }));
1721
1738
  let backgroundChecks = null;
1722
1739
  let agentsCheckedAt = 0;
1723
- if (options.backgroundChecks === true)
1740
+ if (options.backgroundChecks === true && options.rehearsal !== true)
1724
1741
  server.once('listening', () => {
1725
1742
  try {
1726
1743
  secretFolder();