Documentation
¶
Overview ¶
Package slackapp is the factory's Slack App (factory interfaces F9): a sponsored principal that drafts and files issues from a thread, a webhook subscriber that keeps the thread told, and the one surface that decides a forge.push approval — a card's two buttons, inside the same signed events door (v3.x Slack push approval §6), answered by the broker's decide route as the App's principal. It never relays room text, and no reply, reaction or message ever decides anything.
Index ¶
- Constants
- Variables
- type Act
- type ActPayload
- type ActResult
- type Answer
- type App
- type ApprovalPayload
- type Broker
- func (b Broker) Answer(ctx context.Context, a Answer) (ActResult, error)
- func (b Broker) CoordinationDraft(ctx context.Context, parent string, in coordination.CoordinationConfirmation, ...) (coordination.CoordinationConfirmation, error)
- func (b Broker) CoordinationPlan(ctx context.Context, in CoordinationPlanRequest) (CoordinationPlanResult, error)
- func (b Broker) Decide(ctx context.Context, d Decision) (DecisionResult, error)
- func (b Broker) Handoff(ctx context.Context, in HandoffRequest) (HandoffResult, error)
- func (b Broker) HandoffCheck(ctx context.Context, id, onBehalfOf string, workflow *string) (HandoffChecked, error)
- func (b Broker) Inbox(ctx context.Context, room string) ([]summary.Need, error)
- func (b Broker) IntentClassify(ctx context.Context, in IntentRequest) (IntentResult, error)
- func (b Broker) Retry(ctx context.Context, a Act) (ActResult, error)
- func (b Broker) RunCreate(ctx context.Context, c RunCreate) (RunResult, error)
- func (b Broker) SlackLinkCode(ctx context.Context, team, user, handle, name string) (string, error)
- func (b Broker) SlackUnlink(ctx context.Context, team, user string) (bool, error)
- func (b Broker) Stop(ctx context.Context, a Act) (ActResult, error)
- func (b Broker) Task(ctx context.Context, room string) (TaskResult, error)
- type BrokerAPI
- type Channel
- type Config
- type ConfigMapThreads
- type CoordinationPlanRequest
- type CoordinationPlanResult
- type CoordinationProposal
- type Decision
- type DecisionResult
- type HandoffChecked
- type HandoffQuestion
- type HandoffRequest
- type HandoffResult
- type IntentRequest
- type IntentResult
- type MarkerPayload
- type Message
- type Metadata
- type ProjectionRecorder
- type ProposalPayload
- type Question
- type Recorder
- type Refused
- type RunCreate
- type RunResult
- type Slack
- type SlackClient
- func (c *SlackClient) Message(ctx context.Context, channel, ts string) (Message, error)
- func (c *SlackClient) Post(ctx context.Context, channel, threadTS, text string, meta *Metadata) (string, error)
- func (c *SlackClient) PostCard(ctx context.Context, channel, threadTS, text string, blocks json.RawMessage, ...) (string, error)
- func (c *SlackClient) PostEphemeral(ctx context.Context, channel, user, threadTS, text string) error
- func (c *SlackClient) Thread(ctx context.Context, channel, threadTS string) ([]Message, error)
- func (c *SlackClient) Update(ctx context.Context, channel, ts, text string, blocks json.RawMessage) error
- func (c *SlackClient) UpdateProposal(ctx context.Context, channel, ts, text string, blocks json.RawMessage, ...) error
- func (c *SlackClient) UserName(ctx context.Context, user string) (string, string, error)
- type SlackCoordinationProjection
- type TaskQuestion
- type TaskResult
- type Thread
- type Threads
- type Tokens
- type Verifier
Constants ¶
const ( IntentsOff = "off" IntentsShadow = "shadow" IntentsOn = "on" )
The values of a channel's intents switch (SI20).
const ( PresetZITADEL = "zitadel" PresetGeneric = "generic" )
The presets of the App's token request (v4 D8), as the broker's human block names them.
Variables ¶
var ErrSignature = errors.New("slackapp: request not signed by Slack")
ErrSignature is any request that does not verify; it never says which check failed.
var ErrThreadTooLong = errors.New("slackapp: slack: the thread is too long")
ErrThreadTooLong is a thread with more pages than Thread follows: its latest draft cannot be known, so nothing is edited or filed from it.
var ErrUnknownTool = errors.New("slackapp: the broker does not offer this tool")
ErrUnknownTool is the broker without the tool asked: the self-serve link is off there.
var RequestedTextTooLong = errors.New("Not proposed: that request is longer than 16 KB; hand it off from your coding agent or the web UI.")
RequestedTextTooLong is a planner request past intake_plan's 16 KiB bound: a mention whose own text is, or a reply whose thread's first message is. Its text is the one line the thread shows: the person's fix is to hand the request off, not to shorten it in Slack, since a plan drawn from part of a request is a plan nobody read. The name and the prose are this package's interface rather than a caller's error to test, which is why they are not Go's Err-something form.
Functions ¶
This section is empty.
Types ¶
type Act ¶ added in v0.53.0
type Act struct {
Team, User, Channel, MessageTS, Room string
}
Act is one confirmed stop or retry press, as POST /api/slack/stops and POST /api/slack/retries take it: the ids Slack signed on the click and the room the confirmation's metadata bound.
type ActPayload ¶ added in v0.53.0
type ActPayload struct {
Action string `json:"action"`
Room string `json:"room"`
Presser string `json:"presser"`
Text string `json:"text,omitempty"`
Expires string `json:"expires"`
}
ActPayload is a stop, retry or answer confirmation's metadata: the action, the room it targets, the Slack user who asked for it (the only one who may confirm or cancel it), the exact answer text when Action is "answer", and its RFC 3339 ten-minute expiry.
type ActResult ¶ added in v0.53.0
type ActResult struct{ Result string }
ActResult is the closed code the broker's stop, retry or answer route answered.
type Answer ¶ added in v0.53.0
type Answer struct {
Team, User, Channel, MessageTS, Room, Text string
}
Answer is one confirmed answer press, as POST /api/slack/answers takes it: the ids Slack signed on the click, the room the confirmation's metadata bound, and the exact words the confirmation showed.
type App ¶
type App struct {
Slack Slack
Broker BrokerAPI
Threads Threads
Verifier Verifier
WebhookKeys func() ([][]byte, error)
TeamID string
BotUserID string
RoomsURL string
Channels map[string]Channel
PlanningAfter time.Duration // how long a plan runs before the thread shows a "planning…" status; zero means 4s
Async func(func()) // runs an event's handling after the 200 (tests); nil means the App's workers
Now func() time.Time
Metrics Recorder
Logger *slog.Logger
// contains filtered or unexported fields
}
App is the flows: a mention drafts, the draft's author amends it with replies in its thread, a maintainer's check mark files, the broker's webhooks tell the thread, and — for forge.push only, where the channel's approvals flag is on — a card's button decides. A thread reply is read only to amend an unfiled draft; none is ever a command (invariant 8) and no reply is ever a decision.
func (*App) Events ¶
Events is the events listener's handler: the signature first, nothing read before it. Two body shapes arrive at this one door (D11, §6): Slack's JSON events and its form-encoded button presses, told apart by content type after the same verification.
func (*App) Wait ¶ added in v0.33.0
Wait stops taking events and returns once every queued and running one has finished, or ctx ends first: then it logs how many were left and returns the context's error, wrapped. Each of those was answered 200, so Slack will not resend it (F-10); the bound is the caller's, since 72 events at handleTimeout over eight workers can outlast a pod's grace period. Safe to call more than once.
type ApprovalPayload ¶ added in v0.35.0
type ApprovalPayload struct {
ApprovalID string `json:"approvalId"`
Class string `json:"class"`
Branch string `json:"branch"`
}
ApprovalPayload is a card's metadata (§5): what finds the card again without a search scope.
type Broker ¶
type Broker struct {
URL string // the broker's base URL, from config only
Tokens *Tokens
HC *http.Client // httpx.New in production
}
Broker is the room-broker's MCP endpoint, called as the App's own principal. It never calls tasks/*: the App follows a room through webhooks.
func (Broker) Answer ¶ added in v0.53.0
Answer posts one confirmed answer press to the broker's human listener as the App's principal.
func (Broker) CoordinationDraft ¶ added in v0.39.0
func (b Broker) CoordinationDraft(ctx context.Context, parent string, in coordination.CoordinationConfirmation, onBehalfOf string) (coordination.CoordinationConfirmation, error)
CoordinationDraft is coordination_draft: the plan stored as its parent's draft, for the user. It confirms nothing; the parent is confirmed on its room page.
func (Broker) CoordinationPlan ¶ added in v0.39.0
func (b Broker) CoordinationPlan(ctx context.Context, in CoordinationPlanRequest) (CoordinationPlanResult, error)
CoordinationPlan is coordination_plan, the broker's governed multi-repository planner: it files nothing.
func (Broker) Decide ¶ added in v0.35.0
Decide posts one press to the broker's human listener as the App's principal, with the same token cache and the same 401 retry every other call uses. The route answers a closed code with 200 for every refusal, so anything but 200 is transport, not a decision.
func (Broker) Handoff ¶ added in v0.53.0
func (b Broker) Handoff(ctx context.Context, in HandoffRequest) (HandoffResult, error)
Handoff is that tool's one call. A key the tool does not take is never sent: a sponsored principal states whom it plans for and the channel's ceiling on every call, since the broker checks both again on a continuation. ErrUnknownTool comes back untouched, and so does the planner-off line (a Refused), so the caller answers the mention's own line.
func (Broker) HandoffCheck ¶ added in v0.53.0
func (b Broker) HandoffCheck(ctx context.Context, id, onBehalfOf string, workflow *string) (HandoffChecked, error)
HandoffCheck is handoff_check for the Slack user named: the stored plan, its hash and the workflows they may choose. workflow nil changes nothing; a value pins that workflow ("" for the factory's choice), which re-validates the stored plan and stores its new hash. It files nothing.
func (Broker) Inbox ¶ added in v0.53.0
Inbox is inbox for one room: the needs/v1 items alone. A sponsored caller reads a room's needs, never a login's, and each item's action is a link it cannot follow for anyone (CD26).
func (Broker) IntentClassify ¶ added in v0.45.0
func (b Broker) IntentClassify(ctx context.Context, in IntentRequest) (IntentResult, error)
IntentClassify is that tool's one call. ErrUnknownTool is a broker without human.slackIntents, and a Refused is one of the closed words (not_linked, capped, ...): the caller branches on neither more than to fall back to today's line.
func (Broker) Retry ¶ added in v0.53.0
Retry posts one confirmed retry press to the broker's human listener as the App's principal.
func (Broker) RunCreate ¶
RunCreate files the run. Its arguments are run_create's schema exactly: `text` is the draft's body and dataClass is always public. A proposal sends `handoff` (and `plan_hash`, the hash it showed) in place of the repository's issue: the broker files the plan it stored, so the App carries no plan and no body (UX2).
func (Broker) SlackLinkCode ¶
SlackLinkCode asks the broker for a one-time link for the Slack user, handle and name shown on the page. The answer must be the link page with one code, or it is not passed on to the user.
func (Broker) SlackUnlink ¶
SlackUnlink asks the broker to remove the Slack user's link; unlinked is false when none was.
type BrokerAPI ¶
type BrokerAPI interface {
RunCreate(ctx context.Context, c RunCreate) (RunResult, error)
SlackLinkCode(ctx context.Context, team, user, handle, name string) (string, error)
SlackUnlink(ctx context.Context, team, user string) (bool, error)
// Handoff and HandoffCheck are the governed planner and its stored-plan check (UX2): a mention or a
// reply goes through Handoff, and HandoffCheck reads or pins the stored plan's workflow without a
// model call. Neither files anything, and ErrUnknownTool is a broker without the tool.
Handoff(ctx context.Context, in HandoffRequest) (HandoffResult, error)
HandoffCheck(ctx context.Context, id, onBehalfOf string, workflow *string) (HandoffChecked, error)
// Decide records one press of an approval's card, on the broker's decide route (§1): the only
// thing the App decides, and only for forge.push.
Decide(ctx context.Context, d Decision) (DecisionResult, error)
// Task and Inbox are the reads a filed thread makes (UX4): Task for status, coordination, changes
// and PR, Inbox for what needs a person in that room.
Task(ctx context.Context, room string) (TaskResult, error)
Inbox(ctx context.Context, room string) ([]summary.Need, error)
// Stop, Retry and Answer record one confirmed press on the broker's stop, retry and answer routes.
Stop(ctx context.Context, a Act) (ActResult, error)
Retry(ctx context.Context, a Act) (ActResult, error)
Answer(ctx context.Context, a Answer) (ActResult, error)
// IntentClassify is tier 1's one read-only classification of a reply tier 0 does not know
// (natural-language intents): a label, never an action. ErrUnknownTool is a broker without it.
IntentClassify(ctx context.Context, in IntentRequest) (IntentResult, error)
// CoordinationPlan and CoordinationDraft are a two-repository mention's planner and its parent's
// draft (v4): neither confirms, files nor runs anything.
CoordinationPlan(ctx context.Context, in CoordinationPlanRequest) (CoordinationPlanResult, error)
CoordinationDraft(ctx context.Context, parent string, in coordination.CoordinationConfirmation, onBehalfOf string) (coordination.CoordinationConfirmation, error)
}
BrokerAPI is what the flows call on the broker; Broker has it, and the test fakes it.
type Channel ¶
type Channel struct {
Repositories []string `json:"repositories"`
MaxCostUSD float64 `json:"maxCostUSD"`
// Approvals draws this channel's forge.push approvals as a card with two buttons (v3.x Slack push
// approval D14). Off, the thread keeps today's line and a press answers not_enabled.
Approvals bool `json:"approvals,omitempty"`
// Intents is the second reading of a filed thread's replies (natural-language intents, SI20):
// off (the default), shadow or on. Shadow classifies a reply tier 0 does not know, counts and logs
// it, and posts today's unknown line; until the read intents ship, on behaves as shadow.
Intents string `json:"intents,omitempty"`
// CollectReplies is the channel's agreement that its replies are stored with their label for
// retentionDays (SI19). Without it nothing a person typed here is kept. It needs intents.
CollectReplies bool `json:"collectReplies,omitempty"`
// IntentActions is the App's per-action switch for the write intents (SI21): any of stop, retry,
// answer, steer, amend, each once. stop, retry and answer are served without needing intents: on;
// steer and amend remain ignored.
IntentActions []string `json:"intentActions,omitempty"`
// Notify is which webhook transitions post a line in this channel (UX8, CD11). Absent means
// defaultNotify — the four transitions a person is told about by default; an explicit empty list
// means none, which is a choice, not an omission.
Notify []string `json:"notify,omitempty"`
}
Channel is a channel the App serves: the repositories a proposal there may name, the max_cost a there sends, whether its forge.push approvals are drawn as a card, and which webhook transitions post a line there (CD11, CD24 — declared once in ai-native-ref's slack-bindings.yaml).
type Config ¶
type Config struct {
TeamID string `json:"teamID"`
BotUserIDFile string `json:"botUserIDFile"`
BotTokenFile string `json:"botTokenFile"`
SigningSecretFile string `json:"signingSecretFile"`
WebhookKeyFile string `json:"webhookKeyFile"`
BrokerURL string `json:"brokerURL"`
RoomsURL string `json:"roomsURL"`
IssuerURL string `json:"issuerURL"`
ClientIDFile string `json:"clientIDFile"`
ClientSecretFile string `json:"clientSecretFile"`
ProjectIDFile string `json:"projectIDFile"`
// Preset is "" or "zitadel" (today's token request: ZITADEL's fixed path, the project's
// audience scope, ProjectIDFile required), or "generic": any OIDC issuer (v4 D8).
Preset string `json:"preset,omitempty"`
// TokenURL is the token endpoint under generic; empty, the issuer's discovery document names it.
TokenURL string `json:"tokenURL,omitempty"`
// Scopes and Audience are the generic client-credentials request's: the audience is sent as a
// parameter (Auth0), and is the value the broker's and the factory's audience pin.
Scopes []string `json:"scopes,omitempty"`
Audience string `json:"audience,omitempty"`
Namespace string `json:"namespace"`
Channels map[string]Channel `json:"channels"`
// The three listeners (M11): Slack's events (public), the broker's webhooks (cluster only),
// and metrics with the probes. Defaults :8080, :8081 and :9090; a test passes 127.0.0.1:0.
// APIBaseURL is Slack's Web API base, a test seam (the e2e stub): empty is https://slack.com/api/.
APIBaseURL string `json:"apiBaseURL,omitempty"`
EventsAddr string `json:"eventsAddr,omitempty"`
WebhooksAddr string `json:"webhooksAddr,omitempty"`
OpsAddr string `json:"opsAddr,omitempty"`
}
Config is the App's config file, loaded strictly as the broker's config is.
func LoadConfig ¶
LoadConfig reads, strictly decodes, defaults and validates the file at path.
func (Config) EffectivePreset ¶ added in v0.47.0
EffectivePreset is the configured preset; an empty one is zitadel.
type ConfigMapThreads ¶
type ConfigMapThreads struct {
C client.Client
Namespace string
Now func() time.Time
MaxBytes int // the encoded map's cap; defaults to 900 KiB (a ConfigMap holds 1 MiB)
Logger *slog.Logger // optional
}
ConfigMapThreads keeps the map in one ConfigMap: a key per room, the thread as JSON.
type CoordinationPlanRequest ¶ added in v0.39.0
type CoordinationPlanRequest struct {
Text, Context, Primary string
Candidates []string
OnBehalfOf string
ID string `json:"id,omitempty"`
Version int32 `json:"version,omitempty"`
}
CoordinationPlanRequest is coordination_plan's arguments: the mention's words, the user's primary first, the two candidates, the user it plans for and, to replan, the draft's id and next version.
type CoordinationPlanResult ¶ added in v0.39.0
type CoordinationPlanResult struct {
Plan v1alpha1.CoordinationPlan `json:"plan"`
Hash string `json:"hash"`
Diagnostics []coordination.Diagnostic `json:"diagnostics"`
Planning coordination.PlanningReconciliation `json:"planning"`
}
CoordinationPlanResult is coordination_plan's answer, as the broker serves it.
type CoordinationProposal ¶ added in v0.39.0
type CoordinationProposal struct {
ParentTask string `json:"parentTask"`
PlanHash string `json:"planHash"`
Version int32 `json:"version"`
Author string `json:"author"`
}
CoordinationProposal is a coordination proposal's metadata: the parent, the hash and version the message shows, and the mention's author, who alone may revise it.
type Decision ¶ added in v0.35.0
type Decision struct {
Team, User, Channel, MessageTS, ApprovalID, Branch, Decision string
}
Decision is one press, as POST /api/slack/decisions takes it (§1 of the design). The App fills it from the signed click only; no field comes from the card's text.
type DecisionResult ¶ added in v0.35.0
type DecisionResult struct{ Result string }
DecisionResult is the broker's closed code; Result is the decision when it recorded one.
type HandoffChecked ¶ added in v0.53.0
type HandoffChecked struct {
Plan intake.Plan `json:"plan"`
Hash string `json:"hash"`
Workflows []string `json:"workflows"`
Repository string `json:"repository"`
Title string `json:"title"`
}
HandoffChecked is handoff_check's answer: the stored plan re-validated as start and run_create validate it, the hash it is stored under, the workflows the Slack user may choose (none unless they maintain the repository) and the issue it files.
type HandoffQuestion ¶ added in v0.53.0
HandoffQuestion is the one question a plan asks, and the answer the planner recommends.
type HandoffRequest ¶ added in v0.53.0
type HandoffRequest struct {
Text string
Candidates []string
OnBehalfOf string
CeilingUSD float64
// ID, Answer and AcceptRest continue a handoff: ID with exactly one of the other two.
ID string
Answer string
AcceptRest bool
}
HandoffRequest is handoff's arguments, as the App has them (UX2). A mention begins one: the requester's own words, the channel's repositories as the candidate set, the linked Slack user the plan is made for and the channel's ceiling. A reply continues one: the id the proposal's metadata carries, with the person's answer or AcceptRest. The App picks no repository and holds no plan: the broker stores the plan under the id and applies the answer to it.
type HandoffResult ¶ added in v0.53.0
type HandoffResult struct {
ID string `json:"id"`
Text string `json:"text"`
Question *HandoffQuestion `json:"question"`
Ready bool `json:"ready"`
Workflow string `json:"workflow"`
Budget float64 `json:"budget"`
}
HandoffResult is handoff/v1: the id the plan is stored under, the plan as text to show as it is, the one question when something is unclear, whether the plan is ready to start, and the workflow and budget it would run with.
type IntentRequest ¶ added in v0.45.0
IntentRequest is intent_classify's arguments: the reply alone, its author, the channel and the thread's phase as one closed word. Collect is true only for a channel that opted in to collecting replies; the App never sends thread history.
type IntentResult ¶ added in v0.45.0
type IntentResult struct {
Intent string `json:"intent"`
Text string `json:"text"`
TextHash string `json:"textHash"`
Confidence float64 `json:"confidence"`
Expires string `json:"expires"`
SampleID int64 `json:"sampleId"`
}
IntentResult is intent_classify's answer: a label, never an action. Text is the span of the reply a steer or an amend acts on, TextHash its hash, Expires when a confirm for it lapses and SampleID the stored sample's id when the channel collects.
type MarkerPayload ¶ added in v0.36.0
type MarkerPayload struct {
Repo string `json:"repo"`
Room string `json:"room,omitempty"`
Cancelled bool `json:"cancelled,omitempty"`
}
MarkerPayload is the "Filed" line's tag: the repository that was filed and the room it started, so a thread that lost its map can still tell where the work went. Today's Filed lines carry the repository alone, which is why Room is optional — a decoder that required one would read every Filed line posted so far as a foreign message.
Cancelled marks the line a Cancel wrote: the proposal closed without filing anything, so its thread has no room and no question to answer (CD25).
type Message ¶
Message is a Slack message as the ✅ flow reads it (M9). User is who posted it: the App's own bot user for its drafts.
type Metadata ¶
type Metadata struct {
EventType string `json:"event_type"`
EventPayload json.RawMessage `json:"event_payload"`
}
Metadata is what the App attaches to its own messages (R23); Slack keeps it off the visible text. EventPayload is tagged: the App decodes it on demand by EventType, so a card and a draft share one message shape (v3.x Slack push approval §5). A draft's bytes on the wire do not change.
type ProjectionRecorder ¶ added in v0.39.0
ProjectionRecorder counts slack_coordination_projection_total{outcome}; a Recorder that is not one counts nothing.
type ProposalPayload ¶ added in v0.36.0
type ProposalPayload struct {
ID string `json:"id"`
Hash string `json:"hash"`
Author string `json:"author"`
Rev int `json:"rev"`
Repo string `json:"repo,omitempty"`
// Degraded says the composer wrote this plan, not the planner (CD18). It rides the payload so the
// message says it, and says it again after a restart that only has the message. It is display, not
// material: the hash binds the plan, and the label is in no section's material set.
Degraded bool `json:"degraded,omitempty"`
// Pins are the workflows the select offers beside the factory's choice: set only when the author
// maintains the repository (P5, spec "Slack plan"). Display, like Degraded: the broker checks
// every pin.
Pins []string `json:"pins,omitempty"`
Pinned string `json:"pinned,omitempty"`
Workflow string `json:"workflow,omitempty"`
Plan intake.Plan `json:"-"`
}
ProposalPayload is a proposal's metadata (UX2, CD20): the handoff id the broker stored the plan under, the hash a Confirm binds, who asked for it, which revision of the message this is and the repository it files into. The plan body itself never rides Slack metadata; Plan is held in memory only while rendering a revision.
type Question ¶ added in v0.36.0
type Question string
Question is one of the five things a filed proposal's thread answers, or the one word for everything else (CD25). The values are the counter's closed label set: one word per question, never a person's phrase, so slack_thread_answers_total{question} stays six series.
const ( // QuestionStatus is where the task is: its phase and the room it is in. QuestionStatus Question = "status" // QuestionNeeds is what waits on a person in that room, the needs/v1 items. QuestionNeeds Question = "needs" // QuestionChanges is what happened recently, the room's milestones. QuestionChanges Question = "changes" // QuestionPR is the pull request the task opened, if it has one. QuestionPR Question = "pr" // QuestionStop is how to stop a run, or behind intentActions a stop confirmation. QuestionStop Question = "stop" // QuestionRetry is how to retry an escalated task, or behind intentActions a retry confirmation. QuestionRetry Question = "retry" // QuestionUnknown is every phrase outside the vocabulary: answered with where things happen. QuestionUnknown Question = "unknown" )
type Recorder ¶
type Recorder interface {
Request(ctx context.Context, route, outcome string)
ProposalUpdate(ctx context.Context, action string)
ThreadAnswer(ctx context.Context, question string)
// SlackIntent counts one reply tier 1 read: tier, intent and outcome from the closed lists
// (maku_slack_intents_total).
SlackIntent(ctx context.Context, tier, intent, outcome string)
}
Recorder counts requests for maku_slack_app_requests_total{route, outcome}, the proposal actions (proposal_updates_total{action}) and the answers a filed proposal's thread gives (thread_answers_total{question}). The two last are closed vocabularies the App passes: the instruments' names and their serving are metrics' (CD7, CD25).
type Refused ¶
type Refused string
Refused is a tool's refusal ("rejected: <code>"), shown in the thread as is.
type RunCreate ¶
type RunCreate struct {
Repo string
Title string
Body string
Handoff string // the handoff id the proposal's metadata carries
PlanHash string // the hash the proposal showed, "" to file whatever the id holds
MaxCostUSD float64
OnBehalfOf string // slack:<team>/<user>
Ref string // slack/<team>/<channel>/<thread_ts>
Key string // the idempotency key
}
RunCreate is a draft filed as a run for the person who asked. Handoff is set when the run is a proposal (UX2): the id of the plan the broker stored, so the broker files that plan after re-validating it, and PlanHash binds the plan the message showed to the one stored — the broker refuses `plan_changed` when they disagree (CD20, CD27). A draft sets neither, and its arguments stay exactly what they were.
type RunResult ¶
type RunResult struct {
Room string
Issue int
Duplicate bool
Sponsor string
Replanned *intake.Plan
}
RunResult is what run_create answered: Sponsor is the GitHub login the factory filed as, "" when it did not say. Replanned is set, and nothing was filed, when the stored plan was a plan/v1: the broker answered the plan/v2 to show and confirm instead (P14).
type Slack ¶
type Slack interface {
// Thread is the thread's messages, oldest first, the parent included, with their metadata.
Thread(ctx context.Context, channel, threadTS string) ([]Message, error)
Post(ctx context.Context, channel, threadTS, text string, meta *Metadata) (ts string, err error)
// PostCard posts text with Block Kit blocks: the approval card and the conversational design's
// proposal message ride it, so Post's own wire bytes do not move.
PostCard(ctx context.Context, channel, threadTS, text string, blocks json.RawMessage, meta *Metadata) (ts string, err error)
// Update rewrites a message the App posted (chat.update), for a card that must turn inert. Slack
// refuses a message the App does not own; the error carries Slack's code.
Update(ctx context.Context, channel, ts, text string, blocks json.RawMessage) error
// UpdateProposal rewrites the one proposal message in place, its metadata included (CD7, CD20):
// an edit never reposts, and the message the App reads back is the whole proposal.
UpdateProposal(ctx context.Context, channel, ts, text string, blocks json.RawMessage, meta *Metadata) error
Message(ctx context.Context, channel, ts string) (Message, error)
// PostEphemeral is a message only user sees, in channel (and threadTS, when set).
PostEphemeral(ctx context.Context, channel, user, threadTS, text string) error
// UserName is the user's handle and display name, for the link page only; "" when Slack does
// not say.
UserName(ctx context.Context, user string) (handle, display string, err error)
}
Slack is the Web API calls the App makes.
type SlackClient ¶
type SlackClient struct {
BaseURL string // https://slack.com/api/ when empty
Token func() string
HC *http.Client // httpx.New in production
Logger *slog.Logger // Slack's error code on every failed call; discarded when nil
}
SlackClient is Slack's Web API over httpx. Token is read at use, so a rotated Secret applies.
func (*SlackClient) Message ¶
Message is conversations.replies for one ts (M9): the draft is a thread reply, which conversations.history never returns. The answer may also hold the thread's parent, so it keeps only the message whose ts is the one asked.
func (*SlackClient) Post ¶
func (c *SlackClient) Post(ctx context.Context, channel, threadTS, text string, meta *Metadata) (string, error)
Post is chat.postMessage: no unfurling, the metadata attached when there is one.
func (*SlackClient) PostCard ¶ added in v0.35.0
func (c *SlackClient) PostCard(ctx context.Context, channel, threadTS, text string, blocks json.RawMessage, meta *Metadata) (string, error)
PostCard is chat.postMessage for a message that carries Block Kit blocks (§5, §6): the card's prose is its text, so a client without blocks still reads it. Separate from Post on purpose — Post's own call sites and the draft's wire bytes stay untouched.
func (*SlackClient) PostEphemeral ¶
func (c *SlackClient) PostEphemeral(ctx context.Context, channel, user, threadTS, text string) error
PostEphemeral is chat.postEphemeral (chat:write): text that only user sees, never stored in the channel's history.
func (*SlackClient) Thread ¶
Thread is conversations.replies for a thread, followed over a few pages at most.
func (*SlackClient) Update ¶ added in v0.35.0
func (c *SlackClient) Update(ctx context.Context, channel, ts, text string, blocks json.RawMessage) error
Update is chat.update (chat:write already covers it): it rewrites a message the App posted, in place. No metadata — an update is the App's own change to its own message, never a new tag — and no unfurling, as on Post. blocks replaces the message's own; empty leaves them as they are.
func (*SlackClient) UpdateProposal ¶ added in v0.36.0
func (c *SlackClient) UpdateProposal(ctx context.Context, channel, ts, text string, blocks json.RawMessage, meta *Metadata) error
UpdateProposal is chat.update for the proposal message (CD7, CD20): the App's own edit of its own message, carrying the metadata the message must hold afterwards. The blocks go when there are some, as on Update; the metadata is what makes the edited message still the proposal, so an edit that Slack refuses is the caller's to fall back from, never a silent repost.
type SlackCoordinationProjection ¶ added in v0.39.0
SlackCoordinationProjection is what one channel may be told of a family, as Slack lines.
type TaskQuestion ¶ added in v0.53.0
type TaskQuestion struct {
Text string `json:"text"`
Recommended string `json:"recommended,omitempty"`
}
TaskQuestion is task/v1's open question from the scoper's handoff.
type TaskResult ¶ added in v0.53.0
type TaskResult struct {
Room string `json:"room"`
URL string `json:"url"`
Text string `json:"text"`
Cursor string `json:"cursor"`
Runs []envelope.RunFact `json:"runs"`
NeedsYou []summary.Need `json:"needsYou"`
Question *TaskQuestion `json:"question,omitempty"`
Coordination json.RawMessage `json:"coordination"`
Items []roomview.Milestone `json:"items"`
More int `json:"more"`
// Status is summary/v1's status object, decoded into a summary so the thread's answers read the
// same fields the room page renders.
Status json.RawMessage `json:"status"`
}
TaskResult is task/v1 as a thread reads it (UX4): the task's room, its page, its status (the summary's, with the spend and the gate's decision), its runs, what it needs, its coordination view when it is a parent, and the milestones since the cursor.
func (TaskResult) Changes ¶ added in v0.53.0
func (t TaskResult) Changes() roomview.ChangeSet
Changes is the task's milestones as the changes view's set.
func (TaskResult) Summary ¶ added in v0.53.0
func (t TaskResult) Summary() summary.Summary
Summary is the task as summary/v1: the room, its page, its status, its runs, its needs and its coordination view — the fields a thread's answers, coordination updates and the end line read. A status that does not decode is left empty.
type Thread ¶
type Thread struct {
Channel string `json:"channel"`
TS string `json:"ts"`
At time.Time `json:"at"`
// EndTS is the ts of the thread's one end line (UX7): posted on room.ended (or room.merged when it
// arrives first) and rewritten in place on a later merge or revert.
EndTS string `json:"endTS,omitempty"`
// Coordination marks a coordination parent's thread (v4): its deliveries are recomputed against
// the channel at every event (projectCoordination), never posted as a single room's line.
Coordination bool `json:"coordination,omitempty"`
}
Thread is where a room filed from Slack is followed (R25). At is when it was put, for the 30-day prune.
type Threads ¶
type Threads interface {
Put(ctx context.Context, room string, t Thread) error
Get(ctx context.Context, room string) (Thread, bool, error)
}
Threads is the thread map, the ConfigMap factory-slack-threads in production.
type Tokens ¶
type Tokens struct {
Fetch func(ctx context.Context) (*oauth2.Token, error)
// contains filtered or unexported fields
}
Tokens caches the App's client-credentials token until it expires or the broker refuses it (L9): clientcredentials' own TokenSource reuses a token until it expires and cannot be told that the broker refused it. Fetch should go through httpx (oauth2.HTTPClient in the context).
func (*Tokens) Invalidate ¶
func (s *Tokens) Invalidate()
Invalidate drops the cached token after a 401, so the retry fetches a new one.