Skip to content

prism.py: ABAP's positional comment stripper reuses Fortran/COBOL's column-1 anchor set, erasing real code as comments #1898

Closed

Description

@squid-protocol

Summary

prism.py's _strip_positional_comments() treats any line whose column-1 (or column-7) character is in the shared POSITIONAL_ANCHORS set as a full-line comment and strips it from code_stream entirely. That set — {"*", "C", "c", "/", "!"} (gitgalaxy/standards/language_standards.py:215, consumed at gitgalaxy/core/prism.py:192) — is built for Fortran's column-1 C-means-comment convention and COBOL's fixed-form markers, but is applied unconditionally to ABAP too, even though ABAP's own real column-1 comment marker is * only (confirmed by ABAP's own lexical_family doc comment in language_standards.py: "the engine must monitor Column 1 for an asterisk * to identify line-level Commented / Non-Executable Text").

Since real ABAP class declarations are conventionally written flush-left (CLASS <name> DEFINITION / CLASS <name> IMPLEMENTATION.), column 1 is a literal C — so this shared anchor check silently erases every real class header into the comment stream.

Isolated repro

from gitgalaxy.core.prism import Prism
from gitgalaxy.standards.language_standards import LENS_CONFIG, LANGUAGE_DEFINITIONS

p = Prism(LENS_CONFIG.get("COMMENT_DEFINITIONS", {}), LANGUAGE_DEFINITIONS)
sample = "CLASS zcl_foo DEFINITION\n  PUBLIC\n  CREATE PUBLIC .\nENDCLASS.\n"
result = p.split_streams(sample, "abap")
print(result["code_stream"])
# '\n  PUBLIC\n  CREATE PUBLIC .\nENDCLASS.\n'  -- the CLASS header line is GONE
print(result["comment_stream"])
# 'CLASS zcl_foo DEFINITION'  -- misclassified as a comment

Real-world impact

Confirmed against language-crucible/data/abap/abapGit/ (7 files, all 6 .clas.abap files have exactly one real class each — verified by direct source read, grep -n "^CLASS " <file> shows both the DEFINITION and IMPLEMENTATION lines for each). Running the actual production pipeline (galaxyscope language-crucible/data/abap --db-only) and inspecting the resulting file_data.struct_class_start column: 0 for every single file, including the 6 files with real classes. This isn't "GitGalaxy doesn't track ABAP classes" — the class_start regex in language_standards.py is correct (running it directly against unprocessed file text finds all 12 real DEFINITION/IMPLEMENTATION matches) — the regex never gets the chance to run against that text at all, because prism.py already deleted it before detector.py's coding_analysis() sees it.

Downstream consequences, all silently wrong for every ABAP file with a class:

  • class_start's raw signal count (struct_class_start, feeds risk-scoring equations) is always 0.
  • class_data/class_count in the recorder DB is always empty — no ABAP class ever gets a row.
  • detector.py's class→method linkage (_function_slice's class_methods_by_id / parent_class_name assignment) can never fire for ABAP, since there are no classes to link methods into.
  • docs/self_scan/tri_comparison_chart.svg's "Classes Found"/"Class Precision" panels for abap show a flat 0, which reads as "no classes exist" rather than "classes are being erased before extraction."

Suggested fix direction

abap_mode already exists as a parameter to _strip_positional_comments() (used today only to gate the inline "-comment behavior at prism.py:888) — the column-1/7 anchor check at prism.py:876-878 needs the same kind of ABAP-specific carve-out, using an ABAP-only anchor set (just *) instead of the shared POSITIONAL_ANCHORS. This is shared parsing infra also used by COBOL and Fortran (which do want C/c as anchors), so per this repo's Differential Scan protocol, any fix needs crucible_check.py verification across the full corpus before it can ship, to confirm COBOL/Fortran output doesn't regress.

How this was found

Manual validation of ABAP (which has neither a tree-sitter grammar nor a ctags parser, so it's outside the normal tri-comparison-ledger pipeline) via the tri-comparison-ledger-sweep skill's manual-verification fallback, cross-checking the actual galaxyscope pipeline output against raw-regex expectations after the tri-comparison chart showed an unexplained Functions Found: 16 / Func Precision: 0/16 for abap that didn't match a from-scratch manual count.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions