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
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
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
9267534799
9 files changed
+235
-3
No files matched your search
@@ -120,6 +120,17 @@ impl GitHubForge {
|
||||
}
|
||||
}
|
||||
|
||||
/// A PUT builder for `path` with auth applied.
|
||||
fn put(&self, path: &str) -> reqwest::RequestBuilder {
|
||||
let base = &self.base_url;
|
||||
let request = self.http.put(format!("{base}{path}"));
|
||||
if self.token.is_empty() {
|
||||
request
|
||||
} else {
|
||||
request.bearer_auth(&self.token)
|
||||
}
|
||||
}
|
||||
|
||||
/// Follows `per_page`/`page` pagination until a short page.
|
||||
async fn paged<T: DeserializeOwned>(
|
||||
&self,
|
||||
@@ -509,6 +520,9 @@ fn notification_event(row: &WireNotification) -> Result<Option<Notification>, Fo
|
||||
title: subject.title.clone(),
|
||||
url: None,
|
||||
timestamp: updated,
|
||||
// `PUT /notifications/threads/{id}` is keyed on this same id:
|
||||
// the notification, not the thread's number.
|
||||
read_key: Some(id.to_string()),
|
||||
raw: Value::Object(row.raw.clone()),
|
||||
}))
|
||||
}
|
||||
@@ -736,6 +750,22 @@ impl Forge for GitHubForge {
|
||||
}
|
||||
Ok(NotificationPage::finish(notifications, since))
|
||||
}
|
||||
|
||||
async fn mark_read(&self, notification: &Notification) -> Result<(), ForgeError> {
|
||||
let Some(read_key) = notification.read_key.as_deref() else {
|
||||
// A row built without one is a shape break, not a forge
|
||||
// outage: say so instead of silently re-reading it forever.
|
||||
return Err(ForgeError::Parse(format!(
|
||||
"notification {} carries no read key",
|
||||
notification.id
|
||||
)));
|
||||
};
|
||||
let path = format!("/notifications/threads/{read_key}");
|
||||
let response = self.put(&path).send().await.map_err(ForgeError::network)?;
|
||||
// 205 Reset Content: marked, nothing to decode.
|
||||
ensure_success(response).await?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -927,6 +957,7 @@ mod tests {
|
||||
notification.id,
|
||||
"github:notification:27210544329@2026-11-21T22:33:00Z"
|
||||
);
|
||||
assert_eq!(notification.read_key.as_deref(), Some("27210544329"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -947,6 +978,7 @@ mod tests {
|
||||
notification.id,
|
||||
"github:notification:42188@2026-10-08T12:00:00Z"
|
||||
);
|
||||
assert_eq!(notification.read_key.as_deref(), Some("42188"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in new issue
Block a user