Skip to content

Migrate mediatypes.go custom OCI types to ocispec #24

Description

@JAORMX

Description

Replace the custom OCI struct types in oci/skills/mediatypes.go with canonical types from github.com/opencontainers/image-spec/specs-go/v1. The packager (PR #23) already uses ocispec types internally, creating a dual type system where the store and helper functions use custom types while the packager uses spec types.

Context

The OCI expert review of the packager flagged this as the primary concern (C1): configs produced by the packager using ocispec.Image cannot be directly consumed by SkillConfigFromImageConfig(*ImageConfig) without JSON re-serialization. The Go expert review also flagged the redundant media type constants as a maintenance hazard.

Acceptance Criteria

  • Remove custom ImageConfig, ImageConfigData, RootFS, HistoryEntry types — use ocispec.Image, ocispec.ImageConfig, ocispec.RootFS, ocispec.History
  • Remove custom ImageIndex, IndexDescriptor types — use ocispec.Index, ocispec.Descriptor
  • Remove custom Platform type — use ocispec.Platform (which includes Variant, OSVersion, OSFeatures)
  • Update ParsePlatform() to return ocispec.Platform
  • Add PlatformString(p ocispec.Platform) string free function (can't add methods to external types)
  • Update DefaultPlatforms to []ocispec.Platform
  • Update SkillConfigFromImageConfig to accept *ocispec.Image
  • Update Store.GetIndex to return *ocispec.Index
  • Update Store.IsIndex to use ocispec.MediaTypeImageIndex
  • Remove redundant media type constants (MediaTypeImageIndex, MediaTypeImageManifest, MediaTypeImageConfig, MediaTypeImageLayer) — consumers should use ocispec.* directly
  • Remove redundant AnnotationCreated — use ocispec.AnnotationCreated
  • Keep custom constants: ArtifactTypeSkill, AnnotationSkill*, LabelSkill*
  • Keep SkillConfig (domain-specific, not an OCI type)
  • Update PackageOptions.Platforms and PackageResult.Platforms in interfaces.go to use ocispec.Platform
  • Regenerate mocks after interface changes (task gen)
  • Update all tests for the new types
  • All lint + tests pass

Technical Notes

  • ocispec.Platform has Variant string field — enables proper arm64/v8 support in the future
  • ocispec.Image.Created is *time.Time (not string) — stronger typing
  • ocispec.RootFS.DiffIDs is []digest.Digest (not []string) — type-safe digests
  • ocispec.Descriptor.Digest is digest.Digest (not string)
  • ocispec.History.Created is *time.Time with proper JSON marshaling
  • The image-spec dependency is already in go.mod

Estimated Scope

~300 lines changed across mediatypes.go, mediatypes_test.go, store.go, store_test.go, interfaces.go, mocks/mock_interfaces.go

Metadata

Metadata

Assignees

Labels

skillsSkills lifecycle managementtoolhive-platformToolHive Platform team

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions