Skip to content

Epic: Refactor calls_out_to extraction to support non-C language paradigms #3264

Closed

Description

@squid-protocol

GitGalaxy's Information Flow Graph relies on the calls_out_to metric to map internal modularity (subroutines) and cross-module dependencies. Currently, detector.py uses a single generic bounded regex to extract these calls:
\b([a-zA-Z_]\w*)\s*\(

This regex fundamentally assumes that every programming language invokes functions using C-style syntax (name(arg)). A sweep of the keyword-rosetta baseline reveals that this assumption is severely breaking structural analysis for non-C paradigms.

The Impact

The single regex causes two distinct classes of failure:

  1. Topology Blindness (Empty Graphs): Languages that use verbs, space-separation, or brackets for invocation never trigger the regex. Their calls_out_to arrays remain empty, rendering their PageRank and dependency graphs useless.

    • Mainframes (cobol, abap, assembly, hlasm): Rely on verbs like PERFORM, CALL, GO TO.
    • Shell Scripting (shell, bash): Rely on space separation (command arg1).
    • Tcl & Obj-C: Rely on bracket dispatch ([command arg1]).
  2. Topology Pollution (Garbage Edges): Languages where control-flow constructs use parentheses are having their core keywords extracted as function targets.

Options to Solve

Option 1: The Regex Paradigm Switcher (Recommended)
Refactor the invocation_pattern in detector.py to route based on language paradigm, defining bespoke, high-precision regex patterns for each family:

  • C_FAMILY: Retain the current \b([a-zA-Z_]\w*)\s*\( but drastically enhance the language-specific ignore_keywords list to filter out IF, elsif, etc.
  • MAINFRAME_VERBS: (?:PERFORM|CALL|GO\s+TO)\s+['"]?([A-Za-z0-9_-]+)
  • LISP_FAMILY: \(\s*([a-zA-Z0-9_-]+)
  • BRACKET_DISPATCH: \[\s*([a-zA-Z0-9_-]+)
    Pros: Maintains the speed of AST-free bounded regex extraction. Fixes 90% of the gaps instantly.
    Cons: Still struggles with Shell/Bash, where distinguishing a function call from a binary execution via regex is nearly impossible.

Option 2: AST-Assisted Extraction (Hybrid Mode)
Use Tree-Sitter (when available) to extract calls_out_to, falling back to regex only for unsupported languages.
Pros: Perfect precision for all languages.
Cons: Violates the strict AST-free engine requirement for the primary detector phase. Major performance penalty.

Option 3: Strict Opt-In Metric (The Lazy Route)
Mark calls_out_to as officially null (n/a) for non-C paradigms, actively deciding that GitGalaxy will not map dependency edges for Mainframes, Shell, or Lisp.
Pros: Easiest to implement. Instantly stops polluting the graph with garbage data.
Cons: A complete architectural cop-out that permanently blinds the product to the structure of enterprise mainframes.

Activity

  1. squid-protocol commented on Sep 21, 2026

    @squid-protocol
    OwnerAuthor

    Context & Reassurance on COBOL/Mainframe Paradigms:

    An audit of gitgalaxy/standards/language_standards/languages/cobol.py confirms that the actual structural regex keys for COBOL (class_start, func_start, import, args) are incredibly thorough and perfectly fitted to the mainframe paradigm (e.g., extracting PROGRAM-ID, COPY, and USING clauses).

    The language definitions themselves do not suffer from a systemic C-centric bias. The only reason calls_out_to is failing so spectacularly across non-C paradigms is because it is a generic fallback hardcoded directly into the detector.py execution loop, bypassing the paradigm-aware dictionary mechanism entirely.

    Implementing Option 1 (The Regex Paradigm Switcher) will simply bring calls_out_to up to the same rigorous, paradigm-aware standard that the rest of the COBOL definitions already enjoy.

  2. added
    epicLarge-scale architectural milestone or multi-issue initiative
    core-engineModifications to the central physics and parsing engine
    on Sep 22, 2026
  3. squid-protocol commented on Sep 22, 2026

    @squid-protocol
    OwnerAuthor

    Phase 3 complete (2026-09-22): per-language calls_out corrected across all 65 profiles

    Option 1 (regex paradigm switcher) shipped via 6 engine PRs + 5 rosetta rebless PRs, gated end-to-end by a hand-derived truth oracle (keyword-rosetta#144: docs/calls_out_truth.json + checker, now PASS 51/51 on both repos' mains).

    Engine PRs: #3288 foundation (_calls_out_ignore union mechanism + 3 shared constants) · #3289 demotions (11 data/markup langs → UNSUPPORTED) · #3294 CALL-verb + mainframe (fortran/pli/rexx/db2_sql/assembly + abap/hlasm/agc customs) · #3295 command-position + build tools (tcl/powershell/livecode + makefile/batch) · #3297 C-family ignore tuning (perl/ruby/lua/matlab/ada/m4) · #3298 functional/symbolic (scheme/haskell/objectivec/mlir/hlo) · #3296 helper-key convention fix.
    Rosetta: #144 oracle · #145–#149 reblesses (110+ cells re-baselined; rebless.py gained per-function diffs + --add-keys functions:<metric>).

    Real-repo proof (zopeneditor-sample): COBOL paragraph PERFORM-chains (36 edges) and PL/I PSAM1 → PRTHDG1/PSAM2/TRANTOT — graphs that were empty or garbage before.

    Gap register (all ledgered in the truth oracle):

    • jcl: EXEC lives on the step-card signature line, outside the scanned body → calls_out: jcl step→program edges need signature-line scanning #3292 (detector signature-line scanning)
    • db2_sql: scans persist zero function_data rows → db2_sql corpus scans persist zero function_data rows — calls_out unobservable in rosetta #3293
    • shell/dockerfile: intentionally blind (call-vs-binary not regex-distinguishable) — decided 2026-09-22
    • makefile prerequisite edges: non-goal (one-group findall can't express them); only $(call) extracted
    • Ledgered recall gaps: haskell bare juxtaposition, rust name!( macros, abap => methods, hlasm system macros, powershell $obj.method(), unary objc selectors, leading-:: tcl, scheme operator applications
    • batch/mlir/hlo have no rosetta corpus folders (strict-tested only) → keyword-rosetta follow-up filed
    • Golden masters: single-leaf re-bless (sconstruct identity confidence — legacy C-style garbage was inflating a detection score)

    🤖 Generated with Claude Code

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

    core-engineModifications to the central physics and parsing engineepicLarge-scale architectural milestone or multi-issue initiative

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions