@plot-pm/board 0.20.0 → 0.22.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/plot-plan-meta.sh CHANGED
@@ -329,7 +329,7 @@ if [ ${#files[@]} -eq 0 ] && [ ${#missing[@]} -eq 0 ]; then
329
329
  fi
330
330
 
331
331
  for f in ${missing[@]+"${missing[@]}"}; do
332
- printf '{"file":"%s","format":"none","error":"file not found","phase_raw":"","phase":"NONE","phase_alt_raw":"","phase_alt":"NONE","type":"","title":"","sprint":"","story":"","assignee":"","branches":[],"prs":[],"deferred_prs":[],"issues":[],"malformed_prs":[],"changelog":[],"long_wave_names":[],"unread_branch_headings":[],"unread_waits":[],"review_raw":"","review":"NONE","impl_raw":"","impl":"NONE","design_raw":"","spike_approved_raw":"","approved_raw":"","released_raw":"","delivered_raw":"","verified_raw":"","started_raw":[]}\n' \
332
+ printf '{"file":"%s","format":"none","error":"file not found","phase_raw":"","phase":"NONE","phase_alt_raw":"","phase_alt":"NONE","type":"","title":"","sprint":"","story":"","assignee":"","branches":[],"prs":[],"deferred_prs":[],"issues":[],"ticket":"","malformed_prs":[],"changelog":[],"long_wave_names":[],"unread_branch_headings":[],"unread_waits":[],"review_raw":"","review":"NONE","impl_raw":"","impl":"NONE","design_raw":"","spike_approved_raw":"","approved_raw":"","released_raw":"","delivered_raw":"","verified_raw":"","started_raw":[]}\n' \
333
333
  "$(printf '%s' "$f" | sed 's/\\/\\\\/g; s/"/\\"/g')"
334
334
  done
335
335
 
@@ -519,7 +519,7 @@ function reset_state() {
519
519
  delete branches; n_branches = 0
520
520
  delete prs; n_prs = 0; delete dprs; n_dprs = 0
521
521
  delete malformed_prs; n_malformed_prs = 0
522
- fm_issue = ""; canon_issue = ""
522
+ fm_issue = ""; canon_issue = ""; fm_ticket = ""
523
523
  delete issues; n_issues = 0
524
524
  delete wave_names; delete wave_of; delete wave_seq; delete wave_count
525
525
  delete deferred_of; delete deferred_why; delete claimed_of; delete ordered_b; delete spike_of; n_waves = 0
@@ -672,7 +672,10 @@ function emit_record( fmt, praw, palt_raw, traw, title, sprint, story, assigne
672
672
  else
673
673
  out = out (i > 1 ? "," : "") sorted_i[i]
674
674
  }
675
- out = out "],\"malformed_prs\":["
675
+ # `ticket:` is a frontmatter-only field: there is no canonical `## Status`
676
+ # body counterpart, unlike `Issue:`. It exists for a Must-have whose plan
677
+ # names its tracker key only in frontmatter, not on an `Issue:` line.
678
+ out = out "],\"ticket\":\"" jesc(strip_placeholder(fm_ticket)) "\",\"malformed_prs\":["
676
679
  for (i = 1; i <= n_malformed_prs; i++) out = out (i > 1 ? "," : "") "\"" jesc(malformed_prs[i]) "\""
677
680
  out = out "]"
678
681
  # Document order, never sorted: a changelog is a narrative sequence, and the
@@ -1037,6 +1040,7 @@ in_fm {
1037
1040
  else if (lower ~ /^sprint:/ && fm_sprint == "") fm_sprint = val_after_colon($0)
1038
1041
  else if (lower ~ /^story:/ && fm_story == "") fm_story = val_after_colon($0)
1039
1042
  else if (lower ~ /^issue:/ && fm_issue == "") fm_issue = val_after_colon($0)
1043
+ else if (lower ~ /^ticket:/ && fm_ticket == "") fm_ticket = val_after_colon($0)
1040
1044
  else if (lower ~ /^assignee:/ && fm_assignee == "") fm_assignee = val_after_colon($0)
1041
1045
  else if (lower ~ /^review:/ && fm_review == "") fm_review = val_after_colon($0)
1042
1046
  else if (lower ~ /^impl:/ && fm_impl == "") fm_impl = val_after_colon($0)
package/plot-pr-merged.sh CHANGED
@@ -34,41 +34,26 @@
34
34
  # `mayRemove` in the rule, asserted over all nine combinations of the two
35
35
  # readings, and exactly one of them permits a removal.
36
36
  #
37
- # WHY THIS STILL ASKS `gh` AND NOT `plot-host.sh`. Measured 2026-09-06, and it
38
- # is the answer to a question this file's exemption in
39
- # `scripts/check-host-cli-callers.sh` was left open for.
40
- #
41
- # `plot-host.sh pr-merged` prints `merged`/`not-merged`/`unknown`, three words
42
- # that read like the three readings below. THEY DO NOT MATCH. An ABSENT CLI
43
- # arrives from the adapter as `not-merged`, where `_plot_merged_lookup` answers
44
- # `unaskable`:
45
- #
46
- # plot-host.sh pr-merged <branch> → not-merged (exit 0)
47
- # _plot_merged_lookup <branch> → unaskable
48
- #
49
- # The cause is the adapter's `is_lookup_miss`. A missing binary makes the shell
50
- # say `bash: gh: command not found`, and that matches the same `not found` it
51
- # uses to recognise a genuine "no pull requests found" — one phrase covering two
52
- # conditions the rule below exists to keep apart.
53
- #
54
- # THE DIRECTION IS WHY IT BLOCKS RATHER THAN ANNOYS. `not-merged` reads as
55
- # `none` — the host spoke and said nothing merged — so `mayRemove` may permit a
56
- # removal where `unaskable` refuses. `plot-release-refs.sh` deletes remote refs
57
- # on this answer and a deleted ref is not re-creatable.
58
- #
59
- # AND `pr_open` HAS NO OP TO CALL AT ALL. It needs found/none/unaskable about
60
- # ANY open PR; `pr-state` answers about ONE — the newest — and reports a failed
61
- # lookup with the same `state:"NONE"` payload as a real absence. It can express
62
- # neither "any" nor "unaskable".
63
- #
64
- # THE COST WAS MEASURED TOO, and it is the smaller objection. Ten sequential
65
- # calls on this machine: 4.75 s direct, 9.25 s through the adapter — +450 ms per
66
- # branch, from the connector's slot and budget accounting rather than from the
67
- # spawn. Across the 48 branches the fleet scan walks that is ~21 s. Real, but it
68
- # is the correctness gap above that decides this, not the clock.
69
- #
70
- # Both halves are pinned in `test/reconcile/host.test.mjs`, so the exemption
71
- # rests on tests that fail when it stops being true.
37
+ # BOTH LOOKUPS ASK THROUGH `plot-host.sh`, WHICH IS WHY NEITHER CALLS `gh` OR
38
+ # `bb` DIRECTLY. The 2026-09-06 attempt stopped on two gaps, both since closed:
39
+ # an absent CLI used to arrive from `plot-host.sh pr-merged` as `not-merged`
40
+ # (fixed the same day — `is_lookup_miss` now excludes the shell's own
41
+ # `command not found`), and the open lookup had no op to call at all (`pr-list
42
+ # --state open` answers it, filtered to the asked branch here because the
43
+ # GitHub arm does not filter rows by head itself).
44
+ #
45
+ # `_plot_merged_lookup` maps `plot-host.sh pr-merged`'s three words onto the
46
+ # three readings, and the mapping is NOT the identity: `merged` → `found`,
47
+ # `not-merged` → `none`, `unknown` or a non-zero exit → `unaskable`.
48
+ #
49
+ # `_plot_open_lookup` asks `pr-list --state open --branch <br>` and reads its
50
+ # rows for one whose `head` equals the branch asked about. The `--branch` flag
51
+ # narrows the Bitbucket arm to a per-branch sweep; GitHub's arm does not filter
52
+ # on it at all, so the match here is load-bearing on that backend. A page
53
+ # `plot-host.sh` could not prove complete says so on stderr
54
+ # ("possibly truncated") — a caller that read `none` past that warning could
55
+ # miss its own branch's open PR behind a fuller page, so it reads `unaskable`
56
+ # instead.
72
57
  #
73
58
  # AN EMPTY BRANCH IS NOT ASKED ABOUT. `gh pr list --head ""` applies no filter,
74
59
  # so every PR in the repository matches: measured 2026-10-01 on `origin/main`
@@ -116,6 +101,11 @@
116
101
  # npm package alike, which is why both are vendored together.
117
102
  _plot_landed_mjs="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/board/plot-landed.mjs"
118
103
 
104
+ # `plot-host.sh`, resolved the same way and for the same reason: the two
105
+ # lookups below ask it rather than `gh`/`bb` directly, so it must be found
106
+ # beside this script regardless of either caller's cwd.
107
+ _plot_host_sh="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/plot-host.sh"
108
+
119
109
  # Ask the rule about one branch's two lookups.
120
110
  #
121
111
  # $1=merged reading, $2=open reading, both `found`/`none`/`unaskable`.
@@ -133,22 +123,28 @@ _plot_landed() {
133
123
  # ran and matched nothing is the host speaking, while a lookup that did not run
134
124
  # is silence, and silence is never permission.
135
125
  _plot_merged_lookup() {
136
- local br="$1" out
137
- [ -n "$br" ] || { echo unaskable; return; }
138
- command -v gh >/dev/null 2>&1 || { echo unaskable; return; }
139
- out=$(gh pr list --head "$br" --state all --limit 100 --json mergedAt 2>/dev/null) \
140
- || { echo unaskable; return; }
141
- case "$out" in *'"mergedAt":"'*) echo found ;; *) echo none ;; esac
126
+ local br="$1" word
127
+ [ -n "$br" ] && [ -f "$_plot_host_sh" ] || { echo unaskable; return; }
128
+ word=$(bash "$_plot_host_sh" pr-merged "$br" 2>/dev/null) || { echo unaskable; return; }
129
+ case "$word" in merged) echo found ;; not-merged) echo none ;; *) echo unaskable ;; esac
142
130
  }
