Repository navigation
Widen hlasm internal_discriminator to catch EQU-only register copybooks (#3110) - #3151
Merged
Merged
Conversation
…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]>
Contributor
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]>
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.
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/ARMassemblyat Tier 1.5 (Ecosystem Consensus Lock). It carries none of the #2503internal_discriminatortokens (CSECT/DSECT/USING/…), so Tier 2 never fired and gravity decided.Fix
Issue option 1 — the register-equate idiom specifically.
internal_discriminatornow 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 equateR0 EQU 0 / R1 EQU 1 / …— x86 registers are native, not user-equated. TheR-prefix + numeric-value + 3-hit requirement keeps real MASM equate files resolving asassembly.Verification
LanguageDetector.focus()path: the EQU copybook →hlasm; a MASM file (.model/.code/mov) →assembly.[\s\S]*?scans to at most two → linear; verified against an 80k-line adversarial input (~0.05 s).test_hlasm_strict.py(147) passes;hlasm.pyruff identical to baseline; mypy clean.