Repository navigation
feat(archetypes): graded per-level validation + drift harness (#4100) - #4105
Merged
Merged
Conversation
The archetype brains are retrained offline far less often than the engine
changes, so labels are allowed to drift ahead of a retrain -- but no longer
unseen. Each level of the function -> file -> composition-file ->
composition-repo tower now carries a trust state (VALIDATED / DRIFTING /
UNVALIDATED / DEGRADED / INVALID):
- archetype_parity: live structural checks incl. cross-level label-vocabulary
parity (which the per-brain gate could not see), brain fingerprints, and
validation_status() combining them with the shipped record.
- archetype_brains/archetype_validation.json: trained-at engine/corpus,
per-level agreement with the trained state, eroding archetypes, open
retrain issue, history. Agreement is stability, not accuracy.
- INVALID levels are withheld ("Unvalidated"); withholding depends only on
the brains, never on the auto-refreshed record.
- tests/tools/archetype_drift.py + tests/archetype_trained_baseline.json
(crucible labels at the #3196 trained-against engine, 44ffeb1).
- Golden Crucible job: one shared scan feeds the golden diff and a
report-only drift summary. archetype-validation.yml re-measures on main,
opens a record PR for review when a number moves, and opens/updates/closes
one archetype-retrain issue.
- LLM brief section 0 + audit forensic trail report the state (the audit
block is sanitized from golden diffs like a timestamp).
Found and now flagged: the composition brain reads pre-#3196 function labels
(DEGRADED), and the repo brain's inputs share no label with the composition
brain (INVALID -> repo composition archetype withheld).
Golden masters re-blessed: 8 diffs per mode, all the withheld repo
composition archetype (Hub-Coupled Monorepo -> Unvalidated, z 5.592 -> 0.0).
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Contributor
This was referenced Oct 2, 2026
…atenation alerts Hoist render_issue's multi-line strings to named constants and build structural problems via _problem(), so no list/tuple element relies on implicit string concatenation. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #4100.
Why
The archetype brains are retrained offline (gitgalaxy-population-analyses) much less often than the engine changes, so labels are allowed to drift ahead of a retrain. Until now that drift was invisible. The golden master does diff archetype labels, but as an exact match that gets re-blessed wholesale: no tolerance, a baseline that moves on every bless, and archetype diffs buried among X/Y/Z noise behind a 50-line cap. Since the #3196 retrain, 85 re-blesses have accumulated 0.7% / 2.2% / 1.4% cumulative relabelling at the file, composition and function levels, and the crucible's repo archetype flipped. No PR ever showed that as a number.
The golden master had also blessed three structural breaks that the per-brain parity gate (#3125) cannot see, because it checks each brain in isolation:
Annotated & Test Methods,Stateful Encapsulated Methods), but the composition brain still readsAnnotated Framework Methods/Tests & Verification. Two input columns are always 0, and ~7% of crucible functions drop out of file composition.comp_archetypesare the k=18file_cluster_Nlabels, whileclassify_repocounts composition labels. Every repo's composition sub-vector is all zeros.file_cluster_Nlabels. This is recorded as a note, not a downgrade.What this adds
Per-level trust state (
archetype_parity.validation_status). Each level of the function → file → composition-file → composition-repo stack gets a state:Unvalidated"Agreement" is the share of crucible code files the current engine labels the same way the engine the brains were trained against did. It measures stability, not accuracy: there is no ground-truth archetype.
archetype_brains/archetype_validation.json, shipped with the package. It holds the trained-at engine, commit and corpus, brain fingerprints, thresholds, per-level agreement and eroding archetypes, the open retrain issue, and a capped history.tests/archetype_trained_baseline.json, the crucible labels at the trained-against engine (44ffeb1e, v2.9.1, the feat(archetypes): retrain function/file/repo brains on the v2.9.0 corpus #3196 golden master). It moves only onrebaselineafter a retrain.tests/tools/archetype_drift.py(measure,issue-body,set-issue,rebaseline).test_golden_crucible.pynow shares one scan between the golden diff and a newtest_archetype_drift_report, which writes "this PR vs recorded on main" to the job summary. It never fails on drift, only when the harness itself can't measure.archetype-validation.yml. After each push to main it re-measures, opens a PR refreshing the record only when a number moved (≥ 0.25 pp or a state change), and opens, updates or closes onearchetype-retrainissue. The record PR is not auto-merged; it is left for review.golden_diff.sanitize, like timestamps).State today
Golden master
Re-blessed against language-crucible v1.6.0. Each fixture has exactly 8 differences, all from the withheld repo composition archetype:
Hub-Coupled Monorepo→Unvalidatedand fit z 5.592 → 0.0, inRepository Composition Archetype,summary.repo_composition_*,repo_macro_speciesandRepository Ecosystem Baseline (Architecture). No file, function or composition label moved. The new forensic-trail "Archetype Validation" block is sanitized like a timestamp, so the fixtures don't store it and an automated record refresh can't make them stale.Tests
tests/core_engine/test_archetype_validation.py: 26 tests covering states, propagation, withholding, record ↔ brain fingerprints, and the harness math.test_archetype_parity.py: an uncomputable aux feature now yields the explicitUnvalidatedlabel, with the same named warning.Follow-up
The three structural breaks need a refreeze in gitgalaxy-population-analyses. Once this merges, the first
archetype-validation.ymlrun on main opens the retrain issue that tracks them. The per-languageSPECIFIC_FILE_INFERENCE_MODEL(per-file "File Archetype",N/Afor 100% of files) is never applied and is out of this harness's scope; tracked separately.🤖 Generated with Claude Code