@feigi/fleet-ctl 3.158.3 → 3.158.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/scripts/ledger.mjs +46 -26
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@feigi/fleet-ctl",
3
- "version": "3.158.3",
3
+ "version": "3.158.5",
4
4
  "description": "Agent fleet: run-team controller, merge bot, PR reviewer, and the ticket pipeline they share",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -2777,13 +2777,19 @@ function recordFiled(id, subject) {
2777
2777
  // impl-N=blocked nothing to check: report-schema.mjs already
2778
2778
  // refuses a block that names a bailCause, a pr or
2779
2779
  // a head, or gives no reason in bailDetail
2780
- // fix-pr-M=applied:<head> origin's refs/heads/<branch> is <head>, fetched
2781
- // by verify-sha.sh; the Check-step record (below)
2782
- // holds for <head>
2783
- // fix-pr-M=no-op origin's refs/heads/<branch> is PR M's fleet
2784
- // head, as the tick folds it: the head of the
2785
- // applied:<head> the fix-applier with the
2786
- // greatest retry suffix landed since PR M's
2780
+ // fix-pr-M=applied:<head> the report's branch is PR M's head branch, as
2781
+ // GitHub names it (PR M need not read OPEN, and
2782
+ // its head SHA is not compared: a rebase moves
2783
+ // it); then, only once that and every other check
2784
+ // passed: origin's refs/heads/<branch> is <head>,
2785
+ // fetched by verify-sha.sh; the Check-step record
2786
+ // (below) holds for <head>
2787
+ // fix-pr-M=no-op the report's branch is PR M's head branch, as
2788
+ // above; then, only once that and every other
2789
+ // check passed: origin's refs/heads/<branch> is
2790
+ // PR M's fleet head, as the tick folds it: the
2791
+ // head of the applied:<head> the fix-applier with
2792
+ // the greatest retry suffix landed since PR M's
2787
2793
  // latest reviewed=, else the head that reviewed=
2788
2794
  // names
2789
2795
  // finisher-pr-M=labelled PR M's labels carry ready-to-merge, and so does
@@ -2987,18 +2993,22 @@ async function runSettleFromReport() {
2987
2993
  check(`bailCause: ${report.bailCause}`, report.bailCause !== null);
2988
2994
  }
2989
2995
  } else if (live.family === "fix-pr") {
2990
- if (report.outcome === "applied") {
2991
- outcome = `applied:${report.head}`;
2992
- const head = remoteHead(report.branch);
2993
- check(`origin refs/heads/${report.branch} is ${report.head}`, head === report.head);
2994
- if (head === report.head) {
2995
- // verify-sha.sh is the fetch that puts the head's commit object here,
2996
- // which the tree read needs; its exit 2 is a fetch that failed or an
2997
- // object that is not there, so it could not look.
2998
- recipeGate(report.head, () => verifyShaOf(report.branch, report.head));
2999
- }
3000
- } else if (report.outcome === "no-op") {
3001
- outcome = "no-op";
2996
+ // `applied` and `no-op` claim the state of a pushed branch; `failed`
2997
+ // claims none and is settled unchecked.
2998
+ const claimsBranch = report.outcome === "applied" || report.outcome === "no-op";
2999
+ if (claimsBranch) {
3000
+ // The branch the report names must be the one PR M is headed on, so the
3001
+ // head read from origin below is the PR's own. GitHub is asked first and
3002
+ // nothing is read from git: a report naming another branch is refused
3003
+ // whatever origin holds. A replacement fix-pr-M-x checks against the same
3004
+ // PR M, and PR M need not read OPEN: only its head branch is asked.
3005
+ const { headRefName } = prView(live.number, "headRefName");
3006
+ check(`the report's branch is PR #${live.number}'s head branch (report: ${report.branch}, GitHub: ${headRefName})`, report.branch === headRefName);
3007
+ }
3008
+ outcome = report.outcome === "applied" ? `applied:${report.head}` : report.outcome;
3009
+ // The head origin must hold for a `no-op`, with the reason it is that one.
3010
+ let required = null;
3011
+ if (report.outcome === "no-op") {
3002
3012
  let fold;
3003
3013
  try {
3004
3014
  fold = deriveRun({ rows: data.rows, dispatched: data.dispatched, drain: data.drain }, []);
@@ -3014,16 +3024,11 @@ async function runSettleFromReport() {
3014
3024
  if (review === undefined) {
3015
3025
  check(`PR #${live.number}'s row names a reviewed= head`, false);
3016
3026
  } else {
3017
- const head = remoteHead(report.branch);
3018
- const required = review.fleetHead;
3019
- const why = required === review.head
3027
+ const why = review.fleetHead === review.head
3020
3028
  ? `the head PR #${live.number}'s latest reviewed= names`
3021
3029
  : `the head PR #${live.number}'s latest applied: names, landed since its latest reviewed= ${review.head}`;
3022
- check(`origin refs/heads/${report.branch} is ${required}, ${why}`,
3023
- head !== null && head.toLowerCase().startsWith(required));
3030
+ required = { head: review.fleetHead, why };
3024
3031
  }
3025
- } else {
3026
- outcome = "failed";
3027
3032
  }
3028
3033
  const refuted = report.deferred.filter((d) => d.bucket === "refuted");
3029
3034
  if (refuted.length > 0) {
@@ -3043,6 +3048,21 @@ async function runSettleFromReport() {
3043
3048
  }
3044
3049
  }
3045
3050
  }
3051
+ // git is read last, and only once every check above has passed.
3052
+ if (claimsBranch && checks.every((c) => c.ok)) {
3053
+ const head = remoteHead(report.branch);
3054
+ if (report.outcome === "applied") {
3055
+ if (check(`origin refs/heads/${report.branch} is ${report.head}`, head === report.head)) {
3056
+ // verify-sha.sh is the fetch that puts the head's commit object here,
3057
+ // which the tree read needs; its exit 2 is a fetch that failed or an
3058
+ // object that is not there, so it could not look.
3059
+ recipeGate(report.head, () => verifyShaOf(report.branch, report.head));
3060
+ }
3061
+ } else {
3062
+ check(`origin refs/heads/${report.branch} is ${required.head}, ${required.why}`,
3063
+ head !== null && head.toLowerCase().startsWith(required.head));
3064
+ }
3065
+ }
3046
3066
  } else if (live.family === "finisher-pr") {
3047
3067
  if (report.outcome === "labelled") {
3048
3068
  outcome = "labelled";