@fuxi-ailabs/crowdmemory-codex-plugin 0.0.0-stage → 0.1.1

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.
@@ -0,0 +1,2521 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://crowdmemory.local/schemas/agent/memory-agent-ingress-v1.schema.json",
4
+ "title": "memory-agent-ingress/v1 canonical event envelope",
5
+ "description": "Request body of POST /v1/agent-ingress/{adapter_id}/events/{kind}. Closed: unknown kinds and unknown fields are rejected before dispatch (spec FR-01). Responses are {ok:true,result} or {ok:false,error}; see x-results and $defs/response_<kind>. Idempotency: the same event_id with an identical body returns the original result; with a different body it is rejected with idempotency_conflict.",
6
+ "x-contract-id": "memory-agent-ingress/v1",
7
+ "x-protocol-major": 1,
8
+ "x-route": "/v1/agent-ingress/{adapter_id}/events/{kind}",
9
+ "x-l0-kinds": [
10
+ "session.start",
11
+ "step.before",
12
+ "tool.result",
13
+ "context.compaction",
14
+ "subagent.end",
15
+ "note",
16
+ "query",
17
+ "session.end"
18
+ ],
19
+ "x-capability-disabled-kinds": [
20
+ "workflow.start",
21
+ "workflow.phase",
22
+ "workflow.agent.start",
23
+ "workflow.agent.end",
24
+ "workflow.end",
25
+ "goal.changed"
26
+ ],
27
+ "x-error-codes": [
28
+ "bad_request",
29
+ "unknown_kind",
30
+ "schema_invalid",
31
+ "unauthorized",
32
+ "session_unbound",
33
+ "idempotency_conflict",
34
+ "capability_disabled",
35
+ "not_found",
36
+ "budget_exhausted",
37
+ "note_rejected",
38
+ "unavailable",
39
+ "internal"
40
+ ],
41
+ "x-payloads": {
42
+ "session.start": "#/$defs/payload_session_start",
43
+ "step.before": "#/$defs/payload_step_before",
44
+ "tool.result": "#/$defs/payload_tool_result",
45
+ "context.compaction": "#/$defs/payload_context_compaction",
46
+ "subagent.end": "#/$defs/payload_subagent_end",
47
+ "note": "#/$defs/payload_note",
48
+ "query": "#/$defs/payload_query",
49
+ "workflow.start": "#/$defs/payload_workflow_start",
50
+ "workflow.phase": "#/$defs/payload_workflow_phase",
51
+ "workflow.agent.start": "#/$defs/payload_workflow_agent_start",
52
+ "workflow.agent.end": "#/$defs/payload_workflow_agent_end",
53
+ "workflow.end": "#/$defs/payload_workflow_end",
54
+ "goal.changed": "#/$defs/payload_goal_changed",
55
+ "session.end": "#/$defs/payload_session_end"
56
+ },
57
+ "x-results": {
58
+ "session.start": "#/$defs/result_session_start",
59
+ "step.before": "#/$defs/result_step_before",
60
+ "tool.result": "#/$defs/result_tool_result",
61
+ "context.compaction": "#/$defs/result_ack",
62
+ "subagent.end": "#/$defs/result_ack",
63
+ "note": "#/$defs/result_note",
64
+ "query": "#/$defs/result_query",
65
+ "workflow.start": "#/$defs/result_ack",
66
+ "workflow.phase": "#/$defs/result_workflow_phase",
67
+ "workflow.agent.start": "#/$defs/result_ack",
68
+ "workflow.agent.end": "#/$defs/result_ack",
69
+ "workflow.end": "#/$defs/result_ack",
70
+ "goal.changed": "#/$defs/result_ack",
71
+ "session.end": "#/$defs/result_session_end"
72
+ },
73
+ "x-responses": {
74
+ "session.start": "#/$defs/response_session_start",
75
+ "step.before": "#/$defs/response_step_before",
76
+ "tool.result": "#/$defs/response_tool_result",
77
+ "context.compaction": "#/$defs/response_context_compaction",
78
+ "subagent.end": "#/$defs/response_subagent_end",
79
+ "note": "#/$defs/response_note",
80
+ "query": "#/$defs/response_query",
81
+ "workflow.start": "#/$defs/response_workflow_start",
82
+ "workflow.phase": "#/$defs/response_workflow_phase",
83
+ "workflow.agent.start": "#/$defs/response_workflow_agent_start",
84
+ "workflow.agent.end": "#/$defs/response_workflow_agent_end",
85
+ "workflow.end": "#/$defs/response_workflow_end",
86
+ "goal.changed": "#/$defs/response_goal_changed",
87
+ "session.end": "#/$defs/response_session_end"
88
+ },
89
+ "type": "object",
90
+ "additionalProperties": false,
91
+ "required": [
92
+ "adapter_id",
93
+ "event_id",
94
+ "session_ref",
95
+ "occurred_at",
96
+ "kind",
97
+ "payload"
98
+ ],
99
+ "properties": {
100
+ "adapter_id": {
101
+ "$ref": "#/$defs/adapter_id"
102
+ },
103
+ "event_id": {
104
+ "$ref": "#/$defs/digest"
105
+ },
106
+ "session_ref": {
107
+ "$ref": "#/$defs/ref"
108
+ },
109
+ "parent_ref": {
110
+ "anyOf": [
111
+ {
112
+ "$ref": "#/$defs/ref"
113
+ },
114
+ {
115
+ "type": "null"
116
+ }
117
+ ]
118
+ },
119
+ "occurred_at": {
120
+ "$ref": "#/$defs/timestamp"
121
+ },
122
+ "kind": {
123
+ "enum": [
124
+ "session.start",
125
+ "step.before",
126
+ "tool.result",
127
+ "context.compaction",
128
+ "subagent.end",
129
+ "note",
130
+ "query",
131
+ "workflow.start",
132
+ "workflow.phase",
133
+ "workflow.agent.start",
134
+ "workflow.agent.end",
135
+ "workflow.end",
136
+ "goal.changed",
137
+ "session.end"
138
+ ]
139
+ },
140
+ "payload": {
141
+ "type": "object"
142
+ }
143
+ },
144
+ "allOf": [
145
+ {
146
+ "if": {
147
+ "properties": {
148
+ "kind": {
149
+ "const": "session.start"
150
+ }
151
+ },
152
+ "required": [
153
+ "kind"
154
+ ]
155
+ },
156
+ "then": {
157
+ "properties": {
158
+ "payload": {
159
+ "$ref": "#/$defs/payload_session_start"
160
+ }
161
+ }
162
+ }
163
+ },
164
+ {
165
+ "if": {
166
+ "properties": {
167
+ "kind": {
168
+ "const": "step.before"
169
+ }
170
+ },
171
+ "required": [
172
+ "kind"
173
+ ]
174
+ },
175
+ "then": {
176
+ "properties": {
177
+ "payload": {
178
+ "$ref": "#/$defs/payload_step_before"
179
+ }
180
+ }
181
+ }
182
+ },
183
+ {
184
+ "if": {
185
+ "properties": {
186
+ "kind": {
187
+ "const": "tool.result"
188
+ }
189
+ },
190
+ "required": [
191
+ "kind"
192
+ ]
193
+ },
194
+ "then": {
195
+ "properties": {
196
+ "payload": {
197
+ "$ref": "#/$defs/payload_tool_result"
198
+ }
199
+ }
200
+ }
201
+ },
202
+ {
203
+ "if": {
204
+ "properties": {
205
+ "kind": {
206
+ "const": "context.compaction"
207
+ }
208
+ },
209
+ "required": [
210
+ "kind"
211
+ ]
212
+ },
213
+ "then": {
214
+ "properties": {
215
+ "payload": {
216
+ "$ref": "#/$defs/payload_context_compaction"
217
+ }
218
+ }
219
+ }
220
+ },
221
+ {
222
+ "if": {
223
+ "properties": {
224
+ "kind": {
225
+ "const": "subagent.end"
226
+ }
227
+ },
228
+ "required": [
229
+ "kind"
230
+ ]
231
+ },
232
+ "then": {
233
+ "properties": {
234
+ "payload": {
235
+ "$ref": "#/$defs/payload_subagent_end"
236
+ }
237
+ }
238
+ }
239
+ },
240
+ {
241
+ "if": {
242
+ "properties": {
243
+ "kind": {
244
+ "const": "note"
245
+ }
246
+ },
247
+ "required": [
248
+ "kind"
249
+ ]
250
+ },
251
+ "then": {
252
+ "properties": {
253
+ "payload": {
254
+ "$ref": "#/$defs/payload_note"
255
+ }
256
+ }
257
+ }
258
+ },
259
+ {
260
+ "if": {
261
+ "properties": {
262
+ "kind": {
263
+ "const": "query"
264
+ }
265
+ },
266
+ "required": [
267
+ "kind"
268
+ ]
269
+ },
270
+ "then": {
271
+ "properties": {
272
+ "payload": {
273
+ "$ref": "#/$defs/payload_query"
274
+ }
275
+ }
276
+ }
277
+ },
278
+ {
279
+ "if": {
280
+ "properties": {
281
+ "kind": {
282
+ "const": "workflow.start"
283
+ }
284
+ },
285
+ "required": [
286
+ "kind"
287
+ ]
288
+ },
289
+ "then": {
290
+ "properties": {
291
+ "payload": {
292
+ "$ref": "#/$defs/payload_workflow_start"
293
+ }
294
+ }
295
+ }
296
+ },
297
+ {
298
+ "if": {
299
+ "properties": {
300
+ "kind": {
301
+ "const": "workflow.phase"
302
+ }
303
+ },
304
+ "required": [
305
+ "kind"
306
+ ]
307
+ },
308
+ "then": {
309
+ "properties": {
310
+ "payload": {
311
+ "$ref": "#/$defs/payload_workflow_phase"
312
+ }
313
+ }
314
+ }
315
+ },
316
+ {
317
+ "if": {
318
+ "properties": {
319
+ "kind": {
320
+ "const": "workflow.agent.start"
321
+ }
322
+ },
323
+ "required": [
324
+ "kind"
325
+ ]
326
+ },
327
+ "then": {
328
+ "properties": {
329
+ "payload": {
330
+ "$ref": "#/$defs/payload_workflow_agent_start"
331
+ }
332
+ }
333
+ }
334
+ },
335
+ {
336
+ "if": {
337
+ "properties": {
338
+ "kind": {
339
+ "const": "workflow.agent.end"
340
+ }
341
+ },
342
+ "required": [
343
+ "kind"
344
+ ]
345
+ },
346
+ "then": {
347
+ "properties": {
348
+ "payload": {
349
+ "$ref": "#/$defs/payload_workflow_agent_end"
350
+ }
351
+ }
352
+ }
353
+ },
354
+ {
355
+ "if": {
356
+ "properties": {
357
+ "kind": {
358
+ "const": "workflow.end"
359
+ }
360
+ },
361
+ "required": [
362
+ "kind"
363
+ ]
364
+ },
365
+ "then": {
366
+ "properties": {
367
+ "payload": {
368
+ "$ref": "#/$defs/payload_workflow_end"
369
+ }
370
+ }
371
+ }
372
+ },
373
+ {
374
+ "if": {
375
+ "properties": {
376
+ "kind": {
377
+ "const": "goal.changed"
378
+ }
379
+ },
380
+ "required": [
381
+ "kind"
382
+ ]
383
+ },
384
+ "then": {
385
+ "properties": {
386
+ "payload": {
387
+ "$ref": "#/$defs/payload_goal_changed"
388
+ }
389
+ }
390
+ }
391
+ },
392
+ {
393
+ "if": {
394
+ "properties": {
395
+ "kind": {
396
+ "const": "session.end"
397
+ }
398
+ },
399
+ "required": [
400
+ "kind"
401
+ ]
402
+ },
403
+ "then": {
404
+ "properties": {
405
+ "payload": {
406
+ "$ref": "#/$defs/payload_session_end"
407
+ }
408
+ }
409
+ }
410
+ }
411
+ ],
412
+ "$defs": {
413
+ "digest": {
414
+ "type": "string",
415
+ "pattern": "^sha256:[0-9a-f]{64}$"
416
+ },
417
+ "adapter_id": {
418
+ "type": "string",
419
+ "pattern": "^[a-z][a-z0-9_-]{0,63}$"
420
+ },
421
+ "ref": {
422
+ "type": "string",
423
+ "minLength": 1,
424
+ "maxLength": 256,
425
+ "description": "Opaque runtime-side reference (session_ref, child_ref, run_ref…)."
426
+ },
427
+ "session_handle": {
428
+ "type": "string",
429
+ "pattern": "^[A-Za-z0-9_-]{1,128}$",
430
+ "description": "Issued by the Runtime in the session.start result; every later payload carries it."
431
+ },
432
+ "record_ref": {
433
+ "type": "string",
434
+ "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,127}$",
435
+ "description": "Memory record reference (Release rr_… or local lr_…); opaque to adapters."
436
+ },
437
+ "timestamp": {
438
+ "type": "string",
439
+ "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(\\.[0-9]{1,9})?(Z|[+-][0-9]{2}:[0-9]{2})$"
440
+ },
441
+ "trust": {
442
+ "enum": [
443
+ "raw",
444
+ "local_auto",
445
+ "reviewed",
446
+ "verified"
447
+ ]
448
+ },
449
+ "outcome": {
450
+ "enum": [
451
+ "pass",
452
+ "conditional_pass",
453
+ "fail",
454
+ "blocked",
455
+ "interrupted",
456
+ "unknown"
457
+ ]
458
+ },
459
+ "signal_name": {
460
+ "enum": [
461
+ "error_signature",
462
+ "code_symbol",
463
+ "tool_name",
464
+ "lexical",
465
+ "same_project",
466
+ "environment",
467
+ "evidence",
468
+ "recency",
469
+ "trust",
470
+ "negative",
471
+ "phase",
472
+ "dimension"
473
+ ],
474
+ "description": "Relevance signals (spec FR-12, FR-22, FR-38); same set as memory-profile/v1 signals. dimension: a soft template dimension matched (value name=value)."
475
+ },
476
+ "push_trigger": {
477
+ "enum": [
478
+ "session_start",
479
+ "after_failure",
480
+ "phase_start"
481
+ ]
482
+ },
483
+ "capability": {
484
+ "enum": [
485
+ "session_binding",
486
+ "step_injection",
487
+ "tool_capture",
488
+ "compaction_capture",
489
+ "subagent_capture",
490
+ "workflow_events",
491
+ "goal_events",
492
+ "note_tool",
493
+ "query_tools",
494
+ "workspace_snapshot"
495
+ ]
496
+ },
497
+ "phase_name": {
498
+ "type": "string",
499
+ "minLength": 1,
500
+ "maxLength": 128
501
+ },
502
+ "match_reason": {
503
+ "type": "object",
504
+ "additionalProperties": false,
505
+ "required": [
506
+ "signal",
507
+ "value",
508
+ "contribution"
509
+ ],
510
+ "properties": {
511
+ "signal": {
512
+ "$ref": "#/$defs/signal_name"
513
+ },
514
+ "value": {
515
+ "type": "string",
516
+ "maxLength": 512,
517
+ "description": "The concrete value that matched (signature, symbol, term, project…)."
518
+ },
519
+ "contribution": {
520
+ "type": "number",
521
+ "description": "weight × normalized signal; negative for negative signals."
522
+ }
523
+ },
524
+ "description": "One entry of the match reasons (FR-13)."
525
+ },
526
+ "hit": {
527
+ "type": "object",
528
+ "additionalProperties": false,
529
+ "required": [
530
+ "record_ref",
531
+ "title",
532
+ "trust",
533
+ "provenance_label",
534
+ "score",
535
+ "reasons"
536
+ ],
537
+ "properties": {
538
+ "record_ref": {
539
+ "$ref": "#/$defs/record_ref"
540
+ },
541
+ "title": {
542
+ "type": "string",
543
+ "minLength": 1,
544
+ "maxLength": 512
545
+ },
546
+ "trust": {
547
+ "$ref": "#/$defs/trust"
548
+ },
549
+ "provenance_label": {
550
+ "type": "string",
551
+ "minLength": 1,
552
+ "maxLength": 512,
553
+ "description": "Agent-facing source text, e.g. 「本机自动确认 · <项目> · <日期> · 记录时会话结局:<结局>」 (FR-10③)."
554
+ },
555
+ "score": {
556
+ "type": "number"
557
+ },
558
+ "reasons": {
559
+ "type": "array",
560
+ "maxItems": 32,
561
+ "items": {
562
+ "$ref": "#/$defs/match_reason"
563
+ }
564
+ },
565
+ "summary": {
566
+ "type": "string",
567
+ "maxLength": 4000,
568
+ "description": "First-paragraph summary (FR-16①)."
569
+ },
570
+ "excerpt": {
571
+ "type": "string",
572
+ "maxLength": 4000
573
+ },
574
+ "marks": {
575
+ "type": "array",
576
+ "maxItems": 16,
577
+ "uniqueItems": true,
578
+ "items": {
579
+ "enum": [
580
+ "task_failed",
581
+ "contradicted",
582
+ "superseded",
583
+ "used_then_passed"
584
+ ]
585
+ }
586
+ }
587
+ },
588
+ "description": "A ranked candidate as returned to adapters (inject hits, search hits, note similar[])."
589
+ },
590
+ "inject": {
591
+ "type": "object",
592
+ "additionalProperties": false,
593
+ "required": [
594
+ "text",
595
+ "record_refs",
596
+ "hits"
597
+ ],
598
+ "properties": {
599
+ "text": {
600
+ "type": "string",
601
+ "minLength": 1,
602
+ "maxLength": 65536,
603
+ "description": "Ready-to-fold text for the next model request (DSH plugin message, form=recall)."
604
+ },
605
+ "record_refs": {
606
+ "type": "array",
607
+ "minItems": 1,
608
+ "maxItems": 16,
609
+ "uniqueItems": true,
610
+ "items": {
611
+ "$ref": "#/$defs/record_ref"
612
+ }
613
+ },
614
+ "hits": {
615
+ "type": "array",
616
+ "maxItems": 16,
617
+ "items": {
618
+ "$ref": "#/$defs/hit"
619
+ }
620
+ },
621
+ "trigger": {
622
+ "$ref": "#/$defs/push_trigger"
623
+ }
624
+ },
625
+ "description": "Push injection (COLLAB §3.2)."
626
+ },
627
+ "environment": {
628
+ "type": "object",
629
+ "additionalProperties": false,
630
+ "required": [],
631
+ "properties": {
632
+ "os": {
633
+ "type": "string",
634
+ "minLength": 1,
635
+ "maxLength": 64
636
+ },
637
+ "arch": {
638
+ "type": "string",
639
+ "minLength": 1,
640
+ "maxLength": 64
641
+ },
642
+ "language": {
643
+ "type": "array",
644
+ "maxItems": 16,
645
+ "uniqueItems": true,
646
+ "items": {
647
+ "type": "string",
648
+ "minLength": 1,
649
+ "maxLength": 64
650
+ }
651
+ }
652
+ },
653
+ "description": "Soft environment facts for the environment signal."
654
+ },
655
+ "dimensions": {
656
+ "type": "object",
657
+ "maxProperties": 32,
658
+ "patternProperties": {
659
+ "^[a-z][a-z0-9_]{0,63}$": {
660
+ "oneOf": [
661
+ {
662
+ "type": "string",
663
+ "minLength": 1,
664
+ "maxLength": 256
665
+ },
666
+ {
667
+ "type": "array",
668
+ "minItems": 1,
669
+ "maxItems": 32,
670
+ "uniqueItems": true,
671
+ "items": {
672
+ "type": "string",
673
+ "minLength": 1,
674
+ "maxLength": 256
675
+ }
676
+ }
677
+ ]
678
+ }
679
+ },
680
+ "additionalProperties": false,
681
+ "description": "Task dimension values reported by the integrator (FR-38 ②, plan §13.2): name -> string (kind exact) or string list (kind set). Names follow memory-profile/v1 dimension.name; the Runtime rejects names the effective template does not declare (schema_invalid). Stored with the task; notes recorded in it inherit them."
682
+ },
683
+ "query_facts": {
684
+ "type": "object",
685
+ "additionalProperties": false,
686
+ "required": [],
687
+ "properties": {
688
+ "tool_name": {
689
+ "type": "string",
690
+ "minLength": 1,
691
+ "maxLength": 128
692
+ },
693
+ "error_signature": {
694
+ "$ref": "#/$defs/digest"
695
+ },
696
+ "error_tail": {
697
+ "type": "string",
698
+ "maxLength": 4096
699
+ },
700
+ "symbols": {
701
+ "type": "array",
702
+ "maxItems": 32,
703
+ "items": {
704
+ "type": "string",
705
+ "minLength": 1,
706
+ "maxLength": 256
707
+ }
708
+ },
709
+ "files": {
710
+ "type": "array",
711
+ "maxItems": 32,
712
+ "items": {
713
+ "type": "string",
714
+ "minLength": 1,
715
+ "maxLength": 1024
716
+ }
717
+ }
718
+ },
719
+ "description": "Structured query facts (mode A, FR-14)."
720
+ },
721
+ "payload_query_search": {
722
+ "type": "object",
723
+ "additionalProperties": false,
724
+ "required": [
725
+ "session_handle",
726
+ "op",
727
+ "query"
728
+ ],
729
+ "properties": {
730
+ "session_handle": {
731
+ "$ref": "#/$defs/session_handle"
732
+ },
733
+ "op": {
734
+ "const": "search"
735
+ },
736
+ "query": {
737
+ "type": "string",
738
+ "minLength": 1,
739
+ "maxLength": 2000
740
+ },
741
+ "limit": {
742
+ "type": "integer",
743
+ "minimum": 1,
744
+ "maximum": 5
745
+ },
746
+ "phase": {
747
+ "anyOf": [
748
+ {
749
+ "$ref": "#/$defs/phase_name"
750
+ },
751
+ {
752
+ "type": "null"
753
+ }
754
+ ]
755
+ },
756
+ "facts": {
757
+ "$ref": "#/$defs/query_facts"
758
+ }
759
+ }
760
+ },
761
+ "payload_query_read": {
762
+ "type": "object",
763
+ "additionalProperties": false,
764
+ "required": [
765
+ "session_handle",
766
+ "op",
767
+ "ref"
768
+ ],
769
+ "properties": {
770
+ "session_handle": {
771
+ "$ref": "#/$defs/session_handle"
772
+ },
773
+ "op": {
774
+ "const": "read"
775
+ },
776
+ "ref": {
777
+ "$ref": "#/$defs/record_ref"
778
+ }
779
+ }
780
+ },
781
+ "payload_session_start": {
782
+ "type": "object",
783
+ "additionalProperties": false,
784
+ "required": [
785
+ "project",
786
+ "capabilities"
787
+ ],
788
+ "properties": {
789
+ "project": {
790
+ "type": "string",
791
+ "minLength": 1,
792
+ "maxLength": 256,
793
+ "description": "Integrator-configured project id, or the working-directory name."
794
+ },
795
+ "profile_ref": {
796
+ "anyOf": [
797
+ {
798
+ "type": "string",
799
+ "pattern": "^[a-z0-9][a-z0-9._-]{0,63}(@[A-Za-z0-9._-]{1,32})?$"
800
+ },
801
+ {
802
+ "type": "null"
803
+ }
804
+ ]
805
+ },
806
+ "capabilities": {
807
+ "type": "array",
808
+ "uniqueItems": true,
809
+ "items": {
810
+ "$ref": "#/$defs/capability"
811
+ }
812
+ },
813
+ "adapter_version": {
814
+ "type": "string",
815
+ "minLength": 1,
816
+ "maxLength": 64
817
+ },
818
+ "environment": {
819
+ "$ref": "#/$defs/environment"
820
+ },
821
+ "dimensions": {
822
+ "$ref": "#/$defs/dimensions"
823
+ },
824
+ "workspace_root": {
825
+ "type": "string",
826
+ "minLength": 1,
827
+ "maxLength": 1024,
828
+ "description": "Absolute path of the session's working directory. Local only: the Runtime snapshots it at a failure when the adapter declares workspace_snapshot and the host enables snapshots (v1.1 FR-44 F1); it is never copied into Raw."
829
+ }
830
+ }
831
+ },
832
+ "payload_step_before": {
833
+ "type": "object",
834
+ "additionalProperties": false,
835
+ "required": [
836
+ "session_handle",
837
+ "step"
838
+ ],
839
+ "properties": {
840
+ "session_handle": {
841
+ "$ref": "#/$defs/session_handle"
842
+ },
843
+ "step": {
844
+ "type": "integer",
845
+ "minimum": 0
846
+ },
847
+ "phase": {
848
+ "anyOf": [
849
+ {
850
+ "$ref": "#/$defs/phase_name"
851
+ },
852
+ {
853
+ "type": "null"
854
+ }
855
+ ]
856
+ },
857
+ "query_text": {
858
+ "type": "string",
859
+ "maxLength": 4000,
860
+ "description": "first user prompt or current task text, redacted by the adapter; used only as query facts (mode A)"
861
+ }
862
+ }
863
+ },
864
+ "payload_tool_result": {
865
+ "type": "object",
866
+ "additionalProperties": false,
867
+ "required": [
868
+ "session_handle",
869
+ "tool_name",
870
+ "ok"
871
+ ],
872
+ "properties": {
873
+ "session_handle": {
874
+ "$ref": "#/$defs/session_handle"
875
+ },
876
+ "tool_name": {
877
+ "type": "string",
878
+ "minLength": 1,
879
+ "maxLength": 128
880
+ },
881
+ "ok": {
882
+ "type": "boolean"
883
+ },
884
+ "call_ref": {
885
+ "$ref": "#/$defs/ref"
886
+ },
887
+ "exit_code": {
888
+ "anyOf": [
889
+ {
890
+ "type": "integer"
891
+ },
892
+ {
893
+ "type": "null"
894
+ }
895
+ ]
896
+ },
897
+ "error_tail": {
898
+ "anyOf": [
899
+ {
900
+ "type": "string",
901
+ "maxLength": 4096
902
+ },
903
+ {
904
+ "type": "null"
905
+ }
906
+ ]
907
+ },
908
+ "error_signature": {
909
+ "anyOf": [
910
+ {
911
+ "$ref": "#/$defs/digest"
912
+ },
913
+ {
914
+ "type": "null"
915
+ }
916
+ ]
917
+ },
918
+ "path": {
919
+ "anyOf": [
920
+ {
921
+ "type": "string",
922
+ "minLength": 1,
923
+ "maxLength": 1024,
924
+ "description": "Logical path for write-type tools; never file content."
925
+ },
926
+ {
927
+ "type": "null"
928
+ }
929
+ ]
930
+ },
931
+ "symbols": {
932
+ "type": "array",
933
+ "maxItems": 32,
934
+ "items": {
935
+ "type": "string",
936
+ "minLength": 1,
937
+ "maxLength": 256
938
+ }
939
+ },
940
+ "command": {
941
+ "anyOf": [
942
+ {
943
+ "type": "string",
944
+ "minLength": 1,
945
+ "maxLength": 4096
946
+ },
947
+ {
948
+ "type": "null"
949
+ }
950
+ ],
951
+ "description": "The shell command, redacted by the adapter. On a failure it lets a replay reproduce the failing step (C2, C3); on a success (sent only after the session was shown memory) it lets the Runtime see that a pushed or read fix was run, or that a step that failed now passes (FR-18 applied). Never journaled."
952
+ }
953
+ }
954
+ },
955
+ "payload_context_compaction": {
956
+ "type": "object",
957
+ "additionalProperties": false,
958
+ "required": [
959
+ "session_handle",
960
+ "summary_text"
961
+ ],
962
+ "properties": {
963
+ "session_handle": {
964
+ "$ref": "#/$defs/session_handle"
965
+ },
966
+ "summary_text": {
967
+ "type": "string",
968
+ "maxLength": 16384
969
+ }
970
+ }
971
+ },
972
+ "payload_subagent_end": {
973
+ "type": "object",
974
+ "additionalProperties": false,
975
+ "required": [
976
+ "session_handle",
977
+ "child_ref",
978
+ "stop_reason"
979
+ ],
980
+ "properties": {
981
+ "session_handle": {
982
+ "$ref": "#/$defs/session_handle"
983
+ },
984
+ "child_ref": {
985
+ "$ref": "#/$defs/ref"
986
+ },
987
+ "stop_reason": {
988
+ "type": "string",
989
+ "minLength": 1,
990
+ "maxLength": 64
991
+ },
992
+ "agent_type": {
993
+ "type": "string",
994
+ "minLength": 1,
995
+ "maxLength": 128
996
+ },
997
+ "output_tail": {
998
+ "anyOf": [
999
+ {
1000
+ "type": "string",
1001
+ "maxLength": 4096
1002
+ },
1003
+ {
1004
+ "type": "null"
1005
+ }
1006
+ ]
1007
+ }
1008
+ }
1009
+ },
1010
+ "payload_note": {
1011
+ "type": "object",
1012
+ "additionalProperties": false,
1013
+ "required": [
1014
+ "session_handle",
1015
+ "title",
1016
+ "type",
1017
+ "scope",
1018
+ "content"
1019
+ ],
1020
+ "properties": {
1021
+ "session_handle": {
1022
+ "$ref": "#/$defs/session_handle"
1023
+ },
1024
+ "title": {
1025
+ "type": "string",
1026
+ "minLength": 1,
1027
+ "maxLength": 160
1028
+ },
1029
+ "type": {
1030
+ "enum": [
1031
+ "decision",
1032
+ "bugfix",
1033
+ "pattern",
1034
+ "config",
1035
+ "discovery",
1036
+ "learning",
1037
+ "pitfall"
1038
+ ]
1039
+ },
1040
+ "scope": {
1041
+ "enum": [
1042
+ "project",
1043
+ "global"
1044
+ ]
1045
+ },
1046
+ "phase": {
1047
+ "anyOf": [
1048
+ {
1049
+ "$ref": "#/$defs/phase_name"
1050
+ },
1051
+ {
1052
+ "type": "null"
1053
+ }
1054
+ ]
1055
+ },
1056
+ "topic_key": {
1057
+ "type": "string",
1058
+ "pattern": "^[a-z0-9][a-z0-9_.-]{0,63}/[a-z0-9][a-z0-9_.-]{0,127}$",
1059
+ "description": "family/description; omitted -> derived from type and title (FR-06②)."
1060
+ },
1061
+ "content": {
1062
+ "type": "object",
1063
+ "additionalProperties": false,
1064
+ "required": [
1065
+ "what",
1066
+ "why",
1067
+ "where",
1068
+ "learned"
1069
+ ],
1070
+ "properties": {
1071
+ "what": {
1072
+ "type": "string",
1073
+ "minLength": 1,
1074
+ "maxLength": 2000
1075
+ },
1076
+ "why": {
1077
+ "type": "string",
1078
+ "minLength": 1,
1079
+ "maxLength": 2000
1080
+ },
1081
+ "where": {
1082
+ "type": "string",
1083
+ "minLength": 1,
1084
+ "maxLength": 2000
1085
+ },
1086
+ "learned": {
1087
+ "type": "string",
1088
+ "minLength": 1,
1089
+ "maxLength": 2000
1090
+ }
1091
+ }
1092
+ },
1093
+ "evidence_refs": {
1094
+ "type": "array",
1095
+ "maxItems": 20,
1096
+ "items": {
1097
+ "type": "string",
1098
+ "minLength": 1,
1099
+ "maxLength": 512
1100
+ }
1101
+ },
1102
+ "relates_to": {
1103
+ "type": "array",
1104
+ "maxItems": 5,
1105
+ "items": {
1106
+ "type": "object",
1107
+ "additionalProperties": false,
1108
+ "required": [
1109
+ "record_ref",
1110
+ "relation"
1111
+ ],
1112
+ "properties": {
1113
+ "record_ref": {
1114
+ "$ref": "#/$defs/record_ref"
1115
+ },
1116
+ "relation": {
1117
+ "enum": [
1118
+ "related",
1119
+ "compatible",
1120
+ "scoped",
1121
+ "conflicts_with",
1122
+ "supersedes",
1123
+ "not_conflict"
1124
+ ]
1125
+ }
1126
+ }
1127
+ }
1128
+ },
1129
+ "fix": {
1130
+ "$ref": "#/$defs/fix"
1131
+ }
1132
+ }
1133
+ },
1134
+ "payload_query": {
1135
+ "oneOf": [
1136
+ {
1137
+ "$ref": "#/$defs/payload_query_search"
1138
+ },
1139
+ {
1140
+ "$ref": "#/$defs/payload_query_read"
1141
+ }
1142
+ ]
1143
+ },
1144
+ "payload_workflow_start": {
1145
+ "type": "object",
1146
+ "additionalProperties": false,
1147
+ "required": [
1148
+ "session_handle",
1149
+ "run_ref",
1150
+ "name",
1151
+ "phases"
1152
+ ],
1153
+ "properties": {
1154
+ "session_handle": {
1155
+ "$ref": "#/$defs/session_handle"
1156
+ },
1157
+ "run_ref": {
1158
+ "$ref": "#/$defs/ref"
1159
+ },
1160
+ "name": {
1161
+ "type": "string",
1162
+ "minLength": 1,
1163
+ "maxLength": 256
1164
+ },
1165
+ "description": {
1166
+ "anyOf": [
1167
+ {
1168
+ "type": "string",
1169
+ "maxLength": 4000
1170
+ },
1171
+ {
1172
+ "type": "null"
1173
+ }
1174
+ ]
1175
+ },
1176
+ "phases": {
1177
+ "type": "array",
1178
+ "maxItems": 64,
1179
+ "items": {
1180
+ "$ref": "#/$defs/phase_name"
1181
+ }
1182
+ },
1183
+ "meta_digest": {
1184
+ "anyOf": [
1185
+ {
1186
+ "$ref": "#/$defs/digest"
1187
+ },
1188
+ {
1189
+ "type": "null"
1190
+ }
1191
+ ]
1192
+ },
1193
+ "script_digest": {
1194
+ "anyOf": [
1195
+ {
1196
+ "$ref": "#/$defs/digest"
1197
+ },
1198
+ {
1199
+ "type": "null"
1200
+ }
1201
+ ]
1202
+ },
1203
+ "dimensions": {
1204
+ "$ref": "#/$defs/dimensions"
1205
+ }
1206
+ }
1207
+ },
1208
+ "payload_workflow_phase": {
1209
+ "type": "object",
1210
+ "additionalProperties": false,
1211
+ "required": [
1212
+ "session_handle",
1213
+ "run_ref",
1214
+ "title"
1215
+ ],
1216
+ "properties": {
1217
+ "session_handle": {
1218
+ "$ref": "#/$defs/session_handle"
1219
+ },
1220
+ "run_ref": {
1221
+ "$ref": "#/$defs/ref"
1222
+ },
1223
+ "title": {
1224
+ "$ref": "#/$defs/phase_name"
1225
+ }
1226
+ }
1227
+ },
1228
+ "payload_workflow_agent_start": {
1229
+ "type": "object",
1230
+ "additionalProperties": false,
1231
+ "required": [
1232
+ "session_handle",
1233
+ "run_ref",
1234
+ "seq"
1235
+ ],
1236
+ "properties": {
1237
+ "session_handle": {
1238
+ "$ref": "#/$defs/session_handle"
1239
+ },
1240
+ "run_ref": {
1241
+ "$ref": "#/$defs/ref"
1242
+ },
1243
+ "seq": {
1244
+ "type": "integer",
1245
+ "minimum": 0
1246
+ },
1247
+ "label": {
1248
+ "anyOf": [
1249
+ {
1250
+ "type": "string",
1251
+ "minLength": 1,
1252
+ "maxLength": 256
1253
+ },
1254
+ {
1255
+ "type": "null"
1256
+ }
1257
+ ]
1258
+ },
1259
+ "phase": {
1260
+ "anyOf": [
1261
+ {
1262
+ "$ref": "#/$defs/phase_name"
1263
+ },
1264
+ {
1265
+ "type": "null"
1266
+ }
1267
+ ]
1268
+ },
1269
+ "child_ref": {
1270
+ "anyOf": [
1271
+ {
1272
+ "$ref": "#/$defs/ref"
1273
+ },
1274
+ {
1275
+ "type": "null"
1276
+ }
1277
+ ]
1278
+ }
1279
+ }
1280
+ },
1281
+ "payload_workflow_agent_end": {
1282
+ "type": "object",
1283
+ "additionalProperties": false,
1284
+ "required": [
1285
+ "session_handle",
1286
+ "run_ref",
1287
+ "seq"
1288
+ ],
1289
+ "properties": {
1290
+ "session_handle": {
1291
+ "$ref": "#/$defs/session_handle"
1292
+ },
1293
+ "run_ref": {
1294
+ "$ref": "#/$defs/ref"
1295
+ },
1296
+ "seq": {
1297
+ "type": "integer",
1298
+ "minimum": 0
1299
+ },
1300
+ "label": {
1301
+ "anyOf": [
1302
+ {
1303
+ "type": "string",
1304
+ "minLength": 1,
1305
+ "maxLength": 256
1306
+ },
1307
+ {
1308
+ "type": "null"
1309
+ }
1310
+ ]
1311
+ },
1312
+ "phase": {
1313
+ "anyOf": [
1314
+ {
1315
+ "$ref": "#/$defs/phase_name"
1316
+ },
1317
+ {
1318
+ "type": "null"
1319
+ }
1320
+ ]
1321
+ },
1322
+ "child_ref": {
1323
+ "anyOf": [
1324
+ {
1325
+ "$ref": "#/$defs/ref"
1326
+ },
1327
+ {
1328
+ "type": "null"
1329
+ }
1330
+ ]
1331
+ },
1332
+ "outcome": {
1333
+ "anyOf": [
1334
+ {
1335
+ "type": "string",
1336
+ "minLength": 1,
1337
+ "maxLength": 64
1338
+ },
1339
+ {
1340
+ "type": "null"
1341
+ }
1342
+ ]
1343
+ }
1344
+ }
1345
+ },
1346
+ "payload_workflow_end": {
1347
+ "type": "object",
1348
+ "additionalProperties": false,
1349
+ "required": [
1350
+ "session_handle",
1351
+ "run_ref",
1352
+ "stop_reason"
1353
+ ],
1354
+ "properties": {
1355
+ "session_handle": {
1356
+ "$ref": "#/$defs/session_handle"
1357
+ },
1358
+ "run_ref": {
1359
+ "$ref": "#/$defs/ref"
1360
+ },
1361
+ "stop_reason": {
1362
+ "enum": [
1363
+ "completed",
1364
+ "cancelled",
1365
+ "error"
1366
+ ]
1367
+ },
1368
+ "error": {
1369
+ "anyOf": [
1370
+ {
1371
+ "type": "string",
1372
+ "maxLength": 4096
1373
+ },
1374
+ {
1375
+ "type": "null"
1376
+ }
1377
+ ]
1378
+ },
1379
+ "agents_started": {
1380
+ "type": "integer",
1381
+ "minimum": 0
1382
+ },
1383
+ "result_outcome": {
1384
+ "anyOf": [
1385
+ {
1386
+ "type": "string",
1387
+ "minLength": 1,
1388
+ "maxLength": 64
1389
+ },
1390
+ {
1391
+ "type": "null"
1392
+ }
1393
+ ]
1394
+ }
1395
+ }
1396
+ },
1397
+ "payload_goal_changed": {
1398
+ "type": "object",
1399
+ "additionalProperties": false,
1400
+ "required": [
1401
+ "session_handle",
1402
+ "operation"
1403
+ ],
1404
+ "properties": {
1405
+ "session_handle": {
1406
+ "$ref": "#/$defs/session_handle"
1407
+ },
1408
+ "operation": {
1409
+ "enum": [
1410
+ "create",
1411
+ "complete",
1412
+ "block",
1413
+ "pause",
1414
+ "resume",
1415
+ "clear"
1416
+ ]
1417
+ },
1418
+ "objective_digest": {
1419
+ "anyOf": [
1420
+ {
1421
+ "$ref": "#/$defs/digest"
1422
+ },
1423
+ {
1424
+ "type": "null"
1425
+ }
1426
+ ]
1427
+ }
1428
+ }
1429
+ },
1430
+ "payload_session_end": {
1431
+ "type": "object",
1432
+ "additionalProperties": false,
1433
+ "required": [
1434
+ "session_handle",
1435
+ "reason"
1436
+ ],
1437
+ "properties": {
1438
+ "session_handle": {
1439
+ "$ref": "#/$defs/session_handle"
1440
+ },
1441
+ "reason": {
1442
+ "type": "string",
1443
+ "minLength": 1,
1444
+ "maxLength": 64
1445
+ }
1446
+ }
1447
+ },
1448
+ "result_ack": {
1449
+ "type": "object",
1450
+ "additionalProperties": false,
1451
+ "required": [],
1452
+ "properties": {},
1453
+ "description": "Capture-type events: empty acknowledgement."
1454
+ },
1455
+ "read_record": {
1456
+ "type": "object",
1457
+ "additionalProperties": false,
1458
+ "required": [
1459
+ "record_ref",
1460
+ "title",
1461
+ "trust",
1462
+ "provenance_label",
1463
+ "text"
1464
+ ],
1465
+ "properties": {
1466
+ "record_ref": {
1467
+ "$ref": "#/$defs/record_ref"
1468
+ },
1469
+ "title": {
1470
+ "type": "string",
1471
+ "minLength": 1,
1472
+ "maxLength": 512
1473
+ },
1474
+ "trust": {
1475
+ "$ref": "#/$defs/trust"
1476
+ },
1477
+ "provenance_label": {
1478
+ "type": "string",
1479
+ "minLength": 1,
1480
+ "maxLength": 512
1481
+ },
1482
+ "text": {
1483
+ "type": "string",
1484
+ "minLength": 1,
1485
+ "maxLength": 65536,
1486
+ "description": "Full agent-facing text."
1487
+ },
1488
+ "type": {
1489
+ "type": "string",
1490
+ "minLength": 1,
1491
+ "maxLength": 64
1492
+ },
1493
+ "scope": {
1494
+ "type": "string",
1495
+ "minLength": 1,
1496
+ "maxLength": 64
1497
+ },
1498
+ "topic_key": {
1499
+ "type": "string",
1500
+ "minLength": 1,
1501
+ "maxLength": 256
1502
+ },
1503
+ "revision": {
1504
+ "type": "integer",
1505
+ "minimum": 1
1506
+ },
1507
+ "project": {
1508
+ "type": "string",
1509
+ "minLength": 1,
1510
+ "maxLength": 256
1511
+ },
1512
+ "phase": {
1513
+ "anyOf": [
1514
+ {
1515
+ "$ref": "#/$defs/phase_name"
1516
+ },
1517
+ {
1518
+ "type": "null"
1519
+ }
1520
+ ]
1521
+ },
1522
+ "content": {
1523
+ "type": "object",
1524
+ "additionalProperties": false,
1525
+ "required": [],
1526
+ "properties": {
1527
+ "what": {
1528
+ "type": "string",
1529
+ "maxLength": 4000
1530
+ },
1531
+ "why": {
1532
+ "type": "string",
1533
+ "maxLength": 4000
1534
+ },
1535
+ "where": {
1536
+ "type": "string",
1537
+ "maxLength": 4000
1538
+ },
1539
+ "learned": {
1540
+ "type": "string",
1541
+ "maxLength": 4000
1542
+ }
1543
+ }
1544
+ },
1545
+ "evidence_refs": {
1546
+ "type": "array",
1547
+ "items": {
1548
+ "type": "string",
1549
+ "minLength": 1,
1550
+ "maxLength": 512
1551
+ }
1552
+ },
1553
+ "marks": {
1554
+ "type": "array",
1555
+ "maxItems": 16,
1556
+ "uniqueItems": true,
1557
+ "items": {
1558
+ "enum": [
1559
+ "task_failed",
1560
+ "contradicted",
1561
+ "superseded",
1562
+ "used_then_passed"
1563
+ ]
1564
+ }
1565
+ },
1566
+ "created_at": {
1567
+ "$ref": "#/$defs/timestamp"
1568
+ },
1569
+ "updated_at": {
1570
+ "$ref": "#/$defs/timestamp"
1571
+ }
1572
+ }
1573
+ },
1574
+ "result_query_search": {
1575
+ "type": "object",
1576
+ "additionalProperties": false,
1577
+ "required": [
1578
+ "op",
1579
+ "hits"
1580
+ ],
1581
+ "properties": {
1582
+ "op": {
1583
+ "const": "search"
1584
+ },
1585
+ "hits": {
1586
+ "type": "array",
1587
+ "maxItems": 5,
1588
+ "items": {
1589
+ "$ref": "#/$defs/hit"
1590
+ }
1591
+ },
1592
+ "status": {
1593
+ "enum": [
1594
+ "ok",
1595
+ "no_match",
1596
+ "budget_exhausted"
1597
+ ]
1598
+ }
1599
+ }
1600
+ },
1601
+ "result_query_read": {
1602
+ "type": "object",
1603
+ "additionalProperties": false,
1604
+ "required": [
1605
+ "op",
1606
+ "record"
1607
+ ],
1608
+ "properties": {
1609
+ "op": {
1610
+ "const": "read"
1611
+ },
1612
+ "record": {
1613
+ "$ref": "#/$defs/read_record"
1614
+ }
1615
+ }
1616
+ },
1617
+ "result_session_start": {
1618
+ "type": "object",
1619
+ "additionalProperties": false,
1620
+ "required": [
1621
+ "session_handle",
1622
+ "profile"
1623
+ ],
1624
+ "properties": {
1625
+ "session_handle": {
1626
+ "$ref": "#/$defs/session_handle"
1627
+ },
1628
+ "profile": {
1629
+ "type": "object",
1630
+ "additionalProperties": false,
1631
+ "required": [
1632
+ "id",
1633
+ "revision",
1634
+ "digest"
1635
+ ],
1636
+ "properties": {
1637
+ "id": {
1638
+ "type": "string",
1639
+ "minLength": 1,
1640
+ "maxLength": 64
1641
+ },
1642
+ "revision": {
1643
+ "type": "string",
1644
+ "minLength": 1,
1645
+ "maxLength": 32
1646
+ },
1647
+ "digest": {
1648
+ "$ref": "#/$defs/digest"
1649
+ }
1650
+ },
1651
+ "description": "Pinned profile snapshot (FR-29)."
1652
+ },
1653
+ "profile_fallback": {
1654
+ "anyOf": [
1655
+ {
1656
+ "type": "string",
1657
+ "minLength": 1,
1658
+ "maxLength": 256,
1659
+ "description": "Why the default profile was used instead (FR-29)."
1660
+ },
1661
+ {
1662
+ "type": "null"
1663
+ }
1664
+ ]
1665
+ },
1666
+ "capabilities_missing": {
1667
+ "type": "array",
1668
+ "uniqueItems": true,
1669
+ "items": {
1670
+ "$ref": "#/$defs/capability"
1671
+ }
1672
+ },
1673
+ "disabled_kinds": {
1674
+ "type": "array",
1675
+ "uniqueItems": true,
1676
+ "items": {
1677
+ "enum": [
1678
+ "session.start",
1679
+ "step.before",
1680
+ "tool.result",
1681
+ "context.compaction",
1682
+ "subagent.end",
1683
+ "note",
1684
+ "query",
1685
+ "workflow.start",
1686
+ "workflow.phase",
1687
+ "workflow.agent.start",
1688
+ "workflow.agent.end",
1689
+ "workflow.end",
1690
+ "goal.changed",
1691
+ "session.end"
1692
+ ]
1693
+ }
1694
+ }
1695
+ }
1696
+ },
1697
+ "result_step_before": {
1698
+ "type": "object",
1699
+ "additionalProperties": false,
1700
+ "required": [],
1701
+ "properties": {
1702
+ "inject": {
1703
+ "anyOf": [
1704
+ {
1705
+ "$ref": "#/$defs/inject"
1706
+ },
1707
+ {
1708
+ "type": "null"
1709
+ }
1710
+ ]
1711
+ }
1712
+ }
1713
+ },
1714
+ "result_tool_result": {
1715
+ "type": "object",
1716
+ "additionalProperties": false,
1717
+ "required": [],
1718
+ "properties": {
1719
+ "inject": {
1720
+ "anyOf": [
1721
+ {
1722
+ "$ref": "#/$defs/inject"
1723
+ },
1724
+ {
1725
+ "type": "null"
1726
+ }
1727
+ ]
1728
+ }
1729
+ },
1730
+ "description": "inject only when a failure triggers a push."
1731
+ },
1732
+ "result_note": {
1733
+ "type": "object",
1734
+ "additionalProperties": false,
1735
+ "required": [
1736
+ "record_ref",
1737
+ "revision",
1738
+ "topic_key",
1739
+ "similar"
1740
+ ],
1741
+ "properties": {
1742
+ "record_ref": {
1743
+ "anyOf": [
1744
+ {
1745
+ "$ref": "#/$defs/record_ref"
1746
+ },
1747
+ {
1748
+ "type": "null"
1749
+ }
1750
+ ]
1751
+ },
1752
+ "draft_ref": {
1753
+ "anyOf": [
1754
+ {
1755
+ "$ref": "#/$defs/record_ref"
1756
+ },
1757
+ {
1758
+ "type": "null"
1759
+ }
1760
+ ]
1761
+ },
1762
+ "revision": {
1763
+ "type": "integer",
1764
+ "minimum": 1
1765
+ },
1766
+ "topic_key": {
1767
+ "type": "string",
1768
+ "pattern": "^[a-z0-9][a-z0-9_.-]{0,63}/[a-z0-9][a-z0-9_.-]{0,127}$"
1769
+ },
1770
+ "topic_key_derived": {
1771
+ "type": "boolean"
1772
+ },
1773
+ "visible_from": {
1774
+ "enum": [
1775
+ "next_session"
1776
+ ]
1777
+ },
1778
+ "similar": {
1779
+ "type": "array",
1780
+ "maxItems": 3,
1781
+ "items": {
1782
+ "$ref": "#/$defs/hit"
1783
+ }
1784
+ }
1785
+ }
1786
+ },
1787
+ "result_query": {
1788
+ "oneOf": [
1789
+ {
1790
+ "$ref": "#/$defs/result_query_search"
1791
+ },
1792
+ {
1793
+ "$ref": "#/$defs/result_query_read"
1794
+ }
1795
+ ]
1796
+ },
1797
+ "result_workflow_phase": {
1798
+ "type": "object",
1799
+ "additionalProperties": false,
1800
+ "required": [],
1801
+ "properties": {
1802
+ "inject": {
1803
+ "anyOf": [
1804
+ {
1805
+ "$ref": "#/$defs/inject"
1806
+ },
1807
+ {
1808
+ "type": "null"
1809
+ }
1810
+ ]
1811
+ }
1812
+ }
1813
+ },
1814
+ "result_session_end": {
1815
+ "type": "object",
1816
+ "additionalProperties": false,
1817
+ "required": [
1818
+ "outcome",
1819
+ "domain_status",
1820
+ "exposures"
1821
+ ],
1822
+ "properties": {
1823
+ "outcome": {
1824
+ "$ref": "#/$defs/outcome"
1825
+ },
1826
+ "domain_status": {
1827
+ "type": "string",
1828
+ "minLength": 0,
1829
+ "maxLength": 256
1830
+ },
1831
+ "task_id": {
1832
+ "type": "string",
1833
+ "minLength": 1,
1834
+ "maxLength": 256
1835
+ },
1836
+ "exposures": {
1837
+ "type": "object",
1838
+ "additionalProperties": false,
1839
+ "required": [
1840
+ "pushed",
1841
+ "listed",
1842
+ "read",
1843
+ "cited"
1844
+ ],
1845
+ "properties": {
1846
+ "pushed": {
1847
+ "type": "integer",
1848
+ "minimum": 0
1849
+ },
1850
+ "listed": {
1851
+ "type": "integer",
1852
+ "minimum": 0
1853
+ },
1854
+ "read": {
1855
+ "type": "integer",
1856
+ "minimum": 0
1857
+ },
1858
+ "cited": {
1859
+ "type": "integer",
1860
+ "minimum": 0
1861
+ },
1862
+ "applied": {
1863
+ "type": "integer",
1864
+ "minimum": 0,
1865
+ "description": "Records whose fix the session ran after they were pushed or read (FR-18 applied)."
1866
+ }
1867
+ }
1868
+ },
1869
+ "record_refs": {
1870
+ "type": "array",
1871
+ "uniqueItems": true,
1872
+ "items": {
1873
+ "$ref": "#/$defs/record_ref"
1874
+ }
1875
+ },
1876
+ "notes": {
1877
+ "type": "integer",
1878
+ "minimum": 0
1879
+ }
1880
+ },
1881
+ "description": "Receipt summary."
1882
+ },
1883
+ "error": {
1884
+ "type": "object",
1885
+ "additionalProperties": false,
1886
+ "required": [
1887
+ "code",
1888
+ "message",
1889
+ "retryable"
1890
+ ],
1891
+ "properties": {
1892
+ "code": {
1893
+ "type": "string",
1894
+ "pattern": "^[a-z][a-z0-9_]{0,63}$",
1895
+ "description": "See x-error-codes."
1896
+ },
1897
+ "message": {
1898
+ "type": "string",
1899
+ "maxLength": 2000
1900
+ },
1901
+ "retryable": {
1902
+ "type": "boolean"
1903
+ }
1904
+ }
1905
+ },
1906
+ "response_error": {
1907
+ "type": "object",
1908
+ "additionalProperties": false,
1909
+ "required": [
1910
+ "ok",
1911
+ "error"
1912
+ ],
1913
+ "properties": {
1914
+ "ok": {
1915
+ "const": false
1916
+ },
1917
+ "error": {
1918
+ "$ref": "#/$defs/error"
1919
+ }
1920
+ }
1921
+ },
1922
+ "response_session_start": {
1923
+ "oneOf": [
1924
+ {
1925
+ "type": "object",
1926
+ "additionalProperties": false,
1927
+ "required": [
1928
+ "ok",
1929
+ "result"
1930
+ ],
1931
+ "properties": {
1932
+ "ok": {
1933
+ "const": true
1934
+ },
1935
+ "result": {
1936
+ "$ref": "#/$defs/result_session_start"
1937
+ }
1938
+ }
1939
+ },
1940
+ {
1941
+ "$ref": "#/$defs/response_error"
1942
+ }
1943
+ ]
1944
+ },
1945
+ "response_step_before": {
1946
+ "oneOf": [
1947
+ {
1948
+ "type": "object",
1949
+ "additionalProperties": false,
1950
+ "required": [
1951
+ "ok",
1952
+ "result"
1953
+ ],
1954
+ "properties": {
1955
+ "ok": {
1956
+ "const": true
1957
+ },
1958
+ "result": {
1959
+ "$ref": "#/$defs/result_step_before"
1960
+ }
1961
+ }
1962
+ },
1963
+ {
1964
+ "$ref": "#/$defs/response_error"
1965
+ }
1966
+ ]
1967
+ },
1968
+ "response_tool_result": {
1969
+ "oneOf": [
1970
+ {
1971
+ "type": "object",
1972
+ "additionalProperties": false,
1973
+ "required": [
1974
+ "ok",
1975
+ "result"
1976
+ ],
1977
+ "properties": {
1978
+ "ok": {
1979
+ "const": true
1980
+ },
1981
+ "result": {
1982
+ "$ref": "#/$defs/result_tool_result"
1983
+ }
1984
+ }
1985
+ },
1986
+ {
1987
+ "$ref": "#/$defs/response_error"
1988
+ }
1989
+ ]
1990
+ },
1991
+ "response_context_compaction": {
1992
+ "oneOf": [
1993
+ {
1994
+ "type": "object",
1995
+ "additionalProperties": false,
1996
+ "required": [
1997
+ "ok",
1998
+ "result"
1999
+ ],
2000
+ "properties": {
2001
+ "ok": {
2002
+ "const": true
2003
+ },
2004
+ "result": {
2005
+ "$ref": "#/$defs/result_ack"
2006
+ }
2007
+ }
2008
+ },
2009
+ {
2010
+ "$ref": "#/$defs/response_error"
2011
+ }
2012
+ ]
2013
+ },
2014
+ "response_subagent_end": {
2015
+ "oneOf": [
2016
+ {
2017
+ "type": "object",
2018
+ "additionalProperties": false,
2019
+ "required": [
2020
+ "ok",
2021
+ "result"
2022
+ ],
2023
+ "properties": {
2024
+ "ok": {
2025
+ "const": true
2026
+ },
2027
+ "result": {
2028
+ "$ref": "#/$defs/result_ack"
2029
+ }
2030
+ }
2031
+ },
2032
+ {
2033
+ "$ref": "#/$defs/response_error"
2034
+ }
2035
+ ]
2036
+ },
2037
+ "response_note": {
2038
+ "oneOf": [
2039
+ {
2040
+ "type": "object",
2041
+ "additionalProperties": false,
2042
+ "required": [
2043
+ "ok",
2044
+ "result"
2045
+ ],
2046
+ "properties": {
2047
+ "ok": {
2048
+ "const": true
2049
+ },
2050
+ "result": {
2051
+ "$ref": "#/$defs/result_note"
2052
+ }
2053
+ }
2054
+ },
2055
+ {
2056
+ "$ref": "#/$defs/response_error"
2057
+ }
2058
+ ]
2059
+ },
2060
+ "response_query": {
2061
+ "oneOf": [
2062
+ {
2063
+ "type": "object",
2064
+ "additionalProperties": false,
2065
+ "required": [
2066
+ "ok",
2067
+ "result"
2068
+ ],
2069
+ "properties": {
2070
+ "ok": {
2071
+ "const": true
2072
+ },
2073
+ "result": {
2074
+ "$ref": "#/$defs/result_query"
2075
+ }
2076
+ }
2077
+ },
2078
+ {
2079
+ "$ref": "#/$defs/response_error"
2080
+ }
2081
+ ]
2082
+ },
2083
+ "response_workflow_start": {
2084
+ "oneOf": [
2085
+ {
2086
+ "type": "object",
2087
+ "additionalProperties": false,
2088
+ "required": [
2089
+ "ok",
2090
+ "result"
2091
+ ],
2092
+ "properties": {
2093
+ "ok": {
2094
+ "const": true
2095
+ },
2096
+ "result": {
2097
+ "$ref": "#/$defs/result_ack"
2098
+ }
2099
+ }
2100
+ },
2101
+ {
2102
+ "$ref": "#/$defs/response_error"
2103
+ }
2104
+ ]
2105
+ },
2106
+ "response_workflow_phase": {
2107
+ "oneOf": [
2108
+ {
2109
+ "type": "object",
2110
+ "additionalProperties": false,
2111
+ "required": [
2112
+ "ok",
2113
+ "result"
2114
+ ],
2115
+ "properties": {
2116
+ "ok": {
2117
+ "const": true
2118
+ },
2119
+ "result": {
2120
+ "$ref": "#/$defs/result_workflow_phase"
2121
+ }
2122
+ }
2123
+ },
2124
+ {
2125
+ "$ref": "#/$defs/response_error"
2126
+ }
2127
+ ]
2128
+ },
2129
+ "response_workflow_agent_start": {
2130
+ "oneOf": [
2131
+ {
2132
+ "type": "object",
2133
+ "additionalProperties": false,
2134
+ "required": [
2135
+ "ok",
2136
+ "result"
2137
+ ],
2138
+ "properties": {
2139
+ "ok": {
2140
+ "const": true
2141
+ },
2142
+ "result": {
2143
+ "$ref": "#/$defs/result_ack"
2144
+ }
2145
+ }
2146
+ },
2147
+ {
2148
+ "$ref": "#/$defs/response_error"
2149
+ }
2150
+ ]
2151
+ },
2152
+ "response_workflow_agent_end": {
2153
+ "oneOf": [
2154
+ {
2155
+ "type": "object",
2156
+ "additionalProperties": false,
2157
+ "required": [
2158
+ "ok",
2159
+ "result"
2160
+ ],
2161
+ "properties": {
2162
+ "ok": {
2163
+ "const": true
2164
+ },
2165
+ "result": {
2166
+ "$ref": "#/$defs/result_ack"
2167
+ }
2168
+ }
2169
+ },
2170
+ {
2171
+ "$ref": "#/$defs/response_error"
2172
+ }
2173
+ ]
2174
+ },
2175
+ "response_workflow_end": {
2176
+ "oneOf": [
2177
+ {
2178
+ "type": "object",
2179
+ "additionalProperties": false,
2180
+ "required": [
2181
+ "ok",
2182
+ "result"
2183
+ ],
2184
+ "properties": {
2185
+ "ok": {
2186
+ "const": true
2187
+ },
2188
+ "result": {
2189
+ "$ref": "#/$defs/result_ack"
2190
+ }
2191
+ }
2192
+ },
2193
+ {
2194
+ "$ref": "#/$defs/response_error"
2195
+ }
2196
+ ]
2197
+ },
2198
+ "response_goal_changed": {
2199
+ "oneOf": [
2200
+ {
2201
+ "type": "object",
2202
+ "additionalProperties": false,
2203
+ "required": [
2204
+ "ok",
2205
+ "result"
2206
+ ],
2207
+ "properties": {
2208
+ "ok": {
2209
+ "const": true
2210
+ },
2211
+ "result": {
2212
+ "$ref": "#/$defs/result_ack"
2213
+ }
2214
+ }
2215
+ },
2216
+ {
2217
+ "$ref": "#/$defs/response_error"
2218
+ }
2219
+ ]
2220
+ },
2221
+ "response_session_end": {
2222
+ "oneOf": [
2223
+ {
2224
+ "type": "object",
2225
+ "additionalProperties": false,
2226
+ "required": [
2227
+ "ok",
2228
+ "result"
2229
+ ],
2230
+ "properties": {
2231
+ "ok": {
2232
+ "const": true
2233
+ },
2234
+ "result": {
2235
+ "$ref": "#/$defs/result_session_end"
2236
+ }
2237
+ }
2238
+ },
2239
+ {
2240
+ "$ref": "#/$defs/response_error"
2241
+ }
2242
+ ]
2243
+ },
2244
+ "query_item_additions": {
2245
+ "type": "object",
2246
+ "additionalProperties": false,
2247
+ "required": [],
2248
+ "properties": {
2249
+ "record_ref": {
2250
+ "$ref": "#/$defs/record_ref"
2251
+ },
2252
+ "match_reasons": {
2253
+ "type": "array",
2254
+ "maxItems": 32,
2255
+ "items": {
2256
+ "$ref": "#/$defs/match_reason"
2257
+ }
2258
+ },
2259
+ "trust": {
2260
+ "$ref": "#/$defs/trust"
2261
+ },
2262
+ "provenance_label": {
2263
+ "type": "string",
2264
+ "minLength": 1,
2265
+ "maxLength": 512
2266
+ }
2267
+ },
2268
+ "description": "Additive fields for crowdmemory-query-response/v1 items (plan §4.3); old clients ignore them. Validate only these keys."
2269
+ },
2270
+ "receipt_mark_payload": {
2271
+ "type": "object",
2272
+ "additionalProperties": false,
2273
+ "required": [
2274
+ "mark",
2275
+ "record_ref",
2276
+ "task_id",
2277
+ "phase",
2278
+ "attempt"
2279
+ ],
2280
+ "properties": {
2281
+ "mark": {
2282
+ "enum": [
2283
+ "task_failed",
2284
+ "contradicted",
2285
+ "superseded",
2286
+ "used_success"
2287
+ ]
2288
+ },
2289
+ "record_ref": {
2290
+ "$ref": "#/$defs/record_ref"
2291
+ },
2292
+ "revision": {
2293
+ "type": "integer",
2294
+ "minimum": 1
2295
+ },
2296
+ "task_id": {
2297
+ "type": "string",
2298
+ "minLength": 1,
2299
+ "maxLength": 256
2300
+ },
2301
+ "phase": {
2302
+ "$ref": "#/$defs/phase_name"
2303
+ },
2304
+ "attempt": {
2305
+ "type": "integer",
2306
+ "minimum": 1
2307
+ },
2308
+ "session_handle": {
2309
+ "$ref": "#/$defs/session_handle"
2310
+ },
2311
+ "by_ref": {
2312
+ "type": "string",
2313
+ "minLength": 1,
2314
+ "maxLength": 256
2315
+ }
2316
+ },
2317
+ "description": "payload of crowdmemory-receipt/v1 record_usage (task_failed|superseded|used_success) and contradiction (contradicted) receipts that seal a mark into Raw with the session that caused it (FR-09 ④)."
2318
+ },
2319
+ "receipt_exposure_payload": {
2320
+ "type": "object",
2321
+ "additionalProperties": false,
2322
+ "required": [
2323
+ "exposure_kind",
2324
+ "record_ref",
2325
+ "trust",
2326
+ "task_id",
2327
+ "phase",
2328
+ "attempt"
2329
+ ],
2330
+ "properties": {
2331
+ "exposure_kind": {
2332
+ "enum": [
2333
+ "pushed",
2334
+ "listed",
2335
+ "read",
2336
+ "cited",
2337
+ "applied"
2338
+ ]
2339
+ },
2340
+ "applied_via": {
2341
+ "enum": [
2342
+ "fix_command",
2343
+ "fix_path"
2344
+ ],
2345
+ "description": "applied only: the session ran the record's fix command (fix_command) or wrote a file its fix names (fix_path, config or diff fixes)."
2346
+ },
2347
+ "record_ref": {
2348
+ "$ref": "#/$defs/record_ref"
2349
+ },
2350
+ "trust": {
2351
+ "$ref": "#/$defs/trust"
2352
+ },
2353
+ "task_id": {
2354
+ "type": "string",
2355
+ "minLength": 1,
2356
+ "maxLength": 256
2357
+ },
2358
+ "phase": {
2359
+ "$ref": "#/$defs/phase_name"
2360
+ },
2361
+ "attempt": {
2362
+ "type": "integer",
2363
+ "minimum": 1
2364
+ },
2365
+ "session_handle": {
2366
+ "$ref": "#/$defs/session_handle"
2367
+ },
2368
+ "trigger": {
2369
+ "$ref": "#/$defs/push_trigger"
2370
+ },
2371
+ "score": {
2372
+ "type": "number"
2373
+ },
2374
+ "reasons": {
2375
+ "type": "array",
2376
+ "maxItems": 32,
2377
+ "items": {
2378
+ "$ref": "#/$defs/match_reason"
2379
+ }
2380
+ },
2381
+ "push_policy": {
2382
+ "type": "object",
2383
+ "additionalProperties": false,
2384
+ "required": [
2385
+ "max_items",
2386
+ "max_chars",
2387
+ "min_score"
2388
+ ],
2389
+ "properties": {
2390
+ "max_items": {
2391
+ "type": "integer",
2392
+ "minimum": 0
2393
+ },
2394
+ "max_chars": {
2395
+ "type": "integer",
2396
+ "minimum": 0
2397
+ },
2398
+ "min_score": {
2399
+ "type": "number"
2400
+ },
2401
+ "require": {
2402
+ "type": "array",
2403
+ "maxItems": 16,
2404
+ "items": {
2405
+ "type": "string",
2406
+ "minLength": 1,
2407
+ "maxLength": 64
2408
+ }
2409
+ },
2410
+ "overridden": {
2411
+ "type": "array",
2412
+ "maxItems": 16,
2413
+ "items": {
2414
+ "type": "string",
2415
+ "minLength": 1,
2416
+ "maxLength": 64
2417
+ }
2418
+ }
2419
+ },
2420
+ "description": "pushed only: the trigger policy in effect and which keys a local override changed (FR-15)."
2421
+ }
2422
+ },
2423
+ "description": "payload of crowdmemory-receipt/v1 view_exposure (pushed|listed) and record_usage (read|cited|applied) receipts (FR-18). applied: after the record was pushed to the task or read in the session, the agent ran its fix (deterministic match, no self-report).",
2424
+ "allOf": [
2425
+ {
2426
+ "if": {
2427
+ "properties": {
2428
+ "exposure_kind": {
2429
+ "const": "applied"
2430
+ }
2431
+ },
2432
+ "required": [
2433
+ "exposure_kind"
2434
+ ]
2435
+ },
2436
+ "then": {
2437
+ "required": [
2438
+ "applied_via"
2439
+ ]
2440
+ },
2441
+ "else": {
2442
+ "not": {
2443
+ "required": [
2444
+ "applied_via"
2445
+ ]
2446
+ }
2447
+ }
2448
+ }
2449
+ ]
2450
+ },
2451
+ "fix": {
2452
+ "type": "object",
2453
+ "additionalProperties": false,
2454
+ "required": [
2455
+ "kind"
2456
+ ],
2457
+ "description": "The fix the agent attached to a note (v1.1 FR-39, T-B4): a shell command run in the workspace root, a unified diff with paths relative to it, or a whole config file. A note with a fix and a failure signature is a fix-type candidate; the center applies it mechanically (C3) without an agent.",
2458
+ "properties": {
2459
+ "kind": {
2460
+ "enum": [
2461
+ "command",
2462
+ "diff",
2463
+ "config"
2464
+ ]
2465
+ },
2466
+ "command": {
2467
+ "type": "string",
2468
+ "minLength": 1,
2469
+ "maxLength": 4096
2470
+ },
2471
+ "diff": {
2472
+ "type": "string",
2473
+ "minLength": 1,
2474
+ "maxLength": 65536
2475
+ },
2476
+ "path": {
2477
+ "type": "string",
2478
+ "minLength": 1,
2479
+ "maxLength": 1024
2480
+ },
2481
+ "content": {
2482
+ "type": "string",
2483
+ "maxLength": 65536
2484
+ }
2485
+ },
2486
+ "oneOf": [
2487
+ {
2488
+ "properties": {
2489
+ "kind": {
2490
+ "const": "command"
2491
+ }
2492
+ },
2493
+ "required": [
2494
+ "command"
2495
+ ]
2496
+ },
2497
+ {
2498
+ "properties": {
2499
+ "kind": {
2500
+ "const": "diff"
2501
+ }
2502
+ },
2503
+ "required": [
2504
+ "diff"
2505
+ ]
2506
+ },
2507
+ {
2508
+ "properties": {
2509
+ "kind": {
2510
+ "const": "config"
2511
+ }
2512
+ },
2513
+ "required": [
2514
+ "path",
2515
+ "content"
2516
+ ]
2517
+ }
2518
+ ]
2519
+ }
2520
+ }
2521
+ }