@sjawhar/claude-envoy 2.6.0 → 2.7.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.
- package/.claude-plugin/plugin.json +1 -1
- package/.omp-plugin/plugin.json +1 -1
- package/AGENTS.md +13 -3
- package/dist/dispatch.js +7498 -6764
- package/dist/envoy-channel.js +4998 -4223
- package/dist/session-hook.js +7523 -6789
- package/legion/skills/legion-architect/SKILL.md +1 -1
- package/legion/skills/legion-architect/references/acceptance.md +49 -52
- package/legion/skills/legion-architect/references/design-gate.md +4 -5
- package/legion/skills/legion-architect/references/wake-routing.md +7 -16
- package/legion/skills/legion-controller/SKILL.md +2 -2
- package/legion/skills/legion-controller/references/admission.md +4 -5
- package/legion/skills/legion-controller/references/backlog-stewardship.md +3 -4
- package/legion/skills/legion-controller/references/escalation.md +8 -7
- package/legion/skills/legion-controller/references/finding-asks.md +1 -1
- package/legion/skills/legion-controller/references/session.md +1 -1
- package/legion/skills/legion-controller/references/slack-mentions.md +1 -1
- package/legion/skills/legion-controller/references/triage.md +1 -1
- package/legion/skills/legion-controller/references/wakes.md +6 -4
- package/legion/skills/legion-retro/SKILL.md +13 -19
- package/legion/skills/legion-worker/SKILL.md +12 -8
- package/legion/skills/legion-worker/references/conflicts-and-rewrites.md +3 -3
- package/legion/skills/legion-worker/references/merge-gate.md +110 -151
- package/legion/skills/legion-worker/references/pr-body.md +15 -14
- package/legion/skills/legion-worker/references/review-threads.md +4 -4
- package/package.json +2 -2
- package/src/legion-phase-hook.ts +25 -11
- package/legion/skills/legion-architect/references/merge-notices.md +0 -104
package/src/legion-phase-hook.ts
CHANGED
|
@@ -41,6 +41,15 @@ import { configuredValue } from "./claude-session"
|
|
|
41
41
|
* appended to that turn as its next step (`deliver`/`step` in
|
|
42
42
|
* `packages/daemon/internal/claudebridge/bridge.go`), which would destroy the turn boundary the
|
|
43
43
|
* whole split exists for.
|
|
44
|
+
*
|
|
45
|
+
* A turn Claude Code ended on an API error fires `StopFailure` rather than `Stop`, and that is
|
|
46
|
+
* the provider refusing the turn: it earns no continuation, since the host would turn one into
|
|
47
|
+
* another turn at once and the provider would refuse that one the same way. It does arm one
|
|
48
|
+
* timer, because the task that refused turn carried ended with it and nothing else would wake
|
|
49
|
+
* this worker, so a single transient refusal would otherwise leave the issue idle. What stops
|
|
50
|
+
* the reminding for good is the runner's record check, which drops every reminder once the
|
|
51
|
+
* daemon has failed this role's claim — the refused turns themselves are counted by the bridge,
|
|
52
|
+
* which reports each turn's outcome to the daemon (INFRA-714).
|
|
44
53
|
*/
|
|
45
54
|
|
|
46
55
|
/** The tool's name: Claude Code shows it as `mcp__legion__legion_phase_hook`, and a hook entry
|
|
@@ -516,7 +525,9 @@ export function createPhaseHookEndpoint(deps: PhaseHookDeps): PhaseHookEndpoint
|
|
|
516
525
|
stopHookActive: event.stopHookActive ?? "",
|
|
517
526
|
backgroundWork,
|
|
518
527
|
})
|
|
519
|
-
const reminded = await reminder.settle(
|
|
528
|
+
const reminded = await reminder.settle({
|
|
529
|
+
kind: "settle",
|
|
530
|
+
lastAssistantText: event.lastAssistantMessage ?? "",
|
|
520
531
|
backgroundWork,
|
|
521
532
|
})
|
|
522
533
|
// After the settle, so the report carries the wake that settle armed. The daemon
|
|
@@ -526,13 +537,17 @@ export function createPhaseHookEndpoint(deps: PhaseHookDeps): PhaseHookEndpoint
|
|
|
526
537
|
return reminded === undefined ? {} : { decision: "block", reason: reminded }
|
|
527
538
|
}
|
|
528
539
|
case "StopFailure": {
|
|
529
|
-
//
|
|
530
|
-
//
|
|
531
|
-
//
|
|
532
|
-
//
|
|
533
|
-
//
|
|
534
|
-
// else
|
|
535
|
-
|
|
540
|
+
// Claude Code runs this instead of `Stop` when the turn ended on an API error, and
|
|
541
|
+
// `${last_assistant_message}` is then the error text itself rather than anything the
|
|
542
|
+
// worker said ("Hooks reference", code.claude.com/docs/en/hooks). So this is the
|
|
543
|
+
// provider refusing the turn, and the machine takes it as one: it earns no
|
|
544
|
+
// continuation, because the next turn would be refused the same way, and one timer,
|
|
545
|
+
// because nothing else would wake this worker once the task that turn carried ended
|
|
546
|
+
// with it. What ends a session the provider keeps refusing is the daemon failing its
|
|
547
|
+
// claim on the outcomes the bridge reports, which the timer's own record check reads.
|
|
548
|
+
// Claude Code ignores whatever this hook returns, which costs nothing now that there
|
|
549
|
+
// is nothing to return.
|
|
550
|
+
await reminder.settle({ kind: "refused", message: event.lastAssistantMessage ?? "" })
|
|
536
551
|
return {}
|
|
537
552
|
}
|
|
538
553
|
case "PostToolUse":
|
|
@@ -550,9 +565,8 @@ export function createPhaseHookEndpoint(deps: PhaseHookDeps): PhaseHookEndpoint
|
|
|
550
565
|
// Claude Code's stdin from the bridge and never this process, so what a turn means is
|
|
551
566
|
// read from the prompt itself. The turn is declared first, which makes every armed
|
|
552
567
|
// timer stale, and the pending one is dropped outright: the runner's generation guard
|
|
553
|
-
// answers the same for the timers it armed, and the one this
|
|
554
|
-
//
|
|
555
|
-
// guard of its own.
|
|
568
|
+
// answers the same for the timers it armed, and dropping the one timer this server
|
|
569
|
+
// holds is the plainest way to say the same thing.
|
|
556
570
|
reminder.turnStarted()
|
|
557
571
|
dropTimer()
|
|
558
572
|
const prompt = event.prompt ?? ""
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
# The notices the daemon writes when a write of its own did not go through
|
|
2
|
-
|
|
3
|
-
Part of `skill://legion-architect`. Read the section for the notice that woke you. Each of
|
|
4
|
-
`merge-refused`, `merge-stalled`, `merge-removed` and `merge-waiting` is the daemon reporting on
|
|
5
|
-
the merge it submitted for an accepted READY, and `message-refused` on a message it was posting
|
|
6
|
-
on an issue; each reaches the architect that owns the issue. The wake-routing table, in
|
|
7
|
-
`skill://legion-architect/references/wake-routing.md`, gives each notice its move in one
|
|
8
|
-
sentence; the section here is what that sentence stands on — what the notice's `reason` names,
|
|
9
|
-
what the daemon has and has not stopped doing, and what you read before you ask a person.
|
|
10
|
-
|
|
11
|
-
In every one of the four merge notices the issue stays in `awaiting_merge`, where no worker holds
|
|
12
|
-
a phase and a backward move is refused, so what a repository rule needs is a person's to give.
|
|
13
|
-
|
|
14
|
-
## `merge-refused`
|
|
15
|
-
|
|
16
|
-
Its `reason` names the pull request, READY's head, what the daemon asked GitHub to do (merge,
|
|
17
|
-
enqueue, or enable auto-merge for it), and GitHub's refusal, which a retry would meet again
|
|
18
|
-
(squash merges disabled, a permission the implement App lacks). The daemon has stopped submitting
|
|
19
|
-
that merge; the issue stays in `awaiting_merge`. The cause is a repository setting or an App
|
|
20
|
-
permission, a person's to change: ask one with `dispatch ask`, naming the refusal and the pull
|
|
21
|
-
request at READY's head, which that person merges under the repository's rules once it is fixed.
|
|
22
|
-
The merge closes the issue. Never bypass a rule.
|
|
23
|
-
|
|
24
|
-
## `merge-stalled`
|
|
25
|
-
|
|
26
|
-
Its `reason` names the pull request, the state and head GitHub shows (closed, or another head),
|
|
27
|
-
since when GitHub has shown it, and READY's head, which the record still awaits. GitHub's last
|
|
28
|
-
change to the pull request is more than 10 minutes old and the record never heard of it, so its
|
|
29
|
-
webhook never reached the daemon: the daemon has stopped submitting that merge, and the issue
|
|
30
|
-
stays in `awaiting_merge`. Read the pull request on GitHub. Open at READY's head, GitHub has
|
|
31
|
-
caught up: a person merges it under the repository's rules, and the merge closes the issue.
|
|
32
|
-
Closed, or at another head the daemon never recorded: ask a person with `dispatch ask`, naming the
|
|
33
|
-
pull request, what GitHub shows, and READY's head. Never bypass a rule.
|
|
34
|
-
|
|
35
|
-
## `merge-removed`
|
|
36
|
-
|
|
37
|
-
Its `reason` names who took the pull request out of the merge queue or turned its auto-merge off
|
|
38
|
-
at READY's head after the daemon submitted it, or says GitHub turned it off on its own (over a
|
|
39
|
-
repository setting such as a merge method the repository blocks) and names the App that submitted
|
|
40
|
-
the merge, which GitHub names as the actor of its own disables; then what was removed, GitHub's
|
|
41
|
-
reason (`manual`, `merge_conflict`, `manually_disabled`, `merge_commit_blocked`, …), when, and
|
|
42
|
-
READY's head. It was not a failed merge, which comes as a `checks-red` instead. The daemon submits
|
|
43
|
-
that merge no further, so the removal stands, and the issue stays in `awaiting_merge`. Read the
|
|
44
|
-
pull request on GitHub.
|
|
45
|
-
A `merge_conflict` removal reaches you only when the head conflicts with the base itself (GitHub's
|
|
46
|
-
merge state `DIRTY`), when GitHub answered no merge state for five minutes, or when it is the
|
|
47
|
-
second such removal of this head: a conflict with a pull request queued ahead of it, which that
|
|
48
|
-
merge state tells apart, the daemon submits once more at the same head and says so on the issue,
|
|
49
|
-
telling you nothing.
|
|
50
|
-
Where the conflict is on the base, the daemon's own conflict check sends the issue back to
|
|
51
|
-
`implementing` by itself.
|
|
52
|
-
Otherwise ask a person with `dispatch ask` (the one who removed it, when the reason names a person
|
|
53
|
-
rather than GitHub on its own), naming the pull request at READY's head and the reason; that
|
|
54
|
-
person merges or queues it again under the repository's rules when it should land, and the merge
|
|
55
|
-
closes the issue.
|
|
56
|
-
Never bypass a rule.
|
|
57
|
-
|
|
58
|
-
## `merge-waiting`
|
|
59
|
-
|
|
60
|
-
Its `reason` names the pull request, READY's head, how long the row has waited and what GitHub
|
|
61
|
-
last answered. GitHub has not completed the merge the daemon submitted within an hour of the
|
|
62
|
-
workflow queueing it at READY's acceptance. Nothing has been withdrawn: the merge stands, the
|
|
63
|
-
issue stays in `awaiting_merge`, and the daemon goes on submitting it, so there is nothing to undo
|
|
64
|
-
and you are told once, however much longer it waits. Read the pull request on GitHub and find what
|
|
65
|
-
GitHub is waiting for: a required check that never ran, a required check that failed, a review
|
|
66
|
-
only a person can give, or a merge queue that has not landed it. Act on what you find. In
|
|
67
|
-
`awaiting_merge` no worker holds a phase and a backward move is refused, so what a check, a review
|
|
68
|
-
or a repository rule needs is a person's: ask one with `dispatch ask`, naming the pull request at
|
|
69
|
-
READY's head and what GitHub waits on; the merge closes the issue when GitHub completes it,
|
|
70
|
-
whoever unblocks it. Never bypass a rule.
|
|
71
|
-
|
|
72
|
-
## `message-refused`
|
|
73
|
-
|
|
74
|
-
Its `reason` names the issue, Dispatch's own answer, and what the write carried: a message, with
|
|
75
|
-
how long it was and its first line, or a status write, with the status and whether it was set.
|
|
76
|
-
Dispatch refused that write the way it would refuse every attempt, so the daemon makes it no
|
|
77
|
-
more.
|
|
78
|
-
|
|
79
|
-
A close reason and a READY packet are checked against Dispatch's own bounds at the call that
|
|
80
|
-
carries them — `close_root` answers `CLOSE_REASON_TOO_LONG` and `handoff_complete` answers
|
|
81
|
-
`READY_PACKET_TOO_LONG`, each naming the bound and how far over the text is — so this notice is a
|
|
82
|
-
refusal those checks did not predict.
|
|
83
|
-
|
|
84
|
-
Those two calls also answer `CLOSE_REASON_DECISION_BLOCK` and `READY_PACKET_DECISION_BLOCK` for a
|
|
85
|
-
text holding a decision block (`:::ask{…}`). Such a text is refused however short it is, because
|
|
86
|
-
a question put in a message is one nobody can answer where it stands. The question belongs in the
|
|
87
|
-
issue's own document, as a decision block there, or in an ask opened with `dispatch ask`; the
|
|
88
|
-
close reason or the packet then goes again with the decision stated.
|
|
89
|
-
|
|
90
|
-
On a status write the daemon writes the status all the same, retrying it on the row's backoff
|
|
91
|
-
until Dispatch takes it, so the status is set unless Dispatch refused the status itself — the
|
|
92
|
-
reason says which. With the status set, only the reason beside it is on no issue: the issue's
|
|
93
|
-
lifecycle stands and nothing waits on you. With the status refused, the issue keeps the status
|
|
94
|
-
it had while the daemon's own record reads the one the write carried, and no retry of the
|
|
95
|
-
daemon's closes that gap: ask a person with `dispatch ask` to set on the issue the status the
|
|
96
|
-
reason names, saying what the record reads. The reason beside such a write may be on the issue
|
|
97
|
-
already, which the notice says. On a message the message is on no issue and nothing else about
|
|
98
|
-
the issue changed: no phase moved, and no worker was told.
|
|
99
|
-
|
|
100
|
-
Either way, what a person still needs is yours to post on the issue with `dispatch comment`. A
|
|
101
|
-
refused READY packet is nobody's to send again: the issue is in `awaiting_merge`, where no worker
|
|
102
|
-
holds a phase, and its merger's phase is over, so a completion from it is refused. Write that
|
|
103
|
-
comment yourself, naming the pull request at READY's head and where its verification stands; the
|
|
104
|
-
merge the daemon submits is unaffected and closes the issue when GitHub completes it.
|