Push policy coverage 90.3% -> 99.5%; pin audit-flagged defensives#1
Merged
Conversation
Adds 6 new *_test.go files covering the worst-covered functions surfaced by go tool cover, plus three defensive pins for the iter-2 audit findings: AUDIT PIN #1 (MED): default-allow on empty/unrecognized verdict. - DefaultVerdict="deny" + no matching rule MUST deny (zz_audit_defensive_test.go) - DefaultVerdict="" + no matching rule MUST allow (backcompat) - Bogus DefaultVerdict values MUST be rejected by Validate - EvaluateGate fail-open on expression eval error (current contract) AUDIT PIN #2 (MED): expression evaluation timeout. - EvaluateGate is bounded inside a 1s SLA (proxy for runProgram's 100ms select; trips immediately if the goroutine+select disappears) - OOB-index expression returns fail-open allow without panicking (drives the defer-recover branch end-to-end) AUDIT PIN #3 (MED): peer-list iteration is not unbounded. - executeEvictWhere over 5k peers completes <3s - applyMembershipDiff over 5k peers completes <3s - Concurrent Status() readers aren't starved during reconcile pass (catches a regression from RLock -> Lock-for-whole-pass refactors) Coverage holes filled (highlights): runner.evaluatePerPeerCycle 0.0% -> 100% runner.EvaluateActions 53.3% -> 100% (Evict/EvictWhere/Fill/PruneTrust/FillTrust dispatch + eval-error) runner.executeFill 85.3% -> 100% (max_peers clamps, over-capacity no-op) runner.executePruneTrust 89.7% -> 96.6% (toRemove promote/clamp/early-return) runner.executeFillTrust 85.7% -> 91.4% (already-trusted skip, deficit clamp, handshake error) runner.cycleLoop 73.9% -> 95.7% (bad-duration default 24h, sub-1s promote 1s, reconcile + cycle ticks) runner.reconcileMembership 75.0% -> 100% runner.applyMembershipDiff 85.1% -> 97.0% (join evict/log/webhook, leave dispatches, eval-error continue, cooldown set) runner.bootstrap 86.3% -> 92.2% (max_peers clamp, deny cooldown, log/webhook/tag dispatch, eval-error) runner.rankTrustLinks 75.0% -> 100% (random branch) runner.rankedPeers 77.8% -> 100% (activity branch) runner.fetchMembersWithTags 82.6% -> 97.8% (backoff skip, recovery reset, failure increment, non-map entry, missing nodes, 5min cap) runner.load 85.7% -> 93.3% (unmarshal error, nil-peers init) runner.NewPolicyRunner 87.5% (PILOT_HOME override + fallback + prior-state load) runner.paramInt 87.5% -> 100% (int64 case) runner.Stop (idempotency) service.handleNetworkJoined 73.3% -> 100% (missing netID, already-running, bad JSON) service.handleNetworkLeft 75.0% -> 100% service.dispatchNetworkEvents (tags_changed reserved branch) service.startInternal 94.1% -> 100% (Compile error) service.LoadPersisted 86.7% -> 93.3% (empty home, readdir error, UserHomeDir error) service.exprPolicyJSONFromPayload 88.2% -> 100% (channel + nested-channel marshal failure) policylang.evaluateGate 86.4% -> 100% (rule.On mismatch, eval error, side-effects accumulate) policylang.evaluateActions 81.8% -> 100% (rule.On mismatch, eval error) policylang.runProgram 81.2% -> 87.5% (non-bool result, happy path) policylang.Validate 97.0% -> 100% (action-validate error propagation) Final coverage: 99.5% combined (99.6% policy / 99.1% policylang). runner.go change is the production-side hook the existing TestMain already relies on: PILOT_HOME env wins over UserHomeDir so parallel tests get per-binary tmpdirs and don't race through ~/.pilot/policy_*.json. Remaining ceiling (4 blocks, ~10 lines, all honest): policylang/engine.go:233 defer-recover needs deterministic expr.Run panic policylang/engine.go:250 100ms timeout needs synthetic infinite expr runner.go:515 toRemove<=0 dead code (earlier total<=min catches it) runner.go:1182 MarshalIndent unreachable for policySnapshot's types go test -race -count=1 -timeout 180s ./... passes in 7s.
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. ℹ️ You can also turn on project coverage checks and project coverage reporting on Pull Request comment Thanks for integrating Codecov - We've got you covered ☂️ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Coverage moves (highlights)
Audit defensives (zz_audit_defensive_test.go)
Honest ceiling (~10 lines, 4 blocks remain uncovered)
Test plan