event

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2026 License: MIT Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	Type      EventType       `json:"type"`
	Payload   json.RawMessage `json:"payload,omitempty"`
	Timestamp time.Time       `json:"timestamp"`
	SessionID string          `json:"session_id"`
}

Event is one append-only NDJSON record in a session event log.

type EventFilter

type EventFilter struct {
	Types map[EventType]struct{}
	Since *time.Time
	Until *time.Time
}

EventFilter limits event reads by type and time range.

type EventReader

type EventReader struct {
	// contains filtered or unexported fields
}

EventReader reads session event logs.

func NewEventReader

func NewEventReader(runtimeDir string) *EventReader

NewEventReader constructs a reader rooted at a .noodle runtime directory.

func (*EventReader) ReadSession

func (r *EventReader) ReadSession(sessionID string, filter EventFilter) ([]Event, error)

ReadSession reads events for one session and applies the filter.

func (*EventReader) TailSession

func (r *EventReader) TailSession(sessionID string, n int, filter EventFilter) ([]Event, error)

TailSession reads the most recent n events for one session after filtering.

type EventType

type EventType string

EventType is the normalized event type used in session event logs.

const (
	// Core runtime events.
	EventSpawned     EventType = "spawned"
	EventAction      EventType = "action"
	EventCost        EventType = "cost"
	EventStateChange EventType = "state_change"
	EventExited      EventType = "exited"
	EventDelta       EventType = "delta"

	// Cook lifecycle events.
	EventCookStarted   EventType = "cook_started"
	EventCookCompleted EventType = "cook_completed"

	// Stage message events (emitted by agents via CLI).
	EventStageMessage EventType = "stage_message"

	// Stage yield events (emitted by agents to declare deliverable complete).
	EventStageYield EventType = "stage_yield"

	// Ticket protocol events.
	EventTicketClaim    EventType = "ticket_claim"
	EventTicketProgress EventType = "ticket_progress"
	EventTicketDone     EventType = "ticket_done"
	EventTicketBlocked  EventType = "ticket_blocked"
	EventTicketRelease  EventType = "ticket_release"
)

type EventWriter

type EventWriter struct {
	// contains filtered or unexported fields
}

EventWriter appends events to one session log.

func NewEventWriter

func NewEventWriter(runtimeDir, sessionID string) (*EventWriter, error)

NewEventWriter constructs a writer for one session.

func (*EventWriter) Append

func (w *EventWriter) Append(ctx context.Context, event Event) error

Append writes one event as NDJSON.

type LoopEvent

type LoopEvent struct {
	Seq     uint64          `json:"seq"`
	Type    LoopEventType   `json:"type"`
	At      time.Time       `json:"at"`
	Payload json.RawMessage `json:"payload,omitempty"`
}

LoopEvent is one append-only NDJSON record in loop-events.ndjson.

type LoopEventType

type LoopEventType string

LoopEventType is a lifecycle event emitted by the loop.

const (
	LoopEventStageCompleted     LoopEventType = "stage.completed"
	LoopEventStageFailed        LoopEventType = "stage.failed"
	LoopEventOrderCompleted     LoopEventType = "order.completed"
	LoopEventOrderFailed        LoopEventType = "order.failed"
	LoopEventOrderDropped       LoopEventType = "order.dropped"
	LoopEventOrderRequeued      LoopEventType = "order.requeued"
	LoopEventWorktreeMerged     LoopEventType = "worktree.merged"
	LoopEventMergeConflict      LoopEventType = "merge.conflict"
	LoopEventScheduleCompleted  LoopEventType = "schedule.completed"
	LoopEventRegistryRebuilt    LoopEventType = "registry.rebuilt"
	LoopEventSyncDegraded       LoopEventType = "sync.degraded"
	LoopEventBootstrapCompleted LoopEventType = "bootstrap.completed"
	LoopEventBootstrapExhausted LoopEventType = "bootstrap.exhausted"
	LoopEventPromotionFailed    LoopEventType = "promotion.failed"
)

