@feigi/fleet-ctl 3.30.18 → 3.30.19

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@feigi/fleet-ctl",
3
- "version": "3.30.18",
3
+ "version": "3.30.19",
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": {
@@ -1847,11 +1847,7 @@ while :; do # one tick
1847
1847
  echo "WATCHER DEGRADED: core REST budget=$rl — CI polling paused, silence is NOT green"
1848
1848
  budget_out=1
1849
1849
  fi
1850
- else
1851
- if [ -n "$budget_out" ]; then
1852
- echo "WATCHER RECOVERED: core budget=$rl — CI polling resumed"
1853
- budget_out=
1854
- fi
1850
+ else # budget RECOVERED waits for the per-pass gate below
1855
1851
  prs=$(gh pr list --state open --limit "$pr_cap" --json number --jq '.[].number' 2>/dev/null) || prs=ERR
1856
1852
  if [ "$prs" = ERR ]; then
1857
1853
  if [ -z "$list_out" ]; then # global latch: this cause is account-level too
@@ -1863,7 +1859,8 @@ while :; do # one tick
1863
1859
  echo "WATCHER RECOVERED: open-PR list readable again — CI polling resumed"
1864
1860
  list_out=
1865
1861
  fi
1866
- if [ "$(printf '%s\n' "$prs" | grep -c .)" -ge "$pr_cap" ]; then
1862
+ count=$(printf '%s\n' "$prs" | grep -c .) || : # grep -c exits 1 on zero matches; set -e must not take it
1863
+ if [ "$count" -ge "$pr_cap" ]; then
1867
1864
  if [ -z "$cap_out" ]; then # global latch: a full page may have been cut there
1868
1865
  echo "WATCHER DEGRADED: open-PR list hit its --limit $pr_cap — PRs past it are NOT watched, silence on them is NOT green"
1869
1866
  cap_out=1
@@ -1872,21 +1869,36 @@ while :; do # one tick
1872
1869
  echo "WATCHER RECOVERED: open-PR list under its --limit $pr_cap — every open PR watched again"
1873
1870
  cap_out=
1874
1871
  fi
1875
- for pr in $(printf '%s\n' "$prs"); do # inline $(...): `for pr in $prs` is ONE iteration under zsh
1876
- st=$(~/.fleet/bin/fleet-run ci-state.mjs --pr "$pr" 2>/dev/null) || : # not-green exits non-zero; the payload is the verdict
1877
- if ! printf '%s' "$st" | jq -e '.verdict and .verdict != "rate-limited"' >/dev/null 2>&1; then
1878
- case " $blind " in *" $pr "*) ;; *) # latch keyed BY PR: this cause is per-PR
1879
- echo "WATCHER DEGRADED: no usable ci-state reading for #$pr — silence is NOT green"
1880
- blind="$blind $pr" ;;
1881
- esac
1882
- continue # inner continue — still reaches the tick sleep
1872
+ # gh pr list is GraphQL, so $rl still holds. The pass is budgeted at 4 core
1873
+ # REST units per listed PR on top of the 200 floor — an allowance, not a
1874
+ # count: one ci-state.mjs call makes several REST reads (more for a PR whose
1875
+ # head dropped required jobs). A shortfall pauses this tick's pass.
1876
+ if [ "$rl" -lt $((200 + 4 * count)) ]; then
1877
+ if [ -z "$budget_out" ]; then
1878
+ echo "WATCHER DEGRADED: core REST budget=$rl < $((200 + 4 * count)) needed for $count PRs — CI polling paused, silence is NOT green"
1879
+ budget_out=1
1880
+ fi
1881
+ else
1882
+ if [ -n "$budget_out" ]; then
1883
+ echo "WATCHER RECOVERED: core budget=$rl — CI polling resumed"
1884
+ budget_out=
1883
1885
  fi
1884
- case " $blind " in *" $pr "*)
1885
- echo "WATCHER RECOVERED: ci-state reading #$pr again — CI polling resumed"
1886
- keep=; for b in $(printf '%s\n' "$blind"); do [ "$b" = "$pr" ] || keep="$keep $b"; done; blind=$keep ;;
1887
- esac
1888
- : # your normal handling of $st for this PR
1889
- done
1886
+ for pr in $(printf '%s\n' "$prs"); do # inline $(...): `for pr in $prs` is ONE iteration under zsh
1887
+ st=$(~/.fleet/bin/fleet-run ci-state.mjs --pr "$pr" 2>/dev/null) || : # not-green exits non-zero; the payload is the verdict
1888
+ if ! printf '%s' "$st" | jq -e '.verdict and .verdict != "rate-limited"' >/dev/null 2>&1; then
1889
+ case " $blind " in *" $pr "*) ;; *) # latch keyed BY PR: this cause is per-PR
1890
+ echo "WATCHER DEGRADED: no usable ci-state reading for #$pr — silence is NOT green"
1891
+ blind="$blind $pr" ;;
1892
+ esac
1893
+ continue # inner continue — still reaches the tick sleep
1894
+ fi
1895
+ case " $blind " in *" $pr "*)
1896
+ echo "WATCHER RECOVERED: ci-state reading #$pr again — CI polling resumed"
1897
+ keep=; for b in $(printf '%s\n' "$blind"); do [ "$b" = "$pr" ] || keep="$keep $b"; done; blind=$keep ;;
1898
+ esac
1899
+ : # your normal handling of $st for this PR
1900
+ done
1901
+ fi
1890
1902
  fi
1891
1903
  fi
1892
1904
  sleep 120 # the block's only pacing, once per tick
@@ -1954,6 +1966,23 @@ enforce. It latches globally like the list failure but does not pause polling:
1954
1966
  the PRs it did return are real, so the pass still watches them, and the
1955
1967
  DEGRADED line names the rest as unwatched until a pass comes back under the cap.
1956
1968
 
1969
+ **The budget is gated twice, and only the second gate announces recovery.** The
1970
+ tick-top floor (`200`) covers the probes themselves. Once the open-PR list is
1971
+ read, the pass gate reserves `200 + 4 × count` core REST units — an allowance of
1972
+ 4 per listed PR on top of the floor, so the reserve grows with the list instead
1973
+ of staying a flat 200 that a long list drains mid-pass. It is an allowance, not
1974
+ a count: one `ci-state.mjs` call makes several REST reads, more for a PR whose
1975
+ head dropped required jobs. A shortfall at either gate pauses the **whole** pass
1976
+ through the one budget latch and never polls a prefix of the list: a prefix runs
1977
+ in list order, so the same tail PRs would go unread every tick with no line at
1978
+ all (never polled, so nothing marks them blind), while the PRs that were polled
1979
+ would run dry mid-pass and each emit a blind line. The DEGRADED line from the
1980
+ pass gate names the amount it needed and the count it needed it for, so a
1981
+ healthy-looking `budget=999` is not read as an outage with no cause. Only the
1982
+ pass gate emits the budget RECOVERED line: announcing recovery at the floor
1983
+ would report resumption on a tick whose pass gate then pauses it again — a
1984
+ DEGRADED/RECOVERED pair every tick.
1985
+
1957
1986
  **Judge `ci-state` on its payload, never its exit code** — the same rule as
1958
1987
  `merge-gate.mjs` applies on the merge path, applied to the watcher. `not-green` is an
1959
1988
  ordinary, frequent state that exits non-zero, so a watcher treating any non-zero