feat(claw): answer a thread only when somebody addresses the daemon
A repo watch saw *every* issue, pull request, review and comment on the repository, and the handler treated each dispatch as work to do: a snapshot fetch, a coding-agent turn, and a comment posted back. On a repository with any traffic at all that is the wrong end of the question — watching a repo is not volunteering to answer it — and it is also how a daemon ends up talking to itself, since its own replies are news too. The dispatch now starts with a mention gate. A thread runs when: - it delivered a triaged notification — assigned, review requested, @-mentioned: the notifications feed already adjudicated that one; or - one of its plain events names the handle the daemon speaks as (`@kosmos`), written by anybody *but* the daemon. Everything else is drained and dropped: no snapshot, no model call, no comment. The outcome is `Superseded` — RSD's vocabulary has no "nothing was asked", and the closest is that the work the event names is not this daemon's. Recognizing its own name took a little plumbing. The credential a watch resolves carries a login only when an account identity supplied the token; a token pasted into a watch row, or a forge environment variable, names nobody — and that is the deployment the gate must not go inert on. So `Forge::viewer_login` is the backend's own answer to "who am I", from its `/user` (Gitea and GitHub spell it `login`, GitLab `username`), with a `None` default for backends that cannot say; the handler asks at most once per credential and keeps the answer beside the cached client. A forge that will not name the credential leaves the gate *open*, with a warning in the log: a filter that silently mutes a watch is worse than one that occasionally over-answers. The actor check is load-bearing for the same reason the gate exists: a reply quotes the mention it answers, so "addressed by name" alone would have the daemon answer itself, forever. Tests: unit tests for the gate (name in any case, own comment, no body, notification, unnamed credential), one end-to-end test per behaviour — a mention runs one turn and posts one reply; a thread's own chatter runs nothing and posts nothing; the daemon's own reply does not reopen the gate — plus `viewer_login` against all three backends.
This commit is contained in:
1 parent
a9c41be440
commit
f1a3d3b4ed
10 files changed
+535
-5
No files matched your search
@@ -244,7 +244,21 @@ tool wakes with the account id, never the secret, and a denial or a
|
||||
15-minute silence comes back in-band so the turn can say so and move
|
||||
on. A watch with no token of its own polls — and replies — as the
|
||||
matching saved account: the same forge, and on a self-hosted forge the
|
||||
same base URL. Acting with a stored account is `identity_exec`: it runs one shell
|
||||
same base URL.
|
||||
|
||||
A repo watch is a feed, not an invitation. The daemon answers a thread
|
||||
when somebody there addresses it — a comment whose body names the handle
|
||||
its credential speaks as (`@kosmos`), written by anyone but itself — and
|
||||
otherwise drains the news and runs nothing: no snapshot, no turn, no
|
||||
comment on somebody else's conversation. (Its own replies quote the
|
||||
mention they answer, so they never reopen the gate.) Notifications are
|
||||
the other door and are adjudicated before they arrive — assigned, review
|
||||
requested, @-mentioned — so those always run. The handle is the account
|
||||
identity's when the token has one, and the forge's own `/user` answer
|
||||
when it does not; a credential the forge will not name leaves the gate
|
||||
open, with a warning in the log, rather than silently muting a watch.
|
||||
|
||||
Acting with a stored account is `identity_exec`: it runs one shell
|
||||
command in the session workspace with the secret injected —
|
||||
`ACCOUNT_SECRET` plus the service's own `GITHUB_TOKEN`/`GITEA_TOKEN`/
|
||||
`GITLAB_TOKEN`, and a git credential helper — so `git clone` and API
|
||||
|
||||
Reference in new issue
Block a user