@windyroad/itil 0.14.0 → 0.15.0-preview.157

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.
@@ -0,0 +1,142 @@
1
+ #!/usr/bin/env bats
2
+ # Contract assertions for /wr-itil:restore-incident (P071 split slice 6b).
3
+ #
4
+ # This skill hosts the "mark an incident as restored" user intent previously
5
+ # hidden behind /wr-itil:manage-incident <I> restored. It transitions an
6
+ # incident from .mitigating.md to .restored.md, updates the Status field,
7
+ # appends a "Service restored" timeline entry, and invokes the Skill tool
8
+ # to hand off to /wr-itil:manage-problem for linked-problem creation /
9
+ # update per ADR-011's Decision Outcome point 4.
10
+ #
11
+ # Structural assertion — Permitted Exception to the source-grep ban
12
+ # (ADR-005 / P011 / ADR-037 contract-assertion pattern).
13
+ #
14
+ # @problem P071
15
+ # @jtbd JTBD-001 (enforce governance without slowing down — discoverable surface)
16
+ # @jtbd JTBD-101 (extend the suite with clear patterns — one skill per distinct user intent)
17
+ # @jtbd JTBD-201 (restore service fast with an audit trail — this skill IS the active-restoration path)
18
+ #
19
+ # Cross-reference:
20
+ # P071: docs/problems/071-argument-based-skill-subcommands-are-not-discoverable.open.md
21
+ # ADR-010 amended (Skill Granularity section) — split naming + forwarder contract
22
+ # ADR-011 — manage-incident skill-wrapping precedent (cross-skill Skill-tool invocation to manage-problem)
23
+ # ADR-037 — contract-assertion bats pattern
24
+
25
+ setup() {
26
+ SKILL_DIR="$(cd "$(dirname "$BATS_TEST_FILENAME")/.." && pwd)"
27
+ SKILL_FILE="${SKILL_DIR}/SKILL.md"
28
+ }
29
+
30
+ @test "SKILL.md exists and has frontmatter" {
31
+ [ -f "$SKILL_FILE" ]
32
+ run head -1 "$SKILL_FILE"
33
+ [ "$status" -eq 0 ]
34
+ [ "$output" = "---" ]
35
+ }
36
+
37
+ @test "SKILL.md frontmatter name is wr-itil:restore-incident (P071 + ADR-010 amended)" {
38
+ # Split naming convention per ADR-010 amendment: <verb>-<object> pair.
39
+ # The new skill's name must match the phased-landing plan pinned in P071.
40
+ run grep -n "^name: wr-itil:restore-incident$" "$SKILL_FILE"
41
+ [ "$status" -eq 0 ]
42
+ }
43
+
44
+ @test "SKILL.md frontmatter description names the restore intent (P071)" {
45
+ # Description must name "restore" and "incident" so Claude Code autocomplete
46
+ # surfaces the user intent rather than a generic name.
47
+ run grep -inE "^description:.*restor.*incident|^description:.*incident.*restor|^description:.*service restored" "$SKILL_FILE"
48
+ [ "$status" -eq 0 ]
49
+ }
50
+
51
+ @test "SKILL.md frontmatter allowed-tools grants file-mutation + Skill surface (P071 — restore requires rename + handoff)" {
52
+ # restore-incident renames .mitigating.md → .restored.md, updates the
53
+ # Status field, and invokes /wr-itil:manage-problem via the Skill tool.
54
+ # AskUserQuestion is required for the problem-handoff prompt (yes /
55
+ # no-with-justification) per ADR-011 Decision Outcome point 4.
56
+ run grep -nE "^allowed-tools:" "$SKILL_FILE"
57
+ [ "$status" -eq 0 ]
58
+ run grep -nE "^allowed-tools:.*Write" "$SKILL_FILE"
59
+ [ "$status" -eq 0 ]
60
+ run grep -nE "^allowed-tools:.*Edit" "$SKILL_FILE"
61
+ [ "$status" -eq 0 ]
62
+ run grep -nE "^allowed-tools:.*Bash" "$SKILL_FILE"
63
+ [ "$status" -eq 0 ]
64
+ run grep -nE "^allowed-tools:.*AskUserQuestion" "$SKILL_FILE"
65
+ [ "$status" -eq 0 ]
66
+ run grep -nE "^allowed-tools:.*Skill" "$SKILL_FILE"
67
+ [ "$status" -eq 0 ]
68
+ }
69
+
70
+ @test "SKILL.md documents the .mitigating.md → .restored.md rename (P071 + ADR-011)" {
71
+ # The restore transition renames the incident file from .mitigating.md
72
+ # to .restored.md. The SKILL.md must name both suffixes explicitly so
73
+ # the file-suffix contract is legible.
74
+ run grep -inE "\.mitigating\.md" "$SKILL_FILE"
75
+ [ "$status" -eq 0 ]
76
+ run grep -inE "\.restored\.md" "$SKILL_FILE"
77
+ [ "$status" -eq 0 ]
78
+ }
79
+
80
+ @test "SKILL.md documents the verification-signal pre-flight (P071 + ADR-011)" {
81
+ # Per ADR-011, restore requires at least one recorded mitigation attempt
82
+ # AND a captured verification signal (e.g. "error rate back to baseline
83
+ # per Datadog", "user reports normal", "synthetic probe passing").
84
+ # The SKILL.md must name the verification-signal check explicitly.
85
+ run grep -inE "verification signal|verify|verification" "$SKILL_FILE"
86
+ [ "$status" -eq 0 ]
87
+ }
88
+
89
+ @test "SKILL.md documents the manage-problem handoff via the Skill tool (P071 + ADR-011 Decision Outcome 4)" {
90
+ # The restore transition hands off to /wr-itil:manage-problem via the
91
+ # Skill tool so a problem record is created or updated with the timeline
92
+ # summary + top-ranked hypothesis + mitigation + verification signal.
93
+ # The SKILL.md must name the handoff target so the cross-skill
94
+ # invocation is legible.
95
+ run grep -inE "wr-itil:manage-problem|manage-problem" "$SKILL_FILE"
96
+ [ "$status" -eq 0 ]
97
+ run grep -inE "Skill tool|via the Skill" "$SKILL_FILE"
98
+ [ "$status" -eq 0 ]
99
+ }
100
+
101
+ @test "SKILL.md documents the 'no problem required' justification path (P071 + ADR-011)" {
102
+ # Per ADR-011, the user may decline problem creation with a documented
103
+ # justification (e.g. "one-off cosmic-bit-flip; not reproducible"). The
104
+ # SKILL.md must document the No Problem section write so the audit
105
+ # trail invariant (JTBD-201) is preserved post-split.
106
+ run grep -inE "No Problem|no problem required|no-problem" "$SKILL_FILE"
107
+ [ "$status" -eq 0 ]
108
+ }
109
+
110
+ @test "SKILL.md cites P071 and ADR-010 amended (P071 + ADR-025)" {
111
+ # ADR-025 inheritance per ADR-037: contract-assertion bats should reflect
112
+ # traceability cites on the skill spec document.
113
+ run grep -inE "P071|ADR-010" "$SKILL_FILE"
114
+ [ "$status" -eq 0 ]
115
+ }
116
+
117
+ @test "SKILL.md cites ADR-011 for the incident lifecycle conventions (P071 + ADR-011)" {
118
+ # restore-incident inherits file-suffix conventions and the handoff
119
+ # contract from ADR-011. The SKILL.md must cite ADR-011 so the
120
+ # precedent chain is legible.
121
+ run grep -inE "ADR-011" "$SKILL_FILE"
122
+ [ "$status" -eq 0 ]
123
+ }
124
+
125
+ @test "SKILL.md does not carry a deprecated-arguments frontmatter flag (clean-split skill)" {
126
+ # restore-incident is a clean-split skill with no argument-subcommands
127
+ # itself (its argument is a data parameter — incident ID only).
128
+ # ADR-010 amendment's `deprecated-arguments: true` flag is only valid
129
+ # on host skills with forwarder routes. restore-incident is a
130
+ # forwarder TARGET, not a host. It must NOT carry the flag.
131
+ run grep -E "^deprecated-arguments:" "$SKILL_FILE"
132
+ [ "$status" -ne 0 ]
133
+ }
134
+
135
+ @test "SKILL.md does not use word-argument subcommand branching (P071 regression guard)" {
136
+ # The whole point of P071: Claude Code autocomplete does not surface
137
+ # word-argument subcommands. A clean-split skill must not reintroduce
138
+ # word-arg subcommand routing (e.g. `list` / `mitigate` / `restore`).
139
+ # The data parameter <I> is a string, not a verb keyword.
140
+ run grep -inE "If arguments start with \"(list|mitigate|restore|close|link)\"|If arguments contain \"(list|mitigate|restore|close|link)\"" "$SKILL_FILE"
141
+ [ "$status" -ne 0 ]
142
+ }