Skip to content

dockerfile has no named class (build-stage) extraction -- class_start regex captures the FROM keyword, not the stage alias #1974

Closed

Description

@squid-protocol

Summary

Dockerfile is not in _CLASS_START_NAMED_EXTRACTION_LANGS (gitgalaxy/core/detector.py:369), so
it gets the legacy fallback regex (class|struct|interface|trait|enum) for named-class
extraction -- which never matches Dockerfile's FROM syntax at all, correctly, since Dockerfile
has no such keywords. The practical result: class_data stays completely empty for every
Dockerfile scanned (confirmed: 0 rows across all 4 files in
language-crucible/data/dockerfile/moby/test_targets/, despite real multi-stage builds with up
to 69 real FROM ... AS <stage> build stages in one file).

This is a real, missing feature, not a bug in an existing implementation -- filed separately from
#1972 (which is about file_data.class_count wrongly reporting a phantom number even though this
gap exists) because implementing it requires a regex change, not just a data-source swap.

Why simply adding "dockerfile" to the allowlist isn't enough

Dockerfile's own class_start rule (language_standards.py):

"class_start": re.compile(r"^[ \t]*(FROM)(?=[ \t]|\\[ \t]*(?:\r?\n|$))", re.M | re.I),

Group 1 captures the literal keyword FROM, not the build stage's actual name/alias (the
AS <name> suffix, e.g. FROM golang:1.25 AS base -> real name is base, GitGalaxy's own
"class wrapper" framing per the rule's own comment). Every real Dockerfile class instance would
need to resolve to the SAME literal string "FROM" if the allowlist were added today without
also changing the regex to capture the AS <name> alias (falling back to the base image name,
e.g. golang:1.25, for a stage with no alias -- the final/default stage).

Suggested fix

  1. Extend class_start's regex to capture the stage alias when present
    (FROM <image>(?:\s+AS\s+(\S+))?), landing the name in a group the same way other languages'
    class_start rules already do.
  2. Add dockerfile to _CLASS_START_NAMED_EXTRACTION_LANGS.
  3. Decide the boundary-resolution path: dockerfile stages are never nested (mirrors ABAP's own
    #1907 precedent -- flat "next class match, or EOF" is always correct, no brace/indent
    scoping needed).
  4. Verify against _CLASS_START_REQUIRES_BODY_ANCHOR gating (dockerfile should NOT be added
    there -- a FROM line has no body-anchor concept the way c's forward-declaration check does).

Full verification chain required (extraction gauntlet + strict tests, ruff/mypy audits,
crucible_check.py against the full corpus, both golden masters re-blessed) since this is a
language_standards.py + detector.py change, same as any other parsing-logic PR.

Activity

  1. added
    bug
    core-engine
    testing
    on Aug 21, 2026
  2. added this to the v2.4.9 milestone on Aug 31, 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-enginepriority: mediumtesting

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions