Skip to content

feat: add layer annotations for oras CLI compatibility - #25

Merged
pavelanni merged 6 commits into
mainfrom
fix/oras-layer-annotations
Apr 14, 2026
Merged

pavelanni merged 6 commits into
mainfrom
fix/oras-layer-annotations

Conversation

@pavelanni

@pavelanni pavelanni commented Apr 14, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Add org.opencontainers.image.title annotations to layer descriptors
so that oras pull extracts them as named files instead of skipping.

Before:

$ oras pull quay.io/docsclaw/skill-resume-screener:1.0.0
Skipped pulling layers without file name in "org.opencontainers.image.title"

After:

$ oras pull quay.io/docsclaw/skill-resume-screener:1.0.0
✓ Pulled  skill.yaml
✓ Pulled  resume-screener.tar.gz

6 lines changed in internal/oci/pack.go. Only affects artifact mode
(not --as-image).

Fixes #23

Test plan

  • make test — all passing
  • make lint — zero errors
  • Verified layer annotations in packed manifest
  • Push to quay.io and verify with oras pull

🤖 Generated with Claude Code

Summary by CodeRabbit

Documentation

  • Added Architecture Decision Record documenting dual OCI format support for skill distribution (artifact and image modes).
  • Updated OCI skills guide with examples for both distribution formats and pulling methods.
  • Enhanced deployment guidance with container security hardening recommendations for OpenShift.

Tests

  • Added test coverage for artifact and image mode operations.

Add org.opencontainers.image.title annotations to layer descriptors
so that 'oras pull' can extract them as named files (skill.yaml and
<name>.tar.gz) instead of skipping layers without file names.

Fixes #23

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Pavel Anni <[email protected]>
@coderabbitai

coderabbitai Bot commented Apr 14, 2026 •

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: caced4dc-505d-4ac9-9c2a-20990e578ec2

📥 Commits

Reviewing files that changed from the base of the PR and between 16cfdcd and 76e604d.

📒 Files selected for processing (7)
  • docs/adr/0001-oci-skill-dual-format.md
  • docs/oci-skills-guide.md
  • internal/oci/inspect.go
  • internal/oci/media.go
  • internal/oci/pack.go
  • internal/oci/pull.go
  • internal/oci/push_pull_test.go

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to data retention organization setting


📝 Walkthrough

Walkthrough

The PR implements dual OCI format support for skill distribution. Artifact mode (default) pushes each skill file as a separate OCI layer with title annotations for oras pull compatibility, while image mode packs the skill directory into a single tar+gzip layer for Kubernetes mounting. Pull operations automatically detect the format and extract accordingly.

Changes

Cohort / File(s) Summary
Documentation
docs/adr/0001-oci-skill-dual-format.md, docs/oci-skills-guide.md
New ADR defining dual OCI format approach with artifact and image modes. Updated deployment and usage guides to describe both formats, CLI workflows, OpenShift integration with kubelet image volume mounting, and security hardening with securityContext.
Pack & Inspect Operations
internal/oci/pack.go, internal/oci/inspect.go
Pack refactored to push per-file layers (artifact mode) with title annotations instead of two fixed layers; includes new pushFileLayers helper. Inspect adds annotation-based skill card extraction fallback when no card media type layer is found.
Pull Operation
internal/oci/pull.go
Pull now derives skill name from manifest annotations and supports dual-mode extraction: tarball-based (image mode) or file-per-layer (artifact mode) with path traversal validation.
Constants & Tests
internal/oci/media.go, internal/oci/push_pull_test.go
Added FileMediaType constant for per-file layers. New tests validate artifact mode layer annotations, file extraction for both modes, and manifest structure compliance.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Pack as Pack Operation
    participant Registry as OCI Registry
    participant Manifest as Manifest/Layers

    Client->>Pack: Push skill (AsImage=false)
    Pack->>Pack: Walk skill directory
    Pack->>Pack: pushFileLayers: read each file
    Pack->>Registry: Push each file as blob (FileMediaType)
    Pack->>Pack: Annotate each layer (AnnotationTitle=filepath)
    Pack->>Registry: Push config blob
    Pack->>Manifest: Create manifest with annotated layers
    Pack->>Registry: Store manifest
    Pack-->>Client: Success
Loading
sequenceDiagram
    participant Client
    participant Pull as Pull Operation
    participant Registry as OCI Registry
    participant Manifest as Manifest Inspection
    participant Filesystem as Filesystem

    Client->>Pull: Pull skill
    Pull->>Registry: Fetch manifest
    Pull->>Manifest: Check for tarball layer (ContentMediaType)
    alt Tarball Layer Found
        Manifest-->>Pull: Image mode detected
        Pull->>Registry: Fetch tar+gzip layer
        Pull->>Filesystem: Extract tarball to extractDir
    else No Tarball Layer
        Manifest-->>Pull: Artifact mode detected
        Pull->>Manifest: Iterate layers with AnnotationTitle
        loop Per-file extraction
            Pull->>Pull: Validate title (no path traversal)
            Pull->>Registry: Fetch file layer
            Pull->>Filesystem: Write file to extractDir
        end
    end
    Pull-->>Client: Extraction complete
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/oras-layer-annotations

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Suppresses the "Skipped pulling layers without file name" warning
from oras pull by adding org.opencontainers.image.title to the
config descriptor in artifact mode.

Fixes #23

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Pavel Anni <[email protected]>
Root artifact-mode tarballs at "." instead of "<skill-name>/" so
that 'oras pull -o <name>' extracts files directly without double
nesting. Pull now creates a skill-name subdirectory from the
SkillCard metadata, preserving multi-skill coexistence.

Rename tarball title from <name>.tar.gz to content.tar.gz since
the tarball no longer carries the skill name internally.

Add config.json title annotation to suppress oras pull warning
about layers without file names.

Workflow for users without docsclaw:
  oras pull -o resume-screener quay.io/.../skill-resume-screener:1.0.0
  cd resume-screener && tar xzf content.tar.gz

Fixes #23

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Pavel Anni <[email protected]>
Artifact mode (default) now pushes each file as a separate OCI
layer with a title annotation. This enables 'oras pull' to extract
files directly as named files — no tarball extraction needed.

Image mode (--as-image) is unchanged: single tar+gzip layer for
kubelet-mountable images on OpenShift 4.20+.

Pull and Inspect detect the format automatically by inspecting
layer media types and annotations. Both formats produce the same
result on disk.

Add ADR-0001 documenting the dual format decision and trade-offs.

Fixes #23

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Pavel Anni <[email protected]>
Restructure the guide around the two OCI formats:
- Artifact (default): individual file layers for oras pull
- Image (--as-image): single tarball for K8s image volumes

Add comparison table, publishing workflow showing both pushes,
oras pull example, and notes about which format to use where.
Include securityContext in all example manifests. Reference
ADR-0001 for design rationale.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Pavel Anni <[email protected]>
Security:
- Add path traversal protection for file-per-layer pull (reject
  titles containing ".." or absolute paths, verify resolved path
  stays inside destination)
- Skip dot-prefixed directories (.git, etc) in pushFileLayers

Tests:
- TestArtifactModeLayerAnnotations: verify layers have title
  annotations and correct media type
- TestArtifactModePullExtractsFiles: verify round-trip produces
  correct files with expected content
- TestImageModePushAndPull: verify image-mode round-trip works

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Pavel Anni <[email protected]>
@pavelanni
pavelanni marked this pull request as ready for review April 14, 2026 20:32
@pavelanni
pavelanni merged commit 602ac9a into main Apr 14, 2026
1 check passed
@pavelanni
pavelanni deleted the fix/oras-layer-annotations branch April 14, 2026 20:33
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.

feat: add layer annotations for oras CLI compatibility

1 participant