Documentation
¶
Overview ¶
Package approvalnotify wires the permission gate's unwatched-prompt signal to the operator's alert registry (#647).
The gate can now bound how long a prompt waits (permissions.approval_timeout). That stops an unattended daemon from hanging forever on an approval nobody will give. It does not tell anybody the approval was wanted — so on its own the bound converts a hung agent into an agent that quietly gives up, which is better but still not operable.
This package closes the other half: when a prompt opens and the fan-out reaches nobody, one notification goes out to a pre-registered alert target carrying what was asked, which session asked it, the request id, and when it expires. That is the difference between a doorbell and a door.
permissions.approval_notify_after extends that to a prompt that did reach an attached client and then went unanswered for that long (#1167), because a client being attached is not somebody watching it.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Notifier ¶
type Notifier struct {
// contains filtered or unexported fields
}
Notifier turns unwatched prompts into alerts on one target.
func New ¶
New builds a Notifier for cfg.Permissions.ApprovalNotify, or (nil, nil) when the operator did not ask for one.
An error here is a startup error and callers should treat it as fatal rather than degrading to no notification. The whole point of the field is that an operator running gated and unattended has stated they cannot watch the console; starting anyway, with a warning on that same console, hands them exactly the silence they configured against.
func (*Notifier) Attach ¶
func (n *Notifier) Attach(broker *attach.PromptBroker, session func() string)
Attach installs n on broker for the session the getter names. A nil Notifier is a no-op, so callers can wire unconditionally.
The session id is supplied rather than read off the frame because the broker is per-session and the frame does not carry the id — and the id is the one thing a responder cannot do without, since the respond route is /sessions/<sid>/perms/respond.
It is a GETTER rather than a string because of when the wiring happens. On the daemon path the broker is constructed and handed to the gate while the primary agent is still just a list of options — agent.New does not run until the runner starts — so there is no session id to read yet, and on a multi-session daemon there is no primary agent at all and never will be. Taking a string here invites the caller to resolve it eagerly, which is a nil dereference at startup rather than a missing field in one notification.
func (*Notifier) AttachSession ¶
func (n *Notifier) AttachSession(broker *attach.PromptBroker, session string)
AttachSession is Attach for a caller that already holds the id — the per-session factory, where the session exists before its broker does.