dsh-hive-runner 1.0.14 → 1.0.15

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/CHANGELOG.md CHANGED
@@ -7,6 +7,24 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
  Version 0.6.0 is the first public snapshot; 0.1.0-0.5.0 were local development
8
8
  iterations of the plugin before this repository was published.
9
9
 
10
+ ## [1.0.15] - 2026-12-05
11
+
12
+ ### Fixed
13
+
14
+ - Queen tool visibility is now diagnosed and observable. On queen registration (and
15
+ retried by the patrol if the agent was not live yet) the plugin lists
16
+ `ctx.tools.schemas(queenAgent)` once, logs `queen visible tools (<n>): ...`, and
17
+ exposes `queenTools` / `queenToolsSessionId` / `queenToolsListedAt` /
18
+ `queenToolsError` in status. Investigation: under PTC the model request declares only
19
+ `run_code`; the plugin tools are registered globally and are bound inside `run_code`
20
+ (live session log shows successful `hive_arch_review` PTC dispatches). The earlier
21
+ "no tools" report came from the boundary guard blocking `run_code` before 1.0.12, not
22
+ from a per-agent registration failure.
23
+ - Added a tool-independent host fallback:
24
+ `hiveSupervisor.recordArchReview(repo, { card, verdict, findings, summary })` writes
25
+ the same durable `arch_review` event through the shared host writer, so a caller can
26
+ repair reviews when an agent tool is unavailable; `hive_events` verifies it.
27
+
10
28
  ## [1.0.14] - 2026-12-05
11
29
 
12
30
  ### Fixed
@@ -28,6 +46,10 @@ iterations of the plugin before this repository was published.
28
46
  - `patrolMs` is still accepted as a legacy alias for `patrolIntervalMs`; both keys are
29
47
  reported on the resolved config.
30
48
 
49
+ ### Published
50
+
51
+ - npm: `dsh-hive-runner@1.0.14` on 2026-12-05.
52
+
31
53
  ## [1.0.13] - 2026-12-05
32
54
 
33
55
  ### Added
package/SPEC.md CHANGED
@@ -62,6 +62,10 @@ wrong method -> `405` (`hive/method-not-allowed`).
62
62
  "lastDiscoverError": null,
63
63
  "pendingAnomalies": 0,
64
64
  "repoCount": 1,
65
+ "queenTools": ["hive_arch_review", "run_code"],
66
+ "queenToolsSessionId": "queen-session-id",
67
+ "queenToolsListedAt": "2026-12-05T09:00:00.000Z",
68
+ "queenToolsError": null,
65
69
  "claimedButOrphaned": 0,
66
70
  "workerSessionIds": ["worker-session-id"],
67
71
  "repos": [
@@ -122,6 +126,8 @@ wrong method -> `405` (`hive/method-not-allowed`).
122
126
  - `backlog` — aggregate `{ queued, inFlight, completed }` for the current or last drain.
123
127
  - `pendingCheckpoints` — progress checkpoints queued while no live queen Session was
124
128
  available; the next patrol/queen registration flushes them.
129
+ - `queenTools` — one-shot diagnostic list of tool schema names visible to the registered
130
+ queen Agent, with `queenToolsSessionId`, `queenToolsListedAt`, `queenToolsError`.
125
131
  - `repos` / `repoCount` — the status-visible repository registry. `hiveSupervisor.addRepo(repo)`
126
132
  adds one at runtime (absolute path, must be an initialized Hive repository; idempotent;
127
133
  rejects a relative or uninitialized path).
@@ -392,6 +398,10 @@ counts + gate + recent completed ids); a change re-arms it. With no live queen
392
398
  Session it stays pending (`status.pendingCheckpoints`) and is flushed by the next
393
399
  patrol or queen registration.
394
400
 
401
+ A host-side fallback writes the same durable event without the agent tool:
402
+ `hiveSupervisor.recordArchReview(repo, { card, verdict, findings, summary })`; the
403
+ read-only `hive_events` tool verifies the appended event.
404
+
395
405
  ### 8.6.2 Queen tool boundary
396
406
 
397
407
  DSH's `ctx.tools.guard` lets a plugin veto a tool call after pre-execute policy and
package/docs/DESIGN.md CHANGED
@@ -51,6 +51,10 @@ Response:
51
51
  "lastDiscoverError": null,
52
52
  "pendingAnomalies": 0,
53
53
  "pendingCheckpoints": 0,
54
+ "queenTools": ["hive_arch_review", "run_code"],
55
+ "queenToolsSessionId": "queen-session-id",
56
+ "queenToolsListedAt": "2026-12-05T09:00:00.000Z",
57
+ "queenToolsError": null,
54
58
  "repoCount": 1,
55
59
  "claimedButOrphaned": 0,
56
60
  "workerSessionIds": ["worker-session-id"],
@@ -113,6 +117,10 @@ Response:
113
117
  last drain.
114
118
  - `pendingCheckpoints` — progress checkpoints queued while no live queen Session was
115
119
  available; the next patrol/queen registration flushes them.
120
+ - `queenTools` — one-shot diagnostic: the tool schema names visible to the registered
121
+ queen Agent (`ctx.tools.schemas(agent)`), plus `queenToolsSessionId`,
122
+ `queenToolsListedAt` and `queenToolsError`. Under the PTC preset the model-facing
123
+ request only exposes `run_code`; this list proves `hive_*` bindings exist inside it.
116
124
  - `repos` / `repoCount` — the repositories the supervisor currently tracks; this is the
117
125
  status-visible registry the panel renders. Runtime additions go through
118
126
  `hiveSupervisor.addRepo(repo)` (absolute path, initialized Hive repository, idempotent).
@@ -346,6 +354,28 @@ queen Session the checkpoint is kept in the controller's pending list (status
346
354
  `pendingCheckpoints`) and flushed by the next patrol or queen registration; it never
347
355
  falls through to an anomaly digest.
348
356
 
357
+ ### Tool visibility diagnostic and host fallback
358
+
359
+ Under the PTC preset the model-facing request declares only `run_code`; the plugin's
360
+ `hive_*` tools are still registered globally by `apply()` and are visible to the agent
361
+ as schemas inside `run_code` (`tool/ptc-dispatch-start` events for `hive_arch_review`
362
+ prove this on the live queen session). The 1.0.11 queen saw `run_code` denied by an
363
+ earlier version of the boundary guard and concluded that no tools existed; 1.0.12
364
+ allows `run_code`, and its nested `write`/`bash` calls remain vetoed. No per-agent
365
+ registration path change is needed for a correctly mounted plugin.
366
+
367
+ To make this observable, the plugin lists `ctx.tools.schemas(queenAgent)` once per
368
+ registered queen Session, logs the names, and exposes them as `queenTools` /
369
+ `queenToolsSessionId` / `queenToolsListedAt` / `queenToolsError` in status. If the
370
+ agent is not live yet, the patrol retries the listing; the log line is
371
+ `queen visible tools (<n>): ...`.
372
+
373
+ If a queen Session genuinely cannot reach the tool, the host has a tool-independent
374
+ fallback: `hiveSupervisor.recordArchReview(repo, { card, verdict, findings, summary })`
375
+ writes the same durable `arch_review` event through the shared host writer. The
376
+ `hive_events` tool remains read-only and can verify the event; a host/panel caller can
377
+ also invoke the service method directly.
378
+
349
379
  ### Tool boundary: hard veto through `ctx.tools.guard`
350
380
 
351
381
  DSH does expose a plugin-side tool veto. `ToolsService.guard(guard)` registers a
package/index.js CHANGED
@@ -105,6 +105,9 @@ export function apply(ctx, config = {}) {
105
105
  // POST ?op=queen). Every worker is parented to exactly that Session; before
106
106
  // registration the supervisor does not dispatch at all.
107
107
  const queenSession = { sessionId: null };
108
+ // One-shot diagnostic: schema names visible to the queen agent (under PTC the
109
+ // model sees only run_code, but tools.hive_* exist inside run_code).
110
+ const queenTools = { names: [], sessionId: null, listedAt: null, error: null };
108
111
  /** Queen boundary violations observed by the tool guard (status observability). */
109
112
  const queenBoundary = { count: 0, last: null };
110
113
  let parentProviderImpl;
@@ -198,6 +201,40 @@ export function apply(ctx, config = {}) {
198
201
  }
199
202
  }
