@plot-pm/board 0.19.0 → 0.20.0
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/dist/board-server.mjs +233 -226
- package/package.json +1 -1
- package/plot-config.sh +19 -9
- package/plot-dispatch.sh +59 -86
- package/plot-fleet-scan.sh +52 -19
- package/plot-host.sh +229 -183
- package/plot-plan-meta.sh +225 -233
- package/plot-pr-merged.sh +4 -33
- package/plot-release-refs.sh +0 -1
- package/plot-tmp.sh +8 -2
- package/plot-worker-state.sh +29 -51
package/plot-pr-merged.sh
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# Plot helper: the ONE answer to "did the host merge ANY PR for this branch?"
|
|
3
3
|
#
|
|
4
|
-
# SOURCED, NOT RUN. `. "$script_dir/plot-pr-merged.sh"` defines `pr_merged
|
|
5
|
-
# `pr_open
|
|
4
|
+
# SOURCED, NOT RUN. `. "$script_dir/plot-pr-merged.sh"` defines `pr_merged` and
|
|
5
|
+
# `pr_open`; the file does nothing else on load. That is what makes sourcing it
|
|
6
6
|
# safe, and it is the same shape — and the same reason — as
|
|
7
7
|
# `plot-worker-state.sh`: the logic could not simply stay in `plot-reap.sh`,
|
|
8
8
|
# because that file parses `$@` and `exit 2`s on an unknown argument at load
|
|
@@ -72,9 +72,8 @@
|
|
|
72
72
|
#
|
|
73
73
|
# AN EMPTY BRANCH IS NOT ASKED ABOUT. `gh pr list --head ""` applies no filter,
|
|
74
74
|
# so every PR in the repository matches: measured 2026-10-01 on `origin/main`
|
|
75
|
-
# (`56a978ea`), `_plot_merged_lookup ""` answered `found
|
|
76
|
-
# 0 — merged
|
|
77
|
-
# merged PR here. So each of the three lookups refuses an empty branch BEFORE
|
|
75
|
+
# (`56a978ea`), `_plot_merged_lookup ""` answered `found` and `pr_merged ""`
|
|
76
|
+
# exited 0 — merged. So each of the two lookups refuses an empty branch BEFORE
|
|
78
77
|
# `command -v gh`, answering `unaskable` rather than `none` because a lookup that
|
|
79
78
|
# did not run is silence and `none` would claim the host spoke; `pr_open ""` then
|
|
80
79
|
# casts no veto, which is safe only because `pr_merged ""` refuses on the same
|
|
@@ -193,31 +192,3 @@ pr_open() {
|
|
|
193
192
|
answer=$(_plot_landed none "$(_plot_open_lookup "$1")") || return 1
|
|
194
193
|
case "$answer" in *" open-pr") return 0 ;; *) return 1 ;; esac
|
|
195
194
|
}
|
|
196
|
-
|
|
197
|
-
# Which commits did the host merge for this branch? One `headRefOid` per merged
|
|
198
|
-
# PR, one per line.
|
|
199
|
-
#
|
|
200
|
-
# A THIRD QUESTION, asked by `plot-reap.sh` only. After a squash merge the
|
|
201
|
-
# host deletes the branch (`delete_branch_on_merge`), `git fetch --prune`
|
|
202
|
-
# drops the remote-tracking ref, and the branch's own commits are then on no
|
|
203
|
-
# remote ref at all. So "which commits did no remote ever hold?" needs the
|
|
204
|
-
# head the host merged: a commit reachable from it was pushed; a commit beyond
|
|
205
|
-
# it exists only on the desk.
|
|
206
|
-
#
|
|
207
|
-
# Returns 1 when the host cannot be asked. The caller reads that as
|
|
208
|
-
# `unknown`, which keeps the desk: here a failure to observe is the case that
|
|
209
|
-
# loses work. It prints nothing and returns 0 when the host answered and no PR
|
|
210
|
-
# merged.
|
|
211
|
-
pr_merged_heads() {
|
|
212
|
-
local br="$1" out
|
|
213
|
-
[ -n "$br" ] || return 1
|
|
214
|
-
command -v gh >/dev/null 2>&1 || return 1
|
|
215
|
-
out=$(gh pr list --head "$br" --state all --limit 100 --json mergedAt,headRefOid 2>/dev/null) \
|
|
216
|
-
|| return 1
|
|
217
|
-
printf '%s' "$out" | node -e '
|
|
218
|
-
let s = "";
|
|
219
|
-
process.stdin.on("data", (d) => { s += d; }).on("end", () => {
|
|
220
|
-
const rows = JSON.parse(s);
|
|
221
|
-
for (const r of rows) if (r.mergedAt && r.headRefOid) console.log(r.headRefOid);
|
|
222
|
-
});' 2>/dev/null || return 1
|
|
223
|
-
}
|
package/plot-release-refs.sh
CHANGED
package/plot-tmp.sh
CHANGED
|
@@ -85,10 +85,16 @@ _plot_tmp_create() {
|
|
|
85
85
|
trap '__plot_tmp_pending="TERM 15"' TERM
|
|
86
86
|
trap '__plot_tmp_pending="PIPE 13"' PIPE
|
|
87
87
|
fi
|
|
88
|
+
# `mktemp` IGNORES THE GROUP SIGNAL. It is a process of its own in the
|
|
89
|
+
# script's group, and the handlers above do not reach it: a group TERM after
|
|
90
|
+
# it creates the path and before it prints the name ends it, and the name
|
|
91
|
+
# never reaches the registry. CI run 38169324238 left one
|
|
92
|
+
# `plot-host-prlist-err.*` this way (#1582). Ignored signals pass to the child,
|
|
93
|
+
# so it always prints the name; this shell still records the signal.
|
|
88
94
|
if [ "${3:-}" = -d ]; then
|
|
89
|
-
__plot_tmp_new=$(mktemp -d "${TMPDIR:-/tmp}/plot-$2.XXXXXX")
|
|
95
|
+
__plot_tmp_new=$(trap '' INT TERM PIPE; mktemp -d "${TMPDIR:-/tmp}/plot-$2.XXXXXX")
|
|
90
96
|
else
|
|
91
|
-
__plot_tmp_new=$(mktemp "${TMPDIR:-/tmp}/plot-$2.XXXXXX")
|
|
97
|
+
__plot_tmp_new=$(trap '' INT TERM PIPE; mktemp "${TMPDIR:-/tmp}/plot-$2.XXXXXX")
|
|
92
98
|
fi
|
|
93
99
|
__plot_tmp_rc=$?
|
|
94
100
|
# THE PATH IS REGISTERED WHEN IT EXISTS, whatever the status says. bash 3.2
|
package/plot-worker-state.sh
CHANGED
|
@@ -303,7 +303,7 @@ plot_pid_is_current() { # $1=pid $2=startedAt (ISO-8601) → 0 if current, 1 if
|
|
|
303
303
|
|
|
304
304
|
# Convert the manifest's startedAt (ISO-8601) to epoch seconds.
|
|
305
305
|
# `date -j -f` is macOS; `date -d` is GNU. Try both.
|
|
306
|
-
if manifest_epoch=$(date -j -f "%Y-%m-%dT%H:%M:%SZ" "$started" +%s 2>/dev/null); then
|
|
306
|
+
if manifest_epoch=$(date -j -u -f "%Y-%m-%dT%H:%M:%SZ" "$started" +%s 2>/dev/null); then
|
|
307
307
|
:
|
|
308
308
|
elif manifest_epoch=$(date -d "$started" +%s 2>/dev/null); then
|
|
309
309
|
:
|
|
@@ -330,11 +330,12 @@ plot_pid_is_current() { # $1=pid $2=startedAt (ISO-8601) → 0 if current, 1 if
|
|
|
330
330
|
fi
|
|
331
331
|
|
|
332
332
|
# A process that started BEFORE the manifest's startedAt is a reused pid.
|
|
333
|
-
# A process that started AT or AFTER is the real worker.
|
|
334
|
-
#
|
|
335
|
-
#
|
|
336
|
-
#
|
|
337
|
-
local
|
|
333
|
+
# A process that started AT or AFTER is the real worker. The slack is 3 s:
|
|
334
|
+
# the wrapper writes the pid and then the manifest's awk stamps it, so the
|
|
335
|
+
# second can tick over in between, and procps on Linux reports a start 0.8 to
|
|
336
|
+
# 1.2 s early (`SKEW_MS` in `test/reconcile/own-process.mjs`). The stamp is
|
|
337
|
+
# UTC, so the macOS parse takes `-u`; without it the stamp read as local time.
|
|
338
|
+
local slack=3
|
|
338
339
|
[ "$proc_epoch" -ge "$((manifest_epoch - slack))" ]
|
|
339
340
|
}
|
|
340
341
|
|
|
@@ -394,32 +395,6 @@ plot_worker_log() { # $1=worktree → path to the worker log, or "" (non-zero)
|
|
|
394
395
|
[ -e "$wt/.plot-worker.log" ] || return 1
|
|
395
396
|
printf '%s' "$wt/.plot-worker.log"
|
|
396
397
|
}
|
|
397
|
-
# Why did the worker in this worktree end?
|
|
398
|
-
#
|
|
399
|
-
# A SEPARATE READING FROM `plot_worker_state`, and deliberately so. That function
|
|
400
|
-
# answers what the PROCESS did and what the desk holds; this answers why the
|
|
401
|
-
# worker stopped, which is a fact only the worker itself could record. The two
|
|
402
|
-
# come apart in the case that matters: a worker ended by the floor and one ended
|
|
403
|
-
# by a monitor finding both leave `.plot-worker.exit` holding `124`, so the exit
|
|
404
|
-
# code cannot tell them apart and the state word does not try to.
|
|
405
|
-
#
|
|
406
|
-
# IT IS NOT FOLDED INTO THE STATE ROW. `plot_worker_state` prints three
|
|
407
|
-
# tab-separated fields that three callers and one domain port parse positionally;
|
|
408
|
-
# a fourth field would change a contract this reading does not need to change.
|
|
409
|
-
# `plot_worker_log` is the precedent — a standalone reader beside the state
|
|
410
|
-
# function, asked by whoever wants it.
|
|
411
|
-
#
|
|
412
|
-
# ABSENT IS ABSENT, and it is load-bearing. No worktree, or no ending file in
|
|
413
|
-
# one, prints nothing and returns non-zero — which is what a SIGKILLed worker
|
|
414
|
-
# leaves behind, and what every worker that ran before this record existed
|
|
415
|
-
# leaves too. The domain's `readEnding` keeps that apart from a file that exists
|
|
416
|
-
# and does not parse; this prints the bytes and decides neither.
|
|
417
|
-
plot_worker_ending() { # $1=worktree → the ending record's JSON, or "" (non-zero)
|
|
418
|
-
local wt="$1"
|
|
419
|
-
[ -n "$wt" ] || return 1
|
|
420
|
-
[ -f "$wt/.plot-worker.ending.json" ] || return 1
|
|
421
|
-
cat "$wt/.plot-worker.ending.json" 2>/dev/null
|
|
422
|
-
}
|
|
423
398
|
|
|
424
399
|
# Is a person being waited on inside this worktree?
|
|
425
400
|
#
|
|
@@ -819,25 +794,6 @@ plot_worker_idle_now() { # $1..$7 as above → idle | silent
|
|
|
819
794
|
# `origin/<default>` resolution are copied verbatim, including the comment
|
|
820
795
|
# that explains why a dispatched branch's own claim commit must not count.
|
|
821
796
|
|
|
822
|
-
# The reset epoch a desk is waiting out, or nothing.
|
|
823
|
-
#
|
|
824
|
-
# THE LOOP WRITES THE FILE AND THIS ONLY READS IT. `.plot-worker.limited`
|
|
825
|
-
# carries the reset epoch, the same instant as ISO text, and the limit line;
|
|
826
|
-
# only the first field is read here, because the caller compares integers and
|
|
827
|
-
# never parses a date.
|
|
828
|
-
#
|
|
829
|
-
# NOTHING IS ANSWERED FOR AN ABSENT, EMPTY OR UNPARSEABLE FILE, and the caller
|
|
830
|
-
# reads that as *this desk is not waiting*. A record whose first field is not a
|
|
831
|
-
# number is the same answer as no record: a reading that cannot be made must
|
|
832
|
-
# not widen into a reason to hold a verdict back.
|
|
833
|
-
plot_worker_limited_reset() { # $1=worktree → epoch seconds | ""
|
|
834
|
-
local file="$1/.plot-worker.limited" reset
|
|
835
|
-
[ -n "$1" ] && [ -r "$file" ] || return 0
|
|
836
|
-
reset=$(cut -f1 < "$file" 2>/dev/null | head -n1)
|
|
837
|
-
case "$reset" in (''|*[!0-9]*) return 0 ;; esac
|
|
838
|
-
printf '%s' "$reset"
|
|
839
|
-
}
|
|
840
|
-
|
|
841
797
|
# Are there commits on this branch yet? → 0 yes | 1 no | 2 unanswerable
|
|
842
798
|
#
|
|
843
799
|
# THE THIRD CONDITION ON `idle`, and the one that separates a stall from an
|
|
@@ -1188,6 +1144,20 @@ plot_worker_task_state() { # $1=worktree $2=pr-fact → finished|waiting|stalled
|
|
|
1188
1144
|
printf '%s' "$answer"
|
|
1189
1145
|
}
|
|
1190
1146
|
|
|
1147
|
+
# Whether the loop `$2` at the desk `$1` is a free agent waiting for a hand-over:
|
|
1148
|
+
# `.plot-worker.freewait`, with leading and trailing whitespace removed, names
|
|
1149
|
+
# exactly that pid. A DECLARED DUPLICATE of `deskWaitsFree`: `plot_worker_state`
|
|
1150
|
+
# runs once per desk per fleet-scan pass, so it does not ask a bundle, and
|
|
1151
|
+
# `packages/domain/corpus/desk-waits-free.corpus.test.ts` holds the pair.
|
|
1152
|
+
plot_worker_waits_free() { # $1=worktree $2=pid → 0 when the record names $2
|
|
1153
|
+
local fw; [ -n "$2" ] && [ -f "$1/.plot-worker.freewait" ] && fw=$(<"$1/.plot-worker.freewait") || return 1
|
|
1154
|
+
fw="${fw#"${fw%%[![:space:]]*}"}"; [ "${fw%"${fw##*[![:space:]]}"}" = "$2" ]
|
|
1155
|
+
}
|
|
1156
|
+
|
|
1157
|
+
# `deskLoopAlive` and `deskWaitsFree` for the desk paths on stdin, one answer
|
|
1158
|
+
# line per desk (`board/plot-desk-loop.mjs`). Asked once per operator command.
|
|
1159
|
+
plot_desk_loops() { PLOT_MANIFEST_DIR="${PLOT_MANIFEST_DIR:-}" node "${_plot_wstate_config%/*}/board/plot-desk-loop.mjs" "$@"; }
|
|
1160
|
+
|
|
1191
1161
|
# Classify the worker in a worktree.
|
|
1192
1162
|
#
|
|
1193
1163
|
# $1 = worktree path
|
|
@@ -1324,6 +1294,14 @@ plot_worker_state() { # $1=worktree $2=pr-fact → "state\tpid\tcode"
|
|
|
1324
1294
|
# means — `stalled` for work only this machine holds, `waiting` for a
|
|
1325
1295
|
# marker, `finished` for a desk that is clear — because the process has
|
|
1326
1296
|
# nothing left to say. No exit file exists: the wrapper has not exited.
|
|
1297
|
+
#
|
|
1298
|
+
# A FREE AGENT WAITS HERE: its loop polls for a hand-over with no agent
|
|
1299
|
+
# beneath it, and `.plot-worker.freewait` names the loop's pid
|
|
1300
|
+
# (`deskWaitsFree`'s reading). That desk is occupied, so it reads `running`.
|
|
1301
|
+
# ONLY FOR A PID WHOSE OWNERSHIP IS PROVEN: `started_at` is set only when
|
|
1302
|
+
# the manifest's `startedAt` passed `plot_pid_is_current` above, so a
|
|
1303
|
+
# reused pid, or a pid from the bare pid file, never reads as a free agent.
|
|
1304
|
+
[ -n "$started_at" ] && plot_worker_waits_free "$wt" "$pid" && { printf 'running\t%s\t' "$pid"; return; }
|
|
1327
1305
|
printf '%s\t%s\t' "$(plot_worker_task_state "$wt" "$has_pr")" "$pid"
|
|
1328
1306
|
return
|
|
1329
1307
|
fi
|