@windyroad/risk-scorer 0.3.2-preview.77 → 0.3.3-preview.81

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,66 @@
1
+ #!/usr/bin/env bats
2
+ # Doc-lint guard: wip.md and assess-wip SKILL.md must define the
3
+ # RISK_VERDICT: COMMIT extension per ADR-016.
4
+ #
5
+ # Structural assertion — Permitted Exception to the source-grep ban (ADR-005 / P011).
6
+ # These tests assert that the agent and skill specification documents conform to
7
+ # the COMMIT verdict contract introduced by P024 / ADR-016.
8
+ #
9
+ # Cross-reference:
10
+ # P024: docs/problems/024-risk-scorer-wip-flag-uncommitted-completed-work.open.md
11
+ # ADR-016: docs/decisions/016-wip-verdict-commit-for-completed-governance-work.proposed.md
12
+ # ADR-013: docs/decisions/013-structured-user-interaction-for-governance-decisions.proposed.md
13
+ # @jtbd JTBD-002 (ship with confidence)
14
+ # @jtbd JTBD-001 (enforce governance without slowing down)
15
+
16
+ setup() {
17
+ AGENTS_DIR="$(cd "$(dirname "$BATS_TEST_FILENAME")/.." && pwd)"
18
+ WIP_FILE="${AGENTS_DIR}/wip.md"
19
+ SKILL_DIR="$(cd "${AGENTS_DIR}/../skills/assess-wip" && pwd)"
20
+ SKILL_FILE="${SKILL_DIR}/SKILL.md"
21
+ }
22
+
23
+ # ──────────────────────────────────────────────────────────────────────────────
24
+ # wip.md — COMMIT verdict definition
25
+ # ──────────────────────────────────────────────────────────────────────────────
26
+
27
+ @test "wip.md defines RISK_VERDICT: COMMIT as a third verdict type" {
28
+ # ADR-016 §Verdict Contract: COMMIT is distinct from CONTINUE and PAUSE.
29
+ # The agent prompt must name this verdict so the LLM knows to emit it.
30
+ run grep -n "RISK_VERDICT:.*COMMIT\|RISK_VERDICT: COMMIT" "$WIP_FILE"
31
+ [ "$status" -eq 0 ]
32
+ }
33
+
34
+ @test "wip.md defines RISK_COMMIT_REASON: output field" {
35
+ # ADR-016 §Verdict Contract: COMMIT verdict must include a one-line reason
36
+ # so the calling skill can surface a meaningful message to the user.
37
+ run grep -n "RISK_COMMIT_REASON" "$WIP_FILE"
38
+ [ "$status" -eq 0 ]
39
+ }
40
+
41
+ @test "wip.md defines governance-artefact detection heuristic for COMMIT verdict" {
42
+ # ADR-016 §Detection Heuristic: COMMIT fires only when all uncommitted changes
43
+ # are in governance artefact paths (docs/problems/, packages/*/skills/).
44
+ # This guards against false-positive COMMIT signals on mixed diffs.
45
+ run grep -in "governance.artefact\|governance artefact\|docs/problems\|packages/\*/skills" "$WIP_FILE"
46
+ [ "$status" -eq 0 ]
47
+ }
48
+
49
+ @test "wip.md COMMIT verdict is only emitted when risk is within appetite" {
50
+ # ADR-016 §Detection Heuristic criterion 1: risk must be ≤ 4 for COMMIT to fire.
51
+ # Above-appetite changes must be PAUSE regardless of governance-artefact status.
52
+ # Look for the explicit appetite gate in the COMMIT detection section specifically.
53
+ run grep -in "PAUSE.*governance\|governance.*PAUSE\|appetite.*COMMIT\|COMMIT.*appetite\|COMMIT.*within\|within.*COMMIT" "$WIP_FILE"
54
+ [ "$status" -eq 0 ]
55
+ }
56
+
57
+ # ──────────────────────────────────────────────────────────────────────────────
58
+ # assess-wip SKILL.md — COMMIT verdict handling
59
+ # ──────────────────────────────────────────────────────────────────────────────
60
+
61
+ @test "assess-wip SKILL.md handles RISK_VERDICT: COMMIT distinctly from CONTINUE/PAUSE" {
62
+ # ADR-016 §Consequences: assess-wip Step 4 must surface RISK_VERDICT: COMMIT
63
+ # as a prominent suggestion to commit, not treat it the same as CONTINUE.
64
+ run grep -n "COMMIT\|commit.*now\|commit now" "$SKILL_FILE"
65
+ [ "$status" -eq 0 ]
66
+ }
package/agents/wip.md CHANGED
@@ -70,6 +70,32 @@ Do NOT emit free-text suggestions as prose. The structured block is the only out
70
70
 
