@sjawhar/claude-envoy 2.31.4 → 2.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,5 +2,5 @@
2
2
  "name": "claude-envoy",
3
3
  "description": "Put Envoy events into the Claude Code session's own conversation and expose Envoy MCP tools.",
4
4
  "mcpServers": "./.mcp.json",
5
- "version": "2.31.4"
5
+ "version": "2.32.0"
6
6
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-envoy",
3
- "version": "2.31.4",
3
+ "version": "2.32.0",
4
4
  "description": "Put Envoy events into the Claude Code session's own conversation and expose Envoy MCP tools.",
5
5
  "mcpServers": {}
6
6
  }
package/dist/dispatch.js CHANGED
@@ -30433,7 +30433,8 @@ var EnvelopeResponseSchema = EnvelopeSchema.extend({
30433
30433
  });
30434
30434
  var PublishResponseSchema = EnvelopeResponseSchema.extend({
30435
30435
  kept: boolean2().optional(),
30436
- kept_reason: _enum2(["unclaimed", "holder_lapsed"]).optional()
30436
+ kept_reason: _enum2(["unclaimed", "holder_lapsed"]).optional(),
30437
+ kept_until: number2().int().optional()
30437
30438
  });
30438
30439
  var DeliveryRefusalSchema = object({
30439
30440
  mode: string2(),
@@ -30708,7 +30709,7 @@ function createEnvoyClient(config) {
30708
30709
  confirmed: response.recipient !== undefined,
30709
30710
  recipientState: response.recipient_state ?? "live",
30710
30711
  state: response.state === "stopped" ? "stopped" : "connected",
30711
- ...response.last_seen === undefined || response.last_seen <= 0 ? {} : { lastSeen: response.last_seen },
30712
+ ...lastSeenOf(response.last_seen),
30712
30713
  duplicate: response.duplicate === true
30713
30714
  };
30714
30715
  },
@@ -30728,10 +30729,12 @@ function createEnvoyClient(config) {
30728
30729
  envelope: response,
30729
30730
  ...response.holder === undefined ? {} : { holder: response.holder },
30730
30731
  ...response.holder_state === undefined ? {} : { holderState: response.holder_state },
30732
+ ...lastSeenOf(response.last_seen),
30731
30733
  ...response.recipients === undefined ? {} : { recipients: response.recipients },
30732
30734
  ...response.recipients_connected === undefined ? {} : { recipientsConnected: response.recipients_connected },
30733
30735
  ...response.kept === undefined ? {} : { kept: response.kept },
30734
- ...response.kept_reason === undefined ? {} : { keptReason: response.kept_reason }
30736
+ ...response.kept_reason === undefined ? {} : { keptReason: response.kept_reason },
30737
+ ...response.kept_until === undefined ? {} : { keptUntil: response.kept_until }
30735
30738
  };
30736
30739
  },
