Skip to content

Repo-level ecosystem_baseline clustering's feature vocabulary is stale -- 3 of 4 static-file archetype slots never populated #1159

Closed

Description

@squid-protocol

🛑 Problem Statement

repo_data.ecosystem_baseline (repo_macro_species, the repo-wide K-Means clustering computed
by signal_processor.py:1116-1158) clusters each repo by the ratio of its files across each
file archetype
. Its features list (GENERAL_REPO_INFERENCE_MODEL, analysis_lens.py:8096)
must exactly string-match the archetype names actually produced by file-level classification --
feature_counts = {feat: archetype_counts.get(feat, 0) for feat in repo_model["features"]}
(signal_processor.py:1126) silently drops any archetype whose name isn't in that list.

The model's feature list includes 4 "static" (non-ML, bypass-path) slots meant to correspond to
STATIC_ARCHETYPES (gitgalaxy_config.py:672-677, the single source of truth for files that
skip active ML classification -- build/vendor/doc/data files). Comparing the two:

GENERAL_REPO_INFERENCE_MODEL["features"] (trained on) Current STATIC_ARCHETYPES value Match?
"File Macro-Species 10: Universal Mixed Logic" (nothing produces this string anymore) dead
"Static: Literature & Documentation" "Static: Literature & Documentation" matches
"Static: Minified & Vendor Opaque Mass" "Static: Minified & Vendor Opaque Footprint" mismatch ("Mass" vs "Footprint")
"Unknown" "Static: Unmapped / Unsupported Format" mismatch
(missing entirely) "Static: Declarative Data & Configurations" not represented at all

Net effect: any file classified as data/minified/unknown under today's STATIC_ARCHETYPES
contributes zero to the repo's feature vector -- archetype_counts.get(feat, 0) misses on
every one of those 3 slots every time, regardless of how many such files the repo actually has.
Repos dominated by config/data files, vendor/minified bundles, or unparsable/unknown files get
systematically misclassified, because up to 4 of the 22 trained feature dimensions are
permanently zero no matter the real repo composition. "File Macro-Species 10: Universal Mixed Logic" also confirms this model predates the file-level model's current naming scheme (see the
sibling file-level issue -- the "Claim 5" doc it references described a 10-cluster file model;
this repo model's dead string is a leftover from that generation).

Separately (lower severity, not the main bug): GENERAL_REPO_INFERENCE_MODEL never sets a
cluster_names key, so signal_processor.py:1141-1144's fallback ([f"Cluster {i}" for i in range(k_clusters)]) is always taken -- repo_data.ecosystem_baseline is permanently a bare
"Cluster 0".."Cluster 5" label, never a human-readable name (unlike the function-level model,
which does ship real cluster_names like "Utility/Helper"). This is what produced the
"Cluster 3"-style values referenced in #1149.

🎯 Objective

Make the repo-level feature vocabulary match what the file-level classifier (and its static
bypass path) actually produce today, so repo clustering counts every file instead of silently
dropping the static ones.

🛠️ Proposed Implementation

  1. Update GENERAL_REPO_INFERENCE_MODEL["features"] (and its centroid/z-score-param vectors,
    which are keyed positionally to features) to use the 4 current STATIC_ARCHETYPES string
    values instead of the 3 stale ones + 1 dead legacy string. This changes the model's
    dimensionality (22 -> 23, gaining the data slot) and requires the centroids to be
    re-derived, not just relabeled -- flag as needing real retraining data, not a pure string swap.
  2. If retraining isn't feasible right now, at minimum fix the 2 renamed-string mismatches
    ("Static: Minified & Vendor Opaque Mass" -> "...Footprint", "Unknown" ->
    "Static: Unmapped / Unsupported Format") so those two slots stop being permanently zero --
    a smaller fix that restores 2 of the 3 broken slots without touching centroid dimensionality.
  3. Decide what to do with the dead "File Macro-Species 10: Universal Mixed Logic" slot -- it
    doesn't correspond to anything current code produces, so it's permanently zero and can likely
    just be dropped (reduces dims by 1) once whoever owns the training data confirms it's safe to.
  4. Optional: populate cluster_names with descriptive labels the same way
    GENERAL_FUNCTION_INFERENCE_MODEL does, so ecosystem_baseline stops being a bare cluster
    index.

✅ Acceptance Criteria

  • Every STATIC_ARCHETYPES value has an exact-matching slot in
    GENERAL_REPO_INFERENCE_MODEL["features"].
  • No dead/unproducible strings remain in GENERAL_REPO_INFERENCE_MODEL["features"].
  • A repo whose files are dominated by config/data/vendor/unknown files is proven (via a real
    test) to actually shift repo_data.ecosystem_baseline's cluster assignment, not silently
    contribute zero.

Activity

  1. added
    bug
    ml-ops
    metrics
    data-integrity
    on Aug 9, 2026
  2. squid-protocol commented on Aug 9, 2026

    @squid-protocol
    OwnerAuthor

    Part of epic #1160 (K-Means archetype clustering drift, all 3 tiers). Sibling issue: #1158 (file-level, referenced above for the file-archetype naming scheme this repo model's features are keyed off of).

  3. squid-protocol commented on Sep 16, 2026

    @squid-protocol
    OwnerAuthor

    Checked this against current main (23d7b8a) — none of this issue's reported bug has been touched.

    GENERAL_REPO_INFERENCE_MODEL["features"] in analysis_lens.py still lists, verbatim:

    • "File Macro-Species 10: Universal Mixed Logic" — still dead, nothing produces this string
    • "Static: Minified & Vendor Opaque Mass" — still mismatched against STATIC_ARCHETYPES["minified"] = "Static: Minified & Vendor Opaque Footprint"
    • "Unknown" — still mismatched against STATIC_ARCHETYPES["unknown"] = "Static: Unmapped / Unsupported Format"
    • "Static: Declarative Data & Configurations" (current STATIC_ARCHETYPES["data"]) — still absent from the feature list entirely

    And the model still has no cluster_names key, so ecosystem_baseline is still a bare "Cluster 0".."Cluster 5" label (the signal_processor.py:1141 fallback is unconditionally taken).

    The recent archetype work (#3016/#3021 function-level, #3023/#3026/#3061 file-level + the new composition lenses) is all real progress on the epic, but it's additive/parallel — repo_composition_archetype (#3023) is a brand-new population-relative feature living alongside ecosystem_baseline, not a fix to it. The original ecosystem_baseline/repo_macro_species K-Means path this issue describes (signal_processor.py:1240 → GENERAL_REPO_INFERENCE_MODEL) is untouched by any merged PR.

    Leaving open — none of the acceptance criteria here are met yet.

  4. added a commit that references this issue on Sep 16, 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-integritymetricsml-opspriority: medium

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions