fix(#275): accept top-level decision gate result fields (#283)

This commit is contained in:
Tom Boucher
2026-05-26 12:07:40 -04:00
committed by GitHub
parent afba2afbe7
commit ce945ef753
3 changed files with 21 additions and 3 deletions

View File

@@ -0,0 +1,5 @@
---
type: Fixed
pr: 275
---
Fixed plan-phase decision coverage gate compatibility with top-level .passed/.message command output.

View File

@@ -1522,8 +1522,8 @@ if [ "$GATE_CFG" != "false" ]; then
# `passed: true` covers both real-pass and skipped cases (gate disabled / no CONTEXT.md /
# no trackable decisions). Verify-phase counterpart deliberately omits this exit-1 — that
# gate is non-blocking by design (review finding F15).
echo "$GATE_RESULT" | jq -e '.data.passed == true' >/dev/null || {
echo "$GATE_RESULT" | jq -r '.data.message'
echo "$GATE_RESULT" | jq -e '(.passed // .data.passed) == true' >/dev/null || {
echo "$GATE_RESULT" | jq -r '(.message // .data.message // "Decision coverage gate failed.")'
exit 1
}
fi

View File

@@ -94,13 +94,26 @@ describe('plan-phase decision-coverage gate (#2492)', () => {
assert.ok(gateIdx !== -1);
const snippet = md.slice(gateIdx, gateIdx + 800);
// Accept either an inline `|| exit 1` or a `|| { ...; exit 1; }` group.
const hasJqGuard = /jq[^\n]*passed\s*==\s*true/.test(snippet);
const hasJqGuard =
/jq[^\n]*\.data\.passed\s*==\s*true/.test(snippet) ||
/jq[^\n]*\(\.passed\s*\/\/\s*\.data\.passed\)\s*==\s*true/.test(snippet);
const hasExitOne = /\|\|\s*(?:exit\s+1|\{[\s\S]{0,200}?exit\s+1)/.test(snippet);
assert.ok(
hasJqGuard && hasExitOne,
'plan-phase gate must guard with `jq -e .passed == true || exit 1` (or `|| { ...; exit 1; }`) to actually block',
);
});
test('plan-phase gate accepts top-level .passed field from CLI output (#275)', () => {
const gateIdx = md.indexOf('check.decision-coverage-plan');
assert.ok(gateIdx !== -1, 'check.decision-coverage-plan invocation must exist');
const snippet = md.slice(gateIdx, gateIdx + 800);
assert.ok(
/\.(?:passed)\s*==\s*true\s*\|\|\s*\.data\.passed\s*==\s*true/.test(snippet) ||
/\(\.passed\s*\/\/\s*\.data\.passed\)\s*==\s*true/.test(snippet),
'plan-phase gate must explicitly check top-level .passed with a compatibility fallback to .data.passed',
);
});
});
describe('verify-phase decision-coverage gate (#2492)', () => {