Documentation
¶
Overview ¶
Package source adapts the source kind of plugins to the daemon: the host's side of the broker a source plugin calls, one file per broker interface; the host adapters of each capability (publisher, briefs, payload, placement, checkouts, tools); the manifest codecs; and the kind adapter the plugin host starts each source plugin through. It converts the protocol's units, task ids and drafts to the domain's.
No broker method takes the loop's lock: a broker call runs on the plugin connection's goroutine while the host may hold that lock around the call that led the plugin to make it.
Index ¶
- Constants
- func Decode(st snapshot.Stored) (src.Snapshot, error)
- func HostTopics(ts ...plugin.Topic) port.Topic
- func ItemOf(w src.Item) items.Item
- func JobName(id, job string) string
- func TaskID(s string) (task.ID, error)
- func Wire(u unit.Unit) plugin.Unit
- func WireDraft(d draft.Draft) src.Draft
- func WireTopics(t port.Topic) []plugin.Topic
- func Wires(us []unit.Unit) []plugin.Unit
- type Answer
- type BriefStore
- type Briefs
- func (b Briefs) Describe(in brief.UnitInput) string
- func (b Briefs) Input(ctx context.Context, u unit.Unit) (brief.UnitInput, error)
- func (b Briefs) Revision(ctx context.Context, u unit.Unit) (brief.At, error)
- func (b Briefs) Stale(w brief.Written, cur brief.At, version string, now time.Time) bool
- func (b Briefs) Want(ctx context.Context, u unit.Unit) (bool, error)
- type Broker
- type Catalog
- func (c Catalog) CardSignals() []api.SignalSpec
- func (c Catalog) Details() []api.DetailSpec
- func (c Catalog) Events() []api.EventSpec
- func (c Catalog) Facets() []api.FacetSpec
- func (c Catalog) Lens() api.ProviderWords
- func (c Catalog) PluginUI() *api.PluginUI
- func (c Catalog) Reasons() api.ProviderWords
- func (c Catalog) Situations() []api.SituationSpec
- func (c Catalog) Views() []api.ViewSpec
- type Checkouts
- type DraftGate
- type DraftHome
- type DraftLister
- type EventLog
- type Hosted
- type ItemLedger
- type Kind
- func (k *Kind) Client(id string) (*src.Client, error)
- func (k *Kind) Down(id string)
- func (k *Kind) Expect(ids ...string)
- func (k *Kind) Kind() plugin.Kind
- func (k *Kind) Loading() map[string]string
- func (k *Kind) Notify(ctx context.Context, changes port.Changes, from port.Generation)
- func (k *Kind) Start(ctx context.Context, m *manifest.Manifest, c *plugin.Client) error
- func (k *Kind) Stop(ctx context.Context, id string)
- type MarkStore
- type Meters
- type OverrideStore
- type PayloadPlanner
- type Payloads
- type Placements
- type Proposals
- type Publisher
- func (p Publisher) Landed(ctx context.Context, d draft.Draft) (unit.Unit, bool, error)
- func (p Publisher) Live(ctx context.Context, u unit.Unit, kind string) (string, error)
- func (p Publisher) Place(ctx context.Context, d draft.Draft) (draft.Placed, error)
- func (p Publisher) Publish(ctx context.Context, d draft.Draft) (draft.Evidence, error)
- func (p Publisher) Takes(target string) bool
- func (p Publisher) Validate(ctx context.Context, d draft.Draft) error
- func (p Publisher) Verify(ctx context.Context, d draft.Draft, startedAt time.Time) (draft.Evidence, bool, error)
- func (p Publisher) Where(ctx context.Context, d draft.Draft) (string, error)
- func (p Publisher) Within(ctx context.Context, u unit.Unit, target string) (bool, error)
- type SessionBooks
- type SettledFacts
- type Snapshots
- func (s *Snapshots) Last(ctx context.Context, u unit.Unit) (src.Snapshot, bool, error)
- func (s *Snapshots) OnStale(f func(unit.ProviderID))
- func (s *Snapshots) Put(ctx context.Context, ss map[unit.Unit]src.Snapshot) error
- func (s *Snapshots) Reported(ctx context.Context, units []unit.Unit) (map[unit.Unit]src.Snapshot, error)
- func (s *Snapshots) Revs(ctx context.Context, units []unit.Unit) (map[unit.Unit]uint64, error)
- func (s *Snapshots) SetDown(p unit.ProviderID, down bool)
- func (s *Snapshots) Stale(u unit.Unit) bool
- func (s *Snapshots) Unextracted(ctx context.Context, units []unit.Unit) (time.Time, error)
- func (s *Snapshots) Units(ctx context.Context, p unit.ProviderID) ([]unit.Unit, error)
- type TaskLookup
- type TaskWakes
- type Tools
- type UnitFacts
- type Units
Constants ¶
const ( ReasonStarting = "starting" ReasonDown = "not running" )
Reason why an expected plugin has not loaded, before it says why itself.
const DefaultHealthPoll = time.Second
DefaultHealthPoll is how often a Kind with a zero HealthPoll asks a loading plugin its health.
const DefaultNotifyTimeout = 10 * time.Second
DefaultNotifyTimeout is the bound of one Notify of a Kind with a zero NotifyTimeout.
KeyNav is the action of a [source.ui] key that jumps to the plugin's views.
const SettledFact = "settled_at"
SettledFact is the name, after a plugin's slot, of the fact the host fills in a workflow's scope: the newest update of a settled draft the workflow proposed on the unit.
Variables ¶
This section is empty.
Functions ¶
func HostTopics ¶
HostTopics are the host topics behind ts.
func JobName ¶ added in v0.4.0
JobName is the host's name of plugin id's manifest job job, one after its ingestion job.
func WireTopics ¶
WireTopics are the plugin topics t, a set of host topics, touches.
Types ¶
type BriefStore ¶
type BriefStore interface {
PutUnitBrief(ctx context.Context, u unit.Unit, version, body string, at time.Time) error
PutRecord(ctx context.Context, u unit.Unit, kind string, w task.Writer, data []byte, at time.Time) error
ItemsHeld(ctx context.Context, u unit.Unit) (map[task.ID][]string, error)
Records(ctx context.Context, kind string, units ...unit.Unit) (map[unit.Unit]port.Event, error)
}
BriefStore keeps the briefs a plugin writes. PutUnitBrief keeps body, the brief JSON a plugin wrote of u at version, as the brief u uses since at; PutRecord keeps a task's brief record. ItemsHeld are the items of u each task holding u or one of its items holds.
type Briefs ¶
Briefs is a source plugin's Briefer as the brief queue reads it.
type Broker ¶
type Broker struct {
// ID is the plugin's id, the provider of its units.
ID string
// Manifest is the plugin's [source] table.
Manifest *manifest.Source
Units Units
// Snapshots keep what the plugin reports.
Snapshots *Snapshots
// Config is the configuration in force.
Config func() config.Config
// Note records a change in the host's change log; nil records none.
Note func(t port.Topic, units ...unit.Unit)
// Events are the host's events; nil serves neither Recorder.RecordEvents
// nor History.
Events EventLog
// Marks are the host's handled marks of units; nil serves no SetMarks.
Marks MarkStore
// Drafts move drafts between units; nil serves no RehomeDrafts.
Drafts DraftHome
// Overrides are the host's overrides of units; nil serves neither
// SetOverride nor RoundState.
Overrides OverrideStore
// Wakes are the host's tasks as wakes move them; nil serves neither
// SetWake nor ClearWake.
Wakes TaskWakes
// Paused says a unit's rounds are held by a pause wider than its own
// hold, such as its repository's; nil holds none.
Paused func(ctx context.Context, u unit.Unit) (bool, error)
// Briefs keep the briefs the plugin writes of its units, and Briefed
// hears of each unit whose brief it wrote; nil Briefs serves no
// PutBrief.
Briefs BriefStore
Briefed func(u unit.Unit)
// BriefRecords set the properties a task's brief record projects; nil
// sets none.
BriefRecords *brief.Records
// Now is the host's clock; PutBrief needs it.
Now func() time.Time
// BriefIntent is the brief intent of a provider's units as the loaded
// profile resolves it, which Config hands the plugin; nil hands none.
BriefIntent func(p unit.ProviderID) brief.Intent
// Rounds is a unit's round bookkeeping: its marks, sends, counts and
// start block; nil serves a RoundState of overrides alone.
Rounds func(ctx context.Context, u unit.Unit) (src.RoundState, error)
// Links keep the links the plugin's snapshots report; nil keeps none.
Links port.LinkStore
// Hosted are the host's services the plugin spends; nil serves none.
Hosted *Hosted
// Meters take the samples the plugin meters; nil serves no Meter.
Meters *Meters
// Workspaces lists the host's workspaces of a repository, "" every one;
// nil serves no Reader.Workspaces.
Workspaces func(ctx context.Context, repo string) (src.Listing, error)
// Books are the turn books of units; nil serves no Reader.Books.
Books func(ctx context.Context, units ...unit.Unit) (map[unit.Unit]turn.Book, error)
// WakeJob runs the host job named name, a [JobName], at at, or now when at is zero; false when the host
// runs no such job. nil serves no Jobs.
WakeJob func(name string, at time.Time) bool
}
Broker is the host's side of the broker of one source plugin: what the plugin calls back. Each broker interface lives in its own file; a method the host does not serve yet answers ErrUnsupported.
func (*Broker) TasksHolding ¶
TasksHolding gives each task that holds items of one of the units and has no brief record yet, such as one reconcile made after the plugin wrote the unit's brief, the unit's plugin brief with the asks of the items it holds, as PutBrief does. A unit's brief the host wrote, such as a pull request's, stays the unit's: a task that starts holding the unit takes its properties alone (brief.Records.ProjectUnheld).
type Catalog ¶
type Catalog struct {
Source *manifest.Source
// Texts are the plugin's words as the profile last loaded them; nil
// words nothing.
Texts func() intentload.UITexts
}
Catalog is a source plugin's views, facets and situations, and what its clients show of it, as its manifest declares them and its profile layer's ui.toml words them; an id ui.toml does not word shows as itself.
func BundledCatalog ¶
BundledCatalog is bundled plugin id's catalog, worded by its own layer alone; one with no bundled manifest has none.
func (Catalog) CardSignals ¶ added in v0.4.0
func (c Catalog) CardSignals() []api.SignalSpec
CardSignals are the plugin's words of its cards' signals, by key, in key order; a signal whose values take words from the situations reads each kind as the situations do unless its own values word it.
func (Catalog) Details ¶
func (c Catalog) Details() []api.DetailSpec
Details are the words of the fields of the plugin's unit detail, in field order.
func (Catalog) Events ¶
Events are the words of the event kinds the manifest declares that its profile layer words; a kind it leaves out shows as itself.
func (Catalog) Lens ¶ added in v0.4.0
func (c Catalog) Lens() api.ProviderWords
Lens are the plugin's own row words, those its profile layers set.
func (Catalog) PluginUI ¶
PluginUI is what the plugin's clients show of it: a saved view per view, the menu bar's sections, its keys, the key that jumps to its views and its web directory; nil for a plugin whose manifest declares no [source.ui].
func (Catalog) Reasons ¶ added in v0.4.0
func (c Catalog) Reasons() api.ProviderWords
Reasons are the plugin's words of the reasons its situations name, by reason key.
func (Catalog) Situations ¶
func (c Catalog) Situations() []api.SituationSpec
type Checkouts ¶
Checkouts is a source plugin's Lander as the host reads where a unit's work checks out, which directory holds a unit, and a task's move written back to the source.
type DraftGate ¶
type DraftGate interface {
Propose(ctx context.Context, p outbox.Proposal) (draft.Draft, error)
RecordSent(ctx context.Context, p outbox.Proposal, ev draft.Evidence) (draft.Draft, error)
PublisherOf(d draft.Draft) unit.ProviderID
}
DraftGate is the host's outbox as a plugin proposes and records drafts.
type DraftHome ¶
type DraftHome interface {
RehomeDrafts(ctx context.Context, moves map[unit.Unit]unit.Unit) (int, error)
}
DraftHome moves the drafts of each unit of moves onto the unit it maps to, in one transaction, and counts them.
type DraftLister ¶
DraftLister lists the host's drafts.
type EventLog ¶
type EventLog interface {
RecordSourceEvents(ctx context.Context, evs ...port.Event) error
UnitEvents(ctx context.Context, units []unit.Unit, kinds []string, since time.Time) ([]port.Event, error)
}
EventLog is the host's event log as a plugin writes and reads it.
type Hosted ¶
type Hosted struct {
Items ItemLedger
// Ask asks the host's agent; an answer over its cost cap fails with
// turns.ErrOverBudget.
Ask func(ctx context.Context, req src.AskRequest) (src.AskResult, error)
// Profile reads path in the plugin's profile layer.
Profile func(ctx context.Context, path string) ([]byte, error)
// Holds says whether the plugin's predicate holds over each of sets, as one loaded profile sets it.
Holds func(ctx context.Context, predicate string, sets []map[string]any) ([]src.Holding, error)
// Sessions are the host's sessions and their turns.
Sessions SessionBooks
// Intents is the loaded registry, whose drafts.allowed_effects bound a
// session's drafts.
Intents func() *dintent.Registry
Drafts DraftGate
Tasks TaskLookup
// Resolve is the unit an address lands in, through every plugin's codec.
Resolve func(ctx context.Context, address string) (unit.Unit, bool, error)
Now func() time.Time
}
Hosted are the host's services a plugin spends beyond its unit data: the items ledger, the agent, the profile layer, the drafts it proposes, the sessions that propose them, the tasks of its units and the briefs it writes. A nil field answers its calls with ErrUnsupported.
type ItemLedger ¶
type ItemLedger interface {
Apply(ctx context.Context, prov items.Provenance, ops []items.Op) (coreitems.Result, error)
Query(ctx context.Context, q coreitems.Query) ([]items.Item, error)
}
ItemLedger is the host's items ledger.
type Kind ¶
type Kind struct {
// Broker is the broker the host serves plugin id, whose source table
// is s.
Broker func(id string, s *manifest.Source) *Broker
// Snapshots are marked stale while a plugin is down.
Snapshots *Snapshots
// StateDir is plugin id's own state directory.
StateDir func(id string) string
// Loaded is called once a plugin expected to load first reports it has
// imported its data and reported every unit; nil calls nothing.
Loaded func(id string)
// HealthPoll is how often a loading plugin is asked its health.
HealthPoll time.Duration
// NotifyTimeout bounds one plugin's Notify, so a plugin that hangs
// delays the others by no more; zero is DefaultNotifyTimeout.
NotifyTimeout time.Duration
// Logf logs a failed notification; nil logs nothing.
Logf func(format string, args ...any)
// Meters carry the host's meter scopes to the plugins' calls; nil
// meters nothing.
Meters *Meters
// contains filtered or unexported fields
}
Kind starts and stops the source kind of plugin processes for the plugin host, and holds the client of each running one.
func (*Kind) Client ¶
Client is the client of plugin id's running source kind; ErrUnavailable while it does not run.
func (*Kind) Expect ¶
Expect says plugins ids are to load on this start: each is loading until its health first says it serves.
func (*Kind) Notify ¶
Notify tells each running plugin of the host changes its manifest's notify subscribes to, from the changes after from until ctx ends, one note at a time. A plugin hears of its own units only: a note naming units, none of them its, is not sent to it, and a note of every unit, or of none, is sent with no unit.
type MarkStore ¶
type MarkStore interface {
SetMarks(ctx context.Context, u unit.Unit, marks map[string]string) error
}
MarkStore sets a unit's handled marks; a value "" removes one.
type Meters ¶
type Meters struct {
// Registry keeps a sample whose scope ended; nil drops it.
Registry *meter.Registry
// contains filtered or unexported fields
}
Meters bridge the host's meter scopes to the samples a plugin sends back: a call made under Call carries its scope's name, and a sample a plugin meters under that name lands in the scope while the call is in flight, else in Registry under the name.
type OverrideStore ¶
type OverrideStore interface {
Override(ctx context.Context, u unit.Unit) (map[string]string, error)
SetOverride(ctx context.Context, u unit.Unit, set, ifMatch map[string]string) (written bool, err error)
}
OverrideStore keeps the host's overrides of units by name (port.Overrides); SetOverride writes set in one transaction while ifMatch holds.
type PayloadPlanner ¶
type PayloadPlanner interface {
Payload(ctx context.Context, req src.PayloadRequest) (src.PayloadResult, error)
}
PayloadPlanner is the plugin's Payload call.
type Payloads ¶
type Payloads struct {
ID string
Kind *Kind
Now func() time.Time
// Planner nil is the running plugin ID of Kind.
Planner func() (PayloadPlanner, error)
}
Payloads is a source plugin's Planner.Payload as a turn reads it.
type Placements ¶
Placements is a source plugin's Planner.Placement as placement reads it: its default and its suggestion.
type Proposals ¶
Proposals are a source plugin's Planner.Proposals as the proposals job reads them: drafts of the plugin's own rules on its own units, each with an auto origin naming its rule, and no delivery of the plugin's, and the withdrawals of its rules on its own units.
type Publisher ¶
Publisher is a source plugin's Publisher and Lander as the outbox reads them: port.Effects and its optional capabilities.
func (Publisher) Live ¶ added in v0.5.0
Live asks the plugin now, never a cache, what a draft of kind on u would be written against; a plugin that checks no draft answers "", and one that is not running fails, so no draft is taken as fresh unread.
func (Publisher) Publish ¶
Publish sends d to the plugin once. An error that may follow a post, the plugin's own or a call it never answered, starts with src.ErrMayHavePosted's text, so the outbox asks a person to confirm a retry; the plugin's stale refusal is outbox.ErrStale.
func (Publisher) Takes ¶
Takes says whether the plugin posts drafts to target: whether its manifest codec's targets pattern matches it.
type SessionBooks ¶
type SessionBooks interface {
Session(ctx context.Context, id string) (dturn.Session, bool, error)
// BookOf is the book of the session's turns; false for none.
BookOf(ctx context.Context, session string) (dturn.Book, bool, error)
}
SessionBooks are the host's sessions and the turns their books hold.
type SettledFacts ¶
type SettledFacts struct {
UnitFacts
Source *manifest.Source
Drafts DraftLister
}
SettledFacts are a plugin's UnitFacts with <slot>.settled_at filled in each workflow's scope, when the manifest declares that fact.
type Snapshots ¶
type Snapshots struct {
// contains filtered or unexported fields
}
Snapshots are the last snapshot each source plugin reported of each of its units, kept in the store, and whether the plugin is down, which makes its units stale: they keep their last snapshot until the plugin reports again.
func NewSnapshots ¶
NewSnapshots keeps the snapshots in store.
func (*Snapshots) OnStale ¶
func (s *Snapshots) OnStale(f func(unit.ProviderID))
OnStale calls f with a provider whose units went stale or fresh again.
func (*Snapshots) Reported ¶
func (s *Snapshots) Reported(ctx context.Context, units []unit.Unit) (map[unit.Unit]src.Snapshot, error)
Reported are units' last snapshots; a unit with none is absent.
func (*Snapshots) SetDown ¶
func (s *Snapshots) SetDown(p unit.ProviderID, down bool)
SetDown says whether p's plugin is down.
func (*Snapshots) Stale ¶
Stale says whether u renders from a snapshot its plugin no longer stands behind: its plugin is down.
func (*Snapshots) Unextracted ¶
Unextracted is when the oldest message not yet extracted arrived, across the extraction health of units' last snapshots; zero when none waits.
type TaskLookup ¶
TaskLookup reads the tasks linked to a unit.
type TaskWakes ¶
type TaskWakes interface {
TasksOf(ctx context.Context, u unit.Unit) ([]task.Task, error)
Sleep(ctx context.Context, id task.ID, w wake.Wake) error
Rouse(ctx context.Context, id task.ID) error
}
TaskWakes are the host's tasks as their wakes move them: TasksOf are the tasks that hold a unit, Sleep defers a task under a wake, and Rouse drops its wake and returns it where the wake said.
type Tools ¶
type Tools struct {
ID string
Kind *Kind
// Manifest is the plugin's [source] table.
Manifest *manifest.Source
// Sessions are the host's sessions; a tool that posts at once runs only
// for no session or a live one.
Sessions SessionBooks
}
Tools are the MCP tools a source plugin's manifest declares, as the MCP server calls them; the server words each answer from the layered tools.toml.
func (Tools) Call ¶
func (t Tools) Call(ctx context.Context, tool string, args json.RawMessage, session, turn string) (Answer, error)
Call runs tool with args for the MCP session handle, during turn. A tool that posts at once is refused before it runs for a session that is not live, whose post nothing could record.
type UnitFacts ¶
type UnitFacts struct {
Snapshots *Snapshots
}
UnitFacts are a source plugin's units as the automation engine reads them: the facts and the rev of each unit's last snapshot, read from the store and never asked of the plugin. A temporal value is a workflow.Temporal, which the engine resolves with its clock.
func (UnitFacts) Facts ¶
Facts are u's reported facts; automation.ErrUnitGone when u has no snapshot.
type Units ¶
type Units struct {
// Codecs read every plugin's keys, the core's included.
Codecs *unit.Registry
}
Units converts between the protocol's units and the domain's for the plugin whose codecs it holds.
func (Units) Draft ¶
Draft is the domain draft a plugin's d proposes or reports. The unit and the task are checked; what only the host sets (approval, state, origin of a session's draft) is the host's to fill.
Source Files
¶
- basis.go
- briefs.go
- broker.go
- broker_gates.go
- broker_history.go
- broker_hosted.go
- broker_jobs.go
- broker_ledger.go
- broker_links.go
- broker_reader.go
- broker_recorder.go
- broker_reporter.go
- broker_services.go
- broker_wakes.go
- checkouts.go
- convert.go
- doc.go
- facts.go
- facts_settled.go
- items.go
- kind.go
- meters.go
- notify.go
- payload.go
- placement.go
- proposals.go
- publisher.go
- snapshots.go
- targets.go
- tools.go
- topics.go
- ui.go
Directories
¶
| Path | Synopsis |
|---|---|
|
Package fakesource is a source plugin's reports of chat threads, for tests: each thread is a snapshot, served as rows through the host's readmodel.Reported, as a plugin's units are.
|
Package fakesource is a source plugin's reports of chat threads, for tests: each thread is a snapshot, served as rows through the host's readmodel.Reported, as a plugin's units are. |
|
Package value converts the values a source plugin reports to the host's: a literal, or a workflow.Temporal the host resolves with its clock.
|
Package value converts the values a source plugin reports to the host's: a literal, or a workflow.Temporal the host resolves with its clock. |