Repository navigation
fix(core-engine): assembly + agc_assembly branch counts decisions, not unconditional transfers (#2764) - #2779
Merged
Conversation
…t unconditional transfers (#2764) Both assembly dialects counted every control transfer as a `branch`: the generic-assembly rule matched `jmp|call|ret|b|bl|bx|blr` alongside the conditional jumps, and agc_assembly's matched `TC|TCF|TCR|CALL|GOTO` (unconditional -- `TC` is the AGC's subroutine call) plus `RESUME|RETURN` (returns). Measured against the keyword-rosetta control corpus, 23 of assembly's 25 branch hits and 4 of agc's 5 were not decisions. `branch` feeds avg_func_complexity, max_func_complexity, func_internal_density, cog_raw, control_flow_ratio and risk_cognitive_load -- all decision-DENSITY measures -- plus #2546's x3 cascading-flux amplifier. Counting calls and returns made cognitive load track how many subroutines a file has, the thing `functions_found` already measures: assembly ran +811% over the corpus median on avg_func_complexity and func_internal_density, +778% on cog_raw, +524% on control_flow_ratio, and was the only language in the corpus where the flux amplifier fired at all (its "branch context" was a `ret`). #2545 settled the identical question for high-level languages when it took bare `return` out of `branch` in six of them; `ret` IS `return`, and no other language's `branch` counts its call syntax. Per that precedent the tokens are RELOCATED to `structural_boundaries`, not deleted -- `control_flow_ratio = branch / (branch + linear)` keeps the same denominator and no signal is lost. One deliberate de-duplication: agc's `CCS` (Count, Compare and Skip) was counted by BOTH rules and is now claimed by `branch` alone. Side effect: ARM's single-letter `b` stops inflating `branch` from prose and paths (the filename inside `%include "b.asm"` matched `\bb\b`); the false positive moves with the token to the bulk structural signal, where it is not a decision claim. Verification: - Golden masters re-blessed both modes. Every non-coordinate diff is inside an `assembly` or `agc_assembly` directory group -- verified programmatically over all 2817 files; 189 files moved, none of them outside the language's own extensions (this corpus has no polyglot assembly: all 244 `.asm/.s/.S/.inc/.agc` files live under those two categories). Function name/line sets are byte-identical corpus-wide; the `5. Function Analysis[N]` churn is impact-order reshuffling, not re-extraction. branch+linear is conserved per file except on the nine apollo-11 files carrying `CCS`, where the total drops by exactly that file's CCS count -- the intended de-duplication. Nine global aggregates move (three corpus-wide health averages, the top-3 state_flux leaderboard) plus the global 3D topology reflow. - Strict tests: the branch/structural_boundaries parametrized cases are re-partitioned in both languages, plus 5 new regression tests (decision vs transfer in each dialect, the `b.asm` path FP, RESUME still reading as cleanup) and 2 ReDoS detonations for the widened alternations. Full suite 7716 passed. audit_check all clear. - rosetta_audit against this build moves exactly two languages, assembly and agc_assembly (44 others PASS unchanged), including the predicted b.asm state_mutation 6 -> 2 flux ripple. The changed Absolute Project Path / Remote Origin URL / timestamp / duration fields are the usual machine-to-machine churn (golden_diff sanitizes them). Closes #2764 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JrpVFZDVVWo19LP3nYoQfP
Contributor
Conflict was the two golden masters only (#2778 re-blessed them for the orphan-census fixes; `assembly.py` auto-merged cleanly -- its `_visibility_export` addition sits well below this branch's `branch` / `structural_boundaries` edits). Resolved per the ledger-sweep playbook: took main's fixtures wholesale (`--theirs`) rather than hand-merging 680k lines of JSON, then re-blessed both modes from scratch on the merged tree. Re-verified every invariant against the NEW baseline -- identical scope to the pre-merge run: all 11784 non-coordinate leaf diffs sit in `assembly` (6240) or `agc_assembly` (5535); 189 files touched, none outside those languages' own extensions; function name/line sets byte-identical across all 2817 files; branch+linear conserved everywhere except the nine apollo-11 files carrying `CCS`, by exactly that file's CCS count. Nine global aggregates and the 3D topology reflow, as before. Full suite 7725 passed; audit_check all clear. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JrpVFZDVVWo19LP3nYoQfP
squid-protocol
added a commit
to squid-protocol/keyword-rosetta
that referenced
this pull request
Sep 6, 2026
…less against gitgalaxy#2764 (#65) gitgalaxy#2764 (engine PR squid-protocol/gitgalaxy#2779) takes the unconditional control transfers out of both assembly dialects' `branch` rule and relocates them to `structural_boundaries`: assembly loses `jmp|call|ret|b|bl|bx|blr`, agc_assembly loses `TC|TCF|TCR|CALL|GOTO` (unconditional -- TC is the AGC's subroutine call) and `RESUME|RETURN` (returns), and agc's `CCS` is de-duplicated out of `structural_boundaries` so only `branch` claims it. Authoring (NOT a pure re-bless -- the issue's "Corpus pairing" section said no authoring change, but both shells planted unconditional mnemonics as branch keywords): - `main.asm` probe_branch planted `jmp` / `je` / `jne`. `jmp` is an unconditional transfer, so leaving it would drop probe_branch to two conditionals against SPEC's `branch x 3`. Re-authored to `jz`. - `main.agc` PROBEBR planted `TCF` + `BZF` and leaned on DISPATCH's `TC` to reach three, which no longer holds once only conditionals count. It now plants three real conditionals: `BZF` on the label line (still a func_start opcode), then `BZMF` and `BMN`. main.agc branch stays 3. Manifests (both PASS: assembly 76 assertions, agc_assembly 80): - assembly branch main 10->3, a 4->0, b 5->0, c 5->0 (25 hits corpus-wide of which 23 were transfers -> 3, all decisions). - assembly b.asm `state_mutation` 6->2, the predicted flux ripple: the branch context inside probe_state's 150-character radius was the function's own `ret`, so with call/ret out of `branch` the file records its raw inc+dec. Same de-amplification gitgalaxy#2634 produced for apex. - agc_assembly c.agc branch 1->0 (RESUME is an interrupt return; it keeps its `cleanup` reading). main.agc branch 3->3, now three conditionals. Ledger: - `asm-call-ret-in-branch` -> `still_reproduces: false`, upstream_issue gitgalaxy#2764, languages_seen gains agc_assembly (same shape, same fix). - `asm-single-letter-mnemonic-in-path` -> `signal` repointed from `branch` to `structural_boundaries`. The collision still reproduces (a bare `b` in a path is still matched) but no longer claims a decision; the underlying literal-counting cause (#2535) is unchanged, so the entry is repointed rather than retired. - `state-flux-branch-weighting` -> assembly drops out of languages_seen. Menus regenerated for the two languages (`tools/keyword_menu.py assembly agc_assembly`). Both files also pick up a stale-since-gitgalaxy#2730 `api` refresh (EXTERN/IMPORT, SUBROUTINE/BEXT/EXTEND) that predates this change. Effect (bias_report.py against the #2779 build, not committed -- bias-history.yml owns those artifacts): assembly 10 out-of-band cells -> 1, agc_assembly 8 -> 3. avg_func_complexity, max_func_complexity, func_internal_density, cog_raw, func_complexity_gini, risk_cognitive_load, risk_state_flux, control_flow_ratio, structural_mass and dependency_density all come back into band. Corpus-wide: 36 -> 37 metrics at >=80% green-band share, avg_func_complexity 67% -> 72%, and func_internal_density leaves the five weakest metrics. `na_check --ci` clean. Cross-repo: squid-protocol/gitgalaxy#2779 merges FIRST (docs/GATING.md "Cross-repo flow (no pins)"); `verify.yml` here is red against engine main until it lands. Claude-Session: https://claude.ai/code/session_01JrpVFZDVVWo19LP3nYoQfP Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Both assembly dialects counted every control transfer as a
branch. Thegeneric-assembly rule carried
jmp|call|ret|b|bl|bx|blrnext to the conditionaljumps;
agc_assembly's carriedTC|TCF|TCR|CALL|GOTO(unconditional —TCis theAGC's subroutine call) plus
RESUME|RETURN(returns). Measured against thekeyword-rosetta control corpus, 23 of assembly's 25 branch hits and 4 of agc's 5
were not decisions — 13 returns, 7 calls, 3 unconditional jumps.
Why this is a defect and not ISA morphology
branchfeedsavg_func_complexity,max_func_complexity,func_internal_density,cog_raw,control_flow_ratioandrisk_cognitive_load— every one a decision-density measure — plus #2546's ×3 cascading-flux
amplifier. Counting
call/retmade cognitive load track how many subroutines afile has, which
functions_foundalready measures:avg_func_complexityfunc_internal_densitycog_rawcontrol_flow_ratiorisk_cognitive_loadassembly was also the only language in the corpus where the flux amplifier fired at
all — the "branch context" within 150 characters of the mutation was a
ret.#2545 settled the identical question for high-level languages when it took bare
returnout ofbranchin kotlin/apex/objective-c/powershell/solidity/zig.retIS
return,callis a call, and no other language'sbranchcounts its callsyntax.
Fix — relocate, not delete (#2545's own branch)
Both
structural_boundariesrules already held the mnemonic families these belongwith (
push/pop/mov/lea;CA/TS/XCH), so the tokens stay measured, in therule that means structure rather than decision — and
control_flow_ratio = branch / (branch + linear)keeps the same denominator. One deliberatede-duplication: agc's
CCS(Count, Compare and Skip, its one real multi-way test)was counted by both rules and is now claimed by
branchalone.Side effect: ARM's single-letter
bstops inflatingbranchfrom prose and paths(the filename inside
%include "b.asm"matched\bb\b— rosetta ledgerasm-single-letter-mnemonic-in-path). The false positive moves with the token tothe bulk structural signal, where it is not a decision claim.
Verification
assemblyoragc_assemblydirectory group, verified programmatically across all2817 files: 189 files moved, none outside those languages' own extensions. The
issue's polyglot warning does not bite here — all 244
.asm/.s/.S/.inc/.agcfilesin the crucible live under those two categories, checked rather than assumed.
5. Function Analysis[N]churn is impact-order reshuffling of the same functions,not re-extraction.
apollo-11filescarrying
CCS, where the total drops by exactly that file's CCS count (15/4/26/1/…cross-checked against a raw
\bCCS\bcount per file). That is the intendedde-duplication and nothing else.
state_fluxleaderboard reshuffles as agc's amplified flux drops) plus the usualglobal 3D topology reflow.
branch/structural_boundariesparametrized cases arere-partitioned in both languages (
\tjmp foowas astructural_boundariesnegative and is now a positive), plus 5 new regression tests — decision-vs-transfer
sweeps in each dialect, the
%include "b.asm"false positive, andRESUMEstillreading as
cleanup— and 2 ReDoS detonations for the widened alternations.crucible_check.pyPASS both venvs;audit_check.pyall clear (ruff/mypy/dead-key/ast-accuracy).
Cross-repo
rosetta-auditagainst this build moves exactly two languages,assemblyandagc_assembly; the other 44 PASS unchanged. Failures are the intended ones:branch10→2 / 4→0 / 5→0 / 5→0 (assembly), 3→1 / 1→0 (agc), and the predictedb.asmstate_mutation6 → 2 flux ripple once the phantomretbranchcontext disappears (the same ripple fix(standards): stop counting bare return as branch in 6 languages (closes #2545) #2634 confirmed for apex).
keyword-rosetta/docs/GATING.md"Cross-repo flow (no pins)", this PR mergesfirst with the
rosetta:rebless-owedlabel; the corpus re-bless follows againstengine main as corpus(assembly, agc_assembly): branch plants conditionals only, re-bless against gitgalaxy#2764 keyword-rosetta#65.
change, but
main.asm'sprobe_branchplantsjmp/je/jneandmain.agc'sPROBEBRplantsTCF/BZF— i.e. the planted 3 include the very unconditionalmnemonics this PR reclassifies. A re-bless alone would leave both languages
planting fewer conditionals than SPEC's
probe_branch → branch × 3. The corpus PRtherefore swaps those plants for real conditionals, and re-blesses. Ledger:
asm-call-ret-in-branchretires,asm-single-letter-mnemonic-in-pathmoves tostructural_boundaries,state-flux-branch-weightingdrops assembly.rosetta[agc_assembly]: cross-language consistency — 5 red / 3 amber metrics, 3 ledgered shapes #2563). Sibling of kotlin: branch rule counts 'return' — inconsistent with java/swift/c siblings #2545 / fix(standards): stop counting bare return as branch in 6 languages (closes #2545) #2634.
🤖 Generated with Claude Code
https://claude.ai/code/session_01JrpVFZDVVWo19LP3nYoQfP