@adhdev/mesh-shared 1.0.82-rc.1 → 1.0.82-rc.100

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.
Files changed (69) hide show
  1. package/dist/assistant-protocol.d.ts +163 -6
  2. package/dist/decision-push-relay.d.ts +20 -0
  3. package/dist/index.d.ts +13 -0
  4. package/dist/index.js +1683 -120
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +1540 -120
  7. package/dist/index.mjs.map +1 -1
  8. package/dist/launch-defaults.d.ts +196 -0
  9. package/dist/light-task.d.ts +96 -0
  10. package/dist/mesh-tool-names.d.ts +2 -2
  11. package/dist/mesh-vocabulary.d.ts +13 -4
  12. package/dist/mission-git-state.d.ts +83 -0
  13. package/dist/mission-items.d.ts +202 -0
  14. package/dist/node-facts.d.ts +75 -1
  15. package/dist/outbound-message.d.ts +9 -2
  16. package/dist/path-ownership.d.ts +1 -1
  17. package/dist/protocol/daemon-server.d.ts +42 -2
  18. package/dist/protocol/dashboard-daemon-p2p.d.ts +1 -1
  19. package/dist/protocol/dashboard-server.d.ts +20 -2
  20. package/dist/provider-approval.d.ts +36 -0
  21. package/dist/provider-question.d.ts +19 -0
  22. package/dist/quota-freshness.d.ts +65 -0
  23. package/dist/relay-reprobe.d.ts +52 -0
  24. package/dist/release.d.ts +90 -0
  25. package/dist/role-launch.d.ts +11 -0
  26. package/dist/session-launch.d.ts +10 -22
  27. package/dist/slot-proposal.d.ts +14 -0
  28. package/dist/task-source-phase.d.ts +83 -0
  29. package/dist/task-stages.d.ts +208 -0
  30. package/dist/turn-evidence.d.ts +43 -13
  31. package/dist/turn-ipc-mission.d.ts +72 -1
  32. package/dist/turn-ipc-queue.d.ts +30 -0
  33. package/dist/turn-ipc.d.ts +2 -2
  34. package/dist/types.d.ts +1 -0
  35. package/dist/worker-protocol.d.ts +41 -1
  36. package/package.json +1 -1
  37. package/src/assistant-protocol.ts +306 -6
  38. package/src/daemon-normalize.ts +7 -5
  39. package/src/decision-push-relay.ts +23 -0
  40. package/src/index.ts +14 -0
  41. package/src/keyed-doc-delta.ts +9 -1
  42. package/src/launch-defaults.ts +170 -0
  43. package/src/light-task.ts +116 -0
  44. package/src/mesh-tool-names.ts +22 -0
  45. package/src/mesh-vocabulary.ts +12 -2
  46. package/src/mission-git-state.ts +112 -0
  47. package/src/mission-items.ts +421 -0
  48. package/src/node-facts.ts +70 -1
  49. package/src/outbound-message.ts +19 -0
  50. package/src/path-ownership.ts +4 -6
  51. package/src/protocol/daemon-server.ts +37 -2
  52. package/src/protocol/dashboard-server.ts +13 -2
  53. package/src/provider-approval.ts +59 -0
  54. package/src/provider-question.ts +31 -0
  55. package/src/quota-freshness.ts +139 -0
  56. package/src/relay-reprobe.ts +117 -0
  57. package/src/release.ts +121 -0
  58. package/src/role-launch.ts +51 -0
  59. package/src/session-launch.ts +17 -1
  60. package/src/slot-proposal.ts +61 -2
  61. package/src/task-source-phase.ts +70 -0
  62. package/src/task-stages.ts +457 -0
  63. package/src/turn-evidence.ts +56 -20
  64. package/src/turn-ipc-mission.ts +127 -11
  65. package/src/turn-ipc-queue.ts +45 -2
  66. package/src/turn-ipc-turn.ts +1 -1
  67. package/src/turn-ipc.ts +1 -0
  68. package/src/types.ts +1 -0
  69. package/src/worker-protocol.ts +94 -0
@@ -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