@plot-pm/board 0.18.0 → 0.19.1
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 +206 -195
- package/package.json +2 -1
- package/plot-approve.sh +9 -978
- package/plot-config.sh +8 -0
- package/plot-dispatch.sh +40 -31
- package/plot-fleet-scan.sh +9 -6
- package/plot-host.sh +194 -110
- package/plot-plan-meta.sh +9 -5
- package/plot-pr-merged.sh +4 -33
- package/plot-reap.sh +12 -1250
- package/plot-tmp.sh +8 -2
- package/plot-worker-state.sh +29 -6
package/plot-config.sh
CHANGED
|
@@ -193,6 +193,14 @@
|
|
|
193
193
|
# CI jenkins | github-actions | none — which CI system this
|
|
194
194
|
# project uses. Recorded by /plot-board-setup; not yet
|
|
195
195
|
# read by the board.
|
|
196
|
+
# Default branch checks
|
|
197
|
+
# comma-separated workflow names whose runs decide whether
|
|
198
|
+
# the default branch is red (`CI, Lint`). Read by fleetd
|
|
199
|
+
# where it writes `.plot/state/default-branch.json`; a run
|
|
200
|
+
# of any other workflow is not folded, so a publishing or
|
|
201
|
+
# release workflow cannot raise the `default-branch-red`
|
|
202
|
+
# hold or the board's red-branch status. Names match a run's
|
|
203
|
+
# workflow name exactly. Absent = every workflow's runs.
|
|
196
204
|
# Jenkins instance the slug or URL passed to a Jenkins CLI's -I flag.
|
|
197
205
|
# Read back by /plot-board-setup to verify auth against
|
|
198
206
|
# the right instance — without it the only runnable
|
package/plot-dispatch.sh
CHANGED
|
@@ -1014,8 +1014,8 @@ resolve_launch() { # $1 = repo root, $2 = agent name ('' when none)
|
|
|
1014
1014
|
# makes `failed` safe to include — and including it is the point: a gate that
|
|
1015
1015
|
# simply refused `failed` would pass every refusal test and leave the verb
|
|
1016
1016
|
# unable to do the one thing it exists for.
|
|
1017
|
-
handover_refusal() { # $1=branch $2=worktree $3=state → 0 may hand over, 1 refused
|
|
1018
|
-
local branch="$1" wt="$2" state="$3" pr_json pr_num pr_state marker
|
|
1017
|
+
handover_refusal() { # $1=branch $2=worktree $3=state $4=plot_desk_loops line → 0 may hand over, 1 refused
|
|
1018
|
+
local branch="$1" wt="$2" state="$3" loop="${4:-none}" pr_json pr_num pr_state marker lpid lsrc lwait
|
|
1019
1019
|
|
|
1020
1020
|
if reached_review "$branch"; then
|
|
1021
1021
|
pr_json=$("$script_dir/plot-host.sh" pr-state "$branch" </dev/null 2>/dev/null || true)
|
|
@@ -1028,11 +1028,20 @@ handover_refusal() { # $1=branch $2=worktree $3=state → 0 may hand over, 1 ref
|
|
|
1028
1028
|
return 1
|
|
1029
1029
|
fi
|
|
1030
1030
|
|
|
1031
|
+
# A LIVE LOOP REFUSES WHATEVER THE STATE WORD SAYS (#1450). A loop sleeping on
|
|
1032
|
+
# checks, on a usage limit or between passes has no agent beneath it and reads
|
|
1033
|
+
# `stalled` or `finished`, yet a second loop beside it shares the desk.
|
|
1034
|
+
# `deskLoopAlive` reads all three recorded pids; an unread answer refuses too.
|
|
1035
|
+
case "$loop" in
|
|
1036
|
+
none) ;;
|
|
1037
|
+
alive*) IFS=$'\t' read -r _ lpid lsrc lwait <<<"$loop"
|
|
1038
|
+
[ "$lwait" = free ] && printf 'plot-dispatch: a free agent is waiting on %s (pid %s) — refusing.\n Its loop is idle, polling for a hand-over. Confirm before replacing it:\n plot-dispatch.sh --stop %s\n' "$branch" "$lpid" "$branch" >&2 && return 1
|
|
1039
|
+
case "$state" in running*) ;; *) printf 'plot-dispatch: a loop is alive on %s (pid %s, from %s) — refusing.\n It reads %s, which --stop leaves alone, as the reaper does. Let it\n finish its pass, or end pid %s yourself if you mean to replace it.\n' "$branch" "$lpid" "$lsrc" "${state%% *}" "$lpid" >&2; return 1 ;; esac ;;
|
|
1040
|
+
*) printf 'plot-dispatch: could not read whether a loop is alive on %s — refusing.\n' "$branch" >&2; return 1 ;;
|
|
1041
|
+
esac
|
|
1031
1042
|
case "$state" in
|
|
1032
1043
|
running*)
|
|
1033
|
-
|
|
1034
|
-
echo " Stop it first if you mean to replace it:" >&2
|
|
1035
|
-
echo " plot-dispatch.sh --stop $branch" >&2
|
|
1044
|
+
printf 'plot-dispatch: a worker is alive on %s (pid %s) — refusing.\n Stop it first if you mean to replace it:\n plot-dispatch.sh --stop %s\n' "$branch" "${state#running }" "$branch" >&2
|
|
1036
1045
|
return 1
|
|
1037
1046
|
;;
|
|
1038
1047
|
waiting*)
|
|
@@ -1824,14 +1833,12 @@ if [ "$mode" = "stop" ]; then
|
|
|
1824
1833
|
wt_guess="$wt_root_early/$wt_prefix_early$(printf '%s' "$stop_branch" | tr '/' '-')"
|
|
1825
1834
|
[ -n "$wt" ] && [ -d "$wt" ] || wt="$wt_guess"
|
|
1826
1835
|
if [ ! -d "$wt" ]; then
|
|
1827
|
-
|
|
1828
|
-
echo " Asked git for every worktree, and looked at $wt_guess." >&2
|
|
1829
|
-
echo " If a worker is running somewhere this cannot see, that machine is" >&2
|
|
1830
|
-
echo " where to stop it: /plot-dispatch --status names the desks here." >&2
|
|
1831
|
-
echo " Nothing was killed." >&2
|
|
1836
|
+
printf "plot-dispatch: no worktree holds '%s' — nothing to stop.\n Asked git for every worktree, and looked at %s.\n If a worker is running somewhere this cannot see, that machine is\n where to stop it: /plot-dispatch --status names the desks here.\n Nothing was killed.\n" "$stop_branch" "$wt_guess" >&2
|
|
1832
1837
|
exit 1
|
|
1833
1838
|
fi
|
|
1834
1839
|
st=$(worker_state "$wt" "$stop_branch")
|
|
1840
|
+
# A LIVE LOOP IS STOPPED WHATEVER ITS STATE WORD, so the loop `--restart`
|
|
1841
|
+
# refuses on is one this verb can end (`deskLoopAlive`, #1450).
|
|
1835
1842
|
case "$st" in
|
|
1836
1843
|
running*)
|
|
1837
1844
|
pid=${st#running }
|
|
@@ -1863,10 +1870,14 @@ if [ "$mode" = "stop" ]; then
|
|
|
1863
1870
|
else
|
|
1864
1871
|
echo " signalled its whole process group $stop_pgid"
|
|
1865
1872
|
fi
|
|
1873
|
+
# A PERSON'S STOP IS RECORDED AS ONE, so the supervisor's tick leaves the
|
|
1874
|
+
# desk alone. A worker that exits non-zero with no ending gets a fresh
|
|
1875
|
+
# agent from the tick (`killedWorkerEnding`); a `stopped` ending answers
|
|
1876
|
+
# `leave` in `endingAction`, and the desk keeps its claim.
|
|
1877
|
+
printf '{"reason":"stopped","actor":"operator","branch":"%s","detail":"plot-dispatch --stop"}\n' "$stop_branch" 2>/dev/null >"$wt/.plot-worker.ending.json" || true
|
|
1866
1878
|
# The worktree and its claim are left in place: the branch is still taken,
|
|
1867
1879
|
# and deleting either would be the kind of write this design avoids.
|
|
1868
|
-
|
|
1869
|
-
echo " plot-dispatch.sh --release $stop_branch"
|
|
1880
|
+
printf ' worktree kept at %s — the claim stands until you release it:\n plot-dispatch.sh --release %s\n' "$wt" "$stop_branch"
|
|
1870
1881
|
;;
|
|
1871
1882
|
finished*|waiting*|stalled*|failed*|ended*) echo "$stop_branch is not running ($st)" ;;
|
|
1872
1883
|
*) echo "$stop_branch has no worker" ;;
|
|
@@ -1894,9 +1905,7 @@ if [ "$mode" = "restart" ]; then
|
|
|
1894
1905
|
# stopped worker on it should be replaced. Refusing on phase would strand
|
|
1895
1906
|
# exactly the branch this exists to rescue.
|
|
1896
1907
|
if [ -z "$restart_branch" ]; then
|
|
1897
|
-
|
|
1898
|
-
echo " A slug is not enough: which stopped branch to hand to a new worker" >&2
|
|
1899
|
-
echo " is your call, not something this should guess." >&2
|
|
1908
|
+
printf 'plot-dispatch: --restart needs a branch name, e.g. --restart feature/x\n A slug is not enough: which stopped branch to hand to a new worker\n is your call, not something this should guess.\n' >&2
|
|
1900
1909
|
exit 1
|
|
1901
1910
|
fi
|
|
1902
1911
|
|
|
@@ -1908,9 +1917,7 @@ if [ "$mode" = "restart" ]; then
|
|
|
1908
1917
|
# them, and a hand-made worktree rarely follows dispatch's naming.
|
|
1909
1918
|
restart_wt=$(worktree_holding_branch "$restart_branch")
|
|
1910
1919
|
if [ -z "$restart_wt" ] || [ ! -d "$restart_wt" ]; then
|
|
1911
|
-
|
|
1912
|
-
echo " --restart hands an EXISTING checkout to a new worker; it creates none." >&2
|
|
1913
|
-
echo " To start this branch fresh, dispatch its plan." >&2
|
|
1920
|
+
printf "plot-dispatch: no worktree holds '%s' — nothing to restart.\n --restart hands an EXISTING checkout to a new worker; it creates none.\n To start this branch fresh, dispatch its plan.\n" "$restart_branch" >&2
|
|
1914
1921
|
exit 1
|
|
1915
1922
|
fi
|
|
1916
1923
|
|
|
@@ -1935,7 +1942,8 @@ if [ "$mode" = "restart" ]; then
|
|
|
1935
1942
|
# running here" — asked rather than re-derived, so this cannot drift from
|
|
1936
1943
|
# `--status` and the scan the way five of six states already did once.
|
|
1937
1944
|
restart_state=$(worker_state "$restart_wt" "$restart_branch")
|
|
1938
|
-
|
|
1945
|
+
restart_loop=$(printf '%s\n' "$restart_wt" | plot_desk_loops) || restart_loop="unread"
|
|
1946
|
+
handover_refusal "$restart_branch" "$restart_wt" "$restart_state" "${restart_loop:-unread}" || exit 1
|
|
1939
1947
|
# `stalled`, `failed`, `ended` and `no worker` all restart. The PR question
|
|
1940
1948
|
# above is what makes `failed` safe to include — and including it is the
|
|
1941
1949
|
# point: a gate that simply refused `failed` would pass every refusal test
|
|
@@ -2310,8 +2318,11 @@ if [ "$mode" = "start" ]; then
|
|
|
2310
2318
|
[ -n "$start_main" ] || start_main="main"
|
|
2311
2319
|
|
|
2312
2320
|
# HOW MANY WORKERS ARE ALREADY UP, counted from the desks on this disk rather
|
|
2313
|
-
# than from the registry. A manifest records a launch; a live
|
|
2314
|
-
# worker, and the question `--start` asks is about the machine's load.
|
|
2321
|
+
# than from the registry. A manifest records a launch; a live loop records a
|
|
2322
|
+
# worker, and the question `--start` asks is about the machine's load. A loop
|
|
2323
|
+
# counts whatever its state word: one sleeping on checks, on a usage limit or
|
|
2324
|
+
# between passes holds no agent and still loads the machine. `deskLoopAlive`
|
|
2325
|
+
# answers, through `plot_desk_loops`, the reading `--restart` refuses on. The
|
|
2315
2326
|
# count is what `fleetSize` subtracts, so asking for three twice gives three
|
|
2316
2327
|
# agents rather than six.
|
|
2317
2328
|
#
|
|
@@ -2338,14 +2349,7 @@ if [ "$mode" = "start" ]; then
|
|
|
2338
2349
|
if [ -n "${PLOT_START_ONE:-}" ]; then
|
|
2339
2350
|
start_count=1
|
|
2340
2351
|
else
|
|
2341
|
-
|
|
2342
|
-
[ -n "$wt" ] || continue
|
|
2343
|
-
[ -f "$wt/.plot-worker.pid" ] || continue
|
|
2344
|
-
p=$(cat "$wt/.plot-worker.pid" 2>/dev/null) || continue
|
|
2345
|
-
[ -n "$p" ] && ps -p "$p" >/dev/null 2>&1 && start_running=$((start_running + 1))
|
|
2346
|
-
done <<EOF
|
|
2347
|
-
$(git worktree list --porcelain </dev/null 2>/dev/null | awk '/^worktree /{print $2}')
|
|
2348
|
-
EOF
|
|
2352
|
+
start_running=$(git worktree list --porcelain </dev/null 2>/dev/null | awk '/^worktree /{print $2}' | plot_desk_loops --count) || start_running=""
|
|
2349
2353
|
fi
|
|
2350
2354
|
|
|
2351
2355
|
# THE MACHINE'S OWN READING, one timed fork. `machine-system.ts` samples five
|
|
@@ -2406,8 +2410,13 @@ EOF
|
|
|
2406
2410
|
# missing node, a module that throws all leave the answer empty. The direction
|
|
2407
2411
|
# is the reaper's: silence is never permission, and here permission would spawn
|
|
2408
2412
|
# detached processes.
|
|
2409
|
-
|
|
2410
|
-
|
|
2413
|
+
#
|
|
2414
|
+
# A COUNT THAT CANNOT BE READ IS THE SAME REFUSAL: an empty `start_running`
|
|
2415
|
+
# means `plot-desk-loop.mjs` answered nothing, and the refusal below names
|
|
2416
|
+
# that bundle, because an undercount would start too many agents.
|
|
2417
|
+
start_bundle="$script_dir/board/plot-fleet-size.mjs" start_answer=""
|
|
2418
|
+
[ -n "$start_running" ] || start_bundle="$script_dir/board/plot-desk-loop.mjs"
|
|
2419
|
+
[ -z "$start_running" ] || start_answer=$(printf '%s\t%s\t%s' "$start_count" "$start_running" "$start_cost" \
|
|
2411
2420
|
| node "$start_bundle" 2>/dev/null)
|
|
2412
2421
|
|
|
2413
2422
|
if [ -z "$start_answer" ]; then
|
package/plot-fleet-scan.sh
CHANGED
|
@@ -220,8 +220,8 @@
|
|
|
220
220
|
# every run.
|
|
221
221
|
#
|
|
222
222
|
# 2. `.plot/state/last-pulse.json` — the bridge, written by `write_bridge` on
|
|
223
|
-
# the success path of `--stream` (
|
|
224
|
-
# (what /plot-pulse passes). Those are the two callers that produce a pulse
|
|
223
|
+
# the success path of `--stream` (unless PLOT_SCAN_RECORD=0) and `--log-pulse`
|
|
224
|
+
# (what /plot-pulse passes; not while the fleet's writer holds the bridge). Those are the two callers that produce a pulse
|
|
225
225
|
# for somebody to READ; plain `--json` is a query and records nothing. That
|
|
226
226
|
# is a CACHE WITH AN EXPIRY: `pulse-bridge.ts` discards it after 15 minutes
|
|
227
227
|
# and on a version mismatch, so it can only ever be a shortcut to an answer
|
|
@@ -311,7 +311,7 @@ while [ $# -gt 0 ]; do
|
|
|
311
311
|
# caught this: `conflicts: the scan writes NOTHING` and `fleet: scan is
|
|
312
312
|
# read-only`, both of which drive `--json`.
|
|
313
313
|
--json) as_json=1; build_doc=1 ;;
|
|
314
|
-
--stream) as_json=1; stream=1; build_doc=1; record=1 ;;
|
|
314
|
+
--stream) as_json=1; stream=1; build_doc=1; [ "${PLOT_SCAN_RECORD:-1}" = 0 ] || record=1 ;;
|
|
315
315
|
-h|--help) sed -n '2,12p' "$0"; exit 0 ;;
|
|
316
316
|
*) slug="$1" ;;
|
|
317
317
|
esac
|
|
@@ -5122,8 +5122,8 @@ fi
|
|
|
5122
5122
|
# each with `toMap`, which yields an empty Map for anything it cannot use, and
|
|
5123
5123
|
# `branchUrlBase` falls back to `''`. So a scan-written bridge serves the rows,
|
|
5124
5124
|
# the verdicts and the counts, with unknown ages and no branch links — degraded
|
|
5125
|
-
# in the direction the board already handles
|
|
5126
|
-
#
|
|
5125
|
+
# in the direction the board already handles. While the fleet runs, its
|
|
5126
|
+
# `writeScan` writes the full bridge and `--log-pulse` writes none.
|
|
5127
5127
|
#
|
|
5128
5128
|
# TEMP FILE PLUS RENAME, carrying the pid, exactly as `writeBridge` does and for
|
|
5129
5129
|
# the same reason: `rename` is atomic within a filesystem, so a board reading
|
|
@@ -5173,8 +5173,11 @@ write_bridge() {
|
|
|
5173
5173
|
# git rather than assuming the two agree.
|
|
5174
5174
|
local root file tmp
|
|
5175
5175
|
root=$(git rev-parse --show-toplevel 2>/dev/null) || return 0
|
|
5176
|
-
[ -n "$root" ] || return 0
|
|
5177
5176
|
file="$root/.plot/state/last-pulse.json"
|
|
5177
|
+
# `--log-pulse` leaves a bridge the fleet's writer holds (`fleetHoldsBridge`):
|
|
5178
|
+
# one writer while a fleet runs. A missing, stale or thin bridge, or a failed
|
|
5179
|
+
# ask, writes as before, so a repository with no board and no fleet keeps its history.
|
|
5180
|
+
[ "$log_pulse" = 1 ] && [ -f "$file" ] && node "$script_dir/board/plot-delta.mjs" --held < "$file" 2>/dev/null && return 0
|
|
5178
5181
|
mkdir -p "$root/.plot/state" 2>/dev/null || return 0
|
|
5179
5182
|
tmp="$file.$$.tmp"
|
|
5180
5183
|
# `at` is when the scan COMPLETED, which is what `pulse-bridge.ts:81` asks for
|