@sjawhar/claude-envoy 2.31.5 → 2.32.1

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.
Files changed (37) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/.omp-plugin/plugin.json +1 -1
  3. package/dist/dispatch.js +9 -3
  4. package/dist/envoy-channel.js +42 -16
  5. package/legion/agents/plan-reviewer.md +5 -1
  6. package/legion/skills/legion-architect/SKILL.md +4 -3
  7. package/legion/skills/legion-architect/references/acceptance.md +14 -4
  8. package/legion/skills/legion-architect/references/decomposition.md +4 -3
  9. package/legion/skills/legion-architect/references/design-gate.md +24 -5
  10. package/legion/skills/legion-controller/references/daily-report.md +2 -2
  11. package/legion/skills/legion-controller/references/finding-asks.md +12 -9
  12. package/legion/skills/legion-controller/references/session.md +2 -1
  13. package/legion/skills/legion-controller/references/slack-mentions.md +2 -2
  14. package/legion/skills/legion-controller/references/triage.md +2 -2
  15. package/legion/skills/legion-controller/references/wakes.md +2 -2
  16. package/legion/skills/legion-oracle/SKILL.md +6 -4
  17. package/legion/skills/legion-retro/SKILL.md +9 -3
  18. package/legion/skills/legion-worker/SKILL.md +14 -12
  19. package/legion/skills/legion-worker/references/ci-checks.md +20 -3
  20. package/legion/skills/legion-worker/references/conflicts-and-rewrites.md +12 -40
  21. package/legion/skills/legion-worker/references/findings.md +11 -11
  22. package/legion/skills/legion-worker/references/merge-gate.md +31 -30
  23. package/legion/skills/legion-worker/references/plan-tests.md +40 -0
  24. package/legion/skills/legion-worker/references/pr-body.md +31 -10
  25. package/legion/skills/legion-worker/references/tools.md +6 -6
  26. package/legion/skills/legion-worker/references/withheld-capability.md +9 -5
  27. package/legion/skills/simplify-settled-diff/SKILL.md +1 -1
  28. package/package.json +1 -1
  29. package/skills/agent-secrets/SKILL.md +5 -3
  30. package/skills/dispatch-first/SKILL.md +1 -1
  31. package/skills/dispatch-writing-specs/SKILL.md +2 -2
  32. package/skills/envoy/SKILL.md +8 -5
  33. package/skills/envoy/references/deliveries.md +2 -1
  34. package/skills/envoy/references/legion.md +10 -1
  35. package/skills/envoy/references/roles.md +1 -1
  36. package/skills/plain-words/SKILL.md +1 -1
  37. package/src/envoy-channel-server.ts +6 -10
@@ -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.5"
5
+ "version": "2.32.1"
6
6
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-envoy",
3
- "version": "2.31.5",
3
+ "version": "2.32.1",
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.5";
57479
+ var version2 = "2.32.1";
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: {
@@ -37,6 +37,10 @@ it out without getting stuck? You find blockers, not improvements.
37
37
  covers. Where a spec's own parts disagree on the scope of the goal, that is the owner's to
38
38
  settle: reject, and say so. Never "approve when in doubt" here: doubt is a rejection that
39
39
  says what is unclear.
40
+ 7. **Tests named before code.** Each requirement clause has a test row, and a requirement of one
41
+ of the four kinds in the reference the caller carries, `legion-worker/references/plan-tests.md`,
42
+ has its inventory test, fixtures, state table or list of readers and writers before any task
43
+ that writes code. A clause with no row, or a kind with no list, is a rejection that names it.
40
44
 
41
45
  You do not judge whether the approach is the best one, style, naming, edge cases the engineer can
42
46
  settle during the work, or anything you would simply do differently.
@@ -46,7 +50,7 @@ settle during the work, or anything you would simply do differently.
46
50
  Approve when in doubt. A plan that is mostly clear is good enough. Reject only for a blocker: a
47
51
  reference that does not exist or does not hold what the plan says (read to confirm), a task with
48
52
  nowhere to start, a contradiction, a requirement no task serves, a check no task makes pass, a
49
- check marked `after_merge` that could run before the merge, or check 6.
53
+ check marked `after_merge` that could run before the merge, check 6, or check 7.
50
54
 
51
55
  A rejection names at most three blocking issues, the most severe first. Each gives:
52
56
 
@@ -7,7 +7,7 @@ description: "Use when you are a Legion root or sub-architect: decomposing child
7
7
 
8
8
  If this skill disagrees with the code, a command's output or its `--help`, follow those and say which line of this skill is wrong.
9
9
 
10
- You own one issue tree from its first decision to the merge that closes it. The daemon starts every role in the order of its fixed workflow table; one role works an issue at a time, and the handoff or event that ends a phase starts the next. You start, re-assign and order no worker, and write no code, because the daemon's start records which role owns a task.
10
+ You own one issue tree from its first decision to the merge that closes it. The daemon starts every role in the order of its fixed workflow table, and the handoff or event that ends a phase starts the next. One role holds the issue's phase at a time, and every role that has a session may work beside it and tell the role whose phase it is what it finds: for example, the reviewer reads each push as it lands, and the tester tries an intermediate build. You can ask them to. A role has no session before its first assignment, so in an issue's first round the reviewer and the tester do not exist yet. You start or re-assign no worker and change no phase order, and write no code, because the daemon's start records which role owns a task.
11
11
 
12
12
  ## Every turn
13
13
 
@@ -31,7 +31,7 @@ An answered root stands in the admission line until the pass that resumes it, an
31
31
  - A child may wait on a sibling's merge in the same repository: release it with `--blocked-by` that sibling, and Legion holds it until the sibling is `done`.
32
32
  - A child that duplicates another issue and is not yet released is never released: fold it by the duplicate rule of `skill://dispatch-first`. The daemon records a child at its release and re-asserts a status only on an issue it has recorded, so that close stands. A released duplicate goes out with `park_child` instead, because its work is folded into the issue you keep. Move an issue to `backlog`, `icebox` or `triage` only when a person asked for that move, or when the work is done, folded into another issue or no longer needed, and cite that reason in a comment on the issue: for a duplicate, name the issue you keep in a `dispatch comment` on the child.
33
33
  - Every child names the running system its criteria are proven on (the command, service or page the tester drives) and the repository skill that drives it. If the repository cannot exercise a criterion end to end, building that path is work of this tree.
34
- - The issue's primary document is the root spec: extend it in place, because a second "spec" artifact replaces the human's document. Mark each requirement of it as a `requirement` block, and write the issue's Verification document (`verification.md`) beside it: one `check` block per thing to be proved, each with `serves` naming the requirements it serves, its `surface` (`browser`, `cli` or `api`), `run`, `when` (`before_merge`, `after_merge` or `default_branch`) and `negative_control`. A check carrying `ci_check` is CI's: it names the CI check run that proves it and takes no `run` (`skill://legion-architect/references/design-gate.md#a-check-ci-proves`). Where a CI job that runs on an ordinary pull request already makes a check's proof, write `ci_check` rather than a command. The checks are the gate every later role reads: the implementer and the tester record a result against each check with no `ci_check`, and the reviewer approves only once a pass stands for every `before_merge` check at the head. The decomposition's order and the plan's tasks go in the children and the planner's `plan` handoff, not the root spec.
34
+ - The issue's primary document is the root spec: extend it in place, because a second "spec" artifact replaces the human's document. Mark each requirement of it as a `requirement` block, and write the issue's Verification document (`verification.md`) beside it: one `check` block per thing to be proved, each with `serves` naming the requirements it serves, its `surface` (`browser`, `cli` or `api`), `run`, `when` (`before_merge`, `after_merge` or `default_branch`) and `negative_control`. A check carrying `ci_check` is CI's: it names the CI check run that proves it and takes no `run` (`skill://legion-architect/references/design-gate.md#a-check-ci-proves`). Where a CI job that runs on an ordinary pull request already makes a check's proof, write `ci_check` rather than a command. A check that a whole test suite proves names the CI job that runs that suite, and a `run` that names tests names specific tests or files. The checks are the gate every later role reads: the implementer and the tester record a result against each check with no `ci_check`, and the reviewer approves only once a pass stands for every `before_merge` check at the head. The decomposition's order and the plan's tasks go in the children and the planner's `plan` handoff, not the root spec.
35
35
  - Before you write a design, state the problem to `task(agent="design-outsider")` and read its answer with `wait`. The brief holds the problem statement and the design principles, and no design of your own. The four questions are where the proposal is stupid, whether the thing in question should exist at all, what the smallest thing that gives the person what they asked for is, and what to delete. Record the answer in a comment on the issue, or in the issue's `plan.md` where one exists, before any action that states or favours a design, and give your reason where you do not follow it. Run the step once per design: at the first design of an issue, and again when a push-back or a review changes what the design is for. It is a challenge, never a gate.
36
36
  - Read `skill://legion-architect/references/design-gate.md` before you write the root spec and before any edit to it after approval, because any new version closes the gate. It also names the design gate steps your `Legion addressing` line declares, the document each step records, and says that a sub-architect runs none.
37
37
  - **Show the surface before you ask.** Where this tree builds or changes a surface a person opens — a page, a screen, a dashboard — that person sees it and answers before you ask them to approve the spec, because they refuse a spec for a surface they have not seen. Whether a change needs that is your judgement, and a large visual change wants a page they can click rather than a picture. The readings, the round and where the pictures end up: `skill://legion-architect/references/design-gate.md`, "Show the surface before you ask". A change whose only reader surface is text carries that literal text in the spec instead; a change with no reader surface carries neither.
@@ -54,10 +54,11 @@ Your issue's own first phase does not start while Dispatch shows an open child u
54
54
 
55
55
  - Prove every criterion of your issue in its own pull request, never in a child: a child that proves its parent defers the tree's own verification. Its last round: `skill://legion-architect/references/acceptance.md`, "The last round".
56
56
  - Read the issue's own tester evidence, not a child pull request's check status. A failed check goes back to its implementer by the daemon's table; a fix that belongs in other work follows section 1's sizing reasons and red-team check. Never downgrade a parent criterion or carry the failure forward.
57
+ - While the work is built, a role runs the application from the issue's branch and uses it as its user would: a passing check does not show that a person can do their job with it. Where the work is a page or a tool a person uses, offer the person it is for a running build before the review, because a change they ask for then costs less than one after it. The deployment's instructions say how a pod runs one.
57
58
 
58
59
  ## 5. Retro
59
60
 
60
- Your `sign_off` starts retro; never `envoy_publish` to the implementer to start it. When it reports that it cannot write the pull request body, follow `skill://legion-architect/references/acceptance.md`.
61
+ Your `sign_off` starts retro; never `envoy_publish` to the implementer to start it. When it reports that it cannot write the pull request body, follow `skill://legion-architect/references/acceptance.md`. A retro that finds a defect in the work reports it to you and holds its completion until you answer, because the move back is open only while retro holds the phase: answer it, and say whether it moves the issue back.
61
62
 
62
63
  ## 6. Acceptance and the merge
63
64
 
@@ -119,11 +119,15 @@ The daemon keeps this order from its fixed table; you start none of its steps:
119
119
  issue and no commit carries one.
120
120
  4. The merger reads the pull request and merges that head itself, as the implement App and with the
121
121
  head it read as the head GitHub must match
122
- (`gh pr merge <n> --squash --match-head-commit <head> --subject '<pull request title> (#<n>)' --body ''`,
122
+ (into the default branch
123
+ `gh pr merge <n> --squash --match-head-commit <head> --subject '<pull request title> (#<n>)' --body ''`,
123
124
  whose explicit message keeps GitHub's default squash message from joining the branch's commit
124
- messages onto the base; or `expectedHeadOid` on a
125
- merge-queue base, where it enqueues the pull request); it never turns auto-merge on, and the
126
- daemon submits no merge and changes no merge setting. The repository's required reviews and
125
+ messages onto the base; into another base, a merge commit (`--merge` in place of `--squash`)
126
+ where the repository allows one, because a squash there gives each pull request built on that
127
+ branch a conflict of history alone; or `expectedHeadOid` on a merge-queue base, where it
128
+ enqueues the pull request); it
129
+ never turns auto-merge on, and the daemon submits no merge and changes no merge setting. The
130
+ repository's required reviews and
127
131
  checks decide when it lands; Legion neither reads nor writes those rules, and a review only a
128
132
  person can give is waited for, never bypassed. Nothing compares that head with the approved one:
129
133
  a repository that wants a later push reviewed says so in its own rulesets. The merger's
@@ -144,6 +148,12 @@ move and you tell it which; from `accepting` you send an issue back only to `imp
144
148
  `squash_merge_commit_message` joins the branch's commit messages among them: the merger tells
145
149
  you, and only a person can change it. Ask one with `dispatch ask`, naming the pull request, the
146
150
  head and GitHub's refusal; never bypass a rule.
151
+ - A squash into a base other than the default branch, where the repository allows only squash or
152
+ the base's rules require a linear history: the merger names each open pull request of the tree
153
+ built on the merged branch. Each one GitHub then reports `CONFLICTING` comes back to
154
+ `implementing` (*A conflicting head*, below). Tell each one's implementer (`envoy_publish` to its
155
+ role topic) to expect its pull request back, and to merge that base forward in that implementing
156
+ round.
147
157
 
148
158
  ## A conflicting head
149
159
 
@@ -124,9 +124,10 @@ name the merged commit. Read the other repositories with your gh's read-only acc
124
124
 
125
125
  ## Recording a wait on other work
126
126
 
127
- Set an issue's `blocked_by` list when its work must wait on an issue outside this tree
128
- (`dispatch issue-update --issue <key> --blocked-by <a> --blocked-by <b>`, which replaces the whole
129
- list, so read the issue's existing links first).
127
+ Set an issue's `blocked_by` list when its work must wait on an issue outside this tree, of any
128
+ Dispatch project (`dispatch issue-update --issue <key> --blocked-by <a> --blocked-by <b>`, which
129
+ replaces the whole list, so read the issue's existing links first); Dispatch refuses a link to
130
+ another project's issue only to a credential that names one project (`PROJECT_SCOPE`).
130
131
  That list is how Legion learns of the wait.
131
132
  An issue the daemon has already started returns its admission slot while a blocker of it is not
132
133
  `done`, so the deployment's cap goes to work that can move,
@@ -28,6 +28,17 @@ reviewer approves only once a pass stands for every `before_merge` check at the
28
28
  check's own answer in `dispatch results --issue <issue>`, and never a pass at another commit, a
29
29
  pass recorded under an older wording of the check or a retracted one.
30
30
 
31
+ A check proves only the clauses that something drove, so each clause of its `negative_control`
32
+ names the test row or the run that drives it. A check of a requirement over every member of a
33
+ class iterates that class's list as data, never a sample of it: a sample passes while a member it
34
+ left out is broken.
35
+
36
+ Where a real recorded input exists for the work (a stored record, a captured log, an answer the
37
+ real service gave), the Verification document holds at least one read-only check against it,
38
+ because a fixture written for the test proves only what its author expected; where no such check
39
+ can be written, a decision block says why. A requirement of the form "try X and see" is an
40
+ experiment, and its acceptance is a real run that someone observed.
41
+
31
42
  On your first pass over the spec, cut each requirement carried over from an earlier issue's spec or
32
43
  decisions that no source of this issue states: those were decided for that issue. This issue's
33
44
  sources are the words a person wrote in it, and its `Filed for` line with what that line cites: the
@@ -42,19 +53,27 @@ at the head, and the check takes no `run`. Its `when` is `before_merge`, and it
42
53
  `negative_control`. No role runs it or records a result for it. `dispatch results` derives its
43
54
  one result from the named run (`skill://legion-worker/references/ci-checks.md`). Where a CI job
44
55
  that runs on an ordinary pull request already makes a check's proof, write that check as
45
- `ci_check` rather than as a command. Write such a check by three rules:
56
+ `ci_check` rather than as a command. A check that a whole test suite proves names the CI job that
57
+ runs that suite as its `ci_check`, and a check's `run` that names tests names specific tests or
58
+ files, never a package path, a `./...` pattern or a package's whole `test` script: CI proves a
59
+ suite on the pull request and the merge queue on the merged tree, and a suite run in a pod repeats
60
+ that work slower. Any other `run` is the procedure a role drives on the check's surface.
61
+ Write a `ci_check` check by three rules:
46
62
 
47
63
  1. Name the check run of the job that runs the proof, never a roll-up run that stands for other
48
64
  jobs. A roll-up run can pass at a head where the job of the check did not run.
49
- 2. Name no job that the repository holds back from an ordinary pull request. Such a job gives no
50
- pass at any head the reviewer reads, so its proof stays a check with a `run`.
65
+ 2. Name a job that the repository holds back from an ordinary pull request too, because a `run` in
66
+ its place leaves the pod as the only place its proof runs. The worker adds the label that runs
67
+ the held-back jobs at the head, and the tester takes the result from that run. Without the
68
+ label such a job reads `skipped`, so the label stays on for as long as a check of the issue
69
+ names a held-back job, and each later head gets its own run.
51
70
  3. Write in `negative_control` the case inside that job that fails when the property breaks. A
52
71
  job's conclusion is not the property: a step with `continue-on-error` keeps its job green,
53
72
  and a test deleted from a suite takes its failure with it.
54
73
 
55
74
  On cybermonklabs/legion: `ci-ok` passes when the jobs it did not select were skipped
56
- (`.github/scripts/ci-ok.sh`), so never name `ci-ok`. Eight slow suites and the full browser lane
57
- run only in the merge queue or under `full-ci`.
75
+ (`.github/scripts/ci-ok.sh`), so never name `ci-ok`. The slow suites and the full browser lane
76
+ run only in the merge queue or under `full-ci`, the label of rule 2 (`AGENTS.md`).
58
77
 
59
78
  ## Show the surface before you ask
60
79
 
@@ -36,8 +36,8 @@ Each time you read it:
36
36
  `withdrawn`; a reopen brings them back), and Dispatch refuses an ask there
37
37
  (`409 ISSUE_CLOSED`). Reopen it with `set_status` to `icebox`, where the issue holds no work
38
38
  and its asks stay answerable, and say so in the day's report.
39
- - `Assignee: unassigned` with a person known: assign it, naming your session (`dispatch whoami`):
40
- `curl -sS -X PATCH -H "Authorization: Bearer $(cat "$DISPATCH_TOKEN_FILE")" -H 'Content-Type: application/json' -d '{"assignee": "<email>", "actor": {"kind": "session", "id": "<session id>"}}' "$DISPATCH_URL/api/v1/issues/<REPORT KEY>"`.
39
+ - `Assignee: unassigned` with a person known: assign it, naming your session (`dispatch whoami`), in bash:
40
+ `curl -sS -X PATCH -H @<(printf 'Authorization: Bearer %s' "$(< "$DISPATCH_TOKEN_FILE")") -H 'Content-Type: application/json' -d '{"assignee": "<email>", "actor": {"kind": "session", "id": "<session id>"}}' "$DISPATCH_URL/api/v1/issues/<REPORT KEY>"`.
41
41
  An answer that does not print the issue with its new `assignee` left the assignee as it was
42
42
  (`400 ASSIGNEE_NOT_ALLOWED` names an email nobody has signed in to Dispatch with): name it, with
