fix(forge): consume a decided account notification #6

Merged
vhaudiquet merged 1 commits from kosmos/rhema-claw:fix/notification-mark-read into main 2026-11-22 01:34:12 +00:00
Collaborator

The account watch re-dispatches the same notification on every poll. Nothing ever marks a row read, and the dedup ids do not cover the repeat.

The loop

  • GitHub's since is inclusive at the boundary, and NotificationPage::finish advances its cursor only to the newest row seen. A row at or before the cursor is returned again on the next poll — and since the row stays unread, the cursor never passes it. That is every poll, forever.
  • A repeated row decoded on a later pass is a fresh Event with the same id. RSD dedups against its pending inbox, not against history, so a pass re-feeds it and a second turn is dispatched for a thread that already has one.
  • The cursor map (account_cursors) is in memory, so a restart asks for the whole unread feed again.

Observed live: github:issue:vhaudiquet/orcaslicer-snap#10 went revision: 1 → 2 at the 00:35 poll with inbox_depth: 0 and last_outcome: null — a re-dispatch of a turn that was already running, not a new event. The thread is still unread on the bot's feed right now (GET /notifications?since=2026-11-21T22:33:00Z returns it).

The dedup comment on NotificationPage::finish ("boundary rows repeat, ids dedup them") describes an intent the daemon never implemented.

The change

Consume what the poll decides, which is the shape you asked for:

  • Forge::mark_read — a new trait method with a default no-op, implemented for GitHub as PUT /notifications/threads/{id}.
  • Notification::read_key — what that route keys on. GitHub keys on the notification id, while Notification::id carries it only as text (the suffix is the dedup timestamp); None on a backend with no read route. #[serde(default)], so a payload already sitting in an inbox still decodes after this deploys.
  • poll_account marks each row read once triage has decided it — dispatched, surfaced, or ignored, since the decision is durable and re-deciding an ignored row every minute is pure noise. Best-effort: an unread row costs a repeat, never a lost event, so a failed call logs and the poll carries on. A row that fails to ingest is not marked read — nothing was decided.

Why mark read rather than only advance the cursor to the poll instant: the cursor fix dies with the process (it is in memory), and the bot's unread feed grows forever. Marking read fixes the restart replay too, and it is what the forge's own model means by "decided".

Note the account is kosmos-ai-bot, so this clears the bot's unread state, not yours.

Gitea has an equivalent route (PATCH /notifications/threads/{id}) and GitLab has none; both keep the no-op, since neither has an account watch here yet.

Tests

  • marking_a_notification_read_puts_its_thread — mock server: poll, then mark, then assert exactly one PUT /notifications/threads/42188 with the bearer header; also pins that the route keys on the notification id and not the thread number.
  • a_notification_without_a_read_key_fails_loudly — a row with no read key is a Parse error, not a silent no-op that would re-read the thread forever. It also proves the serde(default) path an old inbox row takes.
  • a_triaged_account_notification_is_marked_read — the daemon end: an account watch over a mock feed, one mention, one dispatch, one read call.
  • Both notification-decoding unit tests now also assert read_key.

bin/gate.sh is green (fmt, clippy -D warnings, check — all targets). This box cannot execute test binaries, so CI runs the tests first.

