correlation

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AppProcessMethod     = "agentprov.command_time_process/v3"
	AppProcessConfidence = 0.8 // Attribution tier, not a calibrated probability.
	AppProcessEdgePrefix = "agent-correlation-v3-"
)

AppProcessMethod identifies derived app-to-runtime links, not kernel-proven agent identity. Keep its version in the stored edge ID for portable readers.

View Source
const BindingSourceK8sCgroup = "k8s_cgroup"

BindingSourceK8sCgroup marks a scope established by passive cgroup→pod attribution (a node sensor observing an externally-scheduled pod we did not launch), as opposed to a scope we launched via record/control-plane.

Variables

View Source
var MaxOpenBindingAge = 24 * time.Hour

MaxOpenBindingAge bounds how long a binding left open (ended_at = "") is allowed to match telemetry. Without it, a binding whose CloseBinding was dropped - every close call is best-effort (record/control) - would match every future event for its container/pid forever, silently over-binding later, unrelated executions to a stale context. An open binding only matches events within this window after it started; older events fall through to the next resolution tier or to unresolved.

PRODUCT SEMANTICS: this assumes an open binding represents a SHORT-LIVED ToolCallScope (a tool call / process lifetime), not a session-lifetime identity. A long-running agent or session that stays open past this window without a close/reopen will see its real events go unresolved rather than risk mis-binding - which is the safe failure here. Session-lifetime identity that legitimately exceeds 24h must keep its binding refreshed (re-record on activity) or model itself as a series of scoped bindings, not one perpetual open binding. Tune via this var if the deployment's scope lifetimes differ.

Functions

func CanonicalProcessInstance added in v0.10.0

func CanonicalProcessInstance(instance string, pid int64) string

func CaptureOrigin added in v0.10.0

func CaptureOrigin(layers []map[string]any, pid int64) (string, bool)

CaptureOrigin namespaces kernel-local identifiers by the strongest recorded host identity and boot. A boot ID never hides a conflicting explicit host. Layers are storage envelopes, not alternative identities to choose between.

func CloseBinding

func CloseBinding(db *sql.DB, processID, endedAt string) error

func CloseBindingByID added in v0.7.2

func CloseBindingByID(db bindingExecer, bindingID, endedAt string) error

CloseBindingByID closes one exact binding. Kubernetes informer attribution uses this when a container restarts or its pod is deleted: closing by cgroup or session could accidentally terminate a sibling container's scope.

func CloseBindingByPID added in v0.3.0

func CloseBindingByPID(db bindingPIDStore, pid int64, endedAt string) error

func CloseProcessInstance added in v0.9.0

func CloseProcessInstance(db ProcessStore, raw RawIdentity) error

CloseProcessInstance uses the captured lifetime identity. A delayed exit must not close a different process that has reused the same numeric PID.

func DefaultBindingConfidence added in v0.7.0

func DefaultBindingConfidence(bindingSource string) float64

DefaultBindingConfidence caps how much a binding may vouch for a match by how it was established, when the caller did not set an explicit confidence. Resolution takes the MIN of this binding confidence and the method's own confidence, so an app-asserted (ai_asserted) join can never read as certain as a kernel-verified one even if it happens to match by pid. This is the honesty tier: a scope the model merely CLAIMED is worth less than one the control plane launched or the kernel witnessed.

func EventPayloadWithCorrelation

func EventPayloadWithCorrelation(payload string, match Match, resolved bool) string

func ObserveProcessInstance added in v0.9.0

func ObserveProcessInstance(db ProcessStore, raw RawIdentity) error

ObserveProcessInstance retains a process-scoped anchor, never a new whole- cgroup binding. Only an observed cgroup/container or a kernel-identified parent can seed it; bare PID/PPID proximity cannot establish ancestry.

func ProcessInstanceBootID added in v0.10.0

func ProcessInstanceBootID(instance string, pid int64) string

ProcessInstanceBootID returns the kernel boot identity only for a validated native process instance. It is shared by scope attribution and graph analysis.

func RecordBinding

func RecordBinding(db bindingExecer, binding Binding) (string, error)

func RelatedProcessLifetime added in v0.10.0

func RelatedProcessLifetime(parent, child string) bool

RelatedProcessLifetime accepts validated, canonical identities only.

Types

type Binding

type Binding struct {
	ID            string  `json:"id"`
	RunID         string  `json:"run_id"`
	SessionID     string  `json:"session_id"`
	AttemptID     string  `json:"attempt_id"`
	ToolCallID    string  `json:"tool_call_id"`
	ProcessID     string  `json:"process_id"`
	ContainerID   string  `json:"container_id"`
	CgroupID      string  `json:"cgroup_id"`
	RootPID       int64   `json:"root_pid"`
	PID           int64   `json:"pid"`
	StartedAt     string  `json:"started_at"`
	EndedAt       string  `json:"ended_at"`
	BindingSource string  `json:"binding_source"`
	Confidence    float64 `json:"confidence"`
	// ConfidenceSet distinguishes an explicit zero from the legacy Go default.
	ConfidenceSet bool `json:"-"`
}

func GetBinding

func GetBinding(db *sql.DB, id string) (Binding, bool, error)

func ListBindings

func ListBindings(db *sql.DB, filter BindingFilter) ([]Binding, error)

func (Binding) MarshalJSON added in v0.10.0

func (b Binding) MarshalJSON() ([]byte, error)

func (*Binding) UnmarshalJSON added in v0.10.0

func (b *Binding) UnmarshalJSON(data []byte) error

Preserve input presence across JSON and Go callers without changing the stored numeric contract. A missing field keeps the source-specific default.

type BindingFilter

type BindingFilter struct {
	RunID      string
	SessionID  string
	AttemptID  string
	ToolCallID string
	ProcessID  string
}

type Match

type Match struct {
	Binding
	Method              string
	Confidence          float64
	ScopeOnly           bool
	Ambiguous           bool
	CandidateBindingIDs []string
	CandidateCount      int
}

func Resolve

func Resolve(db Queryer, raw RawIdentity) (Match, bool, error)

type ProcessStore added in v0.9.0

type ProcessStore interface {
	Queryer
	// contains filtered or unexported methods
}

type Queryer added in v0.8.0

type Queryer interface {
	Query(string, ...any) (*sql.Rows, error)
	QueryRow(string, ...any) *sql.Row
}

Queryer allows correlation to share the evidence transaction and observe binding changes made earlier in the same batch.

type RawIdentity

type RawIdentity struct {
	HostID                  string
	ProcessInstanceID       string
	ParentProcessInstanceID string
	RunID                   string
	ProcessID               string
	ContainerID             string
	CgroupID                string
	PID                     int64
	TGID                    int64
	PPID                    int64
	Timestamp               string
}

Jump to

Keyboard shortcuts

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