authority

package
v1.13.11 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2026 License: AGPL-3.0 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 authority defines tenant-root-signed key distribution state used by local Pilot enforcement points.

Index

Constants

View Source
const (
	SchemaVersion      uint16 = 1
	TrustDomain               = "pilot-trust-bundle-v1"
	MaxBundleTTL              = 7 * 24 * time.Hour
	MaxBundleKeys             = 256
	MaxBundleClockSkew        = time.Minute
)
View Source
const (
	FleetCommandVersion   uint16 = 1 // accepted legacy wire format
	FleetCommandVersionV2 uint16 = 2
	FleetReportVersion    uint16 = 1
	FleetReportVersionV2  uint16 = 2
	FleetCommandDomain           = "pilot-fleet-command-v1"
	FleetCommandDomainV2         = "pilot-fleet-command-v2"
	FleetReportDomain            = "pilot-fleet-report-v1"
	FleetReportDomainV2          = "pilot-fleet-report-v2"
	FleetResultDomain            = "pilot-fleet-result-v1"
	MaxFleetCommandTTL           = 24 * time.Hour
	MaxFleetTargets              = 10_000
)
View Source
const (
	FleetAppsVersion uint16 = 1

	// FleetAppsDocumentPath is the desired-app-set document's path relative to
	// the node's fleet state root. It is delivered by an ordinary signed
	// FleetStateMutation: apps deliberately introduce no new wire protocol and
	// no new command vocabulary, so a node that already accepts state
	// mutations needs no protocol upgrade to accept apps.
	FleetAppsDocumentPath = "apps.json"

	MaxFleetAppsEntries   = 64
	MaxFleetAppGrants     = 64
	MaxFleetAppReasonSize = 256
)
View Source
const (
	FleetAppInstalled    = "installed"
	FleetAppPending      = "pending"
	FleetAppFailed       = "failed"
	FleetAppGrantBlocked = "grant_blocked"
)
View Source
const (
	FleetNodeControlVersion uint16 = 1
	FleetActivityVersion    uint16 = 1
	FleetNodeControlDomain         = "pilot-fleet-node-control-v1"
	FleetActivityDomain            = "pilot-fleet-activity-v1"
	FleetControlAckVersion  uint16 = 1
	FleetControlAckDomain          = "pilot-fleet-control-ack-v1"
	MaxFleetControlTags            = 16
)
View Source
const (
	FleetControlApplied          = "applied"
	FleetControlPartiallyApplied = "partially_applied"
	FleetControlRejected         = "rejected"
)
View Source
const (
	FleetStateVersion               uint16 = 1
	FleetStateSnapshotDomain               = "pilot-fleet-state-snapshot-v1"
	FleetStateMutationDomain               = "pilot-fleet-state-mutation-v1"
	FleetStateMutationResultDomain         = "pilot-fleet-state-mutation-result-v1"
	MaxFleetStateEntries                   = 10_000
	MaxFleetStateVisibleBytes              = 8 << 20
	MaxFleetStateMutationBytes             = 4 << 20
	MaxFleetStateMutationOperations        = 256
)
View Source
const (
	PolicyDomain          = "pilot-policy-bundle-v1"
	MaxPolicyPayloadBytes = 1 << 20
	MaxPolicyTTL          = 7 * 24 * time.Hour
	PolicyFailureDeny     = "deny"
)
View Source
const (
	PolicyPublicationDomain = "pilot-policy-publication-v1"
	PolicyAckDomain         = "pilot-policy-ack-v1"
	PolicyActivationDomain  = "pilot-policy-activation-v1"
	PolicyWithdrawalDomain  = "pilot-policy-withdrawal-v1"
	MaxRolloutTargets       = 10_000
)
View Source
const FleetAppsReportPath = "apps-observed.json"

FleetAppsReportPath is where the node publishes its inventory. It is deliberately distinct from FleetAppsDocumentPath: the authority owns the desired set and the node owns the observed set, so neither overwrites the other and drift between them is visible rather than resolved silently.

Variables

View Source
var (
	ErrPersistence              = errors.New("authority: durable state unavailable")
	ErrStateConflict            = errors.New("authority: conflicting durable state")
	ErrUnknownPolicyPublication = errors.New("authority: unknown policy publication")
)

Functions

func GrantsCovered

func GrantsCovered(declared, accepted []FleetAppGrant) bool

GrantsCovered reports whether every grant an installed manifest declares is covered by what the administrator accepted. The node calls this before it lets the supervisor start an app; the authority calls it to show drift in the console. Both must agree, so the comparison lives here rather than in either caller.

Types

type AuthorityKey

type AuthorityKey struct {
	KeyID     string     `json:"key_id"`
	AgentID   string     `json:"agent_id,omitempty"`
	PublicKey string     `json:"public_key"`
	Usages    []KeyUsage `json:"usages"`
	NotBefore int64      `json:"not_before"`
	ExpiresAt int64      `json:"expires_at"`
}

AuthorityKey is an online key delegated by the tenant root. Intent and receipt keys are scoped to one agent; authority-wide issuer keys leave AgentID empty.

type FleetActivity

type FleetActivity struct {
	Version        uint16                     `json:"version"`
	ID             string                     `json:"id"`
	TenantID       string                     `json:"tenant_id"`
	AgentID        string                     `json:"agent_id"`
	Action         string                     `json:"action"`
	ResourceClass  string                     `json:"resource_class"`
	Risk           decision.RiskClass         `json:"risk"`
	Outcome        decision.Outcome           `json:"outcome"`
	Result         decision.EnforcementResult `json:"result"`
	IntentHash     string                     `json:"intent_hash"`
	DecisionID     string                     `json:"decision_id"`
	DurationMillis int64                      `json:"duration_millis"`
	ObservedAt     int64                      `json:"observed_at"`
	KeyID          string                     `json:"key_id"`
	Signature      string                     `json:"signature"`
}

FleetActivity is privacy-bounded, signed operational telemetry for a governed action. It carries the action and coarse resource class but never a resource identifier, destination, prompt, payload, path, or environment value. Signed receipts remain the authoritative execution evidence.

func NewFleetActivity

func NewFleetActivity(intent decision.Intent, result decision.Decision, enforcement decision.EnforcementResult, duration time.Duration, keyID string, observedAt int64) (FleetActivity, error)

func (FleetActivity) Canonical

func (activity FleetActivity) Canonical() ([]byte, error)

func (*FleetActivity) Sign

func (activity *FleetActivity) Sign(privateKey ed25519.PrivateKey) error

func (FleetActivity) Validate

func (activity FleetActivity) Validate() error

func (FleetActivity) Verify

func (activity FleetActivity) Verify(publicKey ed25519.PublicKey, now time.Time) error

type FleetAppGrant

type FleetAppGrant struct {
	Cap    string `json:"cap"`
	Target string `json:"target"`
}

FleetAppGrant is one manifest-declared capability that a tenant administrator accepted on the fleet's behalf. It carries no authority of its own: the node re-reads the installed manifest and refuses to start an app whose declared grants are not covered by this accepted set, so a catalogue that later widens an app's grants fails closed instead of silently gaining capability across the fleet.

func (FleetAppGrant) Validate

func (grant FleetAppGrant) Validate() error

type FleetAppSpec

type FleetAppSpec struct {
	ID             string          `json:"id"`
	Version        string          `json:"version"`
	AcceptedGrants []FleetAppGrant `json:"accepted_grants"`
	ApprovedBy     string          `json:"approved_by"`
	ApprovedAt     int64           `json:"approved_at"`
}

FleetAppSpec is one desired app. Version pins what the node resolves out of the publisher-signed catalogue; the bundle's per-platform sha256 stays in that catalogue rather than here, because one desired-state document is distributed unchanged to a mixed-platform fleet.

func (FleetAppSpec) Validate

func (spec FleetAppSpec) Validate() error

type FleetAppState

type FleetAppState struct {
	ID             string          `json:"id"`
	Version        string          `json:"version"`
	Status         string          `json:"status"`
	Detail         string          `json:"detail,omitempty"`
	BinarySHA256   string          `json:"binary_sha256,omitempty"`
	DeclaredGrants []FleetAppGrant `json:"declared_grants,omitempty"`
	ObservedAt     int64           `json:"observed_at"`
}

FleetAppState is one app as the node actually found it, reported back through the ordinary fleet state mirror rather than a new channel.

DeclaredGrants is what the installed bundle's manifest actually asks for. The catalogue does not publish grants — they exist only inside the signed bundle — so the fleet is the only truthful source for them. A node that installs an app the tenant has not yet reviewed reports the grants here and holds the app unstarted, which lets the console show an operator the real capability list before anyone accepts it.

func (FleetAppState) Validate

func (state FleetAppState) Validate() error

type FleetAppsDocument

type FleetAppsDocument struct {
	Version  uint16         `json:"version"`
	TenantID string         `json:"tenant_id"`
	AgentID  string         `json:"agent_id"`
	Desired  []FleetAppSpec `json:"desired"`
	Reason   string         `json:"reason"`
	IssuedAt int64          `json:"issued_at"`
}

FleetAppsDocument is the complete desired app set for one node. It is declarative on purpose: the node reconciles toward it and is free to be offline, restarted, or rebuilt from an empty disk in between. A container fleet member whose filesystem is discarded on restart converges to the same set without the authority replaying anything.

func (*FleetAppsDocument) Normalize

func (document *FleetAppsDocument) Normalize()

Normalize orders the desired set so that re-approving an unchanged fleet produces a byte-identical document. Without this the console would queue a mutation, and the node would report a new revision, every time an operator opened the page and pressed save with nothing changed.

func (FleetAppsDocument) Validate

func (document FleetAppsDocument) Validate() error

type FleetAppsReport

type FleetAppsReport struct {
	Version    uint16          `json:"version"`
	TenantID   string          `json:"tenant_id"`
	AgentID    string          `json:"agent_id"`
	Apps       []FleetAppState `json:"apps"`
	ObservedAt int64           `json:"observed_at"`
}

FleetAppsReport is the node-authored inventory document. The node writes it into its own state tree, so it arrives through the existing signed snapshot and needs no separate endpoint, storage, or retention policy.

func (FleetAppsReport) Validate

func (report FleetAppsReport) Validate() error

type FleetCommand

type FleetCommand struct {
	Version   uint16           `json:"version"`
	ID        string           `json:"id"`
	TenantID  string           `json:"tenant_id"`
	Targets   []string         `json:"targets"`
	Kind      FleetCommandKind `json:"kind"`
	Reason    string           `json:"reason,omitempty"`
	IssuedAt  int64            `json:"issued_at"`
	ExpiresAt int64            `json:"expires_at"`
	KeyID     string           `json:"key_id"`
	Signature string           `json:"signature"`
}

FleetCommand is a short-lived command addressed to one or more enrolled agent identities. The authority stores and distributes it but does not infer authority from transport or UI identity: the operator supplies a separately signed artifact.

func (FleetCommand) Canonical

func (command FleetCommand) Canonical() ([]byte, error)

func (*FleetCommand) Sign

func (command *FleetCommand) Sign(privateKey ed25519.PrivateKey) error

func (FleetCommand) TargetsAgent

func (command FleetCommand) TargetsAgent(agentID string) bool

func (FleetCommand) Validate

func (command FleetCommand) Validate() error

func (FleetCommand) Verify

func (command FleetCommand) Verify(publicKey ed25519.PublicKey, now time.Time) error

type FleetCommandKind

type FleetCommandKind string

FleetCommandKind is deliberately a small, non-shell command vocabulary. A node executes a command only after checking this separately signed object against its root-pinned authority trust.

const (
	FleetCommandRefreshPolicy   FleetCommandKind = "refresh_policy"
	FleetCommandExportReceipts  FleetCommandKind = "export_receipts"
	FleetCommandReloadControl   FleetCommandKind = "reload_control"
	FleetCommandSyncState       FleetCommandKind = "sync_state"
	FleetCommandDiagnostics     FleetCommandKind = "collect_diagnostics"
	FleetCommandRestartRuntime  FleetCommandKind = "restart_runtime"
	FleetCommandShutdownRuntime FleetCommandKind = "shutdown_runtime"
)

type FleetCommandResult

type FleetCommandResult struct {
	Version    uint16 `json:"version"`
	TenantID   string `json:"tenant_id"`
	AgentID    string `json:"agent_id"`
	CommandID  string `json:"command_id"`
	Outcome    string `json:"outcome"`
	DetailCode string `json:"detail_code,omitempty"`
	ObservedAt int64  `json:"observed_at"`
	KeyID      string `json:"key_id"`
	Signature  string `json:"signature"`
}

FleetCommandResult records the bounded result of one allowlisted command. DetailCode is intentionally an identifier rather than a remote error string.

func (FleetCommandResult) Canonical

func (result FleetCommandResult) Canonical() ([]byte, error)

func (*FleetCommandResult) Sign

func (result *FleetCommandResult) Sign(privateKey ed25519.PrivateKey) error

func (FleetCommandResult) Validate

func (result FleetCommandResult) Validate() error

func (FleetCommandResult) Verify

func (result FleetCommandResult) Verify(publicKey ed25519.PublicKey, now time.Time) error

type FleetControlAcknowledgement

type FleetControlAcknowledgement struct {
	Version               uint16 `json:"version"`
	TenantID              string `json:"tenant_id"`
	AgentID               string `json:"agent_id"`
	ControlRevision       uint64 `json:"control_revision"`
	Status                string `json:"status"`
	DetailCode            string `json:"detail_code,omitempty"`
	AppliedPolicyRevision uint64 `json:"applied_policy_revision,omitempty"`
	RunningVersion        string `json:"running_version,omitempty"`
	Quarantined           bool   `json:"quarantined"`
	ObservedAt            int64  `json:"observed_at"`
	KeyID                 string `json:"key_id"`
	Signature             string `json:"signature"`
}

FleetControlAcknowledgement is signed by the enrolled node after it has reconciled one exact desired-state revision. It distinguishes a published control from a control the workload actually verified and applied.

func (FleetControlAcknowledgement) Canonical

func (ack FleetControlAcknowledgement) Canonical() ([]byte, error)

func (*FleetControlAcknowledgement) Sign

func (ack *FleetControlAcknowledgement) Sign(privateKey ed25519.PrivateKey) error

func (FleetControlAcknowledgement) Validate

func (ack FleetControlAcknowledgement) Validate() error

func (FleetControlAcknowledgement) Verify

func (ack FleetControlAcknowledgement) Verify(publicKey ed25519.PublicKey, now time.Time) error

type FleetControlAuthorizer

type FleetControlAuthorizer struct {
	Base        decision.Authorizer
	Quarantined func(string, string) bool
}

FleetControlAuthorizer applies the cached signed quarantine ceiling after deterministic/semantic policy evaluation. A quarantine can only narrow authority; a missing control record leaves ordinary open-agent behavior unchanged.

func (FleetControlAuthorizer) Authorize

func (authorizer FleetControlAuthorizer) Authorize(ctx context.Context, intent decision.Intent) (decision.Decision, error)

func (FleetControlAuthorizer) AuthorizeDisclosure

func (authorizer FleetControlAuthorizer) AuthorizeDisclosure(ctx context.Context, intent decision.Intent, disclosure decision.DisclosureBinding) (decision.Decision, error)

func (FleetControlAuthorizer) AuthorizeFederatedContent

func (authorizer FleetControlAuthorizer) AuthorizeFederatedContent(ctx context.Context, intent decision.Intent, content decision.FederatedContent) (decision.Decision, error)

AuthorizeFederatedContent preserves the hosted full-content evaluation path through the fleet quarantine ceiling. Wrapping an evaluator must never erase a capability required by the account federation ingress.

type FleetNodeControl

type FleetNodeControl struct {
	Version               uint16   `json:"version"`
	TenantID              string   `json:"tenant_id"`
	AgentID               string   `json:"agent_id"`
	Revision              uint64   `json:"revision"`
	Group                 string   `json:"group,omitempty"`
	Tags                  []string `json:"tags,omitempty"`
	DesiredVersion        string   `json:"desired_version,omitempty"`
	DesiredPolicyRevision uint64   `json:"desired_policy_revision,omitempty"`
	Quarantined           bool     `json:"quarantined"`
	Reason                string   `json:"reason"`
	IssuedAt              int64    `json:"issued_at"`
	KeyID                 string   `json:"key_id"`
	Signature             string   `json:"signature"`
}

FleetNodeControl is the signed desired state for one enrolled node. It is a deliberately small replacement for arbitrary remote shell access: operators can organize a node, declare the expected runtime and policy revision, or quarantine it. The node and the authority both verify this object before treating it as current control state.

func (FleetNodeControl) Canonical

func (control FleetNodeControl) Canonical() ([]byte, error)

func (*FleetNodeControl) Sign

func (control *FleetNodeControl) Sign(privateKey ed25519.PrivateKey) error

func (FleetNodeControl) Validate

func (control FleetNodeControl) Validate() error

func (FleetNodeControl) Verify

func (control FleetNodeControl) Verify(publicKey ed25519.PublicKey, now time.Time) error

type FleetNodeReport

type FleetNodeReport struct {
	Version          uint16                             `json:"version"`
	TenantID         string                             `json:"tenant_id"`
	AgentID          string                             `json:"agent_id"`
	NodeID           uint32                             `json:"node_id"`
	AgentVersion     string                             `json:"agent_version,omitempty"`
	HarnessID        string                             `json:"harness_id,omitempty"`
	HarnessVersion   string                             `json:"harness_version,omitempty"`
	ConnectorVersion string                             `json:"connector_version,omitempty"`
	Capabilities     []actionregistry.AdapterCapability `json:"capabilities,omitempty"`
	ObservedAt       int64                              `json:"observed_at"`
	UptimeSeconds    uint64                             `json:"uptime_seconds"`
	Connections      uint32                             `json:"connections"`
	Peers            uint32                             `json:"peers"`
	EncryptedPeers   uint32                             `json:"encrypted_peers"`
	BytesSent        uint64                             `json:"bytes_sent"`
	BytesReceived    uint64                             `json:"bytes_received"`
	PolicyRevision   uint64                             `json:"policy_revision"`
	KeyID            string                             `json:"key_id"`
	Signature        string                             `json:"signature"`
}

FleetNodeReport contains the bounded, non-sensitive liveness information a daemon elects to make visible to its tenant operators. It never contains prompts, payloads, peer addresses, local paths, or environment values.

func (FleetNodeReport) Canonical

func (report FleetNodeReport) Canonical() ([]byte, error)

func (*FleetNodeReport) Sign

func (report *FleetNodeReport) Sign(privateKey ed25519.PrivateKey) error

func (FleetNodeReport) Validate

func (report FleetNodeReport) Validate() error

func (FleetNodeReport) Verify

func (report FleetNodeReport) Verify(publicKey ed25519.PublicKey, now time.Time) error

type FleetStateEntry

type FleetStateEntry struct {
	Path             string              `json:"path"`
	Kind             FleetStateEntryKind `json:"kind"`
	Mode             uint32              `json:"mode"`
	Size             uint64              `json:"size"`
	ModifiedAt       int64               `json:"modified_at"`
	Hash             string              `json:"hash,omitempty"`
	Content          []byte              `json:"content,omitempty"`
	ContentOffset    uint64              `json:"content_offset,omitempty"`
	ContentHash      string              `json:"content_hash,omitempty"`
	Truncated        bool                `json:"truncated,omitempty"`
	Redacted         bool                `json:"redacted,omitempty"`
	Protected        bool                `json:"protected,omitempty"`
	ProtectionReason string              `json:"protection_reason,omitempty"`
}

FleetStateEntry is one live .pilot tree entry. Hash always identifies the complete local file. Content is a bounded full file or preview; protected values and symlinks are represented by metadata/fingerprint only.

func (FleetStateEntry) Validate

func (entry FleetStateEntry) Validate() error

type FleetStateEntryKind

type FleetStateEntryKind string
const (
	FleetStateDirectory FleetStateEntryKind = "directory"
	FleetStateFile      FleetStateEntryKind = "file"
	FleetStateSymlink   FleetStateEntryKind = "symlink"
)

type FleetStateHistoryPersistence

type FleetStateHistoryPersistence interface {
	ListFleetStateSnapshotHistory(context.Context, string, string, int) ([]FleetStateSnapshot, error)
}

type FleetStateMutation

type FleetStateMutation struct {
	Version          uint16                        `json:"version"`
	ID               string                        `json:"id"`
	TenantID         string                        `json:"tenant_id"`
	AgentID          string                        `json:"agent_id"`
	ExpectedRevision uint64                        `json:"expected_revision"`
	Operations       []FleetStateMutationOperation `json:"operations"`
	Reason           string                        `json:"reason"`
	IssuedAt         int64                         `json:"issued_at"`
	ExpiresAt        int64                         `json:"expires_at"`
	KeyID            string                        `json:"key_id"`
	Signature        string                        `json:"signature"`
}

func (FleetStateMutation) Canonical

func (mutation FleetStateMutation) Canonical() ([]byte, error)

func (*FleetStateMutation) SignWith

func (mutation *FleetStateMutation) SignWith(sign func([]byte) ([]byte, error)) error

func (FleetStateMutation) Validate

func (mutation FleetStateMutation) Validate() error

func (FleetStateMutation) Verify

func (mutation FleetStateMutation) Verify(publicKey ed25519.PublicKey, now time.Time) error

type FleetStateMutationKind

type FleetStateMutationKind string
const (
	FleetStatePutFile       FleetStateMutationKind = "put_file"
	FleetStateDeletePath    FleetStateMutationKind = "delete_path"
	FleetStateMakeDirectory FleetStateMutationKind = "make_directory"
)

type FleetStateMutationOperation

type FleetStateMutationOperation struct {
	Kind         FleetStateMutationKind `json:"kind"`
	Path         string                 `json:"path"`
	ExpectedHash string                 `json:"expected_hash,omitempty"`
	Content      []byte                 `json:"content,omitempty"`
	ContentHash  string                 `json:"content_hash,omitempty"`
	Mode         uint32                 `json:"mode,omitempty"`
}

func (FleetStateMutationOperation) Validate

func (operation FleetStateMutationOperation) Validate() error

type FleetStateMutationResult

type FleetStateMutationResult struct {
	Version      uint16 `json:"version"`
	TenantID     string `json:"tenant_id"`
	AgentID      string `json:"agent_id"`
	MutationID   string `json:"mutation_id"`
	Status       string `json:"status"`
	DetailCode   string `json:"detail_code,omitempty"`
	FromRevision uint64 `json:"from_revision"`
	ToRevision   uint64 `json:"to_revision"`
	ObservedAt   int64  `json:"observed_at"`
	KeyID        string `json:"key_id"`
	Signature    string `json:"signature"`
}

func (FleetStateMutationResult) Canonical

func (result FleetStateMutationResult) Canonical() ([]byte, error)

func (*FleetStateMutationResult) Sign

func (result *FleetStateMutationResult) Sign(privateKey ed25519.PrivateKey) error

func (FleetStateMutationResult) Validate

func (result FleetStateMutationResult) Validate() error

func (FleetStateMutationResult) Verify

func (result FleetStateMutationResult) Verify(publicKey ed25519.PublicKey, now time.Time) error

type FleetStatePersistence

type FleetStatePersistence interface {
	SaveFleetStateSnapshot(context.Context, FleetStateSnapshot) error
	FleetStateSnapshot(context.Context, string, string) (FleetStateSnapshot, bool, error)
	ListFleetStateSnapshots(context.Context, string) ([]FleetStateSnapshot, error)
	SaveFleetStateMutation(context.Context, FleetStateMutation) error
	ListFleetStateMutations(context.Context, string, string) ([]FleetStateMutation, error)
	SaveFleetStateMutationResult(context.Context, FleetStateMutationResult) error
	ListFleetStateMutationResults(context.Context, string, string) ([]FleetStateMutationResult, error)
}

type FleetStateSnapshot

type FleetStateSnapshot struct {
	Version    uint16            `json:"version"`
	ID         string            `json:"id"`
	TenantID   string            `json:"tenant_id"`
	AgentID    string            `json:"agent_id"`
	Revision   uint64            `json:"revision"`
	RootHash   string            `json:"root_hash"`
	Entries    []FleetStateEntry `json:"entries"`
	ObservedAt int64             `json:"observed_at"`
	KeyID      string            `json:"key_id"`
	Signature  string            `json:"signature"`
}

func NewFleetStateSnapshot

func NewFleetStateSnapshot(tenantID, agentID string, revision uint64, entries []FleetStateEntry, observedAt time.Time, keyID string) (FleetStateSnapshot, error)

func (FleetStateSnapshot) Canonical

func (snapshot FleetStateSnapshot) Canonical() ([]byte, error)

func (*FleetStateSnapshot) Sign

func (snapshot *FleetStateSnapshot) Sign(privateKey ed25519.PrivateKey) error

func (FleetStateSnapshot) Validate

func (snapshot FleetStateSnapshot) Validate() error

func (FleetStateSnapshot) Verify

func (snapshot FleetStateSnapshot) Verify(publicKey ed25519.PublicKey, now time.Time) error

func (FleetStateSnapshot) VerifySignature

func (snapshot FleetStateSnapshot) VerifySignature(publicKey ed25519.PublicKey) error

VerifySignature authenticates a retained snapshot without treating its observation time as a live admission credential. Ingestion uses Verify; history reads and revision recovery use this method.

type KeyUsage

type KeyUsage string
const (
	UsageIntent   KeyUsage = "intent"
	UsageDecision KeyUsage = "decision"
	UsagePolicy   KeyUsage = "policy"
	UsageMandate  KeyUsage = "mandate"
	UsageApproval KeyUsage = "approval"
	UsageReceipt  KeyUsage = "receipt"
)

type MandateBundleManager

type MandateBundleManager struct {
	// contains filtered or unexported fields
}

MandateBundleManager validates, durably publishes, and distributes complete signed mandate snapshots. A higher revision replaces the prior snapshot for that one agent; a valid empty higher revision therefore revokes every prior delegation for the agent.

func NewMandateBundleManager

func NewMandateBundleManager(trust MandateBundleTrustStore, persistence MandateBundlePersistence, now func() time.Time) (*MandateBundleManager, error)

func NewTenantMandateBundleManager

func NewTenantMandateBundleManager(trust MandateBundleTrustStore, persistence MandateBundlePersistence, tenantID string, now func() time.Time) (*MandateBundleManager, error)

NewTenantMandateBundleManager scopes a manager to one authority domain when the underlying repository is shared by multiple tenants.

func (*MandateBundleManager) Bundles

func (manager *MandateBundleManager) Bundles(ctx context.Context, tenantID string) ([]decision.MandateBundle, error)

Bundles returns a stable, read-only management view for one tenant.

func (*MandateBundleManager) CurrentForAgent

func (manager *MandateBundleManager) CurrentForAgent(ctx context.Context, tenantID, agentID string) (decision.MandateBundle, bool, error)

CurrentForAgent returns the one current snapshot for a targeted workload. No bundle is a fail-closed result for a mandate-requiring local enforcer; it does not imply that ordinary open-protocol traffic is authorized.

func (*MandateBundleManager) Publish

func (manager *MandateBundleManager) Publish(ctx context.Context, bundle decision.MandateBundle) error

Publish verifies a pre-signed, complete snapshot before it is stored. It never signs or edits a tenant's bundle, keeping authoring keys outside the service process.

type MandateBundlePersistence

type MandateBundlePersistence interface {
	SaveMandateBundle(context.Context, decision.MandateBundle) error
	LoadMandateBundles(context.Context) ([]decision.MandateBundle, error)
}

MandateBundlePersistence makes mandate distribution restart-durable. A persistence implementation must retain the newest bundle per tenant/subject-agent pair and reject conflicting equal revisions.

type MandateBundleTrustStore

type MandateBundleTrustStore interface {
	decision.MandateKeyResolver
	decision.MandateStateResolver
}

MandateBundleTrustStore resolves only tenant-wide mandate issuer keys and supplies the current revocation floor. Workload-scoped keys are deliberately unable to publish a distribution snapshot.

type PinnedRoot

type PinnedRoot struct {
	TenantID  string
	RootKeyID string
	PublicKey ed25519.PublicKey
}

type PolicyAckStatus

type PolicyAckStatus string
const (
	PolicyAckStaged   PolicyAckStatus = "staged"
	PolicyAckEnforced PolicyAckStatus = "enforced"
	PolicyAckRejected PolicyAckStatus = "rejected"
)

type PolicyAcknowledgement

type PolicyAcknowledgement struct {
	Version         uint16          `json:"version"`
	ID              string          `json:"id"`
	PublicationID   string          `json:"publication_id"`
	PolicyHash      string          `json:"policy_hash"`
	TenantID        string          `json:"tenant_id"`
	AgentID         string          `json:"agent_id"`
	PolicyRevision  uint64          `json:"policy_revision"`
	RevocationEpoch uint64          `json:"revocation_epoch"`
	Status          PolicyAckStatus `json:"status"`
	ObservedAt      int64           `json:"observed_at"`
	KeyID           string          `json:"key_id"`
	Signature       string          `json:"signature"`
}

func NewPolicyAcknowledgement

func NewPolicyAcknowledgement(publication PolicyPublication, agentID string, status PolicyAckStatus, observedAt time.Time, keyID string) (PolicyAcknowledgement, error)

func (PolicyAcknowledgement) Canonical

func (ack PolicyAcknowledgement) Canonical() ([]byte, error)

func (*PolicyAcknowledgement) Sign

func (ack *PolicyAcknowledgement) Sign(privateKey ed25519.PrivateKey) error

func (*PolicyAcknowledgement) SignWith

func (ack *PolicyAcknowledgement) SignWith(signer func([]byte) ([]byte, error)) error

func (PolicyAcknowledgement) Validate

func (ack PolicyAcknowledgement) Validate() error

func (PolicyAcknowledgement) Verify

func (ack PolicyAcknowledgement) Verify(publicKey ed25519.PublicKey, now time.Time) error

type PolicyActivation

type PolicyActivation struct {
	Version         uint16 `json:"version"`
	ID              string `json:"id"`
	PublicationID   string `json:"publication_id"`
	PublicationHash string `json:"publication_hash"`
	PolicyHash      string `json:"policy_hash"`
	TenantID        string `json:"tenant_id"`
	PolicyRevision  uint64 `json:"policy_revision"`
	RevocationEpoch uint64 `json:"revocation_epoch"`
	IssuedAt        int64  `json:"issued_at"`
	ActivatesAt     int64  `json:"activates_at"`
	KeyID           string `json:"key_id"`
	Signature       string `json:"signature"`
}

func NewPolicyActivation

func NewPolicyActivation(publication PolicyPublication, bundle PolicyBundle, issuedAt, activatesAt time.Time, keyID string) (PolicyActivation, error)

func (PolicyActivation) Canonical

func (activation PolicyActivation) Canonical() ([]byte, error)

func (*PolicyActivation) Sign

func (activation *PolicyActivation) Sign(privateKey ed25519.PrivateKey) error

func (PolicyActivation) Validate

func (activation PolicyActivation) Validate() error

func (PolicyActivation) VerifyFor

func (activation PolicyActivation) VerifyFor(publication PolicyPublication, bundle PolicyBundle, publicKey ed25519.PublicKey, now time.Time) error

type PolicyBundle

type PolicyBundle struct {
	Version         uint16 `json:"version"`
	TenantID        string `json:"tenant_id"`
	Revision        uint64 `json:"revision"`
	RevocationEpoch uint64 `json:"revocation_epoch"`
	IssuedAt        int64  `json:"issued_at"`
	ActivatesAt     int64  `json:"activates_at"`
	ExpiresAt       int64  `json:"expires_at"`
	Engine          string `json:"engine"`
	EngineVersion   string `json:"engine_version"`
	ContentType     string `json:"content_type"`
	PayloadHash     string `json:"payload_hash"`
	Payload         []byte `json:"payload"`
	FailureMode     string `json:"failure_mode"`
	KeyID           string `json:"key_id"`
	Signature       string `json:"signature"`
}

PolicyBundle is compiled/validated tenant policy state distributed to local enforcement points. Payload interpretation is engine-specific; its signed envelope and activation semantics are protocol-level.

func NewPolicyBundle

func NewPolicyBundle(tenantID string, revision, revocationEpoch uint64, issuedAt, activatesAt, expiresAt time.Time, engine, engineVersion, contentType, keyID string, payload []byte) PolicyBundle

func (PolicyBundle) Canonical

func (bundle PolicyBundle) Canonical() ([]byte, error)

func (PolicyBundle) Hash

func (bundle PolicyBundle) Hash() (string, error)

func (*PolicyBundle) Sign

func (bundle *PolicyBundle) Sign(privateKey ed25519.PrivateKey) error

func (PolicyBundle) Validate

func (bundle PolicyBundle) Validate() error

func (PolicyBundle) Verify

func (bundle PolicyBundle) Verify(publicKey ed25519.PublicKey, now time.Time) error

type PolicyManager

type PolicyManager struct {
	// contains filtered or unexported fields
}

PolicyManager validates, stages, and activates signed policy without ever falling back to an older revision. Persistence/distribution is supplied by the embedding control-plane process.

func NewPolicyManager

func NewPolicyManager(trust PolicyTrustStore, validator PolicyValidator, now func() time.Time) (*PolicyManager, error)

func (*PolicyManager) ActivateHeldWithCommit

func (manager *PolicyManager) ActivateHeldWithCommit(ctx context.Context, tenantID string, revision uint64, commit func() error) error

ActivateHeldWithCommit promotes a managed staged revision only after its signed earliest activation time and only after durable activation commit.

func (*PolicyManager) Active

func (manager *PolicyManager) Active(ctx context.Context, tenantID string) (PolicyBundle, error)

func (*PolicyManager) Install

func (manager *PolicyManager) Install(ctx context.Context, bundle PolicyBundle) error

func (*PolicyManager) InstallHeldWithCommit

func (manager *PolicyManager) InstallHeldWithCommit(ctx context.Context, bundle PolicyBundle, commit func() error) error

InstallHeldWithCommit persists and stages managed desired state without allowing time alone to activate it. A verified rollout activation is needed.

func (*PolicyManager) InstallWithCommit

func (manager *PolicyManager) InstallWithCommit(ctx context.Context, bundle PolicyBundle, commit func() error) error

InstallWithCommit validates and compiles the candidate, then invokes commit while the manager's revision lock is held and before the candidate becomes visible. A failed durable commit therefore cannot advance in-memory policy.

func (*PolicyManager) Snapshot

func (manager *PolicyManager) Snapshot(tenantID string) PolicySnapshot

func (*PolicyManager) Validate

func (manager *PolicyManager) Validate(ctx context.Context, bundle PolicyBundle) error

Validate authenticates, checks state floors, and compiles a policy bundle without mutating active or staged state.

func (*PolicyManager) ValidateInstall

func (manager *PolicyManager) ValidateInstall(ctx context.Context, bundle PolicyBundle) error

type PolicyPublication

type PolicyPublication struct {
	Version              uint16   `json:"version"`
	ID                   string   `json:"id"`
	TenantID             string   `json:"tenant_id"`
	PolicyRevision       uint64   `json:"policy_revision"`
	RevocationEpoch      uint64   `json:"revocation_epoch"`
	PolicyHash           string   `json:"policy_hash"`
	ExpectedAgents       []string `json:"expected_agents"`
	RequiredAcknowledged uint32   `json:"required_acknowledged"`
	IssuedAt             int64    `json:"issued_at"`
	KeyID                string   `json:"key_id"`
	Signature            string   `json:"signature"`
}

func (PolicyPublication) Canonical

func (publication PolicyPublication) Canonical() ([]byte, error)

func (PolicyPublication) Hash

func (publication PolicyPublication) Hash() (string, error)

func (*PolicyPublication) Sign

func (publication *PolicyPublication) Sign(privateKey ed25519.PrivateKey) error

func (PolicyPublication) Validate

func (publication PolicyPublication) Validate() error

func (PolicyPublication) VerifyFor

func (publication PolicyPublication) VerifyFor(bundle PolicyBundle, publicKey ed25519.PublicKey, now time.Time) error

type PolicySnapshot

type PolicySnapshot struct {
	Active *PolicyBundle
	Staged *PolicyBundle
	Held   bool
}

type PolicyTrustStore

type PolicyTrustStore interface {
	PolicyKey(tenantID, keyID string) (ed25519.PublicKey, error)
	MinimumState(context.Context, string) (uint64, uint64, error)
}

type PolicyValidator

type PolicyValidator interface {
	ValidatePolicy(ctx context.Context, engine, engineVersion, contentType string, payload []byte) error
}

