Documentation
¶
Overview ¶
Package attention reads stored answers from the attention-controller store.
The store keeps one card per question a worker asked, plus a delivery report per card. A card whose answer exists but was never delivered is an answer the worker never saw; re-surfacing it on the next resume is what lets the task continue instead of asking the same question again.
Index ¶
Constants ¶
const ( // DeliveryBound is how long after an answer was stored a delivery arm is still // expected to reach the session. It mirrors attention-controller's // AttentionDeliveryBound (itself an alias of AttentionDeliveryRetryBackoff); // past it, a never_attempted or held answer is treated as one no arm will reach. // Pinned by a test so cross-repo drift is caught. DeliveryBound = 5 * time.Minute )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AnsweredItem ¶ added in v0.203.2
type AnsweredItem struct {
// ItemID identifies the attention item.
ItemID string
// Answer is the answer text, already formatted for display. It is used to
// skip answerless cards; callers need not print it.
Answer string
// Status is the delivery status the store derives for the item.
Status DeliveryStatus
// AnsweredAt is when the answer was recorded. Nil when the store carries no
// answered_at.
AnsweredAt *libtime.DateTime
// State is the item's card state.
State ItemState
}
AnsweredItem is one answered attention item for a session, with the delivery status and timing the caller needs to decide whether any delivery arm will reach the session that asked.
type DeliveryStatus ¶ added in v0.203.2
type DeliveryStatus string
DeliveryStatus is the derived delivery status of an attention item's attempt, as returned by GET /api/1.0/attention/{item_id}/attempt.
const ( // DeliveryStatusDelivered means an arm carried the answer to the session. DeliveryStatusDelivered DeliveryStatus = deliveredStatus // DeliveryStatusFailed means an arm ran and gave up: the operator's cue that // the answer did not arrive. DeliveryStatusFailed DeliveryStatus = "failed" // DeliveryStatusHeld means an arm saw the gate and deliberately declined. DeliveryStatusHeld DeliveryStatus = "held" // DeliveryStatusRetrying means an arm ran and could not reach the session yet // but is still trying; it is not a failure. DeliveryStatusRetrying DeliveryStatus = "retrying" // DeliveryStatusNeverAttempted means no arm ever looked at the item. DeliveryStatusNeverAttempted DeliveryStatus = "never_attempted" // DeliveryStatusPreTrailUnknown means the item predates the delivery trail, so // its fate is unknown — not known lost. DeliveryStatusPreTrailUnknown DeliveryStatus = "pre_trail_unknown" )
type ItemState ¶ added in v0.203.2
type ItemState string
ItemState is the attention item's lifecycle state, as carried by the history wire.
const ( // ItemStateOpen is a card awaiting an answer. ItemStateOpen ItemState = "open" // ItemStateAwaitingEvidence is a card whose answer is still being completed. ItemStateAwaitingEvidence ItemState = "awaiting_evidence" // ItemStateAnswered is a card carrying an answer. ItemStateAnswered ItemState = "answered" // ItemStateClosed is a card that was closed. ItemStateClosed ItemState = "closed" )
type StoredAnswer ¶
type StoredAnswer struct {
// ItemID identifies the attention item the answer belongs to.
ItemID string
// Answer is the answer text, already formatted for display.
Answer string
}
StoredAnswer is an answer that was stored against a task's session but never delivered to that session.
type StoredAnswerReader ¶
type StoredAnswerReader interface {
FindUnconsumed(ctx context.Context, sessionID string) (*StoredAnswer, error)
// FindAnswered returns the session's most recent answered items (up to
// answeredScanLimit), each with its delivery status, answer time and card state.
//
// It is deliberately not FindUnconsumed: that read answers "is there an answer to
// inject", which must stay untouched, while this one answers "will any delivery
// arm reach this answer". Items that carry no answer text are skipped, matching
// FindUnconsumed.
FindAnswered(ctx context.Context, sessionID string) ([]AnsweredItem, error)
}
StoredAnswerReader finds an unconsumed stored answer for a session.
It returns (nil, nil) when the session has no undelivered answered item.
func NewHTTPStoredAnswerReader ¶
func NewHTTPStoredAnswerReader(baseURL string, client *http.Client) StoredAnswerReader
NewHTTPStoredAnswerReader creates a reader backed by the attention store at baseURL. The caller owns client and must supply one with a timeout — a blackholed store must never block a resume forever.