core

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const TimestampFormat = "2006-01-02T15:04:05.000000000Z07:00"

TimestampFormat is how every stored timestamp is written.

Stored timestamps are TEXT and SQLite compares them as text, so their text order has to equal their chronological order. RFC3339Nano breaks that: it strips trailing zeros, and the terminating Z sorts after every digit, so `.5Z` sorts after `.53Z` despite being earlier. A row could be skipped for the rest of its second and then reappear.

The fixed nine-digit fraction makes every value exactly 30 bytes, which makes text order and chronological order the same thing again.

It lives in core because two packages write these values. When the constant was defined separately in each, one of them could be changed alone — and a value written in the old format compares just as wrongly against the new one as the bug this replaces.

View Source
const TimestampParseFormat = time.RFC3339Nano

TimestampParseFormat reads a stored timestamp.

It is deliberately not TimestampFormat. Go requires exactly the layout's digit count when a fraction is written with zeros, so parsing with TimestampFormat rejects every value written before the migration to it. RFC3339Nano accepts both widths, so reads keep working across the change and across a database restored from an older backup.

Variables

View Source
var (
	// ErrNotFound: the row asked for is not there.
	ErrNotFound = errors.New("not found")
	// ErrConflict: the write lost a race, or the row was not in the state the
	// write required. Callers are expected to treat this as "someone else got
	// there first" rather than as a failure.
	ErrConflict = errors.New("conflict")
)

Sentinel outcomes every persistence path shares.

They live in core because the store is no longer a single package: a sub-repository cannot import the store that owns it, so a sentinel defined there is one a sub-repository has to reinvent. That already happened — scheduleproposal grew its own expectOne returning a plain "database conflict" string, so errors.Is(err, ErrConflict) silently stopped matching and a duplicate schedule acceptance surfaced a raw database error to the user instead of being recognised as already done.

View Source
var StandingAssignmentChangeClasses = []string{
	"dependency_upgrade",
	"alert_threshold",
	"flaky_test_quarantine",
	"observability",
	"documentation",
}

StandingAssignmentChangeClasses is the closed set of changes an operator can delegate to a standing assignment.

It is an allowlist rather than free text because free text means "Responder may change anything". Each entry is deliberately a class where a wrong change is visible in review and cheap to discard — none of them touch business logic, and none of them are things a reviewer would wave through.

Functions

func BoundedText

func BoundedText(value string, limit int) string

BoundedText trims surrounding whitespace before applying TruncateUTF8, for the many fields whose limit is meant to bound meaningful content rather than incidental padding.

func FirstNonempty

func FirstNonempty(values ...string) string

FirstNonempty returns the first value that is not blank, or "" when none is. It is the standard way to express a fallback chain over optional fields — Slack, Grafana and Coop payloads all carry the same fact under several names, and each caller writing its own loop is how two copies of this drifted apart.

func NewID

func NewID(prefix string) (string, error)

func TruncateUTF8

func TruncateUTF8(value string, limit int) string

TruncateUTF8 bounds value to at most limit bytes without splitting a rune.

Slack messages, incident titles, agent objectives, and stored errors all carry operator and model text that routinely contains multi-byte runes. Slicing those on a byte boundary yields invalid UTF-8, which surfaces to operators as a replacement character and corrupts anything that later re-encodes the value as JSON. Every bound in Responder goes through here.

func TruncateUTF8WithSuffix

func TruncateUTF8WithSuffix(value string, limit int, suffix string) string

TruncateUTF8WithSuffix bounds value to limit bytes including suffix, which is appended only when the value actually had to be shortened.

Types

type ActionProposal

type ActionProposal struct {
	ID            string            `json:"id,omitempty"`
	IncidentID    string            `json:"incident_id,omitempty"`
	ChannelID     string            `json:"channel_id,omitempty"`
	SourceInput   string            `json:"source_input,omitempty"`
	ActionName    string            `json:"action_name"`
	Title         string            `json:"title"`
	Summary       string            `json:"summary"`
	Target        string            `json:"target"`
	Parameters    map[string]string `json:"parameters,omitempty"`
	BlastRadius   string            `json:"blast_radius"`
	Rollback      string            `json:"rollback"`
	Verification  string            `json:"verification"`
	Authority     string            `json:"authority"`
	Risk          string            `json:"risk"`
	Status        string            `json:"status,omitempty"`
	Required      int               `json:"required_approvals,omitempty"`
	ApprovalCount int               `json:"approval_count,omitempty"`
	RequestedBy   string            `json:"requested_by,omitempty"`
	ExecutionTurn string            `json:"execution_turn,omitempty"`
	Result        string            `json:"result,omitempty"`
	ExpiresAt     time.Time         `json:"expires_at,omitempty"`
	CreatedAt     time.Time         `json:"created_at,omitempty"`
	UpdatedAt     time.Time         `json:"updated_at,omitempty"`
}

type AgentMemory

type AgentMemory struct {
	Goal                string          `json:"goal,omitempty"`
	ChannelPurpose      string          `json:"channel_purpose,omitempty"`
	SituationSummary    string          `json:"situation_summary,omitempty"`
	ActiveTopics        []string        `json:"active_topics,omitempty"`
	OpenLoops           []string        `json:"open_loops,omitempty"`
	Topology            []string        `json:"topology,omitempty"`
	Decisions           []string        `json:"decisions,omitempty"`
	UnresolvedQuestions []string        `json:"unresolved_questions,omitempty"`
	EvidenceRefs        []string        `json:"evidence_refs,omitempty"`
	Knowledge           []KnowledgeItem `json:"knowledge,omitempty"`
}

func (*AgentMemory) UnmarshalJSON

func (m *AgentMemory) UnmarshalJSON(data []byte) error

type AgentRun

type AgentRun struct {
	ID                string
	EpisodeID         string
	AttemptID         string
	AttemptNumber     int
	Mode              AgentRunMode
	IncidentID        string
	ChannelID         string
	ThreadTS          string
	ConversationKey   string
	SourceKind        string
	SourceID          string
	UserID            string
	Repository        string
	Prompt            string
	IdempotencyKey    string
	SessionID         string
	SessionGeneration int
	ExpectedRevision  int64
	CoopTurnID        string
	CoopEventSequence int64
	Context           []byte
	Result            []byte
	TerminalState     string
	State             AgentRunState
	Failures          int
	NextAttemptAt     time.Time
	LastError         string
	CreatedAt         time.Time
	UpdatedAt         time.Time
	StartedAt         time.Time
	CompletedAt       time.Time
	CommitmentTitle   string
	Episode           *WorkEpisode
}

type AgentRunMode

type AgentRunMode string
const (
	AgentRunTriage          AgentRunMode = "triage"
	AgentRunIncident        AgentRunMode = "incident"
	AgentRunEngineeringTask AgentRunMode = "engineering_task"
)

type AgentRunState

type AgentRunState string
const (
	AgentRunPending    AgentRunState = "pending"
	AgentRunPreparing  AgentRunState = "preparing"
	AgentRunRunning    AgentRunState = "running"
	AgentRunApplying   AgentRunState = "applying"
	AgentRunFinalizing AgentRunState = "finalizing"
	AgentRunCompleted  AgentRunState = "completed"
	AgentRunFailed     AgentRunState = "failed"
	AgentRunCancelled  AgentRunState = "cancelled"
	AgentRunSuperseded AgentRunState = "superseded"
)

type AuditEvent

type AuditEvent struct {
	ID         string
	IncidentID string
	Kind       string
	ActorID    string
	ObjectID   string
	Outcome    string
	Detail     string
	CreatedAt  time.Time
}

type AuthorityBoundary

type AuthorityBoundary string
const (
	AuthorityReadOnly          AuthorityBoundary = "read_only"
	AuthorityRepositoryWrite   AuthorityBoundary = "repository_write"
	AuthorityGovernedOperation AuthorityBoundary = "governed_operation"
)

type BoundDestination

type BoundDestination struct {
	ChannelID string `json:"channel_id"`
	ThreadTS  string `json:"thread_ts,omitempty"`
	Reason    string `json:"reason,omitempty"`
}

type ChannelConfiguration

type ChannelConfiguration struct {
	ChannelID        string   `json:"channel_id"`
	Participation    string   `json:"participation"`
	Repository       string   `json:"repository"`
	AlertPolicy      string   `json:"alert_policy"`
	InviteUsers      []string `json:"invite_users,omitempty"`
	InviteUserGroups []string `json:"invite_user_groups,omitempty"`
	ActorID          string   `json:"actor_id"`
	Revision         int      `json:"revision"`
	CreatedAt        time.Time
	UpdatedAt        time.Time
}

type ChannelMemory

type ChannelMemory struct {
	ChannelID         string
	Repository        string
	SessionID         string
	SessionRevision   int64
	CoopEventSequence int64
	Generation        int
	TurnCount         int
	State             AgentMemory
	SessionStarted    time.Time
	RotatedAt         time.Time
	UpdatedAt         time.Time
}

type ChannelState

type ChannelState string
const (
	ChannelPending     ChannelState = "pending"
	ChannelActive      ChannelState = "active"
	ChannelArchived    ChannelState = "archived"
	ChannelDeleted     ChannelState = "deleted"
	ChannelUnreachable ChannelState = "unreachable"
)

type ClaimAssessment

type ClaimAssessment struct {
	ID               string    `json:"id,omitempty"`
	EpisodeID        string    `json:"episode_id,omitempty"`
	ClaimID          string    `json:"claim_id"`
	Status           string    `json:"status"`
	Confidence       string    `json:"confidence,omitempty"`
	EvidenceIDs      []string  `json:"evidence_ids,omitempty"`
	ContradictionIDs []string  `json:"contradiction_ids,omitempty"`
	Detail           string    `json:"detail,omitempty"`
	UpdatedAt        time.Time `json:"updated_at,omitempty"`
}

type Commitment

type Commitment struct {
	ID          string
	AgentRunID  string
	ChannelID   string
	ThreadTS    string
	UserID      string
	Repository  string
	Title       string
	State       CommitmentState
	Status      string
	NextAction  string
	SourceKind  string
	SourceID    string
	CreatedAt   time.Time
	UpdatedAt   time.Time
	CompletedAt time.Time
}

Commitment is the operator-facing projection of durable agent work. The underlying AgentRun remains the execution record; this projection answers what Emisar owes the team without exposing model or Coop internals.

type CommitmentState

type CommitmentState string
const (
	CommitmentQueued    CommitmentState = "queued"
	CommitmentWorking   CommitmentState = "working"
	CommitmentFinishing CommitmentState = "finishing"
	CommitmentDone      CommitmentState = "done"
	CommitmentBlocked   CommitmentState = "blocked"
	CommitmentCancelled CommitmentState = "cancelled"
)

type ConfigurationSession

type ConfigurationSession struct {
	ID               string
	TeamID           string
	ChannelID        string
	ThreadTS         string
	ResponseThreadTS string
	ThreadRoots      []string
	Initiator        string
	Step             string
	Status           string
	Draft            ChannelConfiguration
	Revision         int
	ExpiresAt        time.Time
	CreatedAt        time.Time
	UpdatedAt        time.Time
}

type ContextManifest

type ContextManifest struct {
	ID                string
	EpisodeID         string
	AttemptID         string
	ParentManifestID  string
	Version           int
	PromptVersion     string
	ContractVersion   string
	ToolSchemaVersion string
	Preset            string
	Provider          string
	Model             string
	ReasoningEffort   string
	Omissions         []string
	CreatedAt         time.Time
	References        []ContextReference
}

ContextManifest is immutable. ContextReference values point at content-addressed or source-addressed inputs instead of duplicating payloads.

type ContextReference

type ContextReference struct {
	ID             string
	ManifestID     string
	Kind           string
	SourceRef      string
	ContentDigest  string
	SourceRevision string
	Visibility     string
	Ordinal        int
	OmittedReason  string
	Metadata       map[string]string
}

type ConversationMemory

type ConversationMemory struct {
	ChannelID      string
	ChannelName    string
	ThreadTS       string
	Repository     string
	LastMessage    string
	State          AgentMemory
	LastRecalledAt time.Time
	RecallCount    int
	UpdatedAt      time.Time
}

type ConversationRef

type ConversationRef struct {
	Platform    string `json:"platform"`
	WorkspaceID string `json:"workspace_id"`
	ChannelID   string `json:"channel_id"`
	ThreadTS    string `json:"thread_ts,omitempty"`
	AnchorTS    string `json:"anchor_ts,omitempty"`
	Visibility  string `json:"visibility"`
}

ConversationRef identifies the platform conversation in which work was accepted. It is a value object: lifecycle state belongs to WorkEpisode.

type ConversationRoute

type ConversationRoute struct {
	ChannelID        string
	UserID           string
	ActiveThreadTS   string
	PreviousThreadTS string
	Explicit         bool
	UpdatedAt        time.Time
}

type ConversationSession

type ConversationSession struct {
	ChannelID         string
	Repository        string
	Policy            string
	SessionID         string
	SessionRevision   int64
	CoopEventSequence int64
	Generation        int
	TurnCount         int
	SessionStarted    time.Time
	RotatedAt         time.Time
	UpdatedAt         time.Time
}

type CoopCleanup

type CoopCleanup struct {
	SessionID       string
	IncidentID      string
	Reason          string
	AllowUnmerged   bool
	State           string
	PlanOperationID string
	Attempts        int
	EligibleAt      time.Time
	NextAttemptAt   time.Time
	LastError       string
	CreatedAt       time.Time
	UpdatedAt       time.Time
}

type Coverage

type Coverage struct {
	ID          string    `json:"id,omitempty"`
	IncidentID  string    `json:"incident_id,omitempty"`
	ChannelID   string    `json:"channel_id,omitempty"`
	SourceInput string    `json:"source_input,omitempty"`
	Layer       string    `json:"layer"`
	ClaimIDs    []string  `json:"claim_ids,omitempty"`
	Status      string    `json:"status"`
	Source      string    `json:"source,omitempty"`
	Detail      string    `json:"detail,omitempty"`
	ObservedAt  time.Time `json:"observed_at,omitempty"`
	CreatedAt   time.Time `json:"created_at,omitempty"`
}

type EffortContract

type EffortContract string

EffortContract describes how complete a work episode must be before the host accepts its result. It is intentionally independent from AuthorityBoundary.

const (
	EffortConversational        EffortContract = "conversational"
	EffortFocusedCheck          EffortContract = "focused_check"
	EffortOperationalAssessment EffortContract = "operational_assessment"
	EffortIncidentInvestigation EffortContract = "incident_investigation"
	EffortEngineeringTask       EffortContract = "engineering_task"
)

type EmisarApproval

type EmisarApproval struct {
	RequestID          string    `json:"request_id"`
	IncidentID         string    `json:"incident_id,omitempty"`
	ChannelID          string    `json:"channel_id,omitempty"`
	SourceInput        string    `json:"source_input,omitempty"`
	RequestedBy        string    `json:"requested_by,omitempty"`
	DeliveryID         string    `json:"delivery_id,omitempty"`
	MessageTS          string    `json:"message_ts,omitempty"`
	RunID              string    `json:"run_id"`
	OperationID        string    `json:"operation_id"`
	ActionID           string    `json:"action_id"`
	PackRef            string    `json:"pack_ref"`
	RunnerRef          string    `json:"runner_ref"`
	Status             string    `json:"status"`
	ApprovalURL        string    `json:"approval_url"`
	RunURL             string    `json:"run_url,omitempty"`
	LastError          string    `json:"last_error,omitempty"`
	FailureCount       int       `json:"failure_count,omitempty"`
	ContinuationQueued bool      `json:"continuation_queued,omitempty"`
	NextCheckAt        time.Time `json:"next_check_at,omitempty"`
	ExpiresAt          time.Time `json:"expires_at"`
	TerminalAt         time.Time `json:"terminal_at,omitempty"`
	CreatedAt          time.Time `json:"created_at,omitempty"`
	UpdatedAt          time.Time `json:"updated_at,omitempty"`
}

type EpisodeActivity

type EpisodeActivity string
const (
	ActivityInvestigating EpisodeActivity = "investigating"
	ActivityExplaining    EpisodeActivity = "explaining"
	ActivityScheduling    EpisodeActivity = "scheduling"
	ActivityEngineering   EpisodeActivity = "engineering"
	ActivityOperating     EpisodeActivity = "operating"
)

type EpisodeAttempt

type EpisodeAttempt struct {
	ID                string
	EpisodeID         string
	AgentRunID        string
	Number            int
	State             EpisodeAttemptState
	FailureClass      string
	FailureGeneration int
	LeaseOwner        string
	FencingToken      int64
	LeaseExpiresAt    time.Time
	ContextManifestID string
	StartedAt         time.Time
	CompletedAt       time.Time
	CreatedAt         time.Time
	UpdatedAt         time.Time
}

type EpisodeAttemptState

type EpisodeAttemptState string
const (
	AttemptPending   EpisodeAttemptState = "pending"
	AttemptLeased    EpisodeAttemptState = "leased"
	AttemptRunning   EpisodeAttemptState = "running"
	AttemptSucceeded EpisodeAttemptState = "succeeded"
	AttemptFailed    EpisodeAttemptState = "failed"
	AttemptCancelled EpisodeAttemptState = "cancelled"
)

type EpisodeGoal

type EpisodeGoal struct {
	ID                   string
	EpisodeID            string
	ParentGoalID         string
	PrerequisiteGoalIDs  []string
	Kind                 string
	RequestedOutcome     string
	CompletionContract   string
	WritableRepository   string
	ReadOnlyRepositories []string
	AuthorityRequirement AuthorityBoundary
	Required             bool
	State                EpisodeGoalState
	Blocker              string
	CreatedAt            time.Time
	UpdatedAt            time.Time
	CompletedAt          time.Time
}

type EpisodeGoalState

type EpisodeGoalState string
const (
	GoalPlanned   EpisodeGoalState = "planned"
	GoalReady     EpisodeGoalState = "ready"
	GoalWorking   EpisodeGoalState = "working"
	GoalWaiting   EpisodeGoalState = "waiting"
	GoalCompleted EpisodeGoalState = "completed"
	GoalBlocked   EpisodeGoalState = "blocked"
	GoalExcluded  EpisodeGoalState = "excluded"
	GoalCancelled EpisodeGoalState = "cancelled"
)

type EpisodeMode

type EpisodeMode string
const (
	EpisodeConversation          EpisodeMode = "conversation"
	EpisodeCheck                 EpisodeMode = "check"
	EpisodeIncident              EpisodeMode = "incident"
	EpisodeEngineering           EpisodeMode = "engineering"
	EpisodeScheduledVerification EpisodeMode = "scheduled_verification"
	EpisodeStandingAssignment    EpisodeMode = "standing_assignment"
)

type EpisodeWakeup

type EpisodeWakeup struct {
	ID              string
	EpisodeID       string
	Kind            string
	EventMatcher    []byte
	DueAt           time.Time
	PollAfter       time.Time
	Deadline        time.Time
	State           EpisodeWakeupState
	LastObservation []byte
	LeaseOwner      string
	FencingToken    int64
	LeaseExpiresAt  time.Time
	CreatedAt       time.Time
	UpdatedAt       time.Time
	ResolvedAt      time.Time
}

type EpisodeWakeupState

type EpisodeWakeupState string
const (
	WakeupPending   EpisodeWakeupState = "pending"
	WakeupLeased    EpisodeWakeupState = "leased"
	WakeupResolved  EpisodeWakeupState = "resolved"
	WakeupExpired   EpisodeWakeupState = "expired"
	WakeupCancelled EpisodeWakeupState = "cancelled"
)

type EvaluationDecision

type EvaluationDecision struct {
	ID               string
	ChannelID        string
	SessionChannelID string
	ThreadTS         string
	MessageTS        string
	Repository       string
	SourceInput      string
	Mode             string
	Action           string
	Reason           string
	Evidence         int
	Coverage         int
	CreatedAt        time.Time
}

type Evidence

type Evidence struct {
	ID           string            `json:"id,omitempty"`
	IncidentID   string            `json:"incident_id,omitempty"`
	ChannelID    string            `json:"channel_id,omitempty"`
	SourceInput  string            `json:"source_input,omitempty"`
	ClaimID      string            `json:"claim_id,omitempty"`
	Claim        string            `json:"claim"`
	Observation  string            `json:"observation"`
	Relation     string            `json:"relation,omitempty"`
	HealthEffect string            `json:"health_effect,omitempty"`
	SourceType   string            `json:"source_type"`
	SourceID     string            `json:"source_id,omitempty"`
	SourceName   string            `json:"source_name"`
	SourceURL    string            `json:"source_url,omitempty"`
	Target       string            `json:"target,omitempty"`
	ScopeNote    string            `json:"scope_note,omitempty"`
	Freshness    string            `json:"freshness,omitempty"`
	Confidence   string            `json:"confidence,omitempty"`
	ObservedAt   time.Time         `json:"observed_at,omitempty"`
	ValidUntil   time.Time         `json:"valid_until,omitempty"`
	Dimensions   map[string]string `json:"dimensions,omitempty"`
	Metadata     map[string]string `json:"metadata,omitempty"`
	CreatedAt    time.Time         `json:"created_at,omitempty"`
}

func (*Evidence) UnmarshalJSON

func (item *Evidence) UnmarshalJSON(data []byte) error

UnmarshalJSON accepts scalar dimension values and normalizes them to their lossless textual form. Models commonly emit counts and boolean scope axes as JSON numbers or booleans; rejecting those values would not improve evidence integrity because dimensions are labels rather than measurements.

