sori

package module
v0.7.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 31, 2026 License: Apache-2.0 Imports: 29 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

sori

v0.7.0-stable — OCI 기반 참조 데이터(볼륨) 패키징 및 referrer push 라이브러리.
디렉터리를 OCI 아티팩트로 변환하고, 로컬 OCI 스토어와 원격 레지스트리(Harbor 등) 사이의 push/fetch를 담당한다.

개요

sori는 바이오인포매틱스 파이프라인에서 사용하는 참조 데이터(genome, annotation 등)를
OCI 이미지 형식으로 패키징하는 Go 라이브러리다.

  • Core (stable): OCI volume packaging + push/fetch + artifact metadata + chunked CAS
  • Experimental: NodeVault-oriented referrer push (toolspec / toolprofile / security / dataspec)
문서 내용
docs/research/results-summary.md 벤치마크 결과 (v0.7.0-stable 실측값)
docs/public-api.md 공개 API 안정도 분류
docs/generalization-sprint-plan.md 범용 라이브러리화 로드맵
docs/maturity-sprint-plan.md 성숙화 계획
docs/stable-api-promotion.md stable API 승격 검토 항목
docs/followup-sprint-plan.md 후속 스프린트 계획
docs/registry-integration.md registry 통합 테스트 골격
docs/operations.md 운영 환경 체크리스트
docs/stub-status.md 과거 stub 처리 내역
docs/test-strategy.md 테스트 범주 정의 · 패턴 · 다른 프로젝트 적용 가이드

내부 하위 패키지:

  • archiveutil: deterministic tar.gz 생성과 안전한 untar
  • registryutil: remote repository/TLS/auth/http client 구성
  • catalogutil: JSON catalog load/save 공통 유틸
  • adapters/nodevault: NodeVault 친화 metadata adapter 초안

의존성

패키지 버전
oras.land/oras-go/v2 v2.6.0
github.com/opencontainers/image-spec v1.1.1
github.com/opencontainers/go-digest v1.0.0
github.com/sirupsen/logrus v1.9.3

빠른 시작

import "github.com/HeaInSeo/sori"

ctx := context.Background()

// 1) 설정 로드
cfg, err := sori.LoadConfig("sori-oci.json")
if err != nil { ... }
if err := cfg.EnsureDir(); err != nil { ... }

// 2) 컬렉션 매니저 초기화
cm, err := sori.NewCollectionManager(cfg.Local.Path)
if err != nil { ... }

// 또는 객체 기반 client 생성
client := cfg.NewClient()

// 3) 볼륨 디렉터리를 OCI로 패키징 + 컬렉션 등록
if err := cm.PublishVolumeFromDir(ctx, "./my-genome-dir", "HumanRef GRCh38", "grch38.v1.0.0"); err != nil { ... }

// 4) Stable core API: 패키징
pkg, err := sori.PackageVolumeToStore(ctx, cfg.Local.Path, sori.PackageRequest{
  SourceDir:   "./my-genome-dir",
  DisplayName: "HumanRef GRCh38",
  Tag:         "grch38.v1.0.0",
  Dataset:     "grch38",
  Version:     "v1.0.0",
})
if err != nil { ... }

// 5) Stable core API: 원격 레지스트리로 푸시
pushResult, err := sori.PushPackagedVolume(ctx, cfg.Local.Path, pkg, sori.RemoteTarget{
  Registry:   "harbor.local",
  Repository: "project/repo",
  Username:   "user",
  Password:   "pass",
  PlainHTTP:  true,
})
if err != nil { ... }
fmt.Println(pushResult.ManifestDigest)

// 6) Stable core API: generic metadata 생성
meta, err := sori.BuildArtifactMetadata(sori.ArtifactMetadataInput{
  Kind:        "dataset",
  Name:        "grch38-reference",
  Version:     "v1.0.0",
  DisplayName: "HumanRef GRCh38",
  Description: "Human reference genome",
  SourceDir:   "./my-genome-dir",
}, pkg, pushResult)
if err != nil { ... }
fmt.Println(meta.Identity.StableRef)

// 7) Experimental: NodeVault 친화 metadata 초안 생성
spec, err := sori.BuildDataSpec(pkg, pushResult, sori.PackageRequest{
  SourceDir:   "./my-genome-dir",
  DisplayName: "HumanRef GRCh38",
  Tag:         "grch38.v1.0.0",
  Dataset:     "grch38",
  Version:     "v1.0.0",
})
if err != nil { ... }

// 8) Experimental: Harbor subject manifest에 dataspec referrer push
referrerResult, err := sori.PushRemoteDataSpecReferrer(ctx, pushResult, sori.RemoteTarget{
  Registry:   "harbor.local",
  Repository: "project/repo",
  Username:   "user",
  Password:   "pass",
  PlainHTTP:  true,
}, spec)
if err != nil { ... }
fmt.Println(referrerResult.ManifestDigest)

// 9) Experimental: NodeVault/Catalog 친화적인 등록 객체 생성 및 저장
registerResp, err := sori.RegisterPackagedData(ctx, cfg.Local.Path, sori.DataRegisterRequest{
  DataName:    "grch38-reference",
  Version:     "v1.0.0",
  Description: "Human reference genome",
  Format:      "FASTA",
  SourceURI:   "s3://example/grch38.fa.gz",
}, pkg, pushResult)
if err != nil { ... }
fmt.Println(registerResp.CASHash)

// 10) Stable core API: 원격 레지스트리에서 직접 fetch (safe fetch 기본)
vi, err := client.FetchVolumeFromRemote(ctx, "./dest-dir", sori.RemoteTarget{
    Registry:   "harbor.local",
    Repository: "project/repo",
    PlainHTTP:  true,
}, "grch38.v1.0.0", sori.FetchOptions{})
if err != nil { ... }
fmt.Println(vi.DisplayName)

// AtomicOverwrite: 기존 destRoot를 백업 후 원자적 교체
vi, err = client.FetchVolumeFromRemote(ctx, "./dest-dir", sori.RemoteTarget{
    Registry:   "harbor.local",
    Repository: "project/repo",
}, "grch38.v1.1.0", sori.FetchOptions{AtomicOverwrite: true})
if err != nil { ... }

단계 4~6, 10은 stable core 흐름이고, 7~9는 experimental 계층이다.

Chunked CAS 경로 (v0.7.0-stable)

대용량 데이터셋(STAR index 40 GiB+ 등)에는 chunked CAS 포맷을 사용한다.
PackageOptions.Format을 ArtifactFormatChunkedCAS로 지정하면 파일을 1 GiB 고정 청크로 분할해 OCI 레이어로 저장한다.
fetch 측은 manifest의 Config.MediaType을 보고 자동으로 chunked 경로로 디스패치되므로 별도 설정이 필요 없다.

// Chunked CAS push
pkg, err := client.PackageVolumeWithOptions(ctx, sori.PackageRequest{
    SourceDir:   "./star-index",
    DisplayName: "STAR index GRCh38",
    Tag:         "star:v2.7.10",
}, sori.PackageOptions{
    Format: sori.ArtifactFormatChunkedCAS,
})
if err != nil { ... }

// Fetch — chunked/legacy 자동 감지
vi, err := sori.FetchVolSeq(ctx, "./dest", storePath, "star:v2.7.10")
if err != nil { ... }

// 사후 무결성 검증 (M-12)
err = chunked.Fetch(ctx, storePath, "./dest", "star:v2.7.10", chunked.FetchOptions{
    VerifyTree: true, // fetch 완료 후 destRoot 전체 sha256 재검증
})

실측 벤치마크 (Xeon E5-2683 v4, 1 GiB 청크, gate violations 없음):

fixture size push fetch peak RSS
synthetic-1GiB 1 GiB 11.9 s 9.3 s 7.9 MiB
synthetic-10GiB 10 GiB 54.8 s 41.1 s 10.4 MiB
genomics-bwa 15 GiB 75.5 s 53.8 s 10.6 MiB
genomics-star 40 GiB 194.5 s 147.7 s 10.4 MiB

RSS가 데이터 크기와 무관하게 11 MiB 이하로 유지된다 (스트리밍 청킹). 전체 결과: docs/research/results-summary.md

