Skip to content

feat: core variant model, index schema, and selection algorithm - #2

Merged
achimnol merged 1 commit into
topic/plan-docsfrom
topic/core-variant
Aug 9, 2026
Merged

feat: core variant model, index schema, and selection algorithm#2
achimnol merged 1 commit into
topic/plan-docsfrom
topic/core-variant

Conversation

@achimnol

Copy link
Copy Markdown
Member

Summary

Stacked PR 2/7 (base: #1). Implements the pure core library pkg/variant per DESIGN.md:

  • Model & validation: variant labels (^[0-9a-z._]{1,16}$, variants reserved), properties (namespace :: feature :: values, values allow dots for versions like 12.8), image config label parsing (dev.pep817.variant.*).
  • Index document (schema-version 1): JSON (un)marshaling with validation, Upsert, tag helpers (IndexTag, VariantTag, BaseVersion, MatchVariantTag).
  • Selection algorithm (DESIGN.md §4, ported from PEP 817): compatibility filter (intersection semantics incl. multi-value), per-property (namespace, feature, value) rank keys with three tiers — index default-priorities > system preference order > lexicographic — and variant ordering where more matched properties win on equal prefixes; null variant naturally sorts last among compatible variants.
  • Scaffold: Go module, Makefile, .gitignore, CI (gofmt/vet/test).

No third-party dependencies; the package is I/O-free by design so the CLI plugin, the registry proxy, and any future moby/containerd integration share it.

Tests

26 test functions/table cases across labels, index round-trip + wire-shape assertions, and ordering scenarios (CUDA preference, index-priority override, namespace priority + lexicographic fallback, multi-value best-match, more-properties-wins, deterministic tie-break, fallback-to-empty). go test ./... and go vet ./... pass.

https://claude.ai/code/session_01D383U8kkQkJc1yzyC5H5Nk

pkg/variant is pure (no registry/engine I/O): variant label and property
validation, image-label parsing, the variant index document
(schema-version 1), and the PEP 817-ported selection algorithm
(compatibility filter + namespace/feature/value priority ordering with
system-preference and lexicographic fallbacks).

One deviation from DESIGN.md as first written: property *values* accept
dots (^[a-z0-9_.]+$) since version-like values ("12.8") are the primary
use case; namespaces and features stay ^[a-z0-9_]+$. DESIGN.md is
amended in the base branch.

Also adds the Go module, Makefile, .gitignore, and a CI workflow
(gofmt check, vet, unit tests).

Claude-Session: https://claude.ai/code/session_01D383U8kkQkJc1yzyC5H5Nk
@achimnol
achimnol merged commit bfddfe6 into main Aug 9, 2026
1 check passed
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