type LoopEventWriter

type LoopEventWriter struct {
	// contains filtered or unexported fields
}

LoopEventWriter appends lifecycle events to an NDJSON file. It is safe for concurrent use.

func NewLoopEventWriter

func NewLoopEventWriter(path string) *LoopEventWriter

NewLoopEventWriter creates a writer targeting the given file path. It reads the file to determine the next sequence number (continuing from the highest existing sequence).

func (*LoopEventWriter) Emit

func (w *LoopEventWriter) Emit(eventType LoopEventType, payload any) error

Emit appends a lifecycle event. The payload is marshaled to JSON. On write failure, a warning is logged to stderr and the error is returned — callers should ignore the error (best-effort emission).

func (*LoopEventWriter) Seq

func (w *LoopEventWriter) Seq() uint64

Seq returns the current sequence number.

type StageMessagePayload

type StageMessagePayload struct {
	Message  string `json:"message"`
	Blocking *bool  `json:"blocking,omitempty"`
}

StageMessagePayload is the payload for stage_message events.

func (StageMessagePayload) IsBlocking

func (p StageMessagePayload) IsBlocking() bool

IsBlocking returns whether the message blocks auto-advance. Default (nil) is true — blocking.

type StageYieldPayload

type StageYieldPayload struct {
	Message string `json:"message"`
}

StageYieldPayload is the payload for stage_yield events. Agents emit this when their deliverable is complete, decoupling result delivery from process exit.

type Ticket

type Ticket struct {
	Target       string           `json:"target"`
	TargetType   TicketTargetType `json:"target_type"`
	CookID       string           `json:"cook_id"`
	Files        []string         `json:"files,omitempty"`
	ClaimedAt    time.Time        `json:"claimed_at"`
	LastProgress time.Time        `json:"last_progress"`
	Status       TicketStatus     `json:"status"`
	BlockedBy    string           `json:"blocked_by,omitempty"`
	Reason       string           `json:"reason,omitempty"`
}

Ticket is the current materialized claim for one target.

func ActiveTickets

func ActiveTickets(tickets []Ticket) []Ticket

ActiveTickets returns non-terminal tickets.

type TicketEventPayload

type TicketEventPayload struct {
	Target     string           `json:"target"`
	TargetType TicketTargetType `json:"target_type"`
	Files      []string         `json:"files,omitempty"`
	Summary    string           `json:"summary,omitempty"`
	Outcome    string           `json:"outcome,omitempty"`
	BlockedBy  string           `json:"blocked_by,omitempty"`
	Reason     string           `json:"reason,omitempty"`
}

TicketEventPayload is the payload contract used by ticket protocol events.

type TicketMaterializer

type TicketMaterializer struct {
	// contains filtered or unexported fields
}

TicketMaterializer derives active tickets from session event logs.

func NewTicketMaterializer

func NewTicketMaterializer(runtimeDir string) *TicketMaterializer

NewTicketMaterializer constructs a ticket materializer.

func (*TicketMaterializer) Materialize

func (m *TicketMaterializer) Materialize(ctx context.Context, activeSessionIDs []string) ([]Ticket, error)

Materialize reads active session logs and writes tickets.json atomically.

If activeSessionIDs is empty, all discovered session directories are used.

type TicketStatus

type TicketStatus string

TicketStatus is the materialized ticket state.

const (
	TicketStatusActive  TicketStatus = "active"
	TicketStatusBlocked TicketStatus = "blocked"
)

type TicketTargetType

type TicketTargetType string

TicketTargetType identifies what a ticket claims.

const (
	TicketTargetBacklogItem TicketTargetType = "backlog_item"
	TicketTargetFile        TicketTargetType = "file"
	TicketTargetPlanPhase   TicketTargetType = "plan_phase"
)

Jump to

Keyboard shortcuts

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