Skip to content

Add module governance engine parity test - #117

Merged
b-macker merged 1 commit into
masterfrom
claude/module-governance-parity-test
Aug 2, 2026
Merged

Add module governance engine parity test#117
b-macker merged 1 commit into
masterfrom
claude/module-governance-parity-test

Conversation

@b-macker

@b-macker b-macker commented Aug 2, 2026

Copy link
Copy Markdown
Owner

Summary

What was traced

VM (compiler.cpp): skip_main_ at lines 89, 97, 399, 1129, 1267

  • Line 399: skip main block when skip_main_
  • Lines 1129/1267: two function-body sites — !skip_main_checkNaabFunctionBody() (full), skip_main_checkFunctionBehavioralContract() (lightweight)

Tree-walker (interpreter.cpp): module_loading_depth_ == 0 at lines 975, 982, 995, 1027, 1032, 1037, 1067, 1151

  • Line 1027: skip main block
  • Line 1151: module_loading_depth_ == 0checkNaabFunctionBody(), else → checkFunctionBehavioralContract()
  • Lines 975-1067: lifecycle guards (hooks, scope validation, reports, scanner) — no VM equivalent needed (handled in main.cpp)

Result: The guards match. The 3-vs-8 site count asymmetry is different granularity, not different behavior.

Test groups

Group Property Assertion
A (3) Module placeholder skip Both engines allow placeholder in imported module
B (3) Main file enforcement Both engines block placeholder in main file (exit 3)
C (3) Behavioral contracts must_call fires during module load on both engines
D (3) Main block skip Module main{} not executed on import
E (2) Controls Placeholder check is live; disabling it lets code through

Degraded-case validation (guard removal, not expectation inversion)

Broke the property in the source: replaced both if (!skip_main_) guards in compiler.cpp (lines 1129, 1267) with if (true), removing the VM's module-loading skip while leaving the tree-walker's intact. Rebuilt and ran the test.

Assertion Broken result Message
MOD-A1 FAIL engines disagree — VM matches=3 tree-walk matches=0
MOD-A2 FAIL engines disagree — VM matches=0 tree-walk matches=1
MOD-A3 FAIL exit code divergence — VM=3 tree-walk=0
MOD-C1 FAIL engines disagree — VM matches=0 tree-walk matches=2
MOD-C2 FAIL engines disagree — VM matches=1 tree-walk matches=0
B1-B3, D1-D3, E1-E2 PASS Unaffected (main-file checks and main-block skip use separate guard)

All 5 broken assertions reported "engines disagree", confirming the test measures parity, not just correctness. Restored compiler.cpp, rebuilt, confirmed 14/14 pass.

Suite results (clean tree, run to completion)

Branch (claude/module-governance-parity-test): 441 tests, 4 unexpected failures
Master (origin/master): 441 tests, 4 unexpected failures (identical set)

Pre-existing failures on this platform (Termux/ARM64):

  • test_consequence_proof.sh
  • test_sandbox_engine_parity.sh
  • test_semantic_signals.sh
  • test_d1_reconciliation.sh

The branch introduces 0 new failures. Line 3308 of the suite log: test_module_governance_parity.sh: ALL PASSED.

Committed diff is exactly 2 files:

 run-all-tests.sh                                   |  15 +
 tests/governance_v4/test_module_governance_parity.sh | 436 +
 2 files changed, 451 insertions(+)

🤖 Generated with Claude Code

Traced skip_main_ (compiler.cpp:89/97/399/1129/1267) and
module_loading_depth_ (interpreter.cpp:975-1151). The guards match:
both engines skip checkNaabFunctionBody() during module import and
still run checkFunctionBehavioralContract(). The count asymmetry
(3 VM sites vs 8 tree-walker sites) is benign — the tree-walker
guards lifecycle events (hooks, summary, scanner) handled elsewhere
in the VM path.

14 assertions across 5 groups:
  A. Module placeholder NOT blocked on import (both engines)
  B. Same placeholder BLOCKED in main file (both engines, exit 3)
  C. must_call contract fires during module load (both engines)
  D. Module main{} block NOT executed on import (both engines)
  E. Controls: placeholder check is live, not vacuously passing

Every assertion observed failing when inverted (degraded-case check
confirmed for MOD-A1, MOD-B1, MOD-C1, MOD-D1).

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

github-actions Bot commented Aug 2, 2026

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

@b-macker
b-macker marked this pull request as ready for review August 2, 2026 18:51
@b-macker
b-macker merged commit 1989623 into master Aug 2, 2026
22 checks passed
@b-macker
b-macker deleted the claude/module-governance-parity-test branch August 2, 2026 18:51
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