Documentation
¶
Overview ¶
Package port holds what every core package's ports share: the event a save writes, the clock and the publisher.
Index ¶
- Constants
- Variables
- type Activity
- type Change
- type Changes
- type Clock
- type Deliverer
- type Effects
- type Event
- type Facts
- type Generation
- type Heat
- type HeatReader
- type Lander
- type LinkStore
- type Linker
- type Locator
- type Placer
- type Publisher
- type SentText
- type Source
- type SourceStore
- type Stub
- type Targeter
- type Topic
- type TrackRead
- type Validator
Constants ¶
const ( // RowInputs are the topics a row is derived from. RowInputs = TopicPRs | TopicFollow | TopicSourceEvents | TopicLoopEvents | TopicOverrides | TopicTurns | TopicSessions | TopicIntakes | TopicBriefs | TopicUsage | TopicPause | TopicPending | TopicAgents | TopicConfig | TopicViewer | TopicRefusals | TopicItems | TopicGates | TopicWakes // HealthInputs are the topics the health endpoint shows. HealthInputs = TopicMeta | TopicPause | TopicBriefs | TopicApp | TopicJobs | TopicConfig // SweepInputs leaves out LoopEvents and Rounds, the sweep's own writes // that never change its plan. Tasks, items and drafts wake the // workflows over tasks and Slack units, and a matched wake the one that // reacts to task.woke; the drafts draft.propose // writes wake one more pass, which their hold makes idle. The // extraction notes SourceEvents. SweepInputs = TopicPRs | TopicFollow | TopicSourceEvents | TopicOverrides | TopicTurns | TopicIntakes | TopicBriefs | TopicPause | TopicPending | TopicAgents | TopicConfig | TopicViewer | TopicTasks | TopicItems | TopicDrafts | TopicWakes // BriefInputs leaves out the queue's own Briefs writes. BriefInputs = TopicPRs | TopicFollow | TopicConfig )
pr_seen notes nothing. A write that inserts events notes SourceEvents or LoopEvents by who writes them: the source's snapshot, append and merge fills note SourceEvents, every other event writer LoopEvents.
const ( OverrideNextGuidance = "next_guidance" // OverrideHold is the user's pause of the unit's rounds, which a // plugin reads as RoundState.Paused and never sets. OverrideHold = "hold" )
The host's overrides of a unit, by the name a plugin's SetOverride sets and its RoundState reads. A flag is "true", and "" is unset.
const OverrideTrue = "true"
OverrideTrue is a set flag's value.
Variables ¶
var ( // ErrNotFound: GitHub has no such pull request, or will not say. ErrNotFound = errors.New("not found") // ErrGitHub: the read failed on GitHub's side or on the way there. ErrGitHub = errors.New("GitHub") )
var Overrides = []string{OverrideNextGuidance, OverrideHold}
Overrides are every host override name.
var PluginOverrides = slices.DeleteFunc(slices.Clone(Overrides), func(n string) bool { return n == OverrideHold })
PluginOverrides are the host overrides a plugin may set.
Functions ¶
This section is empty.
Types ¶
type Activity ¶ added in v0.3.0
Activity is an event as a feed shows it, with its unit's title, address, author and state; Mine says the viewer started the unit.
type Change ¶
type Change struct {
Gen Generation
Epoch string // per process; a client that sees a new epoch reloads
Topics Topic // the matching notes' topics intersected with the filter; 0 when nothing matched
Units []unit.Unit // distinct, sorted by Unit.Less; empty when All
All bool // a matching note was NoteAll, or from is outside the window
}
Change is one note, or the merge of the notes in (from, Gen] a Since returns.
type Changes ¶
type Changes interface {
Gen() Generation
Since(from Generation, topics Topic) Change
// Subscribe calls fn after every note, in generation order, synchronously
// from Note: fn must return at once (hand off), must not write the store
// and must not note the log.
// A panicking fn is recovered, logged and unsubscribed.
Subscribe(fn func(Change)) (cancel func())
}
Changes is the read side of the change log.
type Deliverer ¶ added in v0.2.0
Deliverer is optional: an Effects value that implements it says how it posts a draft of kind k, whatever delivery its proposer asked for, which the draft then carries, so its approval reads what the provider will show.
type Effects ¶
type Effects interface {
Publish(ctx context.Context, d draft.Draft) (draft.Evidence, error)
// Verify says whether d, found in sending after a crash, was posted at
// or after startedAt by the user, with text matching d.Text as converted.
Verify(ctx context.Context, d draft.Draft, startedAt time.Time) (draft.Evidence, bool, error)
}
Effects publishes approved drafts of one provider. The core calls Publish only for a draft in state sending, once; it never retries.
type Event ¶
type Event struct {
Unit unit.Unit
Kind, Key string
Actor string
Data string
At time.Time
// Anchor is the point of the unit the event happened at, such as a
// review comment; zero for none.
Anchor unit.Anchor
}
Event is a fact a repository writes in the transaction of the change it tells. A keyed event is stored once per unit, kind and key; an unkeyed one moves forward a nanosecond until its time is free.
type Generation ¶
type Generation uint64
Generation counts the notes of one process's change log: 0 before the first note, +1 per note.
type HeatReader ¶
type Lander ¶ added in v0.3.0
Lander is optional: an Effects value that implements it names the unit the post of a sent draft landed in, for a draft whose own unit publishes nothing, such as a task's posted to a channel; false when it cannot.
type LinkStore ¶
type LinkStore interface {
// ReplaceFacts replaces the Origin facts links whose From is in from; notes TopicLinks.
ReplaceFacts(ctx context.Context, from []unit.Unit, links []link.Link, at time.Time) error
// Put upserts one link of origin extraction or user, keyed by (From, To, Kind, Item); notes TopicLinks.
Put(ctx context.Context, l link.Link) error
From(ctx context.Context, u unit.Unit) ([]link.Link, error)
To(ctx context.Context, units []unit.Unit) ([]link.Link, error) // sorted by From, then At
}
type Locator ¶
Locator is optional: an Effects value that implements it names, for the user approving d, the conversation or person d posts to.
type Placer ¶ added in v0.3.0
Placer is optional: an Effects value that implements it names, when a draft is proposed, or sent, with no target, where it posts, which the draft then stores as its Target; "" keeps the unit itself. An error refuses the draft.
type Source ¶
type Source interface {
Provider() unit.ProviderID
Discover(ctx context.Context, cursor string) (stubs []Stub, next string, err error)
Stubs(ctx context.Context, objects []string) ([]Stub, error)
Read(ctx context.Context, objects []string) (Facts, error)
Viewer(ctx context.Context) (string, error)
}
Source reads one provider's objects. It never writes the store.
type SourceStore ¶
type SourceStore interface {
// Watched are the objects to stub-check every run with their stored versions;
// an object whose detail is older than its max age has Version "".
Watched(ctx context.Context) ([]Stub, error)
Versions(ctx context.Context, objects []string) (map[string]string, error)
Cursor(ctx context.Context) (string, error)
// Save stores light facts, then read facts (the read wins for one object),
// then the cursor. It runs on every pass, so read may be nil and light empty;
// it writes and notes the log only for what differs.
Save(ctx context.Context, light []Facts, read Facts, cursor string, at time.Time) error
// See stamps the objects as seen at at; notes nothing.
See(ctx context.Context, objects []string, at time.Time) error
}
SourceStore is the source's own persistence, in its source tables. Only ingest calls it.
type Stub ¶
type Stub struct {
Object string // the source's native id: "owner/repo#12" for github, a channel and thread ts for a thread
Version string // github: updatedAt|state|draft|head|checks|failed names; thread: latest_reply
Light Facts // facts the stub already carries (github: mergeable, review requests, decision); nil when none
}
Stub is one native object's change marker. A unit is not always one object: a DM object may hold several topic units, found in Read.
type Targeter ¶ added in v0.3.0
Targeter is optional: an Effects value that implements it says whether it posts to target, so a draft on a unit whose provider publishes nothing, such as a task, is posted by the provider its target names.
type Topic ¶
type Topic uint64
Topic is a set of input kinds; a note carries one or more.
const ( TopicPRs Topic = 1 << iota // a source's unit data: pull_requests, pr_details, unit_snapshots TopicFollow // pull_requests.reasons and ws_*: follow state (noted with TopicPRs) TopicSourceEvents // events a source writes (GitHub timeline, Slack changes) TopicLoopEvents // events the loop writes: rounds, turns, sessions, situations, views, briefs, would_* TopicOverrides // overrides TopicTurns // turns, turn_records, turn_answers TopicSessions // sessions, agent_sessions, turn_stops TopicIntakes // intakes TopicBriefs // unit_briefs, brief_runs, and the brief records TopicUsage // turn_usage TopicRounds // round_state, round_days, round_day_prs, round_day_notes, turn_instructions, instruction_parts TopicPause // pause TopicViews // view_applied TopicMeta // meta TopicPending // the pending-round set (in memory) TopicAgents // the workspace snapshot's projection TopicConfig // a new loaded intent set or a reloaded profile TopicViewer // viewer login or teams TopicRefusals // the daemon's remove refusals TopicApp // the menu bar's reported status TopicJobs // a job run ended TopicLinks // links TopicItems // items, item_proposals TopicCards // unit_cards TopicTasks // tasks and their tables TopicDrafts // drafts TopicMarks // unit_marks of units other than pull requests, whose are TopicRounds TopicGates // gates TopicWakes // wakes TopicTimeline // events on a task or a unit linked to one TopicRuns // a task's runs: its turns' sessions and workspaces )
type TrackRead ¶
type TrackRead struct {
// Unit is the unit of the pull request GitHub names.
Unit unit.Unit
State string
Save func(context.Context) error
}
TrackRead is a pull request read for a track, not stored yet: Save stores it once the track is admitted, so a refused track leaves no row; nil Save stores nothing.