Skip to content

rebless: state_mutation contract — writes, not declarations (gitgalaxy#2765, Phase 3) - #79

Merged
squid-protocol merged 3 commits into
mainfrom
rebless/gitgalaxy-2765-state-mutation
Sep 6, 2026
Merged

rebless: state_mutation contract — writes, not declarations (gitgalaxy#2765, Phase 3)#79
squid-protocol merged 3 commits into
mainfrom
rebless/gitgalaxy-2765-state-mutation

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Re-bless for gitgalaxy#2765 (the state_mutation contract, roadmap #2812 Phase 3). Engine PR: squid-protocol/gitgalaxy#2818.

What the contract says

One hit is a statement that writes a new value into state that already exists. A declaration is not a write (even var/let mut/int x = 5/go :=); a type or modifier naming mutable state is not a write; a read, bind or cast is not a write; one statement is one hit and a token another rule owns is not a second signal. docs/state_mutation_rule_contract.md in gitgalaxy has the corollaries and the 46-language audit.

What moved here, and why (every cell is in the ledger entry state-mutation-contract-2765)

Cells that moved because the rule was wrong (no plant change): haskell a.hs 2->0 (IORef type signatures), dockerfile a 2->0 (ENV is globals), c a 2->0 / b 3->2 (declarations), go b 5->2 (:=, _ = x), objective-c b 3->2, perl b 3->2 / c 1->0 (my, bare shift), m4 c 2->0 (popdef is cleanup), apex c 1->0 (.clear( is cleanup), matlab c 1->0 and b cleanup 2->0 (clear/clearvars are cleanup only -- matlab's corpus cleanup now sits on the median).

Plants authored to the old rules, re-planted as real writes: cpp, java, javascript, kotlin, rust, scala, swift, typescript, zig (var first = items x2 -> one declaration + first = 1 / first = 2), solidity (payable(items) is a cast -> items = 1), sqlite (UPDATE ... SET had counted twice -> ALTER TABLE corpus RENAME TO corpus_state is the second statement; io stays 3), abap (the = statement joined the rule, APPEND dropped), livecode/scheme/tcl (the decoy line was already a third write; one plant removed). The probe_debt bodies in abap/fortran/matlab/powershell assigned into languages with no declaration syntax and carried a state_mutation into a c file planted at 0; they declare or return now. Every replacement was screened as a pair against the branch rules; the only unplanted side effect is java's AtomicInteger no longer carrying a concurrency 1.

Ledger: new state-mutation-contract-2765 (upstream-bug, resolved, verifying scan 46/46 against fix/2765-state-mutation-contract); batch4-dual-keyword-overlaps loses matlab and m4 (their only itemised duals were retired) and records jcl SET as the one state_mutation dual that stays. tools/screen_plant.py now honours $GITGALAXY_PATH.

Still narrower than the contract, by design for now: python/embedded_python/ruby never count a plain local re-assignment -- gitgalaxy#2817, not a red cell.

Effect (regenerated at full precision against the branch)

state_mutation reads 2 in all 43 comparable languages -- 0 out-of-band cells, down from 16 open defects (37%); risk_state_flux open-defect share 0 of 45. Corpus open-defect share 79 -> 62 of 2303 cells (3.4% -> 2.7%); average consistency across 49 metrics 88% -> 90%. decoy_check.py --gate and na_check.py clean.

Cross-repo

gitgalaxy#2818 merges first; verify.yml here checks out engine main, so this PR is red until then and green by construction after. bias-history.yml regenerates the report and chart on merge (the locally regenerated artifacts are included so the effect is visible in the diff).

squid-protocol and others added 2 commits September 6, 2026 12:37
…xy#2765, roadmap Phase 3)

gitgalaxy#2765 gave state_mutation a stated contract: one hit is a statement that
writes a new value into state that already exists. A declaration is not a write
(even `var`/`let mut`/`int x = 5`), a type naming mutable state is not a write,
a read/bind/cast is not a write, and a token another rule owns is not a second
signal. 30 engine rules were rewritten to it (gitgalaxy PR #2818).

Cells that moved because the rule was wrong: haskell a.hs 2->0 (IORef type
signatures), dockerfile a 2->0 (ENV is globals), c a 2->0 / b 3->2, go b 5->2,
objective-c b 3->2, perl b 3->2 / c 1->0, m4 c 2->0 (popdef is cleanup), apex c
1->0 (.clear( is cleanup), matlab c 1->0 and b cleanup 2->0 (clear is cleanup).

Plants authored to the old rules, re-planted as real writes: cpp, java,
javascript, kotlin, rust, scala, swift, typescript, zig (mutable declarations
-> `first = 1; first = 2`), solidity (payable() cast -> `items = 1`), sqlite
(UPDATE...SET counted twice -> ALTER TABLE as the second statement), abap (the
`=` statement joined the rule; APPEND dropped), livecode/scheme/tcl (the decoy
line was a third write; one plant removed). probe_debt bodies in abap/fortran/
matlab/powershell assigned into languages with no declaration syntax and carried
a state_mutation into a file planted at 0; they now declare or return instead.

Ledger: new `state-mutation-contract-2765` (upstream-bug, resolved, verifying
scan 46/46 against gitgalaxy fix/2765-state-mutation-contract);
`batch4-dual-keyword-overlaps` loses matlab and m4 (their only duals retired).
tools/screen_plant.py honours $GITGALAXY_PATH so a branch worktree can be screened.

Cross-repo: gitgalaxy#2818 merges first; this goes green once engine main carries it.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…2765-state-mutation-contract

state_mutation reads 2 in all 43 comparable languages (was 16 of 43 open defects);
risk_state_flux open-defect share 0/45; corpus open-defect share 79 -> 62 of 2303
(3.4% -> 2.7%); average consistency 88% -> 90%.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@squid-protocol
squid-protocol merged commit 5668178 into main Sep 6, 2026
1 check passed
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