71
71
  The verdict is `RISK_VERDICT: PAUSE`. This blocks the next edit until the risk is addressed.
72
72
 
73
+ ### Completed-Work Detection (RISK_VERDICT: COMMIT)
74
+
75
+ After assessing the risk profile, check whether uncommitted changes represent **completed governance work** that should be committed immediately to reduce WIP pipeline risk (ADR-016).
76
+
77
+ **Governance-artefact detection heuristic**: Check `git status --short` and `git diff HEAD --name-only`. If ALL uncommitted files fall within these paths:
78
+ - `docs/problems/*.md`
79
+ - `packages/*/skills/**/*.md`
80
+ - `packages/*/skills/**/*.bats`
81
+ - `docs/decisions/*.md`
82
+
83
+ AND cumulative risk is **within appetite** (≤ 4), AND at least one completion signal is present:
84
+ - A problem file diff contains "Fix Released" or a status transition keyword (`.known-error.md`, `.closed.md`)
85
+ - A SKILL.md was modified alongside a problem file update
86
+
87
+ → Emit `RISK_VERDICT: COMMIT` instead of `RISK_VERDICT: CONTINUE`.
88
+
89
+ **Appetite gate**: If cumulative risk exceeds appetite, emit `RISK_VERDICT: PAUSE` regardless of governance artefact status — PAUSE takes precedence over COMMIT.
90
+
91
+ **False-positive safeguard**: If ANY uncommitted file is outside governance artefact paths (e.g., `.ts`, `.js`, `.sh`, `.mjs`, `package.json`), do NOT emit COMMIT — the diff is mixed WIP and the heuristic cannot safely distinguish completed from in-progress work. Emit CONTINUE or PAUSE normally.
92
+
93
+ **Format when COMMIT is emitted**:
94
+ ```
95
+ RISK_VERDICT: COMMIT
96
+ RISK_COMMIT_REASON: <one-line description of the completed governance work detected>
97
+ ```
98
+
73
99
  ## Control Discovery
74
100
 
75
101
  For each control claimed to reduce risk, name the specific test file/scenario. If you cannot name it, it provides 0 reduction.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@windyroad/risk-scorer",
3
- "version": "0.3.2-preview.77",
3
+ "version": "0.3.3-preview.81",
4
4
  "description": "Pipeline risk scoring, commit/push gates, and secret leak detection",
5
5
  "bin": {
6
6
  "windyroad-risk-scorer": "./bin/install.mjs"
@@ -53,9 +53,18 @@ Wait for the subagent to complete.
53
53
 
54
54
  ### 4. Present results
55
55
 
56
- Present the WIP risk nudge to the user. The wip subagent provides guidance and recommendations, not a formal gate score. Highlight:
57
- - The highest-risk files or change patterns identified
58
- - Any recommendations to reduce risk before committing
59
- - Whether a full pipeline assessment (`assess-release`) is recommended before committing
56
+ Present the WIP risk nudge to the user. The wip subagent provides guidance and recommendations, not a formal gate score.
57
+
58
+ **Check `RISK_VERDICT` from the subagent output and handle each case distinctly:**
59
+
60
+ - **`RISK_VERDICT: CONTINUE`**: changes are in-progress and within risk appetite. Highlight the highest-risk files or change patterns; note whether a full pipeline assessment (`assess-release`) is recommended before committing.
61
+
62
+ - **`RISK_VERDICT: PAUSE`**: risk exceeds appetite. Prominently surface the `RISK_REMEDIATIONS:` block. Explain each remediation clearly. Do NOT suggest committing until remediations are addressed.
63
+
64
+ - **`RISK_VERDICT: COMMIT`** (ADR-016): the uncommitted diff consists entirely of completed governance work (problem fixes, SKILL.md updates, closed problem transitions) and risk is within appetite. Present a prominent commit-now suggestion:
65
+ > "The uncommitted changes look like completed governance work. Commit now to reduce WIP and feed the pipeline."
66
+ > *Reason: `<RISK_COMMIT_REASON from subagent>`*
67
+
68
+ Use `AskUserQuestion` to offer: "Commit completed governance work now?" — Yes (user confirms and runs `git commit`) or "Not yet" (user defers).
60
69
 
61
70
  $ARGUMENTS