Skip to content

Make fence structure total in structural_decompress - #43

Merged
seanwevans merged 5 commits into
mainfrom
claude/compiler-fence-wasm-ll1hkm
Sep 3, 2026
Merged

seanwevans merged 5 commits into
mainfrom
claude/compiler-fence-wasm-ll1hkm

Conversation

@seanwevans

Copy link
Copy Markdown
Owner

Makes "every string compiles" true for fencing.

Problem

structural_decompress raised ValueError in three places, so unbalanced sources were not compilable at all:

  • a closer with no open fence — "}"
  • a closer that did not match the innermost fence — "{)"
  • a fence left open at end of input — "{a"

Change

  • Fences left open at EOF are closed implicitly, innermost first.
  • A closer that matches no open fence is dropped.
  • The close path is factored into a close_scope helper, so implicit and explicit closes run the same lifetime finalisation and cannot drift apart.
'}'      -> []
'a]'     -> ['A']
'{a'     -> ['A']
'{a)'    -> ['A']
'{{{abc' -> ['A', 'B', 'C']

Scope

The grade-fence check (Effect grade 'state' exceeds 'pure' fence in ()) is a fourth ValueError and is unchanged. It is a static effect violation rather than a parse failure, so "(c)" still raises. Worth knowing if the goal is literal totality of structural_decompress, since that path remains.

Tests

Existing tests that asserted the three removed errors now assert the new behaviour. Added to test_invariants.py: a parametrised set of unbalanced sources, checks that stray closers leave the tree identical to the balanced parse, that implicitly closed fences end lifetimes exactly like explicit ones, and an exhaustive sweep over all 512 three-character fence-only strings.

Full suite: no new failures. The 4 pre-existing failures are environment coupling, addressed separately.

🤖 Generated with Claude Code

https://claude.ai/code/session_01K7BqQpyspK2owRy6g6SFxw


Generated by Claude Code

claude and others added 4 commits September 3, 2026 17:24
Every byte string now denotes a program. structural_decompress previously
raised ValueError in three places — a closer with no open fence, a closer
that did not match the innermost fence, and a fence left open at end of
input — so unbalanced sources were not compilable at all.

Fences left open at EOF are now closed implicitly, innermost first, running
the same lifetime finalisation an explicit closer runs. A closer that
matches no open fence is dropped. The shared close path is factored into a
close_scope helper so implicit and explicit closes cannot drift apart.

The grade-fence check ("effect grade exceeds fence") is unchanged: that is a
static effect violation rather than a parse failure, and it still raises.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K7BqQpyspK2owRy6g6SFxw
continuous_semantics_profile caught the ValueError raised by
structural_decompress and recorded a distance of zero, so a mutation the
front end refuses to compile was indistinguishable from a mutation that
changed nothing. The measurement had holes exactly where the interesting
boundary cases live.

A rejected mutant now scores the rejection distance: every instruction of
the base program counted as deleted, floored at 1 so an empty base program
cannot collapse the score back to zero. Every profile entry also carries an
explicit `compiles` flag, so callers can separate "identical" from
"uncompilable" instead of inferring it from the presence of `error`.

The preceding commit removed the fence-imbalance ValueErrors, so the
remaining rejection path is the grade-fence violation, which the added tests
exercise directly.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K7BqQpyspK2owRy6g6SFxw
Stop scoring rejected mutants as semantically identical
@seanwevans
seanwevans merged commit b1a15af into main Sep 3, 2026
2 checks passed
@seanwevans
seanwevans deleted the claude/compiler-fence-wasm-ll1hkm branch September 3, 2026 17:58
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.

2 participants