autonomy

package
v2.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2026 License: MIT Imports: 18 Imported by: 0 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.

Documentation

Overview

Package autonomy contains the deterministic daily experiment policy. It does not launch agents, change servers, or grant permissions. Callers persist State before dispatching and enforce QuotaGate before and throughout every run.

Index

Constants

View Source
const CompletionOriginalWorkshop = CompletionSupplementDir + "/original-WORKSHOP.md"
View Source
const CompletionOverlayPolicy = "documentary-v1"
View Source
const CompletionSupplementDir = ".lectern-completion"
View Source
const GPUResearchTarget = "aiserver-amd-research-v1"

Variables

This section is empty.

Functions

func InspectCompletionTree

func InspectCompletionTree(dir string) (string, error)

InspectCompletionTree uses the same path, file and digest rules as overlay reconstruction. The caller must freeze the tree before inspecting it.

func QuotaGate

func QuotaGate(c Config, providers []ProviderUsage, required []string, now time.Time) error

QuotaGate fails closed for missing, duplicate, invalid, stale, or reset-past data. The five-minute source cache gets only a one-minute delivery allowance. This threshold is headroom, not a guarantee against provider reporting lag.

func ValidMaintenanceProposal added in v2.5.0

func ValidMaintenanceProposal(p Proposal) bool

func ValidateRequirements

func ValidateRequirements(rs []Requirement) error

Types

type Assignment

type Assignment struct {
	ReportVersion int    `json:"report_version,omitempty"`
	TaskID        int64  `json:"task_id"`
	Role          string `json:"role"`
	Round         int    `json:"round"`
	Item          int    `json:"item"`
	Step          int    `json:"step"`
	Completed     bool   `json:"completed"`
}

type BuildReport

type BuildReport struct {
	Requirements []Requirement     `json:"requirements,omitempty"`
	Outcome      string            `json:"outcome,omitempty"`
	Summary      string            `json:"summary"`
	Evidence     []string          `json:"evidence"`
	Decision     *DecisionProposal `json:"decision,omitempty"`
}

type CompletionOverlayReceipt

type CompletionOverlayReceipt struct {
	Policy         string   `json:"policy"`
	BaselineSHA256 string   `json:"baseline_sha256"`
	OverlaySHA256  string   `json:"overlay_sha256"`
	DerivedSHA256  string   `json:"derived_sha256"`
	Documents      []string `json:"documents"`
}

func ReconstructCompletionOverlay

func ReconstructCompletionOverlay(baselineDir, candidateDir, outputDir string) (receipt CompletionOverlayReceipt, err error)

ReconstructCompletionOverlay validates an exact candidate tree, then copies the trusted baseline and only validated documentary bytes into a new output tree. Inputs must be frozen controller-owned snapshots; output's parent must likewise be controller-owned. It never executes candidate content. Reviewers must not execute fenced examples or use documentation-driven test discovery. Only flat .md/.txt supplements are allowed (no scripts, configs, dependencies or fixtures). Output root is always private 0700 and is excluded from tree receipts. Generated descendants have exact policy modes independent of process umask. A changed-back production file cannot affect output: production is read only from baseline and checked against its initial digest while copying.

type Config

type Config struct {
	Enabled           bool    `json:"enabled"`
	Continuous        bool    `json:"continuous"`
	Timezone          string  `json:"timezone"`
	MorningHour       int     `json:"morning_hour"`
	ReservePercent    float64 `json:"reserve_percent"`
	MarginPercent     float64 `json:"margin_percent"`
	MaxRevisionRounds int     `json:"max_revision_rounds"`
	MaxItemsPerDay    int     `json:"max_items_per_day"`
}

func DefaultConfig

func DefaultConfig() Config

func (Config) Validate

func (c Config) Validate() error

type DecisionProposal

type DecisionProposal struct {
	Title        string   `json:"title"`
	Rationale    string   `json:"rationale"`
	Alternatives []string `json:"alternatives"`
	Risks        []string `json:"risks"`
}

type ExpertRecoveryAudit added in v2.5.0

type ExpertRecoveryAudit struct {
	SourceTaskID      int64    `json:"source_task_id"`
	ProgressKey       string   `json:"progress_key"`
	ProbeIDs          []string `json:"probe_ids"`
	FailureFamily     string   `json:"failure_family"`
	PriorAttempt      int      `json:"prior_attempt"`
	MaterialChange    bool     `json:"material_change"`
	CausalExplanation string   `json:"causal_explanation"`
	DifferentStrategy string   `json:"different_strategy"`
	StopCriterion     string   `json:"stop_criterion"`
}

ExpertRecoveryAudit is a semantic judgment bound to controller-owned probe receipts. Hashes alone do not prove causal relevance or novelty.

type ExplorationFinding

type ExplorationFinding struct {
	Opportunity string   `json:"opportunity"`
	Decision    string   `json:"decision"`
	Evidence    []string `json:"evidence"`
}

type GPUResearchLease added in v2.5.0

type GPUResearchLease struct {
	SemanticSHA      string              `json:"semantic_sha256"`
	ID               string              `json:"id"`
	Request          GPUResearchRequest  `json:"request"`
	RequestRaw       json.RawMessage     `json:"request_raw"`
	RequestSHA       string              `json:"request_sha256"`
	QualificationSHA string              `json:"qualification_sha256"`
	ReservedAt       time.Time           `json:"reserved_at"`
	StartedAt        time.Time           `json:"started_at,omitempty"`
	SettledAt        time.Time           `json:"settled_at,omitempty"`
	MaxMS            int64               `json:"max_ms"`
	StopRequested    bool                `json:"stop_requested"`
	Receipt          *GPUResearchReceipt `json:"receipt,omitempty"`
}

type GPUResearchLedger added in v2.5.0

type GPUResearchLedger struct {
	Runs map[string]*GPUResearchLease `json:"runs"`
}

func (*GPUResearchLedger) Cancel added in v2.5.0

func (l *GPUResearchLedger) Cancel(id string) error

func (*GPUResearchLedger) Record added in v2.5.0

func (l *GPUResearchLedger) Record(receipt GPUResearchReceipt) error

func (*GPUResearchLedger) RecordAt added in v2.5.0

func (l *GPUResearchLedger) RecordAt(receipt GPUResearchReceipt, now time.Time) error

func (*GPUResearchLedger) Reserve added in v2.5.0

func (l *GPUResearchLedger) Reserve(r GPUResearchRequest, runtimeKey, qualificationSHA string, now time.Time, enabled, quotaAllowed bool) (*GPUResearchLease, error)

Reserve requires an independently authenticated qualification and fresh quota decision. Caller pins ExperimentRoot to the retained assignment lineage; a worker cannot choose a new root to reset the rolling resource ledger.

func (*GPUResearchLedger) Start added in v2.5.0

func (l *GPUResearchLedger) Start(id string, now time.Time, enabled, quotaAllowed bool) error

type GPUResearchReceipt added in v2.5.0

type GPUResearchReceipt struct {
	RunID      string `json:"run_id"`
	RequestSHA string `json:"request_sha256"`
	State      string `json:"state"`
	// nil means the trusted supervisor could not establish whether execution
	// started; this consumes the full reserved profile rather than freeing budget.
	Executed         *bool  `json:"executed"`
	ChargedMS        int64  `json:"charged_ms"`
	ElapsedMS        int64  `json:"elapsed_ms,omitempty"`
	ExitCode         *int   `json:"exit_code,omitempty"`
	OutputSHA        string `json:"output_sha256,omitempty"`
	CleanupConfirmed bool   `json:"cleanup_confirmed"`
	ReceiptSHA       string `json:"receipt_sha256"`
}

type GPUResearchRequest added in v2.5.0

