Skip to content

Add OCI annotations to layer descriptors for GGUF and SafeTensors#66

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/extend-oci-artifacts-annotations
Draft

Add OCI annotations to layer descriptors for GGUF and SafeTensors#66
Copilot wants to merge 3 commits intomainfrom
copilot/extend-oci-artifacts-annotations

Conversation

Copy link

Copilot AI commented Nov 12, 2025

Implements OCI-compliant layer annotations per CNCF model specification to enable metadata discoverability in model artifacts.

Implementation

Constants and types (pkg/distribution/types/config.go)

  • Added annotation keys: org.cncf.model.filepath, org.cncf.model.file.metadata+json, org.cncf.model.file.mediatype.untested
  • Added FileMetadata struct with Name, Mode, Uid, Gid, Size, ModTime, Typeflag fields

Layer creation (pkg/distribution/internal/partial/layer.go)

  • NewLayer now extracts file metadata from os.FileInfo and serializes to JSON
  • Populates descriptor annotations for all layer types (GGUF, SafeTensors, License, MMProj, ChatTemplate)

Manifest generation (pkg/distribution/internal/partial/partial.go)

  • ManifestForLayers preserves annotations from custom Layer type instead of reconstructing descriptors

Example

Layers in manifests now include:

{
  "mediaType": "application/vnd.docker.ai.gguf.v3",
  "digest": "sha256:...",
  "size": 1024,
  "annotations": {
    "org.cncf.model.filepath": "/path/to/model.gguf",
    "org.cncf.model.file.metadata+json": "{\"name\":\"model.gguf\",\"mode\":420,\"uid\":0,\"gid\":0,\"size\":1024,\"mtime\":\"2024-01-01T00:00:00Z\",\"typeflag\":0}",
    "org.cncf.model.file.mediatype.untested": "false"
  }
}

Testing

Added test cases validating annotation presence, format, and JSON deserialization for both single-file and sharded models.

Original prompt

This section details on the original issue you should resolve

<issue_title>Extend OCI artifacts to have the below documented annotations for both gguf and safetensors</issue_title>
<issue_description># Annotations

This property contains arbitrary metadata, and SHOULD follow the rules of OCI image annotations.

Pre-defined Annotation Keys

Layer Annotation Keys

  • org.cncf.model.filepath: Specifies the file path of the layer (string).

  • org.cncf.model.file.metadata+json: Specifies the metadata of the file (string), value is the JSON string of File Metadata Annotation Value.

  • org.cncf.model.file.mediatype.untested: Indicates whether the media type classification of files in the layer is untested (string). Valid values are "true" or "false". When set to "true", it signals that the model packager has not verified the media type classification and the type is inferred or assumed based on some heuristics.

Layer Annotation Values

File Metadata Annotation Value

// FileMetadata represents the metadata of file, which is the value definition of AnnotationFileMetadata.
type FileMetadata struct {
	// File name
	Name string `json:"name"`

	// File permission mode (e.g., Unix permission bits)
	Mode uint32 `json:"mode"`

	// User ID (identifier of the file owner)
	Uid uint32 `json:"uid"`

	// Group ID (identifier of the file's group)
	Gid uint32 `json:"gid"`

	// File size (in bytes)
	Size int64 `json:"size"`

	// File last modification time
	ModTime time.Time `json:"mtime"`

	// File type flag (e.g., regular file, directory, etc.)
	Typeflag byte `json:"typeflag"`
}
```</issue_description>

## Comments on the Issue (you are @copilot in this section)

<comments>
</comments>

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits November 12, 2025 17:31
- Add annotation constants (filepath, metadata, mediatype.untested) to types package
- Add FileMetadata struct following OCI spec
- Update partial.NewLayer to populate layer annotations with file metadata
- Update ManifestForLayers to preserve annotations from our Layer type
- Add comprehensive tests for annotation presence and validity
- All layer types (GGUF, SafeTensors, License, MMProj, ChatTemplate) now include annotations

Co-authored-by: ericcurtin <1694275+ericcurtin@users.noreply.github.com>
Run gofmt to align map values properly

Co-authored-by: ericcurtin <1694275+ericcurtin@users.noreply.github.com>
Copilot AI changed the title [WIP] Extend OCI artifacts to include new annotations Add OCI annotations to layer descriptors for GGUF and SafeTensors Nov 12, 2025
Copilot AI requested a review from ericcurtin November 12, 2025 17:40
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.

Extend OCI artifacts to have the below documented annotations for both gguf and safetensors

2 participants