fix(#1983): don't treat alternation-shaped class_start group 2 as a lineage parent - #2380
Merged
Merged
Conversation
…roup 1 also fired
THE LINEAGE EXTRACTOR in detector.py swept every class_start match's
group-2 capture into extracted_parents (-> parent_entity metadata)
whenever the pattern had 2+ groups. Correct for `class Foo extends Bar`
(g1=name, g2=parent), wrong for alternation-shaped class_start rules
where the name lands in group 1 OR group 2, never both:
- fortran: `(?:MODULE|INTERFACE|SUBMODULE)\s+(g1) | TYPE\s+(g2)` --
a bare `TYPE point` put "point" in parent_entity as its own parent.
- dockerfile: `FROM .. AS (g1) | FROM (g2)` -- a bare `FROM debian`
put the base image in parent_entity.
- lua, abap: same alternation shape.
_resolve_class_start_match (the named-class path) already gets this right
-- group 2 is inheritance only `if name_group_idx == 1`. Apply the same
rule here: require group 1 to have matched too. Class extraction itself
is unaffected; this only fixes the secondary parent_entity field.
Closes #1983.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
crucible_check.py --update: 5 Parent Entity fields removed, all cases where the "parent" was really the declaration's own name or base image -- 2 fortran files (TYPE names), 3 dockerfile files (bare FROM base images). No class-count or other structural changes. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Contributor
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 #1983.
Problem
detector.py's THE LINEAGE EXTRACTOR swept everyclass_startmatch's group-2 capture into
extracted_parents(→ the file'sparent_entitymetadata) whenever the pattern had 2+ groups:Correct for
class Foo extends Bar(g1 = name, g2 = parent). Wrong foralternation-shaped
class_startrules, where the name lands in group 1or group 2 depending on which branch fired — never both:
(?:MODULE|INTERFACE|SUBMODULE)\s+(g1) | TYPE\s+(g2)TYPE point→parent_entity = "point"(its own name)FROM .. AS (g1) | FROM (g2)FROM debian→parent_entity = "debian:…"The named-class path (
_resolve_class_start_match) already handles thiscorrectly — it treats group 2 as inheritance only
if name_group_idx == 1.The lineage extractor just never got the same guard.
Fix
Group 2 is a lineage parent only when group 1 (the name) also matched —
the same rule
_resolve_class_start_matchuses, so the two can't drift.Class extraction itself is untouched; this only fixes the secondary
parent_entityfield.Verification
test_detector_lineage_ignores_alternation_shaped_class_start(fortran-shaped
MODULE|TYPErule); existingtest_detector_harvest_above_and_lineage(name-then-parent) still passes.crucible_check.py --update: 5Parent Entityfields removed, nothingelse — 2 fortran files (
TYPEnames), 3 dockerfile files (bareFROMbase images, including the
syscall.Dockerfilecase cited in the issue).No class-count or other structural drift. Both golden masters re-blessed.
tri_comparison_chart.py --all --ci: all OK, no precision regressions.🤖 Generated with Claude Code