@sjawhar/claude-envoy 4.15.3 → 4.16.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.
@@ -7,6 +7,7 @@ Read it when you review or approve, or work a look of a closed issue's productio
7
7
  1. Read CI on GitHub and the issue's results with `dispatch results --issue <issue>`, never from a handoff.
8
8
  2. When the diff the round reads touches runtime code (the whole change, or the difference from the commit your task names), run `task(agent="thermonuclear-deep-review")` and `task(agent="thermonuclear-code-quality")` once at the head the round reviews, and `wait` for each result: each runs as a job of its own. Each agent reviews only the diff its task supplies, so name in each task the commit, the head and `git diff <sha> <head>` as the diff, or the whole change. The last two sentences of your task, `Last reviewed commit: <sha>.` and `Review entry: <n>.`, are the daemon's; your role prompt says how to read them.
9
9
  3. A result that carries no report, or that names another place for it, is a failed run, not a verdict: run that agent again, or read its transcript. Reading the agent's diff yourself and recording that in its place is the same as answering the rubric from a bare verdict. When you can do neither, that half of the round has no review: tell the architect, do not approve, and wait with a `WAITING` line naming what you wait on until it answers.
10
+ 4. A `CHANGES` from either half is answered in the review: its findings are carried into a `REQUEST_CHANGES`, or each finding is recorded with why it does not stand. Your `APPROVE` needs both halves run at the reviewed head, or both `Thermo` rows reading `not run` because the diff the round reads touches no runtime code (the whole change, or the difference from the last reviewed commit to the head).
10
11
 
11
12
  ### What the base requires
12
13
 
@@ -27,8 +27,10 @@ The implementer writes the body from this template when the pull request opens;
27
27
  - Thread <node id>: accepted by the reviewer — <its reason, one line>; resolved at <head-sha>.
28
28
  - Thread <node id>: still open — <what remains>; unresolved at <head-sha>.
29
29
 
30
- **Thermo:** `simplify-settled-diff` once at <head-sha>: <0 applied | applied → new head <sha>>; defects reported: <none | <n>, fixed in <sha>>; thermonuclear pair at the reviewed head <sha> over <the whole change | <last-reviewed-sha>..<sha>>:
31
- <verdict>. (on a docs-only PR the simplify half and the defects are recorded as on any other diff, and the pair half reads `thermonuclear pair: not run (docs-only)`) (in a later round whose difference touches no runtime code, the pair half reads `thermonuclear pair at the reviewed head <sha>: not run (<last-reviewed-sha>..<sha> touches no runtime code)`, and the pair half of the last round the pair ran in stays beside it)
30
+ **Thermo:** `simplify-settled-diff` once at <head-sha>, a docs-only PR included: <0 applied | applied → new head <sha>>; defects reported: <none | <n>, fixed in <sha>>; thermonuclear pair at the reviewed head <sha> over <the whole change | <last-reviewed-sha>..<sha>>, one row per half:
31
+ - `thermonuclear-deep-review`: <APPROVE | CHANGES>, <n> findings stand
32
+ - `thermonuclear-code-quality`: <APPROVE | CHANGES>, <n> findings stand
33
+ Where the diff the round reads touches no runtime code, each row reads `not run (<the whole change | <last-reviewed-sha>..<sha>> touches no runtime code)`, and the two rows of the last round the pair ran in stay beside them.
32
34
 
33
35
  **Checks:** one line per `check` block of the issue's Verification document, in the document's
34
36
  order. Each is the line `dispatch result` printed when the result was recorded, or the
@@ -63,7 +65,7 @@ The implementer keeps `Outcome`, `Why`, `Change`, `Proven by` and `Size` true af
63
65
  - The tester tries to break the changed surface (wrong and boundary inputs, the second and the concurrent run, the party it must refuse) and writes the red test for a way no test would catch. Lint, types and the unit and integration suites are CI's: read them on GitHub at the head, rerun no lane as evidence, and wait for none.
64
66
  - After a forward merge, the tester reruns each check the merge can reach (`skill://legion-worker/references/conflicts-and-rewrites.md`) and records each other check with no `ci_check` at the new head unrun, its `--observed` naming the earlier pass and why the merge misses it. A class search that finds an instance, or a parent's last round, takes a full test round.
65
67
  - The implementer runs `skill://simplify-settled-diff` once per pull request, in its first implementing round, after its own results and before it completes, whatever the diff touches, a docs-only diff included. Applied: rerun the fast local checks and the issue's checks the simplify diff touches, and record them at the applied head. A defect the pass reports is fixed outside the pass and the results recorded again, never dropped as out of scope; the `Thermo` line names the count and the fixing commit.
66
- - The reviewer's pair runs at the head each round reviews, over the diff that round reads, when that diff touches runtime code; the `Thermo` line records the range it read, and earlier rounds' pair halves stay beside it.
68
+ - The reviewer's pair runs at the head each round reviews, over the diff that round reads, when that diff touches runtime code; the `Thermo` line records the range it read and a row per half, and earlier rounds' rows stay beside them.
67
69
 
68
70
  ## Never waiting on CI
69
71
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sjawhar/claude-envoy",
3
- "version": "4.15.3",
3
+ "version": "4.16.0",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Claude Code plugin for Legion's Envoy bus",
6
6
  "type": "module",
@@ -19,7 +19,7 @@
19
19
  "AGENTS.md"
20
20
  ],
21
21
  "legion": {
22
- "daemonApiVersion": 188
22
+ "daemonApiVersion": 193
23
23
  },
24
24
  "repository": {
25
25
  "type": "git",
@@ -83,7 +83,6 @@ import {
83
83
  roleHeldBy,
84
84
  type SubscribeResult,
85
85
  } from "@legion/envoy-client/transport"
86
- import { createLegionDaemonClient } from "@legion/pi-shared/daemon-client"
87
86
  import { findPushedBranchHead, paneHandoffReport } from "@legion/pi-shared/handoff-record"
88
87
  import { Server } from "@modelcontextprotocol/sdk/server/index.js"
89
88
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
@@ -120,6 +119,7 @@ import {
120
119
  type LegionClaim,
121
120
  legionPane,
122
121
  logLegion,
122
+ paneDaemonClient,
123
123
  startLegionClaim,
124
124
  stopPane,
125
125
  } from "./legion-claim"
@@ -2528,7 +2528,7 @@ export async function runEnvoyChannelServer(): Promise<void> {
2528
2528
  // NATS_AUTH=broker waits for the session's token for as long as the server lives.
2529
2529
  let starting = "it reads its settings"
2530
2530
  let claim: LegionClaim | undefined
2531
- const daemon = pane === undefined ? undefined : createLegionDaemonClient(pane.daemonUrl)
2531
+ const daemon = pane === undefined ? undefined : paneDaemonClient(pane.daemonUrl)
2532
2532
  // INFRA-220: the phase reminder's Claude Code host (`./legion-phase-hook`), which Claude Code's
2533
2533
  // own hooks drive through the `legion_phase_hook` tool. It is started here, beside the claim it
2534
2534
  // gates on, and restores this session's record as it starts, before any hook can be answered.
@@ -2564,7 +2564,7 @@ export async function runEnvoyChannelServer(): Promise<void> {
2564
2564
  claim: () => claim?.capability(),
2565
2565
  booted: claimBooted.promise,
2566
2566
  firstTurnStarted: () => reportFirstTurn?.(),
2567
- readState: (signal) => daemon.state({ signal }),
2567
+ readRecord: (issue, signal) => daemon.record(issue, { signal }),
2568
2568
  reportActivity: (input) => daemon.activity(input),
2569
2569
  inbox: inbox === undefined ? undefined : (text) => inbox.notification({ content: text }),
2570
2570
  publish: client.publish,
@@ -6,7 +6,7 @@ import { messageFor } from "@legion/envoy-client/errors"
6
6
  import { readSecretFile } from "@legion/envoy-client/secret-file"
7
7
  import type { EnvoyClient } from "@legion/envoy-client/transport"
8
8
  import { claimFirstTurnBoundMs } from "@legion/pi-shared/claim-first-turn-bound"
9
- import type { LegionDaemonClient } from "@legion/pi-shared/daemon-client"
9
+ import { createLegionDaemonClient, type LegionDaemonClient } from "@legion/pi-shared/daemon-client"
10
10
  import { bootLegionClaim, type LegionClaimBoot } from "@legion/pi-shared/legion-claim-core"
11
11
  import type { ClaimCapability } from "@legion/pi-shared/legion-phase-ops"
12
12
  import { legion } from "../package.json" with { type: "json" }
@@ -61,6 +61,16 @@ export function legionPane(env: NodeJS.ProcessEnv): LegionPane | undefined {
61
61
  }
62
62
  }
63
63
 
64
+ /**
65
+ * The pane's client for the daemon. It states this build's own `legion.daemonApiVersion` on
66
+ * every request, read from the manifest of the module this process loaded, as the claim's
67
+ * registration below reads it: the daemon serves each answer in the shape the contract the
68
+ * caller states describes, so a pane an older or newer daemon answers still reads its answers.
69
+ */
70
+ export function paneDaemonClient(daemonUrl: string): LegionDaemonClient {
71
+ return createLegionDaemonClient(daemonUrl, { pluginContract: legion.daemonApiVersion })
72
+ }
73
+
64
74
  /** Writes one line to the pane's log, the server's stderr. */
65
75
  export function logLegion(line: string): void {
66
76
  process.stderr.write(`[legion] ${line}\n`)
@@ -1,7 +1,7 @@
1
1
  import { randomUUID } from "node:crypto"
2
2
  import { readFileSync, renameSync, rmSync, writeFileSync } from "node:fs"
3
3
  import { dirname, join } from "node:path"
4
- import type { LegionState } from "@legion/contracts/legion-api"
4
+ import type { LegionIssue } from "@legion/contracts/legion-api"
5
5
  import { messageFor } from "@legion/envoy-client/errors"
6
6
  import type { ActivityInput } from "@legion/pi-shared/daemon-client"
7
7
  import type { ClaimCapability } from "@legion/pi-shared/legion-phase-ops"
@@ -182,9 +182,10 @@ export interface PhaseHookDeps {
182
182
  * registered its step — the bridge's seeding `/rename` — signals nothing, and one after the
183
183
  * name is taken costs nothing. */
184
184
  readonly firstTurnStarted: () => void
185
- /** The daemon's whole state, for the reminder's record check, aborted with `signal` once the
186
- * check's bound passes (`PhaseReminderDeps.readState`). */
187
- readonly readState: (signal: AbortSignal) => Promise<LegionState>
185
+ /** One issue's record, for the reminder's record check, aborted with `signal` once the
186
+ * check's bound passes (`PhaseReminderDeps.readRecord`): the record, or `undefined` for an
187
+ * issue the daemon records nothing of. */
188
+ readonly readRecord: (issue: string, signal: AbortSignal) => Promise<LegionIssue | undefined>
188
189
  /** Sends this session's activity report to the daemon (`LegionDaemonClient.activity`), so the
189
190
  * idle rule can decide whether the pane's pod may be released (INFRA-945). */
190
191
  readonly reportActivity: (input: ActivityInput) => Promise<void>
@@ -410,7 +411,7 @@ export function createPhaseHookEndpoint(deps: PhaseHookDeps): PhaseHookEndpoint
410
411
  // count was never recorded is what the count exists to catch.
411
412
  saveEntry: saveRecord,
412
413
  claim: deps.claim,
413
- readState: deps.readState,
414
+ readRecord: deps.readRecord,
414
415
  // The server's own listener client, so the notice reaches the one this session already talks
415
416
  // to; Envoy off for the session leaves it undefined, the runner says so once at debug, and
416
417
  // the reminder keeps coming without a notice.
@@ -9,8 +9,17 @@ import {
9
9
  PHASE_OP_SENTENCES,
10
10
  PHASE_OPS,
11
11
  phaseOpParameters,
12
+ pluginBuildOf,
12
13
  } from "@legion/pi-shared/legion-phase-ops"
13
14
  import { z } from "zod"
15
+ import pkg from "../package.json" with { type: "json" }
16
+
17
+ /** This plugin's own build, which `read_build` answers with: the manifest of the module this
18
+ * process loaded, never a path read anywhere else. In a pod a Claude Code role installs no plugin
19
+ * (the daemon's `NoPluginInstall`) and loads its image's own claude-envoy, so a relaunch keeps
20
+ * this build and only the update round over the pod brings another. It is an Oh My Pi role's
21
+ * relaunch that installs its plugin pair fresh under the role's state home. */
22
+ const BUILD = pluginBuildOf(pkg)
14
23
 
15
24
  /** The tool's name: Claude Code shows it as `mcp__legion__legion`, under the pane's one server. */
16
25
  export const LEGION_TOOL_NAME = "legion"
@@ -23,7 +32,7 @@ export function legionToolDefinition() {
23
32
  description: legionToolDescription({
24
33
  envoyPublish: "mcp__legion__envoy_publish",
25
34
  before: PHASE_OP_SENTENCES.readRecord + PHASE_OP_SENTENCES.readReleaseRecords,
26
- after: PHASE_OP_SENTENCES.requestBackwardMove,
35
+ after: PHASE_OP_SENTENCES.requestBackwardMove + PHASE_OP_SENTENCES.readBuild,
27
36
  }),
28
37
  inputSchema: z.toJSONSchema(z.object({ op: z.enum(PHASE_OPS), ...phaseOpParameters(z) })),
29
38
  }
@@ -64,6 +73,7 @@ export async function executeLegionTool(
64
73
  {
65
74
  daemon: runtime.daemon,
66
75
  claim,
76
+ build: BUILD,
67
77
  handoffReport: runtime.handoffReport,
68
78
  branchHead: runtime.branchHead,
69
79
  ...(signal === undefined ? {} : { restart: { signal } }),