Skip to content

fix(safety): re-enable post-optimization stack validation (H-17)#62

Open
avrabe wants to merge 1 commit intomainfrom
fix/stack-validation-reenable
Open

fix(safety): re-enable post-optimization stack validation (H-17)#62
avrabe wants to merge 1 commit intomainfrom
fix/stack-validation-reenable

Conversation

@avrabe
Copy link
Contributor

@avrabe avrabe commented Mar 23, 2026

Summary

Re-enables the post-optimization stack validation safety gate that was disabled due to false positives in the compositional block analyzer.

Root cause: validate_module_blocks used compositional block-level decomposition that produced false positives when optimizations reorder or eliminate dead code. The fix replaces it with validate_function_with_context which validates each function as a whole without decomposition.

Key finding: Every optimization pass already runs guard.validate(func)? individually, so per-pass validation was never disabled. The module-level check was defense-in-depth that had been bypassed. Functions with unanalyzable instructions are skipped by both the optimizer and the validator -- no coverage gap exists.

  • Closes STPA finding H-17 (stack validation disabled)
  • Addresses SC-16 (stack validation must be active)

Test plan

  • All 310 loom-core tests pass with validation re-enabled
  • No false positives from the new validation approach
  • CI (format, clippy, test, Z3 verify, WASM build)

Trace: H-17, SC-16

🤖 Generated with Claude Code

Replace the disabled compositional block analysis (validate_module_blocks)
with per-function validation (validate_function_with_context) that avoids
the false positives caused by dead code and instruction count changes.

Investigation findings:
- Every optimization pass already calls guard.validate(func)? individually
- Functions with unanalyzable instructions (Unknown, CallIndirect) are
  skipped by both the optimizer AND the validator — no gap exists
- The compositional analyzer (validate_module_blocks) had false positives
  with its block-level decomposition; validate_function_with_context
  checks the whole function without decomposition
- All 310 tests pass with validation re-enabled

This closes STPA finding H-17 (stack validation disabled).

Trace: H-17, SC-16

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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