143
131
 
144
132
  # What the host says about an OPEN PR on this branch: found / none / unaskable.
133
+ #
134
+ # `--branch` narrows the Bitbucket arm to a true per-branch sweep, but the
135
+ # GitHub arm never filters its `gh pr list` call on it — so the row match
136
+ # below is what actually answers "this branch" on that backend. A page
137
+ # `plot-host.sh` could not prove complete says so on stderr, and that is read
138
+ # as `unaskable` rather than trusting a `none` that might be hiding behind a
139
+ # fuller page.
145
140
  _plot_open_lookup() {
146
- local br="$1" out
147
- [ -n "$br" ] || { echo unaskable; return; }
148
- command -v gh >/dev/null 2>&1 || { echo unaskable; return; }
149
- out=$(gh pr list --head "$br" --state open --limit 1 --json number 2>/dev/null) \
150
- || { echo unaskable; return; }
151
- case "$out" in *'"number"'*) echo found ;; *) echo none ;; esac
141
+ local br="$1" out ok=1 err="${TMPDIR:-/tmp}/plot-pr-open-err.$$.$RANDOM"
142
+ [ -n "$br" ] && [ -f "$_plot_host_sh" ] || { echo unaskable; return; }
143
+ out=$(bash "$_plot_host_sh" pr-list --state open --branch "$br" --limit 100 2>"$err") || ok=0
144
+ grep -q 'possibly truncated' "$err" 2>/dev/null && ok=0
145
+ rm -f -- "$err" 2>/dev/null
146
+ [ "$ok" -eq 1 ] || { echo unaskable; return; }
147
+ case "$out" in *"\"head\":\"$br\""*) echo found ;; *) echo none ;; esac
152
148
  }
153
149
 
154
150
  # Did the host merge ANY PR for this branch?