@windyroad/itil 0.47.2 → 0.47.3

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.
@@ -497,5 +497,5 @@
497
497
  }
498
498
  },
499
499
  "name": "wr-itil",
500
- "version": "0.47.2"
500
+ "version": "0.47.3"
501
501
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@windyroad/itil",
3
- "version": "0.47.2",
3
+ "version": "0.47.3",
4
4
  "description": "ITIL-aligned IT service management for Claude Code (problem, and future incident/change skills)",
5
5
  "bin": {
6
6
  "windyroad-itil": "./bin/install.mjs"
@@ -251,8 +251,16 @@ if [ -d "$PROBLEMS_DIR" ]; then
251
251
  # problem_rfc_ids["P168"] = "RFC-001 RFC-002 ..."
252
252
  declare -A problem_rfc_rows
253
253
  declare -A problem_rfc_ids
254
+ # P312 / ADR-031: scan both flat docs/problems/<NNN>-*.md AND per-state
255
+ # subdir docs/problems/<state>/<NNN>-*.md layouts so the reverse-trace
256
+ # remains valid post-migration. Mirrors reconcile-readme.sh lines 74-110.
254
257
  shopt -s nullglob
255
- for pf in "$PROBLEMS_DIR"/[0-9][0-9][0-9]-*.md; do
258
+ problem_files=( "$PROBLEMS_DIR"/[0-9][0-9][0-9]-*.md )
259
+ for ticket_status in open known-error verifying closed parked; do
260
+ problem_files+=( "$PROBLEMS_DIR"/"$ticket_status"/[0-9][0-9][0-9]-*.md )
261
+ done
262
+ shopt -u nullglob
263
+ for pf in "${problem_files[@]}"; do
256
264
  pbase="$(basename "$pf")"
257
265
  pnum="${pbase%%-*}"
258
266
  pid="P${pnum}"
@@ -274,7 +282,6 @@ if [ -d "$PROBLEMS_DIR" ]; then
274
282
  done < <(awk -v start="$sec_start" 'NR>start { if (/^## /) exit; print }' "$pf")
275
283
  problem_rfc_ids["$pid"]="$rfcs_in_p"
276
284
  done
277
- shopt -u nullglob
278
285
 
279
286
  # 1. MISSING_REVERSE_TRACE: RFC claims P, P does not list RFC.
280
287
  for rfc_id in "${!rfc_problems_claim[@]}"; do
@@ -131,6 +131,40 @@ EOF
131
131
  fi
132
132
  }
133
133
 
134
+ # Helper: write a problem ticket under the per-state subdir layout per
135
+ # ADR-031 (state is the parent directory; filename has NO `.state.md` suffix).
136
+ # Args: <pid-num> <slug> <state> <rfcs-rows-block>
137
+ # Used to regression-test P312 — reconcile-rfcs reverse-trace must traverse
138
+ # docs/problems/<state>/<NNN>-*.md, not just flat docs/problems/<NNN>-*.<state>.md.
139
+ write_problem_subdir() {
140
+ local num="$1" slug="$2" state="$3" rfcs_rows="${4:-}"
141
+ mkdir -p "$PROBLEMS_DIR/$state"
142
+ local file="$PROBLEMS_DIR/$state/${num}-${slug}.md"
143
+ cat > "$file" <<EOF
144
+ # Problem ${num}: ${slug}
145
+
146
+ **Status**: ${state}
147
+
148
+ ## Description
149
+
150
+ stub
151
+
152
+ ## Related
153
+
154
+ stub
155
+ EOF
156
+ if [ -n "$rfcs_rows" ]; then
157
+ cat >> "$file" <<EOF
158
+
159
+ ## RFCs
160
+
161
+ | RFC | Status | Title |
162
+ |-----|--------|-------|
163
+ ${rfcs_rows}
164
+ EOF
165
+ fi
166
+ }
167
+
134
168
  # ── Existence + executable ──────────────────────────────────────────────────
135
169
 
136
170
  @test "reconcile-rfcs: script exists" {
@@ -413,6 +447,35 @@ EOF
413
447
  done <<< "$output"
414
448
  }
415
449
 
450
+ # ── P312: per-state subdir reverse-trace (ADR-031 layout) ───────────────────
451
+ # Closes P312 — reconcile-rfcs reported spurious MISSING_REVERSE_TRACE for
452
+ # tickets that live under docs/problems/<state>/<NNN>-*.md because the
453
+ # reverse-trace pass only globbed the flat docs/problems/<NNN>-*.md layout.
454
+ # RFC-002-class dual-tolerant-glob fix mirroring the sibling already shipped
455
+ # in reconcile-readme.sh (P118).
456
+
457
+ @test "P312: reverse-trace clean when problem ticket lives in per-state subdir" {
458
+ write_rfc "001" "foo" "accepted"
459
+ write_minimal_readme "| 2.0 | RFC-001 | foo | 3 Med | Accepted | M | 2026-05-05 |"
460
+ # Ticket lives under docs/problems/verifying/168-p168.md (no .state suffix).
461
+ write_problem_subdir "168" "p168" "verifying" "| RFC-001 | accepted | foo |"
462
+ run bash "$SCRIPT" "$FIXTURE_DIR" "$PROBLEMS_DIR"
463
+ [ "$status" -eq 0 ]
464
+ [[ "$output" != *"MISSING_REVERSE_TRACE"* ]]
465
+ }
466
+
467
+ @test "P312: reverse-trace detects missing trace when problem ticket lives in per-state subdir" {
468
+ write_rfc "001" "foo" "accepted"
469
+ write_minimal_readme "| 2.0 | RFC-001 | foo | 3 Med | Accepted | M | 2026-05-05 |"
470
+ # Subdir ticket WITHOUT a `## RFCs` section → MISSING_REVERSE_TRACE must fire.
471
+ write_problem_subdir "168" "p168" "verifying" ""
472
+ run bash "$SCRIPT" "$FIXTURE_DIR" "$PROBLEMS_DIR"
473
+ [ "$status" -eq 1 ]
474
+ [[ "$output" == *"MISSING_REVERSE_TRACE"* ]]
475
+ [[ "$output" == *"RFC-001"* ]]
476
+ [[ "$output" == *"P168"* ]]
477
+ }
478
+
416
479
  # ── ADR-049 bin shim contract ───────────────────────────────────────────────
417
480
 
418
481
  @test "wr-itil-reconcile-rfcs bin shim exists" {