Documentation
¶
Overview ¶
Package resourcelib manages operator-owned reusable resources, independently of discovered assets. Publication is explicit; stored files are never executed.
Index ¶
- Constants
- Variables
- func OpenTaskFile(rootDir, p string) (*os.File, error)
- func ValidatePath(p string) error
- func ValidateResource(r *Resource) error
- func WriteCredential(ctx context.Context, taskRoot string, v Version, name string, data []byte) (string, error)
- type Actor
- type Conflict
- type DocumentMeta
- type Draft
- type Endpoint
- type Event
- type File
- type InputError
- type Manifest
- type Resource
- type Store
- func (s *Store) BlobPath(f File) string
- func (s *Store) Configure(ctx context.Context, id, revision int64, endpoints []Endpoint, ...) (Draft, error)
- func (s *Store) Create(ctx context.Context, r *Resource, a Actor) error
- func (s *Store) Credentials(ctx context.Context, taskID, versionID int64) (map[string]string, error)
- func (s *Store) Discard(ctx context.Context, id, revision int64, a Actor) error
- func (s *Store) Draft(ctx context.Context, id int64) (Draft, error)
- func (s *Store) Drafts(ctx context.Context, id int64) ([]Draft, error)
- func (s *Store) Events(ctx context.Context, id, before int64) ([]Event, error)
- func (s *Store) Get(ctx context.Context, id int64) (Resource, error)
- func (s *Store) Grant(ctx context.Context, taskID, id, versionID, expected int64) (Version, error)
- func (s *Store) List(ctx context.Context, q, kind string, before int64) ([]Resource, error)
- func (s *Store) Materialize(ctx context.Context, v Version, taskRoot string) (string, error)
- func (s *Store) NewDraft(ctx context.Context, id, base int64, a Actor) (Draft, error)
- func (s *Store) Observe(ctx context.Context, id, version int64, status, detail string, a Actor) error
- func (s *Store) Pin(ctx context.Context, taskID, id, versionID int64, grant bool) (Version, error)
- func (s *Store) Publish(ctx context.Context, id, revision int64, note, validation string, a Actor) (Version, error)
- func (s *Store) ReadDocument(ctx context.Context, m Manifest) (string, error)
- func (s *Store) RemoveFile(ctx context.Context, id, revision int64, p string, a Actor) (Draft, error)
- func (s *Store) Sweep(ctx context.Context, olderThan time.Time) (int, error)
- func (s *Store) Switch(ctx context.Context, taskID, id, versionID, expected int64) (Version, error)
- func (s *Store) TaskVersions(ctx context.Context, taskID int64) ([]Version, error)
- func (s *Store) Update(ctx context.Context, r *Resource, a Actor) error
- func (s *Store) UpdateStates(ctx context.Context, taskID int64) ([]UpdateState, error)
- func (s *Store) Upload(ctx context.Context, id, revision int64, p string, executable bool, ...) (Draft, error)
- func (s *Store) Version(ctx context.Context, id int64) (Version, error)
- func (s *Store) VersionPath(v Version) string
- func (s *Store) Versions(ctx context.Context, id int64) ([]Version, error)
- type UpdateState
- type Version
Constants ¶
const ( MaxFileBytes int64 = 256 << 20 MaxLibraryBytes int64 = 10 << 30 MaxTaskBytes int64 = 1 << 30 MaxTaskResources = 32 MaxFiles = 2048 MaxEndpoints = 32 )
const DocumentName = "RESOURCE.md"
const MaxDocumentBytes = 64 << 10
Variables ¶
var ( ErrConflict = errors.New("resource changed; reload the current revision and create a draft from the latest version before retrying") ErrLimit = errors.New("resource quota exceeded") )
Functions ¶
func OpenTaskFile ¶
OpenTaskFile rejects every symlink component and confines source reads even when another process renames components during the operation.
func ValidatePath ¶
func ValidateResource ¶
Types ¶
type Actor ¶
type Actor struct {
TaskID int64 `json:"task_id"`
ThreadID string `json:"thread_id"`
RunnerID string `json:"runner_id"`
}
Actor is populated by the server, never trusted from tool/HTTP input.
type Conflict ¶
type DocumentMeta ¶
type DocumentMeta struct {
Name string `yaml:"name" json:"name"`
Description string `yaml:"description" json:"description"`
Tags []string `yaml:"tags,omitempty" json:"tags"`
}
func ParseDocument ¶
func ParseDocument(data []byte) (DocumentMeta, error)
Document is the versioned entry point, following the same progressive loading pattern as a Skill, but using a separate registry and invocation tools.
type Draft ¶
type Draft struct {
ID int64 `json:"id"`
ResourceID int64 `json:"resource_id"`
BaseVersionID int64 `json:"base_version_id"`
Revision int64 `json:"revision"`
State string `json:"state"`
PublishedVersionID int64 `json:"published_version_id"`
Size int64 `json:"size"`
Manifest
Actor Actor `json:"actor"`
UpdatedAt time.Time `json:"updated_at"`
}
type InputError ¶
type InputError struct{ Message string }
func (*InputError) Error ¶
func (e *InputError) Error() string
type Manifest ¶
type Manifest struct {
Metadata DocumentMeta `json:"metadata"`
Files []File `json:"files"`
Endpoints []Endpoint `json:"endpoints"`
OS string `json:"os"`
Arch string `json:"arch"`
}
type Resource ¶
type Resource struct {
ID int64 `json:"id"`
Name string `json:"name"`
Kind string `json:"kind"`
Description string `json:"description"`
Tags []string `json:"tags"`
AccessMode string `json:"access_mode"`
Enabled bool `json:"enabled"`
Revision int64 `json:"revision"`
CreatorTaskID int64 `json:"creator_task_id"`
UpdatedAt time.Time `json:"updated_at"`
}
type Store ¶
func (*Store) Configure ¶
func (s *Store) Configure(ctx context.Context, id, revision int64, endpoints []Endpoint, osName, arch string, secrets map[string]string, a Actor) (Draft, error)
Configure replaces endpoints/platform metadata, preserving credentials for unchanged endpoint names. An explicit empty secret clears that credential.
func (*Store) Credentials ¶
func (*Store) Materialize ¶
Materialize supplies a complete disposable working copy, never a writable hard link to global data. An atomic directory rename hides partial copies.
func (*Store) Pin ¶
Pin binds one immutable version per resource per task. Admin grants can change a pin explicitly; agent use is idempotent and never silently upgrades it.
func (*Store) ReadDocument ¶
func (*Store) RemoveFile ¶
func (*Store) Sweep ¶
Sweep removes old, unreferenced blobs left by discarded/replaced drafts or an uncertain commit. The publication lock prevents deleting a just-published blob. Maintenance is independent of execution startup and never scans task folders.
func (*Store) Switch ¶
Switch changes an existing task pin only if the caller still observes the expected version. It grants no new access and preserves all old file paths.
func (*Store) TaskVersions ¶
func (*Store) UpdateStates ¶
UpdateStates queries the bounded set of task pins, not resource files/history. The version index is the durable source of truth, so restarts or lost network notifications cannot permanently lose a publication.