Skip to content

oci: extract artifact-agnostic primitives into oci/artifact (Phase 0, THV-0077)#133

Merged
jhrozek merged 2 commits into
mainfrom
feat/oci-artifact-shared-primitives
Jun 18, 2026
Merged

oci: extract artifact-agnostic primitives into oci/artifact (Phase 0, THV-0077)#133
jhrozek merged 2 commits into
mainfrom
feat/oci-artifact-shared-primitives

Conversation

@JAORMX

@JAORMX JAORMX commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Phase 0 of plugin support (RFC THV-0077)

Extracts the artifact-agnostic OCI primitives out of oci/skills into a new oci/artifact package so the upcoming oci/plugins package can reuse them. Behavior-preserving refactor — no logic changes.

What moved to oci/artifact

  • tarCreateTar/ExtractTar/ExtractTarWithLimit, FileEntry, TarOptions/DefaultTarOptions, MaxTarFileSize, path-traversal/symlink rejection
  • gzipCompress/Decompress/DecompressWithLimit, CompressTar/DecompressTar, GzipOptions/DefaultGzipOptions, MaxDecompressedSize (decompression-bomb guard)
  • platformPlatformString/ParsePlatform/DefaultPlatforms + OS/Arch consts
  • pull-hardening — promoted to exported ValidatingTarget/NewValidatingTarget (+ manifest/blob size caps and manifest-count limits, digest verification)

Backward compatibility

oci/skills re-exports every moved symbol via type aliases (type X = artifact.X), var-forwarding for funcs, and const re-declaration (oci/skills/artifact_aliases.go). The public surface of oci/skills is unchanged — no exported signature changed, and downstream consumers (toolhive) are unaffected. The skills determinism tests still assert byte-stable artifact digests, proving published skill digests don't change.

Notes

  • Skill-specific code (media types, labels, SkillConfig, Packager, Registry, Store) stays in oci/skills.
  • New package is Alpha (per CLAUDE.md stability tracks).
  • This phase precedes GATE-C1 (tag toolhive-core + bump toolhive's go.mod), which is tracked in the epic.

Closes #130
Part of stacklok/toolhive#5525
RFC: stacklok/toolhive-rfcs#77

🤖 Generated with Claude Code

Phase 0 of plugin support (THV-0077). Move the artifact-agnostic OCI
primitives out of oci/skills into a new oci/artifact package so a future
oci/plugins can reuse them:

- tar (CreateTar/ExtractTar*/FileEntry/TarOptions, MaxTarFileSize)
- gzip (Compress/Decompress*/CompressTar/DecompressTar, MaxDecompressedSize)
- platform helpers (PlatformString/ParsePlatform/DefaultPlatforms, OS/Arch)
- pull-hardening, exported as ValidatingTarget/NewValidatingTarget plus the
  manifest/blob size caps and manifest-count limits

oci/skills re-exports every moved symbol via type aliases, var-forwarding,
and const re-declaration (oci/skills/artifact_aliases.go), so the package's
public surface is unchanged and downstream consumers (toolhive) are
unaffected — no exported signature changed. Behavior-preserving move:
function bodies are identical and the oci/skills determinism tests still
assert byte-stable artifact digests.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@jhrozek jhrozek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Batched review from /review-iterate on the oci/artifact extraction. These are non-blocking (the refactor itself is sound — build/vet/test/lint/license all pass and the security posture is preserved). Findings cluster on the back-compat alias layer for an Alpha package, plus two pre-existing path-handling issues carried over by the tar.go rename. Test-coverage gaps from the review were noted but not commented inline.

Comment thread oci/skills/artifact_aliases.go
Comment thread oci/skills/artifact_aliases_test.go Outdated
Comment thread oci/artifact/validate.go
Comment thread oci/artifact/tar.go

@jhrozek jhrozek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All 5 commented findings addressed. LGTM.

@jhrozek jhrozek merged commit ddbfe47 into main Jun 18, 2026
5 checks passed
@jhrozek jhrozek deleted the feat/oci-artifact-shared-primitives branch June 18, 2026 10:20
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.

[plugins] Phase 0: extract artifact-agnostic OCI primitives (THV-0077)

2 participants