Skip to content

fix(#1983): don't treat alternation-shaped class_start group 2 as a lineage parent - #2380

Merged
squid-protocol merged 2 commits into
mainfrom
fix/issue-1983-lineage-alternation
Aug 28, 2026
Merged

squid-protocol merged 2 commits into
mainfrom
fix/issue-1983-lineage-alternation

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Closes #1983.

Problem

detector.py's THE LINEAGE EXTRACTOR swept every class_start
match's group-2 capture into extracted_parents (→ the file's
parent_entity metadata) whenever the pattern had 2+ groups:

if rule_name == "class_start" and pattern.groups >= 2:
    extracted_parents.extend(m.group(2).strip() for m in matches if m.group(2))

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 depending on which branch fired — never both:

lang rule shape broken result
fortran (?:MODULE|INTERFACE|SUBMODULE)\s+(g1) | TYPE\s+(g2) TYPE pointparent_entity = "point" (its own name)
dockerfile FROM .. AS (g1) | FROM (g2) bare FROM debianparent_entity = "debian:…"
lua, abap same alternation shape same

The named-class path (_resolve_class_start_match) already handles this
correctly — it treats group 2 as inheritance only if name_group_idx == 1.
The lineage extractor just never got the same guard.

Fix

extracted_parents.extend(m.group(2).strip() for m in matches if m.group(2) and m.group(1))

Group 2 is a lineage parent only when group 1 (the name) also matched —
the same rule _resolve_class_start_match uses, so the two can't drift.
Class extraction itself is untouched; this only fixes the secondary
parent_entity field.

Verification

  • New test_detector_lineage_ignores_alternation_shaped_class_start
    (fortran-shaped MODULE|TYPE rule); existing
    test_detector_harvest_above_and_lineage (name-then-parent) still passes.
  • crucible_check.py --update: 5 Parent Entity fields removed, nothing
    else
    — 2 fortran files (TYPE names), 3 dockerfile files (bare FROM
    base images, including the syscall.Dockerfile case 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.
  • ruff / mypy / dead-key / ast-accuracy clean.

🤖 Generated with Claude Code

squid-protocol and others added 2 commits August 28, 2026 11:32
…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>
@squid-protocol squid-protocol added bug Unintended behavior or logic failure in the engine core-engine Modifications to the central physics and parsing engine labels Aug 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

@squid-protocol
squid-protocol merged commit 5a3d023 into main Aug 28, 2026
65 of 66 checks passed
@squid-protocol
squid-protocol deleted the fix/issue-1983-lineage-alternation branch August 28, 2026 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Unintended behavior or logic failure in the engine core-engine Modifications to the central physics and parsing engine

Projects

None yet

Development

Successfully merging this pull request may close these issues.

THE LINEAGE EXTRACTOR treats any class_start group 2 as an inheritance parent, even when group 1/2 are alternation-exclusive (not name+parent)

1 participant