Skip to content

Bake archetype-brain provenance + feature-contract sha at freeze (#3124, #3125) - #12

Merged
squid-protocol merged 1 commit into
mainfrom
feat/brain-provenance-parity-3124-3125
Sep 17, 2026
Merged

squid-protocol merged 1 commit into
mainfrom
feat/brain-provenance-parity-3124-3125

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Producer side of the archetype provenance + parity work. Companion engine PR in squid-protocol/gitgalaxy consumes these.

What changed

  • freeze_archetype_brains.py now stamps a provenance block onto both composition brains at freeze time: corpus name + content sha256, trainer commit, engine_commit (from GITGALAXY_ENGINE_COMMIT/GITGALAXY_ENGINE_ROOT), trained-at, record count, language mix, k, the ordered feature_contract, and a feature_contract_sha over that contract.
  • The sha uses a canonicalization (json.dumps(sort_keys=True, separators=(",",":")), list order preserved) that is byte-identical to the engine's gitgalaxy/metrics/archetype_parity.py, so the engine recomputes it at load and detects trainer/engine drift. Verified: both sides independently produce 92c0b8a8… (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 authentic feature_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

  • Backfill diff is pure additions (106 insertions, 0 deletions); centroids/z_score_params/aux_quantiles byte-identical to what shipped.
  • freeze_archetype_brains.py runs 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

…, #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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant