@feigi/fleet-ctl 3.49.3 → 3.49.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.
@@ -256,7 +256,7 @@ For each labeled PR clearing the hold rule, lowest first:
256
256
 
257
257
  **No rebase happened because the PR was already current? Pass the head twice.** That is the normal case in a pass, not an edge case, and `pre == post` selects a proof path built for it. Never invent a plausible-looking `pre` to make the arguments differ — a `pre` that never landed satisfies the pre-rebase leg by construction, and passing one is the single easiest way to turn a stale merge into `proved=true`.
258
258
 
259
- **Read `gates`, not the flat fields.** The payload's flat fields are observations, and one of them being true or false says nothing about the verdict on its own. `gates` is the verdict's own working: `proved` is true exactly when every value in it is true. Membership is per-invocation — on the rebase path it carries `preDidNotLand` (leg 1), on the no-rebase path it does not, because leg 1 is dropped there. That is why `preIsAncestor:true` sits next to `proved:true` on the no-rebase path and is **not** a contradiction: leg 1 wants it false, and leg 1 is not a gate on that path. A sanity check written against `preIsAncestor === false` rejects correct merges; write it against `gates` instead.
259
+ **Read `gates`, not the flat fields.** The payload's flat fields are observations, and one of them being true or false says nothing about the verdict on its own. `gates` is the verdict's own working: `proved` is true exactly when every value in it is true. Membership is per-invocation — on the rebase path it carries `preDidNotLand` (leg 1), on the merge-commit path it carries `preIsParentOfHead` (leg 1 replaced), and on the no-rebase path it carries neither because leg 1 is dropped. That is why `preIsAncestor:true` sits next to `proved:true` on the no-rebase path and is **not** a contradiction: leg 1 wants it false, and leg 1 is not a gate on that path. A sanity check written against `preIsAncestor === false` rejects correct merges; write it against `gates` instead.
260
260
 
261
261
  Exit **0** proved, **1** disproved, **2** the script could not evaluate the claim at all — the merge is unreachable from `origin/main`, is not a merge commit, or an argument does not resolve. Treat 2 as "ask a human", not as a disproof.
