Skip to content

fix: drift tests, type guards, and R4/R5 audit fixes#28

Merged
b-macker merged 3 commits into
masterfrom
audit/round3-fixes
Jun 13, 2026
Merged

fix: drift tests, type guards, and R4/R5 audit fixes#28
b-macker merged 3 commits into
masterfrom
audit/round3-fixes

Conversation

@b-macker

Copy link
Copy Markdown
Owner

Summary

  • Drift detection tests: Fixed all 6 failing tests (T4-T6, T37, T41, T44) by deferring Gate 0 enforcement so all violations and informational messages print before GovernanceHardError throws. Isolated test configs to disable earlier gates. Unmasked drift failures in CI (L-1). Result: 61/61 pass.
  • Type guards: Added .is_<type>() guards to all 422 unguarded .get<T>() calls in governance_config.cpp. Prevents nlohmann::json::type_error crashes from malformed govern.json. Total: 507 calls now guarded (was 85).
  • Round 4+5 audit fixes (from PR fix: Round 3+4 codebase audit fixes #27, already merged): Unicode bypass, import scanning, lockfile safety, filesystem reload sync, JS error propagation, dangling governance pointer, config type guards for critical fields.

Test plan

  • bash tests/governance/test_drift_detection.sh — 61/61 pass (was 55/61)
  • bash tests/security/test_govern_json_fuzz.sh — 100/100, 0 crashes
  • bash tests/security/test_error_msg_leaks.sh — 738/738, 0 failures
  • bash run-all-tests.sh — 396/396 accounted, 0 unexpected failures
  • Drift test failures now counted in CI totals (L-1 unmasked)

🤖 Generated with Claude Code

Termux User and others added 2 commits June 13, 2026 17:08
…onfigs

6 of 61 drift detection tests failed because enforce() with HARD level
threw GovernanceHardError on the first gate violation, killing the process
before subsequent checks or informational messages could execute.

C++ fix: defer basic metric (functions/loc/exports/structs) enforcement
in checkDriftDetection() until after all checks run and deleted function/
export names print. All violation summaries now appear before the first
GovernanceHardError throws, giving users the complete regression picture.

Test fixes: T37/T41/T44 configs now properly isolate the gate under test
by disabling earlier gates (max_*_loss: 1.0, check_body_hash: false,
check_complexity: false).

L-1 fix: drift test failures now count in run-all-tests.sh CI totals
(was masked with commented-out FAILED_TESTS line).

Result: 61/61 drift tests pass, 396/396 full suite, 738/738 security checks.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ce_config.cpp

Every .get<bool/int/double/size_t>() now has a preceding .is_<type>()
guard, preventing nlohmann::json::type_error crashes from malformed
govern.json values (e.g., "timeout": "sixty" instead of int).

Breakdown: 208 bool, 148 int, 61 double, 5 size_t calls guarded.
Total: 507 .get<T>() calls, 512 .is_<type>() guards (was 85/310).

Config fuzz test: 100/100 pass, 0 crashes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

NAAb Governance Report

Metric Count
Files checked 16
Passed 16
Failed 0

All governance checks passed!

Generated by NAAb Governance Engine v4.0

Was returning empty vector (stub). Now queries loader->searchBlocks()
for "adapter" and "convert" keywords, filters through isAdapter(),
and deduplicates. Returns empty gracefully when loader is null or
no blocks.db exists.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@b-macker b-macker merged commit 15f0022 into master Jun 13, 2026
20 checks passed
@b-macker b-macker deleted the audit/round3-fixes branch June 13, 2026 22:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant