@plot-pm/board 0.22.1 → 0.23.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 +246 -230
- package/package.json +1 -1
- package/plot-config.sh +8 -1
- package/plot-dispatch.sh +56 -202
- package/plot-fleet-scan.sh +66 -36
- package/plot-host.sh +701 -306
- package/plot-plan-meta.sh +266 -148
- package/plot-pr-merged.sh +10 -13
- package/plot-state-receipt.sh +10 -10
- package/plot-worker-state.sh +102 -79
package/plot-fleet-scan.sh
CHANGED
|
@@ -403,11 +403,9 @@ fi
|
|
|
403
403
|
# degrades to strict and says so: an unverifiable claim of readiness is not
|
|
404
404
|
# readiness.
|
|
405
405
|
loose_verifiable=0
|
|
406
|
-
if [ "$loose" = 1 ]; then
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
loose_verifiable=1
|
|
410
|
-
fi
|
|
406
|
+
if [ "$loose" = 1 ] && [ "$do_fetch" = 1 ]; then
|
|
407
|
+
loose_backend=$("$script_dir/plot-host.sh" backend 2>/dev/null)
|
|
408
|
+
[ -n "$loose_backend" ] && [ "$loose_backend" != "none" ] && loose_verifiable=1
|
|
411
409
|
fi
|
|
412
410
|
|
|
413
411
|
# ---------------------------------------------------------------------------
|
|
@@ -469,7 +467,7 @@ fi
|
|
|
469
467
|
# small fixture — a cap of 2000 is otherwise unreachable in a test. It is a
|
|
470
468
|
# seam, not a knob: nothing in Plot sets it, and lowering it in real use buys
|
|
471
469
|
# nothing but the silent misses described above.
|
|
472
|
-
MERGE_SCAN_LIMIT=${PLOT_MERGE_SCAN_LIMIT:-
|
|
470
|
+
MERGE_SCAN_LIMIT=${PLOT_MERGE_SCAN_LIMIT:-20000}
|
|
473
471
|
# `%H %s` RATHER THAN `%s`, because the age rule needs the merge COMMIT and not
|
|
474
472
|
# only its sentence: a subject proves a branch for a plan only when its merge is
|
|
475
473
|
# not contained in the commit that added the plan file, and that is an ancestry
|
|
@@ -597,10 +595,32 @@ fi
|
|
|
597
595
|
# `REF_TMP` trap below replaced it, so every scan left one `tmp.*` directory of
|
|
598
596
|
# ~955 files behind (measured 2026-09-30).
|
|
599
597
|
HOST_STATE_CACHE=""
|
|
598
|
+
# WHAT THIS SCAN SPENT ON THE HOST, ON STDERR AND TAGGED like `listing:` and
|
|
599
|
+
# `terminal:` — `fleet-scan.ts`'s `onErrorLine` parses all three the same way.
|
|
600
|
+
# TypeScript sees only the in-process `askPrList` calls; the two `pr-list`
|
|
601
|
+
# calls in `prefill_pr_states` and every real `pr-state` call `host_pr_state
|
|
602
|
+
# --ask` makes are this script's own (#2815). It runs at exit, because
|
|
603
|
+
# `--stream`, which fleetd starts, leaves through its own `exit 0`, and it
|
|
604
|
+
# prints only under `--stream`: `--next` and the other modes promise silence on
|
|
605
|
+
# both streams, and no `--json` caller reads stderr. Registered BEFORE the
|
|
606
|
+
# cache, because the exit handler runs in registration order and removes the
|
|
607
|
+
# cache that holds the count. A scan that spent nothing prints no line.
|
|
608
|
+
plot_on_exit '[ "$stream" = 1 ] && [ -s "$HOST_STATE_CACHE/.spend" ] && printf "spend: %s\n" "$(wc -c < "$HOST_STATE_CACHE/.spend" | tr -d " ")" >&2'
|
|
600
609
|
if [ "$HOST_LOOKUP_OK" = 1 ]; then
|
|
601
610
|
plot_tmpdir HOST_STATE_CACHE fleet-host-state 2>/dev/null || HOST_STATE_CACHE=""
|
|
602
611
|
fi
|
|
603
612
|
|
|
613
|
+
# ONE LINE PER REAL HOST CALL, APPENDED RATHER THAN HELD IN A VARIABLE.
|
|
614
|
+
# `host_pr_state` is called from inside `$(...)` at two sites (`:1524`,
|
|
615
|
+
# `:4469`), and a variable it incremented would die with that subshell —
|
|
616
|
+
# exactly the trap `branch_state`'s own comment names above. The file
|
|
617
|
+
# survives every subshell this scan makes, because it is the same
|
|
618
|
+
# `HOST_STATE_CACHE` directory `host_pr_state`'s own per-branch cache
|
|
619
|
+
# already lives in and is cleaned up by.
|
|
620
|
+
spend_tick() {
|
|
621
|
+
[ -n "$HOST_STATE_CACHE" ] && printf '.' >> "$HOST_STATE_CACHE/.spend" 2>/dev/null
|
|
622
|
+
}
|
|
623
|
+
|
|
604
624
|
# The cache key. Shared by the join and by `host_pr_state`, because the two
|
|
605
625
|
# must agree on it EXACTLY: a prefill written under one spelling and read under
|
|
606
626
|
# another is a cache that silently never hits, which restores the per-branch
|
|
@@ -921,7 +941,7 @@ EOF
|
|
|
921
941
|
# the direction that errs costs a fabricated `NONE`. The MARKER carries the
|
|
922
942
|
# claim, so arrival decides and the row count does not.
|
|
923
943
|
[ "$arrived" = 1 ] || return 1
|
|
924
|
-
printf '1' > "$HOST_STATE_CACHE/.list-arrived" 2>/dev/null
|
|
944
|
+
printf '1' > "$HOST_STATE_CACHE/.list-arrived" 2>/dev/null
|
|
925
945
|
[ "$complete" = 1 ] && { printf '1' > "$HOST_STATE_CACHE/.list-complete" 2>/dev/null || true; }
|
|
926
946
|
# `ok`, AND A NEW WORD HERE WOULD STOP THE FLEET. `reachFrom`
|
|
927
947
|
# (`entry/branch-state.ts:113`) maps any word it does not know to `failed`, so
|
|
@@ -1041,12 +1061,13 @@ prefill_pr_states() {
|
|
|
1041
1061
|
# missing from the rich payload has NO row at all once the plain payload's
|
|
1042
1062
|
# OPEN rows are dropped below, and a missing row reads as "no PR".
|
|
1043
1063
|
#
|
|
1044
|
-
# OPEN FIRST, THEN
|
|
1045
|
-
# a rich OPEN row and a plain MERGED one, and the rank keeps OPEN —
|
|
1046
|
-
# seconds, and the next scan corrects it.
|
|
1064
|
+
# OPEN FIRST, THEN SETTLED. A PR that merges between the two calls then
|
|
1065
|
+
# carries a rich OPEN row and a plain MERGED one, and the rank keeps OPEN —
|
|
1066
|
+
# stale by seconds, and the next scan corrects it.
|
|
1047
1067
|
open_err=$("$script_dir/plot-host.sh" pr-list --state open --limit "$PR_LIST_LIMIT" --rich \
|
|
1048
1068
|
${_branch_args[@]+"${_branch_args[@]}"} \
|
|
1049
1069
|
</dev/null 2>&1 >"$open_list_out"); rc_open=$?
|
|
1070
|
+
spend_tick
|
|
1050
1071
|
# THE VERDICT IS THE WORSE OF THE TWO, never the last one. A rich call
|
|
1051
1072
|
# throttled while the plain one answers leaves `checks` absent for every open
|
|
1052
1073
|
# PR, so `--loose` degrades to strict — and a footer reading `host=ok` would
|
|
@@ -1060,25 +1081,26 @@ prefill_pr_states() {
|
|
|
1060
1081
|
# throttled host it would spend quota on a payload nothing reads.
|
|
1061
1082
|
pr_list_verdict "$rc_open" "$open_err"; _v_open=$_plv
|
|
1062
1083
|
case "$_v_open" in ok|partial) ;; *) HOST_VERDICT=$_v_open; return 0 ;; esac
|
|
1063
|
-
host_err=$("$script_dir/plot-host.sh" pr-list --state
|
|
1084
|
+
host_err=$("$script_dir/plot-host.sh" pr-list --state settled --limit "$PR_LIST_LIMIT" \
|
|
1064
1085
|
${_branch_args[@]+"${_branch_args[@]}"} \
|
|
1065
1086
|
</dev/null 2>&1 >"$host_list_out"); rc=$?
|
|
1087
|
+
spend_tick
|
|
1066
1088
|
pr_list_verdict "$rc" "$host_err"; _v_all=$_plv
|
|
1067
1089
|
pr_list_verdict_rank "$_v_open"; _r_open=$_plr
|
|
1068
1090
|
pr_list_verdict_rank "$_v_all"
|
|
1069
1091
|
if [ "$_r_open" -gt "$_plr" ]; then HOST_VERDICT=$_v_open; else HOST_VERDICT=$_v_all; fi
|
|
1070
1092
|
case "$HOST_VERDICT" in ok|partial) ;; *) return 0 ;; esac
|
|
1071
1093
|
# THE MERGE, AND THE TRAP IT AVOIDS. An open PR is in BOTH payloads — rich
|
|
1072
|
-
# from the `open` call, plain from the `
|
|
1073
|
-
# the dedup below. With the sort key exhausted, `sort` compares whole
|
|
1074
|
-
# and the plain row's `-` sentinel (0x2D) sorts before any letter: the
|
|
1075
|
-
# row wins every time and the rollup is lost for 100% of open PRs.
|
|
1094
|
+
# from the `open` call, plain from the `settled` call — and both rows rank 1
|
|
1095
|
+
# in the dedup below. With the sort key exhausted, `sort` compares whole
|
|
1096
|
+
# lines, and the plain row's `-` sentinel (0x2D) sorts before any letter: the
|
|
1097
|
+
# plain row wins every time and the rollup is lost for 100% of open PRs.
|
|
1076
1098
|
#
|
|
1077
|
-
# So the `
|
|
1078
|
-
# each branch contributes one OPEN row at most. Those rows are unused:
|
|
1079
|
-
# `open` call already answered for every open PR, with its rollup.
|
|
1099
|
+
# So the `settled` payload's OPEN rows are dropped before the concatenation,
|
|
1100
|
+
# and each branch contributes one OPEN row at most. Those rows are unused:
|
|
1101
|
+
# the `open` call already answered for every open PR, with its rollup.
|
|
1080
1102
|
#
|
|
1081
|
-
# THE COMPLETENESS COUNT IS TAKEN FROM THE `
|
|
1103
|
+
# THE COMPLETENESS COUNT IS TAKEN FROM THE `settled` PAYLOAD BEFORE THE FILTER.
|
|
1082
1104
|
# `.list-complete` compares a row count against `PR_LIST_LIMIT`, and a count
|
|
1083
1105
|
# taken after the filter can fall below the limit for a list that reached it
|
|
1084
1106
|
# — a truncated list then reads as whole, and a cache miss derives `NONE` for
|
|
@@ -1136,7 +1158,7 @@ prefill_pr_states() {
|
|
|
1136
1158
|
# Cache format: STATE<TAB>checks<TAB>draft — one line per branch.
|
|
1137
1159
|
# `checks` is one of: green, failing, pending, none, unknown (or empty when
|
|
1138
1160
|
# the response was not `--rich`); `draft` is true or false (or empty).
|
|
1139
|
-
printf '%s\t%s\t%s' "$st" "$chk" "$dft" > "$HOST_STATE_CACHE/$br" 2>/dev/null
|
|
1161
|
+
printf '%s\t%s\t%s' "$st" "$chk" "$dft" > "$HOST_STATE_CACHE/$br" 2>/dev/null
|
|
1140
1162
|
done <<EOF
|
|
1141
1163
|
$(printf '%s\n' "$js" \
|
|
1142
1164
|
| sed -n -e 's/.*"state":"\([A-Z]*\)","head":"\([^"]*\)","draft":\([a-z]*\),"checks":"\([a-z]*\)".*/\1 \4 \3 \2/p' \
|
|
@@ -1175,7 +1197,7 @@ EOF
|
|
|
1175
1197
|
# collide with one: `git check-ref-format` rejects a branch whose name starts
|
|
1176
1198
|
# with a dot, and the key encoding maps only `_` and `/`, so no branch key can
|
|
1177
1199
|
# begin with one either. The separation is git's rule, not a lucky prefix.
|
|
1178
|
-
printf '1' > "$HOST_STATE_CACHE/.list-arrived" 2>/dev/null
|
|
1200
|
+
printf '1' > "$HOST_STATE_CACHE/.list-arrived" 2>/dev/null
|
|
1179
1201
|
# THE LIST WAS WHOLE — a stronger claim than `.list-arrived`, and the only one
|
|
1180
1202
|
# that licenses deriving `NONE` from a cache miss.
|
|
1181
1203
|
#
|
|
@@ -1267,10 +1289,10 @@ EOF
|
|
|
1267
1289
|
return 1
|
|
1268
1290
|
}
|
|
1269
1291
|
if _list_whole "$host_err" && _list_whole "$open_err"; then
|
|
1270
|
-
printf '1' > "$HOST_STATE_CACHE/.list-complete" 2>/dev/null
|
|
1292
|
+
printf '1' > "$HOST_STATE_CACHE/.list-complete" 2>/dev/null
|
|
1271
1293
|
elif [ "$_pr_rows" -gt 0 ] && [ "$_pr_rows" -lt "$PR_LIST_LIMIT" ] \
|
|
1272
1294
|
&& [ "$_pr_open_rows" -lt "$PR_LIST_LIMIT" ] 2>/dev/null; then
|
|
1273
|
-
printf '1' > "$HOST_STATE_CACHE/.list-complete" 2>/dev/null
|
|
1295
|
+
printf '1' > "$HOST_STATE_CACHE/.list-complete" 2>/dev/null
|
|
1274
1296
|
fi
|
|
1275
1297
|
report_listing
|
|
1276
1298
|
}
|
|
@@ -1354,6 +1376,7 @@ host_pr_state() { # $1=branch [--ask] → OPEN|MERGED|CLOSED|NONE|-
|
|
|
1354
1376
|
if [ "$ask" = "--ask" ]; then
|
|
1355
1377
|
# Exit code first: non-zero is a transport failure and its stdout is not an
|
|
1356
1378
|
# answer. Only then is the payload read.
|
|
1379
|
+
spend_tick
|
|
1357
1380
|
if js=$("$script_dir/plot-host.sh" pr-state "$br" </dev/null 2>/dev/null); then
|
|
1358
1381
|
st=$(printf '%s' "$js" | sed -n 's/.*"state":"\([A-Z]*\)".*/\1/p')
|
|
1359
1382
|
[ -n "$st" ] || st='-'
|
|
@@ -3111,13 +3134,17 @@ for line in sys.stdin:
|
|
|
3111
3134
|
# follow: `Tracer: yes` (1/0), a `Spike approved:` record (1/0), the wave
|
|
3112
3135
|
# index of each annotated branch (one entry per branch), and their count.
|
|
3113
3136
|
# Facts only: which slice holds the plan spike is the domain answer, spikeSliceOf.
|
|
3114
|
-
spikes = [str(i) for i, w in enumerate(d.get("waves", []) or [])
|
|
3115
|
-
|
|
3137
|
+
spikes = [str(i) for i, w in enumerate(d.get("waves", []) or []) for b in w.get("branches", []) or [] if b.get("spike")]
|
|
3138
|
+
# unread_branch_items: a non-claim list item naming a branch, plan-level —
|
|
3139
|
+
# `landed()` (packages/domain/src/rules/deliverable.ts) refuses delivery on
|
|
3140
|
+
# one. Rendered here as its own JSON array (json.dumps escapes everything
|
|
3141
|
+
# the bash side would otherwise need json_str for), so the consumer below
|
|
3142
|
+
# has only to store the row — never to parse or re-escape one.
|
|
3143
|
+
unread_json = json.dumps([{k: u.get(k) or "" for k in ("wave", "branch", "line")} for u in d.get("unread_branch_items", []) or []])
|
|
3116
3144
|
print("\t".join(["P", clean(f), clean(d.get("phase", "")) or "-", clean(d.get("type", "")) or "-",
|
|
3117
|
-
"1" if d.get("tracer") else "0",
|
|
3118
|
-
"
|
|
3145
|
+
"1" if d.get("tracer") else "0", "1" if d.get("spike_approved_raw") else "0",
|
|
3146
|
+
",".join(spikes) or "-", str(len(spikes)), clean(unread_json)]))
|
|
3119
3147
|
for i, w in enumerate(d.get("waves", []) or []):
|
|
3120
|
-
name = w.get("name")
|
|
3121
3148
|
for b in w.get("branches", []) or []:
|
|
3122
3149
|
ref = b.get("branch") or ""
|
|
3123
3150
|
# Not every prefixed token in a ## Branches section is
|
|
@@ -3149,7 +3176,7 @@ for line in sys.stdin:
|
|
|
3149
3176
|
"W", f, str(i), ref, str(b.get("deferred")).lower(),
|
|
3150
3177
|
(b.get("deferred_reason") or "-"),
|
|
3151
3178
|
(",".join(waits_on) if isinstance(waits_on, list) else waits_on) or "-",
|
|
3152
|
-
name or "-", b.get("claimed") or "-", ",".join(b.get("commits") or []) or "-"]))
|
|
3179
|
+
w.get("name") or "-", b.get("claimed") or "-", ",".join(b.get("commits") or []) or "-"]))
|
|
3153
3180
|
' 2>/dev/null) || records=""
|
|
3154
3181
|
|
|
3155
3182
|
local kind file rest
|
|
@@ -3158,8 +3185,10 @@ for line in sys.stdin:
|
|
|
3158
3185
|
case "$kind" in
|
|
3159
3186
|
P)
|
|
3160
3187
|
plan_meta_files+=("$file")
|
|
3161
|
-
# `rest` is "<phase>\t<type>\t<tracer>\t<spike approved>\t<spike waves>\t<spikes>"
|
|
3162
|
-
#
|
|
3188
|
+
# `rest` is "<phase>\t<type>\t<tracer>\t<spike approved>\t<spike waves>\t<spikes>\t<unread JSON>".
|
|
3189
|
+
# The last five travel together; `unread_branch_items` is JSON text
|
|
3190
|
+
# with no raw tab or newline byte, so it cannot be mistaken for a
|
|
3191
|
+
# field boundary.
|
|
3163
3192
|
IFS=$'\t' read -r _ph _ty _sp <<< "$rest"
|
|
3164
3193
|
plan_meta_phases+=("${_ph#-}")
|
|
3165
3194
|
plan_meta_types+=("${_ty#-}")
|
|
@@ -3378,14 +3407,12 @@ if [ -n "$slug" ]; then
|
|
|
3378
3407
|
# Same precedence as the worktree form: the dated plan file first, then the
|
|
3379
3408
|
# active index, then delivered. `ref_ls` is filtered rather than globbed
|
|
3380
3409
|
# because the ref has no shell to expand `*`.
|
|
3381
|
-
found=0
|
|
3382
3410
|
for cand in $(ref_ls "$PLAN_DIR" | grep "$slug\.md$") \
|
|
3383
3411
|
$(ref_ls "$ACTIVE_DIR" | grep "/$slug\.md$") \
|
|
3384
3412
|
$(ref_ls "$DELIVERED_DIR" | grep "/$slug\.md$"); do
|
|
3385
3413
|
add_ref_plan "$cand"
|
|
3386
|
-
[ ${#plans[@]} -gt 0 ] &&
|
|
3414
|
+
[ ${#plans[@]} -gt 0 ] && break
|
|
3387
3415
|
done
|
|
3388
|
-
[ "$found" = 1 ] || true
|
|
3389
3416
|
else
|
|
3390
3417
|
for cand in "$PLAN_DIR"*"$slug".md "$ACTIVE_DIR$slug.md" "$DELIVERED_DIR$slug.md"; do
|
|
3391
3418
|
[ -e "$cand" ] && {
|
|
@@ -5014,6 +5041,11 @@ for plan in "${plans[@]}"; do
|
|
|
5014
5041
|
# anything reads.
|
|
5015
5042
|
json_plan+=",\"phase\":\"$(json_str "$plan_phase")\""
|
|
5016
5043
|
[ "${_plan_spike[0]}" = 1 ] && json_plan+=",\"tracer\":true"
|
|
5044
|
+
# A non-claim list item naming a branch, plan-level — `landed()`
|
|
5045
|
+
# (packages/domain/src/rules/deliverable.ts) refuses delivery on one.
|
|
5046
|
+
# The filter already rendered this as JSON (json.dumps), so there is
|
|
5047
|
+
# nothing left to escape here.
|
|
5048
|
+
json_plan+=",\"unreadBranchItems\":${_plan_spike[4]:-[]}"
|
|
5017
5049
|
json_plan+=",\"waves\":[$json_waves]}"
|
|
5018
5050
|
json_plans+="${json_plans:+,}$json_plan"
|
|
5019
5051
|
# THE STREAM'S POINT: this plan is fully derived, so a consumer can render
|
|
@@ -5189,7 +5221,6 @@ read_previous_pulse() {
|
|
|
5189
5221
|
# here leaves PREVIOUS_PULSE empty, which reads as a first run — the same
|
|
5190
5222
|
# answer the scan gave before this existed.
|
|
5191
5223
|
PREVIOUS_PULSE=$(cat "$file" 2>/dev/null | tr -d '\n') || PREVIOUS_PULSE=""
|
|
5192
|
-
return 0
|
|
5193
5224
|
}
|
|
5194
5225
|
|
|
5195
5226
|
write_bridge() {
|
|
@@ -5216,7 +5247,6 @@ write_bridge() {
|
|
|
5216
5247
|
return 0
|
|
5217
5248
|
}
|
|
5218
5249
|
mv -f "$tmp" "$file" 2>/dev/null || rm -f "$tmp" 2>/dev/null
|
|
5219
|
-
return 0
|
|
5220
5250
|
}
|
|
5221
5251
|
|
|
5222
5252
|
# THE READING, COMPOSED ONCE. Two consumers read it — `--json`/`--stream` print
|