# Impulse triage: agents propose, people decide
<!--
ref: @protocol/impulse-triage
version: 5
updated_at: 2026-11-11T06:26:20.406Z
files: [triage-listener.mjs]
-->

Use this when you are asked to triage, groom, or clean up a repo's impulses on protocol.supply. You read the impulses, post suggestions into a **triage run**, and conclude the run. A person answers each suggestion later. **You never write an impulse during triage.**

Why it works this way: you can judge what looks stale, duplicated or unclear, but only the person knows their business. If an agent's guesses change the record directly, the person has to audit everything it did. If they arrive as suggestions, they can be accepted or rejected in a minute. The suggestions, the answers and the reasons stay on protocol.supply, so the next pass, by you or by another agent, starts from what the person already said.

## The loop

1. **Read what the person said last time.** `GET /triage/suggestion?repoId=<repo>&respondedSince=<cursor>` returns every suggestion answered after your cursor, oldest answer first. Each row carries `state` and `response: {verdict, note, by, at}`. Store the last row's `respondedAt` as your next cursor. On a first run, use any old timestamp; an empty list is the normal answer.
   *Why first:* a rejection with a note is an instruction. If you re-suggest something the person turned down without new information, you waste their attention and they learn to stop reading your runs.
2. **Read the impulses.** Use `GET /impulse?repoId=<repo>` with a bounded filter: `?untriaged=true`, `?category=triage,backlog`, an age filter, and `limit` and `offset` paging (read `X-Total-Count`). Triage a slice you can judge well rather than everything at once. Ask for JSON (`?format=json`). The default answer is markdown, and you need each impulse's `updatedAt` for `basis`.
3. **Open a run.** `POST /triage/run` with `{"repoId": "<repo>", "runnerId": "<your name>", "filter": {<the query you used>}}`. It returns `{id: "trun_…"}`. The filter is kept as a record of what you looked at.
4. **Post suggestions.** `POST /triage/run/<runId>/suggestions` takes an array of up to 500 suggestions (see the vocabulary below) and returns a result per row. A refused row carries its `reason`, and the valid rows still land. Fix and re-post only the refused rows. **Send one suggestion per impulse.** A new suggestion on an impulse supersedes the open one, including one you posted earlier in the same run. If an impulse needs two changes (a rollup and a priority, say), put both fields in one `patch` under the kind that matters most.
5. **Conclude.** `POST /triage/run/<runId>/conclude` with `{"summary": "<one line: what you looked at, what you suggested>"}`. An open run shows as "in progress" to the person, so a run you never conclude looks like one that is still running.

You need **write access to the repo**. A scoped API token needs `read` plus `write:triage`. That token can open runs and post suggestions. It **cannot** patch an impulse or answer a suggestion, and that is deliberate: an agent that can approve its own proposals is not proposing.

## The suggestion

```json
{
  "impulseId": "ipls_…",
  "kind": "retire",
  "patch": {"status": "wont_do"},
  "reason": "No activity in 94 days; the v2 plan replaced this approach",
  "confidence": 0.8,
  "group": "superseded by v2",
  "basis": "2026-08-09T14:02:11.000Z"
}
```

- **`kind`** says what you propose. The list is closed, and an unknown kind is refused with the full list.

| kind | patch | use when |
|---|---|---|
| `retire` | `{"status": <closing status>}`: `completed`, `wont_do`, `duplicate`, `superseded`, `not_reproducible` or `retired` | the work is done, abandoned, or moot |
| `rollup` | `{"parentId": "<target ipls_>"}` (status defaults to `duplicate`) | it is the same ask as another impulse in the same repo |
| `rewrite` | `{"title"?, "content"?}`, the drafted text | the ask is real but unreadable: vague title, buried request |
| `status` | `{"status"}` or `{"category"}` | it is in the wrong lifecycle state |
| `recategorize` | e.g. `{"type"}`, `{"metadata": {…}}` | it is filed under the wrong kind |
| `assign` | `{"assignee"}` | it has no owner, or the wrong one |
| `priority` | `{"metadata": {"priority": "P0"–"P3"}}` | its urgency is wrong |
| `group` | none; set `group` | you are only proposing a theme |
| `ask` | none; set `question` | only the person can answer something, and the answer decides the impulse |
| `keep` | none | you looked and it is fine. Say so, so the person knows it was reviewed and not skipped |

Picking a closing status for `retire`:

- `completed`: the need was met, by this work or by something else (a tool now does it automatically).
- `superseded`: another plan replaced this one. Name the plan in `reason`.
- `wont_do`: the person decided against it, or it stopped mattering.
- `duplicate`: use `rollup` instead, so the impulse points at the one it duplicates.
- `not_reproducible`: only for a bug report that nobody can reproduce.

- **`patch`** uses the impulse's own field names (`status`, `category`, `parentId`, `title`, `content`, `assignee`, `type`, `metadata`). It is exactly what would be written if the suggestion were accepted, so make it complete.
- **`reason`** is the most important field. Name the evidence: dates, the impulse it duplicates, the last log line, the decision that made it moot. "Looks stale" is not a reason. "No log row since 2026-08-09, and the v2 plan replaced this approach" is. *Why:* the person decides from your reason, and a good one lets them decide without opening the impulse.
- **`confidence`** is a number from 0 to 1. Be honest: people sort and bulk-accept by it.
- **`group`** is a short theme label, such as `"onboarding dupes"` or `"Q3 vendor work"`. Related suggestions in one group can be answered together, and grouping is most of the value on a long list.
- **`basis`** is the impulse's `updatedAt` as you read it. If you leave it out, the impulse's current value is used. An impulse that changes after your basis is refused when someone accepts the suggestion, so a suggestion never lands on newer state than you saw.

**Re-suggesting** on an impulse that already has an *open* suggestion supersedes that suggestion: the result row lists it under `superseded`, and it can no longer be answered. A suggestion that was already *answered* stays, as the person's side of the conversation. Read it before you suggest again.

## Answers

A person answers each suggestion with `accept`, `reject`, `answer` (a reply to an `ask`, with text) or `skip`, and can add a `note`. Answers come back to you through step 1 of the loop.

- `rejected` with a note means do not re-suggest unless you have new evidence. If you do, quote the note and say what changed.
- `answered` means the `note` holds the answer to your `ask`. Use it to make the real suggestion in your next run.
- `applied` means the person accepted a change suggestion and the server applied its `patch`, as them. The impulse carries a `triage-apply` log row that cites the suggestion and the run. Do not apply anything yourself. *Why:* the change is the person's act, attributed to them, so the record shows who decided.
- `accepted` on an `ask`, `keep` or `group` means the person agrees. Nothing was written, because those kinds propose no change.
- `stale` means the person accepted, but the impulse changed after your `basis`, so nothing was applied. Re-read the impulse. If your suggestion still holds, suggest it again in your next run with the new basis.
- `skipped` means not now. Do not re-suggest it in the very next run.

People answer through the API: `POST /triage/suggestion/<id>/respond` with `{verdict, note?}`, or `POST /triage/respond` with an array for a batch. A person needs write access to the repo to answer. Accepting a change kind applies it right away. A batch reports each row separately, so one stale row does not stop the other accepts.

## Reading the set

- `GET /triage/run?repoId=` lists runs, newest first, each with suggestion counts by state.
- `GET /triage/suggestion?runId=<run>` returns one run's suggestions. Filter with `state=open,accepted`, `kind=retire,rollup` and `group=<label>`, and page with `limit` and `offset`.
- `GET /triage/suggestion?repoId=&impulseId=<id>` returns one impulse's **thread** across runs, oldest first. Read it before you suggest on an impulse that has history.

## Worked example

An agent triages a repo with 140 untriaged impulses.

1. The cursor read returns 3 answers from last week. Two are `rejected` with the note "still needed for the audit". One `ask` is `answered` with "vendor contract ended in September".
2. It reads `GET /impulse?repoId=…&untriaged=true&limit=100`.
3. It opens a run, then posts 100 suggestions: 31 `retire` (group "pre-v2 plan"), 12 `rollup` into 4 parents (group "dupes"), 9 `rewrite`, 6 `ask`, and 42 `keep`. It does not re-suggest the two rejected impulses. For the answered `ask`, it now posts a `retire` with the reason "vendor contract ended in September (your answer, 2026-11-03)".
4. Two rows are refused (a typo in a status, and an impulse in another repo). It fixes the status typo and re-posts that row.
5. It concludes with: "100 of 140 untriaged: 31 retire, 12 rollup, 9 rewrite, 6 ask, 42 keep; 40 left for the next run."

The person opens the set, accepts the "pre-v2 plan" group in one call, rejects 3 rollups with notes, and answers 4 of the asks. The next run starts from those answers.

## Waking when a person answers

You don't have to poll. Each time a person answers a suggestion, and each time a run is concluded, protocol.supply sends one event on the socket channel `triage:<repoId>`:

```json
{"type":"triage.responded","repoId":"repo_…","runId":"trun_…","suggestionId":"tsug_…","impulseId":"ipls_…","at":"2026-11-11T06:40:12.345Z"}
{"type":"triage.run.concluded","repoId":"repo_…","runId":"trun_…","at":"…"}
```

An event carries ids only. It never includes the note, the title or the body. When you get one, read the answer through the API (step 1 of the loop). *Why ids only:* the API checks access on every read, and an event is only a hint that something changed. A copy of the data in an event could go stale, or reach a listener that should not see it.

- **Connect.** Use socket.io on `wss://api.protocol.supply`, path `/realtime`, websocket transport only. Pass `auth: {token: "tok_…"}`. The token needs `read`. Pin it to the repo (`targetId`) so it can't subscribe to any other repo. Then emit `subscribe` with `triage:<repoId>`. If you have no read access, or the token is pinned to a different repo, the server answers with an `exception` event and doesn't subscribe you.
- **Catch up on every connect.** The socket stores nothing and replays nothing. A listener that was offline asks `GET /triage/suggestion?repoId=<repo>&respondedSince=<cursor>`, and that read returns everything it missed. A response event's `at` is that row's `respondedAt`, so it is your next cursor. Subscribe first, then run the catch-up read. If you read first, an answer given between the read and the subscribe is lost. Doing it in this order can send a row twice, once from each path. Drop the duplicate by `suggestionId` and `at`.
- **Batch on your own side.** The server sends one event per answer, so a group accept of 40 rows sends 40 events. Debounce them into one read.

**The reference listener** is the file appendix `triage-listener.mjs` (Node 18+, `npm i [email protected]`). It holds one socket, appends one JSON line per event to a dispatch file, keeps the cursor in a file beside it, and catches up on every reconnect:

```bash
PROTOCOL_TOKEN=tok_… REPO_ID=repo_… DISPATCH_FILE=~/.triage/dispatch.jsonl node triage-listener.mjs
```

What wakes on the file depends on the agent:

- **Claude Code**: a Monitor on `tail -n0 -F <dispatch file>`. Each line wakes the session, and the session reads the answer.
- **Ticker lanes**: the same file shape their Slack monitor already writes.
- **Hermes / Openclaw**: subscribe with your own socket client, using the channel and catch-up rule above. The script is just one worked example.

---

*You're reading a protocol on [protocol.supply](https://protocol.supply) — hosted, searchable knowledge for AI agents. Think Agent Skills, as an API: bootstrap once (`curl -sL https://api.protocol.supply/bootstrap`), search (`/search?q=…`), fetch (`/@repo/slug`).*

*Any skill can become a protocol, and any protocol installs as a local skill — tell your agent "install this as a skill" or see [`@protocol/protocol-to-skill`](https://api.protocol.supply/@protocol/protocol-to-skill).*