presets

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 15 Imported by: 1

Documentation

Overview

Package presets holds ready-made safety configurations a host seeds for each of its tenants. A Bundle is a set of primitives, safety profiles and org-level policies; Seed writes the rows a tenant lacks and keeps every row it already has, so a tenant's own edits survive a re-seed.

Index

Constants

View Source
const (
	InfraAgentInput  = "infra-agent-input"
	InfraAgentOutput = "infra-agent-output"
	InfraAgentTools  = "infra-agent-tools"
)

The InfraAgent safety profiles, one per way an infra agent host uses shield: InfraAgentInput for untrusted content entering the model's context (scan.Input.Untrusted with a Source), InfraAgentOutput for text the agent sends out, InfraAgentTools for proposed tool calls.

View Source
const (
	RiskRead                = "read"
	RiskChange              = "change"
	RiskDeployNonProduction = "deploy_nonproduction"
	RiskPromoteProduction   = "promote_production"
	RiskDestroyProduction   = "destroy_production"
	RiskSecretOrExternal    = "secret_or_external" // #nosec G101 -- a risk class name, not a credential
)

Risk classes the InfraAgent tool profile understands. Hosts put one in ToolCallInput.RiskClass.

The tools profile blocks a call with no class, asks a person to approve RiskDestroyProduction and RiskSecretOrExternal, and allows the rest unless the arguments carry a secret or an instruction. RiskPromoteProduction is allowed on purpose: the host's own autonomy gate decides it.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bundle

type Bundle struct {
	Name       string
	Instincts  []*instinct.Instinct
	Awareness  []*awareness.Awareness
	Boundaries []*boundary.Boundary
	Values     []*values.Values
	Judgments  []*judgment.Judgment
	Reflexes   []*reflex.Reflex
	Profiles   []*profile.SafetyProfile
	Policies   []*policy.Policy // org level; Seed sets ScopeKey to the tenant
}

Bundle is a preset: the rows Seed writes for one tenant. Rows carry no ID, app or tenant; Seed sets them on its own copies.

func InfraAgent

func InfraAgent() Bundle

InfraAgent returns the safety preset for an infrastructure agent that reads commit messages, build logs, READMEs and issue bodies, writes issues and notifications, and proposes tool calls. Every call builds fresh rows, so changing one never changes another call's.

Instruction-shaped text is removed line by line. Secrets are redacted on input and tool calls, and block output: text already on its way out may not be rewritable (a streamed reply, say), and a credential must not leave either way. Personal data is redacted on input and output. Output also flags destructive commands, input flags a strong injection signal, and tool calls follow the risk classes above.

func (Bundle) Seed

func (b Bundle) Seed(ctx context.Context, s store.Store, tenantID, appID string) (SeedReport, error)

Seed creates every row the tenant lacks (by name within app and tenant) and leaves existing rows untouched, so a workspace's edits survive. It puts the tenant on ctx itself. Empty tenantID is shield.ErrTenantRequired.

Primitives go first, then profiles, then policies, so a profile is never stored before what it references. Each policy is written at org level with ScopeKey set to tenantID, the only kind of policy a tenant may own.

Seed is safe to run from several processes at once for one tenant: names are unique per app and tenant (policies per scope key), so when two calls race to create the same row one create fails, and Seed counts a row that exists once its create failed as kept rather than returning the error. Seed does not invalidate any engine's profile cache; a tenant that had no profile before has nothing cached.

type SeedReport

type SeedReport struct {
	Created []string
	Kept    []string
}

SeedReport lists the rows one Seed call wrote and the rows it found already there, each as "<kind>/<name>": instinct, awareness, boundary, values, judgment, reflex, profile or policy.

Jump to

Keyboard shortcuts

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