Skip to content

Widen hlasm internal_discriminator to catch EQU-only register copybooks (#3110) - #3151

Merged
squid-protocol merged 3 commits into
mainfrom
fix/hlasm-equ-3110
Sep 17, 2026
Merged

squid-protocol merged 3 commits into
mainfrom
fix/hlasm-equ-3110

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Closes #3110.

Problem

ASMCOPY/REGISTRS.asm — a 19-line HLASM register-equate copybook (R0 EQU 0 … R15 EQU 15, name in column 1, no colon) — misclassified as x86/ARM assembly at Tier 1.5 (Ecosystem Consensus Lock). It carries none of the #2503 internal_discriminator tokens (CSECT/DSECT/USING/…), so Tier 2 never fired and gravity decided.

Fix

Issue option 1 — the register-equate idiom specifically. internal_discriminator now also matches ^R[0-9]{1,2}[ \t]+EQU[ \t]+[0-9]{1,2} requiring three occurrences.

Why this doesn't flip MASM: MASM also writes colon-less NAME EQU value, but does not repetitively equate R0 EQU 0 / R1 EQU 1 / … — x86 registers are native, not user-equated. The R-prefix + numeric-value + 3-hit requirement keeps real MASM equate files resolving as assembly.

Verification

  • Two new strict tests drive the real LanguageDetector.focus() path: the EQU copybook → hlasm; a MASM file (.model/.code/mov) → assembly.
  • ReDoS: a match failure requires <3 hits, which bounds the lazy [\s\S]*? scans to at most two → linear; verified against an 80k-line adversarial input (~0.05 s).
  • Full test_hlasm_strict.py (147) passes; hlasm.py ruff identical to baseline; mypy clean.

…ks (#3110)

An HLASM register-equate copybook like ASMCOPY/REGISTRS.asm (`R0 EQU 0` …
`R15 EQU 15`, name in column 1, no colon) carries none of the #2503
internal_discriminator's tokens (CSECT/DSECT/USING/…), so Tier 2 never fired and
the "Ecosystem Consensus Lock" misclassified it as x86/ARM `assembly`.

Fix (issue option 1 -- the register-equate idiom specifically): the
internal_discriminator now also matches the name-field EQU shape
`^R[0-9]{1,2}[ \t]+EQU[ \t]+[0-9]{1,2}` requiring THREE occurrences. MASM also
writes colon-less `NAME EQU value`, but does not repetitively equate
`R0 EQU 0 / R1 EQU 1 / …` (x86 registers are native, not user-equated), so the
R-prefix + numeric-value + 3-hit requirement keeps MASM equate files resolving
as `assembly`.

ReDoS: failure requires <3 matches, which bounds the lazy `[\s\S]*?` scans to
at most two, keeping it linear -- verified against an 80k-line adversarial input
(~0.05s). Two new strict tests drive the real LanguageDetector.focus() path:
the EQU copybook -> hlasm, and a MASM file (.model/.code/mov) -> assembly.
hlasm.py ruff/mypy clean.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

squid-protocol and others added 2 commits September 17, 2026 18:02
The zero-tolerance `ruff format` gate requires each `+`-concatenated regex
operand on its own line. Formatting only; no behavior change.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Regenerated both golden-master fixtures for the internal_discriminator widening.
The entire diff is the single expected reclassification of
zopeneditor_sample/REGISTRS.asm (Assembly -> Hlasm, Tier 1.5 -> 2, Identity
Proof "Ecosystem Consensus Lock" -> "Single Indicator (Internal Signature)")
plus its downstream ripple: the assembly composition bucket loses one file
(233->232) and hlasm gains one (17->18), REGISTRS.asm re-measured under hlasm
rules (Coding LOC 20->16, Documentation LOC 0->4 as the `*` comment line now
counts, Function Parameters 10->0), topological X/Y/Z re-solve, and total_loc
drift of 4. No other corpus file changed.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@squid-protocol
squid-protocol merged commit 6f991d0 into main Sep 17, 2026
33 checks passed
@squid-protocol
squid-protocol deleted the fix/hlasm-equ-3110 branch September 17, 2026 22:29
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.

Detection hardening: EQU-only .asm copybooks misclassify as assembly (hlasm discriminator gap)

1 participant