@delorenj/pjangler 1.4.3 → 1.4.4

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.
@@ -43,38 +43,243 @@ cd "$ROOT"
43
43
  CLOSE_GATE="$BIN_DIR/issue-close-gate.sh"
44
44
  EVIDENCE="_bmad-output/implementation-artifacts/issue-evidence/$ISSUE.md"
45
45
 
46
- yget() { sed -n "s/^[[:space:]]*$1:[[:space:]]*//p" "$ROLE_YAML" 2>/dev/null | head -n1 | tr -d '"' | tr -d '\r'; }
46
+ role_mapping_value() {
47
+ python3 - "$ROLE_YAML" "$1" "$2" <<'PY'
48
+ import pathlib
49
+ import re
50
+ import sys
51
+
52
+ path = pathlib.Path(sys.argv[1])
53
+ section = sys.argv[2]
54
+ key = sys.argv[3]
55
+ text = path.read_text(encoding="utf-8") if path.is_file() else ""
56
+ lines = text.splitlines()
57
+ headers = [
58
+ index
59
+ for index, line in enumerate(lines)
60
+ if re.fullmatch(rf"{re.escape(section)}:\s*(?:#.*)?", line)
61
+ ]
62
+ if not headers:
63
+ print("")
64
+ raise SystemExit(0)
65
+ if len(headers) != 1:
66
+ raise SystemExit(f"role config has duplicate top-level {section!r} mappings")
67
+ block = []
68
+ for line in lines[headers[0] + 1 :]:
69
+ if line.strip() and not line[0].isspace() and not line.lstrip().startswith("#"):
70
+ break
71
+ block.append(line)
72
+ content = [
73
+ line
74
+ for line in block
75
+ if line.strip() and not line.lstrip().startswith("#") and line[0].isspace()
76
+ ]
77
+ if not content:
78
+ print("")
79
+ raise SystemExit(0)
80
+ direct_indent = min(len(line) - len(line.lstrip()) for line in content)
81
+ matches = []
82
+ for line in content:
83
+ if len(line) - len(line.lstrip()) != direct_indent:
84
+ continue
85
+ match = re.fullmatch(rf"\s{{{direct_indent}}}{re.escape(key)}:\s*(.*?)\s*", line)
86
+ if match:
87
+ matches.append(match.group(1))
88
+ if len(matches) > 1:
89
+ raise SystemExit(f"role config has duplicate {section}.{key} values")
90
+ value = matches[0] if matches else ""
91
+ value = re.sub(r"\s+#.*$", "", value).strip()
92
+ if len(value) >= 2 and value[0] == value[-1] and value[0] in "\"'":
93
+ value = value[1:-1]
94
+ print(value.strip())
95
+ PY
96
+ }
47
97
  # Informational only: recorded in the ticket comment, never a blocking wait.
48
98
  # Default 0 (no grace); an operator may set grace_hours>0 to reintroduce one.
49
- GRACE_HOURS="${RECONCILE_GRACE_HOURS:-$(yget grace_hours)}"; GRACE_HOURS="${GRACE_HOURS:-0}"
50
- AUTO="$(yget auto_review)"; AUTO="${AUTO:-true}"
99
+ ROLE_GRACE_HOURS="$(role_mapping_value reconcile grace_hours)"
100
+ GRACE_HOURS="${RECONCILE_GRACE_HOURS:-$ROLE_GRACE_HOURS}"
101
+ GRACE_HOURS="$(printf '%s' "${GRACE_HOURS:-0}" | sed 's/^[[:space:]]*//; s/[[:space:]]*$//')"
102
+ case "$GRACE_HOURS" in
103
+ ''|*[!0-9]*)
104
+ printf "AUTONOMOUS REVIEW: CONFIG INVALID - reconcile.grace_hours must be a nonnegative integer (got '%s').\n" "$GRACE_HOURS" >&2
105
+ exit 3
106
+ ;;
107
+ esac
108
+ GRACE_HOURS="$(python3 -c 'import sys; print(int(sys.argv[1]))' "$GRACE_HOURS")"
51
109
 
