Skip to content

fix(intrinsics): pin catalogue entries to HF revision SHAs + deduplicate requirement_check entries (Epic #929 Phase 0) #1135

@planetf1

Description

@planetf1

Parent epic: #929
Design proposal: PR #1080
Phase: 0 (Wave 1 — file immediately, independent of 0.1)
Blocks: 2.2 (revision-aware prepare())

⚠️ Pre-flight dependency: PR #1078 must be merged before starting this issue. PR #1078 adds canned I/O test data for requirement-check and uncertainty formatters that this issue's tests build on. Revision-pinning (here) supersedes the last_validated_commit approach in #1078; close #1029 when #1078 merges.


Problem

mellea/backends/adapters/catalog.py does not record which revision of an upstream HF repository Mellea expects. When upstream pushes new weights, every Mellea install silently picks them up.

PR #1008 is the worked example: requirement-check output changed schema upstream; requirement_check_to_bool returned False for every call until someone noticed.

Current state (verified main 2026-05-21): IntriniscsCatalogEntry has fields name, internal_name, repo_id, adapter_types — no revision. 14 entries across _RAG_REPO, _CORE_REPO, _CORE_R1_REPO, _GUARDIAN_REPO. Note: typo IntriniscsCatalogEntry (missing 'i') is intentional convention — do not fix it in this issue.

Additionally, the catalogue has two entries for the same adapter: requirement_check (underscore) and requirement-check (hyphen) — dead state that creates confusion.

Agreed design

Each catalogue entry gains a revision field pinned to a 40-character HF commit SHA. Mellea pins to that SHA when auto-loading. Callers may pass revision="main" to opt into tracking-latest.

Deduplication: Collapse requirement_check + requirement-check to a single canonical requirement_check entry with role="requirement-check" set on the Identity. Role-based lookup (introduced in 1.A) routes correctly regardless of key used at construction time.

This implements Jake req 5.

Scope

  • mellea/backends/adapters/catalog.py — add revision field to IntriniscsCatalogEntry; populate all 14 entries with current upstream SHA at PR time
  • Validation: revision must be 40-char lowercase hex OR literal "main"
  • Validation function lives next to the catalogue type
  • Collapse requirement_check / requirement-check duplicate to one canonical entry
  • Update any catalogue-construction examples in docs/examples/ and test/ to include the field

Out of scope

Acceptance criteria

  • All 14 catalogue entries have a revision field with a valid 40-char hex SHA
  • Revision validation rejects malformed values with a clear error
  • "main" accepted as explicit opt-in for tracking-latest
  • Tests cover: valid SHA accepted, malformed SHA rejected, "main" accepted, None handling tested explicitly (implementer chooses accept-as-main vs reject-with-error — must be tested)
  • requirement_check and requirement-check entries collapsed to one; no duplicate key
  • Existing tests pass; helpers function unchanged (new field is metadata-only at this stage)
  • ruff format, ruff check, mypy clean

Test plan

test/backends/adapters/test_catalog_revision.py:

  • test_catalog_entries_have_revision — every entry has a valid value
  • test_revision_validation_rejects_malformed — short, long, non-hex
  • test_revision_validation_accepts_main_literal
  • test_revision_round_trip — construct entry, retrieve, assert preserved
  • test_no_duplicate_requirement_check_entry

⚠️ SHA staleness: The SHA pinned at PR-write time may be stale by merge time. Reviewer should re-fetch upstream HEAD just before merging and confirm the SHA is still current.

Breaking changes

None for end users. Downstream code constructing IntriniscsCatalogEntry directly must add the new field (or handle implementer's None behaviour).

References

Metadata

Metadata

Assignees

Labels

area/intrinsicsGranite intrinsic adapters: RAG, Guardian, CoreenhancementNew feature or request

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions