port

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: Apache-2.0 Imports: 7 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 port holds what every core package's ports share: the event a save writes, the clock and the publisher.

Index

Constants

View Source
const (
	// RowInputs are the topics a row is derived from.
	RowInputs = TopicPRs | TopicFollow | TopicSourceEvents | TopicLoopEvents | TopicOverrides |
		TopicTurns | TopicSessions | TopicIntakes | TopicBriefs | TopicUsage | TopicPause |
		TopicGate | TopicAgents | TopicConfig | TopicViewer | TopicRefusals | TopicItems
	// 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. Entries, items and drafts wake the
	// workflows over GTD entries and Slack units; 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 | TopicGate | TopicAgents | TopicConfig | TopicViewer |
		TopicEntries | TopicItems | TopicDrafts
	// 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.

Variables

View Source
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")
)

Functions

func PROf

func PROf(ev Event) (pr.Ref, bool)

PROf is the pull request of an event on a github unit.

Types

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.

func (Change) Empty

func (c Change) Empty() bool

func (Change) Has

func (c Change) Has(t Topic) bool

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 Clock

type Clock interface{ Now() time.Time }

type Deliverer added in v0.2.0

type Deliverer interface {
	Delivers(d draft.Delivery) draft.Delivery
}

Deliverer is optional: an Effects value that implements it says how it posts a draft whose proposer asked for delivery d, 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
}

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 Facts

type Facts interface{ Units() []unit.Unit }

Facts is a source's typed payload; it may name units not seen before.

type Generation

type Generation uint64

Generation counts the notes of one process's change log: 0 before the first note, +1 per note.

type Heat

type Heat string
const (
	HeatActive Heat = "active"
	HeatWarm   Heat = "warm"
	HeatCold   Heat = "cold"
)

type HeatReader

type HeatReader interface {
	Heat(ctx context.Context, units []unit.Unit) (map[unit.Unit]Heat, error) // a unit missing from the map is cold
}

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 Linker

type Linker interface{ Links() []link.Link }

Linker is optional on Facts: mechanical cross-source links found in the facts.

type Locator

type Locator interface {
	Where(ctx context.Context, d draft.Draft) (string, error)
}

Locator is optional: an Effects value that implements it names, for the user approving d, the conversation or person d posts to.

type Publisher

type Publisher interface{ Publish(evs ...Event) }

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 Topic

type Topic uint32

Topic is a set of input kinds; a note carries one or more.

const (
	TopicPRs          Topic = 1 << iota // pull_requests, pr_details
	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, unit_tags
	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
	TopicGate                           // 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
	TopicEntries                        // entries and their tables
	TopicDrafts                         // drafts
	TopicMarks                          // unit_marks of units other than pull requests, whose are TopicRounds
)

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.

type Validator

type Validator interface {
	Validate(ctx context.Context, d draft.Draft) error
}

Validator is optional: an Effects value that implements it is asked at proposal and before approval whether Target and Text would post.

Jump to

Keyboard shortcuts

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