Skip to content

file_data.class_count sourced from raw class_start signal, not the real named class list #1972

Closed

Description

@squid-protocol

Summary

file_data.class_count in the SQLite recorder is computed from the raw class_start signal
count (hv[class_idx], the same value stored as struct_class_start), not from
len(classes) -- the actual named class list that also backs the class_data table. This is
inconsistent with function_count, which correctly uses len(functions) a few lines earlier
in the same function.

Where

gitgalaxy/recorders/record_keeper.py:

  • Line 395: func_count = len(functions) -- correct, function_count uses the real named list.
  • Line 557-558:
    class_idx = self.SIGNAL_SCHEMA.index("class_start") if "class_start" in self.SIGNAL_SCHEMA else -1
    class_count = hv[class_idx] if class_idx >= 0 and class_idx < len(hv) else 0
    class_count instead reads the raw signal vector -- the same number as struct_class_start,
    not len(file_data.get("classes", [])).
  • Line 675 (same per-file loop, just after the file_data row is already inserted):
    classes = file_data.get("classes", []) -- the real named list is available in this exact
    scope, just fetched too late/never reused for class_count.

A correct, already-proven precedent exists in the SAME file: a different function
(_aggregate_repo_summary or similar, around line 875) does
class_count = len(file_data.get("classes", [])) correctly -- the per-file row writer around
line 558 just never adopted that pattern.

Evidence

Found while manually verifying dockerfile's tri-comparison numbers (dockerfile has no
tree-sitter/ctags comparison tool, so numbers are cross-checked directly against pipeline DB
output). Scanned language-crucible/data/dockerfile/moby/test_targets/*.Dockerfile via
galaxyscope --db-only:

file_name                  struct_class_start  class_count  (class_data rows)
daemon.Dockerfile          69                   69           0
generate-files.Dockerfile  6                    6            0
syscall.Dockerfile         1                    1            0
windows.Dockerfile         1                    1            0

class_data is completely empty for all 4 files (dockerfile isn't in
_CLASS_START_NAMED_EXTRACTION_LANGS in detector.py, and the legacy fallback regex
class|struct|interface|trait|enum never matches Dockerfile's FROM keyword -- correctly, by
design, since dockerfile has no named-class extraction implemented at all yet). Despite that,
file_data.class_count still reports 69/6/1/1 -- a phantom count with zero backing rows in
class_data, because it's silently reading the raw signal instead of the (correctly empty)
named list.

Impact

Any consumer joining file_data.class_count against class_data (or just trusting
class_count as "number of real classes GitGalaxy found") gets a number completely
disconnected from reality for any language not in _CLASS_START_NAMED_EXTRACTION_LANGS
(dockerfile, and any other language relying on the legacy fallback regex that doesn't match its
own class syntax). It's likely invisible for most _CLASS_START_NAMED_EXTRACTION_LANGS
languages today only because their raw signal count and named list count usually happen to
coincide -- but that's a coincidence of those specific regexes, not a guarantee, and any
nested-class dedup or per-match rejection in the "FAST CLASS EXTRACTOR" loop would produce the
same silent divergence there too.

Suggested fix

Swap class_count's source at record_keeper.py:558 to len(file_data.get("classes", [])),
mirroring func_count's pattern at line 395 exactly. Not bundled into the dockerfile func_start
routing fix (a separate, unrelated bug found along the way) because this one's blast radius is
NOT dockerfile-specific -- it touches class_count for every language in every scan, so it
needs its own full differential-scan verification (crucible_check.py against the full corpus,
both golden masters re-blessed) as its own scoped PR.

Activity

  1. added
    bug
    data-integrity
    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

    bugdata-integritypriority: mediumtesting

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions