Documentation
¶
Overview ¶
Package nano implements AntiFlock's deterministic, I/O-free conformance runtime for Nano v0.1. It follows DBarr3/Nano PR #1 without copying its Python implementation. Programs can only produce typed intents; this package has no filesystem, process, network, clock, randomness, or host mutation capability.
Index ¶
- Constants
- Variables
- func AdmitWatchdog(program Program) error
- func BindingDigest(bindingID BindingID) (string, error)
- func Evaluate(program Program, frame Frame, cursor Cursor, limits Limits) (EvaluationResult, Cursor, error)
- type AdmissionRequest
- type BindingID
- type Condition
- type Cursor
- type CursorStore
- type EmittedIntent
- type EvaluationResult
- type FindingContext
- type FindingRunResult
- type Frame
- type Intent
- type Limits
- type MemoryCursorStore
- type OpenFindingRunResult
- type Program
- type Registry
- func (registry *Registry) Admit(ctx context.Context, request AdmissionRequest) (storage.NanoWatchdogProgramRecord, error)
- func (registry *Registry) List(ctx context.Context, nodeID string) ([]storage.NanoWatchdogProgramRecord, error)
- func (registry *Registry) RunFinding(ctx context.Context, programID string, finding FindingContext) (RunResult, error)
- func (registry *Registry) RunOpenFindings(ctx context.Context, programID string, findings []FindingContext) (OpenFindingRunResult, error)
- type RunResult
- type Runner
- type RunnerConfig
- type Schedule
- type SecureActionProposal
- type StorageCursorStore
- type SyntaxError
- type TraceEntry
Constants ¶
const ( IRVersion = "0.1.0" UpstreamCommit = "40f697ba9020a4d4fee985406779c0d90ea2d6f4" )
Variables ¶
var ( ErrLimitExceeded = errors.New("nano resource limit exceeded") ErrAdmissionDenied = errors.New("nano program is outside the AntiFlock intent profile") ErrInvalidFrame = errors.New("nano evaluation frame is invalid") ErrInstructionLimit = errors.New("nano instruction budget exhausted") )
var DefaultLimits = Limits{
MaxSourceBytes: 64 << 10, MaxTokens: 4096, MaxAgents: 16,
MaxConditions: 64, MaxIntents: 16, MaxSignals: 128,
MaxTimestamps: 1024, MaxInstructions: 8192, MaxOutputs: 128,
}
Functions ¶
func AdmitWatchdog ¶
func BindingDigest ¶
Types ¶
type AdmissionRequest ¶
type BindingID ¶
type BindingID string
const ( BindingScramblerSimulation BindingID = "scrambler-simulation-v1" BindingFixtureShodan BindingID = "fixture-shodan-query-v1" BindingFixtureBroker BindingID = "fixture-broker-query-v1" BindingFixturePaste BindingID = "fixture-paste-query-v1" BindingCountermeasurePlan BindingID = "countermeasure-plan-v1" )
type CursorStore ¶
type CursorStore interface {
Load(ctx context.Context, programDigest, nodeID string) (Cursor, error)
CompareAndSwap(ctx context.Context, programDigest, nodeID string, previous, next Cursor) (bool, error)
}
CursorStore persists a per-program, per-node schedule cursor. Production runners must supply durable storage before handling real findings.
type EmittedIntent ¶
type EvaluationResult ¶
type EvaluationResult struct {
Intents []EmittedIntent `json:"intents"`
Trace []TraceEntry `json:"trace"`
Instructions int `json:"instructions"`
}
type FindingContext ¶
type FindingRunResult ¶
type FindingRunResult struct {
FindingID string `json:"findingId"`
Result RunResult `json:"result"`
}
FindingRunResult binds a proposal-only result to the Core finding that supplied the host-owned input. It contains neither raw evidence nor a caller-selected signal.
type Frame ¶
func FrameForFinding ¶
func FrameForFinding(finding FindingContext) (Frame, string, error)
type MemoryCursorStore ¶
type MemoryCursorStore struct {
// contains filtered or unexported fields
}
MemoryCursorStore is for deterministic tests and demos. It is not durable.
func NewMemoryCursorStore ¶
func NewMemoryCursorStore() *MemoryCursorStore
func (*MemoryCursorStore) CompareAndSwap ¶
type OpenFindingRunResult ¶
type OpenFindingRunResult struct {
ProgramID string `json:"programId"`
NodeID string `json:"nodeId"`
EvaluatedCount int `json:"evaluatedCount"`
SkippedStale int `json:"skippedStale"`
Results []FindingRunResult `json:"results"`
}
OpenFindingRunResult is a bounded, deterministic Core-owned watchdog pass. It is operator-invoked and proposal-only; it neither authorizes nor executes a proposed action.
type Program ¶
type Program struct {
Name string
Schedule *Schedule
Conditions []Condition
Intents []Intent
Agents []string
}
func (Program) CanonicalJSON ¶
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry admits immutable Nano source into the constrained watchdog profile. It has no provider, process, network, or action-execution capability.
func NewRegistry ¶
func (*Registry) Admit ¶
func (registry *Registry) Admit(ctx context.Context, request AdmissionRequest) (storage.NanoWatchdogProgramRecord, error)
func (*Registry) RunFinding ¶
func (*Registry) RunOpenFindings ¶
func (registry *Registry) RunOpenFindings(ctx context.Context, programID string, findings []FindingContext) (OpenFindingRunResult, error)
RunOpenFindings evaluates an admitted program against already-created Core findings. Callers cannot inject a signal: the server builds FindingContext values from the current OPEN finding projection. Inputs are sorted and capped before cursor advancement so one request has deterministic work bounds.
type RunResult ¶
type RunResult struct {
ProgramDigest string `json:"programDigest"`
InputDigest string `json:"inputDigest"`
Evaluation EvaluationResult `json:"evaluation"`
Proposals []SecureActionProposal `json:"proposals"`
}
RunResult is the stable, proposal-only watchdog response. It never signals authorization or execution; a separate operator-approved action flow remains required.
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
Runner evaluates one admitted program. It cannot fetch data, contact a provider, mutate a host, or submit a proposal to the action gate.
func NewRunner ¶
func NewRunner(config RunnerConfig) (*Runner, error)
func (*Runner) RunFinding ¶
RunFinding saves the cursor before returning proposals so a failed persist never exposes a proposal that can refire after a process restart.
type RunnerConfig ¶
type SecureActionProposal ¶
type SecureActionProposal struct {
ID string `json:"id"`
ApplicationID string `json:"applicationId"`
NodeID string `json:"nodeId"`
ActionType string `json:"actionType"`
Destinations []string `json:"destinations"`
DataClass string `json:"dataClass"`
Sensitivity string `json:"sensitivity"`
Deadline string `json:"deadline"`
OperationID string `json:"operationId"`
BindingID BindingID `json:"bindingId"`
ProgramDigest string `json:"programDigest"`
InputDigest string `json:"inputDigest"`
}
SecureActionProposal is the only outward value Nano can produce. It mirrors the existing gate request but carries no payload and performs no action.
func BuildProposals ¶
func BuildProposals( result EvaluationResult, bindingID BindingID, programDigest, inputDigest, nodeID, deadline string, ) ([]SecureActionProposal, error)
type StorageCursorStore ¶
type StorageCursorStore struct {
// contains filtered or unexported fields
}
StorageCursorStore adapts Core's SQLite store to the watchdog runner. The runner can therefore survive restarts without admitting mutable programs or persisting raw findings.
func NewStorageCursorStore ¶
func (*StorageCursorStore) CompareAndSwap ¶
type SyntaxError ¶
func (*SyntaxError) Error ¶
func (err *SyntaxError) Error() string