30737
30740
  unregisterSession: async (input) => {
@@ -30798,6 +30801,9 @@ function messageMetadata(input) {
30798
30801
  function sourceSession(sessionID) {
30799
30802
  return sessionID === undefined || sessionID === "" ? {} : { source_session: sessionID };
30800
30803
  }
30804
+ function lastSeenOf(lastSeen) {
30805
+ return lastSeen === undefined || lastSeen <= 0 ? {} : { lastSeen };
30806
+ }
30801
30807
 
30802
30808
  // ../envoy-client/src/dispatch-cli.ts
30803
30809
  var OK = 0;
@@ -46222,7 +46222,8 @@ var EnvelopeResponseSchema = EnvelopeSchema.extend({
46222
46222
  });
46223
46223
  var PublishResponseSchema = EnvelopeResponseSchema.extend({
46224
46224
  kept: boolean2().optional(),
46225
- kept_reason: _enum2(["unclaimed", "holder_lapsed"]).optional()
46225
+ kept_reason: _enum2(["unclaimed", "holder_lapsed"]).optional(),
46226
+ kept_until: number2().int().optional()
46226
46227
  });
46227
46228
  var DeliveryRefusalSchema = object({
46228
46229
  mode: string2(),
@@ -46497,7 +46498,7 @@ function createEnvoyClient(config) {
46497
46498
  confirmed: response.recipient !== undefined,
46498
46499
  recipientState: response.recipient_state ?? "live",
46499
46500
  state: response.state === "stopped" ? "stopped" : "connected",
46500
- ...response.last_seen === undefined || response.last_seen <= 0 ? {} : { lastSeen: response.last_seen },
46501
+ ...lastSeenOf(response.last_seen),
46501
46502
  duplicate: response.duplicate === true
46502
46503
  };
46503
46504
  },
@@ -46517,10 +46518,12 @@ function createEnvoyClient(config) {
46517
46518
  envelope: response,
46518
46519
  ...response.holder === undefined ? {} : { holder: response.holder },
46519
46520
  ...response.holder_state === undefined ? {} : { holderState: response.holder_state },
46521
+ ...lastSeenOf(response.last_seen),
46520
46522
  ...response.recipients === undefined ? {} : { recipients: response.recipients },
46521
46523
  ...response.recipients_connected === undefined ? {} : { recipientsConnected: response.recipients_connected },
46522
46524
  ...response.kept === undefined ? {} : { kept: response.kept },
46523
- ...response.kept_reason === undefined ? {} : { keptReason: response.kept_reason }
46525
+ ...response.kept_reason === undefined ? {} : { keptReason: response.kept_reason },
46526
+ ...response.kept_until === undefined ? {} : { keptUntil: response.kept_until }
46524
46527
  };
46525
46528
  },
46526
46529
  unregisterSession: async (input) => {
@@ -46587,6 +46590,9 @@ function messageMetadata(input) {
46587
46590
  function sourceSession(sessionID) {
46588
46591
  return sessionID === undefined || sessionID === "" ? {} : { source_session: sessionID };
46589
46592
  }
46593
+ function lastSeenOf(lastSeen) {
46594
+ return lastSeen === undefined || lastSeen <= 0 ? {} : { lastSeen };
46595
+ }
46590
46596
 
46591
46597
  // ../envoy-client/src/consumer-delivery.ts
46592
46598
  var DELIVER_SUBJECT_PREFIX = "notifications.envoy.deliver.";
@@ -53908,7 +53914,7 @@ var envoyToolSpecs = [
53908
53914
  },
53909
53915
  {
53910
53916
  name: "envoy_publish",
53911
- description: `Publish an Envoy message to a notifications. topic. ${STORED_DELIVERY} A role or built-in topic is delivered as its guide says. A role message has three possible answers. First, a session holds the role, and the stream stores the forward for that holder's consumer. Its 200 says the stream stored it, and it does not say that the holder read it; it names the holder and the state the listener resolved the holder in. Second, no session holds the role. The listener then keeps the message, and gives it to the next session that claims that role in the hour that follows. This is a success, and the result says that the listener kept the message. Third, the listener keeps nothing and errs, which tells you to reach the agent some other way: the holder refuses the message, or the forward is not stored within four seconds. A holder that stopped answering keeps its role but was not sent the message, and nothing waits for it, so publish the message again once that holder's holder_state reads live, and start no replacement for that session. A team topic (such as notifications.team.deploy-squad.all) is stored like every other, so a session subscribed to it that was away still receives it when it returns, and one that subscribes after you publish does not. A notifications. topic no stream subject captures is refused by name: nothing would store it. ${PUBLISH_COUNTS} ${SESSION_STATE_GUIDE} ${DELIVERY_CONTRACT}`,
53917
+ description: `Publish an Envoy message to a notifications. topic. ${STORED_DELIVERY} A role or built-in topic is delivered as its guide says. A role message has three possible answers. First, a live session holds the role, and the stream stores the forward for that holder's consumer. Its 200 says the stream stored it. It does not say that the holder read it. It names the holder and the state the listener resolved the holder in. Second, no live session holds the role: nobody claims it, or its holder is unresponsive or gone. The listener then keeps the message for one hour. This is a success. The result says that the listener kept the message, and its kept_until is the time that hour ends. For a holder that is not live, the result also names that holder and its state. The next session to hold the role live before kept_until gets the message. That can be the same holder when it answers again. If no session takes the message by kept_until, Envoy drops it. If the publish named your session as its source, Envoy then sends your session a message that names the dropped message, unless it dropped it more than an hour late. Third, the listener keeps nothing and errs, which tells you to reach the agent some other way: the holder refuses the message, or the forward is not stored within four seconds. A team topic (such as notifications.team.deploy-squad.all) is stored like every other, so a session subscribed to it that was away still receives it when it returns, and one that subscribes after you publish does not. A notifications. topic no stream subject captures is refused by name: nothing would store it. ${PUBLISH_COUNTS} ${SESSION_STATE_GUIDE} ${DELIVERY_CONTRACT}`,
53912
53918
  arguments: (schema) => ({ topic: schema.string(), ...messageArguments(schema) }),
53913
53919
  operation: EnvoyToolOperation.publish
53914
53920
  },
@@ -53971,7 +53977,7 @@ function sendConfirmationText(result) {
53971
53977
  const state = result.recipientState === "unresponsive" ? `unresponsive${since}, so it is stored until that session answers; ${UNRESPONSIVE_RULE}` : result.recipientState;
53972
53978
  return `sent ${result.envelope.event_id} to ${result.recipient} (${state})${result.confirmed ? "" : " (recipient unconfirmed by listener)"}`;
53973
53979
  }
53974
- function publishConfirmationText(result) {
53980
+ function publishConfirmationText(result, options) {
53975
53981
  const published = `published ${result.envelope.event_id}`;
53976
53982
  if (result.recipients === 0) {
53977
53983
  return `${published}; no other session subscribes to ${result.envelope.topic}, so no other session gets it`;
@@ -53983,13 +53989,35 @@ function publishConfirmationText(result) {
53983
53989
  }
53984
53990
  const sentences = [`${published}.`];
53985
53991
  if (result.kept === true) {
53986
- sentences.push("Envoy kept it for the role: no session holds it yet, and the message waits for the session that claims it next.");
53992
+ const lapsed = result.keptReason === "holder_lapsed";
53993
+ const holder = result.holder === undefined ? "" : ` ${result.holder}`;
53994
+ const why = lapsed ? `its holder${holder} is ${result.holderState ?? "not live"}, so no live session holds the role now` : "no live session holds the role now";
53995
+ const until = result.keptUntil === undefined ? "" : ` until ${new Date(result.keptUntil).toISOString()}`;
53996
+ sentences.push(`Envoy kept it for the role${until}: ${why}.`);
53997
+ sentences.push(result.keptUntil === undefined ? "Envoy did not say until when it keeps it." : "The next session to hold the role before then gets it.");
53998
+ if (result.keptUntil !== undefined && options.senderNamed) {
53999
+ sentences.push("If none does, Envoy drops it and sends you a message that names it, unless it drops it more than an hour late.");
54000
+ }
54001
+ if (lapsed && result.holderState === "unresponsive")
54002
+ sentences.push(UNRESPONSIVE_RULE);
53987
54003
  } else if (result.holder !== undefined) {
53988
54004
  const state = result.holderState === undefined ? "" : ` (${result.holderState})`;
53989
54005
  sentences.push(`Its role holder is ${result.holder}${state}.`);
53990
54006
  }
53991
54007
  return sentences.join(" ");
53992
54008
  }
54009
+ function publishResultDetails(result) {
54010
+ return {
54011
+ ...result.holder === undefined ? {} : { holder: result.holder },
54012
+ ...result.holderState === undefined ? {} : { holder_state: result.holderState },
54013
+ ...result.lastSeen === undefined ? {} : { last_seen: result.lastSeen },
54014
+ ...result.recipients === undefined ? {} : { recipients: result.recipients },
54015
+ ...result.recipientsConnected === undefined ? {} : { recipients_connected: result.recipientsConnected },
54016
+ ...result.kept === undefined ? {} : { kept: result.kept },
54017
+ ...result.keptReason === undefined ? {} : { kept_reason: result.keptReason },
54018
+ ...result.keptUntil === undefined ? {} : { kept_until: result.keptUntil }
54019
+ };
54020
+ }
53993
54021
  function sessionsOnMachine(sessions, machine) {
53994
54022
  if (machine === undefined || machine === "")
53995
54023
  return sessions;
@@ -57448,7 +57476,7 @@ var import_nats2 = __toESM(require_mod4(), 1);
57448
57476
 
57449
57477
  // package.json
57450
57478
  var name = "@sjawhar/claude-envoy";
57451
- var version2 = "2.31.4";
57479
+ var version2 = "2.32.0";
57452
57480
  var legion = {
57453
57481
  daemonApiVersion: 144
57454
57482
  };
@@ -59002,12 +59030,15 @@ function createPhaseReminder(deps) {
59002
59030
  lastMessage
59003
59031
  }),
59004
59032
  idempotencyKey: key,
59005
- sourceSessionID: claim.sessionID,
59006
- keep: false
59033
+ sourceSessionID: claim.sessionID
59007
59034
  });
59008
59035
  if (reportKey !== key)
59009
59036
  return;
59010
59037
  if (answer.kept === true) {
59038
+ if (answer.keptUntil === undefined) {
59039
+ reportKey = undefined;
59040
+ writeEntry();
59041
+ }
59011
59042
  deps.log.debug("legion: the listener kept the architect notice; telling it again later", {
59012
59043
  issue: claim.issue,
59013
59044
  reminders
@@ -62041,15 +62072,10 @@ async function executeEnvoyTool(runtime, name, input) {
62041
62072
  ...toMessageMetadata(args)
62042
62073
  });
62043
62074
  return {
62044
- message: publishConfirmationText(result),
62075
+ message: publishConfirmationText(result, { senderNamed: true }),
62045
62076
  event_id: result.envelope.event_id,
62046
62077
  topic: result.envelope.topic,
62047
- ...result.holder === undefined ? {} : { holder: result.holder },
62048
- ...result.holderState === undefined ? {} : { holder_state: result.holderState },
62049
- ...result.recipients === undefined ? {} : { recipients: result.recipients },
62050
- ...result.recipientsConnected === undefined ? {} : { recipients_connected: result.recipientsConnected },
62051
- ...result.kept === undefined ? {} : { kept: result.kept },
62052
- ...result.keptReason === undefined ? {} : { kept_reason: result.keptReason }
62078
+ ...publishResultDetails(result)
62053
62079
  };
62054
62080
  }
62055
62081
  case EnvoyToolOperation.subscribe: {
@@ -53,11 +53,14 @@ The work goes to whoever already owns that code. You file an issue only when nob
53
53
  `notifications.role.<issues.<KEY>.architect.locator.claim>`. The architect decides whether it
54
54
  is a child of the tree or part of an open issue's work. Reply `Handed dispatch://<that KEY>`
55
55
  under the evidence only when a live holder took the publish. When the root has no locator, or
56
- the listener kept the publish for the role's next holder, reply nothing: no architect reads a
57
- comment on its root, so the evidence stays unhandled, and catch-up step 4 lists it again at
58
- your next start. Publish it again at your next wake. Once the root leaves `admission.trees`,
59
- no running tree owns the code, and step 4 files it. File nothing while a tree owns it: a
60
- second issue splits the work.
56
+ the listener kept the publish because no live session holds the role, reply nothing: no
57
+ architect reads a comment on its root, so the evidence stays unhandled, and catch-up step 4
58
+ lists it again at your next start. A kept publish waits one hour, until the `kept_until` its
59
+ answer names, for the role's next live holder. If no session takes it in that hour, Envoy
60
+ drops it, and when your publish named your session, sends your session a message that names
61
+ it, unless it dropped it more than an hour late. Publish it again at your next wake.
62
+ Once the root leaves `admission.trees`, no running tree owns the code, and step 4 files it.
63
+ File nothing while a tree owns it: a second issue splits the work.
61
64
  4. No running tree owns that code: file it on the repository where the fix belongs, in the
62
65
  project that repository maps to:
63
66
 
@@ -18,10 +18,12 @@ If the deployment instructions (the `# Deployment instructions` part of your sys
18
18
  `oracle` task agent), send your question to it first with
19
19
  `envoy_publish(topic="notifications.role.<name>", expects_reply="required")`, because that role may
20
20
  already hold the answer. Then end your turn: the reply arrives as a delivery that starts your next
21
- one, and research before it duplicates the role's work. If no session holds the role, the publish
22
- answers that Envoy kept the question for the session that claims the role next, which is handed it
23
- once within the hour. Nobody can answer you now, so put that kept answer in your output and
24
- research at once rather than wait for it.
21
+ one, and research before it duplicates the role's work. If no live session holds the role, the
22
+ publish answers that Envoy kept the question for one hour, until its `kept_until`, and the next
23
+ session to hold the role live in that hour is handed it once. If none does, Envoy drops it, and
24
+ when your publish named your session, sends your session a message that names it, unless it
25
+ dropped it more than an hour late. Nobody can answer you now, so put that kept answer in your
26
+ output and research at once rather than wait for it.
25
27
 
26
28
  Run steps 1 and 2, in parallel if you choose, since neither needs the other's result. Run step 3
27
29
  when the question names a library, and step 4 when it asks for general practice, each only when
@@ -77,17 +77,17 @@ next look of its own.
77
77
  The controller topic is a live wake: a message published while no controller runs reaches nobody
78
78
  at the time. `envoy_publish`'s own answer tells you whether one took it. A publish to a role
79
79
  answers with its live `holder`, and with no count of recipients: the listener forwards a role
80
- message to its holder alone. With no claim on `legion-<project>-controller` at all, the answer
81
- says Envoy kept the message instead (`packages/envoy/cmd/listener`, the test "unheld role is kept
82
- and answered 202 without publishing on the role topic"): the next session that claims the role is
83
- handed each kept message once, within one hour of the keep. A keep is not a delivery: a
84
- controller can stay away for the whole hour, and a message kept longer than an hour is dropped
85
- unread, so a kept finding can reach nobody. It fails with `role legion-<project>-controller
86
- holder <session> lapsed; claim retained`, naming the holder, its `holder_state` and its
87
- `last_seen`, when a controller holds the role and its session has not registered within the live
88
- window: an `unresponsive` controller is not a stopped one, so release nothing, take nothing from
89
- it, and publish no second copy.
90
- Treat a kept answer as a controller not taking it. Either way the finding has not been taken yet,
80
+ message to its holder alone. When no live session holds `legion-<project>-controller`, because
81
+ nobody claims it or its holder has not registered within the live window, the answer says Envoy
82
+ kept the message for one hour, and its `kept_until` is the time that hour ends. The next session
83
+ to hold the role live in that hour is handed it once. A keep is not a delivery: a controller can
84
+ stay away for the whole hour, and Envoy then drops the message unread, so a kept finding can
85
+ reach nobody. When your publish named your session, Envoy also sends your session a message that
86
+ names the dropped one, unless it dropped it more than an hour late. For a holder that is not
87
+ live, the answer also names that holder, its `holder_state` and its `last_seen`: an
88
+ `unresponsive` controller is not a stopped one, so release nothing, take nothing from it, and
89
+ publish no second copy.
90
+ Treat a kept answer as a controller not taking it. The finding has not been taken yet,
91
91
  so make it an ask, as
92
92
  [What the ask says](#what-the-ask-says) spells it, on the first
93
93
  of these that holds, so a person sees it and the controller finds it when it returns:
@@ -146,7 +146,7 @@ the three `-alone` ones among them - runs on a pull request labelled `full-ci`,
146
146
  queue and nightly, and the `alone` job that holds the wall-clock rows is gated on it
147
147
  (`if: inputs.lane == 'full'` under `alone:` in `.github/workflows/dispatch-browser.yaml`), so no
148
148
  unlabelled pull request runs a wall-clock row at all. One spec needs
149
- the same stack as all of them: a Postgres with pgvector. On a digest
149
+ the same stack as all the specs: a Postgres with pgvector. On a digest
150
150
  carrying `legion-testpg`, use the pod's own server
151
151
  (`skill://legion-worker/references/tools.md#the-database-your-tests-use`) and
152
152
  unpack nothing. On a digest without it, the way
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sjawhar/claude-envoy",
3
- "version": "2.31.4",
3
+ "version": "2.32.0",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Claude Code plugin for Legion's Envoy bus",
6
6
  "type": "module",
@@ -135,10 +135,13 @@ Every topic starts with `notifications.`.
135
135
  - Publish to a role with `envoy_publish(topic="notifications.role.<role>", ...)`;
136
136
  never subscribe to a role topic, because the listener forwards a role message to its holder only.
137
137
  A publish returns once Envoy's stream has stored the forward for the holder, with the live `holder` and its `holder_state`.
138
- When nobody holds the role, Envoy keeps the message for the session that claims the role next: the answer says it was kept, and that session is handed it once, within one hour of the keep.
139
- A holder that is not `live` returns an error instead: that refusal names the holder, its `holder_state` (`unresponsive` or `gone`), its `last_seen` and `claim_released: false`, and nothing was forwarded and nothing kept, so publish the message again once the holder answers rather than starting a replacement for it or taking anything from it.
140
- A forward the stream did not store for a live holder within about 4 seconds errs too, and you see that one after about 8 seconds, because the client tries once more.
141
- No error releases the role's claim: a holder whose `holder_state` is `unresponsive` keeps its role.
138
+ When no live session holds the role, Envoy keeps the message for one hour: the answer says it was kept, and its `kept_until` is the time that hour ends.
139
+ That holds when nobody claims the role, and when its holder is not `live`: the answer then also names the holder, its `holder_state` (`unresponsive` or `gone`) and its `last_seen`.
140
+ The next session to hold the role live before `kept_until` is handed the message once, and that can be the same holder when it answers again.
141
+ If no session takes it by then, Envoy drops it, and when your publish named your session, sends your session a message that names it, unless it dropped it more than an hour late.
142
+ An `unresponsive` holder is not dead, so start no replacement for it and take nothing from it.
143
+ A forward the stream did not store for a live holder within about 4 seconds errs, and you see that error after about 8 seconds, because the client tries once more.
144
+ Neither a kept answer nor an error releases the role's claim: a holder whose `holder_state` is `unresponsive` keeps its role.
142
145
  `envoy_role_get(role=...)` finds the holder first.
143
146
  The forward is kept on the holder's inbox, so the holder's session gets it once from its own durable consumer, also after a restart, a reconnect, or while it was not running.
144
147
  From a shell with no tool device, read the holder with `envoy role <role>` where sjawhar/dotfiles' `scripts/envoy` is on the PATH, and in a Legion pod, which has no `envoy` command, with `curl -sS -H "Authorization: Bearer $(cat "$ENVOY_TOKEN_FILE")" "$ENVOY_URL/v1/roles/<role>" | jq -r '.holder // .reason // .error'`, which prints the holder's session id, `unclaimed` for a role nobody holds, or the error of a refused read, such as `unauthorized` for a bad token.
@@ -110,7 +110,8 @@ It depends on where a session takes its deliveries, not on whether the topic is
110
110
  the listener finds the live holder and forwards the message to it, and drops the message when that holder is the message's source session.
111
111
  The stream keeps the forward on the holder's inbox, so the holder's session gets it once, also after a restart or while it was not running.
112
112
  No session answers a receipt for one: a publish returns once the stream stored the forward.
113
- A role message no live holder can take is kept for the session that claims the role next, which is handed it once, within one hour of the keep.
113
+ A role message no live holder can take is kept for one hour, until the `kept_until` the publish answers with, and the next session to hold the role live in that hour is handed it once.
114
+ If no session takes it, Envoy drops it, and when the publish named a sender session, Envoy sends that session a message that names it, unless it dropped it more than an hour late.
114
115
 
115
116
  - Every other `notifications.` topic, one no source uses and the stream does not keep, is refused by name
116
117
  — at `envoy_publish` and at `envoy_subscribe` alike — because no session would ever receive it.
@@ -19,9 +19,11 @@ Read this in a Legion pane before you touch a role claim, or when a Legion role
19
19
  Only the reaper releases a claim, once its holder is `gone`;
20
20
  a Legion role whose agent process exits is `gone` at once, so its successor's soft claim takes the role without waiting out the live window.
21
21
 
22
- - `holder_lapsed`: a session holds the claim but has not registered within the live window, so the listener refused the publish `404` and forwarded nothing.
22
+ - `holder_lapsed`: a session holds the claim but has not registered within the live window.
23
+ The daemon's own notices send `keep: false`, so the listener refuses such a notice `404` and forwards nothing.
23
24
  The error names the holder, its `holder_state` and its `last_seen`, and says `claim_released: false`.
24
25
  An `unresponsive` holder is not dead: it keeps the role, nothing replaces it, and the daemon holds the packet and publishes it again.
26
+ A publish of yours to such a role is kept instead: the answer is `202` with `kept_reason: holder_lapsed` and `kept_until`.
25
27
 
26
28
  - `delivery_failed`: the stream stored no forward for the holder:
27
29
  the holder lookup failed, the publish errored, or the stream did not store the forward within the send's window.
@@ -34,8 +36,15 @@ Read this in a Legion pane before you touch a role claim, or when a Legion role
34
36
 
35
37
  - A role message forwarded to you is kept on your inbox in the stream, which your own durable consumer reads, so your session gets it once, also after the pane restarts or reconnects.
36
38
 
39
+ - A role message to a released Legion role is kept for one hour, and it wakes the role.
40
+ The listener reports the wake at the keep.
41
+ Its sweep reports the wake again every five minutes while the message has at least 20 minutes of its hour left and no live session holds the role.
42
+ The woken session gets the message as an Envoy card with `kept_at`, and the card can come before the task the daemon gives the woken role.
43
+ If the role is not back inside the hour, Envoy drops the message, and when the publish named a sender session, Envoy sends that session a message that names it, unless it dropped it more than an hour late.
44
+
37
45
  - Never forward these failure payloads to an architect, because the daemon already acts on them.
38
46
 
39
47
  - A role send the listener refuses `404` also raises one exception on `notifications.envoy.exceptions.notifications.role.<role>`, with the reason it refused: `unclaimed` or `holder_lapsed`.
48
+ The listener refuses only a publish it keeps nothing for: one sent with `keep: false`, as the daemon's own notices are, or one whose keep failed.
40
49
  It is a bus signal and nothing more: no consumer acts on a peer's refusal, and the daemon's own refused outbox row retries by itself until the role is held or its architect cannot hold it again.
41
50
  Never re-send a refused message by hand on the strength of one.
@@ -4,7 +4,7 @@ Read this when a role you held is gone after a resume, fork or restart, when `en
4
4
 
5
5
  - A claim belongs to the session, not the process. `omp --resume` re-claims the role recorded in the session transcript, also after the reaper removed the old session's row (the reaper removes a row only once that session is `gone`: past the gone horizon, `ENVOY_SESSION_GONE_HORIZON`, 1h by default).
6
6
  - `/fork`, `/branch`, `/handoff` and any other switch that carries the transcript read the role the previous session id held and move it to the new id while the new session starts. `/new` and `/resume` install an unrelated transcript and carry nothing.
7
- - A holder that has not registered for longer than the live window (`ENVOY_SESSION_LIVE_WINDOW`, 5m by default) reads `unresponsive`, and keeps its role: a role publish to it is refused `404 holder_lapsed`, which names the holder, its `holder_state`, its `last_seen` and `claim_released: false`, and nothing is forwarded and nothing kept. An unresponsive holder is not dead, so hold the message and publish it again later, start no replacement for that session, and take nothing from it. Only the role-claim reaper releases a claim, once the holder is `gone`; from then Envoy keeps each role publish for the session that claims the role next, and the answer says it was kept, until that transcript resumes or another session claims the role. A client that stops cleanly deregisters its own session and sends its client instance id, and the listener removes the registration only when the registration carries the same id or none, so a departing client never removes a registration another process made under the same session id.
7
+ - A holder that has not registered for longer than the live window (`ENVOY_SESSION_LIVE_WINDOW`, 5m by default) reads `unresponsive`, and keeps its role. Envoy keeps a role publish to it for one hour and answers that it kept it, with `kept_reason: holder_lapsed`, the holder, its `holder_state`, its `last_seen` and `kept_until`, the time that hour ends. The next session to hold the role live in that hour gets the message: the holder when it answers again, or a session that claims the role. If no session takes it by `kept_until`, Envoy drops it, and when your publish named your session, sends your session a message that names it, unless it dropped it more than an hour late. An unresponsive holder is not dead, so start no replacement for that session and take nothing from it. Only the role-claim reaper releases a claim, once the holder is `gone`. A client that stops cleanly deregisters its own session and sends its client instance id, and the listener removes the registration only when the registration carries the same id or none, so a departing client never removes a registration another process made under the same session id.
8
8
  - A role message the listener forwarded to your session while you held the role is kept on your inbox in the stream, which your own durable consumer reads, so your session gets it once after a resume or a reconnect within 72 hours, also when the role moved to another session in the meantime.
9
9
  - An automatic reclaim never steals. It is a soft claim, which the listener grants when the role is unheld, when its holder is not `live` — `gone`, or `unresponsive` past the live window, which is how a relaunched Legion role recovers it — and when its holder is the id this session continues (a fork's parent) and that predecessor is this client instance's: the predecessor is not `live`, or its live registration carries this instance's own id, or one of the two sides carries no instance id. A client instance is one Oh My Pi Envoy extension instance, or one Claude Code channel-server process; each mints its id when it starts. Any other `live` session keeps the role — the parent of a `/fork` whose role moved to the child, a second process on the same transcript, a named predecessor another client instance still runs — and the listener refuses atomically, naming that holder, while the resumed session logs a warning and holds nothing.
10
10
  - A refusal does not stop the session. The session keeps running, and it stays registered, but without the role. It does not claim again at each heartbeat. The Oh My Pi plugin takes the role at its next session event, once the holder is no longer live. The Claude Code channel takes the role at an explicit claim. Use `envoy_role_get` to read who holds the role now.
@@ -63,6 +63,7 @@ import {
63
63
  EnvoyToolOperation,
64
64
  envoyToolSpecs,
65
65
  publishConfirmationText,
66
+ publishResultDetails,
66
67
  sendConfirmationText,
67
68
  sessionsOnMachine,
68
69
  type ToolArgumentsByOperation,
@@ -1859,19 +1860,14 @@ export async function executeEnvoyTool(
1859
1860
  })
1860
1861
  // The answer the model reads, its line first: the counts of a stored topic's answer, a role
1861
1862
  // holder, or a kept answer, which is a success of its own, all in the words the Oh My Pi
1862
- // plugin uses (`publishConfirmationText`).
1863
+ // plugin uses (`publishConfirmationText`). This server always names its own session as the
1864
+ // source, so the listener sends that session a message for a kept copy no session took,
1865
+ // unless it drops the copy more than an hour late, and the line says so.
1863
1866
  return {
1864
- message: publishConfirmationText(result),
1867
+ message: publishConfirmationText(result, { senderNamed: true }),
1865
1868
  event_id: result.envelope.event_id,
1866
1869
  topic: result.envelope.topic,
1867
- ...(result.holder === undefined ? {} : { holder: result.holder }),
1868
- ...(result.holderState === undefined ? {} : { holder_state: result.holderState }),
1869
- ...(result.recipients === undefined ? {} : { recipients: result.recipients }),
1870
- ...(result.recipientsConnected === undefined
1871
- ? {}
1872
- : { recipients_connected: result.recipientsConnected }),
1873
- ...(result.kept === undefined ? {} : { kept: result.kept }),
1874
- ...(result.keptReason === undefined ? {} : { kept_reason: result.keptReason }),
1870
+ ...publishResultDetails(result),
1875
1871
  }
1876
1872
  }
1877
1873
  case EnvoyToolOperation.subscribe: {