Documentation
¶
Overview ¶
Package pending owns the domain types and helpers for the passive-capture queue. Events land in pending_events and stay there until the model promotes them to memories via tl_promote, or the worker archives old ones.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrEmptyEventType = errors.New("pending: event_type must not be empty") ErrUnknownEventType = errors.New("pending: unknown event_type (not one of the 6 accepted names)") ErrEmptyProject = errors.New("pending: project must not be empty") ErrEmptyPayload = errors.New("pending: payload must not be empty") ErrInvalidStatus = errors.New("pending: status must be pending, promoted, or archived") )
Sentinel errors for Validate.
var KnownEventTypes = map[string]bool{ "SessionStart": true, "UserPromptSubmit": true, "PreToolUse": true, "PostToolUse": true, "Stop": true, "SessionEnd": true, }
KnownEventTypes is the exhaustive set of Claude Code hook event names that thoughtline hook accepts. Events outside this set are silently skipped (exit 0, log to stderr).
Functions ¶
func ComputeHash ¶
func ComputeHash(eventType, sessionID, toolUseID string, capturedAt time.Time, payload []byte) string
ComputeHash returns a stable SHA-256 fingerprint for an event tuple.
Composition:
sha256( eventType "\n"
sessionID "\n"
toolUseID "\n"
capturedAt-floored-to-second "\n"
canonicalPayload )
capturedAt is truncated to the second (nanoseconds stripped) so multiple observations within the same second from the same tool call hash identically — useful for SessionStart/Stop where no tool_use_id distinguishes events.
canonicalPayload is the JSON payload re-encoded with sorted keys and no extra whitespace. If the payload is not valid JSON the raw bytes are used verbatim (capture still succeeds; dedup is best-effort for malformed input).
Types ¶
type Event ¶
type Event struct {
ID int64
SyncID string
Project string
SessionID string // "" when absent
EventType string
ToolName string // "" when absent
ToolUseID string // "" when absent
Payload string // raw JSON as received on stdin
Hash string
Status Status
PromotedMemoryID int64 // 0 when not promoted
PromotedAt time.Time
ArchivedAt time.Time
CreatedAt time.Time
CapturedAt time.Time
}
Event is the domain representation of a row in pending_events.