type PolicyWithdrawal

type PolicyWithdrawal struct {
	Version         uint16 `json:"version"`
	ID              string `json:"id"`
	PublicationID   string `json:"publication_id"`
	PublicationHash string `json:"publication_hash"`
	TenantID        string `json:"tenant_id"`
	PolicyRevision  uint64 `json:"policy_revision"`
	Reason          string `json:"reason"`
	IssuedAt        int64  `json:"issued_at"`
	KeyID           string `json:"key_id"`
	Signature       string `json:"signature"`
}

PolicyWithdrawal is the signed terminal state for a published candidate or a future activation. It never rolls back an already-active policy; that requires a higher signed policy revision. Agents and authority replicas can therefore distinguish an intentional withdrawal from transport absence.

func NewPolicyWithdrawal

func NewPolicyWithdrawal(publication PolicyPublication, reason string, issuedAt time.Time, keyID string) (PolicyWithdrawal, error)

func (PolicyWithdrawal) Canonical

func (withdrawal PolicyWithdrawal) Canonical() ([]byte, error)

func (*PolicyWithdrawal) Sign

func (withdrawal *PolicyWithdrawal) Sign(privateKey ed25519.PrivateKey) error

func (PolicyWithdrawal) Validate

func (withdrawal PolicyWithdrawal) Validate() error

func (PolicyWithdrawal) VerifyFor

func (withdrawal PolicyWithdrawal) VerifyFor(publication PolicyPublication, publicKey ed25519.PublicKey, now time.Time) error

type RolloutGenerationPersistence

type RolloutGenerationPersistence interface {
	TenantRolloutPersistence
	RolloutGeneration(context.Context, string) (uint64, error)
}

type RolloutManager

type RolloutManager struct {
	// contains filtered or unexported fields
}

func NewRolloutManager

func NewRolloutManager(trust RolloutTrustStore, policies *PolicyManager, repository RolloutPersistence, now func() time.Time) (*RolloutManager, error)

func (*RolloutManager) Acknowledge

func (manager *RolloutManager) Acknowledge(ctx context.Context, ack PolicyAcknowledgement) error

func (*RolloutManager) Activate

func (manager *RolloutManager) Activate(ctx context.Context, activation PolicyActivation) error

func (*RolloutManager) ActiveForAgent

func (manager *RolloutManager) ActiveForAgent(ctx context.Context, tenantID, agentID string) (PolicyPublication, PolicyBundle, PolicyActivation, bool, error)

ActiveForAgent returns the active policy together with the publication and signed activation that promoted it, but only when the publication explicitly targets agentID. A bare signed bundle is intentionally insufficient proof of managed activation.

func (*RolloutManager) BundleForPublication

func (manager *RolloutManager) BundleForPublication(ctx context.Context, tenantID, publicationID string) (PolicyPublication, PolicyBundle, bool, error)

BundleForPublication returns one immutable historical rollout artifact for review or a monotonic superseding rollback. It never changes active state.

func (*RolloutManager) CandidateForAgent

func (manager *RolloutManager) CandidateForAgent(ctx context.Context, tenantID, agentID string) (PolicyPublication, PolicyBundle, bool, error)

CandidateForAgent returns the newest unactivated policy publication that explicitly targets agentID. The bundle remains held at the authority until the signed acknowledgement threshold and a signed activation are present; callers must not treat this response as active authority.

func (*RolloutManager) CurrentPolicy

func (manager *RolloutManager) CurrentPolicy(ctx context.Context, tenantID string) (PolicyBundle, error)

func (*RolloutManager) Publish

func (manager *RolloutManager) Publish(ctx context.Context, publication PolicyPublication, bundle PolicyBundle) error

func (*RolloutManager) Refresh

func (manager *RolloutManager) Refresh(ctx context.Context) error

Refresh reconciles durable rollout state into this replica. Replaying exact records is idempotent; any conflicting immutable record fails closed.

func (*RolloutManager) ScheduleActivation

func (manager *RolloutManager) ScheduleActivation(ctx context.Context, activation PolicyActivation) error

ScheduleActivation durably records a signed future activation. Refresh promotes it once its signed time arrives; until then agents can still fetch and acknowledge the held candidate.

func (*RolloutManager) Status

func (manager *RolloutManager) Status(publicationID string) (RolloutStatus, error)

func (*RolloutManager) Statuses

func (manager *RolloutManager) Statuses(ctx context.Context, tenantID string) ([]RolloutStatus, error)

Statuses returns every policy rollout for one managed tenant, newest policy revision first. It is a read-model for an operator interface: the returned records contain immutable signed publication data and derived acknowledgement progress, but grant no ability to change policy or activation state.

func (*RolloutManager) ValidateCandidate

func (manager *RolloutManager) ValidateCandidate(ctx context.Context, publication PolicyPublication, bundle PolicyBundle) error

func (*RolloutManager) Withdraw

func (manager *RolloutManager) Withdraw(ctx context.Context, withdrawal PolicyWithdrawal) error

Withdraw durably terminates distribution of a candidate or cancels a future activation. It intentionally refuses to alter an activation whose time has arrived; an active policy is superseded only through a higher revision.

type RolloutPersistence

type RolloutPersistence interface {
	SavePolicyPublication(context.Context, PolicyPublication, PolicyBundle) error
	AppendPolicyAcknowledgement(context.Context, PolicyAcknowledgement) error
	SavePolicyActivation(context.Context, PolicyActivation) error
	LoadRollouts(context.Context) ([]StoredRollout, error)
}

type RolloutStatus

type RolloutStatus struct {
	Publication PolicyPublication `json:"publication"`
	Staged      int               `json:"staged"`
	Enforced    int               `json:"enforced"`
	Rejected    int               `json:"rejected"`
	Pending     []string          `json:"pending"`
	Ready       bool              `json:"ready"`
	Activation  *PolicyActivation `json:"activation,omitempty"`
	Withdrawal  *PolicyWithdrawal `json:"withdrawal,omitempty"`
}

type RolloutTrustStore