설정 파일 (sori-oci.json)

{
  "local": {
    "type": "oci",
    "path": "/path/to/writable/oci-store"
  },
  "remotes": [
    {
      "name": "harbor",
      "type": "registry",
      "registry": "harbor.local",
      "repository": "project/repo",
      "tls": { "insecure": false, "ca_file": "" },
      "auth": { "username": "admin", "password": "${SORI_REGISTRY_PASSWORD}", "token": "" }
    }
  ]
}

/var/lib/sori/oci (기본값)는 root 권한이 필요하다. 개발/테스트 시에는 path를 쓰기 가능한 경로로 설정할 것.

공개 API

새 코드는 Stable API로 분류된 경로를 우선 사용하고, 호환용 wrapper는 신규 사용처에서 피하는 편이 좋다.

Config
func LoadConfig(path string) (*Config, error)
func InitConfig(path string) (*Config, error)          // deprecated 호환용 로더
func (conf *Config) EnsureDir() error
func (conf *Config) NewClient(opts ...ClientOption) *Client
Client
type Client struct { ... }
type ClientOption func(*Client)

type PackageOptions struct {
    ConfigBlob        []byte
    RequireConfigBlob bool
    Format            ArtifactFormat  // 0 = ArtifactFormatLegacy (default), ArtifactFormatChunkedCAS
    DatasetMetadata   []byte          // optional; written as .sori/dataset-metadata.json on fetch
    Progress          chunked.ProgressFunc
}

type PushOptions struct { Target RemoteTarget }

type FetchOptions struct {
    Concurrency             int
    RequireEmptyDestination bool
    AtomicOverwrite         bool  // 3-phase overwrite: staging → backup → rename
}

type ReferrerOptions struct { Target RemoteTarget }

func NewClient(opts ...ClientOption) *Client
func WithLocalStorePath(path string) ClientOption
func WithHTTPClient(httpClient *http.Client) ClientOption
func WithClock(now func() time.Time) ClientOption

func (c *Client) LocalStorePath() string
func (c *Client) PackageVolume(ctx context.Context, req PackageRequest) (*PackageResult, error)
func (c *Client) PackageVolumeWithOptions(ctx context.Context, req PackageRequest, opts PackageOptions) (*PackageResult, error)
func (c *Client) PushPackagedVolume(ctx context.Context, pkg *PackageResult, target RemoteTarget) (*PushResult, error)
func (c *Client) PushPackagedVolumeWithOptions(ctx context.Context, pkg *PackageResult, opts PushOptions) (*PushResult, error)
func (c *Client) FetchVolume(ctx context.Context, destRoot, repo, tag string, opts FetchOptions) (*VolumeIndex, error)
func (c *Client) FetchVolumeFresh(ctx context.Context, destRoot, repo, tag string, concurrency int) (*VolumeIndex, error)
func (c *Client) FetchVolumeSequential(ctx context.Context, destRoot, repo, tag string) (*VolumeIndex, error)
func (c *Client) FetchVolumeParallel(ctx context.Context, destRoot, repo, tag string, concurrency int) (*VolumeIndex, error)
func (c *Client) FetchVolumeFromRemote(ctx context.Context, destRoot string, target RemoteTarget, tag string, opts FetchOptions) (*VolumeIndex, error)
func (c *Client) PublishVolume(ctx context.Context, vi *VolumeIndex, volPath, volName string, configBlob []byte) (*VolumeIndex, error)
func (c *Client) PublishVolumeFromDir(ctx context.Context, volDir, displayName, tag string) (*PackageResult, error)
VolumeIndex / 생성
func GenerateVolumeIndex(rootPath, displayName string) (*VolumeIndex, error)
func (vi *VolumeIndex) SaveToFile(rootPath string) error
func (vi *VolumeIndex) PublishVolume(ctx, volPath, volName string, configBlob []byte) (*VolumeIndex, error)

파티션 모델: GenerateVolumeIndex는 rootPath 바로 아래의 1단계 서브디렉터리만 파티션으로 등록한다. 중첩 디렉터리는 상위 파티션의 레이어에 포함된다. rootPath 바로 아래의 일반 파일(예: README.md)은 별도 root-files 레이어로 패키징되어 fetch 시 복원된다.

fetch 복원 보장: FetchVolSeq / FetchVolParallel 완료 후 configblob.json과 volume-index.json이 destRoot 하위에 원자적으로 기록된다. DisplayName과 CreatedAt은 OCI manifest annotation에서 복원된다.

PublishVolume은 각 레이어 descriptor에 "org.example.partitionPath" 어노테이션을 설정한다.
이 어노테이션이 없으면 FetchVolSeq / FetchVolParallel 시 오류가 발생하므로 직접 descriptor를 만들 때 반드시 포함해야 한다.

CollectionManager
func NewCollectionManager(rootDir string, initial ...VolumeEntry) (*CollectionManager, error)
func (m *CollectionManager) AddOrUpdate(v VolumeEntry) error
func (m *CollectionManager) Remove(ref string) (bool, error)
func (m *CollectionManager) Get(ref string) (VolumeEntry, bool)
func (m *CollectionManager) GetSnapshot() VolumeCollection
func (m *CollectionManager) Flush() error
func (m *CollectionManager) PublishVolumeFromDir(ctx, volDir, displayName, tag string) error
상위 package / dataspec API
type PackageRequest struct {
    SourceDir   string
    DisplayName string
    Tag         string
    Dataset     string
    Version     string
    StableRef   string
    Description string
    Annotations map[string]string
    ConfigBlob  []byte
}

type PackageResult struct {
    StableRef      string
    LocalTag       string
    ManifestDigest string
    ConfigDigest   string
    TotalSize      int64
    CreatedAt      string
    Partitions     []Partition
    VolumeIndex    VolumeIndex
}

type RemoteTarget struct {
    Registry    string
    Repository  string
    PlainHTTP   bool
    InsecureTLS bool
    Username    string
    Password    string
    Token       string
    CAFile      string
}

func PackageVolume(ctx context.Context, req PackageRequest) (*PackageResult, error)
func PackageVolumeToStore(ctx context.Context, localStorePath string, req PackageRequest) (*PackageResult, error)
func PushPackagedVolume(ctx context.Context, localStorePath string, pkg *PackageResult, target RemoteTarget) (*PushResult, error)
func BuildDataSpec(pkg *PackageResult, push *PushResult, req PackageRequest) (*DataSpec, error)
func PushRemoteDataSpecReferrer(ctx context.Context, push *PushResult, target RemoteTarget, spec *DataSpec) (*ReferrerPushResult, error)

이 계층은 CollectionManager 없이도 NodeVault 같은 상위 서비스가 package → push → metadata 생성 흐름을 바로 이어붙일 수 있게 하기 위한 API다.

Generic Metadata
const ArtifactMetadataSchemaVersion = "sori.artifact.v1"

type ArtifactMetadata struct { ... }
type ArtifactMetadataInput struct { ... }

func BuildArtifactMetadata(input ArtifactMetadataInput, pkg *PackageResult, push *PushResult) (*ArtifactMetadata, error)
func ArtifactMetadataToDataSpec(meta *ArtifactMetadata) *DataSpec
func ArtifactMetadataToRegisteredDataDefinition(meta *ArtifactMetadata, req DataRegisterRequest) *RegisteredDataDefinition

ArtifactMetadata는 core 계층의 중립 metadata 모델이다. DataSpec과 RegisteredDataDefinition은 이 모델을 NodeVault 친화 구조로 변환한 adapter 결과다.

Experimental: OCI Referrer Push

이미지 digest에 대한 referrer artifact를 Harbor 등의 OCI 레지스트리에 push하는 실험적 API.
NodeVault의 toolspec / toolprofile / security referrer 축을 지원한다.

Media type 상수
const (
    MediaTypeToolSpec    = "application/vnd.nodevault.toolspec.v1+json"
    MediaTypeDataSpec    = "application/vnd.nodevault.dataspec.v1+json"
    MediaTypeToolProfile = "application/vnd.nodevault.toolprofile.v1+json"
    MediaTypeSecurityScan = "application/vnd.nodevault.security.v1+json"
)
ReferrerTarget / SpecReferrerResult
type ReferrerTarget interface {
    oras.Target
}

