roomctrl

package
v0.40.1 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: Apache-2.0 Imports: 20 Imported by: 0 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

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

View Source
const (
	// Finalizer holds a deleted Room until its runs have ended and its log is sealed.
	Finalizer = "maku.ogenki.io/room-log"
)
View Source
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

func ForkSeq(room *v1alpha1.Room) int64

ForkSeq is the last seq a forked room copied from its source, or 0 for a room that is no fork.

func ParseRetention

func ParseRetention(s string) (time.Duration, error)

ParseRetention reads spec.retention ("<n>d", 1 to 9999). Empty means OD-17's 90 days.

func Phase

func Phase(st store.RoomState, runs []runwatch.Run, pending int, now time.Time) string

Phase projects the log and the runs into the §1 state diagram.

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
	// Kind is the runs kind, required: a deletion lists and reads the room's runs as its claims.
	Kind runwatch.Kind
	// 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

func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)

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).

Jump to

Keyboard shortcuts

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