sensorstate

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package sensorstate defines immutable endpoint sensor-state observations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildCoverageVector

func BuildCoverageVector(w CoverageWindow) riskassessment.CoverageVector

BuildCoverageVector deterministically converts the immutable window facts to the vector consumed by the existing risk scorer. Loss or delivery-gap facts cap affected coverage below complete without changing risk itself.

func RevisionFor

func RevisionFor(w CoverageWindow) string

RevisionFor returns a stable revision for a fully assembled window. It does not use wall clock time, so the same persisted facts always yield the same revision.

func SameSignedObservation

func SameSignedObservation(a, b Observation) bool

SameSignedObservation compares immutable signed sensor-state content. It intentionally excludes server-generated RecordedAt, allowing delayed retries to converge on the first accepted record.

Types

type CoverageWindow

type CoverageWindow struct {
	AssetID        shared.ID
	AgentID        shared.ID
	HostID         shared.ID
	Since          time.Time
	Until          time.Time
	InputDigest    string
	Revision       string
	CreatedAt      time.Time
	States         []detection.ClassCoverage
	SampledCount   int
	TruncatedCount int
	DroppedCount   int
	GapCount       int
	BatchCount     int
	Vector         riskassessment.CoverageVector
}

CoverageWindow is an immutable, revisioned explanation of how much telemetry can be trusted for one asset over a fixed observed-time interval.

func (CoverageWindow) Validate

func (w CoverageWindow) Validate() error

type Observation

type Observation struct {
	ReportID            shared.ID
	AgentID             shared.ID
	HostID              shared.ID
	AssetID             shared.ID
	Kind                RecordKind
	ObservedAt          time.Time
	PayloadDigest       string
	SignedContentDigest string
	SchemaVersion       int
	States              []detection.ClassCoverage
	RecordedAt          time.Time
}

Observation is an append-only, signed endpoint sensor-state record. ReportID is deterministic from the local WAL record and makes retries idempotent.

func NormalizeObservation

func NormalizeObservation(o Observation) Observation

NormalizeObservation canonicalizes persisted timestamps to the precision PostgreSQL retains. RecordedAt is server-owned and excluded from retry identity.

func (Observation) Validate

func (o Observation) Validate() error

type RecordKind

type RecordKind string

RecordKind identifies the durable P0 record represented by an observation.

const (
	RecordCoverage    RecordKind = "coverage"
	RecordSensorState RecordKind = "sensor_state"
)

func (RecordKind) Valid

func (k RecordKind) Valid() bool

Jump to

Keyboard shortcuts

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