52
- if [[ "${RECONCILE_AUTO_REVIEW:-$AUTO}" == "false" || "${RECONCILE_AUTO_REVIEW:-}" == "off" ]]; then
53
- printf 'Autonomous review is disabled (reconcile.auto_review=false).\n' >&2; exit 3
54
- fi
110
+ ROLE_AUTO="$(role_mapping_value reconcile auto_review)"
111
+ AUTO="${RECONCILE_AUTO_REVIEW:-$ROLE_AUTO}"
112
+ AUTO="$(printf '%s' "${AUTO:-true}" | sed 's/^[[:space:]]*//; s/[[:space:]]*$//' | tr '[:upper:]' '[:lower:]')"
113
+ case "$AUTO" in
114
+ true|on) : ;;
115
+ false|off)
116
+ printf 'Autonomous review is disabled (reconcile.auto_review=%s).\n' "$AUTO" >&2
117
+ exit 3
118
+ ;;
119
+ *)
120
+ printf "AUTONOMOUS REVIEW: CONFIG INVALID - reconcile.auto_review must be true|on|false|off (got '%s').\n" "$AUTO" >&2
121
+ exit 3
122
+ ;;
123
+ esac
55
124
  [[ -f "$REPORT" ]] || { printf 'Missing review report file: %s\n' "$REPORT" >&2; exit 2; }
56
125
  [[ -f "$EVIDENCE" ]] || { printf 'Missing issue evidence file: %s\n' "$EVIDENCE" >&2; exit 2; }
57
126
 
58
127
  HOLD=""
59
128
  hold() { HOLD="${HOLD}${HOLD:+; }$1"; }
60
129
 
