@adhdev/mesh-shared 1.0.60-rc.4 → 1.0.60-rc.41

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 (39) hide show
  1. package/dist/index.d.ts +10 -0
  2. package/dist/index.js +2764 -17
  3. package/dist/index.js.map +1 -1
  4. package/dist/index.mjs +2441 -17
  5. package/dist/index.mjs.map +1 -1
  6. package/dist/mesh-tool-names.d.ts +2 -2
  7. package/dist/mesh-vocabulary.d.ts +70 -0
  8. package/dist/mission-brief.d.ts +62 -0
  9. package/dist/outbound-message.d.ts +202 -0
  10. package/dist/path-ownership.d.ts +101 -0
  11. package/dist/protocol/daemon-server.d.ts +388 -0
  12. package/dist/protocol/dashboard-daemon-p2p.d.ts +212 -0
  13. package/dist/protocol/dashboard-server.d.ts +240 -0
  14. package/dist/protocol/envelope.d.ts +55 -0
  15. package/dist/protocol/index.d.ts +15 -0
  16. package/dist/session-launch.d.ts +113 -0
  17. package/dist/session-status.d.ts +61 -0
  18. package/dist/turn-evidence.d.ts +407 -0
  19. package/dist/turn-ipc.d.ts +974 -0
  20. package/dist/worker-protocol.d.ts +69 -0
  21. package/dist/ws-protocol.d.ts +71 -41
  22. package/package.json +1 -1
  23. package/src/index.ts +10 -0
  24. package/src/mesh-tool-names.ts +0 -1
  25. package/src/mesh-vocabulary.ts +98 -0
  26. package/src/mission-brief.ts +153 -0
  27. package/src/outbound-message.ts +320 -0
  28. package/src/path-ownership.ts +271 -0
  29. package/src/protocol/daemon-server.ts +552 -0
  30. package/src/protocol/dashboard-daemon-p2p.ts +272 -0
  31. package/src/protocol/dashboard-server.ts +340 -0
  32. package/src/protocol/envelope.ts +75 -0
  33. package/src/protocol/index.ts +16 -0
  34. package/src/session-launch.ts +247 -0
  35. package/src/session-status.ts +140 -0
  36. package/src/turn-evidence.ts +562 -0
  37. package/src/turn-ipc.ts +2231 -0
  38. package/src/worker-protocol.ts +142 -0
  39. package/src/ws-protocol.ts +102 -93
@@ -0,0 +1,407 @@
1
+ /**
2
+ * turn-evidence — the ONE vocabulary for "what happened to a turn".
3
+ *
4
+ * Wiring-unification Phase C1 (docs/design/2026-09-23-wiring-unification.md §5).
5
+ *
6
+ * Every producer that today decides "done" on its own (completion flush, stall
7
+ * rescue, reconcile synthesis, MCP probes, worker report tools, …) instead
8
+ * submits one of these evidence records to the turn ledger, whose pure reducer
9
+ * is the only authority for a turn's state. Worker daemons and the MCP server
10
+ * build them, so the types live here (a dependency-free leaf).
11
+ *
12
+ * CONTENT-FREE BY CONSTRUCTION
13
+ * ----------------------------
14
+ * Evidence crosses machines (seqscribe `mesh.<id>.events` replication) and must
15
+ * never carry anything a user or an agent wrote. Every field is one of: an
16
+ * identifier, a closed enum, a boolean, a number, or a `SummaryRef` — a pointer
17
+ * `{topic, writer, seq}` to a content-class topic entry (`mesh.<id>.handoff`)
18
+ * where the text actually lives. `TURN_EVIDENCE_FIELD_SPECS` declares the class
19
+ * of every field of every member (the compiler forces it to stay total and
20
+ * exact), the runtime guard validates against it, and a test walks it to prove
21
+ * no free-text field exists.
22
+ */
23
+ import { type WorkerBranchState, type WorkerReportOutcome } from './mesh-vocabulary';
24
+ import { type SessionStatus } from './session-status';
25
+ import { type SendRefusal } from './outbound-message';
26
+ /** Protocol version stamped on every `mesh.<id>.events` entry written by the turn ledger. */
27
+ export declare const MESH_TOPIC_PROTOCOL_VERSION: 2;
28
+ export declare const EVIDENCE_SOURCE_IDS: readonly ["fsm_edge", "short_gen_inline", "completion_flush_genuine", "completion_flush_weak", "monitor_final_summary", "pre_cleanup_transcript", "stall_transcript", "startup_grace_collapse", "acp_prompt_response", "cdp_state", "approval_gate", "modal_button", "mesh_stall_watchdog", "status_monitor", "pty_exit", "provider_error", "coordinator_probe", "mcp_probe", "worker_tool", "dispatch", "input_service", "operator", "intentional_cleanup", "scheduler", "git_probe", "session_registry"];
29
+ export type EvidenceSourceId = typeof EVIDENCE_SOURCE_IDS[number];
30
+ export declare const TURN_SCOPES: readonly ["mesh_queue", "mesh_direct", "plain"];
31
+ export type TurnScope = typeof TURN_SCOPES[number];
32
+ /**
33
+ * Refusals (D1 `SendRefusal`, owned by ./outbound-message) that mean the target
34
+ * can never take this dispatch, so the attempt is reclaimed (R3). Every other
35
+ * refusal is retried by the sender and only recorded.
36
+ */
37
+ export declare const RECLAIMING_SEND_REFUSALS: readonly ["session_exited", "no_target", "unsupported_input"];
38
+ export type ReclaimingSendRefusal = typeof RECLAIMING_SEND_REFUSALS[number];
39
+ export declare const DELIVERY_OUTCOMES: readonly ["delivered", "queued"];
40
+ export type DeliveryOutcome = typeof DELIVERY_OUTCOMES[number];
41
+ export declare const DELIVERY_VIAS: readonly ["local", "p2p"];
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"];
44
+ export type DispatchFailureReason = typeof DISPATCH_FAILURE_REASONS[number];
45
+ export declare const CONSUME_PROFILES: readonly ["default", "native_source"];
46
+ export type ConsumeProfile = typeof CONSUME_PROFILES[number];
47
+ export declare const SESSION_REBOUND_REASONS: readonly ["restart", "live_holder"];
48
+ export type SessionReboundReason = typeof SESSION_REBOUND_REASONS[number];
49
+ export declare const SUSPENSION_MODALS: readonly ["approval", "choice"];
50
+ export type SuspensionModal = typeof SUSPENSION_MODALS[number];
51
+ export declare const SUSPENSION_RESOLUTIONS: readonly ["approved", "rejected", "answered"];
52
+ export type SuspensionResolution = typeof SUSPENSION_RESOLUTIONS[number];
53
+ export declare const SUSPENSION_RESOLUTION_VIAS: readonly ["modal_button", "auto_approve", "prompt_answer"];
54
+ export type SuspensionResolutionVia = typeof SUSPENSION_RESOLUTION_VIAS[number];
55
+ export declare const TURN_END_STRENGTHS: readonly ["genuine", "weak"];
56
+ export type TurnEndStrength = typeof TURN_END_STRENGTHS[number];
57
+ /** Why a provider-side weak end was released (was free text `blockReason`). */
58
+ export declare const TURN_END_BLOCK_REASONS: readonly ["missing_final_assistant", "finalization_timeout", "terminal_block_hard_cap", "decoupled_completion"];
59
+ export type TurnEndBlockReason = typeof TURN_END_BLOCK_REASONS[number];
60
+ export declare const NATIVE_TURN_OUTCOMES: readonly ["completed", "aborted"];
61
+ export type NativeTurnOutcome = typeof NATIVE_TURN_OUTCOMES[number];
62
+ export declare const LIVENESS_RESULTS: readonly ["alive", "unknown", "read_failed", "dead"];
63
+ export type LivenessResult = typeof LIVENESS_RESULTS[number];
64
+ export declare const PROVIDER_FAILURES: readonly ["auth_failed", "billing_failed"];
65
+ export type ProviderFailure = typeof PROVIDER_FAILURES[number];
66
+ /**
67
+ * `daemon_restart` (wiring-unification follow-up, design §5): a boot-time
68
+ * reconciliation observes this for a plain attempt whose session is gone
69
+ * after a restart — the daemon never saw the session's own exit, so it is
70
+ * not `provider_error`/`adapter_error`/etc.; it is the daemon itself
71
+ * reporting "this session no longer exists".
72
+ */
73
+ export declare const SESSION_ERROR_REASONS: readonly ["provider_error", "adapter_error", "spawn_failed", "auth_failed", "billing_failed", "unknown", "daemon_restart"];
74
+ export type SessionErrorReason = typeof SESSION_ERROR_REASONS[number];
75
+ export declare const CANCEL_REASONS: readonly ["operator_cancel", "intentional_cleanup", "task_removed", "mission_abandoned", "superseded"];
76
+ export type CancelReason = typeof CANCEL_REASONS[number];
77
+ export declare const OPERATOR_STATUSES: readonly ["completed", "failed"];
78
+ export type OperatorStatus = typeof OPERATOR_STATUSES[number];
79
+ export declare const OPERATOR_STATUS_REASONS: readonly ["operator_update", "refine_terminal", "validation_terminal"];
80
+ export type OperatorStatusReason = typeof OPERATOR_STATUS_REASONS[number];
81
+ export declare const COORDINATOR_ACK_OUTCOMES: readonly ["delivered", "queued", "duplicate"];
82
+ export type CoordinatorAckOutcome = typeof COORDINATOR_ACK_OUTCOMES[number];
83
+ /** Observed status as a no-progress monitor saw it (canonical session status or `unknown`). */
84
+ export declare const NO_PROGRESS_OBSERVED_STATUSES: readonly ["idle", "generating", "waiting_approval", "waiting_choice", "finalizing", "error", "stopped", "starting", "panel_hidden", "not_monitored", "disconnected", "unknown"];
85
+ export type NoProgressObservedStatus = SessionStatus | 'unknown';
86
+ /**
87
+ * Reasons a turn hold exists. Holds are attempt-scoped only (C2: delivery-side
88
+ * waits are consumer deferral on the `turn.deliver` cursor, not hold rows).
89
+ */
90
+ 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"];
91
+ export type HoldReason = typeof HOLD_REASONS[number];
92
+ export declare const TURN_OUTCOMES: readonly ["completed", "failed", "cancelled"];
93
+ export type TurnOutcome = typeof TURN_OUTCOMES[number];
94
+ export declare const COMMIT_STRENGTHS: readonly ["genuine", "weak", "tool_report", "operator"];
95
+ export type CommitStrength = typeof COMMIT_STRENGTHS[number];
96
+ /** Every terminal or reclaim reason the ledger writes. Closed: no free-text reasons. */
97
+ 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", "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"];
98
+ export type TurnReason = typeof TURN_REASONS[number];
99
+ /**
100
+ * What a `turn.notify` entry tells a coordinator.
101
+ *
102
+ * `late_completion` (C1 R27, owner revision 2026-09-23): a superseded
103
+ * generation finished while the current one was already running; the
104
+ * coordinator decides whether to salvage it (the entry carries the g−1
105
+ * summary as its append `ref`). `mesh_event`: a non-turn coordinator notice
106
+ * (refine terminal, worktree bootstrap, …) whose text lives only in the
107
+ * owner's local `turn_events.payload_json` and is rendered at deliver time.
108
+ */
109
+ export declare const NOTIFY_KINDS: readonly ["completed", "failed", "cancelled", "stopped", "approval", "choice", "approval_resolved", "candidate", "no_progress", "progress", "late_completion", "mesh_event"];
110
+ export type NotifyKind = typeof NOTIFY_KINDS[number];
111
+ export interface TurnAttemptRef {
112
+ attemptId: string;
113
+ generation: number;
114
+ }
115
+ /**
116
+ * Pointer to text that lives in a content-class topic entry (`mesh.<id>.handoff`).
117
+ * Text never travels inside evidence; the deliver side renders it from the ref.
118
+ */
119
+ export interface SummaryRef {
120
+ topic: string;
121
+ writer: string;
122
+ seq: number;
123
+ }
124
+ /** Live-state observations that make a transcript end premature (admission input). */
125
+ export interface LiveTurnPending {
126
+ modal: boolean;
127
+ adapterPending: boolean;
128
+ trailingTool: boolean;
129
+ newestActivityAt?: number;
130
+ }
131
+ /** Structural copy of daemon-core's `CoordinatorIdentity` (this package cannot import daemon-core). */
132
+ export interface EvidenceCoordinatorIdentity {
133
+ daemonId: string;
134
+ coordinatorRunId: string;
135
+ sessionId?: string;
136
+ }
137
+ export interface NativeTurnMarkerRef {
138
+ outcome: NativeTurnOutcome;
139
+ turnId?: string;
140
+ }
141
+ export interface EvidenceEnvelope {
142
+ /** Stable id of this observation; dedupe key across republish/replication. */
143
+ eventId: string;
144
+ /** Producer clock, epoch ms. */
145
+ at: number;
146
+ source: EvidenceSourceId;
147
+ /** The session that produced / is the subject of the observation. */
148
+ sessionId: string;
149
+ attemptRef?: TurnAttemptRef;
150
+ /** Only when attemptRef is absent (legacy relay / MCP probe). */
151
+ taskId?: string;
152
+ /** Daemon id that observed it. */
153
+ observedBy: string;
154
+ }
155
+ /** Kind-specific bodies. `TurnEvidence = EvidenceEnvelope & TurnEvidenceBody`. */
156
+ export type TurnEvidenceBody = {
157
+ kind: 'dispatch_accepted';
158
+ scope: TurnScope;
159
+ messageId: string;
160
+ meshId?: string;
161
+ nodeId?: string;
162
+ providerType?: string;
163
+ attemptNo?: number;
164
+ dispatchNonce?: number;
165
+ consumeProfile?: ConsumeProfile;
166
+ maxTaskRetries?: number;
167
+ coordinator?: EvidenceCoordinatorIdentity;
168
+ } | {
169
+ kind: 'delivered';
170
+ messageId: string;
171
+ outcome: DeliveryOutcome;
172
+ via: DeliveryVia;
173
+ } | {
174
+ kind: 'delivery_refused';
175
+ messageId: string;
176
+ reason: SendRefusal;
177
+ } | {
178
+ kind: 'dispatch_failed';
179
+ workerAbsent: boolean;
180
+ reason: DispatchFailureReason;
181
+ } | {
182
+ kind: 'duplicate_dispatch_refusal';
183
+ holderSessionId: string;
184
+ holderAttemptId?: string;
185
+ } | {
186
+ kind: 'session_rebound';
187
+ toSessionId: string;
188
+ reason: SessionReboundReason;
189
+ } | {
190
+ kind: 'turn_started';
191
+ retro: boolean;
192
+ } | {
193
+ kind: 'suspension';
194
+ modal: SuspensionModal;
195
+ modalKey?: string;
196
+ } | {
197
+ kind: 'suspension_resolved';
198
+ resolution: SuspensionResolution;
199
+ via: SuspensionResolutionVia;
200
+ } | {
201
+ kind: 'turn_end';
202
+ strength: TurnEndStrength;
203
+ afterFinalizationTimeout?: boolean;
204
+ hollow?: boolean;
205
+ summary?: SummaryRef;
206
+ blockReason?: TurnEndBlockReason;
207
+ releasedByHardCap?: boolean;
208
+ nativeOutcome?: NativeTurnOutcome;
209
+ live?: LiveTurnPending;
210
+ /**
211
+ * Stamped (true only) by the WORKER's daemon when the session holds a live
212
+ * worker-MCP session bind, i.e. the worker can call report_completion. The
213
+ * owner then treats a genuine end as a report-awaiting candidate (R9r), not
214
+ * a commit. Absent = no reporting surface = today's genuine-end commit.
215
+ */
216
+ reportExpected?: boolean;
217
+ } | {
218
+ kind: 'transcript_final';
219
+ selfAttributing: boolean;
220
+ nativeRead: boolean;
221
+ nativeMarker?: NativeTurnMarkerRef;
222
+ live: LiveTurnPending;
223
+ summary?: SummaryRef;
224
+ messageAt?: number;
225
+ } | {
226
+ kind: 'transcript_activity';
227
+ newestActivityAt: number;
228
+ } | {
229
+ kind: 'no_progress';
230
+ stalledMs: number;
231
+ observedStatus: NoProgressObservedStatus;
232
+ finalAssistantPresent: boolean;
233
+ } | {
234
+ kind: 'liveness';
235
+ result: LivenessResult;
236
+ } | {
237
+ kind: 'process_exit';
238
+ exitCode: number | null;
239
+ providerFailure?: ProviderFailure;
240
+ } | {
241
+ kind: 'session_error';
242
+ reason: SessionErrorReason;
243
+ } | {
244
+ kind: 'worker_report';
245
+ outcome: WorkerReportOutcome;
246
+ summary: SummaryRef;
247
+ hasHandoffNotes: boolean;
248
+ branchState?: WorkerBranchState;
249
+ touchedFileCount?: number;
250
+ } | {
251
+ kind: 'worker_progress';
252
+ note?: SummaryRef;
253
+ } | {
254
+ kind: 'git_side_effect';
255
+ dirty: boolean;
256
+ commitsSinceDispatch: number;
257
+ attributable: boolean;
258
+ } | {
259
+ kind: 'cancel';
260
+ reason: CancelReason;
261
+ } | {
262
+ kind: 'operator_status';
263
+ status: OperatorStatus;
264
+ reason: OperatorStatusReason;
265
+ } | {
266
+ kind: 'coordinator_ack';
267
+ notify: NotifyKind;
268
+ outcome: CoordinatorAckOutcome;
269
+ } | {
270
+ kind: 'hold_expired';
271
+ holdId: string;
272
+ reason: HoldReason;
273
+ };
274
+ export type TurnEvidence = EvidenceEnvelope & TurnEvidenceBody;
275
+ export type TurnEvidenceKind = TurnEvidenceBody['kind'];
276
+ export type TurnEvidenceOf<K extends TurnEvidenceKind> = EvidenceEnvelope & Extract<TurnEvidenceBody, {
277
+ kind: K;
278
+ }>;
279
+ /**
280
+ * The class of every declared field. There is deliberately NO free-text class:
281
+ * `id` strings are length-bounded and whitespace-free, so prose cannot be
282
+ * smuggled through an identifier slot either.
283
+ */
284
+ export type EvidenceFieldSpec = {
285
+ t: 'id';
286
+ optional?: true;
287
+ } | {
288
+ t: 'enum';
289
+ values: readonly string[];
290
+ optional?: true;
291
+ } | {
292
+ t: 'bool';
293
+ optional?: true;
294
+ } | {
295
+ t: 'int';
296
+ optional?: true;
297
+ nullable?: true;
298
+ } | {
299
+ t: 'ms';
300
+ optional?: true;
301
+ } | {
302
+ t: 'summary_ref';
303
+ optional?: true;
304
+ } | {
305
+ t: 'attempt_ref';
306
+ optional?: true;
307
+ } | {
308
+ t: 'live';
309
+ optional?: true;
310
+ } | {
311
+ t: 'native_marker';
312
+ optional?: true;
313
+ } | {
314
+ t: 'coordinator';
315
+ optional?: true;
316
+ };
317
+ type FieldsOf<K extends TurnEvidenceKind> = Exclude<keyof Extract<TurnEvidenceBody, {
318
+ kind: K;
319
+ }>, 'kind'>;
320
+ /** Exact per-kind registry: a missing or extra field fails to compile. */
321
+ export type TurnEvidenceFieldSpecs = {
322
+ readonly [K in TurnEvidenceKind]: {
323
+ readonly [F in FieldsOf<K>]-?: EvidenceFieldSpec;
324
+ };
325
+ };
326
+ export declare const EVIDENCE_ENVELOPE_FIELD_SPECS: {
327
+ readonly [F in keyof EvidenceEnvelope]-?: EvidenceFieldSpec;
328
+ };
329
+ export declare const TURN_EVIDENCE_FIELD_SPECS: TurnEvidenceFieldSpecs;
330
+ export declare const TURN_EVIDENCE_KINDS: readonly TurnEvidenceKind[];
331
+ /** Evidence kinds that, on their own, can end a turn (the ones R18/R19/R27 reason about). */
332
+ export declare const TERMINAL_CLASS_EVIDENCE_KINDS: readonly ["turn_end", "transcript_final", "no_progress", "worker_report", "session_error", "process_exit", "cancel", "operator_status"];
333
+ export declare const isEvidenceSourceId: (value: unknown) => value is "fsm_edge" | "short_gen_inline" | "completion_flush_genuine" | "completion_flush_weak" | "monitor_final_summary" | "pre_cleanup_transcript" | "stall_transcript" | "startup_grace_collapse" | "acp_prompt_response" | "cdp_state" | "approval_gate" | "modal_button" | "mesh_stall_watchdog" | "status_monitor" | "pty_exit" | "provider_error" | "coordinator_probe" | "mcp_probe" | "worker_tool" | "dispatch" | "input_service" | "operator" | "intentional_cleanup" | "scheduler" | "git_probe" | "session_registry";
334
+ 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";
335
+ export declare const isTurnReason: (value: unknown) => value is "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" | "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";
336
+ export declare const isNotifyKind: (value: unknown) => value is "stopped" | "failed" | "no_progress" | "completed" | "cancelled" | "approval" | "choice" | "approval_resolved" | "candidate" | "progress" | "late_completion" | "mesh_event";
337
+ export declare const isHoldReason: (value: unknown) => value is "await_delivery" | "await_consume" | "await_turn" | "liveness" | "hard_ceiling" | "live_pending" | "transcript_quiet" | "weak_candidate" | "suspension_before_consumed" | "await_report";
338
+ export declare const isTurnOutcome: (value: unknown) => value is "failed" | "completed" | "cancelled";
339
+ export declare const isCommitStrength: (value: unknown) => value is "operator" | "genuine" | "weak" | "tool_report";
340
+ export declare function isEvidenceIdentifier(value: unknown): value is string;
341
+ export declare function isSummaryRef(value: unknown): value is SummaryRef;
342
+ export declare function isTurnAttemptRef(value: unknown): value is TurnAttemptRef;
343
+ /**
344
+ * Strict structural guard: known kind, every declared field of the right class,
345
+ * and NO undeclared field (an unknown key is how free text would sneak in).
346
+ */
347
+ export declare function isTurnEvidence(value: unknown): value is TurnEvidence;
348
+ export declare function isTerminalClassEvidenceKind(kind: TurnEvidenceKind): kind is typeof TERMINAL_CLASS_EVIDENCE_KINDS[number];
349
+ export declare const TURN_EVIDENCE_FLAGS: readonly ["hollow", "afterFinalizationTimeout", "nativeMarker", "selfAttributing"];
350
+ export type TurnEvidenceFlag = typeof TURN_EVIDENCE_FLAGS[number];
351
+ /** Scalar-only payload for `mesh.record` (the existing allow-list projection's output). */
352
+ export type ProjectedScalars = Readonly<Record<string, string | number | boolean | null>>;
353
+ export declare const MESH_TOPIC_ENTRY_KINDS: readonly ["turn.evidence", "turn.committed", "turn.notify", "mesh.record"];
354
+ export type MeshTopicEntryKind = typeof MESH_TOPIC_ENTRY_KINDS[number];
355
+ export type MeshTopicEntry = {
356
+ v: typeof MESH_TOPIC_PROTOCOL_VERSION;
357
+ eventId: string;
358
+ at: number;
359
+ } & ({
360
+ k: 'turn.evidence';
361
+ attemptId: string;
362
+ generation: number;
363
+ ownerDaemonId: string;
364
+ taskId?: string;
365
+ sessionId: string;
366
+ ev: TurnEvidenceKind;
367
+ strength?: TurnEndStrength;
368
+ flags?: Partial<Record<TurnEvidenceFlag, boolean>>;
369
+ /** The full (content-free) evidence, so a foreign `turn.ingest` can re-observe it losslessly. */
370
+ evidence?: TurnEvidence;
371
+ } | {
372
+ k: 'turn.committed';
373
+ attemptId: string;
374
+ generation: number;
375
+ taskId?: string;
376
+ outcome: TurnOutcome;
377
+ strength: CommitStrength;
378
+ reason: TurnReason;
379
+ } | {
380
+ k: 'turn.notify';
381
+ attemptId?: string;
382
+ notify: NotifyKind;
383
+ targetDaemonId: string;
384
+ targetSessionId?: string;
385
+ taskId?: string;
386
+ } | {
387
+ k: 'mesh.record';
388
+ ledgerKind: string;
389
+ nodeId?: string;
390
+ sessionId?: string;
391
+ taskId?: string;
392
+ payload: ProjectedScalars;
393
+ });
394
+ export declare const isMeshTopicEntryKind: (value: unknown) => value is "turn.evidence" | "turn.committed" | "turn.notify" | "mesh.record";
395
+ export declare function isMeshTopicEntry(value: unknown): value is MeshTopicEntry;
396
+ /**
397
+ * Project evidence onto its `turn.evidence` topic entry. Pure; the attempt
398
+ * identity comes from the resolved attempt (the evidence may lack attemptRef).
399
+ */
400
+ export declare function projectTurnEvidenceEntry(evidence: TurnEvidence, attempt: {
401
+ attemptId: string;
402
+ generation: number;
403
+ ownerDaemonId: string;
404
+ }): Extract<MeshTopicEntry, {
405
+ k: 'turn.evidence';
406
+ }>;
407
+ export {};