type SpecReferrerResult struct {
    ReferrerDigest string
    SubjectDigest  string
    MediaType      string
}
Push 함수
// toolspec: 등록 시점 declared spec referrer
func PushToolSpecReferrer(ctx context.Context, target ReferrerTarget, subjectDigest string, specJSON []byte) (SpecReferrerResult, error)

// dataspec: data artifact referrer
func PushDataSpecReferrer(ctx context.Context, target ReferrerTarget, subjectDigest string, specJSON []byte) (SpecReferrerResult, error)

// toolprofile: observed dry-run profile referrer (validationHash, observedIoProfile 등)
func PushToolProfileReferrer(ctx context.Context, target ReferrerTarget, subjectDigest string, profileJSON []byte) (SpecReferrerResult, error)

// security: CVE scan result referrer (trivy-operator 연동)
func PushSecurityReferrer(ctx context.Context, target ReferrerTarget, subjectDigest string, securityJSON []byte) (SpecReferrerResult, error)
Target 생성 헬퍼
func NewReferrerLocalStore(path string) (ReferrerTarget, error)
func NewReferrerRemoteRepository(repoRef string, plainHTTP bool, credential *auth.Credential) (ReferrerTarget, error)
func MarshalSpec(v interface{}) ([]byte, error)
사용 예시
import "github.com/HeaInSeo/sori"

// 원격 Harbor에 toolspec referrer push
target, err := sori.NewReferrerRemoteRepository(
    "harbor.local/project/bwa-mem2:latest",
    true,
    &auth.Credential{Username: "user", Password: "pass"},
)
if err != nil { ... }

specJSON, _ := sori.MarshalSpec(myToolSpec)
result, err := sori.PushToolSpecReferrer(ctx, target, "sha256:IMAGE_DIGEST", specJSON)
if err != nil { ... }
fmt.Println(result.ReferrerDigest)

// toolprofile referrer push (dry-run 결과)
profileJSON, _ := sori.MarshalSpec(myProfile)
profileResult, err := sori.PushToolProfileReferrer(ctx, target, "sha256:IMAGE_DIGEST", profileJSON)

// security scan referrer push
secJSON, _ := sori.MarshalSpec(mySecuritySummary)
secResult, err := sori.PushSecurityReferrer(ctx, target, "sha256:IMAGE_DIGEST", secJSON)
검증 유틸리티
func ValidateVolumeDir(volDir string) ([]byte, error)
// - 빈 디렉터리 → 에러
// - configblob.json 없으면 빈 JSON으로 생성
// - configblob.json 있으면 로드해 반환
원격 push / fetch
type PushResult struct {
    Reference      string
    Repository     string
    Tag            string
    ManifestDigest string
}

func PushLocalToRemote(ctx, localRepoPath, tag, remoteRepo, user, pass string, plainHTTP bool) (*PushResult, error)
func FetchVolSeq(ctx, destRoot, repo, tag string) (*VolumeIndex, error)
func FetchVolParallel(ctx, destRoot, repo, tag string, concurrency int) (*VolumeIndex, error)

PushLocalToRemote, PackageVolume, VolumeIndex.PublishVolume은 호환용 low-level wrapper다.
새 코드는 Client 기반 API 사용을 권장한다.

원격 Harbor가 HTTPS와 사설 CA를 사용하는 경우 RemoteTarget.CAFile에 PEM 경로를 주면 TLS root CA에 반영된다.

Error 모델
var (
    ErrValidation error
    ErrNotFound   error
    ErrConflict   error
    ErrIntegrity  error
    ErrTransport  error
    ErrAuth       error
)

주요 public 함수는 이 에러 종류를 감싼 typed error를 반환한다. 호출자는 errors.Is(err, sori.ErrValidation) 같은 식으로 분기할 수 있다.

추가 정책:

  • PackageOptions.RequireConfigBlob=true이면 configblob.json 자동 생성을 허용하지 않고, 호출자가 config blob을 명시적으로 제공해야 한다.

Fetch 안전도 모드 (안전한 순서):

모드 설정 동작
AtomicOverwrite FetchOptions{AtomicOverwrite: true} staging 추출 → 기존 destRoot 백업 → staging rename. 갱신 워크플로에 권장.
FetchVolumeFresh Client.FetchVolumeFresh(...) RequireEmptyDestination:true 묵시적 wrapper. 최초 설치용 zero-config API.
Safe fetch FetchOptions{RequireEmptyDestination: true} destRoot가 없어야 시작. staging 추출 후 성공 시 rename.
Remote fetch Client.FetchVolumeFromRemote 기본값이 safe fetch. AtomicOverwrite opt-in 지원.
Legacy direct FetchOptions{} (기본) destRoot에 직접 추출. 중간 실패 시 부분 상태 가능. 하위 호환용만.

RequireEmptyDestination과 AtomicOverwrite를 동시에 설정하면 ErrValidation을 반환한다.

등록 / Catalog API
type DataRegisterRequest struct {
    RequestID   string
    DataName    string
    Version     string
    Description string
    Format      string
    SourceURI   string
    Checksum    string
    StorageURI  string
    StableRef   string
    Display     DisplaySpec
}

type RegisteredDataDefinition struct {
    CASHash         string
    DataName        string
    Version         string
    Description     string
    Format          string
    SourceURI       string
    Checksum        string
    StorageURI      string
    StableRef       string
    Display         DisplaySpec
    RegisteredAt    int64
    LifecyclePhase  string
    IntegrityHealth string
}

func BuildRegisteredDataDefinition(req DataRegisterRequest, pkg *PackageResult, push *PushResult) (*RegisteredDataDefinition, error)
func RegisterPackagedData(ctx context.Context, rootDir string, req DataRegisterRequest, pkg *PackageResult, push *PushResult) (*DataRegisterResponse, error)
func NewDataCatalog(rootDir string) *DataCatalog
func (c *DataCatalog) Get(casHash string) (*RegisteredDataDefinition, error)
func (c *DataCatalog) List(stableRef string) ([]RegisteredDataDefinition, error)

이 계층은 NodeKit의 DataRegisterRequest와 Catalog의 AdminDataList 사이를 잇는 최소 로컬 구현이다.
현재는 rootDir/registered-data.json에 저장한다.

tar.gz 유틸리티
func TarGzDir(fsDir, prefixPath string) ([]byte, error)   // 디렉터리 전체 결정론적 tar.gz 생성
func UntarGzDir(gzipStream io.Reader, dest string) error   // tar.gz 해제 (path traversal 방어 포함)

archiveutil.TarGzDirFiles(fsDir, prefixPath string, skipNames map[string]struct{}) — root-level 일반 파일만 tar.gz로 묶는다(서브디렉터리 제외). PublishVolume이 내부적으로 root-files 레이어 생성에 사용한다.

symlink 미지원: TarGzDir / TarGzDirFiles 는 symlink를 만나면 ErrValidation을 반환한다. 패키징 대상 디렉터리에 symlink가 포함되어 있으면 사전에 제거하거나 실제 파일로 대체해야 한다.

API 안정도

계층 포함 항목
Stable Config.NewClient, Client 기반 package/push/fetch, ArtifactFormatChunkedCAS, chunked.Publish / chunked.Fetch, FetchOptions.VerifyTree, BuildArtifactMetadata, typed error, option 모델
Compatibility InitConfig, PackageVolume, PushLocalToRemote, VolumeIndex.PublishVolume
Experimental DataSpec, referrer API (PushToolSpecReferrer / PushToolProfileReferrer / PushSecurityReferrer / PushDataSpecReferrer), registration/catalog API

자세한 목록은 docs/public-api.md를 따른다.

테스트 실행

# 단위 테스트 (외부 인프라 불필요)
go test -short ./...

# 특정 테스트만
go test -v -run "TestGenerateAndSaveVolumeIndex|TestTarGzDirDeterministic|TestExtractTarGz|TestMerge|TestLoadOrNewCollection_New|TestManager|TestValidateVolumeDir|TestLoadConfig_TempDir|TestPublishFetchRoundTrip" ./...

# 전체 테스트 (로컬 OCI 스토어 필요)
go test -v ./...