61
- for s in '^## Reviewer' '^## Locked Intent Baseline' '^## Drift Assessment' '^## Adversarial Findings' '^## Decision'; do
62
- grep -q "$s" "$REPORT" || hold "report missing section ${s#^## }"
63
- done
64
- grep -qi '^- *Independent of implementer: *yes' "$REPORT" || hold "reviewer did not attest independence"
65
- REVIEWER="$(sed -n 's/^- *Reviewer agent: *//p' "$REPORT" | head -n1 | tr -d '\r')"; REVIEWER="${REVIEWER:-unknown}"
66
- IMPL="$(sed -n 's/^- *\(Worker\|Implemented by\): *//p' "$EVIDENCE" | head -n1 | tr -d '\r')"
130
+ # Structural parse of the review report (and the evidence's implementer
131
+ # identity): every required H2 exactly once, each authoritative field read
132
+ # only as a direct field of its own section. Lookalike bullets or examples in
133
+ # other sections can never stand in for -- or override -- the authoritative
134
+ # value, and duplicate/missing/blank sections or fields are rejected here,
135
+ # before any provider call.
136
+ PARSED=""
137
+ if ! PARSED="$(python3 - "$REPORT" "$EVIDENCE" <<'PY'
138
+ import re
139
+ import sys
140
+
141
+ report_path, evidence_path = sys.argv[1], sys.argv[2]
142
+
143
+ heading = re.compile(r"^(#{1,6})\s+(.*?)\s*$")
144
+
145
+
146
+ def parse_sections(path):
147
+ with open(path, encoding="utf-8") as stream:
148
+ lines = stream.read().splitlines()
149
+ sections = {}
150
+ order = []
151
+ current = None
152
+ for line in lines:
153
+ match = heading.match(line)
154
+ if match and len(match.group(1)) <= 2:
155
+ current = match.group(2) if len(match.group(1)) == 2 else None
156
+ if current is not None:
157
+ sections.setdefault(current, [])
158
+ order.append(current)
159
+ continue
160
+ if current is not None:
161
+ sections[current].append(line)
162
+ return sections, order
163
+
164
+
165
+ def direct_fields(sections, section, *names):
166
+ found = []
167
+ for line in sections.get(section, []):
168
+ for name in names:
169
+ match = re.fullmatch(
170
+ r"\s*(?:[-*+]\s+)?" + re.escape(name) + r"\s*:\s*(.*?)\s*", line
171
+ )
172
+ if match:
173
+ found.append(match.group(1))
174
+ break
175
+ return found
176
+
177
+
178
+ errors = []
179
+ out = {}
180
+
181
+ sections, order = parse_sections(report_path)
182
+ for name in (
183
+ "Reviewer",
184
+ "Locked Intent Baseline",
185
+ "Drift Assessment",
186
+ "Adversarial Findings",
187
+ "Decision",
188
+ ):
189
+ count = order.count(name)
190
+ if count == 0:
191
+ errors.append(f"report missing section {name}")
192
+ elif count > 1:
193
+ errors.append(f"report has duplicate {name} sections")
194
+
195
+
196
+ def report_field(section, name):
197
+ if order.count(section) != 1:
198
+ return ""
199
+ found = direct_fields(sections, section, name)
200
+ if len(found) != 1:
201
+ errors.append(
202
+ f"report section {section} must contain exactly one"
203
+ f" '{name}:' field (found {len(found)})"
204
+ )
205
+ return ""
206
+ if not found[0]:
207
+ errors.append(f"report field '{name}:' in section {section} is blank")
208
+ return ""
209
+ return found[0]
210
+
211
+
212
+ def first_token(value):
213
+ tokens = value.split()
214
+ return tokens[0].lower() if tokens else ""
215
+
216
+
217
+ out["reviewer"] = report_field("Reviewer", "Reviewer agent")
218
+ out["independent"] = first_token(report_field("Reviewer", "Independent of implementer"))
219
+ out["drift"] = first_token(report_field("Drift Assessment", "Drift assessment"))
220
+ out["findings"] = first_token(report_field("Adversarial Findings", "Critical/high findings"))
221
+ out["decision"] = first_token(report_field("Decision", "Decision"))
222
+
223
+ evidence_sections, evidence_order = parse_sections(evidence_path)
224
+ implementer = ""
225
+ if evidence_order.count("Issue") != 1:
226
+ errors.append(
227
+ "evidence must contain exactly one Issue section carrying the"
228
+ " implementer identity"
229
+ )
230
+ else:
231
+ found = direct_fields(evidence_sections, "Issue", "Worker", "Implemented by")
232
+ if len(found) != 1:
233
+ errors.append(
234
+ "evidence section Issue must contain exactly one implementer"
235
+ " identity ('Worker:' / 'Implemented by:') field"
236
+ f" (found {len(found)})"
237
+ )
238
+ elif not found[0]:
239
+ errors.append("evidence implementer identity in section Issue is blank")
240
+ else:
241
+ implementer = found[0]
242
+ out["implementer"] = implementer
243
+
244
+ for key, value in out.items():
245
+ print("F\t{}\t{}".format(key, value.replace("\t", " ").replace("\n", " ")))
246
+ for error in errors:
247
+ print(f"E\t{error}")
248
+ PY
249
+ )"; then
250
+ hold "review report could not be parsed"
251
+ fi
252
+
253
+ REVIEWER=""; INDEP=""; DRIFT=""; FINDINGS=""; DEC=""; IMPL=""
254
+ while IFS="$(printf '\t')" read -r kind key value; do
255
+ case "$kind" in
256
+ E) hold "$key" ;;
257
+ F)
258
+ case "$key" in
259
+ reviewer) REVIEWER="$value" ;;
260
+ independent) INDEP="$value" ;;
261
+ drift) DRIFT="$value" ;;
262
+ findings) FINDINGS="$value" ;;
263
+ decision) DEC="$value" ;;
264
+ implementer) IMPL="$value" ;;
265
+ esac
266
+ ;;
267
+ esac
268
+ done <<EOF
269
+ $PARSED
270
+ EOF
271
+ REVIEWER="${REVIEWER:-unknown}"
272
+
273
+ [[ "$INDEP" == "yes" ]] || hold "reviewer did not attest independence"
67
274
  [[ -n "$IMPL" && "$IMPL" == "$REVIEWER" ]] && hold "reviewer ($REVIEWER) is the implementer"
68
275
 
69
- DRIFT="$(sed -n 's/^- *Drift assessment: *//p' "$REPORT" | head -n1 | tr -d '\r' | tr 'A-Z' 'a-z' | awk '{print $1}')"
70
276
  case "$DRIFT" in
71
277
  none|minor) : ;;
72
278
  significant) hold "significant drift from locked intent" ;;
73
279
  *) hold "drift assessment missing/invalid ('${DRIFT:-none-found}')"; DRIFT="${DRIFT:-unknown}" ;;
74
280
  esac
75
- grep -qi '^- *Critical/high findings: *none' "$REPORT" || hold "unresolved critical/high findings (or line missing)"
281
+ [[ "$FINDINGS" == "none" ]] || hold "unresolved critical/high findings (or field missing)"
76
282
  # Accept the keyword `accept` as clearing; tolerate the legacy `close`.
77
- DEC="$(sed -n 's/^- *Decision: *//p' "$REPORT" | head -n1 | tr -d '\r' | tr 'A-Z' 'a-z' | awk '{print $1}')"
78
283
  [[ "$DEC" == "accept" || "$DEC" == "close" ]] || hold "reviewer decision is not 'accept' (got '${DEC:-none}')"
79
284
 
80
285
  GATE=fail
@@ -87,27 +292,47 @@ if [[ "$DECISION" == "held" ]]; then
87
292
  exit 3
88
293
  fi
89
294
 
90
- printf 'AUTONOMOUS REVIEW: ACCEPTED - treat as done (no human wait) for %s (reviewer: %s | drift: %s | gate: %s)\n' \
91
- "$ISSUE" "$REVIEWER" "$DRIFT" "$GATE"
92
-
295
+ PROV="$(role_mapping_value ticket_provider name)"; PROV="${PROV:-}"
93
296
  if [[ "$CLOSE" -eq 1 ]]; then
94
297
  # Optional operator QA sweep: close through the ticket-provider adapter.
95
- PROV="$(yget name)"; PROV="${PROV:-}"
96
- if TICKET_PROVIDER="$PROV" bash -c '. "$1"; tp transition "$2" completed' _ "$SCRIPTS_DIR/lib/ticket-provider.sh" "$ISSUE"; then
97
- printf 'Ticket %s transitioned to completed via adapter.\n' "$ISSUE"
98
- TICKET_PROVIDER="$PROV" bash -c '. "$1"; tp comment "$2" "$3"' _ "$SCRIPTS_DIR/lib/ticket-provider.sh" "$ISSUE" \
99
- "Autonomously accepted by $REVIEWER under the independent adversarial-review protocol (drift: $DRIFT, gate: $GATE, grace ${GRACE_HOURS}h informational). Treated as done; review report: $REPORT." >/dev/null 2>&1 || true
100
- else
101
- printf 'Adapter transition failed; issue left open.\n' >&2
298
+ if ! TICKET_PROVIDER="$PROV" bash -c '. "$1"; tp transition "$2" completed' _ "$SCRIPTS_DIR/lib/ticket-provider.sh" "$ISSUE" \
299
+ >/dev/null 2>&1; then
300
+ printf 'AUTONOMOUS REVIEW: CLOSE FAILED for %s - adapter transition failed; issue left open.\n' "$ISSUE" >&2
102
301
  exit 1
103
302
  fi
303
+
304
+ COMMENT_ID=""
305
+ if ! COMMENT_ID="$(TICKET_PROVIDER="$PROV" bash -c '. "$1"; tp comment "$2" "$3"' _ "$SCRIPTS_DIR/lib/ticket-provider.sh" "$ISSUE" \
306
+ "Autonomously accepted by $REVIEWER under the independent adversarial-review protocol (drift: $DRIFT, gate: $GATE, grace ${GRACE_HOURS}h informational). Treated as done; review report: $REPORT." 2>/dev/null)"; then
307
+ printf 'AUTONOMOUS REVIEW: CLOSE INCOMPLETE for %s - transition succeeded, but acceptance comment failed; issue may already be completed.\n' "$ISSUE" >&2
308
+ exit 1
309
+ fi
310
+ if [[ ! "$COMMENT_ID" =~ [^[:space:]] ]]; then
311
+ printf 'AUTONOMOUS REVIEW: CLOSE INCOMPLETE for %s - transition succeeded, but acceptance comment returned no id; comment write unproven and issue may already be completed.\n' "$ISSUE" >&2
312
+ exit 1
313
+ fi
314
+
315
+ # Acceptance is an assertion about both required writes on this path, so no
316
+ # acceptance-shaped output may escape until transition and comment succeed.
317
+ printf 'AUTONOMOUS REVIEW: ACCEPTED - treat as done (no human wait) for %s (reviewer: %s | drift: %s | gate: %s)\n' \
318
+ "$ISSUE" "$REVIEWER" "$DRIFT" "$GATE"
319
+ printf 'Ticket %s transitioned to completed via adapter.\n' "$ISSUE"
104
320
  else
105
321
  # Accepted: the loop autonomously treats the ticket as done and leaves it in
106
322
  # the review lane (deferred-QA queue). Record the autonomous acceptance via the
107
323
  # adapter -- no approval request, no "waiting on the operator".
108
- PROV="$(yget name)"; PROV="${PROV:-}"
109
- TICKET_PROVIDER="$PROV" bash -c '. "$1"; tp comment "$2" "$3"' _ "$SCRIPTS_DIR/lib/ticket-provider.sh" "$ISSUE" \
110
- "Autonomously accepted by $REVIEWER under the independent adversarial-review protocol (drift: $DRIFT, gate: $GATE, grace ${GRACE_HOURS}h informational). Treated as done; stays in the review lane (deferred-QA queue). Review report: $REPORT." >/dev/null 2>&1 || true
324
+ COMMENT_ID=""
325
+ if ! COMMENT_ID="$(TICKET_PROVIDER="$PROV" bash -c '. "$1"; tp comment "$2" "$3"' _ "$SCRIPTS_DIR/lib/ticket-provider.sh" "$ISSUE" \
326
+ "Autonomously accepted by $REVIEWER under the independent adversarial-review protocol (drift: $DRIFT, gate: $GATE, grace ${GRACE_HOURS}h informational). Treated as done; stays in the review lane (deferred-QA queue). Review report: $REPORT." 2>/dev/null)"; then
327
+ printf 'AUTONOMOUS REVIEW: COMMENT FAILED for %s - acceptance comment was not recorded; issue left in review.\n' "$ISSUE" >&2
328
+ exit 1
329
+ fi
330
+ if [[ ! "$COMMENT_ID" =~ [^[:space:]] ]]; then
331
+ printf 'AUTONOMOUS REVIEW: COMMENT UNPROVEN for %s - acceptance comment returned no id; issue left in review.\n' "$ISSUE" >&2
332
+ exit 1
333
+ fi
334
+ printf 'AUTONOMOUS REVIEW: ACCEPTED - treat as done (no human wait) for %s (reviewer: %s | drift: %s | gate: %s)\n' \
335
+ "$ISSUE" "$REVIEWER" "$DRIFT" "$GATE"
111
336
  printf 'Accepted: ticket stays in the review lane (deferred-QA queue); the loop moves on.\n'
112
337
  printf 'Optional operator QA sweep: re-run with --close to transition %s to completed via the adapter.\n' "$ISSUE"
113
338
  fi
@@ -13,36 +13,167 @@ fi
13
13
  ISSUE="$1"
14
14
  case "$ISSUE" in *[!A-Za-z0-9_-]*) printf 'Invalid issue id: %s\n' "$ISSUE" >&2; exit 2 ;; esac
15
15
 
16
+ BIN_DIR="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)"
17
+ ROLE_YAML="$BIN_DIR/../../../role.yaml"
18
+ ROLE_REPO="$(sed -n 's/^repo:[[:space:]]*//p' "$ROLE_YAML" 2>/dev/null | head -n1 | tr -d '"' | tr -d '\r')"
16
19
  ROOT="${2:-$(git rev-parse --show-toplevel 2>/dev/null || pwd)}"
17
20
  cd "$ROOT"
21
+ ROOT="$(pwd -P)"
22
+ PROJECT_MANIFEST="$ROOT/.project.json"
23
+ if [ -e "$PROJECT_MANIFEST" ] || [ -L "$PROJECT_MANIFEST" ]; then
24
+ [ -f "$PROJECT_MANIFEST" ] || {
25
+ printf 'Project manifest is not a regular file: %s\n' "$PROJECT_MANIFEST" >&2
26
+ exit 1
27
+ }
28
+ REPO_SLUG="$(python3 - "$PROJECT_MANIFEST" <<'PY'
29
+ import json
30
+ import pathlib
31
+ import sys
32
+
33
+ path = pathlib.Path(sys.argv[1])
34
+ try:
35
+ document = json.loads(path.read_text(encoding="utf-8"))
36
+ except (OSError, UnicodeError, json.JSONDecodeError) as exc:
37
+ raise SystemExit(f"close gate: malformed project manifest {path}: {exc}")
38
+ slug = document.get("project_slug") if isinstance(document, dict) else None
39
+ if not isinstance(slug, str) or not slug.strip():
40
+ raise SystemExit(f"close gate: project manifest {path} has no non-blank project_slug")
41
+ print(slug.strip())
42
+ PY
43
+ )" || exit 1
44
+ else
45
+ REPO_SLUG="$(basename "$ROOT")"
46
+ fi
47
+ if [ -n "$ROLE_REPO" ] && [ "$ROLE_REPO" != "$REPO_SLUG" ]; then
48
+ printf 'Installed role repo %s disagrees with target project slug %s.\n' "$ROLE_REPO" "$REPO_SLUG" >&2
49
+ exit 1
50
+ fi
18
51
 
19
52
  FILE="_bmad-output/implementation-artifacts/issue-evidence/$ISSUE.md"
20
53
  FAIL=0
21
- check() { grep -q "$1" "$FILE" || { printf 'Missing required evidence: %s\n' "$2" >&2; FAIL=1; }; }
22
54
 
23
55
  if [ ! -f "$FILE" ]; then
24
56
  printf 'Missing issue evidence file: %s\n' "$FILE" >&2
25
57
  exit 1
26
58
  fi
27
59
 
28
- check '^## Issue' 'Issue'
29
- check '^## Acceptance Criteria' 'Acceptance Criteria'
30
- check '^## Repo Changes' 'Repo Changes'
31
- check '^## Verification' 'Verification'
32
- check '^## Ledger Update' 'Ledger Update'
33
- check '^## Known Gaps' 'Known Gaps'
34
- check '^## Close Recommendation' 'Close Recommendation'
60
+ # Structural parse: every required H2 exactly once, and each authoritative
61
+ # field read only as a direct field of its own section. Lookalike lines in
62
+ # other sections can never stand in for -- or override -- the authoritative
63
+ # value (an authoritative `no`/`hold` always fails the gate). The implementer
64
+ # identity is defined as exactly one nonblank `Worker:` / `Implemented by:`
65
+ # field in the Issue section; duplicates, blanks, and conflicting spellings
66
+ # are rejected.
67
+ GATE_PROBLEMS=""
68
+ if ! GATE_PROBLEMS="$(python3 - "$FILE" <<'PY'
69
+ import re
70
+ import sys
71
+
72
+ with open(sys.argv[1], encoding="utf-8") as stream:
73
+ lines = stream.read().splitlines()
74
+
75
+ REQUIRED = [
76
+ "Issue",
77
+ "Acceptance Criteria",
78
+ "Repo Changes",
79
+ "Verification",
80
+ "Ledger Update",
81
+ "Known Gaps",
82
+ "Close Recommendation",
83
+ ]
84
+
85
+ heading = re.compile(r"^(#{1,6})\s+(.*?)\s*$")
86
+ sections = {}
87
+ order = []
88
+ current = None
89
+ for line in lines:
90
+ match = heading.match(line)
91
+ if match and len(match.group(1)) <= 2:
92
+ current = match.group(2) if len(match.group(1)) == 2 else None
93
+ if current is not None:
94
+ sections.setdefault(current, [])
95
+ order.append(current)
96
+ continue
97
+ if current is not None:
98
+ sections[current].append(line)
99
+
100
+ problems = []
101
+ for name in REQUIRED:
102
+ count = order.count(name)
103
+ if count == 0:
104
+ problems.append(f"Missing required evidence: {name}")
105
+ elif count > 1:
106
+ problems.append(f"Duplicate required evidence section: {name}")
107
+
108
+
109
+ def direct_fields(section, *names):
110
+ found = []
111
+ for line in sections.get(section, []):
112
+ for name in names:
113
+ match = re.fullmatch(
114
+ r"\s*(?:[-*+]\s+)?" + re.escape(name) + r"\s*:\s*(.*?)\s*", line
115
+ )
116
+ if match:
117
+ found.append(match.group(1))
118
+ break
119
+ return found
120
+
121
+
122
+ def first_token(value):
123
+ tokens = value.split()
124
+ return tokens[0].lower() if tokens else ""
125
+
126
+
127
+ if order.count("Ledger Update") == 1:
128
+ found = direct_fields("Ledger Update", "Ledger updated")
129
+ if len(found) != 1:
130
+ problems.append(
131
+ "Expected exactly one 'Ledger updated:' field in '## Ledger Update'"
132
+ f" (found {len(found)})."
133
+ )
134
+ elif first_token(found[0]) != "yes":
135
+ problems.append("Ledger update is not marked yes.")
136
+
137
+ if order.count("Close Recommendation") == 1:
138
+ found = direct_fields("Close Recommendation", "Close recommendation")
139
+ if len(found) != 1:
140
+ problems.append(
141
+ "Expected exactly one 'Close recommendation:' field in"
142
+ f" '## Close Recommendation' (found {len(found)})."
143
+ )
144
+ elif first_token(found[0]) != "ready":
145
+ problems.append("Close recommendation is not ready.")
146
+
147
+ if order.count("Issue") == 1:
148
+ found = direct_fields("Issue", "Worker", "Implemented by")
149
+ if len(found) != 1:
150
+ problems.append(
151
+ "Expected exactly one implementer identity ('Worker:' /"
152
+ f" 'Implemented by:') in '## Issue' (found {len(found)})."
153
+ )
154
+ elif not found[0]:
155
+ problems.append("The implementer identity in '## Issue' is blank.")
156
+
157
+ for problem in problems:
158
+ print(problem)
159
+ PY
160
+ )"; then
161
+ printf 'Evidence file could not be parsed: %s\n' "$FILE" >&2
162
+ exit 1
163
+ fi
164
+ if [ -n "$GATE_PROBLEMS" ]; then
165
+ printf '%s\n' "$GATE_PROBLEMS" >&2
166
+ FAIL=1
167
+ fi
35
168
 
