@adhdev/mesh-shared 1.0.82-rc.12 → 1.0.82-rc.120

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 (60) hide show
  1. package/dist/assistant-protocol.d.ts +158 -6
  2. package/dist/decision-push-relay.d.ts +20 -0
  3. package/dist/index.d.ts +10 -0
  4. package/dist/index.js +1534 -112
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +1400 -112
  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 +54 -1
  15. package/dist/outbound-message.d.ts +9 -2
  16. package/dist/protocol/daemon-server.d.ts +42 -2
  17. package/dist/protocol/dashboard-daemon-p2p.d.ts +1 -1
  18. package/dist/protocol/dashboard-server.d.ts +20 -2
  19. package/dist/quota-freshness.d.ts +4 -4
  20. package/dist/relay-reprobe.d.ts +52 -0
  21. package/dist/release.d.ts +90 -0
  22. package/dist/role-launch.d.ts +11 -0
  23. package/dist/session-launch.d.ts +10 -22
  24. package/dist/slot-proposal.d.ts +14 -0
  25. package/dist/task-source-phase.d.ts +83 -0
  26. package/dist/task-stages.d.ts +210 -0
  27. package/dist/turn-evidence.d.ts +31 -9
  28. package/dist/turn-ipc-mission.d.ts +72 -1
  29. package/dist/turn-ipc-queue.d.ts +30 -0
  30. package/dist/turn-ipc.d.ts +2 -2
  31. package/dist/worker-protocol.d.ts +41 -1
  32. package/package.json +1 -1
  33. package/src/assistant-protocol.ts +294 -6
  34. package/src/daemon-normalize.ts +7 -5
  35. package/src/decision-push-relay.ts +23 -0
  36. package/src/index.ts +11 -0
  37. package/src/launch-defaults.ts +170 -0
  38. package/src/light-task.ts +116 -0
  39. package/src/mesh-tool-names.ts +22 -0
  40. package/src/mesh-vocabulary.ts +12 -2
  41. package/src/mission-git-state.ts +112 -0
  42. package/src/mission-items.ts +421 -0
  43. package/src/node-facts.ts +54 -1
  44. package/src/outbound-message.ts +19 -0
  45. package/src/protocol/daemon-server.ts +37 -2
  46. package/src/protocol/dashboard-server.ts +13 -2
  47. package/src/quota-freshness.ts +29 -13
  48. package/src/relay-reprobe.ts +117 -0
  49. package/src/release.ts +121 -0
  50. package/src/role-launch.ts +51 -0
  51. package/src/session-launch.ts +17 -1
  52. package/src/slot-proposal.ts +61 -2
  53. package/src/task-source-phase.ts +70 -0
  54. package/src/task-stages.ts +459 -0
  55. package/src/turn-evidence.ts +47 -7
  56. package/src/turn-ipc-mission.ts +127 -11
  57. package/src/turn-ipc-queue.ts +45 -2
  58. package/src/turn-ipc-turn.ts +1 -1
  59. package/src/turn-ipc.ts +1 -0
  60. package/src/worker-protocol.ts +94 -0
@@ -0,0 +1,210 @@
1
+ /**
2
+ * task-stages — vocabulary, shapes and validators for "review in task".
3
+ *
4
+ * A medium/difficult `code_change` can be enqueued as ONE stage task: the daemon runs
5
+ * implement → self-check → independent review → (bounded) revise inside the task and the
6
+ * coordinator is woken once, by the parent's terminal. Design:
7
+ * docs/design/2026-11-01-review-in-task.md (§3 model, §5 data contract).
8
+ *
9
+ * Dependency-free leaf: every cap and enum the daemon validator, the MCP schemas and the
10
+ * dashboard chips read lives here once.
11
+ */
12
+ import type { LightTestRun } from './light-task';
13
+ export declare const REVIEW_VERDICTS: readonly ["approve", "approve_with_nits", "changes_requested", "reject_approach"];
14
+ export type MeshReviewVerdict = typeof REVIEW_VERDICTS[number];
15
+ export declare const FINDING_SEVERITIES: readonly ["blocking", "major", "minor", "nit"];
16
+ export type MeshFindingSeverity = typeof FINDING_SEVERITIES[number];
17
+ export declare const FINDING_CATEGORIES: readonly ["correctness", "regression", "test_gap", "scope", "security", "performance", "maintainability"];
18
+ export type MeshFindingCategory = typeof FINDING_CATEGORIES[number];
19
+ export declare const PRIOR_FINDING_STATUSES: readonly ["resolved", "unresolved", "dispute_accepted", "dispute_rejected"];
20
+ export type MeshPriorFindingStatus = typeof PRIOR_FINDING_STATUSES[number];
21
+ export declare const FINDING_RESPONSE_KINDS: readonly ["fixed", "disputed"];
22
+ export type MeshFindingResponseKind = typeof FINDING_RESPONSE_KINDS[number];
23
+ export declare const STAGE_PHASES: readonly ["implementing", "self_checking", "awaiting_review", "reviewing", "revising", "done"];
24
+ export type MeshStagePhase = typeof STAGE_PHASES[number];
25
+ /** Phases in which the parent row holds NO open attempt but is waiting on the daemon (watchdogs must skip it). */
26
+ export declare const STAGE_PARKED_PHASES: readonly MeshStagePhase[];
27
+ export declare const STAGE_INDEPENDENCE_MODES: readonly ["different_provider", "fresh_session_ok"];
28
+ export type MeshStageIndependenceMode = typeof STAGE_INDEPENDENCE_MODES[number];
29
+ /** What actually reviewed (recorded on the verdict and in the final report). */
30
+ export type MeshStageIndependenceUsed = 'different_provider' | 'fresh_session_fallback';
31
+ export declare const STAGE_ROLES: readonly ["implement", "revise", "review"];
32
+ export type MeshStageRole = typeof STAGE_ROLES[number];
33
+ /** Why a stage parent ended `blocked` (R4/R12, doc §3.2). */
34
+ export declare const STAGE_BLOCKED_REASONS: readonly ["review_unresolved", "review_rejected_approach", "review_unavailable", "self_check_failed", "stage_pipeline_ceiling", "reviewer_mutated_source", "reviewer_integrity_unverifiable"];
35
+ export type MeshStageBlockedReason = typeof STAGE_BLOCKED_REASONS[number];
36
+ export declare const STAGE_DECIDE_ACTIONS: readonly ["accept", "revise_once", "rereview", "abandon"];
37
+ export type MeshStageDecideAction = typeof STAGE_DECIDE_ACTIONS[number];
38
+ export declare const STAGE_MAX_REVISIONS_LIMIT = 3;
39
+ export declare const STAGE_DEFAULT_MAX_REVISIONS = 2;
40
+ export declare const STAGE_SELF_CHECK_MAX_BOUNCES = 2;
41
+ /** Minutes a review child may be refused only for `review_independence_required` before fresh_session fallback (R2). */
42
+ export declare const STAGE_INDEPENDENCE_FALLBACK_MS: number;
43
+ /** Parent pipeline ceiling from first dispatch (R12). */
44
+ export declare const STAGE_PIPELINE_CEILING_DEFAULT_MS: number;
45
+ export declare const REVIEW_FINDINGS_MAX = 30;
46
+ export declare const REVIEW_CLAIM_MAX_CHARS = 500;
47
+ export declare const REVIEW_EVIDENCE_MAX_CHARS = 1000;
48
+ export declare const REVIEW_FIX_MAX_CHARS = 500;
49
+ export declare const REVIEW_FINDING_ID_MAX_CHARS = 40;
50
+ export declare const REVIEW_CHECKED_MAX = 20;
51
+ export declare const REVIEW_NOTE_MAX_CHARS = 500;
52
+ export declare const REVIEW_TESTS_RUN_MAX = 20;
53
+ export declare const FINDING_RESPONSES_MAX = 30;
54
+ export interface MeshTaskStagePlan {
55
+ review: true;
56
+ maxRevisions: 0 | 1 | 2 | 3;
57
+ independence: MeshStageIndependenceMode;
58
+ }
59
+ export interface MeshStageHead {
60
+ round: number;
61
+ rootSha: string;
62
+ submodules?: Record<string, string>;
63
+ }
64
+ export interface MeshTaskStageState {
65
+ phase: MeshStagePhase;
66
+ /** Review round in progress (0 before the first review child exists). */
67
+ round: number;
68
+ selfCheckBounces: number;
69
+ startedAt: string;
70
+ phaseSince: string;
71
+ baseSha: string;
72
+ stageHeads: MeshStageHead[];
73
+ reviewTaskIds: string[];
74
+ lastVerdict?: MeshReviewVerdict;
75
+ openFindingIds: string[];
76
+ artifacts: {
77
+ diff: string[];
78
+ selfCheck: string[];
79
+ verdict: string[];
80
+ };
81
+ reviewerSessionId?: string;
82
+ independenceUsed?: MeshStageIndependenceUsed;
83
+ /** Attempts the reducer already consumed (idempotency against the two terminal paths). */
84
+ handledAttemptIds?: string[];
85
+ /** Consecutive reviewer-unavailable outcomes (2 → review_unavailable). */
86
+ reviewerFailures?: number;
87
+ /** Coordinator-granted extra revision rounds (`mesh_task_stage_decide revise_once`). */
88
+ extraRevisions?: number;
89
+ /** Why the parent is blocked, once it is. */
90
+ blockedReason?: MeshStageBlockedReason;
91
+ /** The underlying error text when the reason alone does not say it (e.g. why no reviewer could be created). */
92
+ blockedDetail?: string;
93
+ /** Unresolved findings snapshot kept for the final report (id + severity + claim). */
94
+ openFindings?: Array<{
95
+ id: string;
96
+ severity: MeshFindingSeverity;
97
+ claim: string;
98
+ }>;
99
+ /** Nits/minors from the approving verdict, delivered in the final report. */
100
+ openNits?: Array<{
101
+ id: string;
102
+ severity: MeshFindingSeverity;
103
+ claim: string;
104
+ }>;
105
+ /** Self-check outcome summary for the final report. */
106
+ selfCheck?: 'passed' | 'skipped_not_configured' | 'skipped_infra_error' | 'unavailable' | 'failed';
107
+ /** Resolved/disputed counters for the verdict line. */
108
+ findingsFixed?: number;
109
+ /** The original coordinator message, preserved while revise memos replace `message`. */
110
+ originalMessage?: string;
111
+ /** Artifact ids the implementer cited in its own report (feed the next stage's input, top 4). */
112
+ workerArtifactIds?: string[];
113
+ /** Read-lease reviews only: HEAD + working-tree fingerprint of the parent checkout taken when the review child was created (§11). */
114
+ reviewFingerprint?: string;
115
+ /** Read-lease review whose baseline fingerprint could not be taken (after one retry): the verdict is never accepted. */
116
+ reviewFingerprintUnavailable?: boolean;
117
+ /** True once the parent was released to a terminal by the pipeline (hold lifted). */
118
+ released?: boolean;
119
+ }
120
+ export interface MeshReviewFinding {
121
+ id: string;
122
+ severity: MeshFindingSeverity;
123
+ category: MeshFindingCategory;
124
+ file?: string;
125
+ line?: number;
126
+ claim: string;
127
+ evidence: string;
128
+ suggestedFix?: string;
129
+ }
130
+ export interface MeshPriorFindingStatusEntry {
131
+ id: string;
132
+ status: MeshPriorFindingStatus;
133
+ note?: string;
134
+ }
135
+ /** One definition: the light-task `LightTestRun` (same {command, exit, passed?, failed?, note?} shape). */
136
+ export type MeshTestRun = LightTestRun;
137
+ export interface MeshReviewReport {
138
+ verdict: MeshReviewVerdict;
139
+ findings: MeshReviewFinding[];
140
+ priorFindings?: MeshPriorFindingStatusEntry[];
141
+ checked: string[];
142
+ notChecked: string[];
143
+ testsRun?: MeshTestRun[];
144
+ }
145
+ export interface MeshFindingResponse {
146
+ id: string;
147
+ response: MeshFindingResponseKind;
148
+ note: string;
149
+ }
150
+ export interface StageValidationError {
151
+ field: string;
152
+ message: string;
153
+ }
154
+ export declare const isReviewVerdict: (value: unknown) => value is "approve" | "approve_with_nits" | "changes_requested" | "reject_approach";
155
+ export declare const isFindingSeverity: (value: unknown) => value is "major" | "minor" | "blocking" | "nit";
156
+ export declare const isFindingCategory: (value: unknown) => value is "scope" | "correctness" | "regression" | "test_gap" | "security" | "performance" | "maintainability";
157
+ export declare const isPriorFindingStatus: (value: unknown) => value is "resolved" | "unresolved" | "dispute_accepted" | "dispute_rejected";
158
+ export declare const isFindingResponseKind: (value: unknown) => value is "fixed" | "disputed";
159
+ export declare const isStageBlockedReason: (value: unknown) => value is "review_unresolved" | "review_rejected_approach" | "review_unavailable" | "self_check_failed" | "stage_pipeline_ceiling" | "reviewer_mutated_source" | "reviewer_integrity_unverifiable";
160
+ /** Blocking/major findings keep a review from passing. */
161
+ export declare function isBlockingSeverity(severity: MeshFindingSeverity): boolean;
162
+ export interface StagePlanDefaultsInput {
163
+ taskMode?: string;
164
+ difficulty?: string;
165
+ readonly?: boolean;
166
+ }
167
+ /**
168
+ * Resolve the enqueue-time `review` option into a stage plan, or null when review is off.
169
+ * `review` undefined → OFF (owner decision 2026-11-08: in-task review is opt-in; the default cost speed and parallelism
170
+ * without catching the live bugs). Pass `review: true` (or an options object) for a change that genuinely needs one.
171
+ * `defaultOn: true` restores the old R5 default (medium/difficult non-readonly `code_change` → on) for a caller that asks for it.
172
+ * Throws `invalid_review_option: …` on malformed input (rejected, never coerced).
173
+ */
174
+ export declare function resolveStagePlan(raw: unknown, task: StagePlanDefaultsInput, opts?: {
175
+ defaultOn?: boolean;
176
+ }): MeshTaskStagePlan | null;
177
+ export declare function defaultStagePlan(): MeshTaskStagePlan;
178
+ /** R5: only non-readonly code_change tasks run the pipeline by default (medium/difficult). */
179
+ export declare function isStageEligibleTask(task: StagePlanDefaultsInput): boolean;
180
+ export interface ReviewValidationContext {
181
+ /** 1-based review round of the child this report is for. */
182
+ round: number;
183
+ /** Blocking/major finding ids still open from the previous round (round ≥ 2 must answer each). */
184
+ priorOpenBlockingIds?: readonly string[];
185
+ }
186
+ /**
187
+ * Validate the `review` field of a reviewer's `report_completion`. Rejects, never coerces;
188
+ * unknown keys are rejected (a misspelled `notChecked` must not silently vanish).
189
+ */
190
+ export declare function validateReviewReport(raw: unknown, ctx: ReviewValidationContext): {
191
+ report?: MeshReviewReport;
192
+ errors: StageValidationError[];
193
+ };
194
+ /** Shared by the reviewer's `review.testsRun` and the top-level `testsRun` of any report. */
195
+ export declare function validateTestsRun(raw: unknown, field: string, errors: StageValidationError[]): MeshTestRun[];
196
+ /** Validate an implementer's `findingResponses` (§5.3). */
197
+ export declare function validateFindingResponses(raw: unknown, field?: string): {
198
+ responses?: MeshFindingResponse[];
199
+ errors: StageValidationError[];
200
+ };
201
+ export interface StageVerdictLineInput {
202
+ verdict: MeshReviewVerdict | 'skipped_no_diff';
203
+ rounds: number;
204
+ reviewerProvider?: string;
205
+ independenceUsed?: MeshStageIndependenceUsed;
206
+ fixed?: number;
207
+ openNits?: number;
208
+ }
209
+ /** One human-readable line: `review: approve_with_nits · 2 rounds · reviewer codex-cli (different_provider) · 3 findings fixed, 1 nit open`. */
210
+ export declare function formatStageVerdictLine(input: StageVerdictLineInput): string;
@@ -40,7 +40,11 @@ export declare const DELIVERY_OUTCOMES: readonly ["delivered", "queued"];
40
40
  export type DeliveryOutcome = typeof DELIVERY_OUTCOMES[number];
41
41
  export declare const DELIVERY_VIAS: readonly ["local", "p2p"];
42
42
  export type DeliveryVia = typeof DELIVERY_VIAS[number];
43
- export declare const DISPATCH_FAILURE_REASONS: readonly ["worker_absent", "transport_error", "spawn_failed", "rejected_by_worker", "timeout"];
43
+ /** `submit_unconfirmed` (SUBMIT-UNCONFIRMED-RECLAIM): the worker's CLI never
44
+ * took the written prompt — the submit budget and one re-paste were spent at
45
+ * an idle composer. An owner daemon older than this value drops the evidence
46
+ * as invalid and falls back to its consume/turn holds (the pre-fix path). */
47
+ export declare const DISPATCH_FAILURE_REASONS: readonly ["worker_absent", "transport_error", "spawn_failed", "rejected_by_worker", "timeout", "submit_unconfirmed"];
44
48
  export type DispatchFailureReason = typeof DISPATCH_FAILURE_REASONS[number];
45
49
  /**
46
50
  * Normalize a worker's own refusal code (e.g. `session_busy_with_task`,
@@ -52,6 +56,20 @@ export type DispatchFailureReason = typeof DISPATCH_FAILURE_REASONS[number];
52
56
  * (see the field's doc comment — this evidence replicates cross-machine).
53
57
  */
54
58
  export declare function sanitizeRefusalCode(value: unknown): string | undefined;
59
+ /** Longest refusal message kept on a failed dispatch (see {@link sanitizeDispatchRefusalDetail}). */
60
+ export declare const DISPATCH_REFUSAL_DETAIL_MAX = 200;
61
+ /**
62
+ * Bounded, sanitized "why was this dispatch refused" detail for triage:
63
+ * `{code, message}` with the code in the refusal-code identifier shape and the
64
+ * message a single printable line of at most {@link DISPATCH_REFUSAL_DETAIL_MAX}
65
+ * chars (home-directory prefixes collapsed to `~`). Refusal texts are generated
66
+ * by the daemon / transport, never by a user or an agent. LOCAL records only:
67
+ * it is deliberately NOT part of the replicated turn evidence (content-free).
68
+ */
69
+ export declare function sanitizeDispatchRefusalDetail(code: unknown, message: unknown): {
70
+ code?: string;
71
+ message?: string;
72
+ } | undefined;
55
73
  export declare const CONSUME_PROFILES: readonly ["default", "native_source"];
56
74
  export type ConsumeProfile = typeof CONSUME_PROFILES[number];
57
75
  export declare const SESSION_REBOUND_REASONS: readonly ["restart", "live_holder"];
@@ -99,14 +117,14 @@ export type NoProgressObservedStatus = SessionStatus | 'unknown';
99
117
  * Reasons a turn hold exists. Holds are attempt-scoped only (C2: delivery-side
100
118
  * waits are consumer deferral on the `turn.deliver` cursor, not hold rows).
101
119
  */
102
- export declare const HOLD_REASONS: readonly ["await_delivery", "await_consume", "await_turn", "liveness", "hard_ceiling", "live_pending", "transcript_quiet", "weak_candidate", "suspension_before_consumed", "await_report", "await_end"];
120
+ export declare const HOLD_REASONS: readonly ["await_delivery", "await_consume", "await_turn", "liveness", "hard_ceiling", "live_pending", "transcript_quiet", "weak_candidate", "suspension_before_consumed", "await_report", "await_end", "report_correction", "stall_ceiling"];
103
121
  export type HoldReason = typeof HOLD_REASONS[number];
104
- export declare const TURN_OUTCOMES: readonly ["completed", "failed", "cancelled"];
122
+ export declare const TURN_OUTCOMES: readonly ["completed", "blocked", "failed", "cancelled"];
105
123
  export type TurnOutcome = typeof TURN_OUTCOMES[number];
106
124
  export declare const COMMIT_STRENGTHS: readonly ["genuine", "weak", "tool_report", "operator"];
107
125
  export type CommitStrength = typeof COMMIT_STRENGTHS[number];
108
126
  /** Every terminal or reclaim reason the ledger writes. Closed: no free-text reasons. */
109
- export declare const TURN_REASONS: readonly ["turn_end", "weak_end_confirmed", "transcript_final", "worker_reported", "finalization_timeout_no_response", "session_error", "provider_auth_failed", "provider_billing_failed", "provider_usage_limit_exceeded", "provider_server_overloaded", "provider_error", "operator_cancel", "intentional_cleanup", "task_removed", "mission_abandoned", "superseded", "operator_update", "refine_terminal", "validation_terminal", "hard_ceiling", "reclaim_budget_exhausted", "hollow_max_retries", "migration_orphan", "dispatch_refused_session_exited", "dispatch_refused_no_target", "dispatch_refused_unsupported_input", "dispatch_failed", "session_exit", "session_exit_before_turn", "session_dead", "hollow_completion", "assigned_stranded_dispatch_unconfirmed", "delivered_not_consumed_redrive", "delivered_no_turn_deadline"];
127
+ export declare const TURN_REASONS: readonly ["turn_end", "weak_end_confirmed", "transcript_final", "worker_reported", "finalization_timeout_no_response", "weak_end_liveness_unconfirmed", "weak_end_probe_unobserved", "report_correction_expired", "report_missing_timeout", "session_error", "provider_auth_failed", "provider_billing_failed", "provider_usage_limit_exceeded", "provider_server_overloaded", "provider_error", "operator_cancel", "intentional_cleanup", "task_removed", "mission_abandoned", "superseded", "operator_update", "refine_terminal", "validation_terminal", "hard_ceiling", "reclaim_budget_exhausted", "hollow_max_retries", "migration_orphan", "writer_unreachable", "dispatch_refused_session_exited", "dispatch_refused_no_target", "dispatch_refused_unsupported_input", "dispatch_failed", "session_exit", "session_exit_before_turn", "session_dead", "hollow_completion", "assigned_stranded_dispatch_unconfirmed", "delivered_not_consumed_redrive", "delivered_no_turn_deadline", "stalled_no_output"];
110
128
  export type TurnReason = typeof TURN_REASONS[number];
111
129
  /**
112
130
  * What a `turn.notify` entry tells a coordinator.
@@ -118,7 +136,7 @@ export type TurnReason = typeof TURN_REASONS[number];
118
136
  * (refine terminal, worktree bootstrap, …) whose text lives only in the
119
137
  * owner's local `turn_events.payload_json` and is rendered at deliver time.
120
138
  */
121
- export declare const NOTIFY_KINDS: readonly ["completed", "failed", "cancelled", "stopped", "approval", "choice", "approval_resolved", "candidate", "no_progress", "progress", "late_completion", "mesh_event"];
139
+ export declare const NOTIFY_KINDS: readonly ["completed", "blocked", "failed", "cancelled", "stopped", "approval", "choice", "approval_resolved", "candidate", "no_progress", "progress", "late_completion", "mesh_event"];
122
140
  export type NotifyKind = typeof NOTIFY_KINDS[number];
123
141
  export interface TurnAttemptRef {
124
142
  attemptId: string;
@@ -275,6 +293,7 @@ export type TurnEvidenceBody = {
275
293
  } | {
276
294
  kind: 'liveness';
277
295
  result: LivenessResult;
296
+ probeStartedAtMs?: number;
278
297
  } | {
279
298
  kind: 'process_exit';
280
299
  exitCode: number | null;
@@ -295,6 +314,9 @@ export type TurnEvidenceBody = {
295
314
  hasHandoffNotes: boolean;
296
315
  branchState?: WorkerBranchState;
297
316
  touchedFileCount?: number;
317
+ } | {
318
+ kind: 'worker_report_correction_requested';
319
+ deliveryId?: string;
298
320
  } | {
299
321
  kind: 'worker_progress';
300
322
  note?: SummaryRef;
@@ -378,10 +400,10 @@ export declare const TURN_EVIDENCE_FIELD_SPECS: TurnEvidenceFieldSpecs;
378
400
  export declare const TURN_EVIDENCE_KINDS: readonly TurnEvidenceKind[];
379
401
  /** Evidence kinds that, on their own, can end a turn (the ones R18/R19/R27 reason about). */
380
402
  export declare const TERMINAL_CLASS_EVIDENCE_KINDS: readonly ["turn_end", "transcript_final", "no_progress", "worker_report", "session_error", "process_exit", "cancel", "operator_status"];
381
- export declare const isTurnEvidenceKind: (value: unknown) => value is "no_progress" | "delivered" | "liveness" | "turn_end" | "transcript_final" | "session_error" | "dispatch_failed" | "dispatch_accepted" | "delivery_refused" | "duplicate_dispatch_refusal" | "session_rebound" | "turn_started" | "suspension" | "suspension_resolved" | "transcript_activity" | "process_exit" | "worker_report" | "worker_progress" | "git_side_effect" | "cancel" | "operator_status" | "coordinator_ack" | "hold_expired";
382
- export declare const isTurnReason: (value: unknown) => value is "provider_error" | "intentional_cleanup" | "operator_cancel" | "task_removed" | "mission_abandoned" | "superseded" | "operator_update" | "refine_terminal" | "validation_terminal" | "hard_ceiling" | "turn_end" | "weak_end_confirmed" | "transcript_final" | "worker_reported" | "finalization_timeout_no_response" | "session_error" | "provider_auth_failed" | "provider_billing_failed" | "provider_usage_limit_exceeded" | "provider_server_overloaded" | "reclaim_budget_exhausted" | "hollow_max_retries" | "migration_orphan" | "dispatch_refused_session_exited" | "dispatch_refused_no_target" | "dispatch_refused_unsupported_input" | "dispatch_failed" | "session_exit" | "session_exit_before_turn" | "session_dead" | "hollow_completion" | "assigned_stranded_dispatch_unconfirmed" | "delivered_not_consumed_redrive" | "delivered_no_turn_deadline";
383
- export declare const isNotifyKind: (value: unknown) => value is "stopped" | "failed" | "no_progress" | "completed" | "cancelled" | "approval" | "choice" | "approval_resolved" | "candidate" | "progress" | "late_completion" | "mesh_event";
384
- export declare const isTurnOutcome: (value: unknown) => value is "failed" | "completed" | "cancelled";
403
+ export declare const isTurnEvidenceKind: (value: unknown) => value is "no_progress" | "delivered" | "liveness" | "turn_end" | "transcript_final" | "session_error" | "dispatch_failed" | "dispatch_accepted" | "delivery_refused" | "duplicate_dispatch_refusal" | "session_rebound" | "turn_started" | "suspension" | "suspension_resolved" | "transcript_activity" | "process_exit" | "worker_report" | "worker_report_correction_requested" | "worker_progress" | "git_side_effect" | "cancel" | "operator_status" | "coordinator_ack" | "hold_expired";
404
+ export declare const isTurnReason: (value: unknown) => value is "provider_error" | "intentional_cleanup" | "operator_cancel" | "task_removed" | "mission_abandoned" | "superseded" | "operator_update" | "refine_terminal" | "validation_terminal" | "hard_ceiling" | "turn_end" | "weak_end_confirmed" | "transcript_final" | "worker_reported" | "finalization_timeout_no_response" | "weak_end_liveness_unconfirmed" | "weak_end_probe_unobserved" | "report_correction_expired" | "report_missing_timeout" | "session_error" | "provider_auth_failed" | "provider_billing_failed" | "provider_usage_limit_exceeded" | "provider_server_overloaded" | "reclaim_budget_exhausted" | "hollow_max_retries" | "migration_orphan" | "writer_unreachable" | "dispatch_refused_session_exited" | "dispatch_refused_no_target" | "dispatch_refused_unsupported_input" | "dispatch_failed" | "session_exit" | "session_exit_before_turn" | "session_dead" | "hollow_completion" | "assigned_stranded_dispatch_unconfirmed" | "delivered_not_consumed_redrive" | "delivered_no_turn_deadline" | "stalled_no_output";
405
+ export declare const isNotifyKind: (value: unknown) => value is "stopped" | "failed" | "blocked" | "no_progress" | "completed" | "cancelled" | "approval" | "choice" | "approval_resolved" | "candidate" | "progress" | "late_completion" | "mesh_event";
406
+ export declare const isTurnOutcome: (value: unknown) => value is "failed" | "blocked" | "completed" | "cancelled";
385
407
  export declare const isCommitStrength: (value: unknown) => value is "operator" | "genuine" | "weak" | "tool_report";
386
408
  export declare function isEvidenceIdentifier(value: unknown): value is string;
387
409
  export declare function isSummaryRef(value: unknown): value is SummaryRef;
@@ -30,8 +30,43 @@ export interface MissionUpsertRequest {
30
30
  * this wire guard only checks SHAPE, not that decision.
31
31
  */
32
32
  brief?: MissionBriefWire | null;
33
+ /**
34
+ * Structured-missions bundle A (design 2026-10-28 §5.1). Every key below is optional
35
+ * and ABSENT on a legacy call. `structured: true` is the caller's capability flag: the
36
+ * daemon only puts the new keys on the response (mission summary/outcome/version,
37
+ * `result`) when it is set, so an older mcp-server that never sends it keeps decoding
38
+ * byte-identical responses (mixed-version fleets, design §13.1).
39
+ */
40
+ structured?: boolean;
41
+ summary?: string;
42
+ /** One user/operator-visible sentence for the release CHANGELOG draft (design 2026-11-01-release-objects L5). `''` clears. */
43
+ releaseNote?: string;
44
+ outcome?: string;
45
+ outcomeReason?: string;
46
+ /** Mission id open items move to when this call closes the mission (default: the carry-over mission). */
47
+ carryOverTo?: string;
48
+ /** Route to the mesh's auto-created carry-over mission instead of `id`/`title` (decision requests without a mission). `title` may then be empty. */
49
+ toCarryOver?: boolean;
50
+ itemsAdd?: readonly Record<string, unknown>[];
51
+ itemsUpdate?: readonly Record<string, unknown>[];
52
+ }
53
+ export interface MeshMissionOpenItemCountsWire {
54
+ remaining: number;
55
+ live_check: number;
56
+ decision: number;
57
+ evidence: number;
58
+ }
59
+ /** Structured-missions fields (only with `structured: true` on the request). */
60
+ export interface MeshMissionStructuredWire {
61
+ summary?: string;
62
+ releaseNote?: string;
63
+ outcome?: string;
64
+ outcomeReason?: string;
65
+ version?: number;
66
+ carryOver?: boolean;
67
+ openItems?: MeshMissionOpenItemCountsWire;
33
68
  }
34
- export interface MeshMissionRecordWire {
69
+ export interface MeshMissionRecordWire extends MeshMissionStructuredWire {
35
70
  id: string;
36
71
  meshId: string;
37
72
  title: string;
@@ -42,6 +77,8 @@ export interface MeshMissionRecordWire {
42
77
  }
43
78
  export interface MissionUpsertResponse {
44
79
  mission: MeshMissionRecordWire;
80
+ /** Structured calls only: per-item results, movedItems/movedTo, restoredItems, ownerConfirmationItemId, warnings. */
81
+ result?: Record<string, unknown>;
45
82
  }
46
83
  export declare function decodeMissionUpsertRequest(value: unknown): MissionUpsertRequest | null;
47
84
  export declare function isMissionUpsertResponse(value: unknown): value is MissionUpsertResponse;
@@ -77,6 +114,12 @@ export interface MissionListQueryRequest {
77
114
  * option except `historyIdLimit` is ignored. An older daemon rejects the key.
78
115
  */
79
116
  meshStatusView?: 'compact' | 'verbose';
117
+ /** Structured-missions capability flag (see MissionUpsertRequest.structured): rows then carry summary/outcome/openItems/carryOver/version. */
118
+ structured?: boolean;
119
+ /** Structured only: attach each mission's items. */
120
+ items?: boolean;
121
+ /** Structured only: attach each mission's change history (bounded tail). */
122
+ history?: boolean;
80
123
  }
81
124
  export interface MeshMissionTaskAggregateWire {
82
125
  total: number;
@@ -89,6 +132,8 @@ export interface MeshMissionTaskAggregateWire {
89
132
  lastActivityAt: string | null;
90
133
  }
91
134
  export interface MeshMissionStatsWire {
135
+ /** Present on peers that project proven blocked outcomes separately. */
136
+ blocked?: number;
92
137
  missionId: string;
93
138
  taskCount: number;
94
139
  completed: number;
@@ -113,6 +158,16 @@ export interface MissionListSummaryVerboseWire {
113
158
  createdAt?: string;
114
159
  updatedAt?: string;
115
160
  closeCandidateEmittedAt?: string | null;
161
+ /** Structured lists only. */
162
+ summary?: string;
163
+ releaseNote?: string;
164
+ outcome?: string;
165
+ outcomeReason?: string;
166
+ version?: number;
167
+ carryOver?: boolean;
168
+ openItems?: MeshMissionOpenItemCountsWire;
169
+ items?: readonly Record<string, unknown>[];
170
+ history?: readonly Record<string, unknown>[];
116
171
  }
117
172
  /** Compact (default) mission row. `goalPreview`/`goalTruncated` present, `goal` absent. */
118
173
  export interface MissionListSummarySlimWire {
@@ -130,6 +185,16 @@ export interface MissionListSummarySlimWire {
130
185
  createdAt?: string;
131
186
  updatedAt?: string;
132
187
  closeCandidateEmittedAt?: string | null;
188
+ /** Structured lists only. */
189
+ summary?: string;
190
+ releaseNote?: string;
191
+ outcome?: string;
192
+ outcomeReason?: string;
193
+ version?: number;
194
+ carryOver?: boolean;
195
+ openItems?: MeshMissionOpenItemCountsWire;
196
+ items?: readonly Record<string, unknown>[];
197
+ history?: readonly Record<string, unknown>[];
133
198
  }
134
199
  export type MissionListSummaryWire = MissionListSummaryVerboseWire | MissionListSummarySlimWire;
135
200
  export interface MeshMissionHistoryFoldWire {
@@ -231,6 +296,12 @@ export interface LedgerQueryEntryWire {
231
296
  payload: Record<string, unknown>;
232
297
  }
233
298
  export interface LedgerQuerySummaryWire {
299
+ /** Absent on older peers; never folded into failed by the decoder. */
300
+ taskBlocked?: number;
301
+ /** Failed Refinery jobs (not tasks). Absent on older peers. Lifetime, not the current window. */
302
+ refineFailed?: number;
303
+ /** Refine failures inside the 30-minute current window. Absent on older peers. */
304
+ recentRefineFailures?: number;
234
305
  meshId: string;
235
306
  totalEntries: number;
236
307
  taskDispatched: number;
@@ -65,6 +65,8 @@ export interface QueueQueryResponse {
65
65
  counts?: Record<string, number>;
66
66
  /** `withCounts` + `historicalOlderThanMs`: terminal rows older than that age. */
67
67
  oldHistoricalCount?: number;
68
+ /** Included in counts.blocked, derived from proven worker reports; stored failed rows stay unchanged. */
69
+ legacyReportedBlockedCount?: number;
68
70
  /** `withDependencyHeads`. */
69
71
  dependencyHeads?: readonly QueueDependencyHeadWire[];
70
72
  }
@@ -123,6 +125,12 @@ export interface QueueRequeueRequest {
123
125
  }
124
126
  export interface QueueRequeueResponse {
125
127
  task: QueueEntryWire | null;
128
+ /** queue_revise {requestQuotaOverride}: the owner decision that was raised (or already open). Never a grant. */
129
+ quotaOverrideRequested?: {
130
+ decisionId: string;
131
+ alreadyAsked: boolean;
132
+ options: string[];
133
+ };
126
134
  }
127
135
  export declare function decodeQueueRequeueRequest(value: unknown): QueueRequeueRequest | null;
128
136
  export declare function decodeQueueRequeueResponse(value: unknown): QueueRequeueResponse | null;
@@ -194,3 +202,25 @@ export interface RecoveryContextQueryResponse {
194
202
  }
195
203
  export declare function decodeRecoveryContextQueryRequest(value: unknown): RecoveryContextQueryRequest | null;
196
204
  export declare function decodeRecoveryContextQueryResponse(value: unknown): RecoveryContextQueryResponse | null;
205
+ export interface QueueReviseRequest {
206
+ v: typeof TURN_IPC_PROTOCOL_VERSION;
207
+ meshId: string;
208
+ taskId: string;
209
+ expectedRevision: number;
210
+ dryRun?: boolean;
211
+ deferScheduling?: boolean;
212
+ patch: {
213
+ message?: string;
214
+ ownedPaths?: string[];
215
+ phase?: 'source' | 'integration';
216
+ dependsOn?: string[];
217
+ routingPreferences?: import('./task-source-phase').MeshRoutingPreferences;
218
+ review?: import('./task-source-phase').MeshReviewConstraint;
219
+ difficulty?: 'easy' | 'medium' | 'difficult' | 'freeform';
220
+ requestQuotaOverride?: true;
221
+ attestActiveOwnership?: true;
222
+ };
223
+ }
224
+ export type QueueReviseResponse = QueueRequeueResponse;
225
+ export declare function decodeQueueReviseRequest(value: unknown): QueueReviseRequest | null;
226
+ export declare const decodeQueueReviseResponse: typeof decodeQueueRequeueResponse;
@@ -94,6 +94,6 @@ export interface TurnIpcError {
94
94
  }
95
95
  export declare function isTurnIpcError(value: unknown): value is TurnIpcError;
96
96
  /** The complete, closed set of IPC command names this contract defines. */
97
- export declare const TURN_IPC_COMMANDS: readonly ["turn_observe", "mesh_record", "turn_cancel", "operator_status", "turn_query", "mesh_index_query", "mission_upsert", "mission_query", "note_upsert", "note_forget", "tool_call_record", "ledger_query", "mission_list_query", "record_local", "queue_query", "queue_enqueue", "queue_enqueue_batch", "queue_cancel", "queue_requeue", "direct_dispatch_record", "active_work_query", "recovery_context_query", "task_stats_query", "prune_stale_direct", "orphaned_pin_notify"];
97
+ export declare const TURN_IPC_COMMANDS: readonly ["turn_observe", "mesh_record", "turn_cancel", "operator_status", "turn_query", "mesh_index_query", "mission_upsert", "mission_query", "note_upsert", "note_forget", "tool_call_record", "ledger_query", "mission_list_query", "record_local", "queue_query", "queue_enqueue", "queue_enqueue_batch", "queue_cancel", "queue_requeue", "queue_revise", "direct_dispatch_record", "active_work_query", "recovery_context_query", "task_stats_query", "prune_stale_direct", "orphaned_pin_notify"];
98
98
  export type TurnIpcCommand = typeof TURN_IPC_COMMANDS[number];
99
- export declare const isTurnIpcCommand: (value: unknown) => value is "prune_stale_direct" | "operator_status" | "turn_observe" | "mesh_record" | "turn_cancel" | "turn_query" | "mesh_index_query" | "mission_upsert" | "mission_query" | "note_upsert" | "note_forget" | "tool_call_record" | "ledger_query" | "mission_list_query" | "record_local" | "queue_query" | "queue_enqueue" | "queue_enqueue_batch" | "queue_cancel" | "queue_requeue" | "direct_dispatch_record" | "active_work_query" | "recovery_context_query" | "task_stats_query" | "orphaned_pin_notify";
99
+ export declare const isTurnIpcCommand: (value: unknown) => value is "prune_stale_direct" | "operator_status" | "turn_observe" | "mesh_record" | "turn_cancel" | "turn_query" | "mesh_index_query" | "mission_upsert" | "mission_query" | "note_upsert" | "note_forget" | "tool_call_record" | "ledger_query" | "mission_list_query" | "record_local" | "queue_query" | "queue_enqueue" | "queue_enqueue_batch" | "queue_cancel" | "queue_requeue" | "queue_revise" | "direct_dispatch_record" | "active_work_query" | "recovery_context_query" | "task_stats_query" | "orphaned_pin_notify";
@@ -30,7 +30,7 @@
30
30
  * the protocol contract the marker demarcates.
31
31
  */
32
32
  import { type MissionBrief } from './mission-brief';
33
- export declare const WORKER_TOOLS: readonly ["report_completion", "progress_update", "peer_context_pull", "git_status", "git_log", "git_diff"];
33
+ export declare const WORKER_TOOLS: readonly ["report_completion", "progress_update", "peer_context_pull", "git_status", "git_log", "git_diff", "driver_list", "driver_describe", "driver_invoke", "driver_scaffold", "driver_validate", "driver_export", "driver_install", "artifact_register", "artifact_list", "artifact_read", "contract_read", "contract_observe", "contract_current"];
34
34
  export type WorkerTool = typeof WORKER_TOOLS[number];
35
35
  export declare function isWorkerTool(value: unknown): value is WorkerTool;
36
36
  /** Stable marker line so a body is never footered twice and tests can find it. */
@@ -53,7 +53,45 @@ export interface WorkerProtocolFooterInput {
53
53
  * which is what every worker launched with the default gate receives.
54
54
  */
55
55
  workerMcp?: boolean;
56
+ /**
57
+ * Same-machine light task: the worker runs in a temporary light workspace.
58
+ * Renders the light-workspace rules (stay inside, commit there, no installs).
59
+ */
60
+ light?: {
61
+ workspace: string;
62
+ baseSha: string;
63
+ ossBaseSha?: string;
64
+ ownedPaths: string[];
65
+ };
66
+ /**
67
+ * Code-changing task on a shared (non-worktree) node checkout, not a light task: the worker commits on the
68
+ * branch that is currently checked out. Renders the "do not create or switch branches" rule.
69
+ */
70
+ commitOnCurrentBranch?: boolean;
71
+ /**
72
+ * Review-in-task (docs/design/2026-11-01-review-in-task.md §9.3): present when this
73
+ * dispatch is one stage of a stage pipeline. `workspace` is the reviewer's pinned
74
+ * workspace path when the daemon prepared one.
75
+ */
76
+ stage?: {
77
+ role: 'implement' | 'revise' | 'review';
78
+ round: number;
79
+ maxRevisions: number;
80
+ workspace?: string;
81
+ };
56
82
  }
83
+ /** Light-workspace worker rules (design §9). */
84
+ export declare function renderLightWorkspaceRules(light: NonNullable<WorkerProtocolFooterInput['light']>): string[];
85
+ /** Base-node code changes land on the branch the coordinator and review expect: the one already checked out. */
86
+ export declare const WORKER_CURRENT_BRANCH_RULE: string;
87
+ /**
88
+ * Shell-command style rule (every worker). Agent CLIs that pre-check shell commands before running them
89
+ * (for example a permission classifier that must prove every path a command reads) cannot analyse a path
90
+ * held in a shell variable, so such a command stops and asks the person — measured as a stream of
91
+ * approval prompts on delegated workers whose analysis scripts did `N=dir; cat $N/file`. Literal paths
92
+ * cost the worker nothing and keep each command checkable; the rule never widens what a worker may run.
93
+ */
94
+ export declare const WORKER_SHELL_LITERAL_PATHS_RULE: string;
57
95
  export declare function hasWorkerProtocolFooter(body: string): boolean;
58
96
  /**
59
97
  * The protocol block appended to a dispatched task. Written for the model that
@@ -61,6 +99,8 @@ export declare function hasWorkerProtocolFooter(body: string): boolean;
61
99
  * the worker does not go looking for coordinator tools.
62
100
  */
63
101
  export declare function renderWorkerProtocolFooter(input?: WorkerProtocolFooterInput): string;
102
+ /** The stage-pipeline paragraph of the worker footer (implement / revise / review). */
103
+ export declare function renderStageProtocolLines(stage: NonNullable<WorkerProtocolFooterInput['stage']>): string[];
64
104
  /**
65
105
  * The authored text of a dispatched body: everything before the footer marker.
66
106
  * Ledger descriptors, replay fixtures and tests compare authored text, never
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adhdev/mesh-shared",
3
- "version": "1.0.82-rc.12",
3
+ "version": "1.0.82-rc.120",
4
4
  "description": "ADHDev mesh-shared — pure mesh/git status normalizers shared by daemon-core and web-core",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",