@windyroad/itil 0.4.2 → 0.4.3-preview.99

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.
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "wr-itil",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "ITIL-aligned IT service management for Claude Code"
5
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@windyroad/itil",
3
- "version": "0.4.2",
3
+ "version": "0.4.3-preview.99",
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"
@@ -130,12 +130,24 @@ Before creating, search existing problems for similar issues. The user may not k
130
130
 
131
131
  ### 3. For new problems: Assign the next ID
132
132
 
133
- Scan `docs/problems/` for existing files. Extract the highest numeric ID and increment by 1. Zero-pad to 3 digits.
133
+ Compute the next ID as the **max of the local and origin highest IDs**, plus one, zero-padded to 3 digits. Comparing against `origin/<base>` is required by ADR-019 (confirmation criterion 2): without it, parallel sessions can mint the same ID for different problems and force a destructive surgical rebase on push (P040 incident).
134
134
 
135
135
  ```bash
136
- ls docs/problems/*.md 2>/dev/null | sed 's/.*\///' | grep -oE '^[0-9]+' | sort -n | tail -1
136
+ # Local-max ID
137
+ local_max=$(ls docs/problems/*.md 2>/dev/null | sed 's/.*\///' | grep -oE '^[0-9]+' | sort -n | tail -1)
138
+
139
+ # Origin-max ID — `git ls-tree origin/<base>` reads remote-tracking ref
140
+ # without requiring a fetch in this step (Step 0 preflight is the place
141
+ # where the fetch happens). Default base is `main`; if the user is on
142
+ # another branch, swap accordingly.
143
+ origin_max=$(git ls-tree origin/main docs/problems/ 2>/dev/null | grep -oE '[0-9]{3}' | sort -n | tail -1)
144
+
145
+ # Take the max of the two and increment.
146
+ next=$(printf '%03d' $(( $(echo -e "${local_max:-0}\n${origin_max:-0}" | sort -n | tail -1) + 1 )))
137
147
  ```
138
148
 
149
+ If the local choice would have collided with an origin ticket created since the last fetch, the `git ls-tree origin/<base>` lookup catches it here and the renumber is automatic. Log the renumber decision in the operation report (e.g. "Bumped next ID from 042 → 043 to avoid collision with origin").
150
+
139
151
  ### 4. For new problems: Gather information
140
152
 
141
153
  If the arguments contain a description, extract what you can. For anything missing, use `AskUserQuestion` to gather:
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env bats
2
+ # Doc-lint guard: manage-problem SKILL.md step 3 (Assign the next ID) must
3
+ # include the next-ID collision guard against origin per ADR-019
4
+ # confirmation criterion 2.
5
+ #
6
+ # Structural assertion — Permitted Exception to the source-grep ban (ADR-005 / P011).
7
+ # These tests assert that the skill specification document instructs the
8
+ # orchestrator to compare next-ID against origin/<base> before assigning,
9
+ # so parallel sessions don't produce colliding ticket numbers.
10
+ #
11
+ # Cross-reference:
12
+ # P043 (next-ID collision guard in ticket-creator skills)
13
+ # P040 (work-problems does not fetch origin before starting — sibling)
14
+ # ADR-019 (AFK orchestrator preflight, including next-ID guard)
15
+ # @jtbd JTBD-006 (Progress the Backlog While I'm Away)
16
+
17
+ setup() {
18
+ SKILL_DIR="$(cd "$(dirname "$BATS_TEST_FILENAME")/.." && pwd)"
19
+ SKILL_FILE="${SKILL_DIR}/SKILL.md"
20
+ }
21
+
22
+ @test "SKILL.md cites ADR-019 (next-ID collision guard)" {
23
+ run grep -n "ADR-019" "$SKILL_FILE"
24
+ [ "$status" -eq 0 ]
25
+ }
26
+
27
+ @test "SKILL.md step 3 references git ls-tree origin for next-ID lookup" {
28
+ # ADR-019 mechanism: the orchestrator MUST re-check next-ID assignment
29
+ # against `git ls-tree origin/<base>` before creating any new ticket.
30
+ run grep -n "git ls-tree origin" "$SKILL_FILE"
31
+ [ "$status" -eq 0 ]
32
+ }
33
+
34
+ @test "SKILL.md mentions taking the max of local and origin IDs" {
35
+ # The guard logic is: take the max of local-max-ID and origin-max-ID,
36
+ # then increment. Skill must mention this combination.
37
+ run grep -niE "max of (the )?(two|local and origin)|max\(.*origin" "$SKILL_FILE"
38
+ [ "$status" -eq 0 ]
39
+ }