intent

package
v0.59.0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: Apache-2.0 Imports: 18 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 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

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

View Source
var (
	// ErrInvalid is a gateway reply that is not the shape the call asks for, or too large.
	ErrInvalid = errors.New("classifier_invalid")
	// ErrUnavailable is a gateway that could not be reached, refused, or could not authenticate us.
	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.

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.

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

func ConfirmHash(text string) string

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

func DecideLine(repository, branch, digest string) string

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

func MentionReview(text string) (repo string, pr int, ok bool)

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

func OneLine(s string) string

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

func Parse(raw []byte, reply string, minConfidence float64) (Result, Outcome)

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

func PauseLine(action string, issue int) string

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

func PlanNoteOK(note string) bool

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

func Span(reply, text string) string

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

func TaskLine(repository, title string) string

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).

func TextHash

func TextHash(text string) string

TextHash is the value the confirm binds to: "sha256:" and the hex of the span's SHA-256.

func ValidPhase

func ValidPhase(p string) bool

ValidPhase reports whether p is one of Phases.

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

func (i Intent) InPause(taskPhase, reason string) bool

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

func (i Intent) PhaseBound() bool

PhaseBound reports whether i is read only in a pause (InPause): the plan and split decisions and an answer.

func (Intent) Valid

func (i Intent) Valid() bool

Valid reports whether i is one of All.

func (Intent) Write

func (i Intent) Write() bool

Write reports whether the intent acts on a task once confirmed: stop, retry, steer, amend, an answer and the plan and split decisions. The rest are reads or nothing.

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

func (m Model) Classify(ctx context.Context, reply, phase string) ([]byte, Usage, error)

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 is a private repository's reply with no internal route: no call made.
	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.

type Result

type Result struct {
	Intent     Intent
	Text       string
	Confidence float64
}

Result is a classification: the label, the span of the reply it acts on (steer, amend, answer and plan_revise only) and the model's confidence.

type Usage

type Usage struct {
	Model            string
	PromptTokens     int
	CompletionTokens int
}

Usage is what the call cost, from the reply's own `usage`: a reply without it is refused, since the spend of the App's `classifier` client has to be attributable.

Jump to

Keyboard shortcuts

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