objects

package
v0.0.73 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package objects provides immutable, typed checkpoints backed by JobDB artifacts.

Index

Constants

View Source
const ArtifactPrefix = "__c2j_objects__/"
View Source
const Marker = "$c2j_object"
View Source
const Version = "v1"

Variables

This section is empty.

Functions

func ExpandSchema

func ExpandSchema(schema map[string]any) (map[string]any, error)

ExpandSchema translates the object annotation into ordinary JSON Schema so nested properties, items, unions and local $refs use the same validator. Only schema-valued keywords are visited; defaults/examples remain data.

func IsInternalArtifact

func IsInternalArtifact(name string) bool

func JSONValue

func JSONValue(value any) (any, error)

JSONValue converts native references to the JSON values used by schema validators.

func Transform

func Transform(value any, fn func(Ref) (any, error)) (any, error)

Transform walks nested inputs/outputs, retaining native scalar values. References are leaves: their storage descriptors are not walked as inputs.

func ValidationRef

func ValidationRef(objectType string) map[string]any

ValidationRef is a shape-only placeholder for recipe validation, never execution.

Types

type Config

type Config struct {
	JobKey      jobdb.JobKey
	TaskOrdinal int64
	Workdir     string
	GetArtifact func(jobdb.ArtifactKey) (jobdb.Artifact, error)
	AddArtifact func(jobdb.Artifact) error
}

type Ref

type Ref struct {
	Format   string            `json:"$c2j_object"`
	Type     string            `json:"type"`
	TenantID string            `json:"tenant_id"`
	Artifact jobdb.ArtifactKey `json:"artifact"`
	SHA256   string            `json:"sha256"`
}

Ref identifies an exact checkpoint. Metadata and files live in its artifact, never in the recipe value. The type includes its contract version, e.g. c2ops.codex.session/v1, independently of this reference format's version.

func Collect

func Collect(value any) ([]Ref, error)

func Parse

func Parse(value any) (Ref, bool, error)

Parse recognizes both native references and their JSON representation.

func (Ref) Validate

func (r Ref) Validate() error

type Snapshot

type Snapshot struct {
	Ref       Ref               `json:"ref"`
	Metadata  json.RawMessage   `json:"metadata"`
	Files     map[string]string `json:"files"`
	Directory string            `json:"-"`
}

func (*Snapshot) Close

func (s *Snapshot) Close() error

type Store

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

Store is invocation-local. Open always produces a fresh writable copy, even when called twice on the same reference. It has no session-ID or latest cache.

func NewStore

func NewStore(config Config) *Store

func (*Store) Open

func (s *Store) Open(ctx context.Context, ref Ref, expectedType string) (*Snapshot, error)

func (*Store) Publish

func (s *Store) Publish(ctx context.Context, objectType string, metadata any, files map[string]string) (Ref, error)

Publish freezes metadata and files immediately; subsequent source changes cannot affect the result. JobDB persists the archive with the task outcome.

Jump to

Keyboard shortcuts

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