type FixtureCandidate

type FixtureCandidate struct {
	ID              string    `json:"id"`
	EpisodeID       string    `json:"episode_id"`
	RunID           string    `json:"run_id"`
	Capability      string    `json:"capability,omitempty"`
	CorrectionClass string    `json:"correction_class"`
	Correction      string    `json:"correction"`
	Status          string    `json:"status"`
	ReviewedBy      string    `json:"reviewed_by,omitempty"`
	CreatedAt       time.Time `json:"created_at"`
	ExpiresAt       time.Time `json:"expires_at"`
}

FixtureCandidate is a correction waiting to become a regression fixture.

The host already decided the model was wrong and said why, so the label costs nothing to produce. What it still needs is a human deciding the lesson is worth keeping — both because the design document requires review before anything enters a release gate, and because unreviewed corrections would fill the corpus with the same few mistakes.

type GeneratedVisual

type GeneratedVisual struct {
	Artifact string `json:"artifact"`
	Title    string `json:"title"`
	AltText  string `json:"alt_text"`
}

type Incident

type Incident struct {
	ID                    string
	Route                 string
	Repository            string
	CorrelationKey        string
	SourceIncidentID      string
	WorkKind              WorkKind
	WorkScope             WorkScope
	OriginChannelID       string
	OriginThreadTS        string
	Title                 string
	Severity              string
	Status                IncidentStatus
	Workflow              WorkflowState
	SignalCount           int
	FiringCount           int
	ChannelID             string
	ChannelName           string
	ChannelState          ChannelState
	ChannelStateChangedAt time.Time
	ChannelCheckedAt      time.Time
	RootTS                string
	CoopSessionID         string
	CoopForkName          string
	CoopRevision          int64
	CoopEventSequence     int64
	ActiveTurnID          string
	InitialTurnQueued     bool
	CardVersion           int64
	CardRenderedVersion   int64
	LastError             string
	CreatedAt             time.Time
	UpdatedAt             time.Time
	LastFiringAt          time.Time
	ResolveDueAt          time.Time
	ResolvedAt            time.Time
	ClosedAt              time.Time
}

func (Incident) ChannelWritable

func (i Incident) ChannelWritable() bool

func (Incident) ConversationThreadTS

func (i Incident) ConversationThreadTS() string

func (Incident) IsEngineeringTask

func (i Incident) IsEngineeringTask() bool

func (Incident) IsThreadScoped

func (i Incident) IsThreadScoped() bool

type IncidentStatus

type IncidentStatus string
const (
	IncidentActive     IncidentStatus = "active"
	IncidentMonitoring IncidentStatus = "monitoring"
	IncidentResolved   IncidentStatus = "resolved"
	IncidentClosed     IncidentStatus = "closed"
)

type KnowledgeItem

type KnowledgeItem struct {
	Subject         string `json:"subject"`
	Kind            string `json:"kind"`
	Statement       string `json:"statement"`
	Status          string `json:"status"`
	Confidence      int    `json:"confidence"`
	SourceRef       string `json:"source_ref"`
	SourceMessageTS string `json:"source_message_ts,omitempty"`
}

KnowledgeItem is a provenance-linked fact learned from a Slack conversation. It is continuity context, not an instruction, authority grant, or current operational evidence.

type MemoryEntry

type MemoryEntry struct {
	ID             string    `json:"id"`
	ScopeKind      string    `json:"scope_kind"`
	ScopeKey       string    `json:"scope_key"`
	SubjectKey     string    `json:"subject_key"`
	Predicate      string    `json:"predicate"`
	Value          string    `json:"value"`
	ValueHash      string    `json:"value_hash"`
	SourceRef      string    `json:"source_ref"`
	SourceRevision string    `json:"source_revision,omitempty"`
	ActorID        string    `json:"actor_id"`
	VisibilityKind string    `json:"visibility_kind"`
	VisibilityID   string    `json:"visibility_id"`
	ExpiresAt      time.Time `json:"expires_at"`
	LastRecalledAt time.Time `json:"last_recalled_at,omitempty"`
	RecallCount    int       `json:"recall_count"`
	LastReviewedAt time.Time `json:"last_reviewed_at,omitempty"`
	CreatedAt      time.Time `json:"created_at"`
	UpdatedAt      time.Time `json:"updated_at"`
}

type MemoryHealth

type MemoryHealth struct {
	ExplicitActive        int
	ExplicitRecalled      int
	ConversationSummaries int
	Rollups               int
	PendingReviews        int
	LastDreamedAt         time.Time
}

type MemoryOffer

type MemoryOffer struct {
	Scope          string `json:"scope"`
	Repository     string `json:"repository,omitempty"`
	Subject        string `json:"subject"`
	Predicate      string `json:"predicate"`
	Value          string `json:"value"`
	Visibility     string `json:"visibility"`
	ExpiresIn      string `json:"expires_in,omitempty"`
	SourceRevision string `json:"source_revision,omitempty"`
}

type MemoryReviewItem

type MemoryReviewItem struct {
	ID           string
	Kind         string
	EntryIDs     []string
	Reason       string
	SourceDigest string
	Status       string
	ReviewedBy   string
	ReviewedAt   time.Time
	CreatedAt    time.Time
	UpdatedAt    time.Time
}

type MemoryRollup

type MemoryRollup struct {
	ID             string
	ScopeKind      string
	ScopeKey       string
	Repository     string
	PeriodStart    time.Time
	PeriodEnd      time.Time
	State          AgentMemory
	SourceRefs     []string
	SourceCount    int
	LastRecalledAt time.Time
	RecallCount    int
	ExpiresAt      time.Time
	CreatedAt      time.Time
	UpdatedAt      time.Time
}