type GPUResearchRequest struct {
	SchemaVersion    int      `json:"schema_version"`
	OwnerJob         string   `json:"owner_job"`
	OwnerTask        int64    `json:"owner_task"`
	Role             string   `json:"role"`
	ExperimentRoot   string   `json:"experiment_root"`
	SourceJob        string   `json:"source_job"`
	SourceSnapshotID string   `json:"source_snapshot_id"`
	SourceTreeSHA    string   `json:"source_tree_sha256"`
	SourceArchiveSHA string   `json:"source_archive_sha256"`
	AdmissionSHA     string   `json:"admission_sha256"`
	AcceptanceSHA    string   `json:"acceptance_sha256"`
	Target           string   `json:"target"`
	RuntimeKey       string   `json:"runtime_key"`
	QualificationSHA string   `json:"qualification_sha256"`
	Profile          string   `json:"profile"`
	Script           string   `json:"script"`
	Argv             []string `json:"argv"`
	Trial            int      `json:"trial"`
}

func (GPUResearchRequest) Validate added in v2.5.0

func (r GPUResearchRequest) Validate() error

type MaintenanceLimits added in v2.5.0

type MaintenanceLimits struct {
	CPUPercent  int   `json:"cpu_quota_percent"`
	MemoryBytes int64 `json:"memory_max_bytes"`
	Tasks       int   `json:"tasks_max"`
}

type MaintenanceProposal added in v2.5.0

type MaintenanceProposal struct {
	TargetID      string            `json:"target_id"`
	ServiceID     string            `json:"service_id"`
	ObservationID string            `json:"observation_id"`
	Limits        MaintenanceLimits `json:"limits"`
	Pin           string            `json:"pin,omitempty"`
}

type NoWorkBlocker

type NoWorkBlocker struct {
	Key         string   `json:"key"`
	Requirement string   `json:"requirement"`
	Evidence    []string `json:"evidence"`
}

NoWorkReport makes declining work an auditable decision, not an implicit shortcut around the two independent plan auditors. Evidence remains claims to inspect; structure alone never proves novelty, feasibility or exhaustion.

type NoWorkReport

type NoWorkReport struct {
	Reason      string               `json:"reason"`
	Blockers    []NoWorkBlocker      `json:"blockers"`
	Exploration []ExplorationFinding `json:"exploration"`
}

type Phase

type Phase string
const (
	Plan          Phase = "plan"
	Audit         Phase = "audit"
	Revise        Phase = "revise"
	Build         Phase = "build"
	DecisionAudit Phase = "decision_audit"
	Review        Phase = "review"
	Complete      Phase = "complete"
	Paused        Phase = "paused"
)

type PlanReport

type PlanReport struct {
	Requirements []Requirement `json:"requirements,omitempty"`
	NoWork       *NoWorkReport `json:"no_work,omitempty"`
	Items        []Proposal    `json:"items"`
	Backlog      []Proposal    `json:"backlog,omitempty"`
}

type Proposal

type Proposal struct {
	Maintenance                *MaintenanceProposal `json:"maintenance,omitempty"`
	IntegrationTaskID          int64                `json:"integration_task_id,omitempty"`
	IntegrationPin             string               `json:"integration_pin,omitempty"`
	IntegrationPaths           []string             `json:"integration_paths,omitempty"`
	SourceIntegrationID        string               `json:"source_integration_id,omitempty"`
	ExpertRecoveryTaskID       int64                `json:"expert_recovery_task_id,omitempty"`
	ExpertProgressKey          string               `json:"expert_progress_key,omitempty"`
	DiagnoseTaskID             int64                `json:"diagnose_task_id,omitempty"`
	EnvironmentDiagnosisTaskID int64                `json:"environment_diagnosis_task_id,omitempty"`
	DiagnoseRequirement        string               `json:"diagnose_requirement,omitempty"`
	DocumentationTaskID        int64                `json:"documentation_task_id,omitempty"`
	ProjectID                  int64                `json:"project_id"`
	SourceRevision             string               `json:"source_revision,omitempty"`
	RepairTaskID               int64                `json:"repair_task_id,omitempty"`
	ContinueTaskID             int64                `json:"continue_task_id,omitempty"`
	Title                      string               `json:"title"`
	Why                        string               `json:"why"`
	Acceptance                 []string             `json:"acceptance"`
	Ambition                   string               `json:"ambition,omitempty"`
	Novelty                    string               `json:"novelty,omitempty"`
	Score                      int                  `json:"score,omitempty"`
	Expert                     bool                 `json:"expert,omitempty"`
}