43
43
  its first line, in your summary.
@@ -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
 
@@ -149,10 +152,10 @@ finding asks roles opened on their own issues while no controller ran:
149
152
  reply `Moved dispatch://<REPORT KEY>/ask/<new id>` under the old ask. Resolve the old ask once it
150
153
  carries a `Moved`, `Handed` or `Filed` reply. A clear defect no holder took stays open, and the
151
154
  next start takes it again.
152
- 3. List the answered asks still waiting on you, which no `dispatch` command lists:
155
+ 3. List the answered asks still waiting on you, which no `dispatch` command lists, in bash:
153
156
 
154
157
  ```text
155
- asks=$(curl -sS --fail-with-body -H "Authorization: Bearer $(cat "$DISPATCH_TOKEN_FILE")" "$DISPATCH_URL/api/v1/issues/<ISSUE KEY>/asks?state=answered&thread=1") || { echo "Dispatch read failed" >&2; exit 1; }
158
+ asks=$(curl -sS --fail-with-body -H @<(printf 'Authorization: Bearer %s' "$(< "$DISPATCH_TOKEN_FILE")") "$DISPATCH_URL/api/v1/issues/<ISSUE KEY>/asks?state=answered&thread=1") || { echo "Dispatch read failed" >&2; exit 1; }
156
159
  printf '%s' "$asks" | jq -cn 'input | if type == "array" then [.[] | select(any(.options[]; .label == "Do not file" or .label == "Admit it" or .label == "Park it" or .label == "Leave it admitted" or .label == "Defer it" or .label == "Let it run")) | .answer.at as $t | select([.thread.replies[]? | select(.author.kind == "session" and .created_at > $t and (.body | test("^(Filed dispatch://|Handed dispatch://|Admitted dispatch://|Not filed:|Not admitted:|Parked dispatch://|Not parked dispatch://|Left admitted dispatch://|Deferred dispatch://|Not deferred dispatch://|Let run dispatch://)")))] | length == 0) | {id, question, answer}] else error("Dispatch did not answer the list") end'
157
160
  ```
158
161
 
@@ -172,10 +175,10 @@ finding asks roles opened on their own issues while no controller ran:
172
175
  4. List the clear defects nobody took yet: each evidence comment whose first line starts
173
176
  `Clear defect from `, with no session reply under it that starts `Handed dispatch://`,
174
177
  `Filed dispatch://`, `Not filed:` or `Asked dispatch://` (a role that asked instead, which step
175
- 2 takes):
178
+ 2 takes), in bash:
176
179
 
177
180
  ```text
178
- notes=$(curl -sS --fail-with-body -H "Authorization: Bearer $(cat "$DISPATCH_TOKEN_FILE")" "$DISPATCH_URL/api/v1/issues/<REPORT KEY>/comments") || { echo "Dispatch read failed" >&2; exit 1; }
181
+ notes=$(curl -sS --fail-with-body -H @<(printf 'Authorization: Bearer %s' "$(< "$DISPATCH_TOKEN_FILE")") "$DISPATCH_URL/api/v1/issues/<REPORT KEY>/comments") || { echo "Dispatch read failed" >&2; exit 1; }
179
182
  printf '%s' "$notes" | jq -cn 'input | if type == "array" then (. as $all | [.[] | select(.reply_to == null and (.body | startswith("Clear defect from "))) | .id as $id | select([$all[] | select(.reply_to == $id and .author.kind == "session" and (.body | test("^(Handed dispatch://|Filed dispatch://|Not filed:|Asked dispatch://)")))] | length == 0) | {id, body}]) else error("Dispatch did not answer the list") end'
180
183
  ```
181
184
 
@@ -80,7 +80,8 @@ of the three. Text of any other shape is never a command argument: report
80
80
  Each `curl` in these references reads `DISPATCH_URL` and `DISPATCH_TOKEN_FILE`. `legion controller
81
81
  start` sets them only when `controller.yaml` names `dispatch_url`; the daemon's pod sets
82
82
  `DISPATCH_URL` when the daemon has one. When they are unset, every `curl` fails: act on nothing it
83
- would decide and name it in your summary.
83
+ would decide and name it in your summary. Each passes its token as a header file (`-H @<(…)`), so
84
+ that no process's arguments hold it: run it in bash, because `sh` refuses that form.
84
85
 
85
86
  ## Taking the controller over by hand
86
87
 
@@ -43,9 +43,9 @@ alone. Read the whole thread before you decide what the person wants. The read i
43
43
  (`skill://agent-secrets`):
44
44
 
45
45
  ```sh
46
- agent-secrets LEGION_SLACK_BOT_TOKEN --reason 'read the thread of a Slack mention' --wait 0s -- sh -c '
46
+ agent-secrets LEGION_SLACK_BOT_TOKEN --reason 'read the thread of a Slack mention' --wait 0s -- bash -c '
47
47
  curl -sS -G https://slack.com/api/conversations.replies \
48
- -H "Authorization: Bearer $LEGION_SLACK_BOT_TOKEN" \
48
+ -H @<(printf "Authorization: Bearer %s" "$LEGION_SLACK_BOT_TOKEN") \
49
49
  --data-urlencode channel=<channel_id> \
50
50
  --data-urlencode ts=<thread_ts> \
51
51
  --data-urlencode limit=200'
@@ -29,8 +29,8 @@ Read this on a `triage` wake, at every start, and when a person hands you an iss
29
29
  leave it. Note its `Assignee:`: that person answers the tree's asks, because their Inbox opens on the
30
30
  issues they hold. Never reassign it, because who holds an issue is the people's decision, made
31
31
  from the issue header.
32
- 2. Find who set the label. `dispatch read` does not show who set a label, so list its events:
33
- `curl -sS -H "Authorization: Bearer $(cat "$DISPATCH_TOKEN_FILE")" "$DISPATCH_URL/api/v1/issues/<issue>/events?limit=200"`,
32
+ 2. Find who set the label. `dispatch read` does not show who set a label, so list its events in bash:
33
+ `curl -sS -H @<(printf 'Authorization: Bearer %s' "$(< "$DISPATCH_TOKEN_FILE")") "$DISPATCH_URL/api/v1/issues/<issue>/events?limit=200"`,
34
34
  oldest first, 200 a page. When a page holds 200 events, read the next with
35
35
  `&after=<the last event's seq>` until a page holds fewer: the setter is the newest transition,
36
36
  and the daemon reads the whole log. The event that added the label set it, and its `actor` is
@@ -256,10 +256,10 @@ at every run, while the text of `<cause>` can change from one run to the next. T
256
256
  admitted and keeps working while you ask ([Admission and the `legion` label](https://cybermonklabs.github.io/legion/legion/concepts/#admission-and-the-legion-label)). A comment or a reply from any session counts as yours
257
257
  here, because the controller's session id changes when it restarts or is taken over.
258
258
 
259
- 1. Look for the ask you opened for this key already. List the root's comments that name an ask:
259
+ 1. Look for the ask you opened for this key already. List the root's comments that name an ask, in bash:
260
260
 
261
261
  ```text
262
- notes=$(curl -sS --fail-with-body -H "Authorization: Bearer $(cat "$DISPATCH_TOKEN_FILE")" "$DISPATCH_URL/api/v1/issues/<root>/comments") || { echo "Dispatch read failed" >&2; exit 1; }
262
+ notes=$(curl -sS --fail-with-body -H @<(printf 'Authorization: Bearer %s' "$(< "$DISPATCH_TOKEN_FILE")") "$DISPATCH_URL/api/v1/issues/<root>/comments") || { echo "Dispatch read failed" >&2; exit 1; }
263
263
  printf '%s' "$notes" | jq -cn 'input | if type == "array" then [.[] | select(.author.kind == "session" and (.body | startswith("Asked whether to park: "))) | {id, created_at, body}] else error("Dispatch did not answer the list") end'
264
264
  ```
265
265
 
@@ -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
@@ -33,8 +33,12 @@ would put a commit above the head the reviewer approved.
33
33
  When a step fails (the body cannot be computed, read or written, or Dispatch refuses a write), do
34
34
  not call `handoff_complete`. Report it with `envoy_publish` to the architect's
35
35
  topic in the `Legion addressing` line of your system prompt, with the command and its output. A
36
- check with no pass standing at the head goes back as step 1 says. The Dispatch message (step 5) is
37
- for a finished retro only.
36
+ check with no pass standing at the head goes back as step 1 says. A defect you find in the work at
37
+ any other step goes to the architect with its evidence, and you hold your completion until the
38
+ architect answers: while retro holds the phase, `request_backward_move` is yours to make, and your
39
+ `handoff_complete` moves the issue to `merging`, which takes that move from you. End each turn of
40
+ that hold with a WAITING line naming the defect and the architect's answer you wait on. The
41
+ Dispatch message (step 5) is for a finished retro only.
38
42
 
39
43
  ## Steps
40
44
 
@@ -53,7 +57,9 @@ for a finished retro only.
53
57
  fail, or its run concluded `skipped`, `neutral` or `cancelled`. Wait for a run that has not
54
58
  concluded, and read again where GitHub could not be read. Send a name that no run answers
55
59
  (`absent`) to the architect as a finding, because the words of the check are wrong. Neither
56
- wait nor that finding moves the issue back. When a check has no pass standing at that head, or
60
+ wait nor that finding moves the issue back. A check whose `run` is a whole test suite has wrong
61
+ words too: send it to the architect the same way, and it moves the issue back no more than that
62
+ finding does. When any other check has no pass standing at that head, or
57
63
  a check with no `ci_check` has a unit suite as its only evidence, call the `legion` tool's
58
64
  `request_backward_move` with `to: implementing` for the implementer's result or a `ci_check`
59
65
  check, or `to: testing` for the tester's result, its `reason` naming the check by its block