root 권한이 없는 환경에서는 TestLoadConfig / TestInitConfig가 자동으로 skip된다.
TestLoadConfig_TempDir으로 동일 기능을 검증할 수 있다.

알려진 제한 사항

  • referrer 조회(list referrers) API는 미구현. 현재는 push까지만 제공한다.
  • toolprofile / security referrer push는 payload 구조를 호출자가 직접 구성해야 한다. payload 스펙은 NodeVault의 docs/OBSERVED_PROFILE_SPEC.md, docs/SECURITY_SCAN_SPEC.md 참조.
  • 과거 stub였던 local-registry.go, pipeline-index.go, oci-crud.go는 제거했다. 판단 배경은 docs/stub-status.md 참조.
P3 backlog (연기된 항목)

상세 설계는 p3-backlog.md 참조.

항목 현재 상태 해결 방향
Streaming tar/push Step 1 완료: 레이어를 temp 파일에 기록(메모리 버퍼 제거). Step 2(진정한 스트리밍 push)는 미설계 ORAS Store.Push streaming 모드 검토 후 구현
✅ Chunked CAS ArtifactFormatChunkedCAS stable 승격 완료 (v0.7.0-stable). 1 GiB 청크, 스트리밍, M-12 tree verify 포함. —
✅ Remote registry fetch Client.FetchVolumeFromRemote 추가 완료 —
✅ Staging 고도화 safe fetch(RequireEmptyDestination) + 3-phase AtomicOverwrite + validateStagingDir 모두 완료 —

라이선스

Apache License 2.0

Documentation

Overview

Package sori provides OCI-based packaging, push/fetch, and metadata helpers for reference datasets.

Preferred entrypoint:

  1. Load configuration with LoadConfig
  2. Build a Client with Config.NewClient or NewClient
  3. Package with Client.PackageVolumeWithOptions
  4. Push with Client.PushPackagedVolumeWithOptions
  5. Build generic metadata with BuildArtifactMetadata

The Client path plus generic packaging, push, fetch, metadata, and core error/option surfaces form the preferred core path and the current stable core candidate.

NodeVault-oriented data spec, registration, and referrer helpers remain in this package for compatibility, but they are still experimental and are not yet part of the frozen core contract.

This package is intentionally in a soft-boundary stage: core and higher-level experimental helpers share the same package path today, but not the same stability level. Some experimental areas may be reevaluated before any future stable promotion.

Index

Examples

Constants

View Source
const (
	// MediaTypeToolSpec is the current media type used by the experimental tool
	// referrer helpers.
	MediaTypeToolSpec = "application/vnd.nodevault.toolspec.v1+json"

	// MediaTypeDataSpec is the current media type used by the experimental data
	// referrer helpers.
	MediaTypeDataSpec = "application/vnd.nodevault.dataspec.v1+json"

	// MediaTypeToolProfile is the media type for observed dry-run profile referrers.
	// It carries validationHash, observedIoProfile, observedResourceProfile, and
	// contractCheck for a given tool image.
	MediaTypeToolProfile = "application/vnd.nodevault.toolprofile.v1+json"

	// MediaTypeSecurityScan is the media type for security scan result referrers.
	// It carries CVE summary, scanner identity, and policy evaluation results
	// for a given tool image.
	MediaTypeSecurityScan = "application/vnd.nodevault.security.v1+json"
)
View Source
const (
	ConfigBlobJson  = "configblob.json"
	CollectionJson  = "volume-collection.json"
	VolumeIndexJson = "volume-index.json"
)
View Source
const ArtifactMetadataSchemaVersion = "sori.artifact.v1"

Variables

View Source
var (
	// ErrValidation marks validation failures on the exported core error path.
	ErrValidation = &Error{Kind: KindValidation}
	// ErrNotFound marks missing-resource failures on the exported core error path.
	ErrNotFound = &Error{Kind: KindNotFound}
	// ErrConflict marks state conflicts on the exported core error path.
	ErrConflict = &Error{Kind: KindConflict}
	// ErrIntegrity marks integrity or decode failures on the exported core error path.
	ErrIntegrity = &Error{Kind: KindIntegrity}
	// ErrTransport marks IO, network, or remote-transport failures on the exported core error path.
	ErrTransport = &Error{Kind: KindTransport}
	// ErrAuth marks authentication and authorization failures on the exported core error path.
	ErrAuth = &Error{Kind: KindAuth}
)
View Source
var Log = logrus.New()

Functions

func MarshalSpec

func MarshalSpec(v interface{}) ([]byte, error)

MarshalSpec marshals the payload used by the experimental referrer helpers.

Experimental: this helper remains available for the current referrer API but is not yet part of the frozen core contract.

func TarGzDir

func TarGzDir(fsDir, prefixPath string) ([]byte, error)

func UntarGzDir

func UntarGzDir(gzipStream io.Reader, dest string) error

func ValidateVolumeDir

func ValidateVolumeDir(volDir string) ([]byte, error)

Types

type ArtifactContents

type ArtifactContents struct {
	Format     string      `json:"format,omitempty"`
	TotalSize  int64       `json:"total_size"`
	CreatedAt  string      `json:"created_at,omitempty"`
	Partitions []Partition `json:"partitions,omitempty"`
}

ArtifactContents describes packaged contents in the generic core model.

type ArtifactDisplay

type ArtifactDisplay struct {
	Name        string   `json:"name"`
	Description string   `json:"description,omitempty"`
	Category    string   `json:"category,omitempty"`
	Tags        []string `json:"tags,omitempty"`
}

ArtifactDisplay holds display-oriented metadata in the generic core model.

type ArtifactFormat added in v0.7.1

type ArtifactFormat int

ArtifactFormat selects the OCI artifact layout used during packaging. The zero value is ArtifactFormatLegacy, preserving backward compatibility.

const (
	// ArtifactFormatLegacy packages each partition as a gzip-compressed tar
	// layer.  This is the original sori format and is always supported on fetch.
	ArtifactFormatLegacy ArtifactFormat = iota

	// ArtifactFormatChunkedCAS packages files as fixed-size raw chunks with a
	// chunk-index.json manifest.  Fetch requires a sori client at v0.7.0 or later.
	ArtifactFormatChunkedCAS
)

type ArtifactIdentity

type ArtifactIdentity struct {
	Name      string `json:"name"`
	Version   string `json:"version,omitempty"`
	StableRef string `json:"stable_ref"`
}

ArtifactIdentity identifies the packaged artifact in the generic core model.

type ArtifactLocation

type ArtifactLocation struct {
	LocalTag       string `json:"local_tag,omitempty"`
	Repository     string `json:"repository,omitempty"`
	Reference      string `json:"reference,omitempty"`
	ManifestDigest string `json:"manifest_digest,omitempty"`
	ConfigDigest   string `json:"config_digest,omitempty"`
}

ArtifactLocation describes where the packaged artifact lives in the generic core model.

type ArtifactMetadata

type ArtifactMetadata struct {
	SchemaVersion string                 `json:"schema_version"`
	Kind          string                 `json:"kind"`
	Identity      ArtifactIdentity       `json:"identity"`
	Display       ArtifactDisplay        `json:"display"`
	Source        ArtifactSource         `json:"source"`
	Location      ArtifactLocation       `json:"location"`
	Contents      ArtifactContents       `json:"contents"`
	Annotations   map[string]string      `json:"annotations,omitempty"`
	Extras        map[string]interface{} `json:"extras,omitempty"`
}

ArtifactMetadata is the generic metadata model for the preferred core path.

This type is intended to remain the long-lived metadata surface even while higher-level NodeVault-oriented adapters stay experimental.

func BuildArtifactMetadata

func BuildArtifactMetadata(input ArtifactMetadataInput, pkg *PackageResult, push *PushResult) (*ArtifactMetadata, error)

BuildArtifactMetadata derives generic metadata from the preferred core packaging and push results.

This function is part of the intended long-lived core surface and is the preferred metadata entrypoint for new code.

type ArtifactMetadataInput

type ArtifactMetadataInput struct {
	Kind        string
	Name        string
	Version     string
	StableRef   string
	DisplayName string
	Description string
	Category    string
	Tags        []string
	Format      string
	SourceDir   string
	SourceURI   string
	Annotations map[string]string
	Extras      map[string]interface{}
}