type ProviderUsage

type ProviderUsage struct {
	ID        string        `json:"id"`
	Status    string        `json:"status"`
	UpdatedAt *float64      `json:"updated_at"`
	Buckets   []UsageBucket `json:"buckets"`
}

type Requirement

type Requirement struct {
	Capability    string   `json:"capability"`
	SchemaVersion int      `json:"schema_version"`
	Requirements  []string `json:"requirements,omitempty"`
	Imports       []string `json:"imports,omitempty"`
	Modules       []string `json:"modules,omitempty"`
	Binaries      []string `json:"binaries,omitempty"`
	PackageJSON   string   `json:"package_json,omitempty"`
	PackageLock   string   `json:"package_lock,omitempty"`
	Condition     string   `json:"condition"`
	Evidence      []string `json:"evidence"`
}

Requirement is an observation, never permission to execute a remediation. Identities, providers, paths and proof are supplied by the controller/runner.

type State

type State struct {
	NoWork         *NoWorkReport             `json:"no_work,omitempty"`
	Date           string                    `json:"date"`
	Phase          Phase                     `json:"phase"`
	ResumePhase    Phase                     `json:"resume_phase,omitempty"`
	Reason         string                    `json:"reason,omitempty"`
	Revision       int                       `json:"revision"`
	Cycle          int                       `json:"cycle"`
	Item           int                       `json:"item"`
	Step           int                       `json:"step"`
	Items          []Proposal                `json:"items"`
	Backlog        []Proposal                `json:"backlog,omitempty"`
	Decision       *DecisionProposal         `json:"decision,omitempty"`
	DecisionAudits map[string]Verdict        `json:"decision_audits,omitempty"`
	Assignments    []Assignment              `json:"assignments"`
	Audits         map[string]Verdict        `json:"audits"`
	Reports        map[int64]json.RawMessage `json:"reports"`
}

func NewState

func NewState(date string) (*State, error)

func (*State) ActiveTaskIDs

func (s *State) ActiveTaskIDs() []int64

func (*State) ApplyReport

func (s *State) ApplyReport(c Config, id int64, raw []byte) error

ApplyReport accepts only the expected, owned task and validates the entire report before changing state. Repeated delivery is rejected without mutation.

func (*State) NeededRoles

func (s *State) NeededRoles() []string

NeededRoles is a stable dispatch plan. RegisterTask must be persisted before dispatch; a restart then sees the same outstanding owned task IDs.

func (*State) Pause

func (s *State) Pause(reason string)

func (*State) RegisterTask

func (s *State) RegisterTask(role string, id int64) error

func (*State) Resume

func (s *State) Resume(c Config, providers []ProviderUsage, required []string, now time.Time) error

type Usage

type Usage struct {
	Providers      []ProviderUsage `json:"providers"`
	RefreshSeconds int             `json:"refresh_seconds"`
}

Usage matches homelab-api /api/agent-usage's normalized response. Pointers distinguish absent measurements from legitimate zeroes; all advertised windows, including model-specific ones, constrain dispatch.

type UsageBucket

type UsageBucket struct {
	ID      string        `json:"id"`
	Windows []UsageWindow `json:"windows"`
}

type UsageWindow

type UsageWindow struct {
	Label            string   `json:"label"`
	UsedPercent      *float64 `json:"used_percent"`
	RemainingPercent *float64 `json:"remaining_percent"`
	ResetsAt         *float64 `json:"resets_at"`
	ResetPassed      bool     `json:"reset_passed"`
	ResetState       string   `json:"reset_state,omitempty"`
}

type Verdict

type Verdict struct {
	ExpertRecovery []ExpertRecoveryAudit `json:"expert_recovery,omitempty"`
	Requirements   []Requirement         `json:"requirements,omitempty"`
	Outcome        string                `json:"outcome,omitempty"`
	Approve        *bool                 `json:"approve"`
	Reason         string                `json:"reason"`
}

func (Verdict) AcceptsWork

func (v Verdict) AcceptsWork() bool

Legacy reports remain interpretable; explicit non-completion never promotes.

Jump to

Keyboard shortcuts

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