36
169
  if grep -Eiq 'TBD|TODO|not run|pending|unknown' "$FILE"; then
37
170
  printf 'Evidence file still contains unresolved placeholders or unverified work.\n' >&2
38
171
  FAIL=1
39
172
  fi
40
- grep -q 'Ledger updated: yes' "$FILE" || { printf 'Ledger update is not marked yes.\n' >&2; FAIL=1; }
41
- grep -q 'Close recommendation: ready' "$FILE" || { printf 'Close recommendation is not ready.\n' >&2; FAIL=1; }
42
173
 
43
174
  if [ "$FAIL" -ne 0 ]; then
44
175
  printf '\nCLOSE GATE: FAIL for %s\n' "$ISSUE" >&2
45
176
  exit 1
46
177
  fi
47
178
 
48
- printf 'CLOSE GATE: PASS for %s\n' "$ISSUE"
179
+ printf 'CLOSE GATE: PASS for %s (repo: %s)\n' "$ISSUE" "$REPO_SLUG"
@@ -31,7 +31,9 @@ current and machine-readable: `source`, `agent_id`, `repo`, `ticket_provider`,
31
31
 
32
32
  ## Source order (each pass)
33
33
 
34
- 1. Active milestone (`tp active_milestone`) and issues (`tp list_issues`).
34
+ 1. Active milestone (`tp active_milestone`) and issues (`tp list_issues`). Plane's
35
+ issue list is project-wide: current-cycle visibility is exactly the rows with
36
+ `in_active_milestone:true`, not every returned issue.
35
37
  2. Local evidence under `_bmad-output/implementation-artifacts/issue-evidence/`.
36
38
  3. Live worker state: zellij sessions, worktrees, branches, recent git.
37
39
 
@@ -55,7 +55,11 @@ ticket_provider:
55
55
  {%- elif ticket_provider == 'trello' %}
56
56
  board: "" # Trello board id (set by 42-ticket-provider.sh)
57
57
  {%- endif %}
58
+ timezone: "" # IANA project calendar; empty = TICKET_PROVIDER_TIMEZONE, TZ, then host-local
58
59
  # Optional normalized-state name overrides for non-standard boards.
60
+ backlog: "" # e.g. "Backlog"
61
+ unstarted: "" # e.g. "Todo"
62
+ started: "" # e.g. "In Progress"
59
63
  in_review: "" # e.g. "In Review"
60
64
  completed: "" # e.g. "Done"
61
65
  cancelled: "" # e.g. "Cancelled"