Documentation
¶
Overview ¶
Package packops orchestrates pack verbs (add, apply, status, remove) over the standalone kind managers (skillsync, agentsync, contexts, wiring). There is still no pack write path of its own: a pack expands into calls against the engines that own every write, and this package only owns the expansion. The CLI and the REST layer both drive these functions; rendering and exit codes stay with each caller.
Index ¶
- Constants
- Variables
- func LoadLockedPack(name string) (*skills.LockedPack, error)
- func TallyRows(rows []Row) (applied, failed int)
- type AddDoc
- type AddOptions
- type AddResult
- type ApplyDoc
- type ApplyOptions
- type Counts
- type FindingsError
- type Managers
- func (m *Managers) Add(ctx context.Context, imp *skills.Importer, opts AddOptions) (*AddResult, error)
- func (m *Managers) Apply(ctx context.Context, name string, opts ApplyOptions) (*ApplyDoc, error)
- func (m *Managers) LoadLockedPack(name string) (*skills.LockedPack, error)
- func (m *Managers) Remove(ctx context.Context, imp *skills.Importer, name string, opts RemoveOptions) (*RemoveDoc, error)
- func (m *Managers) Statuses(ctx context.Context, opts StatusOptions) ([]PackStatus, error)
- type Origin
- type PackInfo
- type PackRuleFile
- type PackStatus
- type PreviewOptions
- type PreviewResource
- type PreviewResult
- type RemoveDoc
- type RemoveOptions
- type Row
- type StatusOptions
Constants ¶
const SchemaVersion = 1
SchemaVersion versions every pack document (Article X).
Variables ¶
var ( // ErrNoManifest marks a repository without a gridctl-pack.yaml at // its root. ErrNoManifest = errors.New("no pack manifest found") // ErrNotImported marks a pack name with no record in the import // lockfile. ErrNotImported = errors.New("pack is not imported") // ErrNameCollision marks a pack name claimed by more than one // imported source; operations must refuse rather than pick one. ErrNameCollision = errors.New("pack name is claimed by multiple sources") )
Sentinel errors callers branch on with errors.Is; the user-facing prose rides on the concrete error unchanged.
Functions ¶
func LoadLockedPack ¶
func LoadLockedPack(name string) (*skills.LockedPack, error)
LoadLockedPack finds a pack's record in the default import lockfile.
Types ¶
type AddDoc ¶
type AddDoc struct {
SchemaVersion int `json:"schema_version"`
DryRun bool `json:"dry_run,omitempty"`
Pack string `json:"pack"`
Skills []string `json:"skills"`
Agents []string `json:"agents"`
Rules []string `json:"rules,omitempty"`
Wiring bool `json:"wiring"`
Unresolved []string `json:"unresolved,omitempty"`
Skipped []string `json:"skipped,omitempty"`
Warnings []string `json:"warnings,omitempty"`
}
AddDoc is the machine-readable pack add document.
type AddOptions ¶
type AddOptions struct {
Repo string
Ref string
Path string
Trust bool
DryRun bool
// BlockOnFindings refuses the whole import with a *FindingsError
// before any write when the resolved selection carries security
// findings and Trust is false. The CLI leaves it false (partial
// import with per-resource skips, its documented contract); the REST
// layer sets it so a 409 can never follow a half-done import.
BlockOnFindings bool
}
AddOptions parameterizes a pack import.
type AddResult ¶
AddResult pairs the document with progress notes the CLI prints in order (rule updates, fragments-mode migration). Notes are caller-facing prose, not part of the versioned document.
type ApplyDoc ¶
type ApplyDoc struct {
SchemaVersion int `json:"schema_version"`
Pack string `json:"pack"`
DryRun bool `json:"dry_run,omitempty"`
Applied int `json:"applied"`
Total int `json:"total"`
Rows []Row `json:"rows"`
}
ApplyDoc is the machine-readable apply document.
type ApplyOptions ¶
type ApplyOptions struct {
Force bool
DryRun bool
// Clients restricts wiring to these client slugs.
Clients []string
}
ApplyOptions parameterizes a pack projection, mirroring the CLI flags one to one (--force, --dry-run, --clients).
type Counts ¶
type Counts struct {
Skills int `json:"skills"`
Agents int `json:"agents"`
Rules int `json:"rules"`
Wiring bool `json:"wiring"`
}
Counts summarizes a pack's resolved selection per kind.
type FindingsError ¶
type FindingsError struct {
Pack string
Resources []PreviewResource
}
FindingsError blocks an import whose resolved selection carries security findings and no trust acknowledgment. It is returned before any write, so a refusal never follows a half-done import.
func (*FindingsError) Error ¶
func (e *FindingsError) Error() string
type Managers ¶
type Managers struct {
Skills *skillsync.Manager
Agents *agentsync.Manager
Wiring *wiring.Manager
Contexts *contexts.Manager
Home string
// LockPath overrides the import lockfile path (skills.lock.yaml).
// Empty means the HOME-derived default. Callers that inject a custom
// lockfile path into their importer (the API server) must set the
// same path here, or the importer and the pack record would write
// two different files.
LockPath string
}
Managers bundles the kind managers pack verbs orchestrate.
func (*Managers) Add ¶
func (m *Managers) Add(ctx context.Context, imp *skills.Importer, opts AddOptions) (*AddResult, error)
Add clones, resolves the manifest selection, and imports.
func (*Managers) Apply ¶
Apply projects one pack across every kind it selects. Apply is additive and never transactional: each resource succeeds or skips independently, and per-resource outcomes become rows, not errors.
func (*Managers) LoadLockedPack ¶
func (m *Managers) LoadLockedPack(name string) (*skills.LockedPack, error)
LoadLockedPack finds a pack's record in this engine's lockfile.
func (*Managers) Remove ¶
func (m *Managers) Remove(ctx context.Context, imp *skills.Importer, name string, opts RemoveOptions) (*RemoveDoc, error)
Remove cascades one pack's removal in dependency order: pack-tagged projections are unsynced, pack-tagged wiring records removed through the ownership manager, then the registry entries and the pack record itself. A drifted resource is kept unless forced; the trimmed pack record stays truthful about what remains.
func (*Managers) Statuses ¶
func (m *Managers) Statuses(ctx context.Context, opts StatusOptions) ([]PackStatus, error)
Statuses reports the state matrix for one or all imported packs, sorted by pack name. Skill, agent, and wiring rows come from the kind managers' per-client statuses; rule rows report per-client projection state from the context engine (pack-tagged lock entries joined with per-fragment status), falling back to a store-presence row for rules that were imported but never projected.
type Origin ¶
type Origin struct {
Source string `json:"source"`
Repo string `json:"repo"`
Ref string `json:"ref,omitempty"`
CommitSHA string `json:"commit_sha,omitempty"`
FetchedAt time.Time `json:"fetched_at,omitempty"`
}
Origin identifies where a pack was imported from, straight off its parent lockfile source.
type PackInfo ¶
type PackInfo struct {
Name string `json:"name"`
Version string `json:"version,omitempty"`
Description string `json:"description,omitempty"`
Author string `json:"author,omitempty"`
Origin Origin `json:"origin"`
Counts Counts `json:"counts"`
Unresolved []string `json:"unresolved,omitempty"`
// Applied reports whether any per-client projection exists: an
// imported-but-never-applied pack is registry-only, and list views
// surface that as attention rather than reading healthy.
Applied bool `json:"applied"`
// Collision marks a pack name claimed by more than one source; the
// listed repos disambiguate. Detail fetches for a colliding name
// refuse instead of picking one.
Collision bool `json:"collision,omitempty"`
CollisionRepos []string `json:"collision_repos,omitempty"`
}
PackInfo is the identity half of a pack status: everything a list view needs without the per-resource rows.
type PackRuleFile ¶
type PackRuleFile struct {
Name string
Path string // absolute path on disk in the clone
// Rel is the path within the pack repo, recorded as provenance so a
// later install can name where the rule came from. Clone paths are
// temporary and must never be persisted.
Rel string
}
PackRuleFile is one discovered rule fragment in a pack repo.
type PackStatus ¶
type PackStatus struct {
Info PackInfo `json:"info"`
Rows []Row `json:"rows"`
NeedsAttention bool `json:"needs_attention"`
}
PackStatus is one pack's identity plus its per-resource state rows.
type PreviewOptions ¶
PreviewOptions parameterizes a read-only pack resolution.
type PreviewResource ¶
type PreviewResource struct {
Kind string `json:"kind"`
Name string `json:"name"`
Findings []skills.SecurityFinding `json:"findings,omitempty"`
// Blocking mirrors the import gate exactly: body findings always
// block; supporting-file findings block only at danger severity.
// Non-blocking findings stay visible without forcing a trust grant.
Blocking bool `json:"blocking,omitempty"`
}
PreviewResource is one resolved resource with its scan findings.
type PreviewResult ¶
type PreviewResult struct {
Pack string `json:"pack"`
Version string `json:"version,omitempty"`
Description string `json:"description,omitempty"`
Author string `json:"author,omitempty"`
Wiring bool `json:"wiring"`
Clients []string `json:"clients,omitempty"`
Skills []PreviewResource `json:"skills"`
Agents []PreviewResource `json:"agents"`
Rules []PreviewResource `json:"rules"`
Unresolved []string `json:"unresolved,omitempty"`
Warnings []string `json:"warnings,omitempty"`
}
PreviewResult is a pack manifest resolved against its repository, with nothing written: what an import would select, name by name, and which resources carry security findings.
func Preview ¶
func Preview(ctx context.Context, opts PreviewOptions) (*PreviewResult, error)
Preview clones the repository, parses the pack manifest, and resolves the selection with scan findings, writing nothing.
type RemoveDoc ¶
type RemoveDoc struct {
SchemaVersion int `json:"schema_version"`
Pack string `json:"pack"`
DryRun bool `json:"dry_run,omitempty"`
Rows []Row `json:"rows"`
Kept []string `json:"kept,omitempty"`
}
RemoveDoc is the machine-readable remove document.
type RemoveOptions ¶
type RemoveOptions struct {
Force bool
DryRun bool
// GatewayPort feeds the wiring status probe used to find pack-tagged
// wiring records.
GatewayPort int
}
RemoveOptions parameterizes a cascade removal.
type Row ¶
type Row struct {
Kind string `json:"kind"`
Name string `json:"name"`
Client string `json:"client,omitempty"`
Action string `json:"action,omitempty"`
State string `json:"state,omitempty"`
Detail string `json:"detail,omitempty"`
Remediation string `json:"remediation,omitempty"`
}
Row is one resource line in pack output.
type StatusOptions ¶
type StatusOptions struct {
// Pack restricts the report to one pack; empty means all.
Pack string
// GatewayPort feeds the wiring status probe (the caller resolves it:
// the CLI from running state, the API server from its own listener).
GatewayPort int
}
StatusOptions parameterizes a status pass.