draft

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: Apache-2.0 Imports: 5 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 draft holds the Outbox drafts: posts the loop proposes and the user approves before they reach a provider.

Index

Constants

This section is empty.

Variables

View Source
var ErrTransition = errors.New("draft: transition not allowed")

ErrTransition is wrapped by Can.

Open are the states in which a draft may still be posted.

Functions

This section is empty.

Types

type Approval

type Approval struct {
	Mode   ApprovalMode
	Window time.Duration // Mode "window" only, > 0
}

func (Approval) Validate

func (a Approval) Validate() error

Validate refuses an unknown mode, a window <= 0 with window, a window set without window.

type ApprovalMode

type ApprovalMode string // "always" (default), "window", "none", "observe"
const (
	Always  ApprovalMode = "always"
	Window  ApprovalMode = "window"
	None    ApprovalMode = "none"
	Observe ApprovalMode = "observe"
)

type Draft

type Draft struct {
	ID       ID
	Unit     unit.Unit
	Items    []string // item ids of Unit; may be empty
	Entry    string   // the entry it serves, "" none; the Outbox entry itself is "draft:<ID>"
	Kind     Kind
	Target   string // plugin target grammar; "" means the unit itself (its thread, its PR)
	Text     string // standard Markdown with mentions as @{<person key>}; the Effects implementation converts both
	Reaction string // Kind "react" only: emoji name without colons
	Original string // Text as proposed
	Edited   bool   // Text != Original
	Origin   Origin
	Approval Approval  // fixed at proposal
	Deadline time.Time // Approval.Mode "window": when Tick approves it; zero otherwise
	State    State
	Evidence Evidence // State "sent" only
	Error    string   // State "failed" only, never a token
	Reason   string   // State "discarded": "user", "assigned", "observe", ...
	Would    Would
	Rev      int64 // the stored row's version; every Update bumps it

	CreatedAt, UpdatedAt, SendingAt time.Time
}

func (Draft) Can

func (d Draft) Can(s State) error

Can says why d cannot move to s, nil when it can: proposed->approved|discarded; approved->sending|discarded; sending->sent|failed; failed->approved (by hand only)|discarded.

type Evidence

type Evidence struct {
	Ref       string // Slack: message ts; GitHub: comment id
	Permalink string
	At        time.Time
}

type ID

type ID int64

type Kind

type Kind string // "reply", "nudge", "close", "react", "ask_owner", "comment"
const (
	Reply    Kind = "reply"
	Nudge    Kind = "nudge"
	Close    Kind = "close"
	React    Kind = "react"
	AskOwner Kind = "ask_owner"
	Comment  Kind = "comment"
)

func (Kind) Valid

func (k Kind) Valid() bool

type Origin

type Origin struct {
	Kind     OriginKind
	TurnSeq  int64  // Kind "turn": the turn (session or headless) that proposed it; Kind "session": the handle's newest turn on the unit, 0 none
	Intent   string // the proposing turn's intent ("" for auto and user)
	Workflow string // the workflow that started the proposing turn (turn.Turn.Workflow), "" none
	Rule     string // Kind "auto": the core or plugin rule, e.g. "stalled-nudge", "closure", "ask-owner", "github-nudge"
	Key      string // Kind "auto": the rule's dedupe key, e.g. "stalled-nudge:<entry>:<person key>"
}

type OriginKind

type OriginKind string // "turn", "session", "auto", "user"
const (
	OriginTurn    OriginKind = "turn"
	OriginSession OriginKind = "session"
	OriginAuto    OriginKind = "auto"
	OriginUser    OriginKind = "user"
)

type Outcome

type Outcome string // "", "as_is", "edited", "discarded", "auto" (approved by its policy), "observed" (recorded only)
const (
	OutcomeAsIs      Outcome = "as_is"
	OutcomeEdited    Outcome = "edited"
	OutcomeDiscarded Outcome = "discarded"
	OutcomeAuto      Outcome = "auto"
	OutcomeObserved  Outcome = "observed"
)

type State

type State string // "proposed", "approved", "sending", "sent", "failed", "discarded"
const (
	Proposed  State = "proposed"
	Approved  State = "approved"
	Sending   State = "sending"
	Sent      State = "sent"
	Failed    State = "failed"
	Discarded State = "discarded"
)

type Would

type Would struct {
	Policy  WouldPolicy // what auto-send would have done, fixed at proposal
	Reason  string      // why, one line
	Outcome Outcome     // what the user (or the policy) did, set at approve or discard
}

type WouldPolicy

type WouldPolicy string // "send", "hold"
const (
	WouldSend WouldPolicy = "send"
	WouldHold WouldPolicy = "hold"
)

Jump to

Keyboard shortcuts

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