fix(forge): consume a decided account notification
android / debug (pull_request) Successful in 2m14s
android / release (pull_request) Skipped
ci / test (pull_request) Failing after 33s
ci / chart (pull_request) Successful in 4s
ci / docker (pull_request) Successful in 1m29s
ci / checks (pull_request) Successful in 1m3s
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
android / debug (pull_request) Successful in 2m14s
android / release (pull_request) Skipped
ci / test (pull_request) Failing after 33s
ci / chart (pull_request) Successful in 4s
ci / docker (pull_request) Successful in 1m29s
ci / checks (pull_request) Successful in 1m3s
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
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.
This commit is contained in:
1 parent
c65f7fe962
commit
e07499f0b7
9 files changed
+237
-3
No files matched your search
@@ -16,7 +16,9 @@
|
||||
use async_trait::async_trait;
|
||||
|
||||
use crate::error::ForgeError;
|
||||
use crate::event::{ForgeEvent, ForgeThreadKind, NotificationPage, RepoRef, Snapshot, Timestamp};
|
||||
use crate::event::{
|
||||
ForgeEvent, ForgeThreadKind, Notification, NotificationPage, RepoRef, Snapshot, Timestamp,
|
||||
};
|
||||
|
||||
/// One poll's worth of activity, with the cursor to continue from.
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
@@ -100,6 +102,25 @@ pub trait Forge: Send + Sync {
|
||||
since: Option<&Timestamp>,
|
||||
) -> Result<NotificationPage, ForgeError>;
|
||||
|
||||
/// Marks `notification` read on the forge, so the account's feed
|
||||
/// stops returning it.
|
||||
///
|
||||
/// The feed is at-least-once: `since` is inclusive at the boundary
|
||||
/// and the cursor only ever advances to the newest row seen, so a row
|
||||
/// that the poll cannot get past — anything at or before the cursor,
|
||||
/// every poll — comes back for as long as the forge considers it
|
||||
/// unread. Dedup ids absorb a repeat *within* one pass, but a row
|
||||
/// re-read on the next pass is a fresh event with the same id, and a
|
||||
/// restart drops the in-memory cursor entirely and asks for the whole
|
||||
/// unread feed again. Deciding a row is therefore not the same as
|
||||
/// consuming it; this is the call that consumes it.
|
||||
///
|
||||
/// The default is a no-op: a backend with no read route repeats its
|
||||
/// rows, which its dedup ids absorb — noisier, never wrong.
|
||||
async fn mark_read(&self, _notification: &Notification) -> Result<(), ForgeError> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// The login this client authenticates as — the backend's own answer
|
||||
/// to "who am I".
|
||||
///
|
||||
|
||||
Reference in new issue
Block a user