fix(review-loop-run): counts parses count-by-severity block with scope + format branches (2026-09-13 fix, 40/40 tests)

Was live via ~/sbin symlink but never committed. Baseline for bug 5352fe72.

Claude-Session: https://claude.ai/code/session_01G3SkMRBRWXyiGuMGs8WVas
This commit is contained in:
Paul O'Reilly
2026-09-16 14:27:52 +12:00
parent 636b8b2401
commit b340e2cd5c
8 changed files with 152 additions and 11 deletions

View File

@@ -0,0 +1,10 @@
# Review
Some findings above.
## Summary
- CRITICAL: 0
- HIGH: 1
- MEDIUM: 2
- LOW: 0

View File

@@ -0,0 +1,16 @@
# Review
## Finding 3 — HTTP 404 on /widgets
### MEDIUM: endpoint returns wrong status
Some prose mentioning 42 and HIGH severity inline that is not a real count.
## Count by severity
| Severity | Count |
|----------|-------|
| CRITICAL | 0 |
| HIGH | 0 |
| MEDIUM | 1 |
| LOW | 0 |

View File

@@ -0,0 +1,5 @@
# Review
## Count by severity
CRITICAL: 0. **HIGH**: 2. MEDIUM: 0. LOW: 0.

View File

@@ -0,0 +1,15 @@
# Review
### CRITICAL: auth bypass on /admin
Detailed explanation of the bypass.
### HIGH: missing input validation
Detailed explanation.
### HIGH: race condition in worker pool
Detailed explanation.
No explicit count-by-severity section is present in this file.

10
tests/fixtures/review-loop-run/table.md vendored Normal file
View File

@@ -0,0 +1,10 @@
# Review
## Count by severity
| Severity | Count |
|----------|-------|
| CRITICAL | 0 |
| HIGH | 0 |
| MEDIUM | 1 |
| LOW | 3 |

View File

@@ -58,6 +58,28 @@ printf '## CRITICAL findings\n### C1 CRITICAL x\n### H1 HIGH y\n' > "$TMP/heads.
out=$("$SCRIPT" counts "$TMP/heads.md"); rc=$?
assert_exit "heading fallback exits 4" 4 "$rc"
FIXTURES="$REPO_ROOT/tests/fixtures/review-loop-run"
out=$("$SCRIPT" counts "$FIXTURES/bullet-list.md"); rc=$?
assert_exit "bullet-list block exits 4" 4 "$rc"
assert_contains "bullet-list counts" "CRITICAL=0 HIGH=1 MEDIUM=2 LOW=0" "$out"
out=$("$SCRIPT" counts "$FIXTURES/table.md"); rc=$?
assert_exit "table block exits 0" 0 "$rc"
assert_contains "table counts" "CRITICAL=0 HIGH=0 MEDIUM=1 LOW=3" "$out"
out=$("$SCRIPT" counts "$FIXTURES/inline-bold.md"); rc=$?
assert_exit "inline bold exits 4" 4 "$rc"
assert_contains "inline bold counts" "CRITICAL=0 HIGH=2 MEDIUM=0 LOW=0" "$out"
out=$("$SCRIPT" counts "$FIXTURES/heading-numbers.md"); rc=$?
assert_exit "heading with HTTP 404 exits 0" 0 "$rc"
assert_contains "heading-numbers ignores 404/42, uses own count block" "CRITICAL=0 HIGH=0 MEDIUM=1 LOW=0" "$out"
out=$("$SCRIPT" counts "$FIXTURES/no-count-block.md"); rc=$?
assert_exit "no count block derives, exits 4" 4 "$rc"
assert_contains "no count block counts" "CRITICAL=1 HIGH=2 MEDIUM=0 LOW=0" "$out"
assert_contains "no count block marked derived" "(derived)" "$out"
echo "review-loop-run — status"
printf 'x\nexit=0\n' > "$REVIEW_LOOP_RUN_DIR/t-r1-stdout.txt"
out=$("$SCRIPT" status --name t 2>&1); rc=$?