dsh-hive-runner 1.0.25 → 1.0.26
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 +23 -0
- package/index.js +8 -0
- package/lib/anomalies.js +18 -2
- package/lib/patrol.js +79 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -20,6 +20,29 @@ iterations of the plugin before this repository was published.
|
|
|
20
20
|
### Tests
|
|
21
21
|
|
|
22
22
|
- 304 tests pass.
|
|
23
|
+
|
|
24
|
+
### Published
|
|
25
|
+
|
|
26
|
+
- npm: `dsh-hive-runner@1.0.25` on 2026-12-06.
|
|
27
|
+
|
|
28
|
+
## [1.0.26] - 2026-12-06
|
|
29
|
+
|
|
30
|
+
### Fixed
|
|
31
|
+
|
|
32
|
+
- Supervision digest de-duplication: the stable anomaly-id-set hash is persisted
|
|
33
|
+
with `deliveredAt`; an unchanged set is acknowledged silently (never re-sent),
|
|
34
|
+
so restarting the plugin cannot replay old digests. A changed set is rate-limited
|
|
35
|
+
to one digest per repo per 10 minutes and new items wait for the next window.
|
|
36
|
+
- `arch-review-missing` folds into one digest line with count and at most three
|
|
37
|
+
example cards; the digest stays bounded by the 50-entry pending cap.
|
|
38
|
+
- Delivery remains ack-immediate (`deliveredAt` written after a successful send).
|
|
39
|
+
|
|
40
|
+
### Tests
|
|
41
|
+
|
|
42
|
+
- same-set no repeat and silent ack, changed-set rate limit + later flush, restart
|
|
43
|
+
persistence, arch-review folding with 3 examples, and 50-entry backlog cap;
|
|
44
|
+
309 tests pass.
|
|
45
|
+
|
|
23
46
|
## [1.0.24] - 2026-12-06
|
|
24
47
|
|
|
25
48
|
### Fixed
|
package/index.js
CHANGED
|
@@ -19,6 +19,10 @@
|
|
|
19
19
|
* the sandbox, the session sandbox policy, credential scrubbing, output caps and
|
|
20
20
|
* cancellation. Card workers are DSH subagents (`ctx.subagents`), not processes.
|
|
21
21
|
*/
|
|
22
|
+
import fs from 'node:fs';
|
|
23
|
+
import os from 'node:os';
|
|
24
|
+
import path from 'node:path';
|
|
25
|
+
|
|
22
26
|
import { defineTool } from '@deepseek-ai/dsh-tools';
|
|
23
27
|
|
|
24
28
|
import { createCommands } from './lib/commands.js';
|
|
@@ -372,6 +376,10 @@ export function apply(ctx, config = {}) {
|
|
|
372
376
|
notifier: resolved.notifyQueen ? notifier : undefined,
|
|
373
377
|
intervalMs: resolved.patrolIntervalMs,
|
|
374
378
|
debounceMs: resolved.anomalyDebounceMs,
|
|
379
|
+
// Persist delivered digest signatures so a restart does not re-send the
|
|
380
|
+
// same supervision digest; the file is host-level, not repository data.
|
|
381
|
+
statePath: path.join(os.homedir(), '.dsh', 'hive-runner', 'supervision-state.json'),
|
|
382
|
+
digestRateLimitMs: 10 * 60_000,
|
|
375
383
|
// Every patrol also audits done cards for a missing architecture review.
|
|
376
384
|
inspect: async () => {
|
|
377
385
|
let repos = [];
|
package/lib/anomalies.js
CHANGED
|
@@ -204,13 +204,29 @@ export function renderDigest(items, options = {}) {
|
|
|
204
204
|
const repos = [...new Set(list.map((entry) => entry.repo).filter((repo) => typeof repo === 'string' && repo !== ''))];
|
|
205
205
|
if (repos.length === 1) lines.push('repo: ' + repos[0]);
|
|
206
206
|
else if (repos.length > 1) lines.push('repos: ' + repos.join(', '));
|
|
207
|
-
|
|
207
|
+
// Fold identical review-missing items into one line with at most three
|
|
208
|
+
// examples: the queen needs the count and a sample, not one row per card.
|
|
209
|
+
const archMissing = list.filter((entry) => entry.kind === 'arch-review-missing');
|
|
210
|
+
const others = list.filter((entry) => entry.kind !== 'arch-review-missing');
|
|
211
|
+
let shown = 0;
|
|
212
|
+
if (archMissing.length > 0) {
|
|
213
|
+
const cards = [...new Set(archMissing.map((entry) => entry.cardId).filter((cardId) => typeof cardId === 'string' && cardId !== ''))];
|
|
214
|
+
const occurrences = archMissing.reduce((count, entry) => count + (Number.isInteger(entry.count) ? entry.count : 1), 0);
|
|
215
|
+
const examples = cards.slice(0, 3).join(', ');
|
|
216
|
+
lines.push('- arch-review-missing ×' + String(occurrences) + ': ' + String(cards.length)
|
|
217
|
+
+ ' done task(s) without arch_review' + (examples !== '' ? ' (e.g. ' + examples + ')' : ''));
|
|
218
|
+
shown += 1;
|
|
219
|
+
}
|
|
220
|
+
for (const entry of others.slice(-Math.max(0, max - shown))) {
|
|
208
221
|
const tag = labelOf(entry);
|
|
209
222
|
const count = Number.isInteger(entry.count) && entry.count > 1 ? ' ×' + String(entry.count) : '';
|
|
210
223
|
const detail = typeof entry.detail === 'string' && entry.detail !== '' ? ': ' + entry.detail : '';
|
|
211
224
|
lines.push('- ' + tag + count + detail);
|
|
225
|
+
shown += 1;
|
|
226
|
+
}
|
|
227
|
+
if (others.length + archMissing.length > shown) {
|
|
228
|
+
lines.push('- … and ' + String(others.length + archMissing.length - shown) + ' more (hive_anomalies lists all)');
|
|
212
229
|
}
|
|
213
|
-
if (list.length > max) lines.push('- … and ' + String(list.length - max) + ' more (hive_anomalies lists all)');
|
|
214
230
|
lines.push('');
|
|
215
231
|
lines.push('Next: read the board and supervisor status, then decide — reopen/retry/split/remove a card, '
|
|
216
232
|
+ 'pause or resume the repository, adjust role limits, add a fix card, or ask the human. '
|
package/lib/patrol.js
CHANGED
|
@@ -12,6 +12,9 @@
|
|
|
12
12
|
*
|
|
13
13
|
* @module dsh-hive-runner/patrol
|
|
14
14
|
*/
|
|
15
|
+
import fs from 'node:fs';
|
|
16
|
+
import path from 'node:path';
|
|
17
|
+
|
|
15
18
|
import { renderDigest } from './anomalies.js';
|
|
16
19
|
|
|
17
20
|
/**
|
|
@@ -47,6 +50,48 @@ export function createPatrol(options = {}) {
|
|
|
47
50
|
const setIntervalFn = typeof options.setIntervalFn === 'function' ? options.setIntervalFn : setInterval;
|
|
48
51
|
const clearIntervalFn = typeof options.clearIntervalFn === 'function' ? options.clearIntervalFn : clearInterval;
|
|
49
52
|
const log = typeof options.log === 'function' ? options.log : () => {};
|
|
53
|
+
// A signature is the stable anomaly-id set: kind/repo/card/scope, not the
|
|
54
|
+
// volatile feed ids. Persisting it is what stops a restart from re-delivering
|
|
55
|
+
// the same digest.
|
|
56
|
+
const statePath = typeof options.statePath === 'string' && options.statePath !== '' ? options.statePath : null;
|
|
57
|
+
const rateLimitMs = Number.isFinite(options.digestRateLimitMs) && options.digestRateLimitMs >= 0
|
|
58
|
+
? options.digestRateLimitMs
|
|
59
|
+
: 10 * 60_000;
|
|
60
|
+
let deliveryState = loadState();
|
|
61
|
+
|
|
62
|
+
function loadState() {
|
|
63
|
+
if (statePath === null) return { repos: {} };
|
|
64
|
+
try {
|
|
65
|
+
const parsed = JSON.parse(fs.readFileSync(statePath, 'utf8'));
|
|
66
|
+
return parsed !== null && typeof parsed === 'object' && parsed.repos !== null && typeof parsed.repos === 'object'
|
|
67
|
+
? { repos: parsed.repos }
|
|
68
|
+
: { repos: {} };
|
|
69
|
+
} catch {
|
|
70
|
+
return { repos: {} };
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function saveState() {
|
|
75
|
+
if (statePath === null) return;
|
|
76
|
+
try {
|
|
77
|
+
fs.mkdirSync(path.dirname(statePath), { recursive: true });
|
|
78
|
+
fs.writeFileSync(statePath, JSON.stringify({ ...deliveryState, updatedAt: new Date(now()).toISOString() }, null, 2) + '\n');
|
|
79
|
+
} catch (error) {
|
|
80
|
+
log('warn', 'saving patrol delivery state failed', error);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** Stable hash of the anomaly id set (independent of feed ids/counts). */
|
|
85
|
+
function signatureOf(entries) {
|
|
86
|
+
const keys = entries.map((entry) => [entry.kind, entry.repo, entry.cardId, entry.summary, entry.detail]
|
|
87
|
+
.map((value) => String(value ?? '')).join('\u0000')).sort();
|
|
88
|
+
let hash = 2166136261;
|
|
89
|
+
for (const key of keys.join('\n')) {
|
|
90
|
+
hash ^= key.codePointAt(0);
|
|
91
|
+
hash = Math.imul(hash, 16777619);
|
|
92
|
+
}
|
|
93
|
+
return (hash >>> 0).toString(16) + ':' + String(keys.length);
|
|
94
|
+
}
|
|
50
95
|
|
|
51
96
|
let patrolTimer = null;
|
|
52
97
|
let flushTimer = null;
|
|
@@ -97,9 +142,35 @@ export function createPatrol(options = {}) {
|
|
|
97
142
|
groups.get(repo).push(entry);
|
|
98
143
|
}
|
|
99
144
|
let deliveredCount = 0;
|
|
145
|
+
let dedupedCount = 0;
|
|
146
|
+
let throttledCount = 0;
|
|
147
|
+
let stateChanged = false;
|
|
100
148
|
let via = null;
|
|
101
149
|
let lastReason = null;
|
|
102
150
|
for (const [repo, entries] of groups) {
|
|
151
|
+
const ids = entries.map((entry) => entry.id);
|
|
152
|
+
const signature = signatureOf(entries);
|
|
153
|
+
const previous = deliveryState.repos[repo];
|
|
154
|
+
const at = now();
|
|
155
|
+
// Same anomaly-id set as the last delivered digest: acknowledge the new
|
|
156
|
+
// feed ids silently and update the count, never re-send the digest.
|
|
157
|
+
if (previous !== undefined && previous.signature === signature) {
|
|
158
|
+
try {
|
|
159
|
+
feed.markDelivered(ids);
|
|
160
|
+
} catch (error) {
|
|
161
|
+
log('warn', 'marking duplicate anomalies delivered failed', error);
|
|
162
|
+
}
|
|
163
|
+
deliveryState.repos[repo] = { ...previous, count: entries.length, lastSeenAt: at };
|
|
164
|
+
stateChanged = true;
|
|
165
|
+
dedupedCount += entries.length;
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
// Rate limit a changing repository state to one digest per window.
|
|
169
|
+
if (previous !== undefined && Number.isFinite(previous.deliveredAt) && at - previous.deliveredAt < rateLimitMs) {
|
|
170
|
+
lastReason = 'rate-limited';
|
|
171
|
+
throttledCount += entries.length;
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
103
174
|
let result;
|
|
104
175
|
try {
|
|
105
176
|
result = notifier.deliver(renderDigest(entries), repo);
|
|
@@ -110,16 +181,19 @@ export function createPatrol(options = {}) {
|
|
|
110
181
|
}
|
|
111
182
|
if (result !== undefined && result.delivered === true) {
|
|
112
183
|
try {
|
|
113
|
-
feed.markDelivered(
|
|
184
|
+
feed.markDelivered(ids);
|
|
114
185
|
} catch (error) {
|
|
115
186
|
log('warn', 'marking anomalies delivered failed', error);
|
|
116
187
|
}
|
|
188
|
+
deliveryState.repos[repo] = { signature, deliveredAt: at, lastSeenAt: at, count: entries.length };
|
|
189
|
+
stateChanged = true;
|
|
117
190
|
deliveredCount += entries.length;
|
|
118
191
|
via = result.via ?? via;
|
|
119
192
|
} else {
|
|
120
193
|
lastReason = result?.reason ?? 'not-delivered';
|
|
121
194
|
}
|
|
122
195
|
}
|
|
196
|
+
if (stateChanged) saveState();
|
|
123
197
|
let stillPending = 0;
|
|
124
198
|
try {
|
|
125
199
|
const rest = feed.pending();
|
|
@@ -128,14 +202,16 @@ export function createPatrol(options = {}) {
|
|
|
128
202
|
stillPending = pending.length - deliveredCount;
|
|
129
203
|
}
|
|
130
204
|
if (deliveredCount > 0) {
|
|
131
|
-
return { delivered: true, count: deliveredCount, pending: stillPending, via, reason: null };
|
|
205
|
+
return { delivered: true, count: deliveredCount, pending: stillPending, via, reason: null, deduped: dedupedCount, throttled: throttledCount };
|
|
132
206
|
}
|
|
133
207
|
return {
|
|
134
208
|
delivered: false,
|
|
135
209
|
count: deliveredCount,
|
|
136
210
|
pending: stillPending,
|
|
137
211
|
via: null,
|
|
138
|
-
reason: lastReason ?? 'no-live-queen-session',
|
|
212
|
+
reason: lastReason ?? (dedupedCount > 0 ? 'deduped' : 'no-live-queen-session'),
|
|
213
|
+
deduped: dedupedCount,
|
|
214
|
+
throttled: throttledCount,
|
|
139
215
|
};
|
|
140
216
|
}
|
|
141
217
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-hive-runner",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.26",
|
|
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",
|