@feigi/fleet-ctl 3.24.29 → 3.24.30

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.24.29",
3
+ "version": "3.24.30",
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": {
@@ -46,7 +46,8 @@
46
46
  #
47
47
  # Exit status: 0 the command is printed; 1 a refusal about the cache, the
48
48
  # repository or the arguments; 3 a tool this script needs to read the cache
49
- # (node, mktemp, cat) could not be started or node died mid-read, so nothing
49
+ # (git, node, mktemp, cat) could not be started, mktemp could not create its
50
+ # temp file, git did not run to an answer, or node died mid-read, so nothing
50
51
  # was read and the cache's usability is unknown.
51
52
  set -eu
52
53
 
@@ -95,11 +96,11 @@ NAME=derive-testcmd
95
96
  die() { printf '%s: %s\n' "$NAME" "$1" >&2; exit 1; }
96
97
 
97
98
  # A refusal about the environment, not the cache: a tool this script needs to
98
- # read the cache (the interpreter, mktemp, cat) could not be started, or the
99
+ # read the cache (git, the interpreter, mktemp, cat) could not be started,
100
+ # mktemp could not create its temp file, git did not run to an answer, or the
99
101
  # interpreter died mid-read, so nothing was read and the cache's usability is
100
102
  # unknown. Exit 3, where every refusal about the cache, the repository or the
101
- # arguments is exit 1. A git that cannot be started is not told apart: it reads
102
- # as no repository, exit 1. A consumer that only tests for non-zero sees no
103
+ # arguments is exit 1. A consumer that only tests for non-zero sees no
103
104
  # difference.
104
105
  unrunnable() { printf '%s: %s\n' "$NAME" "$1" >&2; exit 3; }
105
106
 
@@ -126,7 +127,15 @@ esac
126
127
  repo=$1
127
128
  field=$2
128
129
 
129
- git -C "$repo" rev-parse --git-dir >/dev/null 2>&1 || die "$repo is not a git repository"
130
+ # git's own fatal — no repository there, or no such directory — exits 128, the
131
+ # one status that is a verdict on the repository. Any other non-zero status is
132
+ # git not running to an answer: 126 or 127 from a git that cannot be started,
133
+ # 128+N from a signal. Both git calls below tell the two apart.
134
+ gitout=$(git -C "$repo" rev-parse --git-dir 2>&1) || {
135
+ gitrc=$?
136
+ case $gitrc in 128) die "$repo is not a git repository" ;; esac
137
+ unrunnable "git did not answer whether $repo is a git repository (exit $gitrc), so the Recipe cache was not read${gitout:+ — $gitout}"
138
+ }
130
139
 
131
140
  case $field in
132
141
  install|test) ;;
@@ -144,8 +153,11 @@ fi
144
153
  # `--path-format=absolute` so the workspace is a real directory whatever the
145
154
  # caller's cwd; the workspace is the common dir's parent, the same rule
146
155
  # git-env.mjs's workspaceDirFromGitCommonDir() applies for the ledger.
147
- common=$(git -C "$repo" rev-parse --path-format=absolute --git-common-dir 2>&1) \
148
- || die "cannot resolve the common git dir of $repo — $common"
156
+ common=$(git -C "$repo" rev-parse --path-format=absolute --git-common-dir 2>&1) || {
157
+ gitrc=$?
158
+ case $gitrc in 128) die "cannot resolve the common git dir of $repo — $common" ;; esac
159
+ unrunnable "git did not resolve the common git dir of $repo (exit $gitrc), so the Recipe cache was not read${common:+ — $common}"
160
+ }
149
161
  cache="${common%/*}/.fleet/recipe.json"
150
162
 
151
163
  # Absent is its own refusal, ahead of the interpreter probe: it is the one
@@ -61,10 +61,11 @@
61
61
  // a git or filesystem fault stopped it before the cache was settled
62
62
  // (a git command could not be started, the reader's own git
63
63
  // included, or that git started and could not run; the reader's `sh`,
64
- // `node`, `mktemp` or `cat` could not be started, its `sh` was killed
65
- // by a signal, or its `node` died mid-read — a `cat` that ran and
66
- // failed stays the reader's refusal, exit 1; the cache or its temp
67
- // file could not be written). The log directory under $TMPDIR is
64
+ // `node`, `mktemp` or `cat` could not be started, its `mktemp` could
65
+ // not create its temp file, its `sh` was killed by a signal, or its
66
+ // `node` died mid-read — a `cat` that ran and failed stays the
67
+ // reader's refusal, exit 1; the cache or its temp file could not be
68
+ // written). The log directory under $TMPDIR is
68
69
  // removed.
69
70
 
70
71
  import { spawnSync } from "node:child_process";
@@ -118,8 +119,8 @@ const cannot = (message) => new Refusal(2, message);
118
119
  const notProven = (message) => new Refusal(1, message);
119
120
 
120
121
  // The exit status derive-testcmd.sh uses for a refusal about its own
121
- // environment — a tool it needs would not start, or node died mid-read — where
122
- // every refusal about the cache is 1.
122
+ // environment — a tool it needs would not start, git did not run to an answer,
123
+ // or node died mid-read — where every refusal about the cache is 1.
123
124
  const READER_COULD_NOT_RUN = 3;
124
125
 
125
126
  function parseArgs(argv) {
@@ -297,13 +298,16 @@ function prove(o, wt, logs) {
297
298
  // cache is undone just the same when the read-back is no verdict: an `sh` that
298
299
  // could not be started read nothing; an `sh` killed by a signal has no exit
299
300
  // status and reached no verdict; a reader that exits READER_COULD_NOT_RUN
300
- // could not start its `node`, `mktemp` or `cat`, or lost its `node` mid-read;
301
- // and the reader runs git itself and reads a git that will not run as no
302
- // repository at all, so its refusal is a verdict on what was proven only while
303
- // git still runs. `git --version` is the probe: a working git always passes
304
- // it, so a git that cannot be started fails it, and so does one that starts
305
- // and cannot run — a wrapper whose target is gone exits 126 or 127, a killed
306
- // git has no exit status at all.
301
+ // could not start its git, `node`, `mktemp` or `cat`, could not create its
302
+ // temp file, saw git end on any status but git's own 128, or lost its `node`
303
+ // mid-read; and the reader reads a git that ends on 128 as no repository at
304
+ // all, so its refusal is a verdict on what was proven only while git still
305
+ // runs. `git --version` is the probe for that exit-1 refusal: a working git
306
+ // always passes it, so a git that cannot be started fails it, and so does one
307
+ // that starts and cannot run — one that exits 128 on every call, or one that
308
+ // stopped running after the reader's own git calls answered. A git that exits
309
+ // 126 or 127, or is killed, on those calls never reaches the probe: the reader
310
+ // exits READER_COULD_NOT_RUN first.
307
311
  function writeCache(cache, recipe, repo) {
308
312
  mkdirSync(dirname(cache), { recursive: true });
309
313
  const prior = existsSync(cache) ? readFileSync(cache) : null;