@adhdev/mesh-shared 1.0.82-rc.12 → 1.0.82-rc.121
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/dist/assistant-protocol.d.ts +158 -6
- package/dist/decision-push-relay.d.ts +20 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +1534 -112
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1400 -112
- package/dist/index.mjs.map +1 -1
- package/dist/launch-defaults.d.ts +196 -0
- package/dist/light-task.d.ts +96 -0
- package/dist/mesh-tool-names.d.ts +2 -2
- package/dist/mesh-vocabulary.d.ts +13 -4
- package/dist/mission-git-state.d.ts +83 -0
- package/dist/mission-items.d.ts +202 -0
- package/dist/node-facts.d.ts +54 -1
- package/dist/outbound-message.d.ts +9 -2
- package/dist/protocol/daemon-server.d.ts +42 -2
- package/dist/protocol/dashboard-daemon-p2p.d.ts +1 -1
- package/dist/protocol/dashboard-server.d.ts +20 -2
- package/dist/quota-freshness.d.ts +4 -4
- package/dist/relay-reprobe.d.ts +52 -0
- package/dist/release.d.ts +90 -0
- package/dist/role-launch.d.ts +11 -0
- package/dist/session-launch.d.ts +10 -22
- package/dist/slot-proposal.d.ts +14 -0
- package/dist/task-source-phase.d.ts +83 -0
- package/dist/task-stages.d.ts +210 -0
- package/dist/turn-evidence.d.ts +31 -9
- package/dist/turn-ipc-mission.d.ts +72 -1
- package/dist/turn-ipc-queue.d.ts +30 -0
- package/dist/turn-ipc.d.ts +2 -2
- package/dist/worker-protocol.d.ts +41 -1
- package/package.json +1 -1
- package/src/assistant-protocol.ts +294 -6
- package/src/daemon-normalize.ts +7 -5
- package/src/decision-push-relay.ts +23 -0
- package/src/index.ts +11 -0
- package/src/launch-defaults.ts +170 -0
- package/src/light-task.ts +116 -0
- package/src/mesh-tool-names.ts +22 -0
- package/src/mesh-vocabulary.ts +12 -2
- package/src/mission-git-state.ts +112 -0
- package/src/mission-items.ts +421 -0
- package/src/node-facts.ts +54 -1
- package/src/outbound-message.ts +19 -0
- package/src/protocol/daemon-server.ts +37 -2
- package/src/protocol/dashboard-server.ts +13 -2
- package/src/quota-freshness.ts +29 -13
- package/src/relay-reprobe.ts +117 -0
- package/src/release.ts +121 -0
- package/src/role-launch.ts +51 -0
- package/src/session-launch.ts +17 -1
- package/src/slot-proposal.ts +61 -2
- package/src/task-source-phase.ts +70 -0
- package/src/task-stages.ts +459 -0
- package/src/turn-evidence.ts +47 -7
- package/src/turn-ipc-mission.ts +127 -11
- package/src/turn-ipc-queue.ts +45 -2
- package/src/turn-ipc-turn.ts +1 -1
- package/src/turn-ipc.ts +1 -0
- package/src/worker-protocol.ts +94 -0
package/src/turn-ipc-mission.ts
CHANGED
|
@@ -85,9 +85,46 @@ export interface MissionUpsertRequest {
|
|
|
85
85
|
* this wire guard only checks SHAPE, not that decision.
|
|
86
86
|
*/
|
|
87
87
|
brief?: MissionBriefWire | null
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
/**
|
|
89
|
+
* Structured-missions bundle A (design 2026-10-28 §5.1). Every key below is optional
|
|
90
|
+
* and ABSENT on a legacy call. `structured: true` is the caller's capability flag: the
|
|
91
|
+
* daemon only puts the new keys on the response (mission summary/outcome/version,
|
|
92
|
+
* `result`) when it is set, so an older mcp-server that never sends it keeps decoding
|
|
93
|
+
* byte-identical responses (mixed-version fleets, design §13.1).
|
|
94
|
+
*/
|
|
95
|
+
structured?: boolean
|
|
96
|
+
summary?: string
|
|
97
|
+
/** One user/operator-visible sentence for the release CHANGELOG draft (design 2026-11-01-release-objects L5). `''` clears. */
|
|
98
|
+
releaseNote?: string
|
|
99
|
+
outcome?: string
|
|
100
|
+
outcomeReason?: string
|
|
101
|
+
/** Mission id open items move to when this call closes the mission (default: the carry-over mission). */
|
|
102
|
+
carryOverTo?: string
|
|
103
|
+
/** Route to the mesh's auto-created carry-over mission instead of `id`/`title` (decision requests without a mission). `title` may then be empty. */
|
|
104
|
+
toCarryOver?: boolean
|
|
105
|
+
itemsAdd?: readonly Record<string, unknown>[]
|
|
106
|
+
itemsUpdate?: readonly Record<string, unknown>[]
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export interface MeshMissionOpenItemCountsWire {
|
|
110
|
+
remaining: number
|
|
111
|
+
live_check: number
|
|
112
|
+
decision: number
|
|
113
|
+
evidence: number
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** Structured-missions fields (only with `structured: true` on the request). */
|
|
117
|
+
export interface MeshMissionStructuredWire {
|
|
118
|
+
summary?: string
|
|
119
|
+
releaseNote?: string
|
|
120
|
+
outcome?: string
|
|
121
|
+
outcomeReason?: string
|
|
122
|
+
version?: number
|
|
123
|
+
carryOver?: boolean
|
|
124
|
+
openItems?: MeshMissionOpenItemCountsWire
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export interface MeshMissionRecordWire extends MeshMissionStructuredWire {
|
|
91
128
|
id: string
|
|
92
129
|
meshId: string
|
|
93
130
|
title: string
|
|
@@ -99,10 +136,30 @@ export interface MeshMissionRecordWire {
|
|
|
99
136
|
|
|
100
137
|
export interface MissionUpsertResponse {
|
|
101
138
|
mission: MeshMissionRecordWire
|
|
139
|
+
/** Structured calls only: per-item results, movedItems/movedTo, restoredItems, ownerConfirmationItemId, warnings. */
|
|
140
|
+
result?: Record<string, unknown>
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const STRUCTURED_MISSION_KEYS = ['summary', 'releaseNote', 'outcome', 'outcomeReason', 'version', 'carryOver', 'openItems'] as const
|
|
144
|
+
|
|
145
|
+
function isOpenItemCountsWire(value: unknown): value is MeshMissionOpenItemCountsWire {
|
|
146
|
+
if (!isRecord(value) || !hasOnlyKeys(value, ['remaining', 'live_check', 'decision', 'evidence'])) return false
|
|
147
|
+
return (['remaining', 'live_check', 'decision', 'evidence'] as const).every((k) => isNonNegativeInt(value[k]))
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function isStructuredMissionFields(value: Record<string, unknown>): boolean {
|
|
151
|
+
for (const k of ['summary', 'releaseNote', 'outcome', 'outcomeReason'] as const) {
|
|
152
|
+
if (value[k] !== undefined && typeof value[k] !== 'string') return false
|
|
153
|
+
}
|
|
154
|
+
if (value.version !== undefined && !isNonNegativeInt(value.version)) return false
|
|
155
|
+
if (value.carryOver !== undefined && typeof value.carryOver !== 'boolean') return false
|
|
156
|
+
if (value.openItems !== undefined && !isOpenItemCountsWire(value.openItems)) return false
|
|
157
|
+
return true
|
|
102
158
|
}
|
|
103
159
|
|
|
104
160
|
function isMeshMissionRecordWire(value: unknown): value is MeshMissionRecordWire {
|
|
105
|
-
if (!isRecord(value) || !hasOnlyKeys(value, ['id', 'meshId', 'title', 'goal', 'status', 'brief'])) return false
|
|
161
|
+
if (!isRecord(value) || !hasOnlyKeys(value, ['id', 'meshId', 'title', 'goal', 'status', 'brief', ...STRUCTURED_MISSION_KEYS])) return false
|
|
162
|
+
if (!isStructuredMissionFields(value)) return false
|
|
106
163
|
if (!isEvidenceIdentifier(value.id) || !isEvidenceIdentifier(value.meshId)) return false
|
|
107
164
|
if (typeof value.title !== 'string' || typeof value.goal !== 'string') return false
|
|
108
165
|
if (!isMeshMissionStatusValue(value.status)) return false
|
|
@@ -111,11 +168,24 @@ function isMeshMissionRecordWire(value: unknown): value is MeshMissionRecordWire
|
|
|
111
168
|
}
|
|
112
169
|
|
|
113
170
|
function isMissionUpsertRequest(value: unknown): value is MissionUpsertRequest {
|
|
114
|
-
if (!isRecord(value) || !hasOnlyKeys(value, ['v', 'meshId', 'id', 'title', 'goal', 'status', 'brief'])) return false
|
|
171
|
+
if (!isRecord(value) || !hasOnlyKeys(value, ['v', 'meshId', 'id', 'title', 'goal', 'status', 'brief', 'structured', 'summary', 'releaseNote', 'outcome', 'outcomeReason', 'carryOverTo', 'toCarryOver', 'itemsAdd', 'itemsUpdate'])) return false
|
|
115
172
|
if (value.v !== TURN_IPC_PROTOCOL_VERSION) return false
|
|
116
173
|
if (!isEvidenceIdentifier(value.meshId)) return false
|
|
117
174
|
if (value.id !== undefined && !isEvidenceIdentifier(value.id)) return false
|
|
118
|
-
if (typeof value.title !== 'string'
|
|
175
|
+
if (typeof value.title !== 'string') return false
|
|
176
|
+
// An empty title is allowed only when the daemon can supply one: an existing mission (id) or the carry-over mission.
|
|
177
|
+
if (value.title.trim().length === 0 && value.toCarryOver !== true && value.id === undefined) return false
|
|
178
|
+
if (value.structured !== undefined && typeof value.structured !== 'boolean') return false
|
|
179
|
+
if (value.toCarryOver !== undefined && typeof value.toCarryOver !== 'boolean') return false
|
|
180
|
+
for (const k of ['summary', 'releaseNote', 'outcome', 'outcomeReason'] as const) {
|
|
181
|
+
if (value[k] !== undefined && typeof value[k] !== 'string') return false
|
|
182
|
+
}
|
|
183
|
+
if (value.carryOverTo !== undefined && !isEvidenceIdentifier(value.carryOverTo)) return false
|
|
184
|
+
for (const k of ['itemsAdd', 'itemsUpdate'] as const) {
|
|
185
|
+
const list = value[k]
|
|
186
|
+
// Bounded only to keep the IPC message sane; per-entry shape/size is clamped (never rejected) by the daemon.
|
|
187
|
+
if (list !== undefined && (!Array.isArray(list) || list.length > 500 || !list.every(isRecord))) return false
|
|
188
|
+
}
|
|
119
189
|
if (value.goal !== undefined && typeof value.goal !== 'string') return false
|
|
120
190
|
if (value.status !== undefined && !isMeshMissionStatusValue(value.status)) return false
|
|
121
191
|
if (value.brief !== undefined && value.brief !== null && !isMissionBriefWire(value.brief)) return false
|
|
@@ -127,7 +197,8 @@ export function decodeMissionUpsertRequest(value: unknown): MissionUpsertRequest
|
|
|
127
197
|
}
|
|
128
198
|
|
|
129
199
|
export function isMissionUpsertResponse(value: unknown): value is MissionUpsertResponse {
|
|
130
|
-
return isRecord(value) && hasOnlyKeys(value, ['mission']) && isMeshMissionRecordWire(value.mission)
|
|
200
|
+
return isRecord(value) && hasOnlyKeys(value, ['mission', 'result']) && isMeshMissionRecordWire(value.mission)
|
|
201
|
+
&& (value.result === undefined || isRecord(value.result))
|
|
131
202
|
}
|
|
132
203
|
|
|
133
204
|
export function decodeMissionUpsertResponse(value: unknown): MissionUpsertResponse | null {
|
|
@@ -207,6 +278,12 @@ export interface MissionListQueryRequest {
|
|
|
207
278
|
* option except `historyIdLimit` is ignored. An older daemon rejects the key.
|
|
208
279
|
*/
|
|
209
280
|
meshStatusView?: 'compact' | 'verbose'
|
|
281
|
+
/** Structured-missions capability flag (see MissionUpsertRequest.structured): rows then carry summary/outcome/openItems/carryOver/version. */
|
|
282
|
+
structured?: boolean
|
|
283
|
+
/** Structured only: attach each mission's items. */
|
|
284
|
+
items?: boolean
|
|
285
|
+
/** Structured only: attach each mission's change history (bounded tail). */
|
|
286
|
+
history?: boolean
|
|
210
287
|
}
|
|
211
288
|
|
|
212
289
|
export interface MeshMissionTaskAggregateWire {
|
|
@@ -221,6 +298,8 @@ export interface MeshMissionTaskAggregateWire {
|
|
|
221
298
|
}
|
|
222
299
|
|
|
223
300
|
export interface MeshMissionStatsWire {
|
|
301
|
+
/** Present on peers that project proven blocked outcomes separately. */
|
|
302
|
+
blocked?: number
|
|
224
303
|
missionId: string
|
|
225
304
|
taskCount: number
|
|
226
305
|
completed: number
|
|
@@ -246,6 +325,16 @@ export interface MissionListSummaryVerboseWire {
|
|
|
246
325
|
createdAt?: string
|
|
247
326
|
updatedAt?: string
|
|
248
327
|
closeCandidateEmittedAt?: string | null
|
|
328
|
+
/** Structured lists only. */
|
|
329
|
+
summary?: string
|
|
330
|
+
releaseNote?: string
|
|
331
|
+
outcome?: string
|
|
332
|
+
outcomeReason?: string
|
|
333
|
+
version?: number
|
|
334
|
+
carryOver?: boolean
|
|
335
|
+
openItems?: MeshMissionOpenItemCountsWire
|
|
336
|
+
items?: readonly Record<string, unknown>[]
|
|
337
|
+
history?: readonly Record<string, unknown>[]
|
|
249
338
|
}
|
|
250
339
|
|
|
251
340
|
/** Compact (default) mission row. `goalPreview`/`goalTruncated` present, `goal` absent. */
|
|
@@ -264,6 +353,16 @@ export interface MissionListSummarySlimWire {
|
|
|
264
353
|
createdAt?: string
|
|
265
354
|
updatedAt?: string
|
|
266
355
|
closeCandidateEmittedAt?: string | null
|
|
356
|
+
/** Structured lists only. */
|
|
357
|
+
summary?: string
|
|
358
|
+
releaseNote?: string
|
|
359
|
+
outcome?: string
|
|
360
|
+
outcomeReason?: string
|
|
361
|
+
version?: number
|
|
362
|
+
carryOver?: boolean
|
|
363
|
+
openItems?: MeshMissionOpenItemCountsWire
|
|
364
|
+
items?: readonly Record<string, unknown>[]
|
|
365
|
+
history?: readonly Record<string, unknown>[]
|
|
267
366
|
}
|
|
268
367
|
|
|
269
368
|
export type MissionListSummaryWire = MissionListSummaryVerboseWire | MissionListSummarySlimWire
|
|
@@ -284,7 +383,10 @@ export interface MissionListQueryResponse {
|
|
|
284
383
|
}
|
|
285
384
|
|
|
286
385
|
function isMissionListQueryRequest(value: unknown): value is MissionListQueryRequest {
|
|
287
|
-
if (!isRecord(value) || !hasOnlyKeys(value, ['v', 'meshId', 'statuses', 'verbose', 'withStats', 'limit', 'historyIdLimit', 'meshStatusView'])) return false
|
|
386
|
+
if (!isRecord(value) || !hasOnlyKeys(value, ['v', 'meshId', 'statuses', 'verbose', 'withStats', 'limit', 'historyIdLimit', 'meshStatusView', 'structured', 'items', 'history'])) return false
|
|
387
|
+
for (const k of ['structured', 'items', 'history'] as const) {
|
|
388
|
+
if (value[k] !== undefined && typeof value[k] !== 'boolean') return false
|
|
389
|
+
}
|
|
288
390
|
if (value.meshStatusView !== undefined && value.meshStatusView !== 'compact' && value.meshStatusView !== 'verbose') return false
|
|
289
391
|
if (value.v !== TURN_IPC_PROTOCOL_VERSION) return false
|
|
290
392
|
if (!isEvidenceIdentifier(value.meshId)) return false
|
|
@@ -313,12 +415,13 @@ function isMeshMissionTaskAggregateWire(value: unknown): value is MeshMissionTas
|
|
|
313
415
|
}
|
|
314
416
|
|
|
315
417
|
function isMeshMissionStatsWire(value: unknown): value is MeshMissionStatsWire {
|
|
316
|
-
const keys = ['missionId', 'taskCount', 'completed', 'failed', 'totalDurationMs', 'wallClockMs', 'retries', 'incompleteTaskIds'] as const
|
|
418
|
+
const keys = ['missionId', 'taskCount', 'completed', 'failed', 'blocked', 'totalDurationMs', 'wallClockMs', 'retries', 'incompleteTaskIds'] as const
|
|
317
419
|
if (!isRecord(value) || !hasOnlyKeys(value, keys)) return false
|
|
318
420
|
if (!isEvidenceIdentifier(value.missionId)) return false
|
|
319
421
|
for (const k of ['taskCount', 'completed', 'failed', 'totalDurationMs', 'retries'] as const) {
|
|
320
422
|
if (!isNonNegativeInt(value[k])) return false
|
|
321
423
|
}
|
|
424
|
+
if (value.blocked !== undefined && !isNonNegativeInt(value.blocked)) return false
|
|
322
425
|
if (value.wallClockMs !== null && !isNonNegativeInt(value.wallClockMs)) return false
|
|
323
426
|
if (!Array.isArray(value.incompleteTaskIds) || !value.incompleteTaskIds.every(isEvidenceIdentifier)) return false
|
|
324
427
|
return true
|
|
@@ -329,7 +432,7 @@ function isMissionListSummaryWire(value: unknown): value is MissionListSummaryWi
|
|
|
329
432
|
const hasGoal = 'goal' in value
|
|
330
433
|
const hasPreview = 'goalPreview' in value && 'goalTruncated' in value
|
|
331
434
|
if (hasGoal === hasPreview) return false // exactly one of the two shapes
|
|
332
|
-
const baseKeys = ['id', 'meshId', 'title', 'status', 'tasks', 'stats', 'brief', 'createdAt', 'updatedAt', 'closeCandidateEmittedAt'] as const
|
|
435
|
+
const baseKeys = ['id', 'meshId', 'title', 'status', 'tasks', 'stats', 'brief', 'createdAt', 'updatedAt', 'closeCandidateEmittedAt', ...STRUCTURED_MISSION_KEYS, 'items', 'history'] as const
|
|
333
436
|
const allowed = hasGoal ? [...baseKeys, 'goal'] : [...baseKeys, 'goalPreview', 'goalTruncated']
|
|
334
437
|
if (!hasOnlyKeys(value, allowed)) return false
|
|
335
438
|
if (!isEvidenceIdentifier(value.id) || !isEvidenceIdentifier(value.meshId)) return false
|
|
@@ -343,6 +446,10 @@ function isMissionListSummaryWire(value: unknown): value is MissionListSummaryWi
|
|
|
343
446
|
if (value.createdAt !== undefined && typeof value.createdAt !== 'string') return false
|
|
344
447
|
if (value.updatedAt !== undefined && typeof value.updatedAt !== 'string') return false
|
|
345
448
|
if (value.closeCandidateEmittedAt !== undefined && value.closeCandidateEmittedAt !== null && typeof value.closeCandidateEmittedAt !== 'string') return false
|
|
449
|
+
if (!isStructuredMissionFields(value)) return false
|
|
450
|
+
for (const k of ['items', 'history'] as const) {
|
|
451
|
+
if (value[k] !== undefined && (!Array.isArray(value[k]) || !(value[k] as unknown[]).every(isRecord))) return false
|
|
452
|
+
}
|
|
346
453
|
return true
|
|
347
454
|
}
|
|
348
455
|
|
|
@@ -580,6 +687,12 @@ export interface LedgerQueryEntryWire {
|
|
|
580
687
|
}
|
|
581
688
|
|
|
582
689
|
export interface LedgerQuerySummaryWire {
|
|
690
|
+
/** Absent on older peers; never folded into failed by the decoder. */
|
|
691
|
+
taskBlocked?: number
|
|
692
|
+
/** Failed Refinery jobs (not tasks). Absent on older peers. Lifetime, not the current window. */
|
|
693
|
+
refineFailed?: number
|
|
694
|
+
/** Refine failures inside the 30-minute current window. Absent on older peers. */
|
|
695
|
+
recentRefineFailures?: number
|
|
583
696
|
meshId: string
|
|
584
697
|
totalEntries: number
|
|
585
698
|
taskDispatched: number
|
|
@@ -625,12 +738,15 @@ function isLedgerQueryEntryWire(value: unknown): value is LedgerQueryEntryWire {
|
|
|
625
738
|
}
|
|
626
739
|
|
|
627
740
|
function isLedgerQuerySummaryWire(value: unknown): value is LedgerQuerySummaryWire {
|
|
628
|
-
const keys = ['meshId', 'totalEntries', 'taskDispatched', 'taskCompleted', 'taskFailed', 'taskStalled', 'sessionLaunched', 'checkpointCreated', 'lastActivityAt', 'recentFailures'] as const
|
|
741
|
+
const keys = ['meshId', 'totalEntries', 'taskDispatched', 'taskCompleted', 'taskFailed', 'taskBlocked', 'taskStalled', 'sessionLaunched', 'checkpointCreated', 'lastActivityAt', 'recentFailures', 'taskBlocked', 'refineFailed', 'recentRefineFailures'] as const
|
|
629
742
|
if (!isRecord(value) || !hasOnlyKeys(value, keys)) return false
|
|
630
743
|
if (!isEvidenceIdentifier(value.meshId)) return false
|
|
631
744
|
for (const k of ['totalEntries', 'taskDispatched', 'taskCompleted', 'taskFailed', 'taskStalled', 'sessionLaunched', 'checkpointCreated', 'recentFailures'] as const) {
|
|
632
745
|
if (!isNonNegativeInt(value[k])) return false
|
|
633
746
|
}
|
|
747
|
+
if (value.taskBlocked !== undefined && !isNonNegativeInt(value.taskBlocked)) return false
|
|
748
|
+
if (value.refineFailed !== undefined && !isNonNegativeInt(value.refineFailed)) return false
|
|
749
|
+
if (value.recentRefineFailures !== undefined && !isNonNegativeInt(value.recentRefineFailures)) return false
|
|
634
750
|
if (value.lastActivityAt !== null && typeof value.lastActivityAt !== 'string') return false
|
|
635
751
|
return true
|
|
636
752
|
}
|
package/src/turn-ipc-queue.ts
CHANGED
|
@@ -135,6 +135,8 @@ export interface QueueQueryResponse {
|
|
|
135
135
|
counts?: Record<string, number>
|
|
136
136
|
/** `withCounts` + `historicalOlderThanMs`: terminal rows older than that age. */
|
|
137
137
|
oldHistoricalCount?: number
|
|
138
|
+
/** Included in counts.blocked, derived from proven worker reports; stored failed rows stay unchanged. */
|
|
139
|
+
legacyReportedBlockedCount?: number
|
|
138
140
|
/** `withDependencyHeads`. */
|
|
139
141
|
dependencyHeads?: readonly QueueDependencyHeadWire[]
|
|
140
142
|
}
|
|
@@ -159,9 +161,10 @@ function isQueueDependencyHeadWire(value: unknown): value is QueueDependencyHead
|
|
|
159
161
|
}
|
|
160
162
|
|
|
161
163
|
function isQueueQueryResponse(value: unknown): value is QueueQueryResponse {
|
|
162
|
-
if (!isRecord(value) || !hasOnlyKeys(value, ['entries', 'counts', 'oldHistoricalCount', 'dependencyHeads'])) return false
|
|
164
|
+
if (!isRecord(value) || !hasOnlyKeys(value, ['entries', 'counts', 'oldHistoricalCount', 'legacyReportedBlockedCount', 'dependencyHeads'])) return false
|
|
163
165
|
if (!Array.isArray(value.entries) || !value.entries.every(isQueueEntryWire)) return false
|
|
164
166
|
if (value.counts !== undefined && (!isRecord(value.counts) || !Object.values(value.counts).every(isNonNegativeInt))) return false
|
|
167
|
+
if (value.legacyReportedBlockedCount !== undefined && !isNonNegativeInt(value.legacyReportedBlockedCount)) return false
|
|
165
168
|
if (value.oldHistoricalCount !== undefined && !isNonNegativeInt(value.oldHistoricalCount)) return false
|
|
166
169
|
if (value.dependencyHeads !== undefined && (!Array.isArray(value.dependencyHeads) || !value.dependencyHeads.every(isQueueDependencyHeadWire))) return false
|
|
167
170
|
return true
|
|
@@ -305,6 +308,8 @@ export interface QueueRequeueRequest {
|
|
|
305
308
|
|
|
306
309
|
export interface QueueRequeueResponse {
|
|
307
310
|
task: QueueEntryWire | null
|
|
311
|
+
/** queue_revise {requestQuotaOverride}: the owner decision that was raised (or already open). Never a grant. */
|
|
312
|
+
quotaOverrideRequested?: { decisionId: string; alreadyAsked: boolean; options: string[] }
|
|
308
313
|
}
|
|
309
314
|
|
|
310
315
|
function isQueueRequeueRequest(value: unknown): value is QueueRequeueRequest {
|
|
@@ -318,7 +323,8 @@ export function decodeQueueRequeueRequest(value: unknown): QueueRequeueRequest |
|
|
|
318
323
|
}
|
|
319
324
|
|
|
320
325
|
function isQueueRequeueResponse(value: unknown): value is QueueRequeueResponse {
|
|
321
|
-
return isRecord(value) && hasOnlyKeys(value, ['task']) && (value.task === null || isQueueEntryWire(value.task))
|
|
326
|
+
return isRecord(value) && hasOnlyKeys(value, ['task', 'quotaOverrideRequested']) && (value.task === null || isQueueEntryWire(value.task))
|
|
327
|
+
&& (value.quotaOverrideRequested === undefined || (isRecord(value.quotaOverrideRequested) && typeof value.quotaOverrideRequested.decisionId === 'string'))
|
|
322
328
|
}
|
|
323
329
|
|
|
324
330
|
export function decodeQueueRequeueResponse(value: unknown): QueueRequeueResponse | null {
|
|
@@ -491,3 +497,40 @@ function isRecoveryContextQueryResponse(value: unknown): value is RecoveryContex
|
|
|
491
497
|
export function decodeRecoveryContextQueryResponse(value: unknown): RecoveryContextQueryResponse | null {
|
|
492
498
|
return isRecoveryContextQueryResponse(value) ? value : null
|
|
493
499
|
}
|
|
500
|
+
|
|
501
|
+
// ── queue_revise: host-authenticated pending CAS, never a force requeue ──
|
|
502
|
+
export interface QueueReviseRequest {
|
|
503
|
+
v: typeof TURN_IPC_PROTOCOL_VERSION
|
|
504
|
+
meshId: string
|
|
505
|
+
taskId: string
|
|
506
|
+
expectedRevision: number
|
|
507
|
+
dryRun?: boolean
|
|
508
|
+
deferScheduling?: boolean
|
|
509
|
+
patch: { message?: string; ownedPaths?: string[]; phase?: 'source' | 'integration'; dependsOn?: string[]; routingPreferences?: import('./task-source-phase').MeshRoutingPreferences; review?: import('./task-source-phase').MeshReviewConstraint; difficulty?: 'easy' | 'medium' | 'difficult' | 'freeform'; requestQuotaOverride?: true; attestActiveOwnership?: true }
|
|
510
|
+
}
|
|
511
|
+
export type QueueReviseResponse = QueueRequeueResponse
|
|
512
|
+
export function decodeQueueReviseRequest(value: unknown): QueueReviseRequest | null {
|
|
513
|
+
if (!isRecord(value) || !hasOnlyKeys(value, ['v', 'meshId', 'taskId', 'expectedRevision', 'patch', 'dryRun', 'deferScheduling'])
|
|
514
|
+
|| value.v !== TURN_IPC_PROTOCOL_VERSION || !isEvidenceIdentifier(value.meshId) || !isEvidenceIdentifier(value.taskId)
|
|
515
|
+
|| !Number.isSafeInteger(value.expectedRevision) || (value.expectedRevision as number) < 0
|
|
516
|
+
|| !isRecord(value.patch) || !Object.keys(value.patch).length
|
|
517
|
+
|| !hasOnlyKeys(value.patch, ['message', 'ownedPaths', 'phase', 'dependsOn', 'routingPreferences', 'review', 'difficulty', 'requestQuotaOverride', 'attestActiveOwnership'])) return null
|
|
518
|
+
if (value.dryRun !== undefined && typeof value.dryRun !== 'boolean') return null
|
|
519
|
+
if (value.deferScheduling !== undefined && typeof value.deferScheduling !== 'boolean') return null
|
|
520
|
+
const p = value.patch
|
|
521
|
+
if (p.requestQuotaOverride && (value.dryRun !== undefined || value.deferScheduling !== undefined)) return null
|
|
522
|
+
if (p.requestQuotaOverride !== undefined && (p.requestQuotaOverride !== true || Object.keys(p).length !== 1)) return null
|
|
523
|
+
// Alone, like the quota request: it edits no field, it only attaches the missing physical proof of a running writer.
|
|
524
|
+
// `dry_run` is allowed (the hold text recommends it): it validates the same gates and saves nothing.
|
|
525
|
+
// There is nothing to defer, so `defer_scheduling` stays refused.
|
|
526
|
+
if (p.attestActiveOwnership && value.deferScheduling !== undefined) return null
|
|
527
|
+
if (p.attestActiveOwnership !== undefined && (p.attestActiveOwnership !== true || Object.keys(p).length !== 1)) return null
|
|
528
|
+
if (p.message !== undefined && (typeof p.message !== 'string' || !p.message.trim())) return null
|
|
529
|
+
if (p.phase !== undefined && p.phase !== 'source' && p.phase !== 'integration') return null
|
|
530
|
+
if (p.difficulty !== undefined && p.difficulty !== 'easy' && p.difficulty !== 'medium' && p.difficulty !== 'difficult' && p.difficulty !== 'freeform') return null
|
|
531
|
+
for (const key of ['ownedPaths', 'dependsOn']) {
|
|
532
|
+
if (p[key] !== undefined && (!Array.isArray(p[key]) || !(p[key] as unknown[]).every(x => typeof x === 'string' && !!x.trim()))) return null
|
|
533
|
+
}
|
|
534
|
+
return value as unknown as QueueReviseRequest
|
|
535
|
+
}
|
|
536
|
+
export const decodeQueueReviseResponse = decodeQueueRequeueResponse
|
package/src/turn-ipc-turn.ts
CHANGED
|
@@ -66,7 +66,7 @@ function isTurnObserveResponse(value: unknown): value is TurnObserveResponse {
|
|
|
66
66
|
&& (value.outcome === undefined || isTurnOutcomeValue(value.outcome))
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
const TURN_OUTCOMES_LOCAL = ['completed', 'failed', 'cancelled'] as const
|
|
69
|
+
const TURN_OUTCOMES_LOCAL = ['completed', 'blocked', 'failed', 'cancelled'] as const
|
|
70
70
|
function isTurnOutcomeValue(value: unknown): value is TurnOutcome {
|
|
71
71
|
return typeof value === 'string' && (TURN_OUTCOMES_LOCAL as readonly string[]).includes(value)
|
|
72
72
|
}
|
package/src/turn-ipc.ts
CHANGED
package/src/worker-protocol.ts
CHANGED
|
@@ -40,6 +40,21 @@ export const WORKER_TOOLS = [
|
|
|
40
40
|
'git_status',
|
|
41
41
|
'git_log',
|
|
42
42
|
'git_diff',
|
|
43
|
+
'driver_list',
|
|
44
|
+
'driver_describe',
|
|
45
|
+
'driver_invoke',
|
|
46
|
+
'driver_scaffold',
|
|
47
|
+
'driver_validate',
|
|
48
|
+
'driver_export',
|
|
49
|
+
'driver_install',
|
|
50
|
+
'artifact_register',
|
|
51
|
+
'artifact_list',
|
|
52
|
+
'artifact_read',
|
|
53
|
+
// Contract versioning (Cut A): exact pinned-unit reads (E2), the explicit
|
|
54
|
+
// read claim (C1) and the authoritative head/notice pull.
|
|
55
|
+
'contract_read',
|
|
56
|
+
'contract_observe',
|
|
57
|
+
'contract_current',
|
|
43
58
|
] as const
|
|
44
59
|
|
|
45
60
|
export type WorkerTool = typeof WORKER_TOOLS[number]
|
|
@@ -71,8 +86,57 @@ export interface WorkerProtocolFooterInput {
|
|
|
71
86
|
* which is what every worker launched with the default gate receives.
|
|
72
87
|
*/
|
|
73
88
|
workerMcp?: boolean
|
|
89
|
+
/**
|
|
90
|
+
* Same-machine light task: the worker runs in a temporary light workspace.
|
|
91
|
+
* Renders the light-workspace rules (stay inside, commit there, no installs).
|
|
92
|
+
*/
|
|
93
|
+
light?: { workspace: string; baseSha: string; ossBaseSha?: string; ownedPaths: string[] }
|
|
94
|
+
/**
|
|
95
|
+
* Code-changing task on a shared (non-worktree) node checkout, not a light task: the worker commits on the
|
|
96
|
+
* branch that is currently checked out. Renders the "do not create or switch branches" rule.
|
|
97
|
+
*/
|
|
98
|
+
commitOnCurrentBranch?: boolean
|
|
99
|
+
/**
|
|
100
|
+
* Review-in-task (docs/design/2026-11-01-review-in-task.md §9.3): present when this
|
|
101
|
+
* dispatch is one stage of a stage pipeline. `workspace` is the reviewer's pinned
|
|
102
|
+
* workspace path when the daemon prepared one.
|
|
103
|
+
*/
|
|
104
|
+
stage?: { role: 'implement' | 'revise' | 'review'; round: number; maxRevisions: number; workspace?: string }
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** Light-workspace worker rules (design §9). */
|
|
108
|
+
export function renderLightWorkspaceRules(light: NonNullable<WorkerProtocolFooterInput['light']>): string[] {
|
|
109
|
+
const base = light.ossBaseSha ? `${light.baseSha} (oss ${light.ossBaseSha})` : light.baseSha
|
|
110
|
+
return [
|
|
111
|
+
`You are working in a temporary light workspace at \`${light.workspace}\` based on \`${base}\`. `
|
|
112
|
+
+ 'Work only inside it. Commit your change there (the branch is already set up); do not push.',
|
|
113
|
+
'Do not run `npm install`/`npm ci`/`npm rebuild`/`node-gyp`, do not change package.json or lockfiles — '
|
|
114
|
+
+ 'if the fix needs a dependency change, stop and report `blocked`.',
|
|
115
|
+
'Do not start long-running servers on fixed ports. Run the narrowest tests that cover your change and '
|
|
116
|
+
+ 'list them in `report_completion.testsRun`.',
|
|
117
|
+
light.ownedPaths.length
|
|
118
|
+
? `Stay inside \`owned_paths\` (${light.ownedPaths.join(', ')}); if you must touch more, say why in the summary.`
|
|
119
|
+
: 'Stay inside the paths the task names; if you must touch more, say why in the summary.',
|
|
120
|
+
]
|
|
74
121
|
}
|
|
75
122
|
|
|
123
|
+
/** Base-node code changes land on the branch the coordinator and review expect: the one already checked out. */
|
|
124
|
+
export const WORKER_CURRENT_BRANCH_RULE =
|
|
125
|
+
'Commit your change on the branch that is currently checked out in this workspace. Do not create or switch '
|
|
126
|
+
+ 'branches (no `git checkout -b` / `git switch`) unless the task explicitly says to; report the branch you committed on.'
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Shell-command style rule (every worker). Agent CLIs that pre-check shell commands before running them
|
|
130
|
+
* (for example a permission classifier that must prove every path a command reads) cannot analyse a path
|
|
131
|
+
* held in a shell variable, so such a command stops and asks the person — measured as a stream of
|
|
132
|
+
* approval prompts on delegated workers whose analysis scripts did `N=dir; cat $N/file`. Literal paths
|
|
133
|
+
* cost the worker nothing and keep each command checkable; the rule never widens what a worker may run.
|
|
134
|
+
*/
|
|
135
|
+
export const WORKER_SHELL_LITERAL_PATHS_RULE =
|
|
136
|
+
'In shell commands, write file and directory paths literally (absolute, or relative to your workspace) instead of '
|
|
137
|
+
+ 'through shell variables (`N=dir; cat $N/x`) or `$(...)` substitutions, and keep to one simple command per call, '
|
|
138
|
+
+ 'so the command can be checked before it runs. This does not change what you are allowed to run or read.'
|
|
139
|
+
|
|
76
140
|
export function hasWorkerProtocolFooter(body: string): boolean {
|
|
77
141
|
return typeof body === 'string' && body.includes(WORKER_PROTOCOL_FOOTER_MARKER)
|
|
78
142
|
}
|
|
@@ -108,6 +172,9 @@ export function renderWorkerProtocolFooter(input: WorkerProtocolFooterInput = {}
|
|
|
108
172
|
if (input.readonly) scope.push('read-only')
|
|
109
173
|
if (scope.length) lines.push(`You are a delegated worker (${scope.join(', ')}).`)
|
|
110
174
|
else lines.push('You are a delegated worker.')
|
|
175
|
+
if (input.light) lines.push(...renderLightWorkspaceRules(input.light))
|
|
176
|
+
else if (input.commitOnCurrentBranch && input.stage?.role !== 'review') lines.push(WORKER_CURRENT_BRANCH_RULE)
|
|
177
|
+
lines.push(WORKER_SHELL_LITERAL_PATHS_RULE)
|
|
111
178
|
if (input.workerMcp === false) {
|
|
112
179
|
lines.push(
|
|
113
180
|
'This session has NO adhdev worker tools (`report_completion`, `progress_update`, `peer_context_pull`, '
|
|
@@ -144,6 +211,11 @@ export function renderWorkerProtocolFooter(input: WorkerProtocolFooterInput = {}
|
|
|
144
211
|
+ 'and a read-only task should omit it or send `[]`.',
|
|
145
212
|
'If `report_completion` is refused, the response carries `validationErrors` (or a `hint`) naming exactly '
|
|
146
213
|
+ 'what to fix — correct that field and call it again; a refusal records nothing.',
|
|
214
|
+
'Put substantial findings (a diagnosis, evidence, repro steps, review findings) in a workspace file and register it with '
|
|
215
|
+
+ '`artifact_register`, then cite the returned ids in `report_completion` `artifact_ids`. The next task in this mission '
|
|
216
|
+
+ 'inherits them as input artifacts instead of re-investigating — keep each artifact self-contained and factual.',
|
|
217
|
+
'`driver_invoke` results that carry an image or a large body arrive already registered: take `artifacts[].artifactId` from the '
|
|
218
|
+
+ 'result and cite it in `artifact_ids` — do not paste the body.',
|
|
147
219
|
)
|
|
148
220
|
if (input.enclosedHandoffNotes && input.enclosedHandoffNotes > 0) {
|
|
149
221
|
lines.push(
|
|
@@ -151,9 +223,31 @@ export function renderWorkerProtocolFooter(input: WorkerProtocolFooterInput = {}
|
|
|
151
223
|
+ 'honour their conflict guidance and add your own in `handoff_notes` when you report.',
|
|
152
224
|
)
|
|
153
225
|
}
|
|
226
|
+
if (input.stage) lines.push(...renderStageProtocolLines(input.stage))
|
|
154
227
|
return lines.join('\n')
|
|
155
228
|
}
|
|
156
229
|
|
|
230
|
+
/** The stage-pipeline paragraph of the worker footer (implement / revise / review). */
|
|
231
|
+
export function renderStageProtocolLines(stage: NonNullable<WorkerProtocolFooterInput['stage']>): string[] {
|
|
232
|
+
if (stage.role === 'review') {
|
|
233
|
+
return [
|
|
234
|
+
`STAGE: you are the independent reviewer (round ${stage.round} of at most ${stage.maxRevisions + 1}). Read the input artifacts first (diff, self-check log, previous verdict).`
|
|
235
|
+
+ (stage.workspace ? ` Your workspace ${stage.workspace} is pinned to the round head — you may run tests, but nothing you change lands; do not fix, record findings instead.` : ' Do not modify the workspace: read it, and record findings instead of fixing.')
|
|
236
|
+
+ ' Do not write any file for the review, not even a report: a new or changed file in the reviewed checkout fails the review as reviewer_mutated_source, '
|
|
237
|
+
+ 'and `artifact_register` refuses files outside the workspace. Put every finding in the `review` field of `report_completion` — that is the review record.',
|
|
238
|
+
'Your `report_completion` MUST carry `review`: {verdict: approve | approve_with_nits | changes_requested | reject_approach, findings[{id, severity, category, claim, evidence, suggested_fix?}], checked[], not_checked[], tests_run?[]}. '
|
|
239
|
+
+ '`changes_requested` needs at least one blocking/major finding; `approve` allows none. From round 2 also give `prior_findings[{id, status}]` for every earlier blocking/major finding. '
|
|
240
|
+
+ '`reject_approach` is only for a wrong approach, not for fixable defects.',
|
|
241
|
+
]
|
|
242
|
+
}
|
|
243
|
+
return [
|
|
244
|
+
`STAGE: your \`report_completion\` is a stage report (${stage.role}, round ${stage.round}). An independent reviewer reads your diff next, so commit your work and leave the workspace clean before you report. When your change is committed, report outcome \`completed\` — the review starts only after that report, so never report \`blocked\` because the review has not run yet. You may receive review findings as a follow-up memo in this same session.`,
|
|
245
|
+
...(stage.role === 'revise'
|
|
246
|
+
? ['For every open blocking/major finding in the memo, fill `finding_responses[{id, response: fixed | disputed, note}]` — `disputed` needs your reasoning; the reviewer judges it next round.']
|
|
247
|
+
: []),
|
|
248
|
+
]
|
|
249
|
+
}
|
|
250
|
+
|
|
157
251
|
/**
|
|
158
252
|
* The authored text of a dispatched body: everything before the footer marker.
|
|
159
253
|
* Ledger descriptors, replay fixtures and tests compare authored text, never
|