MemoryRollup is an automatically synthesized continuity summary. It is derived from already bounded conversation summaries and is never operational evidence.

type PreferenceOffer

type PreferenceOffer struct {
	Scope      string `json:"scope"`
	Repository string `json:"repository,omitempty"`
	Name       string `json:"name"`
	Value      string `json:"value"`
	ExpiresIn  string `json:"expires_in,omitempty"`
}

type PruneResult

type PruneResult struct {
	SlackInputs           int64
	WebhookEvents         int64
	SlackDeliveries       int64
	AgentRuns             int64
	EvaluationDecisions   int64
	ChannelIntelligence   int64
	ConversationMemories  int64
	MemoryEntries         int64
	MemoryRollups         int64
	MemoryReviews         int64
	MemorySupersessions   int64
	Preferences           int64
	StandingRules         int64
	StandingRuleRuns      int64
	ScheduledTasks        int64
	ScheduledTaskRuns     int64
	ActionProposals       int64
	EmisarApprovals       int64
	ConfigurationSessions int64
	ClosedIncidents       int64
	AuditEvents           int64
}

func (PruneResult) Total

func (r PruneResult) Total() int64

type Publication

type Publication struct {
	IncidentID    string
	Repository    string
	BaseBranch    string
	HeadBranch    string
	ParentHead    string
	CandidateTree string
	CommitSHA     string
	RemoteSHA     string
	PRNumber      int
	PRURL         string
	State         string
	LastError     string
	CreatedAt     time.Time
	UpdatedAt     time.Time
	PublishedAt   time.Time
}

func (Publication) HasPR

func (p Publication) HasPR() bool

func (Publication) NeedsUpdate

func (p Publication) NeedsUpdate() bool

func (Publication) Published

func (p Publication) Published() bool

type PublicationContext

type PublicationContext struct {
	IncidentID    string `json:"incident_id"`
	RepositoryKey string `json:"repository_key"`
	Repository    string `json:"repository"`
	Title         string `json:"title"`
	PRNumber      int    `json:"pr_number"`
	PRURL         string `json:"pr_url"`
	HeadBranch    string `json:"head_branch"`
	HeadSHA       string `json:"head_sha"`
	MergeSHA      string `json:"merge_sha,omitempty"`
	PRState       string `json:"pr_state"`
	ChecksState   string `json:"checks_state"`
	ChannelID     string `json:"channel_id"`
	ThreadTS      string `json:"thread_ts"`
}

type PublicationFollowup

type PublicationFollowup struct {
	IncidentID   string
	PRState      string
	ChecksState  string
	MergeSHA     string
	MergedAt     time.Time
	NextCheckAt  time.Time
	FailureCount int
	LastError    string
	LastEventKey string
	CreatedAt    time.Time
	UpdatedAt    time.Time
}

type PublicationLifecycleEvent

type PublicationLifecycleEvent struct {
	ID              string
	IncidentID      string
	Kind            string
	State           string
	Summary         string
	SourceChannelID string
	SourceMessageTS string
	CreatedAt       time.Time
}

type PublicationLifecycleStatus

type PublicationLifecycleStatus struct {
	PRState      string
	Draft        bool
	HeadSHA      string
	MergeSHA     string
	ChecksState  string
	ChecksTotal  int
	ChecksPassed int
	ChecksFailed int
	MergedAt     time.Time
}

type RemediationRecord

type RemediationRecord struct {
	Incident    Incident
	Signals     []Signal
	AgentRuns   []AgentRun
	Evidence    []Evidence
	Coverage    []Coverage
	Events      []TimelineEvent
	Proposals   []ActionProposal
	Approvals   []EmisarApproval
	Publication Publication
}

RemediationRecord is the durable, evidence-backed view of one incident. Its members remain canonical in their own tables; the timeline and postmortem are projections over this record rather than copied state.

type ResponderPreference

type ResponderPreference struct {
	ID        string
	ScopeKind string
	ScopeKey  string
	Name      string
	Value     string
	Enabled   bool
	SourceRef string
	ActorID   string
	ExpiresAt time.Time
	CreatedAt time.Time
	UpdatedAt time.Time
}

type RuleOffer

type RuleOffer struct {
	Scope      string `json:"scope"`
	Repository string `json:"repository"`
	Trigger    string `json:"trigger"`
	Action     string `json:"action"`
	SourceKind string `json:"source_kind,omitempty"`
	ExpiresIn  string `json:"expires_in,omitempty"`
}

type ScheduleOffer

type ScheduleOffer struct {
	Title           string   `json:"title"`
	Prompt          string   `json:"prompt"`
	Repository      string   `json:"repository"`
	DeliveryChannel string   `json:"delivery_channel_id,omitempty"`
	Recurrence      string   `json:"recurrence"`
	StartAt         string   `json:"start_at"`
	IntervalSeconds int64    `json:"interval_seconds,omitempty"`
	Weekdays        []string `json:"weekdays,omitempty"`
	DayOfMonth      int      `json:"day_of_month,omitempty"`
	LocalTime       string   `json:"local_time,omitempty"`
	Timezone        string   `json:"timezone,omitempty"`
	CatchUp         string   `json:"catch_up,omitempty"`
	ExpiresIn       string   `json:"expires_in,omitempty"`
}

ScheduleOffer is model-produced but inert until a configured operator confirms it. StartAt anchors the first occurrence when supplied. Calendar schedules keep wall-clock semantics in Timezone; interval schedules use IntervalSeconds after the first occurrence.

type ScheduleProposal

type ScheduleProposal struct {
	ID             string
	TeamID         string
	ChannelID      string
	ThreadTS       string
	ActorID        string
	SourceRef      string
	Task           ScheduledTask
	ReplaceTaskID  string
	Status         string
	AcceptedTaskID string
	ExpiresAt      time.Time
	CreatedAt      time.Time
	UpdatedAt      time.Time
}

ScheduleProposal keeps the complete normalized task on the server while Slack carries only its opaque ID. A proposal is inert until its actor accepts it, at which point AcceptedTaskID makes retries idempotent.

type ScheduledTask

type ScheduledTask struct {
	ID              string
	TeamID          string
	ChannelID       string
	ThreadTS        string
	DeliveryChannel string
	Repository      string
	Title           string
	Prompt          string
	Recurrence      string
	StartAt         time.Time
	IntervalSeconds int64
	Weekdays        []string
	DayOfMonth      int
	LocalTime       string
	Timezone        string
	CatchUp         string
	Enabled         bool
	ActorID         string
	SourceRef       string
	NextRunAt       time.Time
	LastRunAt       time.Time
	LastOutcome     string
	ExpiresAt       time.Time
	CreatedAt       time.Time
	UpdatedAt       time.Time
}

type ScheduledTaskRun

type ScheduledTaskRun struct {
	TaskID       string
	ScheduledFor time.Time
	SourceInput  string
	AgentRunID   string
	EpisodeID    string
	Outcome      string
	LastError    string
	StartedAt    time.Time
	CompletedAt  time.Time
	CreatedAt    time.Time
	UpdatedAt    time.Time
}

type Signal

type Signal struct {
	Route            string            `json:"route"`
	SourceID         string            `json:"source_id"`
	SourceIncidentID string            `json:"source_incident_id,omitempty"`
	EventID          string            `json:"event_id"`
	Repository       string            `json:"repository"`
	CorrelationKey   string            `json:"correlation_key"`
	Status           SignalStatus      `json:"status"`
	Title            string            `json:"title"`
	Severity         string            `json:"severity,omitempty"`
	Summary          string            `json:"summary,omitempty"`
	SourceURL        string            `json:"source_url,omitempty"`
	Labels           map[string]string `json:"labels,omitempty"`
	Annotations      map[string]string `json:"annotations,omitempty"`
	StartsAt         time.Time         `json:"starts_at,omitempty"`
	EndsAt           time.Time         `json:"ends_at,omitempty"`
	ReceivedAt       time.Time         `json:"received_at"`
	ResolveAfter     time.Duration     `json:"-"`
}

type SignalStatus

type SignalStatus string
const (
	SignalFiring   SignalStatus = "firing"
	SignalResolved SignalStatus = "resolved"
)

type SlackAttachment

type SlackAttachment struct {
	ID         string `json:"id"`
	Name       string `json:"name"`
	MediaType  string `json:"media_type"`
	Size       int64  `json:"size"`
	URLPrivate string `json:"url_private"`
}

SlackAttachment is durable Slack-owned metadata. URLPrivate is used only by the ordered input worker for an authenticated download and is never included in model prompts or Slack output.

type SlackDelivery

type SlackDelivery struct {
	ID                          string
	IncidentID                  string
	EpisodeID                   string
	ExpectedEpisodeRevision     int
	ExpectedDestinationRevision int
	Operation                   string
	Kind                        string
	ChannelID                   string
	ThreadTS                    string
	MessageTS                   string
	Body                        []byte
	Status                      string
	Steps                       []string
	CoalesceKey                 string
	CardVersion                 int64
	State                       string
	Attempts                    int
	NextAttemptAt               time.Time
	LastError                   string
	CreatedAt                   time.Time
}

type SlackInput

type SlackInput struct {
	ID          string
	EnvelopeID  string
	EventID     string
	Kind        string
	TeamID      string
	ChannelID   string
	ThreadTS    string
	MessageTS   string
	UserID      string
	Text        string
	Attachments []SlackAttachment
	Reactions   []SlackReaction
	ActionID    string
	ActionValue string
	Frozen      []byte
	State       string
	Attempts    int
	Failures    int
	ReceivedAt  time.Time
}

type SlackReaction

type SlackReaction struct {
	Name    string   `json:"name"`
	Count   int      `json:"count"`
	UserIDs []string `json:"user_ids,omitempty"`
}

SlackReaction is bounded conversation context returned by Slack. Reaction events use the existing ActionID and ActionValue fields so they remain durable without storing a second copy.

type StandingAssignment

type StandingAssignment struct {
	ID            string    `json:"id"`
	ChannelID     string    `json:"channel_id"`
	SignalPattern string    `json:"signal_pattern"`
	Repository    string    `json:"repository"`
	PathGlobs     []string  `json:"path_globs,omitempty"`
	ChangeClass   string    `json:"change_class"`
	DailyBudget   int       `json:"daily_budget"`
	ActorID       string    `json:"actor_id"`
	Enabled       bool      `json:"enabled"`
	ConfirmedAt   time.Time `json:"confirmed_at"`
	ExpiresAt     time.Time `json:"expires_at"`
	CreatedAt     time.Time `json:"created_at"`
	UpdatedAt     time.Time `json:"updated_at"`
}

StandingAssignment is scoped authority to act without a per-action click.