The account watch re-dispatches the same notification on every poll. Nothing ever marks a row read, and the dedup ids do not cover the repeat. ## The loop - GitHub's `since` is inclusive at the boundary, and `NotificationPage::finish` advances its cursor only to the newest row seen. A row at or before the cursor is returned again on the next poll — and since the row stays unread, the cursor never passes it. That is every poll, forever. - A repeated row decoded on a later pass is a fresh `Event` with the same id. RSD dedups against its *pending inbox*, not against history, so a pass re-feeds it and a second turn is dispatched for a thread that already has one. - The cursor map (`account_cursors`) is in memory, so a restart asks for the whole unread feed again. Observed live: `github:issue:vhaudiquet/orcaslicer-snap#10` went `revision: 1 → 2` at the 00:35 poll with `inbox_depth: 0` and `last_outcome: null` — a re-dispatch of a turn that was already running, not a new event. The thread is still unread on the bot's feed right now (`GET /notifications?since=2026-11-21T22:33:00Z` returns it). The dedup comment on `NotificationPage::finish` ("boundary rows repeat, ids dedup them") describes an intent the daemon never implemented. ## The change Consume what the poll decides, which is the shape you asked for: - **`Forge::mark_read`** — a new trait method with a default no-op, implemented for GitHub as `PUT /notifications/threads/{id}`. - **`Notification::read_key`** — what that route keys on. GitHub keys on the notification id, while `Notification::id` carries it only as text (the suffix is the dedup timestamp); `None` on a backend with no read route. `#[serde(default)]`, so a payload already sitting in an inbox still decodes after this deploys. - **`poll_account`** marks each row read once triage has decided it — dispatched, surfaced, or ignored, since the decision is durable and re-deciding an ignored row every minute is pure noise. Best-effort: an unread row costs a repeat, never a lost event, so a failed call logs and the poll carries on. A row that fails to *ingest* is not marked read — nothing was decided. Why mark read rather than only advance the cursor to the poll instant: the cursor fix dies with the process (it is in memory), and the bot's unread feed grows forever. Marking read fixes the restart replay too, and it is what the forge's own model means by "decided". Note the account is `kosmos-ai-bot`, so this clears the bot's unread state, not yours. Gitea has an equivalent route (`PATCH /notifications/threads/{id}`) and GitLab has none; both keep the no-op, since neither has an account watch here yet. ## Tests - `marking_a_notification_read_puts_its_thread` — mock server: poll, then mark, then assert exactly one `PUT /notifications/threads/42188` with the bearer header; also pins that the route keys on the notification id and not the thread number. - `a_notification_without_a_read_key_fails_loudly` — a row with no read key is a `Parse` error, not a silent no-op that would re-read the thread forever. It also proves the `serde(default)` path an old inbox row takes. - `a_triaged_account_notification_is_marked_read` — the daemon end: an account watch over a mock feed, one mention, one dispatch, one read call. - Both notification-decoding unit tests now also assert `read_key`. `bin/gate.sh` is green (fmt, clippy `-D warnings`, check — all targets). This box cannot execute test binaries, so CI runs the tests first.
kosmos force-pushed fix/notification-mark-read from e07499f0b7 to b114049591 2026-11-22 01:09:26 +00:00 Compare
kosmos added 1 commit 2026-11-22 01:14:55 +00:00
fix(forge): consume a decided account notification
android / release (pull_request) Skipped
android / debug (pull_request) Successful in 4m10s
ci / checks (pull_request) Successful in 1m3s
ci / test (pull_request) Successful in 40s
ci / chart (pull_request) Successful in 5s
ci / docker (pull_request) Successful in 1m30s
ci / web (pull_request) Successful in 13s
ci / publish-edge-images (deploy/docker/claw.Dockerfile, rhema-claw) (pull_request) Skipped
ci / publish-edge-images (deploy/docker/ui.Dockerfile, rhema-claw-ui) (pull_request) Skipped
ci / publish-edge-chart (pull_request) Skipped
9267534799
The account feed is at-least-once in a way the dedup ids do not cover.
`since` is inclusive at the boundary and `NotificationPage::finish`
advances its cursor only to the newest row seen, so a row the poll cannot
get past — anything at or before the cursor, which is every poll — comes
back for as long as the forge still considers it unread. Nothing marked
it read, and the daemon's cursor map is in memory, so a restart asked for
the whole unread feed again.

The result is a re-dispatch loop: the same notification id re-triaged
every pass, a fresh turn for a thread that already has one, and a second
comment on that thread if the first turn ever finished inside its lease.
Observed live on `vhaudiquet/orcaslicer-snap#10`: key revision 1 → 2 at
the 00:35 poll, `inbox_depth: 0`, no outcome — a re-dispatch of a turn
that was already running.

So consume what the poll decides:

- `Forge::mark_read` — a new default no-op on the trait, implemented for
  GitHub as `PUT /notifications/threads/{id}`;
- `Notification::read_key` carries what that route keys on (GitHub keys
  on the notification id, which the dedup id embeds only as text), and
  defaults on deserialize so a payload already in an inbox still decodes;
- `poll_account` marks each row read once it is triaged — dispatched,
  surfaced, or ignored; best-effort, since an unread row costs a repeat
  and never a lost event.

Gitea and GitLab keep the no-op: neither has an account watch here yet.
kosmos force-pushed fix/notification-mark-read from b114049591 to 9267534799 2026-11-22 01:14:55 +00:00 Compare
vhaudiquet merged commit f779415b2b into main 2026-11-22 01:34:12 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: vhaudiquet/rhema-claw#6