type RolloutTrustStore interface {
	ManagesTenant(string) bool
	ManagedTenants() []string
	PolicyKey(tenantID, keyID string) (ed25519.PublicKey, error)
	PolicyKeyAt(tenantID, keyID string, at time.Time) (ed25519.PublicKey, error)
	IntentKey(context.Context, string, string, string) (ed25519.PublicKey, error)
	IntentKeyAt(tenantID, agentID, keyID string, at time.Time) (ed25519.PublicKey, error)
	MinimumState(context.Context, string) (uint64, uint64, error)
}

type RolloutWithdrawalPersistence

type RolloutWithdrawalPersistence interface {
	SavePolicyWithdrawal(context.Context, PolicyWithdrawal) error
}

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store is a tenant-scoped local trust view. The pinned root is configured out-of-band; a signed online bundle cannot replace it.

func NewStore

func NewStore(roots []PinnedRoot, now func() time.Time) (*Store, error)

func (*Store) ApprovalKey

func (store *Store) ApprovalKey(tenantID, keyID string) (ed25519.PublicKey, error)

func (*Store) ApprovalKeyAt

func (store *Store) ApprovalKeyAt(tenantID, keyID string, at time.Time) (ed25519.PublicKey, error)

func (*Store) Current

func (store *Store) Current(_ context.Context, tenantID string) (TrustBundle, error)

Current returns the currently active, root-verified trust bundle. Unlike Latest, it never returns an expired or future historical revision.

func (*Store) DecisionKey

func (store *Store) DecisionKey(_ context.Context, tenantID, keyID string) (ed25519.PublicKey, error)

func (*Store) DecisionKeyAt

func (store *Store) DecisionKeyAt(tenantID, keyID string, at time.Time) (ed25519.PublicKey, error)

func (*Store) History

func (store *Store) History(tenantID string) []TrustBundle

func (*Store) Install

func (store *Store) Install(bundle TrustBundle) error

func (*Store) InstallHistorical

func (store *Store) InstallHistorical(bundle TrustBundle) error

InstallHistorical retains a root-signed bundle for verification of evidence created while its keys were valid. Expired state is never made active, and monotonic revision/revocation history is still enforced.

func (*Store) InstallHistoricalWithCommit

func (store *Store) InstallHistoricalWithCommit(bundle TrustBundle, commit func() error) error

InstallHistoricalWithCommit verifies and durably records a historical bundle before exposing it to historical key resolution.

func (*Store) InstallWithCommit

func (store *Store) InstallWithCommit(bundle TrustBundle, commit func() error) error

func (*Store) IntentKey

func (store *Store) IntentKey(_ context.Context, tenantID, agentID, keyID string) (ed25519.PublicKey, error)

func (*Store) IntentKeyAt

func (store *Store) IntentKeyAt(tenantID, agentID, keyID string, at time.Time) (ed25519.PublicKey, error)

func (*Store) Latest

func (store *Store) Latest(tenantID string) (TrustBundle, bool)

func (*Store) ManagedTenants

func (store *Store) ManagedTenants() []string

func (*Store) ManagesTenant

func (store *Store) ManagesTenant(tenantID string) bool

func (*Store) MandateKey

func (store *Store) MandateKey(_ context.Context, tenantID, keyID string) (ed25519.PublicKey, error)

MandateKey resolves a tenant-wide delegated issuer key for signed mandates. Mandates are never signed by a workload-scoped key.

func (*Store) MinimumState

func (store *Store) MinimumState(_ context.Context, tenantID string) (uint64, uint64, error)

func (*Store) PolicyKey

func (store *Store) PolicyKey(tenantID, keyID string) (ed25519.PublicKey, error)

func (*Store) PolicyKeyAt

func (store *Store) PolicyKeyAt(tenantID, keyID string, at time.Time) (ed25519.PublicKey, error)

func (*Store) ReceiptKey

func (store *Store) ReceiptKey(tenantID, agentID, keyID string) (ed25519.PublicKey, error)

func (*Store) ReceiptKeyAt

func (store *Store) ReceiptKeyAt(tenantID, agentID, keyID string, at time.Time) (ed25519.PublicKey, error)

type StoredRollout

type StoredRollout struct {
	Publication      PolicyPublication
	Bundle           PolicyBundle
	Acknowledgements []PolicyAcknowledgement
	Activation       *PolicyActivation
	Withdrawal       *PolicyWithdrawal
}

StoredRollout and RolloutPersistence are the narrow persistence contract accepted by PolicyManager. The managed node normally uses the in-memory implementation; hosted persistence remains in the private control plane.

type TenantMandateBundlePersistence

type TenantMandateBundlePersistence interface {
	MandateBundlePersistence
	LoadTenantMandateBundles(context.Context, string) ([]decision.MandateBundle, error)
}

TenantMandateBundlePersistence can load only one authority domain from a shared backend. A single-tenant authority must not attempt to validate or serve another tenant's delegation snapshots during startup.

type TenantRolloutPersistence

type TenantRolloutPersistence interface {
	RolloutPersistence
	LoadTenantRollouts(context.Context, string) ([]StoredRollout, error)
}

type TrustBundle

type TrustBundle struct {
	Version         uint16         `json:"version"`
	TenantID        string         `json:"tenant_id"`
	Revision        uint64         `json:"revision"`
	PolicyRevision  uint64         `json:"policy_revision"`
	RevocationEpoch uint64         `json:"revocation_epoch"`
	IssuedAt        int64          `json:"issued_at"`
	ExpiresAt       int64          `json:"expires_at"`
	RootKeyID       string         `json:"root_key_id"`
	Keys            []AuthorityKey `json:"keys"`
	Signature       string         `json:"signature"`
}

TrustBundle is the complete signed online-key view for one tenant. Removing or narrowing a previously active key requires a higher RevocationEpoch.

func (TrustBundle) Canonical

func (bundle TrustBundle) Canonical() ([]byte, error)

func (TrustBundle) Hash

func (bundle TrustBundle) Hash() (string, error)

func (*TrustBundle) Sign

func (bundle *TrustBundle) Sign(rootPrivateKey ed25519.PrivateKey) error

func (TrustBundle) Validate

func (bundle TrustBundle) Validate() error

func (TrustBundle) Verify

func (bundle TrustBundle) Verify(rootPublicKey ed25519.PublicKey, now time.Time) error

func (TrustBundle) VerifySignature

func (bundle TrustBundle) VerifySignature(rootPublicKey ed25519.PublicKey) error

Jump to

Keyboard shortcuts

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