The confirmation is not removed, only moved earlier: an operator agrees once to a bounded shape of work. Every field except the identifiers is a bound on what that agreement covers.

func (StandingAssignment) Live

func (a StandingAssignment) Live(now time.Time) bool

Live reports whether an assignment may act right now.

type StandingRule

type StandingRule struct {
	ID            string
	ChannelID     string
	Repository    string
	Trigger       string
	Action        string
	SourceKind    string
	Enabled       bool
	SourceRef     string
	ActorID       string
	TriggerCount  int
	LastTriggered time.Time
	ExpiresAt     time.Time
	CreatedAt     time.Time
	UpdatedAt     time.Time
}

type StoredAgentResult

type StoredAgentResult struct {
	RunID     string    `json:"run_id"`
	Mode      string    `json:"mode"`
	Message   string    `json:"message"`
	CreatedAt time.Time `json:"created_at"`
}

StoredAgentResult is one historical model output, for replaying the result protocol against traffic that already happened.

type TimelineEvent

type TimelineEvent struct {
	ID          string
	IncidentID  string
	ChannelID   string
	Kind        string
	ActorID     string
	Title       string
	Detail      string
	URL         string
	EvidenceIDs []string
	CreatedAt   time.Time
}

func RemediationTimeline

func RemediationTimeline(record RemediationRecord) []TimelineEvent

RemediationTimeline derives an append-only-looking operator view from the canonical incident records. Stable IDs make the projection deterministic.

type WebhookEvent

type WebhookEvent struct {
	ID            string
	Route         string
	DedupeKey     string
	BodyDigest    string
	Signals       []Signal
	IncidentIDs   []string
	Applied       bool
	State         string
	Attempts      int
	NextAttemptAt time.Time
	LastError     string
	ReceivedAt    time.Time
}

type WorkEpisode

type WorkEpisode struct {
	ID                  string
	WorkspaceID         string
	ParentEpisodeID     string
	Mode                EpisodeMode
	Conversation        ConversationRef
	Destination         BoundDestination
	DestinationRevision int
	Revision            int
	LatestAttemptID     string
	AuthoritySnapshot   string
	// AgentRunID is the first attempt retained for compatibility while callers
	// migrate to EpisodeAttempt. It is not the lifecycle owner.
	AgentRunID         string
	Effort             EffortContract
	Authority          AuthorityBoundary
	Activity           EpisodeActivity
	State              WorkEpisodeState
	Objective          string
	RequiredCoverage   []string
	CompletionCriteria []string
	Phase              string
	Status             string
	NextAction         string
	EventSequence      int
	ProgressSequence   int
	LastProgressAt     time.Time
	ProgressDueAt      time.Time
	CreatedAt          time.Time
	UpdatedAt          time.Time
	CompletedAt        time.Time
}

WorkEpisode is the host-owned execution contract for one accepted unit of work. AgentRun remains the transport record; this record says what must be accomplished, what authority is available, and what the team is waiting for.

type WorkEpisodeEvent

type WorkEpisodeEvent struct {
	ID             string          `json:"id"`
	EpisodeID      string          `json:"episode_id"`
	Sequence       int             `json:"sequence"`
	Kind           string          `json:"kind"`
	Actor          string          `json:"actor"`
	IdempotencyKey string          `json:"idempotency_key"`
	Payload        json.RawMessage `json:"payload"`
	CreatedAt      time.Time       `json:"created_at"`
}

type WorkEpisodeProgress

type WorkEpisodeProgress struct {
	ID        string
	EpisodeID string
	Sequence  int
	Phase     string
	Summary   string
	CreatedAt time.Time
}

type WorkEpisodeState

type WorkEpisodeState string
const (
	EpisodeAccepted        WorkEpisodeState = "accepted"
	EpisodeAcknowledged    WorkEpisodeState = "acknowledged"
	EpisodePlanning        WorkEpisodeState = "planning"
	EpisodeWorking         WorkEpisodeState = "working"
	EpisodeBlocked         WorkEpisodeState = "blocked"
	EpisodeWaitingOperator WorkEpisodeState = "waiting_operator"
	EpisodeWaitingExternal WorkEpisodeState = "waiting_external"
	EpisodeWaitingApproval WorkEpisodeState = "waiting_approval"
	EpisodeRetrying        WorkEpisodeState = "retrying"
	EpisodeVerifying       WorkEpisodeState = "verifying"
	EpisodeCompleted       WorkEpisodeState = "completed"
	EpisodeFailed          WorkEpisodeState = "failed"
	EpisodeRefused         WorkEpisodeState = "refused"
	EpisodeCancelled       WorkEpisodeState = "cancelled"
	EpisodeSuperseded      WorkEpisodeState = "superseded"
)

type WorkKind

type WorkKind string
const (
	WorkKindIncident        WorkKind = "incident"
	WorkKindEngineeringTask WorkKind = "engineering_task"
)

type WorkScope

type WorkScope string
const (
	WorkScopeRoom   WorkScope = "room"
	WorkScopeThread WorkScope = "thread"
)

type WorkflowState

type WorkflowState string
const (
	WorkflowProvisioningChannel WorkflowState = "provisioning_channel"
	WorkflowProvisioningSession WorkflowState = "provisioning_session"
	WorkflowHolding             WorkflowState = "holding"
	WorkflowInvestigating       WorkflowState = "investigating"
	WorkflowParked              WorkflowState = "parked"
	WorkflowBlocked             WorkflowState = "blocked"
	WorkflowClosed              WorkflowState = "closed"
)

Jump to

Keyboard shortcuts

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