Documentation
¶
Overview ¶
Package intent is the vocabulary of a Slack reply's second reading (spec SI3, SI4): the closed intents (All), the schema check that turns a model's answer into one of them or into unknown, the span rule that lets the model choose what to quote but never write it, and the pause each phase-bound label needs. It does no I/O: the one model call is model.go's, and who may be classified, and which room's facts the pause is read from, is the broker's.
Index ¶
- Constants
- Variables
- func ConfirmHash(text string) string
- func DecideLine(repository, branch, digest string) string
- func MentionReview(text string) (repo string, pr int, ok bool)
- func OneLine(s string) string
- func Parse(raw []byte, reply string, minConfidence float64) (Result, Outcome)
- func PauseLine(action string, issue int) string
- func PlanNoteOK(note string) bool
- func Span(reply, text string) string
- func TaskLine(repository, title string) string
- func TextHash(text string) string
- func ValidPhase(p string) bool
- type Intent
- type Model
- type Outcome
- type Result
- type Usage
Constants ¶
const ( // MaxPlanNote is a plan revise's note, as the factory caps it. MaxPlanNote = 1 << 10 // MaxSteerText is a steer, as the next run's brief quotes a queued message. MaxSteerText = 1 << 10 )
The bounds a chat loop text is confirmed and sent within (R15): the adapter caps before it draws the Confirm, so the bound text is what is sent, and the broker re-checks. An amendment's is envelope.MaxAmendText.
Variables ¶
var ( // ErrInvalid is a gateway reply that is not the shape the call asks for, or too large. ErrInvalid = errors.New("classifier_invalid") ErrUnavailable = errors.New("classifier_unavailable") // ErrTimeout is the call outliving its deadline. ErrTimeout = errors.New("classifier_timeout") )
The sentinels the caller maps to its closed outcomes: ErrTimeout to `timeout`, ErrInvalid to `invalid_output`, ErrUnavailable to `error`. Each carries its detail after the colon; the detail never holds the reply.
var All = []Intent{Status, Needs, Changes, PR, Stop, Retry, RetryDeeper, Answer, PlanApprove, PlanRevise, PlanSplit, SplitAccept, SplitDecline, Steer, Amend, Unknown}
All is every intent, in the order the schemas list them: the model's response format, the broker's output schema and Parse all read this one list, so none of them can drift from the others.
var Phases = []string{"queued", "running", "waiting-you", "waiting-other", "waiting-pr", "waiting", "done", "failed", "stopped", "unknown"}
Phases is the closed list of words a thread's phase may be sent as (SI3): the kinds of summary.StatusLine, which the App reads from the one room_summary it makes, and "unknown" for a room whose status that summary cannot name. The classifier reads no room; the broker refuses any other word, so a caller cannot smuggle text in through the phase.
Functions ¶
func ConfirmHash ¶ added in v0.59.0
ConfirmHash is th, the free-text binding a chat Confirm button's signed value carries (v5 §3.3): the first 32 hex characters of the digest TextHash names, over the exact UTF-8 bytes sent as text, with no trimming, folding or unescaping. The broker and the chat adapter both call it, so neither carries its own copy.
func DecideLine ¶ added in v0.59.0
DecideLine is the text a signed decide card shows in its maku_text block, which the broker derives from the approval itself (v5 §3.3 step 5): "Push to <repository> <branch>, bundle <first 12 of digest>", the bundle left out for an approval that binds no digest.
func MentionReview ¶ added in v0.54.0
MentionReview reports whether a mention carries a GitHub pull request URL (raw or Slack-wrapped) and asks for a review, returning the repository and pull request number (phase F4/F6).
func OneLine ¶ added in v0.59.0
OneLine is s with every run of whitespace collapsed to one space and the ends trimmed: a plan revise's note as the factory records it.
func Parse ¶
Parse reads the model's raw answer against reply. Anything that is not the closed shape, names an intent outside All or carries a confidence outside 0 to 1 is Unknown with OutcomeInvalidOutput; a confidence under minConfidence is Unknown with OutcomeLowConfidence. Steer, amend, answer and plan_revise keep the span of reply the model quoted (Span), every other intent drops its text.
func PauseLine ¶ added in v0.59.0
PauseLine is the fixed text a signed plan or split Confirm shows in its maku_text block (R2): "Approve plan for #<issue>", "Split task #<issue> as planned", "Accept split for #<issue>" or "Decline split for #<issue>", "this task" in place of "#<issue>" when the task has no issue. The broker derives it from the room's own task facts and refuses a signed click on a card that showed anything else. "" for every other action: a plan revise binds its note, not a fixed line.
func PlanNoteOK ¶ added in v0.59.0
PlanNoteOK reports whether note is a plan revise's note as it must be bound: non-empty, at most MaxPlanNote bytes, and already its own OneLine form, so the factory records the text confirmed.
func Span ¶
Span is what a text-bearing intent (steer, amend, answer, plan_revise) acts on: text if it is a contiguous span of reply once case and whitespace are folded, returned as the reply spelled it; otherwise, an empty text included, the whole reply. The model chooses what to quote and never writes it (SI4).
func TaskLine ¶ added in v0.59.0
TaskLine is the text a signed confirm:task card shows in its maku_text block: "<repository>: <title>", the stored plan's repository and its (first) issue's title (v5 §3.3 step 5).
Types ¶
type Intent ¶
type Intent string
Intent is one of the labels in All a reply can carry.
const ( Status Intent = "status" Needs Intent = "needs" Changes Intent = "changes" PR Intent = "pr" Steer Intent = "steer" Amend Intent = "amend" Stop Intent = "stop" Retry Intent = "retry" RetryDeeper Intent = "retry_deeper" Answer Intent = "answer" PlanApprove Intent = "plan_approve" PlanRevise Intent = "plan_revise" PlanSplit Intent = "plan_split" SplitAccept Intent = "split_accept" SplitDecline Intent = "split_decline" Unknown Intent = "unknown" )
The closed vocabulary. A model answer outside it is Unknown with OutcomeInvalidOutput.
func (Intent) InPause ¶ added in v0.59.0
InPause reports whether i may be read in a task at taskPhase with reason, the room's own task facts (never a word the caller sent): a plan decision only while the plan waits for review (AwaitingHuman, plan_review), a split decision only while a split is proposed (Escalated, split_proposed), an answer only while the scoper's question waits on the author (Escalated, needs_author). Every other intent has no pause and is always in one.
func (Intent) PhaseBound ¶ added in v0.59.0
PhaseBound reports whether i is read only in a pause (InPause): the plan and split decisions and an answer.
type Model ¶
type Model struct {
// URL is the gateway's base route (`human.slackIntents.url`); the call is appended to it.
URL string
// Alias is the one model alias the classifier may name.
Alias string
// KeyFile holds the `classifier` client's key, read at use so a rotation needs no restart.
KeyFile string
// Deadline bounds the call. Zero means five seconds.
Deadline time.Duration
// HC is the audited egress client (`httpx.New`). A nil client makes no call.
HC *http.Client
}
Model is the one bounded `chat/completions` call: the gateway's route, the pinned alias, the key file read at use, the audited egress client and a deadline. It holds no state and shares nothing with the planner's client but httpx: a planner change must not move the classifier.
func (Model) Classify ¶
Classify makes the one call: the reply and the thread's phase as one JSON user message, no history, one attempt. It returns the model's answer as raw bytes for Parse, which decides what it means; an answer outside the closed shape is Parse's `invalid_output`, not an error here.
type Outcome ¶
type Outcome string
Outcome is how a classification ended, as maku_intent_classify_total{outcome} counts it.
const ( OutcomeOK Outcome = "ok" OutcomeLowConfidence Outcome = "low_confidence" OutcomeInvalidOutput Outcome = "invalid_output" OutcomeTimeout Outcome = "timeout" OutcomeCapped Outcome = "capped" OutcomeError Outcome = "error" OutcomePrivateUnavailable Outcome = "private_unavailable" // OutcomePhaseGated is a phase-bound label the model gave outside its pause, answered unknown. OutcomePhaseGated Outcome = "phase_gated" )
The outcomes Parse decides; the caller adds timeout, capped, error, private_unavailable and phase_gated.