[quality] test: pin ioscan classifier audit trail, CI-failing kick list, and tokens Diagnostics - #6059
Conversation
…st, and tokens Diagnostics Covers three previously-untested paths found by coverage analysis: - pkg/scheduler/ioscan_enforce.go recordClassifierResult / recordClassifierSkip (60% -> 100%): every semantic-classifier decision (allow/redact/block) and every skipped evaluation (budget_exhausted, error) must land in the audit log with the ioscan_classifier action and a detail carrying rule/score/category/action. - pkg/scheduler/scheduler.go buildCIFailingList (58.3% -> 100%): missing snapshot file, malformed JSON, empty items, and per-PR line formatting (number, repo, author, head SHA, title). - pkg/tokens/collector.go Diagnostics accessor (0% -> 100%): zero value before scan, clean healthy scan, LiveCaptureEnabled toggle, scan-error surfacing (LastScanError, LastBobScanError), and per-scan rebuild so a stale bob error clears after a healthy scan. Test-only change; no production code touched. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: hivecommons-hive[bot] <hive-bot@hivecommons.dev>
|
Changelog: this PR changes code but carries no changelog entry If it is user-visible — a feature, a fix an operator would notice, a This is a reminder, not a gate; it never blocks a merge. |
|
/lgtm |
|
LGTM label has been added. DetailsGit tree hash: 2e69fa8150af1a0b81dd541f42b2d1e3297473f5 |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: clubanderson The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
Thank you for your contribution! Your PR has been merged. We'd love to hear how your experience was: share feedback |
v5 removed the enforceIssueText wrapper (dead-code refactor); the v4 test from #6059 still called it. Use the two-value form v5 keeps instead of resurrecting the wrapper. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TmdVsn5zULh5KVpFkYrX59 Signed-off-by: Andrew Anderson <andan02@gmail.com>
…st, and tokens Diagnostics (#6059) Covers three previously-untested paths found by coverage analysis: - pkg/scheduler/ioscan_enforce.go recordClassifierResult / recordClassifierSkip (60% -> 100%): every semantic-classifier decision (allow/redact/block) and every skipped evaluation (budget_exhausted, error) must land in the audit log with the ioscan_classifier action and a detail carrying rule/score/category/action. - pkg/scheduler/scheduler.go buildCIFailingList (58.3% -> 100%): missing snapshot file, malformed JSON, empty items, and per-PR line formatting (number, repo, author, head SHA, title). - pkg/tokens/collector.go Diagnostics accessor (0% -> 100%): zero value before scan, clean healthy scan, LiveCaptureEnabled toggle, scan-error surfacing (LastScanError, LastBobScanError), and per-scan rebuild so a stale bob error clears after a healthy scan. Test-only change; no production code touched. Signed-off-by: hivecommons-hive[bot] <hive-bot@hivecommons.dev> Co-authored-by: hivecommons-hive[bot] <hive-bot@hivecommons.dev> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: sec-check <sec-check@hive.kubestellar.io>
v5 removed the enforceIssueText wrapper (dead-code refactor); the v4 test from #6059 still called it. Use the two-value form v5 keeps instead of resurrecting the wrapper. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TmdVsn5zULh5KVpFkYrX59 Signed-off-by: Andrew Anderson <andan02@gmail.com> Signed-off-by: sec-check <sec-check@hive.kubestellar.io>
Test Improvement
Coverage analysis (
go test ./pkg/... -short -coverprofile, total 94.7%) found three untested clusters. This PR adds 14 hermetic tests, no production code.Files/functions claimed (for overlap comparison by future kicks):
src/pkg/scheduler/ioscan_classifier_audit_test.go(new) →recordClassifierResult,recordClassifierSkipinsrc/pkg/scheduler/ioscan_enforce.go(60% → 100%)src/pkg/scheduler/ci_failing_list_test.go(new) →buildCIFailingListinsrc/pkg/scheduler/scheduler.go(58.3% → 100%)src/pkg/tokens/diagnostics_test.go(new) →(*Collector).Diagnosticsinsrc/pkg/tokens/collector.go(0% → 100%)What the tests pin:
budget_exhausted,error) records anioscan_classifieraudit entry with rule/score/category/action — previously the emission paths were dead in tests, so a regression silently dropping classifier decisions from the audit trail would not have been caught.buildCIFailingListrenders(none)for missing/malformed/empty snapshots and one correctly formatted line per failing PR (number, repo, author, head SHA, title) — the kick template contract.tokens.Diagnostics: zero value before scan, clean healthy scan,LiveCaptureEnabledtoggle,LastScanError/LastBobScanErrorsurfacing, and per-scan rebuild (stale bob error clears after a healthy scan).Disjointness: verified against the open-PR snapshot — #6049 (pkg/hub health/verdict, pkg/agent start_failure, cmd/hive), #6046 (v5 forward-port; full 249-file list checked — no scheduler or tokens files), #6010 (pkg/hub wildcard TLS). No file overlap.
Validation
go test ./pkg/scheduler/ ./pkg/tokens/ -short -count=1— ok, coverage 96.3%→97.1% (scheduler), 94.8%→95.7% (tokens)go vet ./pkg/scheduler/ ./pkg/tokens/— clean-raceunavailable in this sandbox: no gcc for cgo; CI's v2-tests lane runs it)Filed by quality agent (hold-gated mode). Human review required.
— hive: agent=quality backend=copilot model=claude-fable-5