262
262
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@feigi/fleet-ctl",
3
- "version": "3.49.3",
3
+ "version": "3.49.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": {
@@ -1,12 +1,7 @@
1
1
  #!/bin/sh
2
2
  # Prove which head actually landed in a merge.
3
3
  #
4
- # Two proof paths, because a PR that is already current never gets rebased.
5
- #
6
- # rebase path (pre != post) — three legs, all required:
7
- # 1. the pre-rebase head is NOT an ancestor of main (the old version did not land)
8
- # 2. the rebased head IS an ancestor of main (the new version did)
9
- # 3. the merge commit's second parent IS the rebased head
4
+ # Three proof paths exist, distinguished by how the PR branch came to be current.
10
5
  #
11
6
  # no-rebase path (pre == post) — leg 1 is dropped, because legs 1 and 2 cannot
12
7
  # both hold here: a commit is its own ancestor, so leg 2 (post IS an ancestor)
@@ -14,23 +9,38 @@
14
9
  # prove. Note leg 1 alone is perfectly satisfiable when pre == post — it holds
15
10
  # whenever the merge has not landed. It is the *conjunction* that is impossible.
16
11
  #
17
- # Two gates carry the weight instead, and both are required on BOTH paths:
12
+ # rebase path (pre != post, and pre is not a parent of a two-parent post) — three legs, all required:
13
+ # 1. the pre-rebase head is NOT an ancestor of main (the old version did not land)
14
+ # 2. the rebased head IS an ancestor of main (the new version did)
15
+ # 3. the merge commit's second parent IS the rebased head
16
+ #
17
+ # merge-commit path (pre != post, post has exactly two parents, and pre is one of them) — one gate replaces leg 1:
18
+ # 1. pre IS a parent of post (the old version survives as an ancestor of the new)
19
+ # 2. the rebased head IS an ancestor of main (the new version did)
20
+ # 3. the merge commit's second parent IS the rebased head
21
+ #
22
+ # Four gates carry the weight on all three paths, and all are required on EACH:
18
23
  #
19
24
  # headWasCurrent — the merge's first parent IS an ancestor of the merged head,
20
25
  # which is what behind_by=0 means for a merge built on main.
21
- # merge ∈ base — <merge> is reachable from $base, so that first parent really
22
- # is a main tip and not something the caller made up.
26
+ # postIsAncestor — the rebased head IS an ancestor of main
27
+ # secondParentIsHead — the merge commit's second parent IS the rebased head
28
+ # exactlyTwoParents — the merge commit has exactly two parents (not an octopus)
29
+ #
30
+ # merge ∈ base — <merge> is reachable from $base (a precondition, not a gate:
31
+ # by the time any payload is emitted it has already been proven true)
23
32
  #
24
- # Both read structure off the merge object rather than off a ref, so the fetch
25
- # below cannot establish them the way it can establish legs 1 and 2.
33
+ # headWasCurrent, secondParentIsHead and exactlyTwoParents read structure off the
34
+ # merge object rather than off a ref, so the fetch below cannot establish them the
35
+ # way it can establish legs 1 and 2. postIsAncestor and merge ∈ base are read
36
+ # against $base, which is what the fetch refreshes.
26
37
  #
27
- # Leg 1 is not a substitute for headWasCurrent: it proves the pre-rebase version
28
- # did not land, not that the merged head was current, and it only bites a caller
29
- # who reports `pre` honestly. headWasCurrent is derived from history alone, which
30
- # is why it is required even on the rebase path — see run-merge-bot.md, "you are
31
- # the only place currency is proven". Both paths also require exactly two parents,
32
- # so an octopus merge cannot drag an unreviewed third parent along behind a second
33
- # parent that looks right.
38
+ # What stands in for leg 1 on each path:
39
+ # no-rebase path — leg 1 is dropped (impossible by construction)
40
+ # rebase path — preDidNotLand: the pre-rebase head is NOT an ancestor of main
41
+ # merge-commit path — preIsParentOfHead: the pre-rebase head IS a parent of post;
42
+ # the path selection already established that, so the gate
43
+ # records which path ran rather than testing anything new
34
44
  #
35
45
  # The payload splits the checks into three kinds, because a flat object could not
36
46
  # say which of its fields were load-bearing for the verdict it sits next to:
@@ -42,8 +52,9 @@
42
52
  # gates — the `gates` object. `proved` is true exactly when every value
43
53
  # in it is true, so a consumer asserts all-true rather than
44
54
  # inferring load-bearing-ness from `proofPath`. Membership is
45
- # per-invocation: `preDidNotLand` (leg 1) is present only on the
46
- # rebase path, because it is the leg the no-rebase path drops.
55
+ # per-invocation: the path-specific leg 1 gate is present only on
56
+ # the rebase and merge-commit paths, because the no-rebase path
57
+ # drops it. The four common gates are present on all three paths.
47
58
  # observations — the flat fields. They are the raw readings, and a true one can
48
59
  # sit next to `proved:true` without contradiction. The one that
49
60
  # prompted all this is `preIsAncestor` on the no-rebase path: it
@@ -170,19 +181,44 @@ echo " ${merge}^1 = $first (${parents} parents)" >&2
170
181
  echo " ${merge}^2 = $second" >&2
171
182
  echo " claimed head = $post_full" >&2
172
183
 
184
+ # To detect merge-commit path, we need to check if pre is a parent of post
185
+ # Extract post's parents
186
+ post_parent_line=$(git rev-list --parents -n 1 "$post_full" --) || die "cannot read the parents of $post_full"
187
+ # Word-splitting is the point: "<post> <parent>..." -> positional params.
188
+ # shellcheck disable=SC2086
189
+ set -- $post_parent_line
190
+ shift
191
+ post_parents=$#
192
+ post_first=""
193
+ post_second=""
194
+ if [ $post_parents -ge 1 ]; then
195
+ post_first=$1
196
+ fi
197
+ if [ $post_parents -ge 2 ]; then
198
+ post_second=$2
199
+ fi
200
+
173
201
  echo "\$ git merge-base --is-ancestor $first $post_full" >&2
174
202
  head_current=$(is_ancestor "$first" "$post_full")
175
203
 
176
204
  if [ "$pre_full" = "$post_full" ]; then
177
- proof_path=no-rebase
205
+ proof_path="no-rebase"
178
206
  teeth=true
179
207
  echo " no rebase (pre == post) — leg 1 dropped, headWasCurrent carries it" >&2
208
+ elif [ "$post_parents" -eq 2 ] && { [ "$post_first" = "$pre_full" ] || [ "$post_second" = "$pre_full" ]; }; then
209
+ proof_path="merge-commit"
210
+ if [ "$post_first" = "$pre_full" ]; then
211
+ echo " merge-commit (pre != post, pre is first parent of post) — pre is a parent of post" >&2
212
+ else
213
+ echo " merge-commit (pre != post, pre is second parent of post) — pre is a parent of post" >&2
214
+ fi
215
+ teeth=true
180
216
  else
181
- proof_path=rebase
217
+ proof_path="rebase"
182
218
  if [ "$pre_anc" = false ]; then teeth=true; else teeth=false; fi
183
219
  echo " rebase (pre != post) — pre is-ancestor = $pre_anc, so leg 1 = $teeth (wants false)" >&2
184
220
  fi
185
- echo " headWasCurrent = $head_current (want true, both paths)" >&2
221
+ echo " headWasCurrent = $head_current (want true, all paths)" >&2
186
222
 
187
223
  # Named before the conjunction rather than tested inside it, so the verdict and
188
224
  # the `gates` object below read the same booleans. Two spellings of one gate is
@@ -192,10 +228,18 @@ if [ "$parents" -eq 2 ]; then two_parents=true; else two_parents=false; fi
192
228
  # `$teeth` is a constant true on the no-rebase path, and it is left OUT of the
193
229
  # object there rather than emitted as one: leg 1 is dropped on that path, and a
194
230
  # gate that cannot fail is not a gate. Its absence is the machine-readable form
195
- # of "leg 1 did not carry this proof".
231
+ # of "leg 1 did not carry this proof". On the merge-commit path `$teeth` is a
232
+ # constant true too — the elif that selects the path is itself the check that pre
233
+ # is a parent of post — and it is emitted anyway, as `preIsParentOfHead`, because
234
+ # the payload contract names it: it records which leg-1 replacement the proof ran
235
+ # under. It cannot fail, so nothing rests on it; the four shared gates carry the
236
+ # verdict there, and any parent of a two-parent post, the main side included,
237
+ # satisfies it.
196
238
  gates="\"postIsAncestor\":$post_anc,\"secondParentIsHead\":$second_is_head,\"exactlyTwoParents\":$two_parents,\"headWasCurrent\":$head_current"
197
239
  if [ "$proof_path" = rebase ]; then
198
240
  gates="\"preDidNotLand\":$teeth,$gates"
241
+ elif [ "$proof_path" = merge-commit ]; then
242
+ gates="\"preIsParentOfHead\":$teeth,$gates"
199
243
  fi
200
244
 
201
245
  # Derived FROM $gates, not restated: two independently hand-written booleans
@@ -211,7 +255,7 @@ echo "$NAME: proved=$proved (path=$proof_path)" >&2
211
255
 
212
256
  # None of the three string fields is reachable today — `$second` and `$first`
213
257
  # come from `git rev-parse`, 40 hex characters and nothing else, and
214
- # `$proof_path` is this script's own `rebase`/`no-rebase` literal. They go
258
+ # `$proof_path` is this script's own `rebase`/`no-rebase`/`merge-commit` literal. They go
215
259
  # through `jstr` for uniformity against a later edit that changes where a field
216
260
  # comes from, the same reason inflight.sh wraps `$pr`, and it costs nothing.
217
261
  # Assigned before the printf, never inline in its argument list — a