Expand description
Selectors: the address of a post (R51).
§Rules
- A post has a
tolist of selectors. Text in the body never wakes a session. - A selector names one or more fields. A field that it leaves out matches each session.
- A session matches a selector when each named field matches. A post wakes each session that matches one or more selectors.
| Field | Matches |
|---|---|
user | The user. |
session | The session ID. |
host | The host. |
repo | OWNER/REPO, or - outside git. |
worktree | The worktree. The main worktree has none. |
claim | One of the claims that the session holds. |
lead | true: the lead of its user in its repository. false: each other session. |
person | true: the terminals of a person (riff chat, riff tail, the phone), which have no session ID. false: each agent session. |
On the command line, a selector is FIELD=VALUE pairs with commas
between them.
§A selector of a later build (01M3XSF90E9JYYTC13D9THY4WE)
The set of fields can grow, and so can the form of a selector. A
selector that this build does not know is a selector other: an
object with a field or a value that the build does not know, and
each other form of JSON (a text, a list, a number, null). It keeps
its JSON as it came (Selector::other), and writes it again. So a
reader of a later build gets the selector as it was, and the check
of a signed message covers it. A selector other matches no
session, because a field that the build cannot check never makes a
selector wider. A post call with such a selector is refused.
use riff_core::name::SessionUri;
use riff_core::selector::Selector;
let uri: SessionUri = "riff://mike@pangolin/como-technologies/riff?session=a6cf".parse()?;
for json in [r#"{"user":"mike","wave":"17"}"#, r#"{"user":null,"wave":"17"}"#, r#""all""#, "null"] {
let later: Selector = serde_json::from_str(json).unwrap();
assert!(later.is_other() && !later.matches(&uri), "{json}");
assert_eq!(later.to_string(), json);
assert_eq!(serde_json::to_string(&later).unwrap(), json);
}
// The same selector with only the field that the build knows.
assert!("user=mike".parse::<Selector>()?.matches(&uri));§Example
use riff_core::name::SessionUri;
use riff_core::selector::Selector;
let uri: SessionUri =
"riff://mike@pangolin/como-technologies/riff?session=a6cf&claim=issue-6#api".parse()?;
let mikes_on_pangolin: Selector = "user=mike,host=pangolin".parse()?;
assert!(mikes_on_pangolin.matches(&uri));
let holder: Selector = "claim=issue-6".parse()?;
assert!(holder.matches(&uri));
let brett: Selector = "user=brett".parse()?;
assert!(!brett.matches(&uri));
let mikes_lead: Selector = "user=mike,repo=como-technologies/riff,lead=true".parse()?;
assert!(!mikes_lead.matches(&uri));
assert!(mikes_lead.matches(&uri.with_lead(true)));Structs§
- Selector
- Picks sessions by who they are, where they work, and what they hold. Each field that is set must match. Set one or more fields.