Skip to content

assembly/agc_assembly: branch counts unconditional transfers — 23 of 25 hits are call/ret/jmp, not decisions (#2545's shape) #2764

Closed

Description

@squid-protocol

Found by the same pass as #2763 (2026-09-05, engine 3b3568e0, corpus main 6183c4b). assembly is the corpus's largest single outlier: branch 24 against a planted intent of 3, and eight further red cells derived from it. 23 of its 25 branch hits are unconditional transfers.

Measured

LANGUAGE_DEFINITIONS['assembly']['rules']['branch'].finditer over keyword-rosetta/data/assembly (4 files, 3 planted conditionals):

file hits tokens
a.asm 4 b, ret, ret, ret
b.asm 6 b, ret, call, call, ret, ret
c.asm 5 call, call, ret, ret, ret
main.asm 10 call, call, call, ret, jmp, je, jne, ret, ret, ret
total 25 ret 13 · call 7 · b 2 · jmp 1 · je 1 · jne 1

Two of twenty-five hits are decisions. The other twenty-three are a subroutine return (13), a subroutine call (7), and an unconditional jump (3).

agc_assembly has the same shape in one alternation:

"branch": re.compile(r"\b(TC|TCF|BZF|BZMF|BZE|BMN|BPL|BMI|CCS|RESUME|RETURN|TCR|OVSK|BVBZ|CALL|GOTO)\b")

TC/TCF/CALL/GOTO are unconditional transfers and RESUME/RETURN/TCR are returns; only BZF/BZMF/BZE/BMN/BPL/BMI/CCS test anything. Corpus totals: TCF 2, TC 1, RESUME 1, BZF 1 — 4 of 5 unconditional.

Why this is a defect and not ISA morphology

The engine already decided this question for high-level languages. #2545 removed return from branch in kotlin/apex/objective-c/powershell/solidity/zig on the grounds that a return is not a decision, checked eleven sibling languages that agree, and relocated it to structural_boundaries where the language had no other rule capturing it. ret is return; call is a call. Neither is a decision in any language, and no other language's branch rule counts its call syntax.

The counter-argument — "in assembly, control transfer is the control-flow vocabulary" — is answered by what the metrics do downstream. branch feeds avg_func_complexity, max_func_complexity, func_internal_density, cog_raw, control_flow_ratio and risk_cognitive_load, all of which are decision-density measures. Counting call/ret makes cognitive load track how many subroutines a file has, which is the thing functions_found already measures:

metric assembly median deviation
avg_func_complexity 1.708 0.1875 +811%
func_internal_density 0.1424 0.01562 +811%
cog_raw 0.18 0.0205 +778%
control_flow_ratio 0.5853 0.09375 +524%
max_func_complexity 2.75 0.75 +267%
risk_cognitive_load 9.389 2.795 (irc4) +236%
risk_state_flux 22.92 7.751 +196%

risk_state_flux is on that list because the ×3 cascading-flux amplifier (#2546, spatial_correlation.py:278) needs a branch hit within 150 characters of a mutation — and assembly is the only language in the corpus where the amplifier fires at all (raw state_mutation 2, recorded 6; every other language records its raw count). The phantom branch context is a ret.

avg_func_complexity and func_internal_density are two of the corpus's five weakest metrics by consistency score (67% each). assembly is the ceiling on both; #2763's tcl is the floor.

Candidate shape

Split the alternation the way #2545 split return:

# assembly
"branch": re.compile(r"\b(je|jne|jz|jnz|ja|jb|jl|jg|jge|jle|jae|jbe|cbz|cbnz|tbz|tbnz|beq|bne|loop)\b"),
"structural_boundaries": re.compile(r"\b(...existing..., jmp|call|ret|b|bl|bx|blr)\b"),
# agc_assembly
"branch": re.compile(r"\b(BZF|BZMF|BZE|BMN|BPL|BMI|CCS|BVBZ|OVSK)\b"),
"structural_boundaries": re.compile(r"\b(...existing..., TC|TCF|TCR|CALL|GOTO|RESUME|RETURN)\b"),

Both structural_boundaries rules already exist and already carry the mnemonic families they belong with (assembly's holds push/pop/mov/lea; agc's holds CA/TS/XCH), so this is #2545's "relocate, not delete" branch — the tokens stay measured, in the rule that means structure rather than decision. Note ARM's single-letter b, which is also the reason a filename inside %include "b.asm" reads as a branch (the asm-single-letter-mnemonic-in-path ledger entry): moving it out of branch closes that false positive as a side effect. CCS appears in both agc rules today and should stay in branch only.

Strict positive/negative tests per #2545's pattern in tests/extraction/languages/test_assembly_strict.py and test_agc_assembly_strict.py: a conditional-jump ladder, a call/ret pair, an ARM b/bl pair, and an AGC CCS counting while TC Q does not.

Blast radius

Directory groups containing .asm/.s/.S/.agc files. Note that polyglot repos in the golden master carry assembly files inside C projects — scope the diff programmatically the way #2634 did rather than by top-level language.

Corpus pairing

No authoring change: keyword-rosetta/data/assembly plants 3 conditionals and that is what the fixed rule should read. The re-bless moves assembly's branch, the six derived shape cells, and state_mutation 6 → 2 once the phantom branch context disappears (the same ripple #2634 confirmed for apex). Ledger: asm-call-ret-in-branch retires, asm-single-letter-mnemonic-in-path retires, state-flux-branch-weighting drops assembly.

Part of #2669 (rosetta[assembly] is #2565, rosetta[agc_assembly] is #2563). Sibling of #2545.

Activity

  1. added
    bug
    metrics
    core-engine
    on Sep 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcore-enginemetrics

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions