diff --git a/Cargo.lock b/Cargo.lock index 56f8ee7..c3ecb13 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -289,7 +289,7 @@ checksum = "47d9d19d1d6efa0109d2f65ff4c85cddd50bd572e5a00127ab10987290bcefae" [[package]] name = "mailroom-logic" -version = "0.2.0" +version = "0.3.0" dependencies = [ "chrono", "pollster", @@ -300,7 +300,7 @@ dependencies = [ [[package]] name = "mailroom-worker" -version = "0.2.0" +version = "0.3.0" dependencies = [ "futures-util", "mailroom-logic", diff --git a/README.md b/README.md index 308fff5..6f2719f 100644 --- a/README.md +++ b/README.md @@ -107,11 +107,16 @@ Tags the poller adds itself: | --- | --- | | `routed:mention` | Discord: the message mentions the agent's bot. GitHub: the text contains `@`. | | `routed:reply` | Discord: the message replies to one of the bot's messages. | -| `routed:assigned` | GitHub: the agent is an assignee. | -| `routed:review` | GitHub: the PR carries `review_label` or the agent is a requested reviewer. | +| `routed:assigned` | GitHub: the agent is an assignee, or a trusted person put `assigned:` on the item (see Work handed over by label). | +| `routed:review` | GitHub: the PR carries `review_label` or the agent is a requested reviewer, or a trusted person put `review:` on the PR (see Work handed over by label). | | `mine` | GitHub: a comment, review or event on an issue or PR the agent authored. | +| `claimed` | GitHub: activity on an item handed to the agent by label (see Work handed over by label). | +| `released` | GitHub: the closing note of such an item. Drop the claim. | +| `untrusted-label` | GitHub: the label was applied by someone GitHub does not report as having triage, write, maintain or admin access to that repository, or by any app or bot. Not followed. | Tags starting `routed:` are addressed to the agent. `mine` is activity on its own work. +`claimed`, `released` and `untrusted-label` do not start with `routed:`, so they do not +call for attention by themselves: they inform. `released` tells the agent to drop a claim. Untagged records are context. Rules can add more tags (see Configuration). ## Tools @@ -163,9 +168,10 @@ tick, and unknown fields are rejected. | Field | Default | Rule | | --- | --- | --- | | `broker` | required | Name of a service binding to a github-broker `Feed`. Same rule as above. | -| `repos` | required | `owner/name`. Not empty, no duplicates. | +| `repos` | required | `owner/name`. No duplicates. Not empty unless `labels` is set. | | `every_secs` | `300` | Minimum `60`. | -| `review_label` | none | A label that means "review this". When set it must not be empty. | +| `review_label` | none | A label that means "review this". When set it must not be empty, and with `labels` it must not be `assigned:` or `review:` (in any case): those labels already route, with a trust check. | +| `labels` | none | `{ "org": "your-org", "tag": "claude" }`. Also finds work handed over by label across the whole organisation; see Work handed over by label. `tag` is 1-32 characters of `a-z`, `0-9`, `-`. | | `skip_self` | `true` | As above. | | `keep` | `"all"` | `"all"` or `"tagged"`. | | `rules` | `[]` | See below. | @@ -217,7 +223,7 @@ purges it. { "when": { "body_contains": ["deploy"] }, "then": { "tag": "deploy" } } ] }, { "type": "github", "broker": "GITHUB", "every_secs": 300, - "repos": ["your-org/your-repo"], "review_label": "review:claude", + "repos": ["your-org/your-repo"], "review_label": "needs-review", "skip_self": true, "keep": "tagged", "rules": [] } ] }, @@ -232,6 +238,87 @@ purges it. } ``` +## Work handed over by label + +A person hands work to an agent by labelling an item. With `labels` set on a GitHub source +(for example `"labels": { "org": "your-org", "tag": "claude" }`), mailroom searches the +whole organisation, not only `repos`, for two labels: + +- `assigned:` on an open issue or pull request (`assigned:claude`); +- `review:` on an open pull request (`review:claude`). + +`` belongs to one mailbox. The source gets one more poll target, +`github::labels:`, on the source's `every_secs`; `mailbox_info` lists it like +any other. Put `labels` on the same source that lists the organisation's repositories in +`repos`: only that source's repo polls learn which items are claimed, and so only they +tag the claimed activity. + +Label names match in any case (`Assigned:Claude` is `assigned:claude`); the claim record +shows the name as GitHub has it. + +**Who is trusted.** The label counts only when the person who applied it can write to the +repository: GitHub reports their `permission` as `admin` or `write`, or their role as +`admin`, `maintain`, `write` or `triage`. Anyone else, and anyone GitHub cannot find, is +untrusted. A GitHub App's bot is never a trusted labeler (GitHub reports no access for +it, and a login containing `[bot]` is untrusted without a lookup), so one agent cannot +hand work to another. There is no allowlist. A failed permission lookup fails the poll +and is retried; it never decides trust. + +Trust is decided per label, by the item's events and never by the search alone. For each +label that the search shows, the newest `labeled` event decides, and it counts only if no +later `unlabeled` event removed it, even when the search still lists the item. An item is +trusted while at least one label that counts was applied by a trusted person. If a +trusted claim stops being trusted (its trusted label was removed while an untrusted one +stays, or it was removed and put back by an untrusted person), the agent gets a closing +note, `released: label removed`, and the claim is kept as untrusted: not followed, no +more activity. + +**What the agent receives.** + +- A *claim record* when a trusted person first puts the label on an item: kind `event`, + title `labeled