@sharedcontext/sdk 0.0.0-stage → 0.2.0

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,753 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "title": "sharedcontext/1.x, the lineage read",
4
+ "$comment": "The lineage read: one new read-only MCP tool, `lineage`, as an additive minor of sharedcontext/1 whose number is not yet assigned: no event type, no event field, no fold or store-format change in the log's contract (any index it reads is the store's own). Nested shapes are $refs into content.schema.json and mcp-tools.schema.json. Served only with the service's reads.lineage on (crates/sharedcontext/src/work/lineage.rs). Checked by contract-check.mjs against cases/lineage.cases.jsonl and against the answers the code serves (crates/sharedcontext/tests/work/lineage/answers.jsonl).",
5
+ "$defs": {
6
+ "LineageArgs": {
7
+ "type": "object",
8
+ "additionalProperties": false,
9
+ "$comment": "The lineage read's arguments. One key per call: `by` names which provenance key `value` is. The record handle is asked for as by: record; its value is what the log carries as record_digest. `repo` narrows a sha (or any key) to one repository of a multi-repo project: the repo key host/owner/name, or the immutable repository id when the log carries one.",
10
+ "properties": {
11
+ "by": {
12
+ "enum": [
13
+ "node",
14
+ "run",
15
+ "record",
16
+ "finding",
17
+ "sha"
18
+ ],
19
+ "$comment": "node: a node id; run: a run_id; record: the record handle; finding: a finding fingerprint; sha: a commit sha"
20
+ },
21
+ "value": {
22
+ "type": "string",
23
+ "minLength": 1,
24
+ "maxLength": 512
25
+ },
26
+ "fp_scheme": {
27
+ "type": "string",
28
+ "minLength": 1,
29
+ "$comment": "by: finding only; fingerprints are opaque and only comparable within one scheme. Absent: every scheme, each match tagged with its own"
30
+ },
31
+ "repo": {
32
+ "type": "string",
33
+ "minLength": 1
34
+ },
35
+ "history": {
36
+ "type": "boolean",
37
+ "default": true,
38
+ "$comment": "every close and reopen of each node, not only the current one"
39
+ },
40
+ "changes": {
41
+ "type": "boolean",
42
+ "default": true,
43
+ "$comment": "for an issue, the lineage of each linked change (for[]), one level deep"
44
+ },
45
+ "limit": {
46
+ "type": "integer",
47
+ "minimum": 1,
48
+ "maximum": 100,
49
+ "default": 25
50
+ },
51
+ "after": {
52
+ "type": [
53
+ "string",
54
+ "null"
55
+ ],
56
+ "$comment": "the opaque `next` of a previous page"
57
+ }
58
+ },
59
+ "required": [
60
+ "by",
61
+ "value"
62
+ ],
63
+ "allOf": [
64
+ {
65
+ "if": {
66
+ "required": [
67
+ "fp_scheme"
68
+ ]
69
+ },
70
+ "then": {
71
+ "properties": {
72
+ "by": {
73
+ "const": "finding"
74
+ }
75
+ }
76
+ }
77
+ }
78
+ ]
79
+ },
80
+ "EventRef": {
81
+ "type": "object",
82
+ "$comment": "One log event by position and id, so a caller can fetch and verify it (subscribe, or the shipped segments). policy_version is the stored line's: the policy the event was judged under.",
83
+ "properties": {
84
+ "seq": {
85
+ "type": "integer",
86
+ "minimum": 1
87
+ },
88
+ "id": {
89
+ "type": "string",
90
+ "pattern": "^[0-9a-f]{64}$"
91
+ },
92
+ "w": {
93
+ "type": "string"
94
+ },
95
+ "received_at": {
96
+ "type": "integer",
97
+ "minimum": 0
98
+ },
99
+ "policy_version": {
100
+ "type": [
101
+ "string",
102
+ "null"
103
+ ]
104
+ }
105
+ },
106
+ "required": [
107
+ "seq",
108
+ "id",
109
+ "w",
110
+ "received_at"
111
+ ]
112
+ },
113
+ "Signer": {
114
+ "type": "object",
115
+ "$comment": "Who signed, as the registry said at that event's seq (the log keeps every registry version). member_id is null when the registry entry has none. evaluator is the registry's evaluator entry (its shape is left open here): null for any key that is not an evaluator, which today is every key, since only the system key may sign the pair.",
116
+ "properties": {
117
+ "pubkey": {
118
+ "type": "string",
119
+ "pattern": "^[0-9a-f]{64}$"
120
+ },
121
+ "role": {
122
+ "type": "string",
123
+ "$comment": "agent · person · steward · system · adapter, and the evaluator role or scope of the evaluator route"
124
+ },
125
+ "label": {
126
+ "type": [
127
+ "string",
128
+ "null"
129
+ ]
130
+ },
131
+ "owner": {
132
+ "anyOf": [
133
+ {
134
+ "type": "null"
135
+ },
136
+ {
137
+ "type": "string",
138
+ "pattern": "^[0-9a-f]{64}$"
139
+ }
140
+ ]
141
+ },
142
+ "stage": {
143
+ "type": [
144
+ "string",
145
+ "null"
146
+ ]
147
+ },
148
+ "member_id": {
149
+ "type": [
150
+ "string",
151
+ "null"
152
+ ]
153
+ },
154
+ "evaluator": {
155
+ "type": [
156
+ "object",
157
+ "null"
158
+ ]
159
+ },
160
+ "active_now": {
161
+ "type": "boolean",
162
+ "$comment": "false when the key has since been retired or rotated out; the event stays valid (verified against the registry at its seq)"
163
+ }
164
+ },
165
+ "required": [
166
+ "pubkey",
167
+ "role",
168
+ "active_now"
169
+ ]
170
+ },
171
+ "FindingsSeenRef": {
172
+ "type": "object",
173
+ "allOf": [
174
+ {
175
+ "$ref": "#/$defs/EventRef"
176
+ }
177
+ ],
178
+ "properties": {
179
+ "signer": {
180
+ "$ref": "#/$defs/Signer"
181
+ },
182
+ "run_id": {
183
+ "type": "string"
184
+ },
185
+ "sha": {
186
+ "type": [
187
+ "string",
188
+ "null"
189
+ ]
190
+ },
191
+ "seen": {
192
+ "type": "array",
193
+ "items": {
194
+ "type": "string"
195
+ }
196
+ },
197
+ "gone": {
198
+ "type": "array",
199
+ "items": {
200
+ "type": "string"
201
+ }
202
+ },
203
+ "fp_scheme": {
204
+ "type": "string"
205
+ }
206
+ },
207
+ "required": [
208
+ "signer",
209
+ "run_id",
210
+ "seen",
211
+ "gone",
212
+ "fp_scheme"
213
+ ]
214
+ },
215
+ "EvidenceRef": {
216
+ "type": "object",
217
+ "allOf": [
218
+ {
219
+ "$ref": "#/$defs/EventRef"
220
+ }
221
+ ],
222
+ "properties": {
223
+ "signer": {
224
+ "$ref": "#/$defs/Signer"
225
+ },
226
+ "run_id": {
227
+ "type": "string"
228
+ },
229
+ "record_digest": {
230
+ "type": [
231
+ "string",
232
+ "null"
233
+ ],
234
+ "$comment": "the record handle as the event carries it; null is legal in sharedcontext/1.0 and is flagged record_handle_missing"
235
+ },
236
+ "sha": {
237
+ "type": [
238
+ "string",
239
+ "null"
240
+ ]
241
+ },
242
+ "stage": {
243
+ "type": "string"
244
+ },
245
+ "coverage": {
246
+ "type": "string"
247
+ },
248
+ "confidence": {
249
+ "type": "string"
250
+ },
251
+ "verdicts": {
252
+ "type": "array",
253
+ "items": {
254
+ "$ref": "content.schema.json#/$defs/Verdict"
255
+ }
256
+ }
257
+ },
258
+ "required": [
259
+ "signer",
260
+ "run_id",
261
+ "record_digest",
262
+ "stage",
263
+ "coverage",
264
+ "confidence",
265
+ "verdicts"
266
+ ]
267
+ },
268
+ "Run": {
269
+ "type": "object",
270
+ "$comment": "One run as one node saw it: the findings.seen and evidence.attached events on that node sharing run_id. For an issue both halves make a qualifying run; a change closes on evidence.attached alone, so findings_seen is null there and that is not a flag.",
271
+ "properties": {
272
+ "node": {
273
+ "type": "string"
274
+ },
275
+ "run_id": {
276
+ "type": "string"
277
+ },
278
+ "sha": {
279
+ "type": [
280
+ "string",
281
+ "null"
282
+ ]
283
+ },
284
+ "fp_scheme": {
285
+ "type": [
286
+ "string",
287
+ "null"
288
+ ]
289
+ },
290
+ "record_digests": {
291
+ "type": "array",
292
+ "items": {
293
+ "type": "string"
294
+ },
295
+ "$comment": "the distinct record handles the run's evidence events on this node carry"
296
+ },
297
+ "findings_seen": {
298
+ "anyOf": [
299
+ {
300
+ "type": "null"
301
+ },
302
+ {
303
+ "$ref": "#/$defs/FindingsSeenRef"
304
+ }
305
+ ]
306
+ },
307
+ "evidence_attached": {
308
+ "type": "array",
309
+ "items": {
310
+ "$ref": "#/$defs/EvidenceRef"
311
+ }
312
+ },
313
+ "qualifying": {
314
+ "type": [
315
+ "boolean",
316
+ "null"
317
+ ],
318
+ "$comment": "whether the run met the close rule for this node under the policy in force at its seq; null for a kind with no evidence close"
319
+ },
320
+ "unmet": {
321
+ "type": [
322
+ "string",
323
+ "null"
324
+ ],
325
+ "$comment": "when not qualifying: the close tool's unmet reason"
326
+ }
327
+ },
328
+ "required": [
329
+ "node",
330
+ "run_id",
331
+ "findings_seen",
332
+ "evidence_attached",
333
+ "qualifying"
334
+ ]
335
+ },
336
+ "Close": {
337
+ "type": "object",
338
+ "$comment": "One node.closed and what it rested on. how: evidence (system, with the run that closed it), override (steward, policy_clause), cancel, or other (a close with none of the three, such as a goal's).",
339
+ "properties": {
340
+ "event": {
341
+ "$ref": "#/$defs/EventRef"
342
+ },
343
+ "signer": {
344
+ "$ref": "#/$defs/Signer"
345
+ },
346
+ "outcome": {
347
+ "enum": [
348
+ "done",
349
+ "cancelled",
350
+ "duplicate"
351
+ ]
352
+ },
353
+ "how": {
354
+ "enum": [
355
+ "evidence",
356
+ "override",
357
+ "cancel",
358
+ "other"
359
+ ]
360
+ },
361
+ "current": {
362
+ "type": "boolean",
363
+ "$comment": "true for the close the node is in now (no reopen after it)"
364
+ },
365
+ "evidence": {
366
+ "anyOf": [
367
+ {
368
+ "type": "null"
369
+ },
370
+ {
371
+ "$ref": "content.schema.json#/$defs/CloseEvidence"
372
+ }
373
+ ]
374
+ },
375
+ "run": {
376
+ "anyOf": [
377
+ {
378
+ "type": "null"
379
+ },
380
+ {
381
+ "$ref": "#/$defs/Run"
382
+ }
383
+ ],
384
+ "$comment": "the run named by evidence.run_id, joined on this node"
385
+ },
386
+ "override": {
387
+ "anyOf": [
388
+ {
389
+ "type": "null"
390
+ },
391
+ {
392
+ "$ref": "content.schema.json#/$defs/Override"
393
+ }
394
+ ]
395
+ },
396
+ "cancel": {
397
+ "anyOf": [
398
+ {
399
+ "type": "null"
400
+ },
401
+ {
402
+ "$ref": "content.schema.json#/$defs/Cancel"
403
+ }
404
+ ]
405
+ },
406
+ "closed_at": {
407
+ "anyOf": [
408
+ {
409
+ "type": "null"
410
+ },
411
+ {
412
+ "$ref": "content.schema.json#/$defs/ClosedAt"
413
+ }
414
+ ]
415
+ },
416
+ "merged_into": {
417
+ "type": [
418
+ "string",
419
+ "null"
420
+ ]
421
+ }
422
+ },
423
+ "required": [
424
+ "event",
425
+ "signer",
426
+ "outcome",
427
+ "how",
428
+ "current"
429
+ ]
430
+ },
431
+ "Reopen": {
432
+ "type": "object",
433
+ "properties": {
434
+ "event": {
435
+ "$ref": "#/$defs/EventRef"
436
+ },
437
+ "signer": {
438
+ "$ref": "#/$defs/Signer"
439
+ },
440
+ "cause": {
441
+ "enum": [
442
+ "regression",
443
+ "override_reversed",
444
+ "cancel_reversed"
445
+ ]
446
+ },
447
+ "run": {
448
+ "anyOf": [
449
+ {
450
+ "type": "null"
451
+ },
452
+ {
453
+ "$ref": "#/$defs/Run"
454
+ }
455
+ ],
456
+ "$comment": "for a regression: the run that saw a covered finding again"
457
+ },
458
+ "reason": {
459
+ "type": [
460
+ "string",
461
+ "null"
462
+ ]
463
+ }
464
+ },
465
+ "required": [
466
+ "event",
467
+ "signer",
468
+ "cause"
469
+ ]
470
+ },
471
+ "ChangeLineage": {
472
+ "type": "object",
473
+ "$comment": "A change linked to an issue by its for[]: the merge the change close needs, and its closes.",
474
+ "properties": {
475
+ "node": {
476
+ "type": "string"
477
+ },
478
+ "state": {
479
+ "type": "string"
480
+ },
481
+ "pr": {
482
+ "anyOf": [
483
+ {
484
+ "type": "null"
485
+ },
486
+ {
487
+ "$ref": "content.schema.json#/$defs/PrRef"
488
+ }
489
+ ]
490
+ },
491
+ "head_sha": {
492
+ "type": [
493
+ "string",
494
+ "null"
495
+ ]
496
+ },
497
+ "merge": {
498
+ "anyOf": [
499
+ {
500
+ "type": "null"
501
+ },
502
+ {
503
+ "type": "object",
504
+ "allOf": [
505
+ {
506
+ "$ref": "#/$defs/EventRef"
507
+ }
508
+ ],
509
+ "properties": {
510
+ "head_sha": {
511
+ "type": [
512
+ "string",
513
+ "null"
514
+ ]
515
+ },
516
+ "merge_sha": {
517
+ "type": [
518
+ "string",
519
+ "null"
520
+ ]
521
+ }
522
+ }
523
+ }
524
+ ]
525
+ },
526
+ "closes": {
527
+ "type": "array",
528
+ "items": {
529
+ "$ref": "#/$defs/Close"
530
+ }
531
+ }
532
+ },
533
+ "required": [
534
+ "node",
535
+ "state",
536
+ "closes"
537
+ ]
538
+ },
539
+ "Flag": {
540
+ "type": "object",
541
+ "$comment": "Something the read found but does not decide. A flag never changes the log; rekey_suspect in particular is a suspicion, not a finding.",
542
+ "properties": {
543
+ "code": {
544
+ "enum": [
545
+ "not_found",
546
+ "not_closed",
547
+ "closed_without_evidence",
548
+ "record_handle_missing",
549
+ "record_handle_mismatch",
550
+ "pair_incomplete",
551
+ "pair_sha_mismatch",
552
+ "mixed_signers",
553
+ "signer_not_evaluator",
554
+ "signer_inactive_now",
555
+ "fp_scheme_mismatch",
556
+ "rekey_suspect",
557
+ "covers_moved",
558
+ "repo_unresolved",
559
+ "repo_key_mutable",
560
+ "history_incomplete",
561
+ "truncated"
562
+ ]
563
+ },
564
+ "node": {
565
+ "type": [
566
+ "string",
567
+ "null"
568
+ ]
569
+ },
570
+ "run_id": {
571
+ "type": [
572
+ "string",
573
+ "null"
574
+ ]
575
+ },
576
+ "fp": {
577
+ "type": [
578
+ "string",
579
+ "null"
580
+ ]
581
+ },
582
+ "detail": {
583
+ "type": [
584
+ "object",
585
+ "string",
586
+ "null"
587
+ ]
588
+ }
589
+ },
590
+ "required": [
591
+ "code"
592
+ ]
593
+ },
594
+ "NodeLineage": {
595
+ "type": "object",
596
+ "properties": {
597
+ "node": {
598
+ "type": "string"
599
+ },
600
+ "kind": {
601
+ "type": "string"
602
+ },
603
+ "state": {
604
+ "type": "string"
605
+ },
606
+ "repo": {
607
+ "type": [
608
+ "object",
609
+ "string",
610
+ "null"
611
+ ],
612
+ "$comment": "the node's resolved repository: the repo key, with the immutable repository id beside it when the log carries one"
613
+ },
614
+ "cluster_key": {
615
+ "type": [
616
+ "string",
617
+ "null"
618
+ ]
619
+ },
620
+ "fp_scheme": {
621
+ "type": [
622
+ "string",
623
+ "null"
624
+ ]
625
+ },
626
+ "covers": {
627
+ "type": "array",
628
+ "items": {
629
+ "type": "string"
630
+ }
631
+ },
632
+ "opened_at": {
633
+ "type": [
634
+ "object",
635
+ "null"
636
+ ],
637
+ "$comment": "an issue's {sha, run_id, at}"
638
+ },
639
+ "closes": {
640
+ "type": "array",
641
+ "items": {
642
+ "$ref": "#/$defs/Close"
643
+ }
644
+ },
645
+ "reopens": {
646
+ "type": "array",
647
+ "items": {
648
+ "$ref": "#/$defs/Reopen"
649
+ }
650
+ },
651
+ "changes": {
652
+ "type": "array",
653
+ "items": {
654
+ "$ref": "#/$defs/ChangeLineage"
655
+ }
656
+ },
657
+ "flags": {
658
+ "type": "array",
659
+ "items": {
660
+ "$ref": "#/$defs/Flag"
661
+ }
662
+ }
663
+ },
664
+ "required": [
665
+ "node",
666
+ "kind",
667
+ "state",
668
+ "closes",
669
+ "reopens",
670
+ "changes",
671
+ "flags"
672
+ ]
673
+ },
674
+ "LineageResult": {
675
+ "type": "object",
676
+ "$comment": "The answer, as of one seq of one org's log. nodes: every node the key leads to, with its closes and reopens. runs: for by run, record, finding and sha, every (run, node) the key matched, closing or not. flags: what the read noticed at query level (not_found, truncated, history_incomplete). org_id is null when project.created carries none.",
677
+ "properties": {
678
+ "as_of_seq": {
679
+ "type": "integer",
680
+ "minimum": 0
681
+ },
682
+ "project": {
683
+ "type": "string"
684
+ },
685
+ "org_id": {
686
+ "type": [
687
+ "string",
688
+ "null"
689
+ ]
690
+ },
691
+ "query": {
692
+ "$ref": "#/$defs/LineageArgs"
693
+ },
694
+ "nodes": {
695
+ "type": "array",
696
+ "items": {
697
+ "$ref": "#/$defs/NodeLineage"
698
+ }
699
+ },
700
+ "runs": {
701
+ "type": "array",
702
+ "items": {
703
+ "$ref": "#/$defs/Run"
704
+ }
705
+ },
706
+ "flags": {
707
+ "type": "array",
708
+ "items": {
709
+ "$ref": "#/$defs/Flag"
710
+ }
711
+ },
712
+ "next": {
713
+ "type": [
714
+ "string",
715
+ "null"
716
+ ]
717
+ }
718
+ },
719
+ "required": [
720
+ "as_of_seq",
721
+ "project",
722
+ "org_id",
723
+ "query",
724
+ "nodes",
725
+ "runs",
726
+ "flags",
727
+ "next"
728
+ ]
729
+ },
730
+ "tool.lineage": {
731
+ "type": "object",
732
+ "$comment": "read only; scope tickets:read. Refusals as every tool's (mcp-tools.schema.json Refusal): node_not_found for by node, bad_arguments, project_not_created. Any other key that leads nowhere is an answer with the flag not_found, not a refusal",
733
+ "properties": {
734
+ "name": {
735
+ "const": "lineage"
736
+ },
737
+ "arguments": {
738
+ "$ref": "#/$defs/LineageArgs"
739
+ },
740
+ "result": {
741
+ "anyOf": [
742
+ {
743
+ "$ref": "#/$defs/LineageResult"
744
+ },
745
+ {
746
+ "$ref": "mcp-tools.schema.json#/$defs/Refusal"
747
+ }
748
+ ]
749
+ }
750
+ }
751
+ }
752
+ }
753
+ }