forked from vhaudiquet/rhema-claw
feat(claw): a mention of the daemon is an ask, not a phone buzz
The notifications feed triaged a GitHub `mention` as `Triage::Surface`:
the human hears about it, no agent runs. That verdict is right for a
consumer that only notifies — a mention of somebody else is not an
assignment — but this daemon is the party named. Somebody typed
`@handle` on a thread and is waiting for an answer, which is the same
ask an assignment is.
The bug that follows is silent: the surface arm never feeds the
dispatcher, so the thread is never dispatched and the mention is never
answered. Nothing looks broken; the phone buzzed.
`claw_triage` keeps the shared vocabulary as the base and upgrades
this one reason, the seam `triage` names for consumers ('classify is
the default, not a mandate'). Every other reason keeps its verdict, so
the co-edit that pinned those tests still holds.
This commit is contained in:
1 parent
6abb1436b5
commit
9c13455f35
1 file changed
+71
-4
@@ -24,10 +24,10 @@ use std::sync::{Arc, Mutex, PoisonError};
|
|||||||
|
|
||||||
use rhema_autonomous_agent::{Source, SourceError, async_trait};
|
use rhema_autonomous_agent::{Source, SourceError, async_trait};
|
||||||
use rhema_forge_integration::forge_key_fn;
|
use rhema_forge_integration::forge_key_fn;
|
||||||
use rhema_forge_integration::triage::{self, Triage};
|
use rhema_forge_integration::triage::{self, Role, Triage};
|
||||||
use rhema_forge_integration::{
|
use rhema_forge_integration::{
|
||||||
Forge, GitHubForge, GitLabForge, GiteaForge, Notification, RepoRef, Timestamp, Watcher,
|
Forge, GitHubForge, GitLabForge, GiteaForge, Notification, NotificationReason, RepoRef,
|
||||||
register_forge,
|
Timestamp, Watcher, register_forge,
|
||||||
};
|
};
|
||||||
use rhema_identity::{IdentityStore, SecretKind};
|
use rhema_identity::{IdentityStore, SecretKind};
|
||||||
use rhema_rsd::{Clock, Dispatcher, Event, KeyFn, SystemClock};
|
use rhema_rsd::{Clock, Dispatcher, Event, KeyFn, SystemClock};
|
||||||
@@ -514,7 +514,7 @@ impl ForgeSource {
|
|||||||
let now = SystemClock.now_millis();
|
let now = SystemClock.now_millis();
|
||||||
let mut fed = 0;
|
let mut fed = 0;
|
||||||
for notification in &page.notifications {
|
for notification in &page.notifications {
|
||||||
match triage::classify(notification) {
|
match claw_triage(notification) {
|
||||||
Triage::Ignore => {}
|
Triage::Ignore => {}
|
||||||
Triage::Surface => {
|
Triage::Surface => {
|
||||||
if let Err(err) = self.notifications.push(
|
if let Err(err) = self.notifications.push(
|
||||||
@@ -576,6 +576,24 @@ impl ForgeSource {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// [`triage::classify`], plus the one reclassification a resident agent
|
||||||
|
/// owes its own name: an @-mention of the daemon is an ask.
|
||||||
|
///
|
||||||
|
/// The shared vocabulary reads a mention as [`Triage::Surface`] — right
|
||||||
|
/// for a consumer that only notifies its human, since a mention is not an
|
||||||
|
/// assignment. This daemon is the party named: somebody typed `@handle` on
|
||||||
|
/// a thread and is waiting for an answer, which is the same ask an
|
||||||
|
/// assignment is. Left as a surface, a mention would be a phone buzz and
|
||||||
|
/// nothing else — this loop never dispatches for a surface, so the turn
|
||||||
|
/// that reads the thread would never run and the mention would go
|
||||||
|
/// unanswered.
|
||||||
|
fn claw_triage(notification: &Notification) -> Triage {
|
||||||
|
match ¬ification.reason {
|
||||||
|
NotificationReason::Mention => Triage::Agent(Role::Implementer),
|
||||||
|
_ => triage::classify(notification),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// The device-notification text a [`Triage::Surface`] lands: the reason
|
/// The device-notification text a [`Triage::Surface`] lands: the reason
|
||||||
/// and the thread title, so the human can judge without opening the
|
/// and the thread title, so the human can judge without opening the
|
||||||
/// forge.
|
/// forge.
|
||||||
@@ -985,4 +1003,53 @@ mod tests {
|
|||||||
});
|
});
|
||||||
assert_eq!(key.as_str(), "github:issue:acme/widgets#142");
|
assert_eq!(key.as_str(), "github:issue:acme/widgets#142");
|
||||||
}
|
}
|
||||||
|
/// The notification fixture the reclassification tests classify: one
|
||||||
|
/// plain issue thread, the reason the only thing that varies.
|
||||||
|
fn triaged_notification(reason: NotificationReason) -> Notification {
|
||||||
|
Notification {
|
||||||
|
id: format!("github:notification:1@{}", reason.as_str()),
|
||||||
|
reason,
|
||||||
|
repo: RepoRef::new("acme", "widgets"),
|
||||||
|
number: 7,
|
||||||
|
is_pr: false,
|
||||||
|
actor: Some("stranger".to_owned()),
|
||||||
|
title: Some("a title".to_owned()),
|
||||||
|
url: None,
|
||||||
|
timestamp: Timestamp::parse("2026-11-21T00:00:00Z").expect("parses"),
|
||||||
|
raw: serde_json::json!({}),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A mention of the daemon is an ask: this daemon is the party named,
|
||||||
|
/// so the feed dispatches a turn that reads the thread — not a phone
|
||||||
|
/// buzz that leaves the mention unanswered.
|
||||||
|
#[test]
|
||||||
|
fn a_mention_of_the_daemon_dispatches_instead_of_surfacing() {
|
||||||
|
assert_eq!(
|
||||||
|
claw_triage(&triaged_notification(NotificationReason::Mention)),
|
||||||
|
Triage::Agent(Role::Implementer),
|
||||||
|
"somebody addressed the daemon and is waiting"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Every other reason keeps the shared vocabulary's verdict — the
|
||||||
|
/// reclassification is one row, not a second opinion.
|
||||||
|
#[test]
|
||||||
|
fn every_other_reason_keeps_the_shared_verdict() {
|
||||||
|
for reason in [
|
||||||
|
NotificationReason::ReviewRequested,
|
||||||
|
NotificationReason::Assigned,
|
||||||
|
NotificationReason::ReviewFeedback,
|
||||||
|
NotificationReason::Author,
|
||||||
|
NotificationReason::CiActivity,
|
||||||
|
NotificationReason::Other("subscribed".to_owned()),
|
||||||
|
] {
|
||||||
|
assert_eq!(
|
||||||
|
claw_triage(&triaged_notification(reason.clone())),
|
||||||
|
triage::classify(&triaged_notification(reason.clone())),
|
||||||
|
"{} keeps the base verdict",
|
||||||
|
reason.as_str()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user