@sjawhar/claude-envoy 2.5.0 → 2.7.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.
Files changed (26) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/.omp-plugin/plugin.json +1 -1
  3. package/AGENTS.md +13 -3
  4. package/dist/envoy-channel.js +84 -28
  5. package/legion/skills/legion-architect/SKILL.md +2 -2
  6. package/legion/skills/legion-architect/references/acceptance.md +53 -54
  7. package/legion/skills/legion-architect/references/design-gate.md +14 -8
  8. package/legion/skills/legion-architect/references/wake-routing.md +7 -16
  9. package/legion/skills/legion-controller/SKILL.md +17 -4
  10. package/legion/skills/legion-controller/references/admission.md +5 -6
  11. package/legion/skills/legion-controller/references/backlog-stewardship.md +3 -4
  12. package/legion/skills/legion-controller/references/escalation.md +8 -7
  13. package/legion/skills/legion-controller/references/finding-asks.md +1 -1
  14. package/legion/skills/legion-controller/references/session.md +1 -1
  15. package/legion/skills/legion-controller/references/slack-mentions.md +1 -1
  16. package/legion/skills/legion-controller/references/triage.md +1 -1
  17. package/legion/skills/legion-controller/references/wakes.md +6 -4
  18. package/legion/skills/legion-retro/SKILL.md +13 -19
  19. package/legion/skills/legion-worker/SKILL.md +12 -8
  20. package/legion/skills/legion-worker/references/conflicts-and-rewrites.md +3 -3
  21. package/legion/skills/legion-worker/references/merge-gate.md +110 -151
  22. package/legion/skills/legion-worker/references/pr-body.md +15 -14
  23. package/legion/skills/legion-worker/references/review-threads.md +4 -4
  24. package/package.json +2 -2
  25. package/src/legion-phase-hook.ts +25 -11
  26. package/legion/skills/legion-architect/references/merge-notices.md +0 -104
@@ -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.5.0"
5
+ "version": "2.7.0"
6
6
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-envoy",
3
- "version": "2.5.0",
3
+ "version": "2.7.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/AGENTS.md CHANGED
@@ -171,9 +171,19 @@ settles the machine: the first reminder of a run comes back as
171
171
  `{"decision":"block","reason":<the reminder>}`, which Claude Code turns into one more turn of the
172
172
  same session, and it is the only one of that run; every later one is written into the session over
173
173
  the bridge's inbox from a timer, because a line written while a turn runs is appended to that turn
174
- and the run would never settle for the daemon. `StopFailure` (the turn ended on an API error, and
175
- Claude Code ignores whatever the hook returns) settles with `canContinue: false`, so the machine
176
- arms that timer for the reminder instead. `PostToolUse` and `PostToolUseFailure` are the worker
174
+ and the run would never settle for the daemon. `StopFailure` runs instead of `Stop` when the turn
175
+ ended on an API error ("Hooks reference", code.claude.com/docs/en/hooks), and its
176
+ `${last_assistant_message}` is then the error text itself, not what the worker said: that is the
177
+ provider refusing the turn, so the machine takes it as `refused`: it earns no continuation, since
178
+ continuing into another turn at once would only buy another refusal, which is what left
179
+ dispatch://INFRA-264's implementer reminded for ever.
180
+ It does arm one timer, because the task that refused turn carried ended with it and nothing else
181
+ would wake this worker, so one transient refusal would leave the issue idle.
182
+ Claude Code ignores whatever this hook returns, which now costs nothing. What ends a session the provider keeps refusing is the daemon: the bridge reports each
183
+ turn's outcome to `POST /legion/v1/claims/turn-outcome` and the daemon fails the claim once the
184
+ trailing run of refusals reaches `launch_failure_limit`, and the runner's record check then drops
185
+ every reminder, since a failed claim is replaced by a retry in a session of its own.
186
+ `PostToolUse` and `PostToolUseFailure` are the worker
177
187
  working, which puts the count back to zero; a non-empty `${agent_id}` is a subagent's
178
188
  call and is ignored. `UserPromptSubmit` is this server's only sight of an inbound turn — the
179
189
  daemon's task reaches Claude Code's stdin from the bridge, never this process — so it declares the
