@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/plot-plan-meta.sh CHANGED
@@ -106,7 +106,8 @@
106
106
  # front matter `sprint:`); "" if absent or an HTML-comment
107
107
  # placeholder
108
108
  # story story slug the plan belongs to (`## Status` `Story:` or
109
- # front matter `story:`); "" if absent or a placeholder
109
+ # front matter `story:`), reduced from Markdown link form
110
+ # via reduce_story_link(); "" if absent or a placeholder
110
111
  # assignee github handle from front matter `assignee:`, else the
111
112
  # `## Approval` `Assignee:` line, else the `## Status`
112
113
  # `Assignee:` line; "" if absent or a placeholder
@@ -235,6 +236,28 @@
235
236
  # no branch stays silent, since reporting that would fire on
236
237
  # every such plan. A marker inside a code span is quoted, not
237
238
  # written, and is read nowhere. ALWAYS present; [] when none.
239
+ # unread_heading_items
240
+ # `{ wave, branch }` pairs, in document order, for a heading-
241
+ # shape list item claiming a branch no heading in that wave
242
+ # carries — a report, not a refusal. A claim on its OWN
243
+ # heading's branch is read instead (see the heading handler).
244
+ # `wave` is the wave NAME, not an index. ALWAYS present; []
245
+ # when every such item was attributed.
246
+ # unread_branch_items
247
+ # `{ wave, branch, line }` triples, in document order, for a
248
+ # list item in a slice section that is NOT a claim
249
+ # (branch_claim_re) and yet holds a token matching a
250
+ # configured branch prefix, inside or outside a code span —
251
+ # a report, not a refusal. Catches a foreign-repository
252
+ # branch named in prose rather than claimed, which the claim
253
+ # grammar never reads at all (unlike unread_heading_items,
254
+ # whose items are already claims the heading cannot
255
+ # attribute). `idea/` tokens, names holding `*`, and file
256
+ # paths (a `.` after the prefix) are not read as a branch. An
257
+ # item carrying `<!-- deferred: ... -->` is excluded: a
258
+ # person already accepted it has no branch yet. `wave` is the
259
+ # wave NAME, "" when the item precedes any heading. ALWAYS
260
+ # present; [] when none.
238
261
  # issues tracker issue numbers this plan answers, from the `## Status`
239
262
  # `Issue:` line or front matter `issue:` (sorted, unique).
240
263
  # A DEDICATED field, never a scan of the body for `#NNN`: a
