record

package
v0.4.5 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const SchemaVersion = "1.0"

Variables

This section is empty.

Functions

func ComputeHash

func ComputeHash(r *Record) (string, error)

func Validate

func Validate(r *Record) error

Types

type AgentChainHop added in v0.4.5

type AgentChainHop struct {
	Identity string `json:"identity"`
	Role     string `json:"role"`

	Extra map[string]json.RawMessage `json:"-"`
}

func (AgentChainHop) MarshalJSON added in v0.4.5

func (h AgentChainHop) MarshalJSON() ([]byte, error)

func (*AgentChainHop) UnmarshalJSON added in v0.4.5

func (h *AgentChainHop) UnmarshalJSON(data []byte) error

type AgentLineageHop added in v0.4.5

type AgentLineageHop struct {
	AgentID            string `json:"agent_id"`
	DelegatedBy        string `json:"delegated_by,omitempty"`
	DelegationRecordID string `json:"delegation_record_id,omitempty"`

	Extra map[string]json.RawMessage `json:"-"`
}

func (AgentLineageHop) MarshalJSON added in v0.4.5

func (h AgentLineageHop) MarshalJSON() ([]byte, error)

func (*AgentLineageHop) UnmarshalJSON added in v0.4.5

func (h *AgentLineageHop) UnmarshalJSON(data []byte) error

type Controls

type Controls struct {
	PermissionsEnforced bool              `json:"permissions_enforced"`
	ApprovedScope       string            `json:"approved_scope,omitempty"`
	WithinScope         *bool             `json:"within_scope,omitempty"`
	GuardrailsActive    []GuardrailStatus `json:"guardrails_active,omitempty"`
	HumanOversight      *HumanOversight   `json:"human_oversight,omitempty"`
}

type GuardrailStatus

type GuardrailStatus struct {
	Name      string `json:"name"`
	Status    string `json:"status"`
	Triggered bool   `json:"triggered"`
}

type HumanOversight

type HumanOversight struct {
	ApprovalRequired bool   `json:"approval_required"`
	LastReview       string `json:"last_review,omitempty"`
	Reviewer         string `json:"reviewer,omitempty"`
}

type Integrity

type Integrity struct {
	RecordHash         string `json:"record_hash"`
	PreviousRecordHash string `json:"previous_record_hash,omitempty"`
	SigningKeyID       string `json:"signing_key_id,omitempty"`
	Signature          string `json:"signature,omitempty"`
}

type PolicyRef added in v0.4.5

type PolicyRef struct {
	PolicyID       string   `json:"policy_id,omitempty"`
	PolicyVersion  string   `json:"policy_version,omitempty"`
	PolicyDigest   string   `json:"policy_digest,omitempty"`
	MatchedRuleIDs []string `json:"matched_rule_ids,omitempty"`

	Extra map[string]json.RawMessage `json:"-"`
}

func (PolicyRef) MarshalJSON added in v0.4.5

func (p PolicyRef) MarshalJSON() ([]byte, error)

func (*PolicyRef) UnmarshalJSON added in v0.4.5

func (p *PolicyRef) UnmarshalJSON(data []byte) error

type Record

type Record struct {
	RecordID      string         `json:"record_id"`
	RecordVersion string         `json:"record_version"`
	Timestamp     time.Time      `json:"timestamp"`
	Source        string         `json:"source"`
	SourceProduct string         `json:"source_product"`
	AgentID       string         `json:"agent_id,omitempty"`
	RecordType    string         `json:"record_type"`
	Event         map[string]any `json:"event"`
	Controls      Controls       `json:"controls"`
	Metadata      map[string]any `json:"metadata,omitempty"`
	Relationship  *Relationship  `json:"relationship,omitempty"`
	// Deprecated: use relationship. Kept for backward compatibility.
	Relations *Relations `json:"relations,omitempty"`
	Integrity Integrity  `json:"integrity"`
}

func Clone

func Clone(r *Record) *Record

func New

func New(opts RecordOpts) (*Record, error)

type RecordOpts

type RecordOpts struct {
	RecordVersion string
	Timestamp     time.Time
	Source        string
	SourceProduct string
	AgentID       string
	Type          string
	Event         map[string]any
	Controls      Controls
	Metadata      map[string]any
	Relationship  *Relationship
	// Deprecated: use Relationship. Kept for backward compatibility.
	Relations *Relations
}

type Relations added in v0.4.5

type Relations = Relationship

type Relationship added in v0.4.5

type Relationship struct {
	ParentRef  *RelationshipRef   `json:"parent_ref,omitempty"`
	EntityRefs []RelationshipRef  `json:"entity_refs,omitempty"`
	PolicyRef  *PolicyRef         `json:"policy_ref,omitempty"`
	AgentChain []AgentChainHop    `json:"agent_chain,omitempty"`
	Edges      []RelationshipEdge `json:"edges,omitempty"`

	// Legacy v1.x compatibility fields (accepted in both relationship and relations).
	ParentRecordID   string            `json:"parent_record_id,omitempty"`
	RelatedRecordIDs []string          `json:"related_record_ids,omitempty"`
	RelatedEntityIDs []string          `json:"related_entity_ids,omitempty"`
	AgentLineage     []AgentLineageHop `json:"agent_lineage,omitempty"`

	// Extra preserves additive fields so they remain hash/signature covered.
	Extra map[string]json.RawMessage `json:"-"`
}

func (Relationship) MarshalJSON added in v0.4.5

func (r Relationship) MarshalJSON() ([]byte, error)

func (*Relationship) UnmarshalJSON added in v0.4.5

func (r *Relationship) UnmarshalJSON(data []byte) error

type RelationshipEdge added in v0.4.5

type RelationshipEdge struct {
	Kind string          `json:"kind"`
	From RelationshipRef `json:"from"`
	To   RelationshipRef `json:"to"`

	Extra map[string]json.RawMessage `json:"-"`
}

func (RelationshipEdge) MarshalJSON added in v0.4.5

func (e RelationshipEdge) MarshalJSON() ([]byte, error)

func (*RelationshipEdge) UnmarshalJSON added in v0.4.5

func (e *RelationshipEdge) UnmarshalJSON(data []byte) error

type RelationshipRef added in v0.4.5

type RelationshipRef struct {
	Kind string `json:"kind"`
	ID   string `json:"id"`

	Extra map[string]json.RawMessage `json:"-"`
}

func (RelationshipRef) MarshalJSON added in v0.4.5

func (r RelationshipRef) MarshalJSON() ([]byte, error)

func (*RelationshipRef) UnmarshalJSON added in v0.4.5

func (r *RelationshipRef) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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