@plot-pm/board 0.16.2 → 0.17.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 +258 -146
- package/package.json +3 -6
- package/plot-agent-manifest.sh +76 -15
- package/plot-agent-monitor.sh +43 -5
- package/plot-approve.sh +224 -73
- package/plot-config.sh +14 -14
- package/plot-deliver.sh +10 -741
- package/plot-dispatch.sh +282 -107
- package/plot-fleet-scan.sh +867 -170
- package/plot-host.sh +310 -76
- package/plot-monitor-subject.sh +61 -10
- package/plot-plan-meta.sh +155 -139
- package/plot-pr-merged.sh +16 -0
- package/plot-reap.sh +61 -28
- package/plot-state-receipt.sh +12 -2
- package/plot-tmp.sh +31 -3
- package/plot-worker-state.sh +458 -24
- package/plot-build-monitor.sh +0 -435
- package/plot-resolve-artifact.sh +0 -423
- package/plot-transcript-quiet.sh +0 -170
- package/plot-worker-monitor.sh +0 -705
package/plot-reap.sh
CHANGED
|
@@ -44,12 +44,11 @@
|
|
|
44
44
|
# written. The scan reports; nothing reaped. Measured 2026-08-25 on this
|
|
45
45
|
# estate: 56 worktrees, 42 of them dispatch trees, of which 29 were finished.
|
|
46
46
|
#
|
|
47
|
-
# WHY A SCRIPT RATHER THAN AN AGENT (Manifesto Principle 3
|
|
48
|
-
#
|
|
49
|
-
#
|
|
50
|
-
#
|
|
51
|
-
#
|
|
52
|
-
# judgement's absence is exactly what licenses the delete.
|
|
47
|
+
# WHY A SCRIPT RATHER THAN AN AGENT (Manifesto Principle 3): every refusal
|
|
48
|
+
# below is a MEASUREMENT, not a judgement. Is a process alive; is the tree
|
|
49
|
+
# dirty; did the host merge the PR. An agent asked "is this safe to delete?"
|
|
50
|
+
# can talk itself past any of the three. A script cannot, and judgement's
|
|
51
|
+
# absence is exactly what licenses the delete.
|
|
53
52
|
#
|
|
54
53
|
# AND THE DECIDING IS NOT HERE. This script GATHERS the readings, asks
|
|
55
54
|
# `packages/domain/src/rules/reapable.ts`, and ACTS on the answer; it holds no
|
|
@@ -433,8 +432,9 @@ LOG_DIR="$WT_ROOT"
|
|
|
433
432
|
#
|
|
434
433
|
# WHICH LOG THIS IS, since the plan says "the dispatcher log" and the estate
|
|
435
434
|
# holds two shapes of one. `plot-resolve-<branch>` is keyed by BRANCH with its
|
|
436
|
-
# slashes flattened (`
|
|
437
|
-
# this loop is removing.
|
|
435
|
+
# slashes flattened (`agentLogPath`'s `resolve` kind), so it maps one-to-one
|
|
436
|
+
# onto the worktree this loop is removing. The artifact repair that wrote it
|
|
437
|
+
# was retired on 2026-10-03; the sweep removes the logs still on disk. `plot-dispatch-<slug>` is keyed by PLAN and opened for
|
|
438
438
|
# APPEND across every dispatch of that plan — `dispatch.ts:150` states it: "a
|
|
439
439
|
# dispatcher log belongs to a plan, a worker log to a branch". Reaping one
|
|
440
440
|
# branch of a five-branch plan must not delete the record the other four are
|
|
@@ -656,8 +656,25 @@ while IFS=$'\037' read -r wt br prunable; do
|
|
|
656
656
|
# not about whether a worktree may go. The filter runs before `head`, so a
|
|
657
657
|
# correction beside a real file names the real file.
|
|
658
658
|
marker=false
|
|
659
|
-
ls "$wt"/PLOT-BLOCKED* >/dev/null
|
|
660
|
-
|
|
659
|
+
marker_file=$(ls "$wt"/PLOT-BLOCKED* 2>/dev/null | head -1)
|
|
660
|
+
[ -n "$marker_file" ] && marker=true
|
|
661
|
+
# The marker's own line is excluded from `dirty`, which otherwise answers
|
|
662
|
+
# `uncommitted-changes` for a desk this slice reads `refused-empty` instead:
|
|
663
|
+
# the marker is a question for a person, not unlanded work, and the two
|
|
664
|
+
# refusals must not both fire for the one line that names it.
|
|
665
|
+
dirty=$(desk_dirt "$wt" | grep -v 'PLOT-BLOCKED' | head -1)
|
|
666
|
+
|
|
667
|
+
# markerRecordsWork — does the desk hold anything besides its marker: a
|
|
668
|
+
# dirty path that is not the marker itself (`$dirty`, already filtered
|
|
669
|
+
# above), or a file-changing commit beyond the default branch. Read only
|
|
670
|
+
# when a marker is present — `firstReapRefusal` does not consult this field
|
|
671
|
+
# otherwise.
|
|
672
|
+
marker_records_work=false
|
|
673
|
+
if [ "$marker" = true ]; then
|
|
674
|
+
if [ -n "$dirty" ] || [ "$(real_commits "$wt" "origin/$DEFAULT..HEAD")" != 0 ]; then
|
|
675
|
+
marker_records_work=true
|
|
676
|
+
fi
|
|
677
|
+
fi
|
|
661
678
|
|
|
662
679
|
# The host: whether ANY PR for this branch merged.
|
|
663
680
|
#
|
|
@@ -726,6 +743,7 @@ while IFS=$'\037' read -r wt br prunable; do
|
|
|
726
743
|
verdict=$(PLOT_BRANCH="$short" PLOT_DEFAULT="$DEFAULT" PLOT_PID="$pid" \
|
|
727
744
|
PLOT_DIRTY="$dirty" PLOT_MARKER="$marker" PLOT_MERGE="$merge" \
|
|
728
745
|
PLOT_UNPUSHED="$unpushed" PLOT_RULE="$RULE" \
|
|
746
|
+
PLOT_MARKER_RECORDS_WORK="$marker_records_work" \
|
|
729
747
|
node --input-type=module - <<'NODE_EOF' 2>/dev/null
|
|
730
748
|
// Imported from an ABSOLUTE path derived from this script, never from the
|
|
731
749
|
// cwd. The reaper runs with its cwd wherever the operator invoked it and the
|
|
@@ -746,6 +764,7 @@ const problem = firstReapRefusal({
|
|
|
746
764
|
workerPid: process.env.PLOT_PID === "" ? null : process.env.PLOT_PID,
|
|
747
765
|
dirtyPath: process.env.PLOT_DIRTY,
|
|
748
766
|
blockedMarker: process.env.PLOT_MARKER === "true",
|
|
767
|
+
markerRecordsWork: process.env.PLOT_MARKER_RECORDS_WORK === "true",
|
|
749
768
|
merge: process.env.PLOT_MERGE,
|
|
750
769
|
unpushed: process.env.PLOT_UNPUSHED === "unknown"
|
|
751
770
|
? "unknown"
|
|
@@ -792,6 +811,27 @@ NODE_EOF
|
|
|
792
811
|
# a missing log is the desired state, not an event.
|
|
793
812
|
logs=$(present_logs "$short")
|
|
794
813
|
|
|
814
|
+
# THE MARKER MOVES, IT IS NOT DROPPED. A tree that reached `reap` with
|
|
815
|
+
# `marker=true` passed `firstReapRefusal` only because `markerRecordsWork`
|
|
816
|
+
# was measured false — `rules/desk-lifecycle.ts`'s `refused-empty`. The
|
|
817
|
+
# marker's text is evidence of a question somebody asked even though the
|
|
818
|
+
# desk holding it is otherwise empty, so it is copied to REFUSALS_LOG before
|
|
819
|
+
# the worktree goes. A FAILED COPY KEEPS THE DESK: the marker is the only
|
|
820
|
+
# record of the question, and a reap that lost both would make the evidence
|
|
821
|
+
# exactly as unrecoverable as the desk it lived in.
|
|
822
|
+
if [ "$DRY" -eq 0 ] && [ "$marker" = true ] && [ -n "$marker_file" ]; then
|
|
823
|
+
refusals_log="$ROOT/.plot/state/refusals.tsv"
|
|
824
|
+
if mkdir -p "$(dirname "$refusals_log")" 2>/dev/null \
|
|
825
|
+
&& printf '%s\t%s\t%s\n' "$(date -u +%Y-%m-%dT%H:%M:%SZ)" "$label" \
|
|
826
|
+
"$(tr '\n\t' ' ' < "$marker_file" 2>/dev/null)" >> "$refusals_log" 2>/dev/null; then
|
|
827
|
+
why="$why, marker saved to .plot/state/refusals.tsv"
|
|
828
|
+
else
|
|
829
|
+
printf '%-8s %-52s %s\n' "keep" "$label" \
|
|
830
|
+
"could not save PLOT-BLOCKED text to .plot/state/refusals.tsv — desk kept"
|
|
831
|
+
kept=$((kept+1)); continue
|
|
832
|
+
fi
|
|
833
|
+
fi
|
|
834
|
+
|
|
795
835
|
reap=$((reap+1))
|
|
796
836
|
if [ "$DRY" -eq 1 ]; then
|
|
797
837
|
printf '%-8s %-52s %s\n' "would" "$label" "$why${logs:+, log $logs}"
|
|
@@ -1035,25 +1075,18 @@ fi
|
|
|
1035
1075
|
case "$ACTIVE_DIR_SWEEP" in /*) ;; *) ACTIVE_DIR_SWEEP="$ROOT/$ACTIVE_DIR_SWEEP" ;; esac
|
|
1036
1076
|
|
|
1037
1077
|
# Does this branch carry ONLY empty claim commits? The scan's definition,
|
|
1038
|
-
# applied to
|
|
1039
|
-
# reads `origin/`.
|
|
1078
|
+
# applied to LOCAL refs — this sweep runs over local branches, where the scan
|
|
1079
|
+
# reads `origin/`. ONE `board/plot-empty-claim.mjs` call answers every branch;
|
|
1080
|
+
# a branch it does not answer `<branch>\t0` for, a missing bundle included,
|
|
1081
|
+
# carries real work and stays.
|
|
1082
|
+
EMPTY_CLAIMS=$(git for-each-ref --format='%(refname:short)' refs/heads/ 2>/dev/null |
|
|
1083
|
+
while IFS= read -r br; do
|
|
1084
|
+
git log --boundary --format="${br//%/%%}%x09%m%x09%H%x09%T%x09%P%x09%s" \
|
|
1085
|
+
"origin/$DEFAULT..$br" -- </dev/null 2>/dev/null
|
|
1086
|
+
done | node "$(dirname "${BASH_SOURCE[0]}")/board/plot-empty-claim.mjs" 2>/dev/null) || EMPTY_CLAIMS=""
|
|
1087
|
+
|
|
1040
1088
|
sweep_is_empty_claim() { # $1=branch
|
|
1041
|
-
|
|
1042
|
-
ahead=$(git rev-list --count "origin/$DEFAULT..$br" 2>/dev/null || echo 0)
|
|
1043
|
-
[ "${ahead:-0}" -gt 0 ] || return 1 # nothing of its own → merged work, not a claim
|
|
1044
|
-
for c in $(git rev-list "origin/$DEFAULT..$br" </dev/null 2>/dev/null); do
|
|
1045
|
-
subj=$(git log -1 --format=%s "$c" </dev/null 2>/dev/null)
|
|
1046
|
-
case "$subj" in
|
|
1047
|
-
"plot: claim "*)
|
|
1048
|
-
# Titled AND empty. Both, or it counts as real work.
|
|
1049
|
-
if [ "$(git rev-parse "$c^{tree}" </dev/null 2>/dev/null)" \
|
|
1050
|
-
= "$(git rev-parse "$c^^{tree}" </dev/null 2>/dev/null)" ]; then
|
|
1051
|
-
continue
|
|
1052
|
-
fi ;;
|
|
1053
|
-
esac
|
|
1054
|
-
real=$((real+1))
|
|
1055
|
-
done
|
|
1056
|
-
[ "$real" = "0" ]
|
|
1089
|
+
printf '%s\n' "$EMPTY_CLAIMS" | grep -qxF "$1 0"
|
|
1057
1090
|
}
|
|
1058
1091
|
|
|
1059
1092
|
# How the plan annotation classified this claim — the scan's `claim_disposition`,
|
package/plot-state-receipt.sh
CHANGED
|
@@ -165,11 +165,17 @@ _action_receipt_dir() {
|
|
|
165
165
|
# adapter — a script name in a controller is a boundary crossing no spawn
|
|
166
166
|
# counter can see. So the shared filename is the action word, and mapping a
|
|
167
167
|
# script back to it happens HERE, on the side that reads command lines.
|
|
168
|
+
#
|
|
169
|
+
# `plot-deliver.sh` maps to `deliver` here, same as always — `release` is a
|
|
170
|
+
# SEPARATE action sharing that script, and only `plot-controller-gate.sh` can
|
|
171
|
+
# tell the two calls apart (by whether `--release` rode along), so it passes
|
|
172
|
+
# the action word directly rather than the script name for that one case.
|
|
168
173
|
_action_of() { # $1=script name or action word → the action, or nothing
|
|
169
174
|
case "${1##*/}" in
|
|
170
175
|
plot-dispatch.sh|dispatch) printf 'dispatch\n' ;;
|
|
171
176
|
plot-approve.sh|approve) printf 'approve\n' ;;
|
|
172
177
|
plot-deliver.sh|deliver) printf 'deliver\n' ;;
|
|
178
|
+
release) printf 'release\n' ;;
|
|
173
179
|
esac
|
|
174
180
|
}
|
|
175
181
|
|
|
@@ -231,7 +237,7 @@ if [ "${BASH_SOURCE[0]}" = "${0}" ]; then
|
|
|
231
237
|
action_reason="$*"
|
|
232
238
|
if [ -z "$action_script" ] || [ -z "$action_subject" ] || [ -z "$action_reason" ]; then
|
|
233
239
|
echo "plot-state-receipt: --unowned-action needs an action, a subject and a reason." >&2
|
|
234
|
-
echo " usage: plot-state-receipt.sh --unowned-action <dispatch|approve|deliver> <slug> <reason>" >&2
|
|
240
|
+
echo " usage: plot-state-receipt.sh --unowned-action <dispatch|approve|deliver|release> <slug> <reason>" >&2
|
|
235
241
|
echo "" >&2
|
|
236
242
|
echo " The reason is required because each use names a routing gap, and a gap" >&2
|
|
237
243
|
echo " nobody wrote down is one nobody closes. Where the board IS running, the" >&2
|
|
@@ -240,13 +246,17 @@ if [ "${BASH_SOURCE[0]}" = "${0}" ]; then
|
|
|
240
246
|
fi
|
|
241
247
|
# The action word, or the script name — an operator reaching for this has
|
|
242
248
|
# just read a refusal naming a script, so both spellings are accepted.
|
|
249
|
+
# `release` has no script of its own (`plot-deliver.sh --release` shares
|
|
250
|
+
# `plot-deliver.sh`, which already names `deliver`), so only the bare word
|
|
251
|
+
# is accepted for it.
|
|
243
252
|
case "$action_script" in
|
|
244
253
|
dispatch|plot-dispatch.sh) action_script="dispatch" ;;
|
|
245
254
|
approve|plot-approve.sh) action_script="approve" ;;
|
|
246
255
|
deliver|plot-deliver.sh) action_script="deliver" ;;
|
|
256
|
+
release) action_script="release" ;;
|
|
247
257
|
*)
|
|
248
258
|
echo "plot-state-receipt: '$action_script' is not a controller-owned action." >&2
|
|
249
|
-
echo " The
|
|
259
|
+
echo " The four are: dispatch, approve, deliver, release." >&2
|
|
250
260
|
exit 2
|
|
251
261
|
;;
|
|
252
262
|
esac
|
package/plot-tmp.sh
CHANGED
|
@@ -59,22 +59,50 @@ _plot_tmp_register() {
|
|
|
59
59
|
# unlisted. While `__plot_tmp_busy` is set, the signal handler records the
|
|
60
60
|
# signal in `__plot_tmp_pending` and returns; `_plot_tmp_create` handles it once
|
|
61
61
|
# the path is registered.
|
|
62
|
+
#
|
|
63
|
+
# A SUBSHELL HOLDS THE SIGNAL ITSELF. bash resets caught traps in `$(…)` and
|
|
64
|
+
# `( … )`, so there the handler above is not installed and a TERM between
|
|
65
|
+
# `mktemp` and the registration ends the subshell with the path unlisted. The
|
|
66
|
+
# owner's cleanup then runs and cannot remove it. `plot-host.sh`'s
|
|
67
|
+
# `pr_list_call` creates `plot-host-prlist-err.*` this way, inside
|
|
68
|
+
# `_raw="$(pr_list_call …)"`, and CI run 37052327801 left one when the board
|
|
69
|
+
# test teardown sent its process group TERM. Inside a subshell
|
|
70
|
+
# (`BASH_SUBSHELL` > 0; bash 3.2 has no `BASHPID`) the creation installs
|
|
71
|
+
# handlers that only record the signal, and after the registration it restores
|
|
72
|
+
# the defaults and exits with 128 + the signal's number. It does not run the
|
|
73
|
+
# cleanup: the registry belongs to the owner, which received the same group
|
|
74
|
+
# signal and removes the path when the subshell has ended.
|
|
62
75
|
__plot_tmp_busy=''
|
|
63
76
|
__plot_tmp_pending=''
|
|
64
77
|
|
|
65
78
|
# _plot_tmp_create VAR prefix [-d] — create, register, assign to VAR.
|
|
66
79
|
_plot_tmp_create() {
|
|
67
|
-
local __plot_tmp_new __plot_tmp_rc
|
|
80
|
+
local __plot_tmp_new __plot_tmp_rc __plot_tmp_sub=''
|
|
68
81
|
__plot_tmp_busy=1
|
|
82
|
+
if [ "${BASH_SUBSHELL:-0}" -gt 0 ]; then
|
|
83
|
+
__plot_tmp_sub=1
|
|
84
|
+
trap '__plot_tmp_pending="INT 2"' INT
|
|
85
|
+
trap '__plot_tmp_pending="TERM 15"' TERM
|
|
86
|
+
trap '__plot_tmp_pending="PIPE 13"' PIPE
|
|
87
|
+
fi
|
|
69
88
|
if [ "${3:-}" = -d ]; then
|
|
70
89
|
__plot_tmp_new=$(mktemp -d "${TMPDIR:-/tmp}/plot-$2.XXXXXX")
|
|
71
90
|
else
|
|
72
91
|
__plot_tmp_new=$(mktemp "${TMPDIR:-/tmp}/plot-$2.XXXXXX")
|
|
73
92
|
fi
|
|
74
93
|
__plot_tmp_rc=$?
|
|
75
|
-
|
|
94
|
+
# THE PATH IS REGISTERED WHEN IT EXISTS, whatever the status says. bash 3.2
|
|
95
|
+
# reports 143 for `$(mktemp …)` when a trap ran during it, although `mktemp`
|
|
96
|
+
# created the path and printed it; a status-only test leaves that path
|
|
97
|
+
# unlisted.
|
|
98
|
+
if [ -n "$__plot_tmp_new" ] && { [ -e "$__plot_tmp_new" ] || [ "$__plot_tmp_rc" -eq 0 ]; }; then
|
|
99
|
+
_plot_tmp_register p "$__plot_tmp_new"
|
|
100
|
+
fi
|
|
76
101
|
__plot_tmp_busy=''
|
|
77
|
-
if [ -n "$
|
|
102
|
+
if [ -n "$__plot_tmp_sub" ]; then
|
|
103
|
+
trap - INT TERM PIPE
|
|
104
|
+
[ -z "$__plot_tmp_pending" ] || exit $((128 + ${__plot_tmp_pending#* }))
|
|
105
|
+
elif [ -n "$__plot_tmp_pending" ]; then
|
|
78
106
|
# shellcheck disable=SC2086 # "<name> <number>", split on purpose
|
|
79
107
|
_plot_tmp_on_signal $__plot_tmp_pending
|
|
80
108
|
fi
|