@windyroad/risk-scorer 0.2.0

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,178 @@
1
+ ---
2
+ name: wr:risk-policy
3
+ description: Create or update the project's RISK-POLICY.md per ISO 31000 and the risk-scorer agent. Examines the project to derive business-specific impact levels.
4
+ allowed-tools: Read, Write, Edit, Bash, Glob, Grep, AskUserQuestion, Agent
5
+ ---
6
+
7
+ # Risk Policy Generator
8
+
9
+ Create or update `RISK-POLICY.md` per ISO 31000, tailored to this project's business context. The risk-scorer agent reads this file to score pipeline actions (commit, push, release).
10
+
11
+ ## What belongs in RISK-POLICY.md (single source of truth)
12
+
13
+ - **Risk appetite** -- the residual risk threshold for pipeline actions
14
+ - **Impact levels** -- business consequences of failure, specific to this product and its users
15
+ - **Likelihood levels** -- descriptions of how likely a risk is to materialise
16
+ - **Risk matrix** -- Impact × Likelihood score table and label bands (Low/Medium/High/Critical)
17
+ - **Last reviewed date** -- when the policy was last reviewed or updated
18
+
19
+ The risk-scorer agent, problem management skill, and any other process that needs to assess risk severity reads these definitions from RISK-POLICY.md.
20
+
21
+ ## What does NOT belong in RISK-POLICY.md (lives in the risk-scorer agent)
22
+
23
+ - Assessment rules, back-pressure, control discovery (scoring mechanics)
24
+
25
+ ## Steps
26
+
27
+ ### 1. Read the risk-scorer agent contract
28
+
29
+ Read `.claude/agents/risk-scorer-pipeline.md` to understand what the scorer expects from `RISK-POLICY.md`. Extract:
30
+
31
+ - What fields the agent reads from the policy (look for "Read `RISK-POLICY.md`" in "Your Role")
32
+ - The impact level labels used in the agent's risk matrix (look for the "Product Reference Table")
33
+ - The label bands and their score ranges (look for "Label Bands")
34
+ - The gate threshold the agent uses (look for "risk appetite" references)
35
+
36
+ Use this contract to guide drafting. Do not hardcode assumptions about the number of levels, their labels, or the appetite threshold -- derive them from the agent definition.
37
+
38
+ ### 2. Discover project context
39
+
40
+ Examine the project to understand what it does and who uses it. Adapt to the project type -- do not assume any particular framework or language.
41
+
42
+ **Find the project manifest** (first match wins):
43
+ - `package.json` (Node/JS/TS)
44
+ - `pyproject.toml` or `setup.py` (Python)
45
+ - `go.mod` (Go)
46
+ - `Cargo.toml` (Rust)
47
+ - `Gemfile` (Ruby)
48
+ - `pom.xml` or `build.gradle` (Java/Kotlin)
49
+
50
+ **Find the project description**:
51
+ - `README.md` or `README.*`
52
+ - The `description` field in the manifest
53
+ - A homepage or docs index
54
+
55
+ **Discover user-facing features** by scanning for:
56
+ - Route/endpoint definitions (scan for directories named `routes/`, `pages/`, `api/`, `handlers/`, `controllers/`, or grep for route decorators/annotations)
57
+ - UI entry points (`.html`, `.svelte`, `.tsx`, `.jsx`, `.vue`, `.astro` files)
58
+ - CLI commands or public API surface
59
+
60
+ **Discover infrastructure**:
61
+ - Deployment config (`Dockerfile`, `docker-compose.*`, `fly.toml`, `app.yaml`, `serverless.yml`, `*.tf`, cloud config)
62
+ - CI/CD workflows (`.github/workflows/`, `.gitlab-ci.yml`, `Jenkinsfile`)
63
+ - Database or storage config
64
+
65
+ Build a mental model of: what does this product do, who are its users, and what would hurt them?
66
+
67
+ **Check repository visibility**:
68
+ - Run `gh repo view --json isPrivate` or check for other visibility indicators
69
+ - If the repository is **public**, confidential business metrics (revenue, user counts, pricing, traffic volumes) must not appear in any committed file. Note this for step 5 — the policy must include a "Confidential Information" section and information disclosure must be covered in the impact levels.
70
+
71
+ ### 3. Check for existing policy
72
+
73
+ If `RISK-POLICY.md` already exists, read it. Identify:
74
+
75
+ - Whether impact levels still reflect the current product (features may have been added/removed)
76
+ - Whether the risk appetite is still appropriate
77
+ - Whether the last reviewed date is stale (> 2 weeks)
78
+
79
+ ### 4. Check for recent incidents
80
+
81
+ If `docs/problems/` exists, scan for open or known-error problems (files ending in `.open.md` or `.known-error.md`). For each:
82
+
83
+ - Read the problem to understand its business impact
84
+ - Consider whether the impact levels adequately cover this kind of failure
85
+ - Flag any gap (e.g., a problem caused data corruption but the impact levels don't mention data integrity)
86
+
87
+ If recent incidents suggest the impact levels need updating, note this for step 6 (user confirmation). ISO 31000 requires risk criteria to be reviewed after incidents, not just on a schedule.
88
+
89
+ ### 5. Draft impact levels, likelihood levels, and risk matrix
90
+
91
+ **Impact levels** must describe **business consequences** (ISO 31000 context establishment), not categories of files changed. Each level answers: "What happens to users/business if this goes wrong?"
92
+
93
+ Use 5 levels (Negligible to Severe). Tailor descriptions to this specific product:
94
+
95
+ - **Negligible**: No user impact at all
96
+ - **Minor**: No user impact; only developer/build affected
97
+ - **Moderate**: Deployment/publishing disrupted; users can't get updates. For public repositories: confidential business metrics (revenue, user counts, pricing, traffic volumes) committed to the repository — an information disclosure requiring immediate remediation but not affecting service availability.
98
+ - **Significant**: User-facing features degraded or inaccessible
99
+ - **Severe**: Data integrity, trust, or availability destroyed
100
+
101
+ Reference specific product features, user workflows, and infrastructure by name. Generic descriptions like "application logic affected" are wrong -- say what breaks and for whom.
102
+
103
+ **Likelihood levels** describe how likely a risk is to materialise. Use 5 levels (Rare to Almost certain). These are universal — not product-specific:
104
+
105
+ - **Rare (1)**: Requires specific, unusual conditions. Extensive test coverage or architectural safeguards make occurrence very unlikely.
106
+ - **Unlikely (2)**: Could happen but controls (tests, CI gates, review hooks) significantly reduce probability.
107
+ - **Possible (3)**: Moderate complexity or limited test coverage. Could happen under normal conditions.
108
+ - **Likely (4)**: High complexity, many code paths, or limited controls. Expected to occur without intervention.
109
+ - **Almost certain (5)**: Known gap, no controls in place, or previously observed failure mode.
110
+
111
+ **Risk matrix**: Include the Impact × Likelihood multiplication table (5×5 = scores 1-25) and the label bands:
112
+
113
+ | Score Range | Label |
114
+ |-------------|-------|
115
+ | 1-4 | Low |
116
+ | 5-9 | Medium |
117
+ | 10-14 | High |
118
+ | 15-25 | Critical |
119
+
120
+ The risk matrix is used by both the **risk-scorer agent** (pipeline risk assessment) and the **problem management process** (problem severity via `/problem` skill).
121
+
122
+ ### 6. Confirm with the user
123
+
124
+ You MUST use the AskUserQuestion tool (not plain text output) to collect user confirmation. Do not proceed to step 7 until you have received answers via AskUserQuestion.
125
+
126
+ Call AskUserQuestion with a single message that presents:
127
+
128
+ 1. The drafted impact levels (as a table) and asks whether they accurately reflect what matters most
129
+ 2. The risk appetite threshold -- present the label bands from the agent contract (step 1) and recommend a threshold based on project maturity. Ask the user to confirm or adjust. A prototype with no real users may tolerate higher risk than a production system with paying users or compliance requirements
130
+ 3. Whether any business context is missing (e.g., compliance requirements, SLAs, user base size)
131
+
132
+ ### 7. Validate draft with risk-scorer agent
133
+
134
+ Before writing the policy file, invoke the risk-scorer agent to validate the draft. This is the gate -- the enforce hook will only allow writes to RISK-POLICY.md after the scorer returns PASS.
135
+
136
+ Run the risk-scorer agent (subagent_type: "risk-scorer") with this prompt:
137
+
138
+ > Review this draft risk policy for ISO 31000 compliance. Validate it.
139
+ >
140
+ > [paste the full draft policy content here]
141
+
142
+ The risk-scorer will check:
143
+ - Impact levels describe business consequences (not file categories)
144
+ - Impact labels match the risk matrix (Negligible, Minor, Moderate, Significant, Severe)
145
+ - Risk appetite defines a numeric threshold
146
+ - Business context is present
147
+ - Last reviewed date is present
148
+
149
+ It ends its output with `RISK_VERDICT: PASS` or `RISK_VERDICT: FAIL`. The PostToolUse hook reads this from the agent output and sets the edit marker on PASS.
150
+
151
+ - **If PASS**: proceed to step 8 (write)
152
+ - **If FAIL**: fix the issues the scorer identified, then re-run this step
153
+
154
+ ### 8. Write RISK-POLICY.md
155
+
156
+ Write the policy using the structure derived from the agent contract (step 1). The output must include:
157
+
158
+ - The ISO 31000 header and "Last reviewed" date (today's date)
159
+ - Business context section
160
+ - **Confidential Information section** (for public repositories): stating that business metrics must not appear in committed files, with examples of what is confidential and guidance to use generic descriptions instead
161
+ - The risk appetite threshold confirmed by the user in step 6
162
+ - The impact levels with project-specific descriptions from step 5
163
+ - The likelihood levels (universal 1-5 scale)
164
+ - The risk matrix (Impact × Likelihood table) and label bands
165
+ - A note that both the risk-scorer agent and problem management process reference this policy
166
+
167
+ ## Updating an existing policy
168
+
169
+ When updating rather than creating:
170
+
171
+ - Preserve the existing risk appetite unless the user wants to change it
172
+ - Compare current impact levels against the current state of the project
173
+ - Flag levels that reference features or infrastructure that no longer exist
174
+ - Flag new features or infrastructure not covered by existing levels
175
+ - Update the "Last reviewed" date to today
176
+ - Show the user a diff of what changed
177
+
178
+ $ARGUMENTS