Repository navigation
feat(control-plane): push notifications for paused and finished subagents (#394) - #998
Conversation
… and rendering (rossoctl#394) Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: cwiklik <[email protected]>
…tl#394) Signed-off-by: cwiklik <[email protected]> Assisted-By: Claude (Anthropic AI) <[email protected]>
…ctl#394) Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: cwiklik <[email protected]>
…ossoctl#394) Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: cwiklik <[email protected]>
Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: cwiklik <[email protected]>
…string (rossoctl#394) Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: cwiklik <[email protected]>
…deliveries (rossoctl#394) sweepNotifications reads each configured owner's rossoctl#392 event stream, coalesces matching states into one delivery, and holds the cursor on failure so the next pass retries. startNotifySweep arms it on a 10s timer, inside rossoctl#394's 30s delivery budget. Fixed a Node fetch invariant in the test fixture: `new Response('', {status: 204})` throws (null-body statuses cannot carry a body); the fake now constructs it with a null body. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: cwiklik <[email protected]>
Adds notifyFromEnv (the five MOCA_NOTIFY_* vars, with the same fail-closed, refuse-to-boot-on-a-bad-entry contract catalogHostsEnv uses for SH_MODEL_CATALOG_HOSTS), replaces the two inert rossoctl#394 placeholder literals in configFromEnv's harness and sandbox branches, wires NotifyStore into the Redis deps beside TurnStore, and arms startNotifySweep beside startGateSweep. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: cwiklik <[email protected]>
…#394 notifications Adds the five MOCA_NOTIFY_* vars to all three deploy targets (vm env example, compose pass-through, k8s optional configMapKeyRefs), bumps the control-plane OpenAPI version to 1.38.0 with a CHANGELOG entry for GET/PUT/DELETE /v1/notifications, updates change-policy.md's running version citation, and adds an operator section to the multi-user guide covering sink setup, webhook verification, the two rate limits, and that the approval deep link 404s until rossoctl#467/B8b lands. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: cwiklik <[email protected]>
…istically deploy/compose has no Docker daemon in this environment to time a real push end-to-end, so this adds a fake-timer test showing a fresh owner event becomes a delivery attempt within one NOTIFY_SWEEP_INTERVAL_MS (10s) tick of the armed sweep timer -- well inside the 30s acceptance criterion. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: cwiklik <[email protected]>
) The notification allowlist is the only SSRF control on a URL the control plane fetches for a user, so its boot contract gets the same treatment as SH_MODEL_CATALOG_HOSTS: empty unless the operator opts in, and a refusal to start on a malformed entry rather than a surprise at first delivery. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: cwiklik <[email protected]>
…kill the process startNotifySweep's setInterval body let sweepNotifications's rejection (e.g. notify.owners() against a down Redis) escape unhandled. On Node 22 an unhandled rejection terminates the process by default, so a Redis blip restarted the control plane every 10s tick. Drive-by: startGateSweep has the exact same shape on its 30s tick, so it gets the same .catch. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: cwiklik <[email protected]>
Three owners with hanging sinks can push one sweep pass past the 10s interval. setInterval fires again while pass A is still inside deliver, the cursor has not advanced, and pass B re-reads and re-delivers the same batch. A module-level in-flight flag skips a tick that starts before the previous one finished. Not the two-replica shortcut documented on sweepNotifications -- a flag does nothing for a second process -- this covers a single replica overlapping its own slow pass. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: cwiklik <[email protected]>
undici follows redirects by default; an allowlisted host answering 302
to an unchecked host would be chased with nothing re-checking the
allowlist on the new URL. `post()` now passes redirect: 'error' so a
redirect fails the delivery instead (the cursor holds, so the next
sweep pass is the retry).
sendNtfy also POSTed to `new URL('/', sink.url)`, discarding any path
component an operator's allowlist entry deliberately carried. It now
POSTs the stored sink url exactly, as `allowsUrl` already approved.
Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: cwiklik <[email protected]>
A re-PUT that drops webhook (or ntfy) for the other left the dropped kind's secret in the credential store with no config pointing at it -- unreadable, unrotatable, and never cleaned up. putNotifications now deletes a kind's credential when the new config has no sink of that kind, same principle DELETE already applies to both secrets. Done after the config write, not before: a crash here leaves a readable config whose dropped-kind secret lingers one extra beat, rather than a config write that could still fail after the secret it depended on was already gone. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: cwiklik <[email protected]>
MOCA_NOTIFY_BASE_URL was only trimmed, not validated: a scheme-less typo would ship as a non-navigable link inside every notification. urlEnv (already used for SH_PUBLIC_HARNESS_URL) now takes an optional protocol list so the base url can require https: specifically; unset still means no link, correct for a deployment the phone cannot reach. MOCA_NOTIFY_PER_HOUR and MOCA_NOTIFY_FAIL_MAX read 0 as "unlimited" to an operator, but the sweep treats 0 literally and would mute every subject permanently. positiveCountEnv wraps the existing countEnv and refuses to boot on 0 for these two settings; MOCA_NOTIFY_MIN_INTERVAL_S keeps 0 as its genuinely meaningful "no minimum spacing" value. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: cwiklik <[email protected]>
…url's hostname An absent `token` means "leave the stored one alone"; parseSink treated an explicitly-empty string the same way, so a caller who thought they were clearing an ntfy token silently kept the old one authenticating. An empty token is now refused, naming DELETE /v1/notifications as the actual way to clear one. A rejected sink url's error message echoed the raw value, including any userinfo or query string -- exactly where a credential gets pasted by mistake. It now echoes only the hostname. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: cwiklik <[email protected]>
…clarifications MOCA_NOTIFY_PER_HOUR and its mute behavior are a fixed window (two bookkeeping fields, not a sliding log of timestamps), but the env example and the multi-user doc both said "rolling" -- fixed and rolling windows reset and re-arm differently, so this was an operator-facing inaccuracy, not just phrasing. Also documents: the X-Moca-Delivery header carries the batch's head cursor rather than a fresh id per attempt (CHANGELOG), that the approve deep link 404s until the login-gated approval page (rossoctl#467/B8b) lands (CHANGELOG, openapi.yaml), notify-store's advance() against a DELETE racing a sweep's read-modify-write, and renderNotification's "first paused event only" batching behavior. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: cwiklik <[email protected]>
clawgenti
left a comment
There was a problem hiding this comment.
Reviewed 0dd30c0 (18 commits, all DCO-signed). The design is sound: a fail-closed allowlist parsed by the same parseDestination the egress store uses, a sweep keyed on the subject's own event stream with the cursor held on failure, and the redirect-to-unlisted-host hole closed with redirect: 'error' before it shipped. The findings below are about where the code and its own description of the credential boundary do not meet.
Must-fix
- An ntfy token follows the sink to a host it was never stored for (
packages/control-plane/src/notify-handlers.ts:129). A re-PUT that omitstokenkeeps the stored secret — correct — but the credential keeps its olddestination.hostswhiledeliver()attaches the token to whatever URL the new config holds. Probe at this head: sink moved fromntfy.example.comtontfy.other.examplewithout resending the token →Authorization: Bearer TOKEN_FOR_Atohttps://ntfy.other.example, credential destination stillntfy.example.com. Details inline.
Suggestions
- A webhook with no signing key also silences the ntfy sink (
packages/control-plane/src/notify-send.ts:140).deliveris all-or-nothing, andsendWebhookreturnsfalsewithout a request when the key is gone (secretMissing's half-written PUT), so the sink that does reach the phone is re-sent the same batch every pass and then muted. Inline.
Nits
- The body says the sweep "advances the cursor only on delivery success, so a failure is the retry". Two paths advance without a delivery: a batch holding no wanted state (
notify-sweep.ts:78) and the hourly cap (notify-sweep.ts:96). Both are documented asshortcut:s in the code; the body should read "only on delivery success, except the two dropped-batch paths".
Author: cwiklik (CONTRIBUTOR — returning external)
Areas reviewed: TypeScript (control-plane), OpenAPI + docs, deploy env wiring (compose / k8s / vm), tests
Agent/IDE config (.claude/.vscode): none in the diff
Commits: 18 commits, all signed-off: yes
CI status: passing — 17/17 checks (check, codeql, DCO, deploy-scripts, deploy-scripts-bash32, docs, hadolint, k8s-kind-e2e, lint, microvm-gates, proto, shellcheck, trivy, dependency-review)
Verified by: tsc --noEmit clean; the five notify suites 58/58; the full control-plane suite locally against Redis 8 — 2190 passed / 4 skipped; two throwaway probes, deleted afterwards (the token host move above, and a states-only re-PUT rotating the webhook key, which the docs already state, so not flagged).
Generated by RepoMan github-pr-review@235a7f7 (https://github.com/rossoctl/agent-skills/blob/235a7f7620139ee3e4ab0872b8439591fe52e8c1/skills/github-pr-review/SKILL.md).
| secret: { token: ntfyToken }, | ||
| }); | ||
| } | ||
| // An ntfy token the caller did NOT resend is left alone, deliberately: a PUT that only edits |
There was a problem hiding this comment.
must-fix — an ntfy token is sent to a host it was never stored for.
Omitting token on a re-PUT keeps the stored one (this comment), but the stored credential keeps its old destination.hosts, and deliver() attaches the token to whatever URL the new config holds — it reads the secret by name only (notify-send.ts:140) and never compares it with the sink's host.
Probe at 0dd30c0 (throwaway file under test/, deleted afterwards), three allowlisted hosts:
- PUT ntfy
https://ntfy.example.com, topica1, tokenTOKEN_FOR_A
→ credential destination{"hosts":["ntfy.example.com"]}, tokenTOKEN_FOR_A - PUT ntfy
https://ntfy.other.example, topicb1, no token
→ credential destination still{"hosts":["ntfy.example.com"]}, tokenTOKEN_FOR_A - one
pausedevent, onesweepNotifications
→ sent{"url":"https://ntfy.other.example","auth":"Bearer TOKEN_FOR_A"}
That destination is the binding the credential store exists to enforce (sandbox-egress keys proxy injection on it); here the sender steps around it. Both hosts are operator-allowlisted, but the user authorized the token for one of them.
Suggested fix: in putNotifications, compare the new ntfy sinks' hosts with the stored descriptor's and, when they differ and no new token was sent, refuse the PUT (invalid_request: "resend the token for "). The alternative — delete the token and surface it — needs an ntfy analogue of secretMissing, since GET currently gives a subject no signal that their token is now going elsewhere.
Why now: this ships in 1.38.0 and a token is exactly the kind of secret a user moves between servers (a self-hosted ntfy to ntfy.sh).
There was a problem hiding this comment.
Fixed in 9ecc8bd7, taking your first suggested fix rather than the second: putNotifications now reads the stored descriptor and refuses the PUT with invalid_request when the new ntfy host is not among destination.hosts and no token was sent (notify-handlers.ts:99-109).
Dropping the kept token instead was the option I rejected, for the reason you give: GET has no ntfy analogue of secretMissing, so it would silently turn an authenticated topic into a failing one with nothing to tell the subject which of the two happened. Refusing puts it where the caller can fix it by resending.
Two details worth naming:
- The check runs before every write, in particular before the webhook put that rotates the signing key. A 400 therefore leaves nothing half-applied and does not hand the caller a secret that no longer verifies — asserted in the new test.
- Resending
tokenrebinds the credential to the new host, so the config and the descriptor cannot drift apart. I walked the five paths that change an ntfy sink's URL (PUT with token; PUT without, same host; PUT without, different host; ntfy dropped; DELETE) and the invariant holds in each.
openapi.yaml, the API CHANGELOG and docs/operate/harness/multi-user.md §7 now state the invariant rather than only "omitting token leaves the previous one in place".
| sinks.map((s) => | ||
| s.kind === 'webhook' | ||
| ? sendWebhook(deps, s, payload, secrets.webhookKey) | ||
| : sendNtfy(deps, s, payload, secrets.ntfyToken), |
There was a problem hiding this comment.
suggestion — one half-configured sink silences the working one.
deliver returns results.every(Boolean), and the sweep holds the cursor on false. A webhook sink whose signing key is missing — the half-written PUT that secretMissing exists to report — makes sendWebhook return false with no request attempted, so the ntfy sink that does reach the phone is re-sent the same batch on every pass and, after failMax, the subject is muted for an hour. The only clue is secretMissing on GET.
Suggested fix: separate the two kinds of failure. A missing key is a config error that no retry can fix; a non-2xx or a timeout is a transport failure that a retry can. Return a tri-state from the sinks and advance the cursor once every sink has either delivered or is permanently unsendable, logging the latter — keeping today's hold-the-cursor behaviour for genuine transport failures.
This is the trade-off the shortcut: on deliver already names (per-sink cursors); the narrower change above does not need them.
There was a problem hiding this comment.
Fixed in 11db0991, in four lines rather than with a tri-state (notify-send.ts:147-150): deliver filters out the sinks that can never be sent to — today only a webhook with no signing key — and takes every() over the ones it actually attempted.
That buys the whole behaviour you describe without a per-sink cursor and without a third return value: the ntfy sink's success advances the cursor, the keyless webhook does not hold it, and a genuine transport failure still does.
Why holding the cursor for the keyless webhook buys it nothing in particular: a re-PUT resets the cursor to turns.lastEventId(subject), so the batch being held is discarded the moment the subject fixes the config. secretMissing on GET remains that sink's signal.
Two tests cover it, including the trap in the narrow form: every() over an empty attempted-list would be vacuously true and drop the batch silently, so a webhook-only config with no key returns false — the cursor holds and failures says so.
…lowlist Three defects from review of rossoctl#998, all in the push path: - The gate summary is model output and was sent unclipped. ntfy rejects a body past its message-size limit (4 KiB on ntfy.sh) and a rejected delivery holds the cursor, so one long summary would retry forever and the subject would never be told anything again. Clipped with `clip` from turn-result.ts, in the one place both sinks read from. - A `lost` event reached the phone under a green tick and the generic "N updates" line: the reaper writes it for a turn nobody picked up, so work that silently never ran was reported as finished. It now renders as a failure, and names itself in the message since it carries no reason. - `MOCA_NOTIFY_ALLOW` was checked only at the PUT that stored a sink, so an operator who took a host back out of the list did not stop deliveries to the sinks already saved under it -- and no route lets an admin edit another subject's config. Re-checked at send time, counted as a failed delivery rather than a silent skip so the cursor holds and `failures` on GET says why. Also asserts the batch's head cursor instead of defaulting it to `cfg.cursor`, which would have re-delivered the same batch on every pass. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: cwiklik <[email protected]>
Review of rossoctl#998 asked four questions the code did not answer: - `deliveryId` is the batch's head cursor, so dedupe holds for a retry of an IDENTICAL batch. A batch that GREW between the failed attempt and the retry carries a new id, and a receiver sees one duplicate. Recorded in the payload comment and in the API changelog, since a receiver writing dedupe logic reads the changelog, not the source. Deliberately not fixed by keying on the batch's start cursor: a deduping receiver would then drop the grown retry and lose the events added to it. Duplicates beat losses. - The sweep's call site in main.ts claimed a cost it does not pay: with MOCA_NOTIFY_ALLOW unset the pass returns before it reads the owner index. - "When a user leaves" did not mention notification sinks. They are not removed, the two secrets stay, and DELETE /v1/notifications is the owner's own route -- so narrowing the allowlist is the operator's only lever. - The multi-user allowlist paragraph now says it is re-checked on every delivery, which is what makes that lever work. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: cwiklik <[email protected]>
…g the token An ntfy token is stored against the host it was authorized for -- `destination.hosts` on the credential, the binding the credential store exists to enforce and the one `sandbox-egress` keys proxy injection on. But the sender reads the token by NAME only and never compares it with the sink's host, so a re-PUT that moved the sink and omitted `token` kept the stored secret (correct) while attaching it to the new URL: a self-hosted ntfy's token posted to ntfy.sh. Both hosts are operator-allowlisted, but the user authorized the token for one of them. Refused at the PUT with `invalid_request` naming the host to resend for. Chosen over dropping the token, which would silently turn an authenticated topic into a failing one with no field on GET to say which happened, and over filtering at send time, which turns a fixable config error into an hour-long mute. The check runs before every write, so a refusal cannot leave the webhook signing key rotated to a value the 400 never returned. Webhook sinks need no equivalent: their key is reminted and rebound on every PUT. Reported by clawgenti on rossoctl#998. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: cwiklik <[email protected]>
`deliver` was all-or-nothing, and `sendWebhook` returns false without a request when the signing key is gone -- the `secretMissing` state an external credential delete or a half-written PUT leaves. So the ntfy sink that DOES reach the phone was re-pushed the same batch on every pass until `failMax` muted the subject for an hour: a config error no retry could fix, charged to the working sink. A webhook with no key is now excluded from the verdict rather than failing it, so the other sink delivers and the cursor advances. Holding the cursor bought the broken sink nothing anyway: a re-PUT mints a fresh key and resets the cursor to now, discarding the backlog either way. `secretMissing` on GET stays the signal, and `every()` is guarded against the empty list, which would have reported success and dropped the batch silently. Narrower than the per-sink cursors the `shortcut:` offered, and the shortcut's stated trigger was wrong: this bit with exactly one webhook plus one ntfy, the documented common case, not with two sinks of one kind. Reworded to the case that remains -- one sink's TRANSPORT failure re-pushing to the other. Reported by clawgenti on rossoctl#998. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: cwiklik <[email protected]>
clawgenti
left a comment
There was a problem hiding this comment.
Reviewed e8bdbe3 (20 commits, all DCO-signed), with the increment since the last marker (0dd30c0) read commit by commit. The three fixes in 422411bc are the right ones: clipping inside renderNotification fixes both sinks at once where they share the text, lost now names itself instead of falling through to a green tick, and the send-time allowlist re-check is the only lever that can work when no admin route may edit another subject's sinks. The follow-up doc commit states the dedupe window and the re-check accurately.
Must-fix
- The ntfy token still follows the sink to a host it was never stored for — re-raised from the
0dd30c0review, unchanged at this head.readNotifySecrets(notify-handlers.ts:44) returns the stored bearer by NAME only, andsendNtfyattaches it to whateversink.urlthe current config holds. APUTthat keeps the ntfy sink but moves it to another allowlisted host without resendingtokensends host A's token to host B, while the credential'sdestination.hostsstill names host A (notify-handlers.ts:112-129). The new send-time check narrows the set of hosts that can receive it; it does not compare the secret's own binding with the URL it is about to travel to. Inline, with the fix.
Suggestions
-
A webhook with no signing key still silences the ntfy sink (carried from the previous review).
deliveris all-or-nothing andsendWebhookreturnsfalsewithout a request when the key is absent, so the sink that would reach the phone is re-sent the batch every pass and then muted. This is exactly the half-written-PUT caseGET /v1/notificationsreports assecretMissing; skipping the keyless sink instead of failing the batch would keep the push alive. -
lostis not inDEFAULT_NOTIFY_STATES. The defaults arepaused, failed, so a turn nobody picked up pages nobody unless the owner opted intolost. The new comment atnotify-config.ts:209says alostevent "would reach the phone under a green tick", which is true only for an owner who asked forlost. Given the event means work that silently never ran, addinglostto the defaults looks closer to the intent than leaving it opt-in.
Nits
- The new doc sentence stops one step short.
multi-user.md:243(and the matchingusers-and-roles.mdrow) says taking a host out of the allowlist "stops the sinks already saved under it" — right, but it does not say what the owner then sees: the delivery counts as a failure, the cursor holds, and afterfailMaxthey are muted until they re-PUTto a host still on the list. That is the part an operator will be asked about.
Author: cwiklik (CONTRIBUTOR — returning external)
Areas reviewed: TypeScript (control-plane notify path), tests, OpenAPI + operator docs
Agent/IDE config (.claude/.vscode): none in the diff
Commits: 20 commits, all signed-off: yes
CI status: running on this head — DCO, check, hadolint and Trivy pass; the rest were pending when this review was written
Verified by: static review of the increment. The host-move probe quoted in the 0dd30c0 review was not re-run here (this program does not execute PR code); the path it exercised — readNotifySecrets → deliver → sendNtfy — is unchanged between 0dd30c0 and e8bdbe3, which is why the finding stands.
Generated by RepoMan github-pr-review@235a7f7 (https://github.com/rossoctl/agent-skills/blob/235a7f7620139ee3e4ab0872b8439591fe52e8c1/skills/github-pr-review/SKILL.md).
| // while it was in, and there is no route an admin can use to edit another subject's config. A | ||
| // now-disallowed sink counts as a failed delivery rather than a silent skip -- the cursor holds and | ||
| // `failures`/`mutedUntil` on GET /v1/notifications is what tells the subject to re-PUT. | ||
| const allowed = cfg.sinks.every((s) => allowsUrl(s.url, deps.config.notify.allow)); |
There was a problem hiding this comment.
must-fix — this re-check covers the operator's allowlist, but not the secret's own destination, so a kept ntfy token still travels to a host it was never stored for.
Evidence at this head: readNotifySecrets (notify-handlers.ts:44-56) returns push.secret.token by name only; the descriptor written at PUT records destination.hosts = the ntfy sink's host at that moment (notify-handlers.ts:112-129); sendNtfy sets authorization: Bearer <token> on sink.url (notify-send.ts:113) without comparing the two. So a re-PUT that keeps the ntfy sink but moves it from ntfy.example.com to another allowlisted host, without resending token, sends host A's token to host B while the credential still says host A. The 0dd30c0 review reproduced this; the path is unchanged here, and the new check only shrinks the set of hosts that can receive it.
Suggested fix: read the descriptor alongside the secret — return destination.hosts from readNotifySecrets — and in this loop treat an ntfy sink whose host is not among them as a failed delivery (same failures path, so the cursor holds and GET /v1/notifications says why). Alternatively, at PUT, drop a kept token when the ntfy sink's host differs from the stored credential's destinations, so "omitting the token leaves it in place" only ever means "for the host it was stored for". Either way the invariant is worth stating in the openapi PUT description, which currently says only that omitting token leaves the previous one in place.
There was a problem hiding this comment.
This is the same finding as the one on notify-handlers.ts, and it was already fixed when this review was written: the marker here is e8bdbe3, and the fix landed in 9ecc8bd7. You are right that the send-time allowlist re-check was never meant to carry this — it answers a different finding (the operator taking a host back out of MOCA_NOTIFY_ALLOW).
I took your "alternatively, at PUT" branch, in a stricter form: rather than dropping a kept token when the hosts differ, the PUT is refused (invalid_request, notify-handlers.ts:99-109). Dropping it needs an ntfy analogue of secretMissing to be anything but silent, which is the objection your other comment raises itself.
I did not take the first branch — returning destination.hosts from readNotifySecrets and failing the delivery in the sweep — because it turns a fixable config error into an hour-long mute after failMax passes, and the subject's only clue would be failures climbing. Refusing at the PUT means the mismatch cannot be stored in the first place, so the sweep has no case to handle.
The invariant is now in the putNotifications description in openapi.yaml, as you asked, plus the API CHANGELOG and multi-user.md §7.
| // `lost` counts as a failure: the reaper writes it for a turn nobody ever picked up, and it | ||
| // carries no `reason` (turn-store.ts:647), so without this it would reach the phone under a green | ||
| // tick and the generic "N updates" line -- work that silently never ran, reported as finished. | ||
| const failed = events.find((e) => e.state === 'failed' || e.state === 'lost'); |
There was a problem hiding this comment.
suggestion — the fix is right, but it reaches fewer phones than the comment implies: renderNotification only ever sees matching, and DEFAULT_NOTIFY_STATES is ['paused', 'failed'] (notify-config.ts:22), so a lost event is rendered only for an owner who explicitly listed lost in states. Consider adding lost to the defaults — "the reaper writes it for a turn nobody ever picked up" is the one case an away owner most needs paged about.
There was a problem hiding this comment.
Agreed and done in ed05797a: DEFAULT_NOTIFY_STATES is now ['paused', 'failed', 'lost'] (notify-config.ts:29).
You put the reason better than my original comment did, so I wrote it into the code: lost is the one state that leaves no other trace — no result, no reason, nothing in the session to find later — so left opt-in, the owner most in need of paging (one whose deployment is not draining the queue at all) is the one who hears nothing.
Followed through the rest: three test assertions, the NotifyStates schema in openapi.yaml, the API CHANGELOG, and the curl example in multi-user.md §7. queued and running are still rejected outright.
| URL reaching your instance metadata service, Redis, or the kube API from inside the control plane. | ||
| A malformed entry refuses to boot, the same contract `SH_MODEL_CATALOG_HOSTS` has. It is re-checked | ||
| on every delivery, not only at the `PUT` that stores a sink, so taking a host back out of the list | ||
| also stops the sinks already saved under it. |
There was a problem hiding this comment.
nit — this says the lever exists but not what it looks like from the owner's side. A sink saved under a host that is later removed from MOCA_NOTIFY_ALLOW counts as a failed delivery (notify-sweep.ts:109-137), so the cursor holds and after failMax consecutive passes the owner is muted; the only way back is a re-PUT naming a host still on the list. Worth one clause here and in the matching users-and-roles.md row, since that is the question an operator will get.
There was a problem hiding this comment.
Done here in ed05797a (multi-user.md:245-248): each pass counts as a failed delivery, so the cursor stops advancing and after MOCA_NOTIFY_FAIL_MAX passes the owner is muted for an hour; failures and mutedUntil on GET /v1/notifications say so, and the way back is a re-PUT naming a host still on the list.
For the matching users-and-roles.md row I wrote a different clause instead of this one. That row is about a user who has left, and a departed subject is not reading GET /v1/notifications — the mute mechanics are not the question an operator asks there. What they do need is that the lever is deployment-wide: taking the host out of MOCA_NOTIFY_ALLOW to stop one leaver's sink also stops every remaining user with a sink on that host, who is then muted until they re-PUT. That is what the row now says (users-and-roles.md:141).
…wlist looks like `lost` was allowed but not a default, so the rendering fix in 422411b only reached an owner who had explicitly listed it. That is backwards: the reaper writes `lost` for a turn nobody ever picked up, which is the one state that leaves NO other trace -- no result, no reason, nothing in the session to find later. Left opt-in, the owner most in need of paging (one whose deployment is not draining the queue at all) is the one who hears nothing. Now `[paused, failed, lost]`. Also answers the question an operator will actually be asked about the send-time allowlist check: narrowing MOCA_NOTIFY_ALLOW counts each pass as a failed delivery, so the cursor holds and the owner is muted after MOCA_NOTIFY_FAIL_MAX until they re-PUT to a listed host -- and the lever is deployment-wide, so every other user on that host stops being notified too. Reported by clawgenti on rossoctl#998. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: cwiklik <[email protected]>
clawgenti
left a comment
There was a problem hiding this comment.
Reviewed ed05797a (29 files, +2500/−11), with the increment since the last marker (e8bdbe3) read commit by commit rather than taken from the commit messages. All three findings from the earlier passes are now addressed, and I re-proved each at this head:
- Must-fix — the ntfy token followed a moved sink.
putNotificationsnow refuses a re-PUT that points the sink at a different host without resendingtoken, and it does so before every write, so a 400 cannot leave the caller holding a rotated webhook key (notify-handlers.ts:89-108). Disabling the guard makes exactly the test that names it fail. - Suggestion — a keyless webhook starved the working sink.
delivernow drops a webhook that can never be sent to from the verdict, and returns failure only when nothing at all could be sent (notify-send.ts:139-152); the two tests pin both halves. - Suggestion —
lostwas not a default. It is now inDEFAULT_NOTIFY_STATES, withrenderNotification's "counts as a failure" comment pointing at that, and the CHANGELOG, OpenAPI and operator docs updated to match. I checked the ordering: NOTIFY_STATES derives from TURN_STATES, so the default array is still in canonical order.
No must-fix and no inline comments this pass.
One boundary worth recording, since the fix is about where a token may travel: the refusal is HOST-level, not host:port. credential-store.ts's validateHost forbids a :port in destination.hosts for every non-egress consumer, so the binding cannot express a port; allowsUrl is port-aware on its own side. I probed it (throwaway test, deleted): a re-PUT from https://ntfy.example.com to https://ntfy.example.com:8443, both allowlisted, is accepted and keeps the token. That is the credential schema's limit rather than this code's, and the operator docs say HOST, so I am not asking for a change -- noting it so nobody later reads the fix as a port-level guarantee.
Author: cwiklik (CONTRIBUTOR — returning external)
Areas reviewed: TypeScript (control-plane notify handlers, send, sweep, config), tests, OpenAPI + CHANGELOG + operator docs
Agent/IDE config (.claude/.vscode): none in the diff
Commits: 23 commits, all signed-off: yes
CI status: passing — 18/18 checks green on ed05797a
Verified by: notify suites 64/64 at this head; the full control-plane suite against a local Redis — 2194 passed / 4 skipped; tsc --noEmit and prettier --check clean; two mutations each caught by the test meant to pin it (disabling the host-move refusal → refuses a re-PUT that MOVES the ntfy sink without resending the token; dropping the sendable filter → a webhook with no signing key does not hold the batch back from the ntfy sink); and one throwaway probe of the same-host/other-port re-PUT described above, deleted afterwards.
Generated by RepoMan github-pr-review@235a7f7 (https://github.com/rossoctl/agent-skills/blob/235a7f7620139ee3e4ab0872b8439591fe52e8c1/skills/github-pr-review/SKILL.md).
ingpaolodettori-dev
left a comment
There was a problem hiding this comment.
Re-review at ed05797a (one commit since the 11db0991 draft). lost is now in DEFAULT_NOTIFY_STATES (notify-config.ts:29), so a turn the reaper marks lost — the one terminal state that leaves no result and no reason behind — pages the owner who never chose a states list. That closes the lost-opt-in gap clawgenti raised at 11db0991, and the OpenAPI/CHANGELOG/operator docs and the GET/PUT response-shape tests were updated with it. The increment is otherwise docs+tests; the 22 earlier commits are unchanged from the 11db0991 draft, where the PUT host-move refusal (9ecc8bd7) and the keyless-webhook sendable filter (11db0991) close the blockers from the 0dd30c01 review with no half-applied write on refusal. The four remaining comments are carried forward unchanged and none blocks merge: two narrow, non-blocking windows in the ntfy token↔host binding and around a disallowed co-sink, and two documentation/UX nits.
Our earlier drafts at e8bdbe3d and 11db0991 were never posted (this pipeline drafts first and posts only on the owner's explicit go-ahead), so this review supersedes them.
Author: cwiklik (MEMBER — maintainer)
Areas reviewed: TypeScript (control-plane), OpenAPI + docs, deploy env wiring (compose / k8s / vm), tests
Agent/IDE config (.claude/.vscode): none in the diff
Commits: 23 commits, all signed-off: yes
CI status: 15 pass / 3 pending (check, deploy-scripts, k8s-kind-e2e)
Known gaps, deliberate per the PR body: the approve deep link 404s until the login-gated approval page lands (B8b, so #394 is not closed here); no live deploy/compose run (the 30 s delivery bound is covered by an injected-clock test); the sweep assumes replicas: 1, named in a shortcut: comment, with self-overlap guarded.
| summary: renderNotification(matching, deps.config.notify.baseUrl), | ||
| events: matching, | ||
| }, | ||
| await readNotifySecrets(deps, subject), |
There was a problem hiding this comment.
suggestion — the sender still trusts the token's name, not its destination.
The PUT refusal closes the move-without-token path, but readNotifySecrets returns the ntfy token by name only and sendNtfy attaches it to whatever sink.url the config now holds (notify-send.ts:113) — the credential's destination.hosts is never compared with the sink's host. Two residual ways to cross that binding:
- A PUT that does resend
tokenfor host B writes the credential atnotify-handlers.ts:133-148, thennotify.putthrows (a Redis 503). The old config still points at host A, and the next 10 s sweep posts B's token to A. - A hand-edited or schema-skewed
sinkshash can point an allowlisted host at a token stored for another host — the same reason the allowlist is re-checked at send time rather than trusted from Redis.
clawgenti's reproduced move-without-token exploit is now refused at PUT, so this is defense in depth, not a blocker. A narrow fix: return destination.hosts alongside the secret from readNotifySecrets and treat an ntfy sink whose host is not among them as a failed delivery (the existing failures path, so the cursor holds and GET says why).
There was a problem hiding this comment.
Taken, in c9df453f. readNotifySecrets now returns ntfyHosts — the credential's destination.hosts — alongside the token, from the same get, and deliver drops an ntfy sink whose host is not among them (notify-send.ts:128-146).
I put it in deliver rather than the sweep so there is one rule for both cases rather than two: a sink this process must not post to is excluded before the verdict, and nothing sendable is still a failure. So a token/host disagreement is skipped while the webhook co-sink keeps working, and an ntfy-only config holds the cursor and climbs failures exactly as your suggestion intended.
Three details I decided rather than inherited:
- Not sent anonymously instead. Dropping the
authorizationheader would publish to a topic the subject chose to protect, and the PUT refuses that for the same reason. - Fail-closed on a missing binding. A token with no
ntfyHostsis treated as bound to nothing, not to everything. The two always travel together out ofreadNotifySecrets, so this only bites a caller that constructs the pair by hand — which is why the test fixtures now carry both, as production does. - An anonymous topic has no binding to cross, so the common self-hosted case is untouched. Asserted in the new test, along with your case 1 (the torn PUT) and the ntfy-only failure.
Both residual paths you name are now closed at the sender. Thank you for pushing on this after the PUT refusal landed — the asymmetry you identified is what made the first bug possible, and it was the right thing to fix at the root.
| // while it was in, and there is no route an admin can use to edit another subject's config. A | ||
| // now-disallowed sink counts as a failed delivery rather than a silent skip -- the cursor holds and | ||
| // `failures`/`mutedUntil` on GET /v1/notifications is what tells the subject to re-PUT. | ||
| const allowed = cfg.sinks.every((s) => allowsUrl(s.url, deps.config.notify.allow)); |
There was a problem hiding this comment.
suggestion — one off-allowlist sink still silences the allowed co-sink.
allowed is every(), so a sink whose host has been taken out of MOCA_NOTIFY_ALLOW sets sentOk = false before deliver runs and the still-allowed co-sink receives nothing; the cursor holds and, after failMax, the subject is muted with only failures/mutedUntil on GET to explain it.
That is the same permanent, retry-cannot-fix-it failure the new sendable filter in deliver now excludes for a webhook with no key (notify-send.ts:142-150) — "no retry can mint a key … holding it buys it nothing" applies here verbatim: no retry can re-add the host to the allowlist. Consider filtering disallowed sinks out and delivering to the rest (still a failure if none remain), so a valid sink keeps working while the operator's change is surfaced the same way.
There was a problem hiding this comment.
You are right, and the "holding it buys it nothing" argument does apply verbatim. Fixed in c9df453f: the sweep filters the sinks by the allowlist instead of every()-ing over them, delivers to what is left, and fails only when nothing is (notify-sweep.ts:104-118).
What decided it: the sink being starved is the owner's phone, and neither party can fix the removed host from where they are — the subject cannot re-add it, and the operator who removed it did so deliberately. Muting the subject was punishing the wrong sink.
One consequence I chose rather than avoided, written into the comment and the docs: a subject left with a working co-sink is now told nothing. GET does not expose the allowlist and there is no secretMissing analogue for "your other sink's host is gone", so the only signal would have been the mute I just removed. I did not add a field for it — that is API surface for a state only the operator can create and only the operator can undo, and they are the one who knows they did it. A subject whose only sink is on the removed host still sees failures/mutedUntil, which is the case the operator docs describe.
Followed through where the old behaviour was documented: multi-user.md §7, the users-and-roles.md leaver row (with the sharper warning that the lever therefore does not stop a leaver who has a sink on another listed host), and the API CHANGELOG. New sweep test pins the co-sink case; the existing single-sink test still pins the failure.
| if (stored && !stored.descriptor.destination.hosts.includes(host)) { | ||
| throw new CpError( | ||
| 'invalid_request', | ||
| `this subject's ntfy token was authorized for another host; resend 'token' for '${host}'`, |
There was a problem hiding this comment.
nit — the message covers the authenticated mover ("resend 'token'") but not the other case this branch now catches. A subject who wants the sink on the new host anonymously cannot get there by omitting token: the stored one is kept, the host check refuses, and "resend token" is the opposite of what they want. They must DELETE /v1/notifications first. One clause here — and in the matching sentence in docs/operate/harness/multi-user.md (around line 271) — saves that round trip; the docs already say DELETE clears both secrets.
There was a problem hiding this comment.
Good catch — omitting token is this very branch, so "resend it" was the one instruction that cannot get an anonymous mover where they want to go. Fixed in c9df453f; the message now reads:
this subject's ntfy token was authorized for another host; resend 'token' for '', or DELETE /v1/notifications first to move the sink without one
Clause added in multi-user.md too, phrased to say why DELETE is needed rather than just that it is: omitting token keeps the stored one rather than clearing it, so it is the refusal and not a way to drop it. Also in the putNotifications description in openapi.yaml and the API CHANGELOG, since the 400 is documented in both.
| #MOCA_NOTIFY_BASE_URL= | ||
| # Per-subject rate limits: the floor between two deliveries, the cap per fixed hour window (over | ||
| # it, the subject is muted for the rest of the window), and the number of CONSECUTIVE failed deliveries | ||
| # that mutes a subject for an hour. Re-PUT the config to un-mute. |
There was a problem hiding this comment.
nit — "Re-PUT the config to un-mute" omits that every webhook PUT mints a fresh signing key (notify-handlers.ts:113; the multi-user doc already says a later PUT rotates it). The caller does get the new webhookSecret in the PUT response, but must install it at the receiver: verifying with the old key rejects every delivery, so the un-mute immediately re-fails and re-mutes after failMax. The new multi-user passage at multi-user.md:245-248 explains the allowlist-mute path but stops short of this; add the caveat here and in that passage.
There was a problem hiding this comment.
Right, and the way it fails is the bad part: the un-mute appears to work, then every delivery fails verification at the receiver and failMax mutes the subject again — looking exactly like the problem they thought they had just fixed. Fixed in c9df453f:
- here (
control-plane.env.example:109-111): "Re-PUT the config to un-mute -- a PUT with a webhook sink mints a FRESH signing key, returned once in that response, so the receiver has to be given it or every delivery fails verification and the subject is muted again." multi-user.md:245-253, on the allowlist-mute path, where the re-PUTis named as the way back.
MOCA_NOTIFY_FAIL_MAX is the only place the phrase appeared, so there is no third copy to keep in step.
…e dead sink starving the other `deliver` now refuses to attach an ntfy token to any host outside the `destination.hosts` it was stored with, read from the same credential as the secret. The PUT already refuses to STORE that mismatch, so reaching this state means something stepped around it -- a torn PUT whose credential write landed and whose config write did not, or a hand-edited hash, the same reason the allowlist is re-checked at send time rather than trusted from Redis. The sink is dropped, never posted to the other host and never sent anonymously instead, which would un-authenticate a topic the subject chose to protect. A sink whose host has left `MOCA_NOTIFY_ALLOW` is dropped for the same reason `deliver` drops a webhook with no signing key: no retry re-adds a host to the operator's allowlist, so failing the whole delivery held the cursor and starved the still-allowed co-sink -- the owner's phone -- until `failMax` muted them over a sink neither side can fix from there. With no allowed sink left it is still a failure, which is the single-sink case the operator docs describe. Two message and doc gaps with it: the PUT refusal now names DELETE as the way to move a sink anonymously (omitting `token` keeps the old one, so it is the refusal and not a way to drop it), and "re-PUT to un-mute" now says that a webhook PUT mints a fresh signing key the receiver has to be given, or every delivery fails verification and the subject is muted again. Reported by ingpaolodettori-dev on rossoctl#998. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: cwiklik <[email protected]>
Push notifications for paused and finished subagents — epic #378 child B8.
An owner registers a webhook and/or an ntfy sink once; a sweep in the control plane turns their
turn events into deliveries, so a paused gate or a finished turn reaches them without a poll.
What's here
GET/PUT/DELETE /v1/notifications— per-owner sink config. The webhook signing key isreturned once, at
PUT, and never byGET; both secrets live in the existing credentialstore (consumer
control-plane), never in Redis.x-moca-signature: sha256=<hex>over`${timestamp}.${rawBody}`with
x-moca-deliveryandx-moca-timestamp, plus ntfy JSON publish with an optional bearer.setInterval(unrefed, modelled onstartGateSweep)reads each owner's events from a stored cursor and advances the cursor only on delivery
success, except the two dropped-batch paths — a batch holding no state the subject asked for,
and a batch past the hourly cap, both
shortcut:-documented innotify-sweep.ts. So a failure isthe retry. Coalesces a batch into one notification; rate-limited by
minIntervalS/perHour,muted after
failMaxconsecutive failures.MOCA_NOTIFY_ALLOWis parsed at boot by the existingparseDestinationand matched segment-aware, so an unlisted host is never fetched. The fetchpasses
redirect: 'error': undici follows redirects by default, which would have let anallowlisted sink
302the control plane at the metadata service.MOCA_NOTIFY_BASE_URL. No bearertoken in the URL, by design.
docs/api/openapi.yamlanddocs/api/CHANGELOG.mdat 1.38.0.Also fixed in passing:
gate-sweep.tshad the same unhandled-rejection shape as the new sweep(
void sweepGates(...)with no.catch), which on Node 22 terminates the process — a Redis bliprestarted the control plane on the 30 s tick. Both call sites now catch and log (901fea7).
Known gaps, deliberate
"approving through the link, after login, resumes it" criterion belongs to that follow-up, so
this does not close Coding-agent subagents B8: notifications for paused and finished subagents #394.
docs/operate/harness/multi-user.mdand the API docs say so.deploy/composerun — no Docker daemon on this machine. The 30 s delivery bound iscovered by an injected-clock test instead. Unverified end to end: a real TLS handshake to a sink,
a real ntfy server accepting this exact body, and
MOCA_NOTIFY_ALLOWthrough the compose/k8s/vmenv plumbing.
replicas: 1(as every deploy target sets) rather than taking a per-ownerlock; a
shortcut:comment names the limit. Self-overlap of one slow pass is guarded(f1808dd).
Verification
Control-plane suite 2188 passed / 4 skipped;
make typecheckandmake check-linksclean;make lintclean except thehadolint-dockerhook, which needs a Docker daemon. Rebased onto4e1943acand re-verified there.No new dependencies.
Assisted-By: Claude Code