daemon

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: Apache-2.0 Imports: 77 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 daemon is the resident process behind the serve command: it runs the collector and the sweep on a schedule and serves the API on a Unix socket and on a token-guarded localhost port.

Index

Constants

View Source
const HomesMaxAge = 10 * time.Minute

HomesMaxAge is how old the last check of the agent homes may be before a health read starts another in the background.

View Source
const (
	ReadModelCheckEnv = "LOOP_READMODEL_CHECK"
)
View Source
const ReconcileWait = 30 * time.Second

ReconcileWait is how long UserAPI waits for the start-up reconcile before it serves anyway.

View Source
const RecordFileSlack = 2 * time.Second

RecordFileSlack is how much older than its turn's start a record file may be.

View Source
const ShutdownGrace = 5 * time.Second

ShutdownGrace is how long the daemon waits for open requests to finish when it stops.

Variables

View Source
var ErrAlreadyRunning = errors.New("daemon already running")

Functions

func BadRequest

func BadRequest(msg string) error

BadRequest is an error the daemon answers with 400.

func BriefMissing

func BriefMissing(ctx context.Context) string

BriefMissing is why the turn an intake starts under ctx goes without a brief; "" when it has one or ctx is no intake's.

func CheckInputs

func CheckInputs(reg *dintent.Registry, d dintent.Def, in map[string]any, surface, source string, automated bool) (map[string]any, error)

CheckInputs validates a request's inputs against the intent's definition and normalizes them to their types; surface is where the request comes from, "" for a client that sends no inputs.

func LockFile

func LockFile(path string, busy error) (unlock func(), err error)

LockFile takes an exclusive flock on path without waiting; busy is the error when another process holds it.

func LoopHeld

func LoopHeld(ctx context.Context) bool

LoopHeld tells a context whose caller holds the daemon's loop mutex, as an intake's start does: what runs under it must not take the mutex again.

func NotOffered

func NotOffered(action string, u unit.Unit) string

NotOffered is the conflict of an action the row does not offer.

func ReadInfo

func ReadInfo(path string) (api.Info, error)

func StoreWarning added in v0.2.0

func StoreWarning(st api.StoreStatus) string

StoreWarning is st as one line: the message and the command to run.

Types

type Actions

type Actions interface {
	Open(ctx context.Context, u unit.Unit, c Call) error // Focus the workspace, else the PR in the browser
	Adopt(ctx context.Context, u unit.Unit, c Call) error
	// Intent runs a round of the named intent; Call.Inputs holds the
	// request's inputs and those its prepare filled.
	Intent(ctx context.Context, name string, u unit.Unit, c Call) error
	Run(ctx context.Context, u unit.Unit, c Call) error // sends the held round now; never counts against the cap
	// Remove deletes the local workspace of a merged or closed pull request,
	// or answers a Refusal when it would lose work.
	Remove(ctx context.Context, u unit.Unit, c Call) error
}

Actions are the operations with side effects outside the store. The daemon runs each one but Open under its loop mutex.

type AheadPreparer added in v0.3.0

type AheadPreparer interface {
	PrepareAhead(ctx context.Context, name string, u unit.Unit, c Call) error
}

AheadPreparer is Actions that readies, before an intent's round takes the loop mutex, what the round needs and may take long to get, such as a clone of its repository.

type AheadReader

type AheadReader interface {
	ReadAhead(ctx context.Context, u unit.Unit, full bool) context.Context
}

AheadReader is Actions that reads, before an action takes the loop mutex, what the action asks GitHub, so that it asks nothing while holding it; full also reads the pull request in full.

type AppState

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

AppState holds the app's last report; nil until the app reports.

func (*AppState) Get

func (a *AppState) Get() *api.AppStatus

func (*AppState) Set

func (a *AppState) Set(st api.AppStatus) bool

Set stores st and reports whether it differs from the last report.

type BlockReader added in v0.3.0

type BlockReader interface {
	StartBlockKey(ctx context.Context, u unit.Unit) (key string, ok bool, err error)
}

BlockReader is Actions that names the start block holding a unit's round: the subject of the trust gate it waits on.

type BriefAttempts added in v0.3.0

type BriefAttempts interface {
	// Attempt is the brief attempt a first turn of u waits on.
	Attempt(ctx context.Context, u unit.Unit) (int, error)
}

BriefAttempts are the brief attempts the intakes wait on.

type BriefHealth

type BriefHealth interface {
	Status(ctx context.Context) (brief.Status, error)
	// Breaker is the brief breaker; open is false while briefs run.
	Breaker() (open bool, since time.Time, lastErr string, next time.Time)
}

BriefHealth is the brief queue as health reads it.

type BriefQueue

type BriefQueue interface {
	Run(ctx context.Context) (string, error)
	// Touched wakes the queue for units whose brief inputs changed.
	Touched(units []unit.Unit)
	// Due is signaled when followed units are due a background brief.
	Due() <-chan struct{}
	// Forget drops a unit's brief, so the next run makes it again.
	Forget(ctx context.Context, u unit.Unit) error
}

BriefQueue is the brief queue the daemon runs as a job.

type Budget

type Budget interface {
	// Low says the budget refuses background reads.
	Low() bool
	// RateLimit is the budget as a client shows it.
	RateLimit() api.RateLimit
}

Budget is the forge's rate-limited budget.

type Call

type Call struct {
	Guidance string
	// AgentHome is the caller's agent home; empty means the one the
	// project's settings name.
	AgentHome string
	// Out receives what the action reports, sent back to the caller.
	Out io.Writer
	// WorkspaceID is the workspace remove acts on; "" is the one its unit
	// is linked to.
	WorkspaceID string
	// Force lets remove past the workspace manager's terminal check.
	Force bool
	// Inputs are the intent's inputs, normalized to their types.
	Inputs map[string]any
	// Items are the unit's item ids and Task the task task the action was asked from; the turn's
	// drafts are tied to them.
	Items []string
	Task  string
	// Manager and Parent are the request's: the workspace manager of the
	// worktree the turn creates and the caller's worktree.
	Manager, Parent string
	// Block is the start block a trust gate names, which TrustAndRun and
	// Unblock refuse to act past once another block replaced it; "" acts on
	// the unit's block.
	Block string
}

Call is what a delegated action gets besides the pull request.

type CardsJob

type CardsJob interface {
	// Changed must not block: the read model's publish waits on it.
	Changed(c api.Change)
	Run(ctx context.Context, rows cards.Rows)
}

CardsJob keeps the cards and derived items current with the rows.

type Collector

type Collector interface {
	SlowJob(ctx context.Context) (summary, skipped string, err error)
}

Collector is the sources' slow job, which rebuilds what their ingestion keeps cheap; skipped holds truncation and warnings, which surface in health without failing the job.

type Deps

type Deps struct {
	// Units parses the keys of the unit routes; the providers it knows are
	// the daemon's.
	Units *unit.Registry
	// Ingest are the sources' ingestion jobs.
	Ingest []IngestJob
	// Loading are the plugins that have not loaded since the daemon
	// started, with why, by id; nil has none.
	Loading func() map[string]string
	// PluginHealth is how each plugin the daemon runs answers; nil runs
	// none.
	PluginHealth func(context.Context) []api.PluginHealth
	// RowProviders build the read model's providers with the daemon's row
	// deps, one per source.
	RowProviders []func(readmodel.RowDeps) readmodel.Provider
	// The store, one field per role; a nil role answers as a daemon with
	// no store does.
	Events    EventLog
	Overrides Overrides
	Meta      Metas
	Records   Records
	// GitAccess keeps how git network operations went per host; nil keeps
	// them in Store.
	GitAccess *GitAccessLog
	Meter     *meter.Registry // nil counts nothing
	// Fallbacks is how many workspace manager calls went to its CLI because
	// its runtime drifted; nil when it does not count them.
	Fallbacks func() int64
	Pauses    Pauses // nil reads as not paused and refuses a pause
	// Collector runs the slow job; nil registers no fast and slow jobs.
	Collector Collector
	// Track reads a unit about to be tracked through its source, wrapping a
	// failed read in port.ErrNotFound or port.ErrGitHub when it can tell
	// which; the read's Save admits and follows it. Nil tracks nothing.
	Track func(ctx context.Context, u unit.Unit) (port.TrackRead, error)
	// Follows says whether a provider's source keeps its own follows: track
	// and untrack of its units go to Track and Untrack. Nil follows none.
	Follows func(unit.ProviderID) bool
	Untrack func(ctx context.Context, u unit.Unit) error
	// Resolve is the unit an address a person gives lands in, such as a
	// Slack message ref; ok is false when no plugin reads it. Nil reads none.
	Resolve func(ctx context.Context, address string) (u unit.Unit, ok bool, err error)
	// PluginAction runs an action of plugin id that names no unit; nil
	// runs none.
	PluginAction func(ctx context.Context, id string, req api.PluginActionRequest) (json.RawMessage, error)
	// PluginRun runs a command line of running plugin id, writing as it
	// goes; nil runs none.
	PluginRun func(ctx context.Context, id string, args []string, stdout, stderr io.Writer) (exit int, err error)
	Sweep     Sweeper // nil registers no sweep job
	Actions   Actions // nil answers 503 to delegated actions
	// Intents is the registry as the profile defines it now, read on every
	// rows rebuild and action; nil serves the bundled intents.
	Intents func() *intentload.Loaded
	// Plan is the workflows' plan; nil answers 503 to the plan routes.
	Plan Plan
	// Plans are the automatic rounds the open plan gates hold, which the rows
	// show; nil shows none.
	Plans   readmodel.Plans
	Changes *change.Log // nil notes nothing
	// Snapshot pins the read model's loads to one read transaction; nil
	// loads without one.
	Snapshot readmodel.Snapshotter
	// Brief, BriefStatus and BriefAttempts are the brief queue's roles; nil
	// when brief.enabled is false.
	Brief         BriefQueue
	BriefStatus   BriefHealth
	BriefAttempts BriefAttempts
	Usage         *coreusage.Service // nil registers no usage job
	// Retain drops the store's rows past their retention and says what it
	// dropped; nil registers no retain job.
	Retain func(ctx context.Context) (summary string, err error)
	// Budget is the forge's budget; nil reads as unknown.
	Budget Budget
	// Turns, Sessions and Views are the turn and view use cases and the
	// sessions turns are typed into; nil answers 503 from the routes that
	// need them.
	Turns    *turns.Service
	Sessions turns.Sessions
	Views    *coreviews.Service
	// RunHost opens a run's workspace and enters its session; Transcripts
	// pages its agent transcript. nil offers neither.
	RunHost     RunHost
	Transcripts turns.Transcripts
	// Agents are the agents' states as the workspace snapshot last read
	// them, never a call to the manager; nil reads as unknown, so a started
	// turn's session is never told waiting.
	Agents readmodel.Agents
	// Activity reads what the loop spent on each provider's units for their
	// rows; nil shows none.
	Activity readmodel.Activities
	// TurnByHand runs a turn the user asked for in the handle's session, ""
	// outside Orca; nil answers 503 to AgentAPI's by-hand turns.
	TurnByHand func(ctx context.Context, r api.ByHandRequest, handle string) (api.ByHandResult, error)
	// Intakes keeps the turns users ask for: review, address and run are
	// accepted at once and start once the first turn's brief is ready. nil
	// runs them at once and answers when they end.
	Intakes intake.Store
	// IntakeBriefs tells an intake whether its brief is ready; nil starts
	// every intake without one, as with briefs off.
	IntakeBriefs intake.Briefs
	// ByHandRef is the pull request a turn by hand is about; with Intakes
	// it takes the turn through an intake, nil runs it at once.
	ByHandRef func(ctx context.Context, r api.ByHandRequest, handle string) (unit.Unit, error)
	// BriefsUnavailable is why briefs are on in the config but the daemon
	// cannot run them; "" when it can or they are off.
	BriefsUnavailable string
	// Facts reads what a pull request's guide is matched against, for
	// profile show <pr-url>; nil answers 503.
	Facts func(ctx context.Context, u unit.Unit) (api.Facts, error)
	// SessionWait is how long a turn by hand waits for its brief; 0 is
	// brief.SessionWait.
	SessionWait time.Duration
	// AfterFunc arms the timer that ends a turn by hand's session wait and
	// returns its stop; nil is time.AfterFunc.
	AfterFunc func(d time.Duration, f func()) (stop func() bool)
	// LoopMu serializes every loop write: sweep, review, take over, address, run.
	// Shared across restarts of the server in one process; nil makes one.
	LoopMu *lock.Mutex
	// App is the menu bar's status, shared across restarts of the server
	// like LoopMu; nil makes one.
	App *AppState
	Cfg config.Config
	// Identity is who the viewer is in the forge, as its plugin's
	// Presenter.Identity says; nil knows nobody.
	Identity func(ctx context.Context) (src.Identity, error)
	// Forge is the plugin of the units the daemon's viewer, intakes, brief
	// queue, timings and budget serve; they serve nothing while it is
	// disabled.
	Forge unit.ProviderID
	// Repo is the repository of a unit, owner/name; "" none, and nil
	// knows none.
	Repo func(ctx context.Context, u unit.Unit) (string, error)
	// Background tags a job's context as background work, below the user's
	// reserve of the forge's budget; nil tags nothing.
	Background func(ctx context.Context) context.Context
	// Presenters build each compiled-in plugin's presenter, by provider,
	// with what the daemon serves it.
	Presenters map[unit.ProviderID]func(PresenterHost) Presenter
	// PluginPresenter is a running plugin's presenter; nil runs none.
	PluginPresenter func(unit.ProviderID) (Presenter, bool)
	Now             func() time.Time
	Version         string
	Log             func(format string, args ...any)
	StateDir        string
	Socket          string
	LockPath        string
	InfoPath        string
	// Restart is the command that restarts the daemon, which a refused
	// client of another API major is told to run.
	Restart string
	// Store is the open store's version and last backup, for the health.
	Store *api.StoreStatus
	// ConfigWarning is the health warning about config.toml drifting from the
	// running config, "" for none; nil never warns.
	ConfigWarning func() string
	// EffectWarnings are the turn effects that went unapplied after their
	// turn went out; nil lists none.
	EffectWarnings func() []string
	// WorkspaceManager names the workspace managers in messages, such as
	// "Claude Desktop or Orca".
	WorkspaceManager string
	// WorkspaceManagers name the enabled managers for the health answer, as
	// displayed; ManagerNames are their registry names, and a hook naming
	// another one is refused.
	WorkspaceManagers []string
	ManagerNames      []string
	// NotifierStart is the command that starts the menu bar; "" when this
	// daemon expects none, and then its absence is no warning.
	NotifierStart string
	// Notices are what the workflows raise for the user, streamed to the
	// event subscribers as they come; nil raises none.
	Notices Notices

	// MCP serves agents' MCP sessions on 127.0.0.1:MCPPort; nil listens on
	// no MCP port.
	MCP http.Handler
	// ReadText words what an agent's turn answer command reads, as task_read does, read of gate id or of every
	// unread answer when 0; nil prints the answers and the chat bare.
	ReadText func(ctx context.Context, got messages.TaskRead, id int64) string
	MCPPort  int

	// Startup reconciles the store and the views; Run holds
	// UserAPI until it returns. nil serves at once with no report.
	Startup func(ctx context.Context) (api.ReconcileReport, error)
	// Homes checks the agent homes; Run checks them at start, the slow job,
	// doctor, a session home no check covered and a health read of a result
	// older than HomesMaxAge check them again, and health reads the last
	// result. nil reports none.
	Homes func(ctx context.Context) ([]api.HomeFinding, error)
	// DryRunTurn stores the review turn of a profile try; nil answers 503.
	DryRunTurn func(ctx context.Context, r api.DryRunTurnRequest) (api.DryRunTurn, error)
	// Doctor runs doctor's checks that read the loop's state; nil runs none
	// but the reconcile's.
	Doctor func(ctx context.Context, q api.DoctorQuery) (api.DoctorReport, error)
	// Plugins are every compiled-in plugin; PluginEnabled nil: all enabled.
	Plugins       []api.Plugin
	PluginEnabled func(unit.ProviderID) bool
	// Runtimes are the enabled plugins' streams, jobs and health.
	Runtimes []PluginRuntime
	// Items is the items ledger; nil answers 503 to the items routes.
	Items ItemsLedger
	// Cards are the units' stored cards; nil serves none.
	Cards card.Store
	// CardsJob is told each published row change; nil runs none.
	CardsJob CardsJob
	// Tasks is the tasks service; nil answers 503 to the tasks routes and runs no Sync. Messages are the
	// Inbox messages, whose tasks' verbs it registers on Tasks.
	Tasks    *coretasks.Service
	Messages *messages.Service
	// Row is what a task's row shows of its facts: TaskView.OwedBy, Askers and ExtractionLag; nil leaves them
	// empty.
	Row func(ctx context.Context, t task.Task) (catalog.Row, error)
	// Timeline reads a task's timeline; nil answers 503 to its route. TaskRecords are the records units
	// keep, a task's brief among them; nil serves no Brief.
	Timeline    timeline.Reader
	TaskRecords timeline.Records
	// Gates resolves the decisions waiting on the user and GateReader lists them; nil answers 503 to the gate
	// routes and serves no TaskView.Gates.
	Gates      *gates.Service
	GateReader gates.Reader
	// RecordWriter keeps the brief a created task carries; nil refuses a create with a brief. Placements
	// keep where a created task's work runs; nil refuses a create with a placement.
	RecordWriter RecordWriter
	Placements   placement.Overrides
	// Drafts are the outbox's drafts the notifications read; nil: no draft notifies.
	Drafts Drafts
	// TasksMe resolves the user's identity over the enabled plugins and sets it on Tasks, saying whether it grew;
	// the Sync worker calls it before each batch until it succeeds. nil: Tasks' identity stands.
	TasksMe func(ctx context.Context) (grew bool, err error)
	// TaskUnits are the units a full Sync covers: those with an open item or a live task; nil: none.
	TaskUnits func(ctx context.Context) ([]unit.Unit, error)
	// Wakes match the tasks' wakes after each tasks sync; nil matches none.
	Wakes Wakes
	// Outbox keeps the drafts; nil answers 503 to the draft routes. SendDrafts runs its sender, which
	// publishes the approved drafts.
	Outbox     *outbox.Service
	SendDrafts bool
	// Headless starts headless turns; nil answers 503 to the act route.
	Headless Headless
	// Placer says where a session on a unit of a provider other than GitHub runs; nil offers the
	// session mode unchecked.
	Placer Placer
}

type Drafts

type Drafts interface {
	List(ctx context.Context, f outbox.Filter) ([]draft.Draft, error)
}

Drafts lists the outbox's drafts; *outbox.Service satisfies it.

type EventLog

type EventLog interface {
	RecentActivity(ctx context.Context, limit int) ([]port.Activity, error)
	RecordEvent(ctx context.Context, ev port.Event) error
}

EventLog reads and records the loop's events.

type Explained

type Explained struct {
	Unit      unit.Unit
	Items     []workflow.Item
	Workflows []api.UnitWorkflow
	Errors    []string
}

Explained is a unit's decisions: its items, and a line per workflow that gives none.

func Explain

func Explain(ctx context.Context, eng *automation.Engine, u unit.Unit) (Explained, error)

Explain evaluates every trigger's workflows on eng, which writes nothing, and matches the `when` of each workflow that gave u no item against u's facts, naming the facts it read and the reasons the providers give.

type Explainer

type Explainer interface {
	Explain(ctx context.Context, u unit.Unit) (Explained, error)
}

Explainer is an optional capability of Plan: what every workflow of a unit's provider decides for that unit now, those that give no item included.

type GitAccessLog

type GitAccessLog struct {
	Store Metas
	// contains filtered or unexported fields
}

GitAccessLog keeps, per host, the latest git network operation and the latest success, in the store's meta table.

func (*GitAccessLog) Hosts

func (l *GitAccessLog) Hosts(ctx context.Context) ([]api.GitAccess, error)

Hosts are the hosts seen so far, sorted by name.

func (*GitAccessLog) Record

type Headless

type Headless interface {
	Start(ctx context.Context, r headless.Request) (int64, error)
}

Headless starts headless turns; Start returns once the turn is stored, and its call runs on.

type Implemented added in v0.2.0

type Implemented struct{ Effects []string }

Implemented are the builtins the daemon implements: the turn effects it applies. A role's prepare is its plugin's action (builtin.PrepareAction).

func Builtins

func Builtins() Implemented

Builtins are the builtins the daemon implements.

type IngestJob

type IngestJob struct {
	ID  unit.ProviderID
	Job ingest.Job
}

IngestJob is a source's ingestion job; the daemon runs it as the job "ingest:<ID>".

type ItemsLedger

type ItemsLedger interface {
	Items(ctx context.Context, u unit.Unit) ([]items.Item, error)
}

ItemsLedger is the items ledger as the unit card reads it.

type Keeper added in v0.3.0

type Keeper interface {
	Keep(ctx context.Context, k readmodel.Kept) error
}

Keeper is a compiled-in plugin's bookkeeping on each new snapshot of the rows: the writes its rows imply, such as a mute whose situation changed.

type Metas

type Metas interface {
	Meta(ctx context.Context, key string) (string, error)
	MetaPrefixed(ctx context.Context, prefix string) (map[string]string, error)
	SetMeta(ctx context.Context, key, value string) error
}

Metas keeps the daemon's small values by key.

type Notices

type Notices interface {
	// Follow calls fn with each notice raised until stop is called.
	Follow(fn func(api.Notice)) (stop func())
}

Notices are the notifications the workflows raise for the user.

type Overrides

type Overrides interface {
	Override(ctx context.Context, u unit.Unit) (map[string]string, error)
	// SetOverride writes set in one transaction only while ifMatch holds;
	// a value "" clears one.
	SetOverride(ctx context.Context, u unit.Unit, set, ifMatch map[string]string) (written bool, err error)
	// Held are the units of provider p the user holds.
	Held(ctx context.Context, p unit.ProviderID) ([]unit.Unit, error)
}

Overrides are the host's overrides of units, by name (port.Overrides).

type Pauses

type Pauses interface {
	Pause(ctx context.Context) (round.Pause, error)
	SetPause(ctx context.Context, p round.Pause) error
}

Pauses keeps the pause of every workflow that does not observe and of board moves.

type Placer

type Placer interface {
	SessionPlace(ctx context.Context, u unit.Unit) (string, error)
}

Placer says where a session on u would run, or why none can.

type Plan

type Plan interface {
	// Evaluate is what the workflows of trigger t would decide now; it
	// writes nothing and notes nothing.
	Evaluate(ctx context.Context, t workflow.TriggerKind) (automation.Plan, error)
	// Items are the stored plan's items f selects.
	Items(ctx context.Context, f automation.Filter) ([]workflow.Item, error)
	// Act carries the user's action on item id; the caller holds the loop
	// lock.
	Act(ctx context.Context, id string, a workflow.Action, guidance string) (workflow.Item, error)
	// Drop discards u's pending items without marking them handled.
	Drop(ctx context.Context, u unit.Unit, why string) error
	// Release is the consequence of the resolved plan gate g on the item it
	// names; the caller holds the loop lock.
	Release(ctx context.Context, g gate.Gate) error
}

Plan is the workflows' plan and the user's actions on it.

type PluginJob

type PluginJob struct {
	Name    string
	Every   time.Duration
	Timeout time.Duration // a run's limit; 0 is pluginTimeout
	Run     func(ctx context.Context) (summary, skipped string, err error)
}

PluginJob is a plugin's daemon job, named as the plugin names it.

type PluginRuntime

type PluginRuntime struct {
	ID unit.ProviderID
	// Run is a long-running stream, run until the daemon stops and started
	// again streamRestart after it returns.
	Run    func(ctx context.Context) error
	Jobs   []PluginJob
	Health func(ctx context.Context) (api.SourceHealth, error)
	// WebAssets are served under /plugins/<id>/.
	WebAssets fs.FS
}

PluginRuntime is what an enabled plugin runs in the daemon; a nil field is absent.

type Presenter added in v0.3.0

type Presenter interface {
	Action(ctx context.Context, req src.ActionRequest) (json.RawMessage, error)
	View(ctx context.Context, req src.ViewRequest) (json.RawMessage, error)
}

Presenter is a plugin's source logic as the daemon reaches it: the actions a person runs on its units and its views. A running plugin's client is one; so is a compiled-in module's.

type PresenterHost added in v0.3.0

type PresenterHost struct {
	Model *readmodel.Model
	// Settings are the rows' settings now; BriefOn says the brief queue runs.
	Settings func() readmodel.RowSettings
	BriefOn  bool
	// Intakes are the open intakes by unit, the oldest first.
	Intakes func(ctx context.Context) (map[unit.Unit][]intake.Intake, error)
	// Books are the units' turn books; nil when the daemon keeps no turns.
	Books func(ctx context.Context, units ...unit.Unit) (map[unit.Unit]turn.Book, error)
	// Viewer is who the viewer is in the forge, cached.
	Viewer func(ctx context.Context) (src.Identity, error)
	// Units are the daemon's codecs.
	Units *unit.Registry
	Now   func() time.Time
	Logf  func(format string, args ...any)
}

PresenterHost is what the daemon serves a compiled-in plugin's presenter beside the broker: the rows as the read model derives them.

type RecordWriter added in v0.3.0

type RecordWriter interface {
	PutRecord(ctx context.Context, u unit.Unit, kind string, w task.Writer, data []byte, at time.Time) error
}

RecordWriter keeps a unit's record of a kind, written by w; a new one replaces the unit's last of that kind.

type Records

type Records interface {
	Turn(ctx context.Context, id string) (port.SentText, bool, error)
	// Brief is u's stored brief; ok is false for none.
	Brief(ctx context.Context, u unit.Unit) (b intake.StoredBrief, ok bool, err error)
	// UnitlessEvents are the events of no source's unit, oldest first.
	UnitlessEvents(ctx context.Context) ([]port.Event, error)
}

Records reads what turns and briefs left behind.

type Refusal

type Refusal struct {
	Reason, Detail string
	// Source names the tool whose message Detail is, "" for the loop's own.
	Source    string
	Forceable bool
}

Refusal is an action that would do harm, with the reason and its detail. Forceable marks a refusal that asking again with force would get past.

func (Refusal) Error

func (e Refusal) Error() string

type RunHost added in v0.3.0

type RunHost interface {
	// Focus brings the workspace on screen in the manager's app.
	Focus(ctx context.Context, manager, workspaceID string) error
	// Wake gives the dormant session of u a live process again in its
	// manager, launched as a turn of intent on u would be.
	Wake(ctx context.Context, u unit.Unit, intent string, sess turn.Session) error
}

RunHost reaches a run's workspace and session in their workspace manager.

type Server

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

func New

func New(d Deps) *Server

func (*Server) AuthHandler

func (s *Server) AuthHandler() http.Handler

AuthHandler is Handler behind the token check, for the TCP port, which serves no AgentAPI and no AdminAPI.

func (*Server) BriefReady

func (s *Server) BriefReady(ctx context.Context, u unit.Unit) (intake.Readiness, error)

BriefReady is the brief queue's answer for a round the sweep is about to propose or send on the pull request.

func (*Server) Decide added in v0.3.0

func (s *Server) Decide(ctx context.Context, g gate.Gate) error

Decide is a resolved proposal gate's consequence: a verb a gate held runs, once approved, as the person through the verb path a person's request takes, its bridge and reply included; any other proposal is the messages'.

func (*Server) Deliver added in v0.3.0

func (s *Server) Deliver(ctx context.Context, g gate.Gate) error

Deliver is a resolved question or post gate's consequence: the messages deliver its answer, under the loop lock with the gate's unit read ahead, as an answer typed or resumed expects.

func (*Server) Handler

func (s *Server) Handler() http.Handler

Handler is the API and the cockpit without authentication, for the socket.

func (*Server) LinkState added in v0.3.0

func (s *Server) LinkState(ctx context.Context, u unit.Unit) (signals map[string]bool, moved time.Time, ok bool, err error)

LinkState is what the read model holds of unit u for the facts of the tasks that link it: its link signals, and when it last moved, the start of its situation under the host's overlays; ok is false for a unit no provider serves a row of.

func (*Server) Once added in v0.3.0

func (s *Server) Once(g gate.Gate) bool

Once says a gate's consequence runs at most once: a round the daily cap held, and a verb a gate held, act in the user's name and leave nothing a second run reads.

func (*Server) OpenIntakes

func (s *Server) OpenIntakes(ctx context.Context) ([]intake.Intake, error)

OpenIntakes lists the open intakes but the session ones nobody asks for; none when the daemon keeps no intakes.

func (*Server) RecheckHomes

func (s *Server) RecheckHomes(ctx context.Context)

RecheckHomes checks the agent homes now; concurrent calls share one check.

func (*Server) Release added in v0.3.0

func (s *Server) Release(ctx context.Context, g gate.Gate) error

Release is a resolved plan gate's consequence: the plan carries it onto the item the gate names, under the loop lock; an approved gate of a round the daily cap held runs that round by hand.

func (*Server) Run

func (s *Server) Run(ctx context.Context) error

func (*Server) RunJob

func (s *Server) RunJob(name string) bool

RunJob queues a run of the named job; false when no such job.

func (*Server) SocketHandler added in v0.3.0

func (s *Server) SocketHandler() http.Handler

SocketHandler is Handler with the runtime's profiles under /debug/pprof/, for the socket alone: the person who owns the socket reads them, never the token-guarded port.

func (*Server) Unblock added in v0.3.0

func (s *Server) Unblock(ctx context.Context, g gate.Gate) error

Unblock is a resolved trust gate's consequence on the start block of its unit's round: an approval trusts the folder and runs the round, any other resolution lifts the block until a new trigger.

func (*Server) Wait added in v0.3.0

func (s *Server) Wait()

Wait blocks until every goroutine Run started has returned, those it left running past the shutdown grace included; the owner of the stores they read waits here before closing them.

type StoreWait added in v0.2.0

type StoreWait struct {
	Version  string
	StateDir string
	Socket   string
	LockPath string
	InfoPath string
	// HTTPPort is the cockpit's configured port; 0 reuses the earlier one.
	HTTPPort int
	// Status is the store's state, read on each request.
	Status func() api.StoreStatus
	// Ready is asked every Every; true ends the wait.
	Ready func() bool
	Every time.Duration
}

StoreWait is the daemon while it cannot open its store: it answers its health with the store's state, refuses every other request with that state's message and fix, and returns once Ready says the store may open. It holds the daemon's lock and socket meanwhile, so clients reach it, not a second daemon.

func (StoreWait) Run added in v0.2.0

func (w StoreWait) Run(ctx context.Context) error

type SweepFunc

type SweepFunc func(ctx context.Context) (summary, skipped string, err error)

SweepFunc is a Sweeper with no deadline that reads no snapshot and runs whole under the loop lock.

func (SweepFunc) Due

func (SweepFunc) Due() time.Time

func (SweepFunc) Seen

func (SweepFunc) Seen() port.Generation

func (SweepFunc) Sweep

func (f SweepFunc) Sweep(ctx context.Context, loop sync.Locker) (string, string, error)

type Sweeper

type Sweeper interface {
	// Sweep plans without loop and takes loop only to act on the plan.
	Sweep(ctx context.Context, loop sync.Locker) (summary, skipped string, err error)
	// Due is the earliest instant a decision of the last sweep changes with
	// no input changing: conflict window end, start block day, cap rollover
	// with a capped step, a review turn reaching the 30-day cutoff. Zero
	// when none.
	Due() time.Time
	// Seen is the change log generation the last sweep's workspace snapshot
	// read was current at; zero when it read none.
	Seen() port.Generation
}

Sweeper is the sweep job's port.

type Unblocker

type Unblocker interface {
	// TrustAndRun trusts the folder the round's start block names, in the
	// agent home the round ran with or, unknown, in every agent home the
	// loop knows, lifts the block and sends the round now.
	TrustAndRun(ctx context.Context, u unit.Unit, c Call) error
	// Unblock marks the trigger of the round a start block holds handled,
	// so the round waits for a new one; the caller records the block lifted.
	Unblock(ctx context.Context, u unit.Unit, c Call) error
}

Unblocker is Actions that lifts the start block of a round.

type Wakes added in v0.3.0

type Wakes interface {
	Sweep(ctx context.Context) error
}

Wakes match the tasks' wakes due, and those whose condition holds.

Jump to

Keyboard shortcuts

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