Fail closed on zero-coverage Patrol scoped runs

This commit is contained in:
rcourtman
2026-03-25 22:18:19 +00:00
parent 551b5eef8a
commit 43f4e63087
3 changed files with 13 additions and 2 deletions
@@ -424,6 +424,8 @@ owner, so the Patrol hook composes one canonical payload-to-summary derivation
instead of rebuilding recent-change, correlation, and governed-resource count
copy inline.
That same normalization applies to supporting effort strips inside the expanded
Zero-coverage scoped runs must also fail closed as `Checked 0 of N scoped
resources` rather than drifting back to a scope-only headline.
run card. Once the run presenter is already carrying canonical coverage copy,
secondary chips must not reintroduce a raw `Scoped to N resources` variant that
re-opens the same ambiguity.
@@ -91,6 +91,16 @@ describe('patrolRunPresentation', () => {
it('uses checked-resource language for non-scoped coverage summaries', () => {
expect(getPatrolRunCoverageSummary(fullCoverageRun)).toBe('Checked 58 resources');
expect(getPatrolRunResourcesHeading(fullCoverageRun)).toBe('Resources checked (58)');
it('fails closed on zero-coverage scoped runs', () => {
expect(
getPatrolRunCoverageSummary({
resources_checked: 0,
scope_resource_ids: ['seed-resource'],
effective_scope_resource_ids: ['expanded-a', 'expanded-b'],
}),
).toBe('Checked 0 of 2 scoped resources');
});
});
it('returns canonical patrol run loading and unavailable copy', () => {
@@ -95,13 +95,12 @@ export function getPatrolRunCoverageSummary(run: Pick<PatrolRunRecord, 'resource
const scopedResourceCount = getCanonicalScopeResourceIds(run)?.length ?? 0;
if (scopedResourceCount > 0) {
if (resourcesChecked > 0 && resourcesChecked < scopedResourceCount) {
if (resourcesChecked < scopedResourceCount) {
return `Checked ${resourcesChecked} of ${scopedResourceCount} scoped resources`;
}
if (resourcesChecked > 0) {
return `Checked ${formatResourceCount(resourcesChecked, 'scoped')}`;
}
return `Scoped to ${formatResourceCount(scopedResourceCount)}`;
}
if (resourcesChecked > 0) {