@@ -329,7 +352,7 @@ if [ ${#files[@]} -eq 0 ] && [ ${#missing[@]} -eq 0 ]; then
329
352
  fi
330
353
 
331
354
  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":[],"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' \
355
+ 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":[],"unread_heading_items":[],"unread_branch_items":[],"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
356
  "$(printf '%s' "$f" | sed 's/\\/\\\\/g; s/"/\\"/g')"
334
357
  done
335
358
 
@@ -367,6 +390,25 @@ function jesc(s) {
367
390
  return s
368
391
  }
369
392
  function trim(s) { sub(/^[ \t]+/, "", s); sub(/[ \t]+$/, "", s); return s }
393
+ # Inserts v into arr[1..n], kept sorted and free of duplicates, and returns the
394
+ # new count. A numeric v compares numerically and a string v as a string, so
395
+ # the caller decides the order by the type it passes. Portable: no gawk asort.
396
+ function sorted_insert(arr, n, v, j) {
397
+ for (j = 1; j <= n; j++) if (arr[j] == v) return n
398
+ for (j = n; j >= 1 && arr[j] > v; j--) arr[j+1] = arr[j]
399
+ arr[j+1] = v
400
+ return n + 1
401
+ }
402
+ # Renders `n` `{"k1":"...","k2":"...",["k3":"..."]}` objects, reading
403
+ # arr1[i]/arr2[i][/arr3[i]] for i=1..n. k3 "" omits the third field — the two-key
404
+ # shape unread_waits and unread_heading_items emit; unread_branch_items passes
405
+ # k3 for its third, "line".
406
+ function emit_pairs(n, k1, arr1, k2, arr2, k3, arr3, i, out) {
407
+ for (i = 1; i <= n; i++)
408
+ out = out (i > 1 ? "," : "") "{\"" k1 "\":\"" jesc(arr1[i]) "\",\"" k2 "\":\"" jesc(arr2[i]) "\"" \
409
+ (k3 != "" ? ",\"" k3 "\":\"" jesc(arr3[i]) "\"" : "") "}"
410
+ return out
411
+ }
370
412
  # Every `<!-- waits: … -->` marker on a line, each value split on commas, in
371
413
  # the line order with duplicates removed, written into outArr/outN (outN is
372
414
  # outArr[0] — awk scalars are pass-by-value, so a count returned through a
@@ -422,6 +464,11 @@ function val_after_colon(s) {
422
464
  }
423
465
  # Template placeholders like "<!-- optional -->" mean "field absent".
424
466
  function strip_placeholder(s) { return (s ~ /^<!--/) ? "" : s }
467
+ # A Markdown link `[text](target)` reduces to `text`, with backticks around
468
+ # the text removed. A malformed link ("[text](" with no close, "[]()") is not
469
+ # a link, so it keeps the raw value unreduced — an empty `story` means "no
470
+ # story", and a malformed link is not that.
471
+ function reduce_story_link(s, t) { if (s !~ /^\[[^]]+\]\([^)]+\)$/) return s; t = s; sub(/^\[/, "", t); sub(/\]\([^)]*\)$/, "", t); gsub(/`/, "", t); return t }
425
472
  # Blank out backtick-delimited inline code, so a marker PRINTED as a literal is
426
473
  # not read as syntax. Markdown renders `<!--` between backticks as the four
427
474
  # characters; this parser used to read it as a comment-open, and because such a
@@ -521,10 +568,13 @@ function reset_state() {
521
568
  delete malformed_prs; n_malformed_prs = 0
522
569
  fm_issue = ""; canon_issue = ""; fm_ticket = ""
523
570
  delete issues; n_issues = 0
524
- delete wave_names; delete wave_of; delete wave_seq; delete wave_count
571
+ delete wave_names; delete wave_of; delete wave_count
525
572
  delete deferred_of; delete deferred_why; delete claimed_of; delete ordered_b; delete spike_of; n_waves = 0
526
573
  delete branch_heading; delete waits_of; delete waits_set; delete waits_n
527
574
  delete unread_waits_branch; delete unread_waits_value; n_unread_waits = 0
575
+ delete unread_heading_item_wave; delete unread_heading_item_branch; n_unread_heading_items = 0
576
+ delete unread_branch_item_wave; delete unread_branch_item_branch; delete unread_branch_item_line; n_unread_branch_items = 0
577
+ heading_branch = ""; heading_branch_n = 0
528
578
  delete builds_of; delete agent_of; delete commits_of; delete started; n_started = 0
529
579
  fm_changelog = ""
530
580
  delete changelog; n_changelog = 0; changelog_seen = 0; cl_open = 0
@@ -609,43 +659,15 @@ function emit_record( fmt, praw, palt_raw, traw, title, sprint, story, assigne
609
659
  issue2 = substr(issue2, RSTART + RLENGTH)
610
660
  }
611
661
  }
612
- # Insertion sort + dedupe (portable: no gawk asort).
613
- nb = 0
614
- for (i = 1; i <= n_branches; i++) {
615
- for (j = 1; j <= nb && sorted_b[j] != branches[i]; j++) ;
616
- if (j <= nb) continue
617
- for (j = nb; j >= 1 && sorted_b[j] > branches[i]; j--) sorted_b[j+1] = sorted_b[j]
618
- sorted_b[j+1] = branches[i]; nb++
619
- }
620
- np = 0
621
- for (i = 1; i <= n_prs; i++) {
622
- for (j = 1; j <= np && sorted_p[j] != prs[i]+0; j++) ;
623
- if (j <= np) continue
624
- for (j = np; j >= 1 && sorted_p[j] > prs[i]+0; j--) sorted_p[j+1] = sorted_p[j]
625
- sorted_p[j+1] = prs[i]+0; np++
626
- }
662
+ nb = 0; for (i = 1; i <= n_branches; i++) nb = sorted_insert(sorted_b, nb, branches[i])
663
+ np = 0; for (i = 1; i <= n_prs; i++) np = sorted_insert(sorted_p, np, prs[i] + 0)
627
664
  # Issues: sort numeric (GitHub) issues first, then string (Jira) keys.
628
665
  # Separate into two arrays, sort each, then concatenate.
629
666
  n_num_i = 0; n_str_i = 0
630
667
  for (i = 1; i <= n_issues; i++) {
631
668
  v = issues[i]
632
- if (v ~ /^[0-9]+$/) {
633
- # Numeric: check for duplicate, then insert sorted.
634
- is_dup = 0
635
- for (j = 1; j <= n_num_i; j++) if (num_issues[j] == v + 0) { is_dup = 1; break }
636
- if (!is_dup) {
637
- for (j = n_num_i; j >= 1 && num_issues[j] > v + 0; j--) num_issues[j+1] = num_issues[j]
638
- num_issues[j+1] = v + 0; n_num_i++
639
- }
640
- } else {
641
- # String (Jira key): check for duplicate, then insert sorted.
642
- is_dup = 0
643
- for (j = 1; j <= n_str_i; j++) if (str_issues[j] == v) { is_dup = 1; break }
644
- if (!is_dup) {
645
- for (j = n_str_i; j >= 1 && str_issues[j] > v; j--) str_issues[j+1] = str_issues[j]
646
- str_issues[j+1] = v; n_str_i++
647
- }
648
- }
669
+ if (v ~ /^[0-9]+$/) n_num_i = sorted_insert(num_issues, n_num_i, v + 0)
670
+ else n_str_i = sorted_insert(str_issues, n_str_i, v "")
649
671
  }
650
672
  # Concatenate: numeric first, then string (matches the field ordering the
651
673
  # board expects — GitHub issues before Jira keys when both are present).
@@ -773,12 +795,9 @@ function emit_record( fmt, praw, palt_raw, traw, title, sprint, story, assigne
773
795
  # report, not a refusal. Filled by store_waits() as each branch is matched;
774
796
  # a `waits:` syntax example on a PROSE line (no branch claim) never reaches
775
797
  # store_waits(), so it stays silent, as today.
776
- out = out ",\"unread_waits\":["
777
- for (i = 1; i <= n_unread_waits; i++) {
778
- out = out (i > 1 ? "," : "") "{\"branch\":\"" jesc(unread_waits_branch[i]) "\"" \
779
- ",\"value\":\"" jesc(unread_waits_value[i]) "\"}"
780
- }
781
- out = out "]"
798
+ out = out ",\"unread_waits\":[" emit_pairs(n_unread_waits, "branch", unread_waits_branch, "value", unread_waits_value) "]"
799
+ out = out ",\"unread_heading_items\":[" emit_pairs(n_unread_heading_items, "wave", unread_heading_item_wave, "branch", unread_heading_item_branch) "]"
800
+ out = out ",\"unread_branch_items\":[" emit_pairs(n_unread_branch_items, "wave", unread_branch_item_wave, "branch", unread_branch_item_branch, "line", unread_branch_item_line) "]"
782
801
  out = out ",\"review_raw\":\"" jesc(review) "\",\"review\":\"" norm_review(review) "\""
783
802
  out = out ",\"impl_raw\":\"" jesc(impl) "\",\"impl\":\"" norm_impl(impl) "\""
784
803
  out = out ",\"design_raw\":\"" jesc(design) "\""
@@ -821,9 +840,16 @@ function note_branch_heading( h) {
821
840
  # slice dialects at the moment each claims a branch, so a `waits:` syntax
822
841
  # example on a line with NO branch claim never drains the queue and stays
823
842
  # silent — the same rule the old single-value reading followed.
824
- function store_waits(n, b, k) {
825
- waits_n[n] = line_waits[0] + 0
826
- for (k = 1; k <= waits_n[n]; k++) waits_of[n, k] = line_waits[k]
843
+ #
844
+ # OVERLAY (a heading-shape list item naming the branch of its heading) keeps what
845
+ # the heading stored and adds the values of this line it lacks: the union, so a
846
+ # prerequisite on either line holds the slice. The unread values drain either way.
847
+ function store_waits(n, b, overlay, k, j, dup) {
848
+ if (!overlay) waits_n[n] = 0
849
+ for (k = 1; k <= line_waits[0]; k++) {
850
+ dup = 0; for (j = 1; j <= waits_n[n]; j++) if (waits_of[n, j] == line_waits[k]) dup = 1
851
+ if (!dup) waits_of[n, ++waits_n[n]] = line_waits[k]
852
+ }
827
853
  waits_set[n] = (waits_n[n] > 0) ? 1 : 0
828
854
  for (k = 1; k <= pending_unread_n; k++) {
829
855
  unread_waits_branch[++n_unread_waits] = b
@@ -963,41 +989,110 @@ function commit_list(s, out, m, h) {
963
989
  h = "[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]+"
964
990
  while (match(s, "→ (commit " h "(, ?" h ")*|[A-Za-z0-9._-]+/[A-Za-z0-9._-]+@" h ")")) {
965
991
  m = substr(s, RSTART, RLENGTH); s = substr(s, RSTART + RLENGTH)
966
- sub(/^→ (commit )?/, "", m); gsub(/, ?/, ",", m)
967
- out = out (out == "" ? "" : ",") m
992
+ sub(/^→ (commit )?/, "", m); gsub(/, ?/, ",", m); out = out (out == "" ? "" : ",") m
968
993
  }
969
994
  return out
970
995
  }
971
996
  # Stores the annotations read_notes() found, and the commits the line names,
972
- # against branch n (named b), at the moment either dialect claims it.
973
- function keep_branch(n, b) {
974
- # THE FLAG accepts the bare form as well as the annotated one.
975
- #
976
- # It matched `deferred:` only, so `<!-- deferred -->` — the annotation with
977
- # nothing after it — read as NOT deferred at all: the strongest statement a
978
- # plan can make about a branch, dropped for want of a colon. A reader
979
- # writing the shorter form has said the branch will not be built; the
980
- # parser now hears it.
981
- deferred_of[n] = ($0 ~ /<!--[ \t]*(deferred|moved)[ \t]*(:|-->)/) ? "true" : "false"
982
- # The reason travels with the flag. Empty on every non-deferred branch, and
983
- # empty is also the honest answer for the bare form: the branch IS deferred
984
- # and no reason was recorded, which is a different statement from a reason
985
- # of "".
986
- deferred_why[n] = defer_note
987
- spike_of[n] = ($0 ~ /<!--[ \t]*spike[ \t]*-->/) ? 1 : 0
988
- # Claim reflection, written by the worker after its ref push succeeds. This
989
- # is a reflection, not the claim: git refs remain authoritative.
990
- claimed_of[n] = claim_note
991
- # The prerequisites travel with the branch, flattened as waits_of[n,1..k]
992
- # since this awk has no nested arrays. Presence is tracked separately so a
993
- # branch that declares none emits no key.
994
- store_waits(n, b)
995
- builds_of[n] = builds_note
996
- # The kind travels with the branch, presence tracked separately so a slice
997
- # declaring none emits no key.
998
- agent_of[n] = agent_note
999
- ordered_b[n] = b
1000
- commits_of[n] = commit_list($0)
997
+ # against branch n (named b).
998
+ #
999
+ # OVERLAY decides whether a field this line does NOT carry erases what is
1000
+ # already stored. False (the old list shape, and a heading line itself): this
1001
+ # is the first and only line that can claim n, so every field is written
1002
+ # outright -- unconditionally false reads as "false", not "unknown". True (a
1003
+ # heading-shape list item naming the branch its heading already claimed): the
1004
+ # heading line claimed n first via read_notes() on itself, so only a field
1005
+ # THIS line carries may overwrite -- a deferral reason written on the heading
1006
+ # must survive a list item that carries none of its own.
1007
+ function keep_branch(n, b, overlay, is_deferred, c, parts, j, m) {
1008
+ is_deferred = ($0 ~ /<!--[ \t]*(deferred|moved)[ \t]*(:|-->)/)
1009
+ # THE FLAG accepts the bare form as well as the annotated one: `deferred:`
1010
+ # and the bare `<!-- deferred -->` both set it true. The reason travels with
1011
+ # the flag, empty for a non-deferred branch and equally empty for a bare
1012
+ # marker with no reason recorded — a different statement from a reason of
1013
+ # "". In OVERLAY mode a bare list-item marker must not blank a reason the
1014
+ # heading already wrote: the flag is set whenever this line claims
1015
+ # deferred, but the reason is overwritten only when this line carries one.
1016
+ if (!overlay || is_deferred) deferred_of[n] = is_deferred ? "true" : "false"
1017
+ if (!overlay || defer_note != "") deferred_why[n] = defer_note
1018
+ if (!overlay || $0 ~ /<!--[ \t]*spike[ \t]*-->/) spike_of[n] = ($0 ~ /<!--[ \t]*spike[ \t]*-->/) ? 1 : 0
1019
+ # Claim reflection, written by the worker after its ref push succeeds. This
1020
+ # is a reflection, not the claim: git refs remain authoritative.
1021
+ if (!overlay || claim_note != "") claimed_of[n] = claim_note
1022
+ # The prerequisites travel with the branch, flattened as waits_of[n,1..k]
1023
+ # since this awk has no nested arrays. Presence is tracked separately so a
1024
+ # branch that declares none emits no key.
1025
+ store_waits(n, b, overlay)
1026
+ if (!overlay || builds_note != "") builds_of[n] = builds_note
1027
+ # The kind travels with the branch, presence tracked separately so a slice
1028
+ # declaring none emits no key.
1029
+ if (!overlay || agent_note != "") agent_of[n] = agent_note
1030
+ ordered_b[n] = b
1031
+ # Commits merge like waits: a list item adds its own to those of the heading,
1032
+ # minus any ref both lines already name, in first-seen order.
1033
+ c = commit_list($0)
1034
+ if (overlay && commits_of[n] != "") { m = split(c, parts, ","); for (j = 1; j <= m; j++) if (parts[j] != "" && index("," commits_of[n] ",", "," parts[j] ",") == 0) commits_of[n] = commits_of[n] "," parts[j] } else commits_of[n] = c
1035
+ }
1036
+ # `→ #N` and `→ owner/repo#N` are both annotations: /plot-deliver instructs
1037
+ # implementers to write the second for `Impl: other repo` plans, and a parser
1038
+ # that dropped it reported `prs: []` for a plan whose only PR was written
1039
+ # exactly as documented. The repo part is matched but not retained — callers
1040
+ # ask which PRs are the evidence, and plot-host.sh resolves where each lives.
1041
+ # A near-miss is REPORTED, never silently dropped. `→#44` (no space) is the
1042
+ # obvious hand-typo, and treating it as absence makes the sweep advise adding
1043
+ # an annotation the plan already carries. Accepting it would widen the
1044
+ # contract on a guess; reporting it leaves the judgement with a person.
1045
+ #
1046
+ # DEFER (optional) files every PR on this line as deferred: a heading-shape list
1047
+ # item passes the deferral of its branch, which the heading line may carry alone.
1048
+ function extract_prs(raw, defer, line, p) {
1049
+ line = raw
1050
+ while (match(line, /→ ([A-Za-z0-9._-]+\/[A-Za-z0-9._-]+)?#[0-9]+/)) {
1051
+ p = substr(line, RSTART, RLENGTH); sub(/^.*#/, "", p)
1052
+ prs[++n_prs] = p; if (defer || raw ~ /<!--[ \t]*(deferred|moved)[ \t]*(:|-->)/) dprs[++n_dprs] = p
1053
+ line = substr(line, RSTART + RLENGTH)
1054
+ }
1055
+ line = raw
1056
+ while (match(line, /→#[0-9]+/)) { malformed_prs[++n_malformed_prs] = substr(line, RSTART, RLENGTH); line = substr(line, RSTART + RLENGTH) }
1057
+ }
1058
+ # The first branch-prefixed token on a NON-CLAIM list item, read for
1059
+ # unread_branch_items. Scans $0 AS WRITTEN — backticks included — since the
1060
+ # 3819 line (`` - Umsetzung: `bug/…` ``) names its branch inside a code span,
1061
+ # unlike mask_code() callers, which strip spans before reading. A boundary
1062
+ # character ahead of the prefix keeps "feature/x" from matching inside a
1063
+ # longer word such as "mifeature/x"; none of the real prefixes end a word
1064
+ # that would otherwise collide.
1065
+ #
1066
+ # Three kinds of token read as something OTHER than a branch, and are
1067
+ # skipped rather than reported: `idea/` names a plan, not a branch a slice
1068
+ # can claim; a name holding `*` is a glob a plan writes to mean "every
1069
+ # branch"; and a `.` anywhere after the prefix means a file path
1070
+ # (`docs/plans/x.md`), since no branch name in this estate ever carries one.
1071
+ # Loops past a skipped token rather than stopping at the first
1072
+ # match, so a line naming an excluded token before a real one (prose citing
1073
+ # both an `idea/` plan and a `bug/` branch) still reports the real one.
1074
+ function unread_branch_token(s, re, tok, pfx, rest) {
1075
+ re = "(^|[^A-Za-z0-9_/-])(" PREFIXES ")/[^ \t,)`:]+"
1076
+ while (match(s, re)) {
1077
+ tok = substr(s, RSTART, RLENGTH)
1078
+ sub("^[^A-Za-z0-9_/-]*", "", tok)
1079
+ s = substr(s, RSTART + RLENGTH)
1080
+ pfx = tok; sub(/\/.*/, "", pfx)
1081
+ rest = substr(tok, length(pfx) + 2)
1082
+ if (pfx != "idea" && index(tok, "*") == 0 && index(rest, ".") == 0) return tok
1083
+ }
1084
+ return ""
1085
+ }
1086
+ # Records $0 into unread_branch_items when it is a non-claim list item naming
1087
+ # a branch token — the one guard and the one recording shape both slice
1088
+ # dialects share in their non-claim arm.
1089
+ function record_unread_branch_item( utok) {
1090
+ if ($0 !~ /^[ \t]*-[ \t]+/ || $0 ~ /<!--[ \t]*(deferred|moved)[ \t]*(:|-->)/) return
1091
+ utok = unread_branch_token($0)
1092
+ if (utok == "") return
1093
+ unread_branch_item_wave[++n_unread_branch_items] = (n_waves > 0 ? wave_names[n_waves] : "")
1094
+ unread_branch_item_branch[n_unread_branch_items] = utok
1095
+ unread_branch_item_line[n_unread_branch_items] = trim($0)
1001
1096
  }
1002
1097
  # The longest wave name that still reads as a label, not prose. A JUDGEMENT, not
1003
1098
  # a measurement: the longest legitimate name in the estate is `Offered first`
@@ -1038,7 +1133,7 @@ in_fm {
1038
1133
  else if (lower ~ /^type:/ && fm_type == "") fm_type = val_after_colon($0)
1039
1134
  else if (lower ~ /^title:/ && fm_title == "") fm_title = val_after_colon($0)
1040
1135
  else if (lower ~ /^sprint:/ && fm_sprint == "") fm_sprint = val_after_colon($0)
1041
- else if (lower ~ /^story:/ && fm_story == "") fm_story = val_after_colon($0)
1136
+ else if (lower ~ /^story:/ && fm_story == "") fm_story = reduce_story_link(val_after_colon($0))
1042
1137
  else if (lower ~ /^issue:/ && fm_issue == "") fm_issue = val_after_colon($0)
1043
1138
  else if (lower ~ /^ticket:/ && fm_ticket == "") fm_ticket = val_after_colon($0)
1044
1139
  else if (lower ~ /^assignee:/ && fm_assignee == "") fm_assignee = val_after_colon($0)
@@ -1153,7 +1248,7 @@ section == "status" {
1153
1248
  else if (lower ~ /^[ \t]*[-*]?[ \t]*\**phase[:*]/ && canon_phase == "") canon_phase = val_after_colon($0)
1154
1249
  else if (lower ~ /^[ \t]*[-*]?[ \t]*\**type[:*]/ && canon_type == "") canon_type = val_after_colon($0)
1155
1250
  else if (lower ~ /^[ \t]*[-*]?[ \t]*\**sprint[:*]/ && canon_sprint == "") canon_sprint = val_after_colon($0)
1156
- else if (lower ~ /^[ \t]*[-*]?[ \t]*\**story[:*]/ && canon_story == "") canon_story = val_after_colon($0)
1251
+ else if (lower ~ /^[ \t]*[-*]?[ \t]*\**story[:*]/ && canon_story == "") canon_story = reduce_story_link(val_after_colon($0))
1157
1252
  else if (lower ~ /^[ \t]*[-*]?[ \t]*\**issue[:*]/ && canon_issue == "") canon_issue = val_after_colon($0)
1158
1253
  else if (lower ~ /^[ \t]*[-*]?[ \t]*\**review[:*]/ && canon_review == "") canon_review = val_after_colon($0)
1159
1254
  else if (lower ~ /^[ \t]*[-*]?[ \t]*\**impl[:*]/ && canon_impl == "") canon_impl = val_after_colon($0)
@@ -1290,31 +1385,12 @@ section == "slices" && slice_shape != "heading" {
1290
1385
  sub(/`$/, "", b)
1291
1386
  branches[++n_branches] = b
1292
1387
  if (n_waves == 0) { wave_names[++n_waves] = "" }
1293
- wave_of[n_branches] = n_waves
1294
- wave_seq[n_branches] = ++wave_count[n_waves]
1295
- keep_branch(n_branches, b)
1296
- }
1297
- line = $0
1298
- # `→ #N` and `→ owner/repo#N` are both annotations: /plot-deliver instructs
1299
- # implementers to write the second for `Impl: other repo` plans, and a parser
1300
- # that dropped it reported `prs: []` for a plan whose only PR was written
1301
- # exactly as documented. The repo part is matched but not retained — callers
1302
- # ask which PRs are the evidence, and plot-host.sh resolves where each lives.
1303
- while (match(line, /→ ([A-Za-z0-9._-]+\/[A-Za-z0-9._-]+)?#[0-9]+/)) {
1304
- p = substr(line, RSTART, RLENGTH)
1305
- sub(/^.*#/, "", p)
1306
- prs[++n_prs] = p; if ($0 ~ /<!--[ \t]*(deferred|moved)[ \t]*(:|-->)/) dprs[++n_dprs] = p
1307
- line = substr(line, RSTART + RLENGTH)
1308
- }
1309
- # A near-miss is REPORTED, never silently dropped. `→#44` (no space) is the
1310
- # obvious hand-typo, and treating it as absence makes the sweep advise adding
1311
- # an annotation the plan already carries. Accepting it would widen the
1312
- # contract on a guess; reporting it leaves the judgement with a person.
1313
- line = $0
1314
- while (match(line, /→#[0-9]+/)) {
1315
- malformed_prs[++n_malformed_prs] = substr(line, RSTART, RLENGTH)
1316
- line = substr(line, RSTART + RLENGTH)
1388
+ wave_of[n_branches] = n_waves; ++wave_count[n_waves]
1389
+ keep_branch(n_branches, b, 0)
1390
+ } else {
1391
+ record_unread_branch_item()
1317
1392
  }
1393
+ extract_prs($0)
1318
1394
  next
1319
1395
  }
1320
1396
  # `## Waves` — the new spelling. The `### ` heading carries the meta (which
@@ -1327,58 +1403,100 @@ section == "slices" && slice_shape != "heading" {
1327
1403
  # old shape produces for the same plan. So this shares every accumulation
1328
1404
  # variable with the branches handler above; only the EXTRACTION differs.
1329
1405
  section == "slices" && slice_shape == "heading" {
1330
- # Only the `### ` heading carries meta. Body lines are prose — never scanned
1331
- # for a branch or a PR, which is the whole point of the new shape.
1332
- if ($0 !~ /^###[ \t]/) next
1406
+ # A `### ` heading carries meta, as before. Below it, ONE line is no longer
1407
+ # prose-only: a list item that is a LIST CLAIM (branch_claim_re, the same
1408
+ # anchor the old shape uses) and names the branch this heading just claimed
1409
+ # is read for its `→ #N` and its annotations — see below. Every other line,
1410
+ # including a list item naming a DIFFERENT branch, stays prose.
1411
+ if ($0 ~ /^###[ \t]/) {
1412
+ # A heading opens a wave whose NAME is the heading text with the
1413
+ # `(Branch: …, PR: …)` parenthetical and any trailing annotation stripped, so
1414
+ # `### Removed (Branch: bug/foo, PR: #300)` names the wave `Removed` — exactly
1415
+ # what the old shape (bare `### Removed`) produced, which is what keeps the two
1416
+ # spellings byte-identical.
1417
+ wname = trim(substr($0, 4))
1418
+ # Drop a trailing HTML comment (claimed/deferred ride the heading line now).
1419
+ sub(/[ \t]*<!--.*$/, "", wname)
1420
+ # Drop the `(Branch: …)` meta parenthetical. Anchored to `(Branch:` so a
1421
+ # parenthetical in a genuine wave name — none exist, but the grammar must not
1422
+ # assume it — is not eaten unless it is the meta block.
1423
+ sub(/[ \t]*\(Branch:.*$/, "", wname)
1424
+ wname = trim(wname)
1425
+ wave_names[++n_waves] = wname
1426
+ note_branch_heading()
1333
1427
 
1334
- # A heading opens a wave whose NAME is the heading text with the
1335
- # `(Branch: …, PR: …)` parenthetical and any trailing annotation stripped, so
1336
- # `### Removed (Branch: bug/foo, PR: #300)` names the wave `Removed` — exactly
1337
- # what the old shape (bare `### Removed`) produced, which is what keeps the two
1338
- # spellings byte-identical.
1339
- wname = trim(substr($0, 4))
1340
- # Drop a trailing HTML comment (claimed/deferred ride the heading line now).
1341
- sub(/[ \t]*<!--.*$/, "", wname)
1342
- # Drop the `(Branch: …)` meta parenthetical. Anchored to `(Branch:` so a
1343
- # parenthetical in a genuine wave name — none exist, but the grammar must not
1344
- # assume it — is not eaten unless it is the meta block.
1345
- sub(/[ \t]*\(Branch:.*$/, "", wname)
1346
- wname = trim(wname)
1347
- wave_names[++n_waves] = wname
1348
- note_branch_heading()
1428
+ # Annotations bind to the line carrying the branch name, which is the heading.
1429
+ read_notes()
1349
1430
 
1350
- # Annotations bind to the line carrying the branch name, which is the heading.
1351
- read_notes()
1431
+ # The branch this heading just claimed, so a list item below can be
1432
+ # matched against it. "" until a branch is read below, so a heading with
1433
+ # no readable branch claims nothing for any list item that follows.
1434
+ heading_branch = ""; heading_branch_n = 0; heading_pr = ""
1352
1435
 
1353
- # The branch is the `Branch:` value, matched against the known prefixes exactly
1354
- # as the old shape matched the backticked name. Written unquoted in the heading
1355
- # (`Branch: bug/foo`), so the match is on a bare token, not on backticks. A
1356
- # heading with no readable branch still opened a wave above — so a `## Waves`
1357
- # section is never silently empty, which is the failure this plan refuses: a
1358
- # consumer sees a wave it could not extract a branch from, not an absence.
1359
- #
1360
- # THE VALUE MAY BE BACKTICKED. `(Branch: \`bug/foo\`)` is unambiguous, and a
1361
- # backtick between `Branch:` and the prefix made the anchored match fail, so
1362
- # the heading opened a wave and yielded nothing. The backticks are optional on
1363
- # both sides and stripped from the name. Measured 2026-09-28 over 357 plans:
1364
- # 2 records change, 355 byte-identical.
1365
- if (match($0, "Branch:[ \t]*`?(" PREFIXES ")/[^ \t,)`]+`?")) {
1366
- b = substr($0, RSTART, RLENGTH)
1367
- sub(/^Branch:[ \t]*/, "", b)
1368
- gsub(/`/, "", b)
1369
- branches[++n_branches] = b
1370
- wave_of[n_branches] = n_waves
1371
- wave_seq[n_branches] = ++wave_count[n_waves]
1372
- keep_branch(n_branches, b)
1436
+ # The branch is the `Branch:` value, matched against the known prefixes exactly
1437
+ # as the old shape matched the backticked name. Written unquoted in the heading
1438
+ # (`Branch: bug/foo`), so the match is on a bare token, not on backticks. A
1439
+ # heading with no readable branch still opened a wave above — so a `## Waves`
1440
+ # section is never silently empty, which is the failure this plan refuses: a
1441
+ # consumer sees a wave it could not extract a branch from, not an absence.
1442
+ #
1443
+ # THE VALUE MAY BE BACKTICKED. `(Branch: \`bug/foo\`)` is unambiguous, and a
1444
+ # backtick between `Branch:` and the prefix made the anchored match fail, so
1445
+ # the heading opened a wave and yielded nothing. The backticks are optional on
1446
+ # both sides and stripped from the name. Measured 2026-09-28 over 357 plans:
1447
+ # 2 records change, 355 byte-identical.
1448
+ if (match($0, "Branch:[ \t]*`?(" PREFIXES ")/[^ \t,)`]+`?")) {
1449
+ b = substr($0, RSTART, RLENGTH)
1450
+ sub(/^Branch:[ \t]*/, "", b)
1451
+ gsub(/`/, "", b)
1452
+ branches[++n_branches] = b
1453
+ wave_of[n_branches] = n_waves; ++wave_count[n_waves]
1454
+ keep_branch(n_branches, b, 0)
1455
+ heading_branch = b; heading_branch_n = n_branches
1456
+ }
1457
+
1458
+ # The PR is the `PR: #NNN` value in the heading. Absent PR: contributes
1459
+ # nothing — not "", not 0 — the same rule `Issue:` follows. Only a heading
1460
+ # that carries the field adds to prs.
1461
+ if (match($0, /PR:[ \t]*#[0-9]+/)) {
1462
+ p = substr($0, RSTART, RLENGTH)
1463
+ sub(/^.*#/, "", p)
1464
+ prs[++n_prs] = heading_pr = p; if ($0 ~ /<!--[ \t]*(deferred|moved)[ \t]*(:|-->)/) dprs[++n_dprs] = p
1465
+ }
1466
+ next
1373
1467
  }
1374
1468
 
1375
- # The PR is the `PR: #NNN` value in the heading. Absent PR: contributes
1376
- # nothing — not "", not 0 — the same rule `Issue:` follows. Only a heading
1377
- # that carries the field adds to prs.
1378
- if (match($0, /PR:[ \t]*#[0-9]+/)) {
1379
- p = substr($0, RSTART, RLENGTH)
1380
- sub(/^.*#/, "", p)
1381
- prs[++n_prs] = p; if ($0 ~ /<!--[ \t]*(deferred|moved)[ \t]*(:|-->)/) dprs[++n_dprs] = p
1469
+ # A LIST CLAIM below the heading — same anchor as the old shape
1470
+ # (`branch_claim_re`), so a backticked name in prose stays unread exactly as
1471
+ # it always has. Only a line that IS the claim form is even considered.
1472
+ if (match($0, branch_claim_re)) {
1473
+ claim = substr($0, RSTART, RLENGTH)
1474
+ item_branch = substr(claim, index(claim, "`") + 1)
1475
+ sub(/`$/, "", item_branch)
1476
+ if (heading_branch != "" && item_branch == heading_branch) {
1477
+ # Names the branch the heading above already claimed: its `→ #N` and its
1478
+ # annotations belong to that branch. read_notes() reads $0 (this line), so
1479
+ # a list item marker is read IN ADDITION TO a heading marker, never
1480
+ # instead of it — the overlay=1 arm of keep_branch then leaves a field
1481
+ # this line does not carry (a deferral reason written on the `### `
1482
+ # line, say) exactly as the heading already stored it.
1483
+ # Deferral is decided per BRANCH once both lines are read: a deferral on
1484
+ # either line files the PR of the heading and the PRs of this line as deferred.
1485
+ was_deferred = deferred_of[heading_branch_n]
1486
+ read_notes()
1487
+ keep_branch(heading_branch_n, heading_branch, 1)
1488
+ if (was_deferred != "true" && deferred_of[heading_branch_n] == "true" && heading_pr != "") dprs[++n_dprs] = heading_pr
1489
+ extract_prs($0, deferred_of[heading_branch_n] == "true")
1490
+ } else {
1491
+ # Names a branch no heading in this wave claims (or there is no current
1492
+ # heading branch at all) — the parser cannot attribute it, so it is
1493
+ # reported rather than silently dropped and never read as a second claim.
1494
+ unread_heading_item_wave[++n_unread_heading_items] = wave_names[n_waves]; unread_heading_item_branch[n_unread_heading_items] = item_branch
1495
+ }
1496
+ } else {
1497
+ # Not a claim at all — a non-claim item in a `## Waves` section can still
1498
+ # name a branch in prose, exactly as a list item in the old shape can.
1499
+ record_unread_branch_item()
1382
1500
  }
1383
1501
  next
1384
1502
  }
package/plot-pr-merged.sh CHANGED
@@ -47,9 +47,9 @@
47
47
  # `not-merged` → `none`, `unknown` or a non-zero exit → `unaskable`.
48
48
  #
49
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
50
+ # rows for one whose `head` equals the branch asked about. `--branch` narrows
51
+ # the Bitbucket arm to a per-branch sweep and the GitHub arm to `gh pr list
52
+ # --head <br>`, so neither answers from a slice of a repository-wide page. A page
53
53
  # `plot-host.sh` could not prove complete says so on stderr
54
54
  # ("possibly truncated") — a caller that read `none` past that warning could
55
55
  # miss its own branch's open PR behind a fuller page, so it reads `unaskable`
@@ -131,18 +131,15 @@ _plot_merged_lookup() {
131
131
 
132
132
  # What the host says about an OPEN PR on this branch: found / none / unaskable.
133
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.
134
+ # `--branch` narrows both hosts to the one branch asked about (Bitbucket: a
135
+ # per-branch query; GitHub: `gh pr list --head`). A page `plot-host.sh` could
136
+ # not prove complete says so on stderr and reads `unaskable`, not `none`. One
137
+ # capture holds both streams, so the lookup creates no temp path.
140
138
  _plot_open_lookup() {
141
- local br="$1" out ok=1 err="${TMPDIR:-/tmp}/plot-pr-open-err.$$.$RANDOM"
139
+ local br="$1" out ok=1
142
140
  [ -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
141
+ out=$(bash "$_plot_host_sh" pr-list --state open --branch "$br" --limit 100 2>&1) || ok=0
142
+ case "$out" in *'possibly truncated'*) ok=0 ;; esac
146
143
  [ "$ok" -eq 1 ] || { echo unaskable; return; }
147
144
  case "$out" in *"\"head\":\"$br\""*) echo found ;; *) echo none ;; esac
148
145
  }