Repository navigation
Bake archetype-brain provenance + feature-contract sha at freeze (#3124, #3125) - #12
Merged
Merged
Conversation
…, #3125) freeze_archetype_brains.py now stamps a `provenance` block onto both composition brains at freeze time, carrying corpus name + content sha, trainer/engine commit, trained-at, record count, language mix, k, and a `feature_contract_sha` over the ORDERED feature contract (archetype names, aux features, weights, k). The sha is computed with a byte-identical canonicalization (sort_keys + compact separators, list order preserved) to the engine's gitgalaxy/metrics/archetype_parity.py, so the engine can recompute it at load and detect trainer/engine drift -- the machine-checkable half of the parity gate #3125 asks for. engine_commit is read from GITGALAXY_ENGINE_COMMIT / GITGALAXY_ENGINE_ROOT, degrading to "unknown". The currently-shipped brains were frozen from a corpus that was since overwritten and is unreproducible (re-freezing yields materially different centroids/labels -- a retrain, out of scope). backfill_provenance.py is a one-shot that preserves the shipped centroids exactly and stamps an authentic feature_contract_sha + engine_commit onto them, honestly recording the corpus fields as "unrecorded" (the exact gap #3124 documents). It reuses the freeze helpers so the sha algorithm stays single-source. The next real freeze attaches full corpus provenance natively. Cross-repo: paired with gitgalaxy PR (archetype_parity module + parity CI test + brief surfacing + the same backfilled brains). gitgalaxy CI is self-contained (it validates the committed brains); this repo is not on any CI path, so merge order is flexible -- this repo carries the reproducible tooling. Co-Authored-By: Claude Opus 4.8 <[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.
Producer side of the archetype provenance + parity work. Companion engine PR in
squid-protocol/gitgalaxyconsumes these.What changed
freeze_archetype_brains.pynow stamps aprovenanceblock onto both composition brains at freeze time: corpus name + content sha256, trainer commit,engine_commit(fromGITGALAXY_ENGINE_COMMIT/GITGALAXY_ENGINE_ROOT), trained-at, record count, language mix,k, the orderedfeature_contract, and afeature_contract_shaover that contract.json.dumps(sort_keys=True, separators=(",",":")), list order preserved) that is byte-identical to the engine'sgitgalaxy/metrics/archetype_parity.py, so the engine recomputes it at load and detects trainer/engine drift. Verified: both sides independently produce92c0b8a8…(file) /5858e2d9…(repo).backfill_provenance.py(new, one-shot): the currently-shipped brains were frozen from a corpus that was since overwritten and is unreproducible — re-freezing yields materially different centroids/labels (a retrain, out of scope). This script preserves the shipped centroids exactly and stamps an authenticfeature_contract_sha+engine_commit, honestly recording corpus fields as"unrecorded"(the exact gap #3124 documents). It reuses the freeze helpers so the sha algorithm stays single-source. The next real freeze attaches full corpus provenance natively.Verification
centroids/z_score_params/aux_quantilesbyte-identical to what shipped.freeze_archetype_brains.pyruns clean (file: 385,158 files, repo: 160 repos, both 100% self-consistency).Cross-repo
Paired with squid-protocol/gitgalaxy PR (archetype_parity module + parity CI test + brief surfacing + the same backfilled brains). The gitgalaxy CI is self-contained (it validates the committed brains); this repo is not on any CI path, so merge order is flexible — this repo carries the reproducible tooling.
🤖 Generated with Claude Code