Documentation
¶
Overview ¶
Package platformfeedback is what agents report the platform could not do for them (#2820), delivered to whoever runs the platform.
The audit records that a call failed, not what the agent wanted. An agent knows at the moment it is blocked what it needed, and that knowledge was lost with the session; the only record of intent in three production deployments was a handful of tool-finding queries. A post here keeps it: what the agent was trying to do, what blocked it, the tool, a suggestion, and the calls involved by reference.
Every text field passes the content secret check (internal/secretscan) before anything is written, posts are bounded per session and per persona, a repeat of an open post is counted on it, and nothing is sent until an administrator turns the feature on and names the channels.
Index ¶
- Constants
- Variables
- func Register(mux *http.ServeMux, wrap func(http.Handler) http.Handler, svc *Service, ...)
- type Caller
- type ChannelSender
- type Delivery
- type Deps
- type Detail
- type InvalidError
- type Item
- type ListFilter
- type ListResponse
- type Post
- type RefusedError
- type Report
- type ResendRequest
- type Result
- type Service
- func (s *Service) Get(ctx context.Context, id string) (Detail, error)
- func (s *Service) List(ctx context.Context, f ListFilter) (ListResponse, error)
- func (s *Service) Resend(ctx context.Context, id, channel string) error
- func (s *Service) SaveSettings(ctx context.Context, in Settings, author string) (settingsjson.Stored[Settings], error)
- func (s *Service) SetStatus(ctx context.Context, id, status, by string) error
- func (s *Service) Settings(ctx context.Context) settingsjson.Stored[Settings]
- func (s *Service) Submit(ctx context.Context, c Caller, p Post) (Result, error)
- type Settings
- type SettingsView
- type Stats
- type StatusRequest
Constants ¶
const ( DefaultSessionLimit = 5 DefaultPersonaDailyLimit = 50 )
Defaults for the limits.
const ( CodeOff = "platform_feedback_off" CodePersona = "platform_feedback_persona" CodeLimit = "platform_feedback_limit" CodeSecret = "platform_feedback_secret" CodeInvalid = "platform_feedback_invalid" )
Codes a post is refused with.
const ( StatusOpen = "open" StatusPlanned = "planned" StatusDone = "done" StatusDeclined = "declined" )
Statuses a post moves through.
const SectionName = "platform_feedback"
SectionName is the platform_settings section the settings are kept in.
Variables ¶
var ErrNotFound = errors.New("platform feedback post not found")
ErrNotFound is a post that does not exist.
Functions ¶
Types ¶
type ChannelSender ¶
type ChannelSender interface {
NotifyChannel(ctx context.Context, s notification.ChannelSend) (notification.ChannelResult, error)
}
ChannelSender queues a document for one channel; notification.Enqueuer is one.
type Delivery ¶
type Delivery struct {
Channel string `json:"channel"`
Status string `json:"status"`
Attempts int `json:"attempts"`
LastError string `json:"last_error,omitempty"`
SentAt *time.Time `json:"sent_at,omitempty"`
}
Delivery is a post's send to one channel, as the notification queue holds it.
type Deps ¶
type Deps struct {
// DB holds the posts and the notification queue rows their sends wrote.
DB *sql.DB
// Section holds the settings; nil is "off".
Section *settingsjson.Section[Settings]
// Detector checks every text field for a credential before anything is
// written.
Detector secretscan.Detector
// Embed turns a post's words into a vector for folding a repeat; nil
// folds only an exact repeat.
Embed func(ctx context.Context, text string) ([]float32, error)
// Channels resolves a channel name; Sender queues a send to it.
Channels notification.ChannelStore
Sender ChannelSender
// ServiceAccount reports a persona whose calls are machinery: it may not
// post when the settings name no personas.
ServiceAccount func(persona string) bool
// KnownPersona checks a persona a settings save names.
KnownPersona func(persona string) bool
// PortalURL is the portal's public address, for the link a send carries.
PortalURL string
// Now is the clock; nil is time.Now.
Now func() time.Time
}
Deps is what the service reads.
type Detail ¶
type Detail struct {
Item
Reports []Report `json:"reports"`
Deliveries []Delivery `json:"deliveries"`
}
Detail is one post with its reports and deliveries.
type InvalidError ¶
type InvalidError struct{ Msg string }
InvalidError is a settings save refused for what it holds.
func (*InvalidError) Error ¶
func (e *InvalidError) Error() string
type Item ¶
type Item struct {
ID string `json:"id"`
TryingTo string `json:"trying_to"`
BlockedBy string `json:"blocked_by"`
Tool string `json:"tool"`
Suggestion string `json:"suggestion"`
Status string `json:"status"`
ReportCount int `json:"report_count"`
CreatedAt time.Time `json:"created_at"`
LastReportedAt time.Time `json:"last_reported_at"`
}
Item is one post as the list shows it.
type ListFilter ¶
ListFilter narrows the list.
type ListResponse ¶
type ListResponse struct {
Posts []Item `json:"posts"`
Total int `json:"total"`
Stats Stats `json:"stats"`
}
ListResponse is a page of posts and the page's counts.
type Post ¶
type Post struct {
TryingTo string `json:"trying_to"`
BlockedBy string `json:"blocked_by"`
Tool string `json:"tool,omitempty"`
Suggestion string `json:"suggestion,omitempty"`
Calls []string `json:"calls,omitempty"`
}
Post is one report as an agent writes it.
type RefusedError ¶
RefusedError is a post refused, with the code a caller branches on. Its message never repeats a field's content.
func (*RefusedError) Error ¶
func (e *RefusedError) Error() string
type Report ¶
type Report struct {
Persona string `json:"persona"`
UserID string `json:"-"`
SessionID string `json:"-"`
Calls []string `json:"calls"`
ReportedAt time.Time `json:"reported_at"`
}
Report is one report of a post: who and in which session, and the calls it names.
type ResendRequest ¶
type ResendRequest struct {
Channel string `json:"channel" example:"ops-webhook"`
}
ResendRequest names the channel a post is sent to again.
type Result ¶
type Result struct {
ID string `json:"id"`
ReportCount int `json:"report_count"`
// Folded is true when the post repeated an open one and was counted on it
// rather than stored and sent again.
Folded bool `json:"folded"`
// Channels is how many channels the new post was queued for.
Channels int `json:"channels"`
Message string `json:"message"`
}
Result is what a post did.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is platform feedback.
func (*Service) List ¶
func (s *Service) List(ctx context.Context, f ListFilter) (ListResponse, error)
List is the posts a filter selects, with the page's counts.
func (*Service) Resend ¶
Resend queues a post again for one channel the settings name, as a delivery that failed is retried by hand.
func (*Service) SaveSettings ¶
func (s *Service) SaveSettings(ctx context.Context, in Settings, author string) (settingsjson.Stored[Settings], error)
SaveSettings validates and stores the settings.
type Settings ¶
type Settings struct {
// Enabled lets agents post. Off by default.
Enabled bool `json:"enabled"`
// Channels are the notification channels a new post is sent to.
Channels []string `json:"channels"`
// Personas may post; empty is every persona except service accounts.
Personas []string `json:"personas"`
// SessionLimit is the most posts one session may make.
SessionLimit int `json:"session_limit"`
// PersonaDailyLimit is the most posts one persona may make in a day.
PersonaDailyLimit int `json:"persona_daily_limit"`
}
Settings is how platform feedback is configured in Admin > Settings.
type SettingsView ¶
type SettingsView struct {
Settings
UpdatedBy string `json:"updated_by,omitempty"`
UpdatedAt *time.Time `json:"updated_at,omitempty"`
}
SettingsView is the settings with who saved them.
type Stats ¶
type Stats struct {
Open int `json:"open"`
ReportsThisWeek int `json:"reports_this_week"`
RefusedThisWeek int `json:"refused_this_week"`
DeliveryFailures int `json:"delivery_failures"`
}
Stats are the list page's counts.
type StatusRequest ¶
type StatusRequest struct {
Status string `json:"status" example:"planned"`
}
StatusRequest moves a post to a status.