200
203
 
204
+ /**
205
+ * One-shot diagnostic: list the tool schemas the queen agent actually sees.
206
+ * Under the PTC preset the model-facing request only exposes run_code; this
207
+ * listing proves whether hive_* definitions are bound inside run_code.
208
+ * Logged once per registered queen Session and exposed in status.queenTools.
209
+ * @param {string} sessionId
210
+ */
211
+ function inspectQueenTools(sessionId) {
212
+ if (typeof sessionId !== 'string' || sessionId === '') return;
213
+ if (queenTools.sessionId === sessionId && queenTools.listedAt !== null) return;
214
+ let agent;
215
+ try {
216
+ agent = ctx.get('agents')?.get?.(sessionId);
217
+ } catch (error) {
218
+ queenTools.error = 'queen-agent-lookup-failed';
219
+ log('warn', 'queen tool listing: agent lookup failed', error);
220
+ return;
221
+ }
222
+ if (agent === undefined) {
223
+ queenTools.error = 'queen-agent-not-live';
224
+ return;
225
+ }
226
+ try {
227
+ const names = ctx.tools.schemas(agent).map((tool) => tool.name).sort();
228
+ queenTools.names = names;
229
+ queenTools.sessionId = sessionId;
230
+ queenTools.listedAt = new Date().toISOString();
231
+ queenTools.error = null;
232
+ log('info', 'queen visible tools (' + names.length + '): ' + names.join(', '));
233
+ } catch (error) {
234
+ queenTools.error = 'schema-listing-failed: ' + (error instanceof Error ? error.message : String(error));
235
+ log('warn', 'queen tool listing failed', error);
236
+ }
237
+ }
201
238
  // DSH tools.guard is evaluated after pre-execute policy/approval and before a
202
239
  // tool body; returning a denial makes the call fail without executing it.
203
240
  // Recognition is registration OR an ordinary initialized-repo Session; a
@@ -247,6 +284,8 @@ export function apply(ctx, config = {}) {
247
284
  activeRuns: (repo) => runner.activeRuns(repo),
248
285
  queenSession,
249
286
  queenBoundary,
287
+ queenTools: () => queenTools,
288
+ archReview: (repo, review) => recordArchReviewHost(repo, review),
250
289
  readMode: (repo) => commands.mode(repo),
251
290
  onAnomaly: (event) => recordAnomaly(event),
252
291
  onGateChange: (event) => {
@@ -254,7 +293,8 @@ export function apply(ctx, config = {}) {
254
293
  void checkpoint.requestTick({ repo: event.repo }).catch((error) => log('warn', 'checkpoint gate tick failed', error));
255
294
  }
256
295
  },
257
- onQueenSession: () => {
296
+ onQueenSession: (sessionId) => {
297
+ inspectQueenTools(sessionId);
258
298
  if (patrol !== undefined) patrol.flushPending();
259
299
  if (checkpoint !== undefined) checkpoint.flushPending();
260
300
  },
@@ -285,6 +325,9 @@ export function apply(ctx, config = {}) {
285
325
  log('warn', 'arch review audit failed for ' + repo + ': ' + (error instanceof Error ? error.message : String(error)));
286
326
  }
287
327
  }
328
+ // Retry the one-shot tool listing if the panel registered before the agent
329
+ // was live (status/queenTools then contains an error until this succeeds).
330
+ if (supervisor.queenSession.sessionId !== null) inspectQueenTools(supervisor.queenSession.sessionId);
288
331
  // Progress checkpoints: drained/all-done/gate-advance/idle goals. Delivery
289
332
  // is direct; failures stay pending in the checkpoint controller.
290
333
  try {
@@ -601,6 +644,39 @@ export function apply(ctx, config = {}) {
601
644
  },
602
645
  });
603
646
 
647
+ /**
648
+ * Shared arch-review writer used by the hive_arch_review tool and the
649
+ * host-side hiveSupervisor.recordArchReview() fallback. Appends the durable
650
+ * event; never edits the card.
651
+ * @param {string | undefined} repoArg
652
+ * @param {{ card?: string, verdict?: string, findings?: string[], summary?: string }} review
653
+ * @param {{ signal?: AbortSignal, agent?: object }} [exec]
654
+ * @returns {Promise<object>} the appended event
655
+ */
656
+ async function recordArchReviewHost(repoArg, review = {}, exec = {}) {
657
+ const repo = repoArg === undefined || repoArg === null || repoArg === ''
658
+ ? resolved.cwd
659
+ : normalizeRepoKey(String(repoArg));
660
+ if (repo !== resolved.cwd && !supervisor.hasRepo(repo)) {
661
+ throw new Error('repo ' + JSON.stringify(repo) + ' is not a configured Hive repository');
662
+ }
663
+ const cardId = typeof review.card === 'string' ? review.card.trim() : '';
664
+ if (cardId === '') throw new Error('hive_arch_review needs card');
665
+ const card = await commands.show(repo, cardId, {
666
+ signal: exec?.signal,
667
+ session: exec?.agent?.session,
668
+ });
669
+ if (card === null || card === undefined) throw new Error('no such card: ' + cardId);
670
+ if (card.state !== 'done') {
671
+ throw new Error('architecture review runs after acceptance: card ' + card.id + ' is ' + card.state + ', not done');
672
+ }
673
+ return appendArchReview(repo, {
674
+ card: card.id,
675
+ verdict: review.verdict,
676
+ findings: review.findings,
677
+ summary: review.summary,
678
+ });
679
+ }
604
680
  registerTextTool({
605
681
  name: 'hive_arch_review',
606
682
  description:
@@ -620,22 +696,7 @@ export function apply(ctx, config = {}) {
620
696
  summary: { type: 'string', description: 'One-line summary of the review.' },
621
697
  },
622
698
  execute: async (args = {}, exec) => {
623
- const repo = repoOf(args);
624
- if (typeof args.card !== 'string' || args.card.trim() === '') throw new Error('hive_arch_review needs card');
625
- const card = await commands.show(repo, args.card.trim(), {
626
- signal: exec?.signal,
627
- session: exec?.agent?.session,
628
- });
629
- if (card === null || card === undefined) throw new Error('no such card: ' + args.card);
630
- if (card.state !== 'done') {
631
- throw new Error('architecture review runs after acceptance: card ' + card.id + ' is ' + card.state + ', not done');
632
- }
633
- const event = appendArchReview(repo, {
634
- card: card.id,
635
- verdict: args.verdict,
636
- findings: args.findings,
637
- summary: args.summary,
638
- });
699
+ const event = await recordArchReviewHost(args.repo, args, exec);
639
700
  return jsonText({ ok: true, event });
640
701
  },
641
702
  });
package/lib/supervisor.js CHANGED
@@ -140,6 +140,8 @@ export class HiveSupervisor {
140
140
  * @param {(event: object) => void} [options.onAnomaly] supervision event sink (queen digest)
141
141
  * @param {(event: object) => void} [options.onGateChange] gate phase/release-readiness change sink
142
142
  * @param {(sessionId: string) => void} [options.onQueenSession] called after a queen Session registers
143
+ * @param {() => { names?: string[], sessionId?: string | null, listedAt?: string | null, error?: string | null }} [options.queenTools] diagnostic: tools visible to the queen agent
144
+ * @param {(repo: string, review: object) => Promise<object>} [options.archReview] host-side arch_review fallback
143
145
  * @param {() => number} [options.pendingAnomalies] undelivered queen anomalies reported in status
144
146
  * @param {() => number} [options.pendingCheckpoints] undelivered progress checkpoints reported in status
145
147
  * @param {Console} [options.logger]
@@ -180,6 +182,8 @@ export class HiveSupervisor {
180
182
  this.onAnomaly = typeof options.onAnomaly === 'function' ? options.onAnomaly : undefined;
181
183
  this.onGateChange = typeof options.onGateChange === 'function' ? options.onGateChange : undefined;
182
184
  this.onQueenSession = typeof options.onQueenSession === 'function' ? options.onQueenSession : undefined;
185
+ this.queenTools = typeof options.queenTools === 'function' ? options.queenTools : undefined;
186
+ this.archReview = typeof options.archReview === 'function' ? options.archReview : undefined;
183
187
  this.pendingAnomalies = typeof options.pendingAnomalies === 'function' ? options.pendingAnomalies : undefined;
184
188
  this.pendingCheckpoints = typeof options.pendingCheckpoints === 'function' ? options.pendingCheckpoints : undefined;
185
189
  this.discover = options.discover;
@@ -393,6 +397,22 @@ export class HiveSupervisor {
393
397
  return this.status();
394
398
  }
395
399
 
400
+ /**
401
+ * Host-side fallback for the queen's arch-review tool. The normal path is the
402
+ * registered hive_arch_review tool (inside run_code under PTC); this method
403
+ * lets a host/panel/CLI caller record the same event when the agent tool is
404
+ * unavailable.
405
+ * @param {string} repo
406
+ * @param {{ card: string, verdict: string, findings?: string[], summary?: string }} review
407
+ * @returns {Promise<object>}
408
+ */
409
+ async recordArchReview(repo, review) {
410
+ if (typeof this.archReview !== 'function') {
411
+ throw new Error('host arch-review fallback is not configured');
412
+ }
413
+ return this.archReview(repo, review);
414
+ }
415
+
396
416
  /**
397
417
  * Live worker Session ids across every registered repository. The panel uses
398
418
  * this to exempt worker conversations from the queen role/prompt and guard.
@@ -569,6 +589,8 @@ export class HiveSupervisor {
569
589
  // queen Session.
570
590
  pendingAnomalies: this.#pendingAnomalyCount(),
571
591
  pendingCheckpoints: this.#pendingCheckpointCount(),
592
+ // One-shot diagnostic: which tool names the registered queen agent can see.
593
+ ...this.#queenToolsStatus(),
572
594
  repoCount: this.repos.size,
573
595
  // Worker Session ids across all repositories: the panel exempts them from
574
596
  // queen-mode prompt injection and the guard exempts their tool calls.
@@ -852,6 +874,23 @@ export class HiveSupervisor {
852
874
  };
853
875
  }
854
876
 
877
+ /** Tool visibility diagnostic for status; observability never throws. */
878
+ #queenToolsStatus() {
879
+ try {
880
+ const info = typeof this.queenTools === 'function' ? this.queenTools() : null;
881
+ if (info === null || typeof info !== 'object') {
882
+ return { queenTools: [], queenToolsSessionId: null, queenToolsListedAt: null, queenToolsError: null };
883
+ }
884
+ return {
885
+ queenTools: Array.isArray(info.names) ? info.names : [],
886
+ queenToolsSessionId: typeof info.sessionId === 'string' ? info.sessionId : null,
887
+ queenToolsListedAt: typeof info.listedAt === 'string' ? info.listedAt : null,
888
+ queenToolsError: typeof info.error === 'string' ? info.error : null,
889
+ };
890
+ } catch {
891
+ return { queenTools: [], queenToolsSessionId: null, queenToolsListedAt: null, queenToolsError: 'status-read-failed' };
892
+ }
893
+ }
855
894
  /** Emit one supervision event without letting the sink break scheduling. */
856
895
  #anomaly(event) {
857
896
  if (this.onAnomaly === undefined) return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-hive-runner",
3
- "version": "1.0.14",
3
+ "version": "1.0.15",
4
4
  "description": "DSH host plugin for Hive: a resident supervisor that runs one DSH subagent per ready task card, with per-role worker limits, pause/resume and Hive tools.",
5
5
  "type": "module",
6
6
  "main": "./index.js",