Commit f81bb04
fix(governance): let the hypatia baseline filter actually run (scan exit-on-findings under bash -e) (#464)
## Summary
Follow-up to **#455**. That PR wired `apply-baseline.sh` into
`validate-hypatia-baseline`, but the fix never actually ran:
`hypatia-cli.sh scan .` **exits non-zero by design whenever it finds
anything**, and the step runs under `bash -e`, so **errexit aborted the
step at the scan line — before the relativization + `apply-baseline.sh`
(the real gate) could run.**
This is also why the pre-#455 job was *always* red on every repo with
findings: its dead `jq` count never executed either. The scan's exit-1
killed the step every time.
**Caught by verifying end-to-end on neurophone#171**, where the job died
at:
```
[hypatia] scan complete: 18 findings >= medium (critical=3, high=9, medium=6); exit 1
##[error]Process completed with exit code 1.
```
…with **no** `apply-baseline.sh` output at all.
## The fix
```bash
HYPATIA_FORMAT=json "$HOME/hypatia/hypatia-cli.sh" scan . > hypatia-findings.raw.json || true
# never swallow a genuine scanner crash into a false pass:
if ! jq -e 'type == "array"' hypatia-findings.raw.json >/dev/null 2>&1; then
echo "::error::hypatia scan did not produce a valid JSON findings array (scanner error, not a baseline result)"
exit 1
fi
```
- **`|| true`** — tolerate the scan's by-design exit-on-findings so the
baseline filter runs and becomes the gate.
- **JSON-array guard** — a genuine scanner *crash* (non-array / empty
output) still fails loudly, so tolerating the exit code can't produce a
silent-green.
Both behaviours simulated locally under `bash -e`:
```
sim 1 (scan exits 1, valid output) -> REACHED-FILTER rc=0 ✓
sim 2 (scanner crash, non-array) -> GUARD-FAIL rc=1 ✓ (no silent-green)
```
## Heads-up for callers (separate, repo-side)
A **newer hypatia HEAD** reports more findings than when a repo's
`.hypatia-baseline.json` was written (neurophone: 18 now vs 14 when its
baseline was authored in #168). So after this lands, a caller may still
see its gate stay red on **genuinely-new** findings — that is the filter
working correctly. Resolution is per-repo: extend the baseline (or fix
at source), not here.
Draft pending CI + your review (edits the shared security gate). Same
opt-in-via-SHA-pin safety as #455.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_0172RBMz3qYjb1ttzD2i7RNh
---
_Generated by [Claude
Code](https://claude.ai/code/session_0172RBMz3qYjb1ttzD2i7RNh)_
Co-authored-by: Claude <noreply@anthropic.com>1 parent 832b157 commit f81bb04
1 file changed
Lines changed: 11 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
131 | | - | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
132 | 142 | | |
133 | 143 | | |
134 | 144 | | |
| |||
0 commit comments