Documentation
¶
Overview ¶
Package roomctrl reconciles Room CRs (S2): the log row and its first event, the finalizer that deletes the room's runs and seals the log, and status.
Index ¶
Constants ¶
const (
// Finalizer holds a deleted Room until its runs have ended and its log is sealed.
Finalizer = "agents.ogenki.io/room-log"
)
const ForkedFrom = "agents.ogenki.io/forked-from"
ForkedFrom annotates a forked Room with <source room>@<seq>: where its log's copied prefix ends, and its state_changed{forked_from} follows.
Variables ¶
This section is empty.
Functions ¶
func ForkSeq ¶
ForkSeq is the last seq a forked room copied from its source, or 0 for a room that is no fork.
func ParseRetention ¶
ParseRetention reads spec.retention ("<n>d", 1 to 9999). Empty means OD-17's 90 days.
Types ¶
type Reconciler ¶
type Reconciler struct {
// Client reads and writes Rooms and deletes runs; without APIReader it also lists them.
Client client.Client
// APIReader, when set, lists the finalizer's runs uncached (mgr.GetAPIReader()), so a stale cache can't seal early; nil falls back to Client.
APIReader client.Reader
Store Store
// Runs feeds the status projection; a deletion lists runs through Client.
Runs runIndex
// Ends is required: a deletion records every run's end before it seals.
Ends runEnds
// Observe, when set, feeds the rooms{phase} and rooms_last_event_timestamp_seconds gauges.
Observe func(room string, st v1alpha1.RoomStatus, lastEventAt time.Time)
// Forget, when set, is told of a room whose CR is gone, so it leaves the gauges.
Forget func(room string)
// Now is the clock for the stall check and the seal timeout; nil means time.Now.
Now func() time.Time
// Log receives the seal-timeout warning; nil discards it.
Log *slog.Logger
// Suspend, when set, suspends and resumes the room's runs at each resync (v2 suspend);
// nil leaves them be.
Suspend suspender
}
Reconciler keeps a Room's log row, first event and status in step with the CR.
func (*Reconciler) Reconcile ¶
Reconcile ensures the room's row and its seq-1 Open event, projects the log and the runs into status, and requeues every resync so a stall is noticed.
func (*Reconciler) SetupWithManager ¶
func (r *Reconciler) SetupWithManager(mgr ctrl.Manager) error
SetupWithManager registers the reconciler for Rooms, refusing a missing dependency: a nil one would panic on the first deletion, and controller-runtime would recover and retry forever with the Room stuck Terminating. It runs one reconcile at a time by default, which bounds the store's load.
type Store ¶
type Store interface {
EnsureRoom(ctx context.Context, r store.NewRoom) (bool, error)
Append(ctx context.Context, d envelope.Draft) (envelope.Event, bool, error)
Room(ctx context.Context, id string) (store.RoomState, error)
CloseRoom(ctx context.Context, id, reason string) error
PendingApprovals(ctx context.Context, roomID string) (int, error)
// LastTaskState is the payload of the room's highest-seq state_changed{kind:task} above
// after, or nil.
LastTaskState(ctx context.Context, roomID string, after int64) (json.RawMessage, error)
}
Store is the part of the log the reconciler writes and reads. Broker-origin events take the plain Append; sealing goes only through CloseRoom (Ruling Y).