@@ -52644,7 +52644,6 @@ var LEGION_WORKFLOW_PHASES = [
52644
52644
  "accepting",
52645
52645
  "retro",
52646
52646
  "merging",
52647
- "awaiting_merge",
52648
52647
  "integrating",
52649
52648
  "done",
52650
52649
  "held"
@@ -52658,7 +52657,6 @@ var LEGION_PHASE_BACKWARD_TARGETS = [
52658
52657
  "accepting",
52659
52658
  "retro",
52660
52659
  "merging",
52661
- "awaiting_merge",
52662
52660
  "done",
52663
52661
  "held"
52664
52662
  ];
@@ -52751,6 +52749,11 @@ var legionClaimView = object({
52751
52749
  updateReasons: nonEmptyString2.optional(),
52752
52750
  providerErrorRun: number2().int().positive().optional(),
52753
52751
  pendingTask: legionPendingTaskView.optional(),
52752
+ lastTurnStart: timestamp.optional(),
52753
+ lastTurnEnd: timestamp.optional(),
52754
+ lastDeathCause: nonEmptyString2.optional(),
52755
+ lastStartFailure: nonEmptyString2.optional(),
52756
+ lastReady: timestamp.optional(),
52754
52757
  step: legionStepView.optional(),
52755
52758
  failure: legionClaimFailureView.optional(),
52756
52759
  pendingCause: legionFailureCause.optional()
@@ -52763,6 +52766,7 @@ var legionPhaseView = object({
52763
52766
  claim: legionClaimView,
52764
52767
  handoffCommit: nonEmptyString2.optional(),
52765
52768
  handoffRecord: legionHandoffRecordView.optional(),
52769
+ pass: number2().int().nonnegative(),
52766
52770
  rounds: number2().int().nonnegative(),
52767
52771
  backwardMoves: record(string2(), number2().int().positive()).optional()
52768
52772
  });
@@ -52771,7 +52775,7 @@ var legionPullRequestView = object({
52771
52775
  number: number2().int().positive(),
52772
52776
  head: nonEmptyString2,
52773
52777
  state: _enum2(["open", "merged", "closed"]),
52774
- checksVerdict: nonEmptyString2.optional(),
52778
+ mergeState: _enum2(["clean", "unstable", "has_hooks", "blocked", "dirty", "behind", "draft", "unknown"]).optional(),
52775
52779
  reviewDecision: nonEmptyString2.optional()
52776
52780
  });
52777
52781
  var legionGateView = object({
@@ -52795,7 +52799,21 @@ var legionSlotView = object({
52795
52799
  });
52796
52800
  var legionWaitingLineView = object({
52797
52801
  place: number2().int().positive(),
52798
- length: number2().int().positive()
52802
+ length: number2().int().positive(),
52803
+ part: _enum2(["returned", "starting"]).optional(),
52804
+ kind: _enum2(["returning", "answered", "queued_root", "first_phase"]).optional(),
52805
+ partPlace: number2().int().positive().optional(),
52806
+ partLength: number2().int().positive().optional(),
52807
+ holdsSlot: boolean2().optional(),
52808
+ since: timestamp.optional(),
52809
+ rootRank: nonEmptyString2.optional(),
52810
+ ownRank: nonEmptyString2.optional(),
52811
+ rootKey: issueKey.optional(),
52812
+ reason: nonEmptyString2.optional()
52813
+ });
52814
+ var legionWhyView = object({
52815
+ state: _enum2(["claim_stopped", "waiting", "blocked", "unlisted"]),
52816
+ reason: nonEmptyString2
52799
52817
  });
52800
52818
  var legionCheckWakeView = object({
52801
52819
  kind: nonEmptyString2,
@@ -52886,6 +52904,7 @@ var legionIssue = object({
52886
52904
  gatedSteps: array(legionGatedStepView).optional(),
52887
52905
  slot: legionSlotView.optional(),
52888
52906
  waitingLine: legionWaitingLineView.optional(),
52907
+ why: legionWhyView.optional(),
52889
52908
  waitingOn: legionWaitingOn.optional(),
52890
52909
  check: legionCheckView.optional(),
52891
52910
  memoryGroup: _enum2(["memory", "none"]).optional(),
@@ -52934,6 +52953,7 @@ var legionCapabilityState = object({
52934
52953
  source: _enum2(["configuration", "boot"]).optional()
52935
52954
  });
52936
52955
  var legionSettings = looseObject({
52956
+ review_round_cap: number2().int().positive(),
52937
52957
  worker_boot_timeout_seconds: number2().int().positive()
52938
52958
  });
52939
52959
  var legionCacheView = object({
@@ -53007,6 +53027,30 @@ var LegionReadyRequest = strictObject({
53007
53027
  generation: number2().int().positive(),
53008
53028
  capabilities: LegionCapabilityReport.optional()
53009
53029
  });
53030
+ var turnOutcomeFields = {
53031
+ generation: number2().int().positive(),
53032
+ sequence: number2().int().positive(),
53033
+ outcome: _enum2(["clean", "refused"]),
53034
+ message: string2().optional()
53035
+ };
53036
+ var LegionTurnOutcomeAgentRequest = strictObject({
53037
+ claimToken: nonEmptyString2,
53038
+ sessionId: nonEmptyString2,
53039
+ secret: nonEmptyString2,
53040
+ ...turnOutcomeFields
53041
+ });
53042
+ var LegionTurnOutcomeBootRequest = strictObject({
53043
+ bootToken: nonEmptyString2,
53044
+ ...turnOutcomeFields
53045
+ });
53046
+ var LegionTurnOutcomeRequest = union([
53047
+ LegionTurnOutcomeAgentRequest,
53048
+ LegionTurnOutcomeBootRequest
53049
+ ]);
53050
+ var LegionTurnOutcomeResponse = object({
53051
+ refusedRun: number2().int().nonnegative(),
53052
+ failed: boolean2()
53053
+ });
53010
53054
  var LegionReadyForUpdateRequest = strictObject({
53011
53055
  claimToken: nonEmptyString2,
53012
53056
  sessionId: nonEmptyString2,
@@ -53129,6 +53173,11 @@ var LegionOperatorClaimResponse = object({
53129
53173
  pluginContract: number2().int().nonnegative(),
53130
53174
  updateRound: nonEmptyString2.optional(),
53131
53175
  updateHead: nonEmptyString2.optional(),
53176
+ lastTurnStart: timestamp.optional(),
53177
+ lastTurnEnd: timestamp.optional(),
53178
+ lastDeathCause: nonEmptyString2.optional(),
53179
+ lastStartFailure: nonEmptyString2.optional(),
53180
+ lastReady: timestamp.optional(),
53132
53181
  step: legionStepView.optional(),
53133
53182
  failure: legionClaimFailureView.optional()
53134
53183
  });
@@ -53149,9 +53198,7 @@ var LegionGrantResponse = object({
53149
53198
  expiresAt: timestamp
53150
53199
  });
53151
53200
  var LegionEmptyResponse = object({});
53152
- var LegionHandoffCompleteResponse = object({
53153
- note: nonEmptyString2.optional()
53154
- });
53201
+ var LegionHandoffCompleteResponse = object({});
53155
53202
  var LegionWaveReleaseResponse = object({
53156
53203
  released: array(nonEmptyString2),
53157
53204
  started: array(issueKey),
@@ -53171,7 +53218,6 @@ var LegionHandoffCompleteRequest = strictObject({
53171
53218
  grantId: nonEmptyString2,
53172
53219
  summary: nonEmptyString2,
53173
53220
  verdict: string2(),
53174
- ready: boolean2(),
53175
53221
  commit: nonEmptyString2.optional(),
53176
53222
  handoffId: nonEmptyString2.optional(),
53177
53223
  handoffVersion: number2().int().positive().optional(),
@@ -53405,6 +53451,7 @@ function createLegionDaemonClient(baseUrl, fetchFn = fetch) {
53405
53451
  ready: (input, options) => acknowledge("/legion/v1/claims/ready", input, options?.signal),
53406
53452
  readyForUpdate: (input) => acknowledge("/legion/v1/claims/ready-for-update", input),
53407
53453
  exit: (input) => acknowledge("/legion/v1/claims/exit", input),
53454
+ turnOutcome: (input) => post("/legion/v1/claims/turn-outcome", LegionTurnOutcomeRequest, LegionTurnOutcomeResponse, input),
53408
53455
  activity: (input) => acknowledge("/legion/v1/claims/activity", input),
53409
53456
  releaseRecords: (input) => post("/legion/v1/claims/release-records", LegionReleaseRecordsRequest, LegionReleaseRecordsResponse, input),
53410
53457
  grant: (input) => post("/legion/v1/grants", LegionGrantRequest, LegionGrantResponse, input),
@@ -55918,9 +55965,9 @@ var import_nats2 = __toESM(require_mod4(), 1);
55918
55965
 
55919
55966
  // package.json
55920
55967
  var name = "@sjawhar/claude-envoy";
55921
- var version2 = "2.5.0";
55968
+ var version2 = "2.7.0";
55922
55969
  var legion = {
55923
- daemonApiVersion: 75
55970
+ daemonApiVersion: 86
55924
55971
  };
55925
55972
 
55926
55973
  // ../pi-shared/src/agent-stream.ts
@@ -57234,12 +57281,12 @@ async function bootLegionClaim(host) {
57234
57281
  await host.afterRegister?.(claim);
57235
57282
  host.setCapability({
57236
57283
  sessionID: host.registration.sessionId,
57237
- claimToken: claim.claimToken,
57238
- generation: claim.generation,
57239
57284
  tree: claim.tree,
57240
57285
  issue: claim.issue,
57241
57286
  role: claim.role,
57242
57287
  secret: claim.secret,
57288
+ claimToken: claim.claimToken,
57289
+ generation: claim.generation,
57243
57290
  promptAgents: claim.promptAgents
57244
57291
  });
57245
57292
  const ready = {
@@ -57333,6 +57380,8 @@ function stepPhaseStall(state, input) {
57333
57380
  return state.state === "closed" ? { state } : { state: { state: "open", count: 0 } };
57334
57381
  case "tool-call":
57335
57382
  return { state: { state: state.state, count: 0 } };
57383
+ case "refused":
57384
+ return { state };
57336
57385
  case "reminded":
57337
57386
  return state.state === "closed" ? { state } : { state: { state: "open", count: state.count + 1 } };
57338
57387
  case "settle": {
@@ -57486,6 +57535,14 @@ function createPhaseReminder(deps) {
57486
57535
  });
57487
57536
  return { reminds: false, record };
57488
57537
  }
57538
+ const state = record.workers[claim.role]?.claim.state;
57539
+ if (state === "failed") {
57540
+ deps.log.debug("legion: the daemon has failed this claim; no reminder is sent", {
57541
+ issue: claim.issue,
57542
+ role: claim.role
57543
+ });
57544
+ return { reminds: false, record };
57545
+ }
57489
57546
  return { reminds: true, record };
57490
57547
  };
57491
57548
  const tellArchitect = async (record) => {
@@ -57608,17 +57665,20 @@ function createPhaseReminder(deps) {
57608
57665
  generation += 1;
57609
57666
  advance(input);
57610
57667
  },
57611
- settle: async (text, options) => {
57668
+ settle: async (turn) => {
57612
57669
  turnRunning = false;
57613
57670
  generation += 1;
57671
+ if (turn.kind === "refused") {
57672
+ advance(turn);
57673
+ continued = false;
57674
+ armReminder(reminderText(""), deps.limits.reminderMs);
57675
+ return;
57676
+ }
57677
+ const text = turn.lastAssistantText;
57614
57678
  if (stall.state !== "closed")
57615
57679
  lastMessage = text.slice(0, LAST_MESSAGE_LIMIT);
57616
57680
  const before = stall.count;
57617
- const reminder = advance({
57618
- kind: "settle",
57619
- lastAssistantText: text,
57620
- backgroundWork: options?.backgroundWork
57621
- });
57681
+ const reminder = advance(turn);
57622
57682
  if (stall.state === "awaiting-update") {
57623
57683
  continued = false;
57624
57684
  return;
@@ -57632,7 +57692,7 @@ function createPhaseReminder(deps) {
57632
57692
  continued = false;
57633
57693
  return;
57634
57694
  }
57635
- if (before !== 0 || continued || options?.canContinue === false) {
57695
+ if (before !== 0 || continued) {
57636
57696
  continued = false;
57637
57697
  armReminder(reminder, deps.limits.reminderMs);
57638
57698
  return;
@@ -57940,14 +58000,16 @@ function createPhaseHookEndpoint(deps) {
57940
58000
  stopHookActive: event.stopHookActive ?? "",
57941
58001
  backgroundWork
57942
58002
  });
57943
- const reminded = await reminder.settle(event.lastAssistantMessage ?? "", {
58003
+ const reminded = await reminder.settle({
58004
+ kind: "settle",
58005
+ lastAssistantText: event.lastAssistantMessage ?? "",
57944
58006
  backgroundWork
57945
58007
  });
57946
58008
  await sendActivity(claim, backgroundWork);
57947
58009
  return reminded === undefined ? {} : { decision: "block", reason: reminded };
57948
58010
  }
57949
58011
  case "StopFailure": {
57950
- await reminder.settle(event.lastAssistantMessage ?? "", { canContinue: false });
58012
+ await reminder.settle({ kind: "refused", message: event.lastAssistantMessage ?? "" });
57951
58013
  return {};
57952
58014
  }
57953
58015
  case "PostToolUse":
@@ -58215,7 +58277,6 @@ var PhaseOpArguments = discriminatedUnion("op", [
58215
58277
  verdict: _enum2(["pass", "pending", "fail"], {
58216
58278
  error: "handoff_complete's verdict is pass, pending or fail"
58217
58279
  }).optional(),
58218
- ready: boolean2({ error: "handoff_complete's ready is true or false" }).optional(),
58219
58280
  wake_at: nextLook.optional()
58220
58281
  }),
58221
58282
  operation("request_backward_move", {
@@ -58259,7 +58320,7 @@ var PHASE_OP_SENTENCES = {
58259
58320
  requestBackwardMove: "request_backward_move returns an issue to an earlier phase (`to`, `reason`): a phase worker moves its own issue; " + "the tree's architect moves an issue in accepting, named by `issue`, back to implementing or testing, which counts a review round. "
58260
58321
  };
58261
58322
  function legionToolDescription(host) {
58262
- return "Perform the workflow operation the Legion daemon assigned this role. The daemon advances phases; this tool cannot spawn workers. " + (host.before ?? "") + "handoff_complete (phase workers and sub-architects; the daemon accepts a completion only from the role working the issue's current phase, " + "and the checking role's report on a look of its closed issue's production check) reports this phase complete: `summary` (two sentences for " + "the architect, or the merger's READY packet), `verdict` pass|fail from the tester alone on a phase completion (the daemon refuses a verdict " + "from any other role there) and pass|pending|fail on a production check report (pending: production does not carry the merge " + "yet), `ready: true` for the merger's READY. A planning, implementing, testing or reviewing phase ends with a handoff record on the " + "Dispatch issue: write it with `dispatch handoff-write --issue <issue> --phase <plan|implement|test|review> --body-file <file>` before " + "calling. This call reads the phase's newest record from Dispatch and reports it; the implementer's round also reports the commit " + "`legion/<issue>@origin` names, so push the branch first; retro and the merger's READY report the commit the workspace stands on. It " + "refuses, posting nothing, a phase with no record, a Dispatch that does not answer, or an implementer's `@-` not yet on " + "`legion/<issue>@origin`, each naming the remedy. A production check report " + "(the task whose first line is `Production check of <KEY>`, handed once the merge closed the issue to the role the check records) needs no " + "handoff and no commit: it carries its verdict and summary alone. A pending report also names `wake_at`, an RFC 3339 time: when you want the " + "next look. A pass, a fail, and a pending on the check's last look end the check, so none of them carries `wake_at` " + "(CHECK_WAKE_UNEXPECTED), and a pending on any other look is refused without one (CHECK_WAKE_REQUIRED). A report on an issue whose check is " + "closed or never opened is refused (CHECK_NOT_OPEN), and so is one from a role the check does not record (CHECK_ROLE_MISMATCH). " + "The daemon refuses " + "HANDOFF_SESSION_MISMATCH (another session wrote the record), HANDOFF_NOT_NEW (the record is the one you named for your previous phase: " + "write this phase's handoff), " + "HANDOFF_STALE_ASSIGNMENT (the issue left your phase and came back while your turn ran, so this completion is of the assignment before the one " + "the phase hands you now: end the turn without completing; the task of the assignment it hands you now is work of its own, so do that work and " + "complete it with a handoff of its own, never this record or verdict again), the implementer's completion of implementing with no open " + "pull request on `legion/<issue>` and none recorded " + "merged (HANDOFF_NO_PULL_REQUEST: open it; one naming a closed pull request is the architect's to decide) and, for READY, each " + "refusal the merger's role names; a refused completion changed nothing, so fix what it names and complete again. An accepted READY whose `note` " + "begins MANUAL_MERGE_REQUIRED: is one a person merges: arm nothing. " + "ready_for_update answers the daemon's update task on this issue's pod: `round` is the round id that task names, and the " + "daemon takes your answer for that round alone. Push every commit you want kept to the issue branch " + "first, because the pod and its disk are replaced after every worker of the pod has answered. The call ends no phase. The " + "daemon holds your next task until your process comes back on the new pod, in this same session. " + (host.after ?? "") + `What a later phase needs goes in your handoff; a question for another live role goes to its role topic with ${host.envoyPublish}.`;
58323
+ return "Perform the workflow operation the Legion daemon assigned this role. The daemon advances phases; this tool cannot spawn workers. " + (host.before ?? "") + "handoff_complete (phase workers and sub-architects; the daemon accepts a completion only from the role working the issue's current phase, " + "and the checking role's report on a look of its closed issue's production check) reports this phase complete: `summary` (two sentences for the " + "architect), `verdict` pass|fail from the tester alone on a phase completion (the daemon refuses a verdict from " + "any other role there) and pass|pending|fail on a production check report (pending: production does not carry the merge " + "yet). A planning, implementing, testing or reviewing phase ends with a handoff record on the " + "Dispatch issue: write it with `dispatch handoff-write --issue <issue> --phase <plan|implement|test|review> --body-file <file>` before " + "calling. This call reads the phase's newest record from Dispatch and reports it; the implementer's round also reports the commit " + "`legion/<issue>@origin` names, so push the branch first; retro and the merger's completion report the commit the workspace stands on. It " + "refuses, posting nothing, a phase with no record, a Dispatch that does not answer, or an implementer's `@-` not yet on " + "`legion/<issue>@origin`, each naming the remedy. A production check report " + "(the task whose first line is `Production check of <KEY>`, handed once the merge closed the issue to the role the check records) needs no " + "handoff and no commit: it carries its verdict and summary alone. A pending report also names `wake_at`, an RFC 3339 time: when you want the " + "next look. A pass, a fail, and a pending on the check's last look end the check, so none of them carries `wake_at` " + "(CHECK_WAKE_UNEXPECTED), and a pending on any other look is refused without one (CHECK_WAKE_REQUIRED). A report on an issue whose check is " + "closed or never opened is refused (CHECK_NOT_OPEN), and so is one from a role the check does not record (CHECK_ROLE_MISMATCH). " + "The daemon refuses " + "HANDOFF_SESSION_MISMATCH (another session wrote the record), HANDOFF_NOT_NEW (the record is the one you named for your previous phase: " + "write this phase's handoff), " + "HANDOFF_STALE_ASSIGNMENT (the issue left your phase and came back while your turn ran, so this completion is of the assignment before the one " + "the phase hands you now: end the turn without completing; the task of the assignment it hands you now is work of its own, so do that work and " + "complete it with a handoff of its own, never this record or verdict again), the implementer's completion of implementing with no open " + "pull request on `legion/<issue>` and none recorded " + "merged (HANDOFF_NO_PULL_REQUEST: open it; one naming a closed pull request is the architect's to decide); a refused completion changed " + "nothing, so fix what it names and complete again. " + "ready_for_update answers the daemon's update task on this issue's pod: `round` is the round id that task names, and the " + "daemon takes your answer for that round alone. Push every commit you want kept to the issue branch " + "first, because the pod and its disk are replaced after every worker of the pod has answered. The call ends no phase. The " + "daemon holds your next task until your process comes back on the new pod, in this same session. " + (host.after ?? "") + `What a later phase needs goes in your handoff; a question for another live role goes to its role topic with ${host.envoyPublish}.`;
58263
58324
  }
58264
58325
  async function mintClaimGrant(daemon, claim) {
58265
58326
  const { grantId } = await daemon.grant({
@@ -58429,9 +58490,6 @@ async function completeHandoff(runtime, args) {
58429
58490
  if (args.verdict === undefined) {
58430
58491
  throw new Error("handoff_complete on a production check names a verdict of pass, pending or fail");
58431
58492
  }
58432
- if (args.ready === true) {
58433
- throw new Error("handoff_complete on a production check is no READY: leave ready out");
58434
- }
58435
58493
  if (claim.role !== check.role) {
58436
58494
  throw new Error(`${claim.issue}'s production check is the ${check.role}'s, and this session is the ${claim.role}'s: only the role the check records reports on it`);
58437
58495
  }
@@ -58447,7 +58505,6 @@ async function completeHandoff(runtime, args) {
58447
58505
  grantId: await mintClaimGrant(daemon, claim),
58448
58506
  summary: args.summary,
58449
58507
  verdict: args.verdict ?? "",
58450
- ready: false,
58451
58508
  ...args.wake_at === undefined ? {} : { wakeAt: args.wake_at }
58452
58509
  });
58453
58510
  }
@@ -58462,7 +58519,6 @@ async function completeHandoff(runtime, args) {
58462
58519
  grantId: await mintClaimGrant(daemon, claim),
58463
58520
  summary: args.summary,
58464
58521
  verdict: args.verdict ?? "",
58465
- ready: args.ready ?? false,
58466
58522
  ...report
58467
58523
  });
58468
58524
  }
@@ -14,7 +14,7 @@ You own one issue tree from its first decision to the merge that closes it. The
14
14
  - Act on delivered wakes and the live artifacts they name; build no wait loop, since every wake reaches you.
15
15
  - Check each claim against the code as fetched now (the default branch your addressing line names, or the head under review), never the workspace as it was at admission, and tell every fresh reader you dispatch to do the same: the branch may have moved since.
16
16
  - Before you end a turn that waits on a human, open what they must answer: a decision block, a `dispatch ask` or `dispatch request-approval`. A turn that ends with nothing open asks nobody, and the tree stops. Open an ordinary ask on the root issue itself, never a child: only a question a session of this tree opens on the root starts a wait on a person, so an ask on a child starts no wait and leaves the tree standing still. Once you have handed a root question to the human, end your turn: when nothing else of the tree is at work — no other issue of the tree in a phase, the `legion` label still on, and no person or outside session holding the root's Dispatch claim — the root moves to `awaiting_person`, keeping its admission slot, while this session stays live. Read the human's comments and replies as they arrive. Their answer gives this live claim a task naming what answered and what is still with them. The same holds once you request approval and `register_gate` that version: the registration hands the spec to the human, so end your turn there too, and the human's review, or a newer version once Dispatch shows the request back on your turn, gives you that task.
17
- An answered root stands in the admission line until the pass that resumes it, and nothing is sent to you about that wait: your record's `waitingLine` gives the live place in the line and the line's length, your resume task says what answered the wait, and you act on neither, because that resume takes no further slot and the daemon starts you again by itself.
17
+ An answered root stands in the admission line until the pass that resumes it, and nothing is sent to you about that wait: your record's `waitingLine` gives the live place in the line and the line's length, with the line's own fields beside them — `part` (`returned` for an issue whose work came back, `starting` for one that has not started) and `kind`, `partPlace` of `partLength` inside that part, `holdsSlot`, which is true for your answered root because it has held its slot since its start, the key that placed it (`since` for a `returned` issue, `rootRank`, `ownRank` and `rootKey` for a `starting` one) and `reason`, the daemon's own sentence for that place — and `why` on any issue of your tree that is not working now gives the same answer in one word and one sentence (`claim_stopped`, a claim nothing will wake; `waiting`, this line; `blocked`, a link or an open child; `unlisted`, an issue no list places), your resume task says what answered the wait, and you act on neither your place nor your wait, because that resume takes no further slot and the daemon starts you again by itself.
18
18
  - Deliver every criterion of the root spec in this tree. Work leaves it only when a root splits, as a `dispatch ask` for the rest: work outside has no owner.
19
19
  - A problem outside the tree is a `dispatch ask`, never an issue you file, because a person decides whether it needs one (`skill://legion-worker/references/findings.md`). A clear defect is the exception. Fix one in code this tree touches or depends on in this tree's pull request. Send any other to the controller, which gives it to the tree that owns that code.
20
20
  - Before you write a spec or ask a person anything, read the repository's `STRATEGY.md` when it has one and the design principles where it states them (`AGENTS.md`, in this repository), then use a standard best-practice solution; ask only what neither settles, with one recommendation. A design that crosses a Boundary in `STRATEGY.md` goes to its owner before it is built. Find the standard with a web search and with how two or three well-regarded projects solve the problem. Cite them in a few lines of the spec's `Design`. A design far from the standard is a sign to fix the underlying problem, not to add a workaround.
@@ -44,7 +44,7 @@ An answered root stands in the admission line until the pass that resumes it, an
44
44
  - Release every child as soon as it is filed, each with `--blocked-by` the issues it waits on, and never hold a release back for a close: a released child, held or running, keeps the root's close waiting, but once the root's own pull request has merged the root closes the moment its last released child leaves, and a child released after that finds no live tree and runs as an orphan root of its own.
45
45
  - On each `child-closed`, read the child's handoff. Edit the spec of each open child the result changes, and take out each child it makes unneeded with `park_child` and say why with `dispatch comment`.
46
46
  - Before you park a child for good (one made unneeded, or parked so its tree can finish), set the `--blocked-by` list of each sibling that waits on it again without it (one call with the rest of its list, or `--clear-blocked-by` when it was the only one), or park that sibling too: a parked child is stopped, not done, and its dependents stay held with no notice. A park followed by `rerun_child` keeps its dependents' links: they wait through the rerun and start when the rerun's merge closes the child.
47
- - A released child takes an admission slot of its own when the daemon starts its first phase and keeps it until it is done, leaves the workflow or waits only for its merge, and it waits in the admission line until the daemon starts it, so a tree of four started issues holds four of the cap's issues. It never becomes a root while your tree is live.
47
+ - A released child takes an admission slot of its own when the daemon starts its first phase and keeps it until it is done or leaves the workflow, and it waits in the admission line until the daemon starts it, so a tree of four started issues holds four of the cap's issues. It never becomes a root while your tree is live.
48
48
 
49
49
  ## 3. Children complete
50
50
 
@@ -106,55 +106,53 @@ The daemon keeps this order from its fixed table; you start none of its steps:
106
106
  2. The reviewer's approval of the head by SHA moves the issue to `accepting`; your `sign_off` moves
107
107
  it to `retro`.
108
108
  3. Retro records what the work taught as a `dispatch comment` on the issue and brings the PR body
109
- up to date. It commits nothing, so the approved head is the head READY names. No merge carries
110
- a handoff onto the default branch, since no commit carries one.
111
- 4. The merger quotes what sits above the approved head
112
- (`jj diff --from <approved-sha> --to <tip-sha> --summary`) in READY and sends the READY packet
113
- with its completion. The daemon refuses a head carrying anything above the approved head but a
114
- commit that changes only `docs/solutions/` and a change whose every path is under `.legion/`,
115
- which nothing writes or reads now, so nobody reviews one
116
- (`READY_UNREVIEWED_CHANGE`). It
117
- posts `READY #<n> at <current sha> (approved at <approved sha>) for <KEY> (<pr url>)` on the
118
- Dispatch issue, publishes it to the project's merge queue role when one is set, and submits the
119
- merge of that head itself, as the implement App with GitHub's expected-head check. The
120
- repository's required reviews and checks decide when it lands; Legion neither reads nor writes
121
- those rules, and a review only a person can give is waited for, never bypassed. A READY the
122
- design gate refused is submitted by the daemon once that spec version is approved.
123
- 5. The merge lands under the repository's rules and closes the issue; a root's close waits until
124
- the rest of its tree has left the workflow.
109
+ up to date. It commits nothing, so the approved head is the head the merger merges. No merge
110
+ carries a handoff onto the default branch, since every handoff is a record on the Dispatch
111
+ issue and no commit carries one.
112
+ 4. The merger reads the pull request and merges that head itself, as the implement App and with the
113
+ head it read as the head GitHub must match
114
+ (`gh pr merge <n> --squash --match-head-commit <head> --subject '<pull request title> (#<n>)' --body ''`,
115
+ whose explicit message keeps GitHub's default squash message from joining the branch's commit
116
+ messages onto the base; or `expectedHeadOid` on a
117
+ merge-queue base, where it enqueues the pull request); it never turns auto-merge on, and the
118
+ daemon submits no merge and changes no merge setting. The repository's required reviews and
119
+ checks decide when it lands; Legion neither reads nor writes those rules, and a review only a
120
+ person can give is waited for, never bypassed. Nothing compares that head with the approved one:
121
+ a repository that wants a later push reviewed says so in its own rulesets. The merger's
122
+ completion records its phase row and moves nothing, and the daemon posts no packet.
123
+ 5. The merge lands under the repository's rules, the daemon reads it and closes the issue; a
124
+ root's close waits until the rest of its tree has left the workflow.
125
125
 
126
126
  A person's request after your sign-off is a requirement of this issue, filed nowhere else: in
127
- `retro` or `merging` the role holding the phase makes the `request_backward_move`; in
128
- `awaiting_merge` the implementer pushes, which withdraws the READY.
129
- A refused or failed READY arrives while the merger holds `merging`, so the merger makes the move
130
- and you tell it which; from `accepting` you send an issue back only to `implementing` or
127
+ `retro` or `merging` the role holding the phase makes the `request_backward_move`.
128
+ A merge the merger cannot make arrives while the merger holds `merging`, so the merger makes the
129
+ move and you tell it which; from `accepting` you send an issue back only to `implementing` or
131
130
  `testing`.
132
131
 
133
132
  - A failed verification the merger reports: handle it as the `pr-blocked` row of
134
133
  `skill://legion-architect/references/wake-routing.md` says, telling the merger to move the
135
134
  issue back with `request_backward_move`, naming what failed; never bypass.
136
- - `READY_UNREVIEWED_CHANGE`, or a merger task with no approved head (`READY_NOT_APPROVED`): the
137
- merger moves it back to `reviewing`, the reason naming the code and what it found, so the
138
- reviewer runs a new round.
135
+ - A merge GitHub refuses for a repository setting or an App permission — a merge-queue base whose
136
+ `squash_merge_commit_message` joins the branch's commit messages among them: the merger tells
137
+ you, and only a person can change it. Ask one with `dispatch ask`, naming the pull request, the
138
+ head and GitHub's refusal; never bypass a rule.
139
139
 
140
140
  ## A conflicting head
141
141
 
142
- What returns the tree to review is a changed diff: a commit above the approved head that touches
143
- anything outside `docs/solutions/`, other than a change whose every path is under `.legion/`, or
144
- a conflict-resolution merge whose fingerprint (the unchanged-diff check,
142
+ What returns the tree to review is a changed diff: a conflict-resolution merge whose
143
+ fingerprint (the unchanged-diff check,
145
144
  `skill://legion-worker/references/conflicts-and-rewrites.md`) differs from the approved head's.
146
- A conflict merge whose fingerprint is unchanged does not.
145
+ A conflict merge whose fingerprint is unchanged does not, and no Legion check compares the head
146
+ that merges with the approved one: a repository that wants a later push reviewed says so in its
147
+ own rulesets.
147
148
 
148
149
  Make a conflict-resolution merge only when GitHub reports `CONFLICTING`
149
- (`gh pr view <n> --json mergeable,mergeStateStatus`). Outside `awaiting_merge` the daemon records
150
- a conflict and moves nothing, so the moment you see it:
151
-
152
- - In a phase a worker holds, tell that worker (`envoy_publish` to its role topic) to move the issue
153
- back to `implementing` with `request_backward_move`.
154
- - In `accepting`, make the move yourself (`request_backward_move` with `issue`).
155
- - In `awaiting_merge`, do nothing: the daemon withdraws the READY and sends the issue back to
156
- `implementing` itself, telling you with a `checks-red` whose reason reads
157
- `the head conflicts with <base>`.
150
+ (`gh pr view <n> --json mergeable,mergeStateStatus`). From `testing`, `reviewing`, `accepting`,
151
+ `retro` and `merging` alike the daemon acts on it itself: it moves the issue back to
152
+ `implementing`, starts the implementer, and tells you with a `checks-red` notice naming the phase
153
+ the issue was taken out of and whose reason reads
154
+ `the head conflicts with <base>: GitHub runs no checks on it; merge <base> forward`. You start
155
+ nothing for it.
158
156
 
159
157
  The daemon then runs the phases from `implementing`: the implementer merges the bookmark forward
160
158
  with the destination and pushes it (the procedure in
@@ -162,7 +160,7 @@ with the destination and pushes it (the procedure in
162
160
  fingerprints; the tester re-runs the bare gates only and the class search of every earlier
163
161
  round's findings at the new head; the reviewer approves the new head by SHA, or continues its
164
162
  round if it had not approved; the daemon carries the issue through your acceptance and retro to
165
- the merger's new READY.
163
+ the merger's merge.
166
164
 
167
165
  ## A review thread GitHub will not resolve
168
166
 
@@ -171,17 +169,18 @@ thread with plain `gh`: the ones it answers and the bot threads the reviewer acc
171
169
  it. The reviewer resolves none. If the implementer reports that GitHub refused its
172
170
  `resolveReviewThread`, open a `dispatch ask` naming the thread's id or URL and GitHub's message, for
173
171
  a human to resolve it by hand, with options for resolved / could not. The merger does not complete
174
- while that ask is open; READY itself checks no thread state
172
+ while that ask is open; the merge itself checks no thread state
175
173
  (`skill://legion-worker/references/merge-gate.md`).
176
174
 
177
175
  ## The close
178
176
 
179
- The merge closes the issue: when GitHub reports the pull request merged while the issue is in
180
- `awaiting_merge` (a merge before that closes it the moment it gets there), the daemon writes `done`.
177
+ The merge closes the issue: the daemon reads the merged pull request — from GitHub's webhook or
178
+ from its own read of the issue — and writes `done`. An issue that reaches `merging` on a pull
179
+ request GitHub has already merged closes at once.
181
180
 
182
181
  - A root whose merge lands while another issue of its tree is still in the workflow stays in
183
- `awaiting_merge`, its workers kept and live and no admission slot held, until the last of them
184
- is done or parked. One
182
+ `merging`, its workers kept and live and its admission slot kept with them, until the last of
183
+ them is done or parked. One
185
184
  `pr-merged` notice names what it waits for and none follows as they depart, so read the pull
186
185
  request on GitHub.
187
186
  - A child's close reaches you as `child-closed`. Where the project's `production_check` names the
@@ -213,9 +212,9 @@ waits in the line for a slot and for any unfinished blocker, and its architect s
213
212
  root and registers its own spec. Only a child that finished, was parked or was never released
214
213
  stays. The child stays its own tree; reopening the old root does not take it back. Park a child
215
214
  with `park_child` before then when its work should stop with the root. A root that is parked
216
- rather than closed hands over only a child at `awaiting_merge` whose pull request is still open,
217
- since the daemon re-admits no parked root and only that child's own new READY arms the merge the
218
- park disarmed; park that child too when its merge should wait with the root.
215
+ rather than closed hands over only a child in `merging` whose pull request is still open,
216
+ since the daemon re-admits no parked root and only that child's own merger, started again under
217
+ its own tree, merges that head; park that child too when its merge should wait with the root.
219
218
 
220
219
  If you are that child's architect:
221
220
 
@@ -223,24 +222,24 @@ If you are that child's architect:
223
222
  or ask for approval again.
224
223
  - It says `handed_over` alone (no gate to carry): your workers already run their phases, so
225
224
  decompose nothing, and read the root's phase from the catch-up (for a root `held`, the phase its
226
- `held` notice names). Before `awaiting_merge`, register your spec with `register_gate`: your
227
- merger's READY waits for its approval.
225
+ `held` notice names). Before the merge, register your spec with `register_gate`: the tree's
226
+ work starts on its approval.
228
227
  That registration's approval request waits with the person like any other, but it starts no wait of the root's own: a root your catch-up calls `handed_over` stands at a phase it carried, never `admitted`, and only a root at `admitted` waits on a person.
229
228
  The section below is for a root of your own at `admitted`, not for this one.
230
229
  When that `design-approved` arrives, release and start
231
230
  nothing: the workers are already running. A child carried in `accepting` is yours to accept. In
232
- `awaiting_merge` the READY is through, so register none; a red or conflicting head that returns
233
- the root to `implementing` makes its next READY read the gate again, so a later `ready-refused`
234
- is when you register.
231
+ `merging` the work is already through every gate, so register none.
235
232
 
236
233
  ## Your slot while a person has your spec
237
234
 
238
235
  This is for a root of your own standing at `admitted`, the only phase from which a root waits on a person.
239
236
  A registration that leaves the approval request with the person moves your root to `awaiting_person`, and what brings the root back is the answer, not the registration.
240
- Your root keeps its admission slot throughout: it holds the slot the daemon gave it at its start until it is done, leaves the workflow or waits only for its merge.
237
+ Your root keeps its admission slot throughout: it holds the slot the daemon gave it at its start until it is done or leaves the workflow.
241
238
  So your resume takes no slot and comes however full the cap is, whether or not the gate has ever opened in this generation.
242
239
  The first phase that resume starts needs no slot of its own either, since the root holds one: it waits in the line among the issues whose work came back, oldest first, placed by the moment your gate opened, so it stands behind every issue of that part whose work came back before it.
243
- A changes request, or a newer version of the document that hands the request back to you, leaves the gate closed, so your merger's READY waits for a new approval.
244
- While your answered root stands in the line, your record carries `waitingLine`, your place in the line and its length.
240
+ A changes request, or a newer version of the document that hands the request back to you, leaves the gate closed, so it holds the tree's work until a new approval.
241
+ While your answered root stands in the line, your record carries `waitingLine`: your place in the line and its length, your `part` (`returned`) and `kind` (`answered`), your `partPlace` of `partLength` among the issues whose work came back, `holdsSlot` true because your root has held its slot since its start, `since`, the moment your work came back, and `reason`, the daemon's own sentence for that place.
242
+ An issue that has not started carries `rootRank`, `ownRank` and `rootKey` in place of `since`, the two Dispatch ranks that placed it and the key of its tree root.
243
+ `why` beside it says why any issue of your tree is not working now, in one word and one sentence: `claim_stopped`, a claim nothing will wake; `waiting`, this line; `blocked`, a Dispatch link or an open child below it; `unlisted`, an issue the record holds in the workflow that no admission list places.
245
244
  Nothing is sent to you about that wait, and your resume task says what answered it.
246
- Act on neither: the daemon starts you again on the pass that reads the answer.
245
+ Act on neither your place nor your wait: the daemon starts you again on the pass that reads the answer.
@@ -1,8 +1,7 @@
1
1
  # The root spec and the design gate
2
2
 
3
3
  Part of `skill://legion-architect`, section 1. Read it before you write the root spec, before any
4
- edit to an approved root spec, and on `design-approved`, `design-changes-requested` or
5
- `ready-refused`.
4
+ edit to an approved root spec, and on `design-approved` or `design-changes-requested`.
6
5
 
7
6
  ## Writing the root spec
8
7
 
@@ -264,11 +263,18 @@ Dispatch shows the request back on your turn. While the root waits on a question
264
263
  human's approval or changes request of the spec answers that wait too, and the task says how the
265
264
  spec stands. Your resume takes no slot, whether or not the gate opened, because the root holds
266
265
  one all along: an issue keeps its admission slot from the moment the daemon starts it
267
- until it is done, leaves the workflow or waits only for its merge. The answered root stands in
266
+ until it is done or leaves the workflow. The answered root stands in
268
267
  the admission line until the pass that resumes it, and nothing is sent to you about that wait:
269
- your record's `waitingLine` gives the live place in the line and the line's length, your resume
270
- task says what answered the wait, and you act on neither, because the daemon starts you again by
271
- itself on that pass.
268
+ your record's `waitingLine` gives the live place in the line and the line's length, and beside
269
+ them the line's own fields — `part` and `kind`, `partPlace` of `partLength` inside that part,
270
+ `holdsSlot`, true for your root, which has held its slot since its start, `since` for an issue
271
+ whose work came back or `rootRank`, `ownRank` and `rootKey` for one that has not started, and
272
+ `reason`, the daemon's own sentence for that place. `why` on any issue of your tree that is
273
+ not working now says the same in one word and one sentence: `claim_stopped`, a claim nothing
274
+ will wake; `waiting`, this line; `blocked`, a Dispatch link or an open child below it;
275
+ `unlisted`, an issue the record holds in the workflow that no admission list places. Your
276
+ resume task says what answered the wait, and you act on neither your place nor your wait,
277
+ because the daemon starts you again by itself on that pass.
272
278
  Release no child until every gated step is open: a delivered wake shows
273
279
  `design-approved` on the root, or a task says its design gate is open, and under more than one
274
280
  step `gatedSteps` in your record shows each one `approved`. The daemon sends a root waiting on a
@@ -310,8 +316,8 @@ to the version it writes. Once they have answered:
310
316
  changed since the earlier approval, then the reviews' sentence (the card shows `Approved at
311
317
  version N on <date> by <who>.`, and its `Show diff` control carries the detail). The rewrite
312
318
  closes the gate until they approve. Release no further child until the `design-approved` after
313
- it; work already in flight, including what the daemon started at the answer, continues. Every
314
- merger's `READY` in the tree is refused until a human approves the latest version.
319
+ it; work already in flight, including what the daemon started at the answer, continues through
320
+ its merge.
315
321
 
316
322
  A settled decision is the human's. A plan that would overturn one goes back to the planner with the
317
323
  decision kept, unless the planner brings evidence the human did not weigh that would change it