dsh-hive-panel 1.0.9 → 1.0.10
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 +18 -0
- package/README.md +4 -1
- package/SPEC.md +11 -5
- package/docs/DESIGN.md +9 -2
- package/lib/queen.js +79 -2
- package/package.json +1 -1
- package/scripts/verify.mjs +76 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,20 @@ All notable changes to this project are documented in this file. The format is
|
|
|
4
4
|
based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and this project
|
|
5
5
|
adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
+
## [1.0.10] - 2026-12-05
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- The queen contract is never injected into worker Sessions: activation worker Sessions
|
|
12
|
+
(subagent / delegation children) are skipped before the cwd-based queen detection, so
|
|
13
|
+
a worker running inside an initialised repository is not treated as the queen and does
|
|
14
|
+
not receive the queen invariants or the `/queen off` suppression. Complements
|
|
15
|
+
dsh-hive-runner 1.0.11's worker exemption in the tool guard.
|
|
16
|
+
|
|
17
|
+
### Tests
|
|
18
|
+
|
|
19
|
+
- 43 checks pass, including the worker Session skip and the unchanged queen paths.
|
|
20
|
+
|
|
7
21
|
## [1.0.9] - 2026-12-05
|
|
8
22
|
|
|
9
23
|
### Fixed
|
|
@@ -15,6 +29,10 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
|
15
29
|
|
|
16
30
|
- 41 checks pass, including the synced top row and the rebuilt client.
|
|
17
31
|
|
|
32
|
+
### Published
|
|
33
|
+
|
|
34
|
+
- npm: `dsh-hive-panel@1.0.9` on 2026-12-05.
|
|
35
|
+
|
|
18
36
|
## [1.0.8] - 2026-12-05
|
|
19
37
|
|
|
20
38
|
### Fixed
|
package/README.md
CHANGED
|
@@ -286,7 +286,10 @@ supervisor registration happens on the same first assembly.
|
|
|
286
286
|
implement; never call `write`/`edit`/`apply_patch`/`bash`/`cua` or any file-mutating or
|
|
287
287
|
command-executing tool; tasks and state use only `hive_*` tools; `claim`/`done`/`fail` are
|
|
288
288
|
worker actions the queen must not call; implementation is delegated to the supervisor). The
|
|
289
|
-
|
|
289
|
+
Card-worker Sessions are never injected or registered as the queen (the supervisor's
|
|
290
|
+
`isWorkerSession(sessionId)`, or the parent/queen and subagent header markers), so they keep
|
|
291
|
+
their normal write/edit/bash tools. The tool-boundary sentence is injected in English and
|
|
292
|
+
Chinese, so an older `hive init` role file
|
|
290
293
|
gets it without re-running init. Goals become Hive tasks; discussion creates tasks only when
|
|
291
294
|
asked to execute, so a stale or custom workspace role file cannot remove the boundary.
|
|
292
295
|
- If you expose DSH Web beyond your machine, add authentication or a reverse proxy at the
|
package/SPEC.md
CHANGED
|
@@ -309,9 +309,14 @@ Activation:
|
|
|
309
309
|
the role + trusted invariants, and registers it with the supervisor. This is the
|
|
310
310
|
path that keeps a restarted DSH, or a Session that never opened the panel, on the
|
|
311
311
|
queen contract instead of a plain coding agent; only that Session's cwd is read.
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
312
|
+
Worker Sessions are excluded so they keep their normal coding tools: the host asks
|
|
313
|
+
the mounted supervisor's new `isWorkerSession(sessionId)` first (authoritative when
|
|
314
|
+
it answers true); otherwise it falls back to
|
|
315
|
+
`session.header.parentSession` equal to the registered queen Session id, or the
|
|
316
|
+
durable subagent markers (`header.origin === "subagent"` / a positive
|
|
317
|
+
`header.delegationDepth`). Card workers share the repository cwd and must never be
|
|
318
|
+
auto-queened, injected with the "do not write code" contract, registered as the
|
|
319
|
+
queen, or blocked from their write/edit/bash tools by the queen mutation guard.
|
|
315
320
|
2. **Snapshot auto (default).** Before returning a `200` snapshot, the host probes
|
|
316
321
|
`refs/hive/v1` and the `hive init` marker files in the Session cwd. When the repo
|
|
317
322
|
is initialised, `autoQueen` is not `false`, and the Session was not explicitly
|
|
@@ -387,6 +392,7 @@ Host APIs used: `connection.fetch.register`, `sessions`, `workingDirectory`, `sh
|
|
|
387
392
|
`ctx.effect` and `ctx.on('agent/disposed')`. `sandboxPolicy`, `sessionPersistence`
|
|
388
393
|
and `hiveSupervisor` are optional and read through `ctx.get`. The supervisor contract
|
|
389
394
|
used here is `setQueenSession(sessionId)` plus the optional `addRepo(repo)` /
|
|
390
|
-
`hasRepo(repo)` from dsh-hive-runner's `HiveSupervisor`
|
|
391
|
-
supervisors get no repository registration
|
|
395
|
+
`hasRepo(repo)` / `isWorkerSession(sessionId)` from dsh-hive-runner's `HiveSupervisor`
|
|
396
|
+
(feature-detected; older supervisors get no repository registration and fall back to
|
|
397
|
+
the Session-header worker markers). A DSH upgrade can change any of these:
|
|
392
398
|
re-run `npm run check` against the installed DSH before releasing.
|
package/docs/DESIGN.md
CHANGED
|
@@ -300,6 +300,11 @@ token(PATH 名或绝对路径)。
|
|
|
300
300
|
**单向**的:`/queen off`、agent dispose、插件卸载、进程重启都不会 `removeRepo`;
|
|
301
301
|
supervisor 的 `status().repos`(面板 supervisor 条的数据源)随即可见该仓库。
|
|
302
302
|
旧版 supervisor 没有 `addRepo` 时跳过仓库登记并记一条日志,仍登记 queen Session。
|
|
303
|
+
**worker 会话跳过注入**:优先调用 supervisor 新接口 `isWorkerSession(sessionId)`;
|
|
304
|
+
拿不到(或返回非 true)时兜底看 `session.header.parentSession === queenSessionId`,再看
|
|
305
|
+
`origin === 'subagent'` / `delegationDepth > 0`。worker 与父会话共享仓库 cwd,若被注入
|
|
306
|
+
「不能写代码」约束或登记成 queen,就会被 runner 的 queen mutation guard 拦掉 write/edit/bash;
|
|
307
|
+
因此 worker 既不注入、也不登记(注册的 queen id 与 repo 均不变),只登记真正的顶层会话。
|
|
303
308
|
subagent 会话
|
|
304
309
|
(`session.header.origin === 'subagent'` 或 `delegationDepth > 0`)被排除:卡 worker 与父会话
|
|
305
310
|
共享仓库 cwd,若自动注入会污染 worker 并把 supervisor 的 queen 登记顶掉。
|
|
@@ -442,7 +447,7 @@ npm run check
|
|
|
442
447
|
# ok - node --check lib/queen.js
|
|
443
448
|
# ok - node --check lib/client.js
|
|
444
449
|
# ...
|
|
445
|
-
#
|
|
450
|
+
# 43 checks passed
|
|
446
451
|
```
|
|
447
452
|
|
|
448
453
|
覆盖:语法、package/bundle 声明、无代理残留、client bundle 的 `/api/hive` URL 与 Session 注入、
|
|
@@ -458,7 +463,9 @@ Connection Fetch 路由注册、快照走 `ctx.shell` 且 cwd/policy 正确、
|
|
|
458
463
|
(含 `QUEEN_INVARIANTS`、supervisor 幂等登记、跨仓库隔离)、`/queen off` 后不注入、
|
|
459
464
|
`autoQueen=false` 不注入、未初始化仓库不注入;prompt/init/queen-on 路径对
|
|
460
465
|
`hiveSupervisor.addRepo` 的登记(幂等去重、只登记有 queen.md 的仓库、退出与卸载不删除);
|
|
461
|
-
invariants 的工具边界断言(write/edit/apply_patch/bash/cua/claim、hive_
|
|
466
|
+
invariants 的工具边界断言(write/edit/apply_patch/bash/cua/claim、hive_*、中英两句);
|
|
467
|
+
worker 会话跳过注入/登记(supervisor `isWorkerSession` 优先与 `parentSession===queen` 兜底),
|
|
468
|
+
配套集成验证真实 runner 的 queen guard 放行 worker 的 write、仍拦截 queen 的 write。
|
|
462
469
|
|
|
463
470
|
不启动、不重启任何 DSH 进程,也不写运行中的 `~/.dsh`。
|
|
464
471
|
|
package/lib/queen.js
CHANGED
|
@@ -157,6 +157,82 @@ export function isTopLevelSession(session) {
|
|
|
157
157
|
return true
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
+
/** Read the mounted dsh-hive-runner supervisor service, if any. */
|
|
161
|
+
function supervisorOf(ctx) {
|
|
162
|
+
if (ctx === null || typeof ctx !== 'object' || typeof ctx.get !== 'function') return undefined
|
|
163
|
+
try {
|
|
164
|
+
return ctx.get('hiveSupervisor')
|
|
165
|
+
} catch {
|
|
166
|
+
return undefined
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* The supervisor's currently registered queen Session id, if any.
|
|
172
|
+
* Reads the shared `queenSession` object first, then `status().queenSessionId`.
|
|
173
|
+
* @param {object} [supervisor] - mounted Hive supervisor service.
|
|
174
|
+
* @returns {string | undefined} the registered queen Session id.
|
|
175
|
+
*/
|
|
176
|
+
export function registeredQueenSessionId(supervisor) {
|
|
177
|
+
if (supervisor === null || typeof supervisor !== 'object') return undefined
|
|
178
|
+
try {
|
|
179
|
+
const id = supervisor.queenSession?.sessionId
|
|
180
|
+
if (typeof id === 'string' && id !== '') return id
|
|
181
|
+
} catch {
|
|
182
|
+
// fall through to status()
|
|
183
|
+
}
|
|
184
|
+
try {
|
|
185
|
+
const status = typeof supervisor.status === 'function' ? supervisor.status() : undefined
|
|
186
|
+
const id = status?.queenSessionId
|
|
187
|
+
if (typeof id === 'string' && id !== '') return id
|
|
188
|
+
} catch {
|
|
189
|
+
// no status, no queen id
|
|
190
|
+
}
|
|
191
|
+
return undefined
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Whether a Session is a supervisor card worker / delegation child. Workers
|
|
196
|
+
* share the repository cwd with the queen but must keep their normal coding
|
|
197
|
+
* tools: injecting the queen contract into them would forbid the writes the
|
|
198
|
+
* supervisor asked them to do (and the queen mutation guard keys off the
|
|
199
|
+
* registered queen Session, so a worker must never be registered as one).
|
|
200
|
+
*
|
|
201
|
+
* Primary source: the mounted supervisor's `isWorkerSession(sessionId)`
|
|
202
|
+
* (newer dsh-hive-runner). Fallback when that interface is unavailable or
|
|
203
|
+
* returns a non-boolean: `session.header.parentSession` equals the
|
|
204
|
+
* supervisor's registered queen Session id, or the durable subagent markers
|
|
205
|
+
* (`origin === 'subagent'` / a positive `delegationDepth`).
|
|
206
|
+
*
|
|
207
|
+
* @param {object} ctx - host Cordis context (may expose `hiveSupervisor`).
|
|
208
|
+
* @param {object} session - DSH Session (or a test stub).
|
|
209
|
+
* @returns {boolean} true for worker/delegated Sessions.
|
|
210
|
+
*/
|
|
211
|
+
export function isWorkerSession(ctx, session) {
|
|
212
|
+
const sessionId = session !== null && typeof session === 'object' ? session.id : undefined
|
|
213
|
+
const supervisor = supervisorOf(ctx)
|
|
214
|
+
if (supervisor !== undefined && typeof supervisor.isWorkerSession === 'function'
|
|
215
|
+
&& typeof sessionId === 'string' && sessionId !== '') {
|
|
216
|
+
try {
|
|
217
|
+
// A positive registry answer is authoritative; a negative answer still
|
|
218
|
+
// falls through to the header lineage below, because a visible subagent
|
|
219
|
+
// Session is not always listed in the supervisor's live-worker registry
|
|
220
|
+
// (legacy/persisted children carry only parentSession in the header).
|
|
221
|
+
const answer = supervisor.isWorkerSession(sessionId)
|
|
222
|
+
if (answer === true) return true
|
|
223
|
+
} catch {
|
|
224
|
+
// Fall back to the header markers below.
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
const header = session !== null && typeof session === 'object' ? session.header : undefined
|
|
228
|
+
const queenSessionId = registeredQueenSessionId(supervisor)
|
|
229
|
+
if (typeof queenSessionId === 'string' && queenSessionId !== ''
|
|
230
|
+
&& header !== null && typeof header === 'object' && header.parentSession === queenSessionId) {
|
|
231
|
+
return true
|
|
232
|
+
}
|
|
233
|
+
return !isTopLevelSession(session)
|
|
234
|
+
}
|
|
235
|
+
|
|
160
236
|
/**
|
|
161
237
|
* Create the queen controller for one plugin fiber.
|
|
162
238
|
*
|
|
@@ -251,8 +327,9 @@ export function createQueen(ctx, options = {}) {
|
|
|
251
327
|
if (active !== undefined) return active.text
|
|
252
328
|
if (!autoQueen || suppressed.has(sessionId)) return ''
|
|
253
329
|
// A card worker / delegated child shares the repo cwd but must never
|
|
254
|
-
// become the queen (
|
|
255
|
-
|
|
330
|
+
// become the queen (nor lose its normal coding tools): ask the supervisor
|
|
331
|
+
// first, then fall back to the parent/queen and subagent header markers.
|
|
332
|
+
if (isWorkerSession(ctx, agent.session)) return ''
|
|
256
333
|
let cwd
|
|
257
334
|
try {
|
|
258
335
|
cwd = ctx.workingDirectory?.get?.(agent.session)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-hive-panel",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.10",
|
|
4
4
|
"description": "Hive board and queen mode inside DSH Web: a conversation view scoped to the Session's repository, with allowlisted task-card actions over DSH's shell seam.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
package/scripts/verify.mjs
CHANGED
|
@@ -1050,6 +1050,82 @@ async function call(route, { method = 'GET', query = {}, body } = {}) {
|
|
|
1050
1050
|
ok('panel init/queen-on register the queen cwd with the supervisor (idempotent, initialised repos only, one-way)')
|
|
1051
1051
|
}
|
|
1052
1052
|
|
|
1053
|
+
// ── 11e. worker Sessions never receive the queen contract ──────────────────
|
|
1054
|
+
{
|
|
1055
|
+
// Preferred path: the mounted supervisor exposes isWorkerSession(sessionId).
|
|
1056
|
+
const repoCalls = []
|
|
1057
|
+
const sessions = []
|
|
1058
|
+
const workerQueries = []
|
|
1059
|
+
const supervisor = {
|
|
1060
|
+
queenSession: { sessionId: 's-queen' },
|
|
1061
|
+
addRepo(repo) { if (!repoCalls.includes(repo)) repoCalls.push(repo); return { repo } },
|
|
1062
|
+
hasRepo(repo) { return repoCalls.includes(repo) },
|
|
1063
|
+
setQueenSession(sessionId) { sessions.push(sessionId) },
|
|
1064
|
+
isWorkerSession(sessionId) { workerQueries.push(sessionId); return sessionId === 's-supervised-worker' },
|
|
1065
|
+
}
|
|
1066
|
+
const sessionsById = new Map([
|
|
1067
|
+
['s-queen', { id: 's-queen', header: { id: 's-queen', cwd: repo } }],
|
|
1068
|
+
['s-supervised-worker', { id: 's-supervised-worker', header: { id: 's-supervised-worker', cwd: repo } }],
|
|
1069
|
+
['s-top', { id: 's-top', header: { id: 's-top', cwd: repo } }],
|
|
1070
|
+
])
|
|
1071
|
+
const shim = createCtx({
|
|
1072
|
+
live: sessionsById,
|
|
1073
|
+
cwdOf: () => repo,
|
|
1074
|
+
supervisor,
|
|
1075
|
+
})
|
|
1076
|
+
host.apply(shim.ctx, {})
|
|
1077
|
+
const section = shim.sections.find(entry => entry.name === 'hive:queen')
|
|
1078
|
+
|
|
1079
|
+
// isWorkerSession(sessionId) is authoritative: even a Session with a clean
|
|
1080
|
+
// top-level header is skipped, and it is never registered as the queen.
|
|
1081
|
+
assert.equal(section.text({ agent: { session: sessionsById.get('s-supervised-worker') } }), '')
|
|
1082
|
+
assert.deepEqual(workerQueries, ['s-supervised-worker'])
|
|
1083
|
+
assert.equal(sessions.length, 0, 'a worker Session must not be registered as the queen')
|
|
1084
|
+
assert.deepEqual(repoCalls, [], 'a worker Session must not register its repo through the queen path')
|
|
1085
|
+
|
|
1086
|
+
// An ordinary top-level Session in the same repository still injects and registers.
|
|
1087
|
+
const topText = section.text({ agent: { session: sessionsById.get('s-top') } })
|
|
1088
|
+
assert.match(topText, /You plan and coordinate/)
|
|
1089
|
+
assert.deepEqual(sessions, ['s-top'])
|
|
1090
|
+
assert.deepEqual(repoCalls, [repo])
|
|
1091
|
+
ok('a supervisor isWorkerSession(sessionId) worker is never injected or registered; a top-level Session still is')
|
|
1092
|
+
}
|
|
1093
|
+
|
|
1094
|
+
// ── 11f. worker fallback: parentSession === the registered queen ───────────
|
|
1095
|
+
{
|
|
1096
|
+
// No isWorkerSession on this supervisor: fall back to the header markers.
|
|
1097
|
+
const repoCalls = []
|
|
1098
|
+
const sessions = []
|
|
1099
|
+
const supervisor = {
|
|
1100
|
+
queenSession: { sessionId: 's-boss' },
|
|
1101
|
+
addRepo(repo) { if (!repoCalls.includes(repo)) repoCalls.push(repo); return { repo } },
|
|
1102
|
+
hasRepo(repo) { return repoCalls.includes(repo) },
|
|
1103
|
+
setQueenSession(sessionId) { sessions.push(sessionId) },
|
|
1104
|
+
}
|
|
1105
|
+
const sessionsById = new Map([
|
|
1106
|
+
['s-boss', { id: 's-boss', header: { id: 's-boss', cwd: repo } }],
|
|
1107
|
+
['s-child', { id: 's-child', header: { id: 's-child', cwd: repo, parentSession: 's-boss' } }],
|
|
1108
|
+
['s-orphan', { id: 's-orphan', header: { id: 's-orphan', cwd: repo } }],
|
|
1109
|
+
])
|
|
1110
|
+
const shim = createCtx({ live: sessionsById, cwdOf: () => repo, supervisor })
|
|
1111
|
+
host.apply(shim.ctx, {})
|
|
1112
|
+
const section = shim.sections.find(entry => entry.name === 'hive:queen')
|
|
1113
|
+
|
|
1114
|
+
// parentSession === registered queen Session: worker, no injection / no queen id.
|
|
1115
|
+
assert.equal(section.text({ agent: { session: sessionsById.get('s-child') } }), '')
|
|
1116
|
+
assert.deepEqual(sessions, [], 'a parentSession child must never be registered as the queen')
|
|
1117
|
+
assert.deepEqual(repoCalls, [])
|
|
1118
|
+
assert.equal(supervisor.queenSession.sessionId, 's-boss', 'the registered queen id must not be overwritten by a worker')
|
|
1119
|
+
// The runner mutation guard keys off registered queen sessions/worker headers, so a
|
|
1120
|
+
// worker that is never registered keeps its write/edit/bash tools unblocked.
|
|
1121
|
+
|
|
1122
|
+
// A normal top-level Session is still injected and registers as before.
|
|
1123
|
+
assert.match(section.text({ agent: { session: sessionsById.get('s-orphan') } }), /You plan and coordinate/)
|
|
1124
|
+
assert.deepEqual(sessions, ['s-orphan'])
|
|
1125
|
+
assert.deepEqual(repoCalls, [repo])
|
|
1126
|
+
ok('the parentSession===queen fallback skips worker Sessions but keeps top-level injection and registration')
|
|
1127
|
+
}
|
|
1128
|
+
|
|
1053
1129
|
// ── 12. queen activation / scope / exit ─────────────────────────────────────
|
|
1054
1130
|
{
|
|
1055
1131
|
const shim = createCtx({
|