Repository navigation
Description
Description
All three tiers of this engine's unsupervised K-Means archetype/clustering system --
function-level (func_archetype), file-level (file_archetype, global + per-language), and
repo-level (ecosystem_baseline / repo_macro_species) -- classify live data against
pre-trained centroid/scaler models hardcoded in gitgalaxy/standards/analysis_lens.py. There is
no training or regeneration tooling committed anywhere in this repo (confirmed: no sklearn
usage outside test fixtures, no train/kmeans script anywhere) -- these models were clearly
generated once, externally, and hand-pasted in as static dicts.
SIGNAL_SCHEMA (the feature source every one of these vectors is built from) has changed
repeatedly since -- #1020 removed AST-dependent security keys, #1145 added naming-convention
signatures, and more -- and each of those changes silently reshapes the live feature vector's
length and ordering without anyone checking whether it still lines up with what these trained
models expect. It doesn't. Confirmed by direct inspection, at all three tiers:
| Tier | Live feature vector | Trained model dimensionality | Result |
|---|---|---|---|
| Function (#1157) | 5 features | 62-dim GENERAL_FUNCTION_INFERENCE_MODEL |
92% of trained dims silently discarded via zip() truncation |
| File -- global (#1158) | 83 features | 115-dim GENERAL_FILE_INFERENCE_MODEL |
28% of trained dims silently discarded via min() truncation |
| File -- per-language (#1158) | 83 features, 5-of-59 languages covered | 74-dim SPECIFIC_FILE_INFERENCE_MODEL |
Same truncation, smaller magnitude; most languages get no local archetype at all |
| Repo (#1159) | 22-dim vocabulary keyed by file-archetype name strings | Same 22 dims, but 3-of-4 static-archetype name strings no longer match STATIC_ARCHETYPES |
Config/vendor/unknown-heavy repos always contribute zero on those slots |
None of this crashes or leaves a column empty -- every archetype/cluster field gets a
confidently-produced value on every scan. That's what made it invisible: #1149's investigation
into ecosystem_baseline's propagation bug is what surfaced the repo-level string mismatch,
which prompted checking whether the other two tiers had the same class of problem. They do.
docs/wiki/03-05-claim-5-file-archetypes.md (a shipped, published claim: "74 dimensions, 10
clusters") no longer matches the shipped file model (115 dimensions, 18 clusters) either --
independent confirmation that these models get retrained/regenerated from time to time without
the consuming code or docs being updated in lockstep.
Sub-issues
- Function-level K-Means archetype classification only compares 5 of the trained model's 62 dimensions #1157 -- Function-level: live vector only 5 of 62 trained dimensions
- File-level K-Means archetype classification silently truncates against its own trained models (115-dim global vs. 83-dim live vector) #1158 -- File-level: global 83-of-115, per-language 83-of-74 + 5-of-59 language coverage, stale published claim
- Repo-level ecosystem_baseline clustering's feature vocabulary is stale -- 3 of 4 static-file archetype slots never populated #1159 -- Repo-level: static-archetype feature vocabulary stale (3 of 4 slots always zero)
Why this order
No hard dependency between the three -- they share a root cause (models frozen at training time,
no drift guard, no regeneration tooling) but are otherwise independent code paths. Suggest
function-level first (smallest, most self-contained fix + guard pattern to copy), then file-level
(same guard pattern, larger surface, touches a published doc claim), then repo-level (different
root cause shape -- string vocabulary, not raw dimensionality -- and depends on file-level's
archetype-naming output being settled first, since the repo model's features are keyed off file
archetype names).
Process
Each sub-issue needs its own PR per this repo's convention. None of these touch parsing logic
(detector.py/language_standards.py/prism.py), so the Differential Scan / crucible_check.py
protocol doesn't apply -- but each fix should add the "live vector length != model
dimensionality" guard as a real test, not just a manual eyeball check, so this specific bug class
can't silently reappear the next time SIGNAL_SCHEMA changes.
Retraining the actual centroid/scaler models (as opposed to fixing the code paths and guards
around them) needs an offline corpus + training pipeline this repo doesn't currently have checked
in -- each sub-issue calls out where a code-only fix is possible vs. where real retraining is
required, so scope doesn't quietly balloon into "also build the missing training pipeline."
Activity
squid-protocol commentedon Sep 16, 2026
Status check against the last two days of merged work (#3016, #3021, #3023, #3026, #3029, #3061 — the "archetype tower" PRs, all merged 2026-09-14/15):
file_archetypecoverage went from ~5% to ~97%). Still outstanding: the per-languageSPECIFIC_FILE_INFERENCE_MODEL/local_archetypepath is explicitly deferred (untouched, stillNone), and the "74 dimensions / 10 clusters" claim indocs/wiki/03-05-claim-5-file-archetypes.mdis still stale against the now-83-feature model.main—GENERAL_REPO_INFERENCE_MODEL's feature-name mismatches againstSTATIC_ARCHETYPESand the missingcluster_namesare all exactly as originally reported. The newrepo_composition_archetypefeature (Classify file + repo composition archetypes at scan time #3023/Persist file/repo composition archetypes to the DB + add fit z-scores #3026) is a parallel, additive population-relative lens — it doesn't touch or fix theecosystem_baseline/repo_macro_speciespath this issue is about.Detailed per-issue assessments posted on #1157, #1158, and #1159. Leaving this epic open until #1158's remaining scope (local model + doc) and #1159 land.
squid-protocol commentedon Sep 16, 2026
Update: #1158 closed. The global file-archetype model fix (#3061) is done; the remaining per-language local model was split off into its own blocked issue (#3085) since it needs a broader per-language corpus we don't have yet. The stale claim-5 doc numbers are fixed in #3086.
Only #1159 (repo-level) remains open with no work started — see the assessment above.