ArtifactMetadataInput is the input contract for BuildArtifactMetadata in the preferred core path.

type ArtifactSource

type ArtifactSource struct {
	SourceDir string `json:"source_dir,omitempty"`
	SourceURI string `json:"source_uri,omitempty"`
}

ArtifactSource describes the source location for the generic core model.

type AuthConfig

type AuthConfig struct {
	Username string `json:"username"`
	Password string `json:"password"`
	Token    string `json:"token"`
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is the preferred entrypoint for the core packaging, push, and fetch path.

Client is the intended long-lived core surface for new code.

Example (FetchVolume)
client := NewClient(WithLocalStorePath(filepath.Join("/tmp", "sori-oci")))
_, _ = client.FetchVolume(context.Background(), "/tmp/restored", "/tmp/sori-oci", "example.v1", FetchOptions{
	Concurrency:             1,
	RequireEmptyDestination: true,
})

fmt.Println("fetch options supported")
Output:
fetch options supported
Example (PackagePushMetadata)
client := NewClient(WithLocalStorePath("/tmp/sori-oci"))

pkg, _ := client.PackageVolumeWithOptions(context.Background(), PackageRequest{
	SourceDir:   "./test-vol",
	DisplayName: "HumanRef GRCh38",
	Tag:         "grch38.v1.0.0",
	Dataset:     "grch38-reference",
	Version:     "v1.0.0",
}, PackageOptions{})

metadata, _ := BuildArtifactMetadata(ArtifactMetadataInput{
	Kind:        "dataset",
	Name:        "grch38-reference",
	Version:     "v1.0.0",
	DisplayName: "HumanRef GRCh38",
	Description: "Human reference genome",
	SourceDir:   "./test-vol",
}, pkg, nil)

fmt.Println(pkg.LocalTag)
fmt.Println(metadata.Identity.StableRef)
Output:
grch38.v1.0.0
grch38-reference@v1.0.0

func NewClient

func NewClient(opts ...ClientOption) *Client

NewClient constructs the preferred core client path for packaging, pushing, and fetching datasets.

This constructor is part of the intended long-lived core surface.

func (*Client) EnsureVolumeFromRemote added in v0.7.2

func (c *Client) EnsureVolumeFromRemote(ctx context.Context, destRoot string, target RemoteTarget, tag string) (*VolumeIndex, error)

EnsureVolumeFromRemote fetches a packaged dataset from a remote OCI registry into destRoot only if the local content is absent or out of date.

It resolves the remote tag to its manifest digest and compares it with the VolumeRef stored in destRoot/volume-index.json. If they match the download is skipped and the returned VolumeIndex has Skipped set to true, reducing a typical k8s init-container re-check to a single network round-trip.

If destRoot does not exist or contains a different version, the dataset is fetched via the 3-phase atomic overwrite path so the transition is safe under concurrent reads.

This is the recommended call pattern for k8s init containers:

vi, err := client.EnsureVolumeFromRemote(ctx, "/data/refs/hg38-star", target, "hg38-2.7.10a")
if vi != nil && vi.Skipped {
    // already up to date, no download performed
}

func (*Client) FetchVolume

func (c *Client) FetchVolume(ctx context.Context, destRoot, repo, tag string, opts FetchOptions) (*VolumeIndex, error)

FetchVolume fetches a packaged dataset using the preferred client-based core path and core fetch options.

When RequireEmptyDestination is true, extraction uses a staging directory so that destRoot is either left untouched (on failure) or fully populated (on success), preventing partial-extraction states.

When AtomicOverwrite is true, the 3-phase overwrite path is used: the new content is extracted to a staging sibling, the existing destRoot is renamed to a backup sibling, then staging is renamed to destRoot.

func (*Client) FetchVolumeFresh

func (c *Client) FetchVolumeFresh(ctx context.Context, destRoot, repo, tag string, concurrency int) (*VolumeIndex, error)

FetchVolumeFresh fetches a packaged dataset into destRoot using the staging path: destRoot must not exist before the call. On success destRoot is fully populated; on failure it is left absent, never partial.

It is a convenience wrapper over FetchVolume with RequireEmptyDestination:true.

func (*Client) FetchVolumeFromRemote

func (c *Client) FetchVolumeFromRemote(ctx context.Context, destRoot string, target RemoteTarget, tag string, opts FetchOptions) (*VolumeIndex, error)

FetchVolumeFromRemote fetches a packaged dataset from a remote OCI registry into destRoot.

Staging is always used: content is extracted to a sibling staging directory and renamed to destRoot only on full success, preventing partial-extraction states. By default destRoot must not exist. Set AtomicOverwrite in opts to replace an existing destRoot via the 3-phase backup-swap path.

RequireEmptyDestination and AtomicOverwrite are mutually exclusive and return ErrValidation if both are set.

func (*Client) FetchVolumeParallel

func (c *Client) FetchVolumeParallel(ctx context.Context, destRoot, repo, tag string, concurrency int) (*VolumeIndex, error)

FetchVolumeParallel fetches a packaged dataset using the preferred client path with explicit parallelism.

func (*Client) FetchVolumeSequential

func (c *Client) FetchVolumeSequential(ctx context.Context, destRoot, repo, tag string) (*VolumeIndex, error)

FetchVolumeSequential fetches a packaged dataset using the preferred client path with sequential extraction.

func (*Client) LocalStorePath

func (c *Client) LocalStorePath() string

LocalStorePath returns the local OCI store path used by the client.

func (*Client) PackageVolume

func (c *Client) PackageVolume(ctx context.Context, req PackageRequest) (*PackageResult, error)

PackageVolume packages a dataset using the preferred client-based core path.

func (*Client) PackageVolumeWithOptions

func (c *Client) PackageVolumeWithOptions(ctx context.Context, req PackageRequest, opts PackageOptions) (*PackageResult, error)

PackageVolumeWithOptions packages a dataset using the preferred client-based core path with explicit core packaging options.

func (*Client) PublishVolume

func (c *Client) PublishVolume(ctx context.Context, vi *VolumeIndex, volPath, volName string, configBlob []byte) (*VolumeIndex, error)

PublishVolume publishes an already-built VolumeIndex through the client path.

This method exists for callers that still operate at the VolumeIndex level, but the preferred core path for new code is PackageVolumeWithOptions.

func (*Client) PublishVolumeFromDir

func (c *Client) PublishVolumeFromDir(ctx context.Context, volDir, displayName, tag string) (*PackageResult, error)

PublishVolumeFromDir is a convenience wrapper over the preferred client packaging path for callers that start from a directory.

func (*Client) PushPackagedVolume

func (c *Client) PushPackagedVolume(ctx context.Context, pkg *PackageResult, target RemoteTarget) (*PushResult, error)

PushPackagedVolume pushes a packaged dataset using the preferred client-based core path.

func (*Client) PushPackagedVolumeWithOptions

func (c *Client) PushPackagedVolumeWithOptions(ctx context.Context, pkg *PackageResult, opts PushOptions) (*PushResult, error)

PushPackagedVolumeWithOptions pushes a packaged dataset using the preferred client-based core path with explicit core push options.

type ClientOption

type ClientOption func(*Client)

ClientOption configures the preferred Client-based core path.

func WithClock

func WithClock(now func() time.Time) ClientOption

WithClock injects the clock used by client flows that need timestamps.

func WithHTTPClient

func WithHTTPClient(httpClient *http.Client) ClientOption

WithHTTPClient injects the HTTP client used by the preferred core push path.

func WithLocalStorePath

func WithLocalStorePath(path string) ClientOption

WithLocalStorePath configures the local OCI store path used by the preferred core client path.

type CollectionManager

type CollectionManager struct {
	// contains filtered or unexported fields
}

func NewCollectionManager

func NewCollectionManager(rootDir string, initial ...VolumeEntry) (*CollectionManager, error)

func (*CollectionManager) AddOrUpdate

func (m *CollectionManager) AddOrUpdate(v VolumeEntry) error

func (*CollectionManager) Flush

func (m *CollectionManager) Flush() error

func (*CollectionManager) Get

func (m *CollectionManager) Get(ref string) (VolumeEntry, bool)

func (*CollectionManager) GetSnapshot

func (m *CollectionManager) GetSnapshot() VolumeCollection

func (*CollectionManager) PublishVolumeFromDir

func (m *CollectionManager) PublishVolumeFromDir(ctx context.Context, volDir, displayName, tag string) error

func (*CollectionManager) Remove

func (m *CollectionManager) Remove(ref string) (bool, error)

type Config

type Config struct {
	Local   LocalStore    `json:"local"`
	Remotes []RemoteStore `json:"remotes"`
}

func InitConfig deprecated

func InitConfig(path string) (*Config, error)

Deprecated: use LoadConfig followed by Config.NewClient so new code stays on the preferred client-based core path.

func LoadConfig

func LoadConfig(path string) (*Config, error)

LoadConfig reads and validates the JSON configuration file used by the preferred core client path.

func (*Config) EnsureDir

func (conf *Config) EnsureDir() error

EnsureDir creates the local OCI store directory defined in the config if it does not already exist. Returns ErrTransport if the directory cannot be created (e.g. insufficient permissions on the parent path).

func (*Config) NewClient

func (conf *Config) NewClient(opts ...ClientOption) *Client

NewClient constructs the preferred core client path from configuration.

type ConfigBlob

type ConfigBlob map[string]interface{}

type DataCatalog

type DataCatalog struct {
	// contains filtered or unexported fields
}

DataCatalog is a local JSON-backed catalog for the current experimental registration model.

Experimental: this helper remains in the root package for compatibility but is not yet part of the intended long-lived core surface.

func NewDataCatalog

func NewDataCatalog(rootDir string) *DataCatalog

NewDataCatalog constructs the local catalog used by the experimental registration helpers.

Experimental: this helper is not yet part of the frozen core contract.

func (*DataCatalog) Get

func (c *DataCatalog) Get(casHash string) (*RegisteredDataDefinition, error)

Get returns one entry from the local experimental catalog by CAS hash.

Experimental: this method is not yet part of the frozen core contract.

func (*DataCatalog) List

func (c *DataCatalog) List(stableRef string) ([]RegisteredDataDefinition, error)

List returns entries from the local experimental catalog, optionally filtered by stableRef.

Experimental: this method is not yet part of the frozen core contract.

func (*DataCatalog) Register

Register stores or updates a registration record in the local experimental catalog.

Experimental: this method is not yet part of the frozen core contract.

type DataDisplay

type DataDisplay struct {
	Name        string            `json:"name"`
	Description string            `json:"description,omitempty"`
	Annotations map[string]string `json:"annotations,omitempty"`
}

DataDisplay describes the presentation-oriented section of an experimental DataSpec.

Experimental: this shape is NodeVault-oriented and may change.

type DataIdentity

type DataIdentity struct {
	StableRef string `json:"stableRef"`
	Dataset   string `json:"dataset,omitempty"`
	Version   string `json:"version,omitempty"`
}

DataIdentity describes the logical identity section of an experimental DataSpec.

Experimental: this shape is NodeVault-oriented and may change before any stable promotion.

type DataProvenance

type DataProvenance struct {
	PackagedAt string `json:"packagedAt"`
	SourceDir  string `json:"sourceDir"`
	LocalTag   string `json:"localTag"`
}

DataProvenance describes the packaging provenance section of an experimental DataSpec.

Experimental: this shape is NodeVault-oriented and may change.

type DataRegisterRequest

type DataRegisterRequest struct {
	RequestID   string      `json:"request_id,omitempty"`
	DataName    string      `json:"data_name"`
	Version     string      `json:"version,omitempty"`
	Description string      `json:"description,omitempty"`
	Format      string      `json:"format,omitempty"`
	SourceURI   string      `json:"source_uri,omitempty"`
	Checksum    string      `json:"checksum,omitempty"`
	StorageURI  string      `json:"storage_uri,omitempty"`
	StableRef   string      `json:"stable_ref,omitempty"`
	Display     DisplaySpec `json:"display,omitempty"`
}

DataRegisterRequest is the current registration input model used by the experimental registration helpers.

Experimental: this shape may still change as the NodeVault-facing contract is reviewed.

type DataRegisterResponse

type DataRegisterResponse struct {
	CASHash string                    `json:"cas_hash"`
	Data    *RegisteredDataDefinition `json:"data"`
}

DataRegisterResponse is returned by the experimental registration helpers.

Experimental: this type is not yet part of the frozen core contract.

func RegisterPackagedData

func RegisterPackagedData(ctx context.Context, rootDir string, req DataRegisterRequest, pkg *PackageResult, push *PushResult) (*DataRegisterResponse, error)

RegisterPackagedData stores a registration record for pkg and push in the current experimental registration catalog.

Experimental: prefer the core client path plus BuildArtifactMetadata unless a caller explicitly needs the current registration model.

type DataSection

type DataSection struct {
	ArtifactType   string      `json:"artifactType"`
	Repository     string      `json:"repository,omitempty"`
	Reference      string      `json:"reference,omitempty"`
	ManifestDigest string      `json:"manifestDigest,omitempty"`
	ConfigDigest   string      `json:"configDigest"`
	TotalSize      int64       `json:"totalSize"`
	Partitions     []Partition `json:"partitions"`
}

DataSection describes the artifact location and contents section of an experimental DataSpec.

Experimental: this shape is not yet part of the frozen core contract.

type DataSpec

type DataSpec struct {
	Identity   DataIdentity   `json:"identity"`
	Data       DataSection    `json:"data"`
	Display    DataDisplay    `json:"display"`
	Provenance DataProvenance `json:"provenance"`
}

DataSpec is a NodeVault-oriented metadata view derived from ArtifactMetadata.

Experimental: this type is kept in the root package for now, but it is not yet part of the frozen core contract and may move or change as the NodeVault-facing model settles.

func ArtifactMetadataToDataSpec

func ArtifactMetadataToDataSpec(meta *ArtifactMetadata) *DataSpec

ArtifactMetadataToDataSpec converts generic ArtifactMetadata into the current NodeVault-oriented DataSpec view.

Experimental: this adapter is intentionally outside the preferred core path and is not yet part of the frozen core contract.

func BuildDataSpec

func BuildDataSpec(pkg *PackageResult, push *PushResult, req PackageRequest) (*DataSpec, error)

BuildDataSpec derives a NodeVault-oriented DataSpec from the generic core metadata inputs.

Experimental: prefer BuildArtifactMetadata for the stable core candidate path. This helper remains available for callers that still need the current DataSpec shape.

type DisplaySpec

type DisplaySpec struct {
	Label       string   `json:"label,omitempty"`
	Description string   `json:"description,omitempty"`
	Category    string   `json:"category,omitempty"`
	Tags        []string `json:"tags,omitempty"`
}

DisplaySpec is the display-oriented portion of the experimental registration model.

Experimental: this type is NodeVault-oriented and is not yet part of the frozen core contract.

type Error

type Error struct {
	Kind    ErrorKind
	Op      string
	Message string
	Err     error
}

Error is the structured error type behind the exported core error sentinels.

func (*Error) Error

func (e *Error) Error() string

func (*Error) Is

func (e *Error) Is(target error) bool

func (*Error) Unwrap

func (e *Error) Unwrap() error

type ErrorKind

type ErrorKind string

ErrorKind classifies exported core errors returned by the root package.

const (
	KindValidation ErrorKind = "validation"
	KindNotFound   ErrorKind = "not_found"
	KindConflict   ErrorKind = "conflict"
	KindIntegrity  ErrorKind = "integrity"
	KindTransport  ErrorKind = "transport"
	KindAuth       ErrorKind = "auth"
)

type FetchOptions

type FetchOptions struct {
	Concurrency             int
	RequireEmptyDestination bool
	// AtomicOverwrite enables the 3-phase overwrite path:
	//   Phase 1 — extract to a staging sibling of destRoot
	//   Phase 2 — rename existing destRoot to a backup sibling (if present)
	//   Phase 3 — rename staging to destRoot (atomic commit)
	//   Cleanup — remove backup (best-effort; warning logged on failure)
	//
	// On Phase 3 failure a best-effort rollback renames the backup back to
	// destRoot.  If that rollback also fails, destRoot may be absent; the
	// error message includes the staging and backup paths for manual recovery.
	//
	// AtomicOverwrite and RequireEmptyDestination are mutually exclusive;
	// setting both returns ErrValidation.
	AtomicOverwrite bool
	// SkipIfCurrent, when true, resolves the remote tag to its manifest digest
	// and compares it with the VolumeRef stored in destRoot/volume-index.json.
	// If they match the fetch is skipped and the returned VolumeIndex has
	// Skipped set to true.  If destRoot does not contain a valid
	// volume-index.json, or VolumeRef is empty, the fetch proceeds normally.
	//
	// The typical k8s init-container pattern is:
	//   FetchOptions{AtomicOverwrite: true, SkipIfCurrent: true}
	//
	// SkipIfCurrent and RequireEmptyDestination are mutually exclusive;
	// setting both returns ErrValidation.
	SkipIfCurrent bool
}

FetchOptions controls the preferred core fetch path.

This option surface is part of the stable core candidate contract.

type LocalStore

type LocalStore struct {
	Type string `json:"type"` // "oci"
	Path string `json:"path"`
}

type PackageOptions

type PackageOptions struct {
	ConfigBlob        []byte
	RequireConfigBlob bool
	// Format selects the artifact layout.  Defaults to ArtifactFormatLegacy.
	Format ArtifactFormat
	// DatasetMetadata is the serialised dataset-metadata.json to include as a
	// dedicated OCI layer (mediaType application/vnd.sori.dataset.metadata.v1+json).
	// Optional: fetch works without it; catalog exposure is degraded without it.
	DatasetMetadata []byte
	// Progress receives per-chunk progress events.  Pass nil to suppress.
	// Use chunked.ProgressFunc and chunked.ChunkProgress for the callback type.
	Progress chunked.ProgressFunc
}

PackageOptions controls the preferred core packaging path.

This option surface is part of the stable core candidate contract.

type PackageRequest

type PackageRequest struct {
	SourceDir   string            `json:"source_dir"`
	DisplayName string            `json:"display_name"`
	Tag         string            `json:"tag"`
	Dataset     string            `json:"dataset,omitempty"`
	Version     string            `json:"version,omitempty"`
	StableRef   string            `json:"stable_ref,omitempty"`
	Description string            `json:"description,omitempty"`
	Annotations map[string]string `json:"annotations,omitempty"`
	ConfigBlob  []byte            `json:"-"`
}

PackageRequest is the input to the preferred core packaging path.

This request type is intended to remain part of the long-lived core surface used by Client.PackageVolume and PackageVolumeToStore.

type PackageResult

type PackageResult struct {
	StableRef      string      `json:"stable_ref"`
	LocalTag       string      `json:"local_tag"`
	ManifestDigest string      `json:"manifest_digest"`
	ConfigDigest   string      `json:"config_digest"`
	TotalSize      int64       `json:"total_size"`
	CreatedAt      string      `json:"created_at"`
	Partitions     []Partition `json:"partitions"`
	VolumeIndex    VolumeIndex `json:"volume_index"`
}

PackageResult is the output of the preferred core packaging path.

This result type is part of the stable core candidate surface used by the client, metadata builder, and remote push flow.

func PackageVolume deprecated

func PackageVolume(ctx context.Context, req PackageRequest) (*PackageResult, error)

Deprecated: prefer Config.NewClient followed by Client.PackageVolume or Client.PackageVolumeWithOptions so new code stays on the preferred core path.

func PackageVolumeToStore

func PackageVolumeToStore(ctx context.Context, localStorePath string, req PackageRequest) (*PackageResult, error)

PackageVolumeToStore packages a dataset into the given local OCI store using the preferred core packaging contract.

type Partition

type Partition struct {
	Name        string `json:"name"`
	Path        string `json:"path"`
	ManifestRef string `json:"manifest_ref"`
	CreatedAt   string `json:"created_at"`
	Compression string `json:"compression"`
}

Partition describes one partition entry inside the packaged dataset.

Partition is part of the preferred core path because it is used by the core packaging, push, and fetch results.

type PushOptions

type PushOptions struct {
	Target RemoteTarget
}

PushOptions controls the preferred core push path.

This option surface is part of the stable core candidate contract.

type PushResult

type PushResult struct {
	Reference      string `json:"reference"`
	Repository     string `json:"repository"`
	Tag            string `json:"tag"`
	ManifestDigest string `json:"manifest_digest"`
}

PushResult reports the remote artifact identity returned by the preferred core push path.

This result type is part of the stable core candidate surface.

func PushLocalToRemote deprecated

func PushLocalToRemote(ctx context.Context, localRepoPath, tag, remoteRepo, user, pass string, plainHTTP bool) (*PushResult, error)

Deprecated: prefer Client.PushPackagedVolume or PushPackagedVolume so new code stays on the preferred core push path.

func PushPackagedVolume

func PushPackagedVolume(ctx context.Context, localStorePath string, pkg *PackageResult, target RemoteTarget) (*PushResult, error)

PushPackagedVolume copies a packaged artifact from the local OCI store to a remote registry using the preferred core push contract.

type ReferrerOptions

type ReferrerOptions struct {
	Target RemoteTarget
}

ReferrerOptions controls the experimental referrer helpers.

Experimental: this option surface belongs to the referrer API and is not yet part of the frozen core contract.

type ReferrerPushResult

type ReferrerPushResult struct {
	SubjectDigest  string `json:"subject_digest"`
	ManifestDigest string `json:"manifest_digest"`
	ConfigDigest   string `json:"config_digest"`
	Repository     string `json:"repository"`
	ArtifactType   string `json:"artifact_type"`
}

ReferrerPushResult reports the manifest uploaded by the experimental referrer helpers.

Experimental: this type is NodeVault-oriented and is not yet part of the intended long-lived core contract.

func PushRemoteDataSpecReferrer

func PushRemoteDataSpecReferrer(ctx context.Context, push *PushResult, target RemoteTarget, spec *DataSpec) (*ReferrerPushResult, error)

PushRemoteDataSpecReferrer uploads an experimental DataSpec referrer for the pushed artifact identified by push.

Experimental: this helper is NodeVault-oriented and is not yet part of the intended long-lived core contract.

type ReferrerTarget

type ReferrerTarget interface {
	orasoras.Target
}

ReferrerTarget is the target interface accepted by the experimental referrer helpers.

Experimental: this target abstraction is tied to the current referrer helpers and is not yet part of the frozen core contract.

func NewReferrerLocalStore

func NewReferrerLocalStore(path string) (ReferrerTarget, error)

NewReferrerLocalStore opens an OCI layout store for the experimental referrer helpers.

Experimental: this helper is specific to the current referrer API.

func NewReferrerRemoteRepository

func NewReferrerRemoteRepository(repoRef string, plainHTTP bool, credential *auth.Credential) (ReferrerTarget, error)

NewReferrerRemoteRepository creates a remote repository for the experimental referrer helpers.

Experimental: this helper is specific to the current referrer API.

type RegisteredDataDefinition

type RegisteredDataDefinition struct {
	CASHash         string      `json:"cas_hash"`
	DataName        string      `json:"data_name"`
	Version         string      `json:"version,omitempty"`
	Description     string      `json:"description,omitempty"`
	Format          string      `json:"format,omitempty"`
	SourceURI       string      `json:"source_uri,omitempty"`
	Checksum        string      `json:"checksum,omitempty"`
	StorageURI      string      `json:"storage_uri,omitempty"`
	StableRef       string      `json:"stable_ref"`
	Display         DisplaySpec `json:"display,omitempty"`
	RegisteredAt    int64       `json:"registered_at"`
	LifecyclePhase  string      `json:"lifecycle_phase"`
	IntegrityHealth string      `json:"integrity_health"`
}

RegisteredDataDefinition is the current persisted view of the experimental registration model.

Experimental: this type is not yet part of the frozen core contract.

func ArtifactMetadataToRegisteredDataDefinition

func ArtifactMetadataToRegisteredDataDefinition(meta *ArtifactMetadata, req DataRegisterRequest) *RegisteredDataDefinition

ArtifactMetadataToRegisteredDataDefinition adapts generic ArtifactMetadata into the current experimental registration shape.

Experimental: this adapter is not yet part of the frozen core contract.

func BuildRegisteredDataDefinition

func BuildRegisteredDataDefinition(req DataRegisterRequest, pkg *PackageResult, push *PushResult) (*RegisteredDataDefinition, error)

BuildRegisteredDataDefinition builds the current experimental registration view from the generic core metadata inputs.

Experimental: this adapter remains available for callers that still need the registration model, but it is not yet part of the frozen core contract.

Example

ExampleBuildRegisteredDataDefinition demonstrates the current experimental registration helper layered on top of the core packaging result.

pkg := &PackageResult{
	LocalTag:       "dataset.v1",
	ManifestDigest: "sha256:local",
	ConfigDigest:   "sha256:config",
	StableRef:      "dataset@v1",
}

def, _ := BuildRegisteredDataDefinition(DataRegisterRequest{
	DataName:    "dataset",
	Version:     "v1",
	Description: "example dataset",
	Format:      "FASTA",
}, pkg, nil)

fmt.Println(def.DataName)
fmt.Println(def.StableRef)
Output:
dataset
dataset@v1

type RemoteStore

type RemoteStore struct {
	Name       string     `json:"name"`
	Type       string     `json:"type"`       // "registry"
	Registry   string     `json:"registry"`   // e.g. harbor.local
	Repository string     `json:"repository"` // e.g. harbor 인 경우 project/repo
	TLS        TLSConfig  `json:"tls"`
	Auth       AuthConfig `json:"auth"`
}

type RemoteTarget

type RemoteTarget struct {
	Registry            string              `json:"registry"`
	Repository          string              `json:"repository"`
	PlainHTTP           bool                `json:"plain_http"`
	InsecureTLS         bool                `json:"insecure_tls,omitempty"`
	Username            string              `json:"username,omitempty"`
	Password            string              `json:"password,omitempty"`
	Token               string              `json:"token,omitempty"`
	CAFile              string              `json:"ca_file,omitempty"`
	HTTPClient          *http.Client        `json:"-"`
	Transport           http.RoundTripper   `json:"-"`
	AuthProvider        auth.CredentialFunc `json:"-"`
	ReferrersCapability *bool               `json:"-"`
}

RemoteTarget describes how the preferred core push path should reach a remote OCI registry.

This type is part of the intended long-lived core surface used by PushPackagedVolume and Client.PushPackagedVolume.

type SpecReferrerResult

type SpecReferrerResult struct {
	ReferrerDigest string
	SubjectDigest  string
	MediaType      string
}

SpecReferrerResult reports the manifest uploaded by the experimental PushToolSpecReferrer and PushDataSpecReferrer helpers.

Experimental: this type is not yet part of the frozen core contract.

func PushDataSpecReferrer

func PushDataSpecReferrer(ctx context.Context, target ReferrerTarget, subjectDigest string, specJSON []byte) (SpecReferrerResult, error)

PushDataSpecReferrer uploads a data-oriented OCI referrer artifact.

Experimental: this helper is NodeVault-oriented, subject to change, and not yet part of the intended long-lived core surface.

func PushSecurityReferrer

func PushSecurityReferrer(ctx context.Context, target ReferrerTarget, subjectDigest string, securityJSON []byte) (SpecReferrerResult, error)

PushSecurityReferrer uploads a security scan result referrer artifact for the given tool image. The securityJSON must be a valid JSON document conforming to the security referrer payload defined in SECURITY_SCAN_SPEC.md.

Experimental: this helper is NodeVault-oriented, subject to change, and not yet part of the intended long-lived core surface.

func PushToolProfileReferrer

func PushToolProfileReferrer(ctx context.Context, target ReferrerTarget, subjectDigest string, profileJSON []byte) (SpecReferrerResult, error)

PushToolProfileReferrer uploads an observed dry-run profile referrer artifact for the given tool image. The profileJSON must be a valid JSON document conforming to the toolprofile payload defined in OBSERVED_PROFILE_SPEC.md.

Experimental: this helper is NodeVault-oriented, subject to change, and not yet part of the intended long-lived core surface.

func PushToolSpecReferrer

func PushToolSpecReferrer(ctx context.Context, target ReferrerTarget, subjectDigest string, specJSON []byte) (SpecReferrerResult, error)

PushToolSpecReferrer uploads a tool-oriented OCI referrer artifact.

Experimental: this helper is NodeVault-oriented, subject to change, and not yet part of the intended long-lived core surface.

type TLSConfig

type TLSConfig struct {
	Insecure bool   `json:"insecure"`
	CAFile   string `json:"ca_file"`
}

type VolumeCollection

type VolumeCollection struct {
	Version int           `json:"version"`
	Volumes []VolumeEntry `json:"volumes"`
}

func LoadOrNewCollection

func LoadOrNewCollection(rootDir string, initialEntries ...VolumeEntry) (*VolumeCollection, error)

func NewVolumeCollection

func NewVolumeCollection(initialEntries ...VolumeEntry) *VolumeCollection

func (*VolumeCollection) AddVolume

func (vc *VolumeCollection) AddVolume(entry VolumeEntry)

func (*VolumeCollection) HasVolume

func (vc *VolumeCollection) HasVolume(vi VolumeIndex) bool

func (*VolumeCollection) Merge

func (vc *VolumeCollection) Merge(newColl VolumeCollection) bool

func (*VolumeCollection) RemoveVolume

func (vc *VolumeCollection) RemoveVolume(idx int) error

type VolumeEntry

type VolumeEntry struct {
	Index      VolumeIndex `json:"index"`
	ConfigBlob ConfigBlob  `json:"configBlob"`
}

type VolumeIndex

type VolumeIndex struct {
	VolumeRef   string      `json:"volume_ref"`
	DisplayName string      `json:"display_name"`
	CreatedAt   string      `json:"created_at"`
	Partitions  []Partition `json:"partitions"`
	// Skipped is true when FetchVolumeFromRemote detected that destRoot
	// already holds the requested manifest digest and skipped the download.
	// This field is runtime-only and is never written to volume-index.json.
	Skipped bool `json:"-"`
}

VolumeIndex describes the partition layout of a packaged dataset.

VolumeIndex is part of the core candidate surface and is used by the preferred client path as well as compatibility helpers.

func FetchVolParallel

func FetchVolParallel(ctx context.Context, destRoot, repo, tag string, concurrency int) (*VolumeIndex, error)

FetchVolParallel fetches a packaged dataset from a local OCI store with parallel layer extraction. Dual-path (D-13): detects chunked CAS vs legacy format from the manifest Config.MediaType; chunked artifacts use the chunked fetcher's own concurrency.

func FetchVolSeq

func FetchVolSeq(ctx context.Context, destRoot, repo, tag string) (*VolumeIndex, error)

FetchVolSeq fetches a packaged dataset from a local OCI store sequentially. Dual-path (D-13): detects chunked CAS vs legacy format from the manifest Config.MediaType and dispatches accordingly.

func GenerateVolumeIndex

func GenerateVolumeIndex(rootPath, displayName string) (*VolumeIndex, error)

GenerateVolumeIndex builds a VolumeIndex from the top-level subdirectories of rootPath. Only immediate child directories become partitions; nested directories are included in their parent partition's layer. Root-level regular files are NOT listed as partitions — they are handled as a separate layer during publish.

func (*VolumeIndex) PublishVolume deprecated

func (vi *VolumeIndex) PublishVolume(ctx context.Context, volPath, volName string, configBlob []byte) (*VolumeIndex, error)

Deprecated: prefer Client.PackageVolume, Client.PackageVolumeWithOptions, or PackageVolumeToStore so new code stays on the preferred client-based core path.

func (*VolumeIndex) SaveToFile

func (vi *VolumeIndex) SaveToFile(rootPath string) error

Directories

Path Synopsis
adapters
Package chunked implements the sori chunked CAS artifact format.
Package chunked implements the sori chunked CAS artifact format.
internal
bench
Package bench implements the P5-6 benchmark gate for the chunked CAS path.
Package bench implements the P5-6 benchmark gate for the chunked CAS path.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址