feat: core variant model, index schema, and selection algorithm - #2
Merged
Conversation
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
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.
Summary
Stacked PR 2/7 (base: #1). Implements the pure core library
pkg/variantper DESIGN.md:^[0-9a-z._]{1,16}$,variantsreserved), properties (namespace :: feature :: values, values allow dots for versions like12.8), image config label parsing (dev.pep817.variant.*).Upsert, tag helpers (IndexTag,VariantTag,BaseVersion,MatchVariantTag).(namespace, feature, value)rank keys with three tiers — indexdefault-priorities> system preference order > lexicographic — and variant ordering where more matched properties win on equal prefixes; null variant naturally sorts last among compatible variants..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 ./...andgo vet ./...pass.https://claude.ai/code/session_01D383U8kkQkJc1yzyC5H5Nk