@sharedcontext/sdk 0.0.0-stage → 0.3.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.
- package/LICENSE-APACHE +201 -0
- package/LICENSE-MIT +21 -0
- package/NOTICE +8 -0
- package/README.md +94 -2
- package/dist/canonical.d.ts +47 -0
- package/dist/canonical.js +257 -0
- package/dist/client.d.ts +96 -0
- package/dist/client.js +205 -0
- package/dist/constants.d.ts +19 -0
- package/dist/constants.js +21 -0
- package/dist/event.d.ts +104 -0
- package/dist/event.js +173 -0
- package/dist/generated/content.d.ts +588 -0
- package/dist/generated/content.js +3 -0
- package/dist/generated/schemas.d.ts +10 -0
- package/dist/generated/schemas.js +22 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +8 -0
- package/dist/reasons.d.ts +14 -0
- package/dist/reasons.js +142 -0
- package/dist/schema.d.ts +45 -0
- package/dist/schema.js +285 -0
- package/dist/types.d.ts +230 -0
- package/dist/types.js +3 -0
- package/package.json +46 -4
- package/schemas/sharedcontext-1/changes.schema.json +128 -0
- package/schemas/sharedcontext-1/content.schema.json +2076 -0
- package/schemas/sharedcontext-1/context.schema.json +218 -0
- package/schemas/sharedcontext-1/event.schema.json +55 -0
- package/schemas/sharedcontext-1/execution.schema.json +342 -0
- package/schemas/sharedcontext-1/history/content-1.0.schema.json +1915 -0
- package/schemas/sharedcontext-1/lineage.schema.json +753 -0
- package/schemas/sharedcontext-1/mcp-tools.schema.json +1357 -0
- package/schemas/sharedcontext-1/stored-event.schema.json +14 -0
- package/schemas/sharedcontext-directory-1/members.schema.json +52 -0
- package/schemas/sharedcontext-directory-1/memberships.schema.json +32 -0
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"title": "sharedcontext/1.6, context provenance and lessons",
|
|
4
|
+
"$comment": "sharedcontext/1.6, an additive minor of sharedcontext/1, built on the execution vocabulary (execution.schema.json, sharedcontext/1.5): the lesson shape and the attempts are that minor's. Holds what this minor adds: context.pinned with lesson and unpin (who: person and steward only), the context bundle pinned field by field with each item's provenance (signer, role, verified, untrusted), the pinned lessons, the lesson candidates, the node's attempts and a size budget, and the policy param for the budget. context.pinned copies 1.0's definition and adds to it. The bundle is the answer of context(node), and what an execution gateway may hand a job; 1.0 leaves it unpinned (mcp-tools.schema.json FoldedView). Every addition to it is a new key, so a body that reads today's bundle reads this one. Served only with the policy switch context.provenance on (crates/sharedcontext/src/work/context.rs). Checked by contract-check.mjs against cases/context.cases.jsonl and against the bundles the code serves (crates/sharedcontext/tests/work/context/bundles.jsonl). Not yet merged into content.schema.json and mcp-tools.schema.json.",
|
|
5
|
+
"$defs": {
|
|
6
|
+
"EventId": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
|
|
7
|
+
"Pubkey": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
|
|
8
|
+
"Role": { "enum": ["agent", "person", "steward", "system", "adapter"], "$comment": "the registry version in force at the item's seq" },
|
|
9
|
+
"Provenance": {
|
|
10
|
+
"type": "object",
|
|
11
|
+
"$comment": "Who wrote an item of the bundle and how far to trust it. signer, role and sponsor come from the event that wrote the item and the registry version in force at its seq. verified: the log checked the content, or the system signed it from a qualifying source (evidence.attached, findings.seen, measure.observed); authored text is never verified, whoever signed it. untrusted: the text is data, never instructions: written by an agent or an adapter key, a node's title or body whose origin is outside (origin.source adapter or run: a customer's ticket, an evaluator's finding), or a note the system signed (the system only relays or rolls up text others wrote). The shape holds two of these rules: an agent's or an adapter's item is untrusted, and only the system's is verified.",
|
|
12
|
+
"properties": {
|
|
13
|
+
"signer": { "$ref": "#/$defs/Pubkey" },
|
|
14
|
+
"role": { "$ref": "#/$defs/Role" },
|
|
15
|
+
"sponsor": { "anyOf": [{ "type": "null" }, { "$ref": "#/$defs/Pubkey" }], "$comment": "for an agent, the registry owner (its human sponsor); null for anyone else" },
|
|
16
|
+
"event": { "$ref": "#/$defs/EventId" },
|
|
17
|
+
"seq": { "type": "integer", "minimum": 1 },
|
|
18
|
+
"verified": { "type": "boolean" },
|
|
19
|
+
"untrusted": { "type": "boolean" }
|
|
20
|
+
},
|
|
21
|
+
"required": ["signer", "role", "event", "seq", "verified", "untrusted"],
|
|
22
|
+
"allOf": [
|
|
23
|
+
{
|
|
24
|
+
"if": { "properties": { "role": { "enum": ["agent", "adapter"] } }, "required": ["role"] },
|
|
25
|
+
"then": { "properties": { "untrusted": { "const": true } } },
|
|
26
|
+
"$comment": "an agent's or an adapter's item is untrusted, always"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"if": { "properties": { "verified": { "const": true } }, "required": ["verified"] },
|
|
30
|
+
"then": { "properties": { "role": { "const": "system" } } },
|
|
31
|
+
"$comment": "only the system's content is verified (evidence, findings, measures)"
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
},
|
|
35
|
+
"context.pinned": {
|
|
36
|
+
"type": "object",
|
|
37
|
+
"additionalProperties": false,
|
|
38
|
+
"$comment": "sharedcontext/1.6: 1.0's context.pinned plus lesson (the event id of a note.added{layer: lesson} anywhere in this log) and unpin. A pin with lesson pins that lesson on n: it flows down to n's descendants whose kind and labels match its scope, as pinned context does. With unpin: true it ends that lesson's pin on n. Who: person and steward only (policy who[\"context.pinned:lesson\"]); an agent's pin with lesson is refused role_not_allowed, and no sponsor or permit lifts it: Policy::grantable answers false for context.pinned:lesson whatever the who row of context.pinned says. A policy document that lists any role but person and steward under context.pinned:lesson is a policy load error, and a project.policy_set carrying it is refused (invalid_value), so no policy widens it. A sandboxed body's pin is signed by the gateway as the hosted agent, so it is refused like any agent's (crates/sharedcontext/tests/work/context/pin-rules.jsonl). Log rules (not shape): lesson names a lesson note of this log (invalid_value); unpin only of a lesson pinned on n (invalid_value). text is the pinner's own note on why, and is the pinner's (trusted when a person or steward signs it). An older log refuses lesson and unpin (unknown_field).",
|
|
39
|
+
"properties": {
|
|
40
|
+
"text": { "type": ["string", "null"] },
|
|
41
|
+
"blob": { "anyOf": [{ "type": "null" }, { "$ref": "content.schema.json#/$defs/Blob" }] },
|
|
42
|
+
"supersedes": { "type": ["string", "null"] },
|
|
43
|
+
"session": { "anyOf": [{ "type": "null" }, { "$ref": "content.schema.json#/$defs/SessionRef" }] },
|
|
44
|
+
"lesson": { "anyOf": [{ "type": "null" }, { "$ref": "#/$defs/EventId" }] },
|
|
45
|
+
"unpin": { "type": ["boolean", "null"] }
|
|
46
|
+
},
|
|
47
|
+
"allOf": [
|
|
48
|
+
{
|
|
49
|
+
"if": { "required": ["unpin"], "properties": { "unpin": { "const": true } } },
|
|
50
|
+
"then": { "required": ["lesson"], "properties": { "lesson": { "$ref": "#/$defs/EventId" } } },
|
|
51
|
+
"$comment": "unpin names the lesson it ends"
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
},
|
|
55
|
+
"policy.context": {
|
|
56
|
+
"type": "object",
|
|
57
|
+
"$comment": "Policy param: the size budget of the bundle served for a claim (context(node) for a claimant, or the bundle an execution gateway hands a job), as the bytes of its canonical JSON. In project.policy_set{params: {context}}, steward-signed, read by the service's context read and ignored by the fold. Default max_bytes 65536; max_bytes_by_intent overrides it per claim intent. A node's own facts, pins by people and stewards, pinned lessons and the evidence slice are never cut.",
|
|
58
|
+
"properties": {
|
|
59
|
+
"max_bytes": { "type": "integer", "minimum": 4096, "maximum": 1048576 },
|
|
60
|
+
"max_bytes_by_intent": {
|
|
61
|
+
"type": "object",
|
|
62
|
+
"properties": {
|
|
63
|
+
"fix": { "type": "integer", "minimum": 4096, "maximum": 1048576 },
|
|
64
|
+
"triage": { "type": "integer", "minimum": 4096, "maximum": 1048576 },
|
|
65
|
+
"review": { "type": "integer", "minimum": 4096, "maximum": 1048576 },
|
|
66
|
+
"verify": { "type": "integer", "minimum": 4096, "maximum": 1048576 }
|
|
67
|
+
},
|
|
68
|
+
"additionalProperties": false
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
"required": ["max_bytes"],
|
|
72
|
+
"additionalProperties": false
|
|
73
|
+
},
|
|
74
|
+
"PinnedItem": {
|
|
75
|
+
"type": "object",
|
|
76
|
+
"$comment": "1.0's pinned entry (crates/sharedcontext/src/work/reads.rs pinned_context: node, text, blob, by, event, pin) plus provenance",
|
|
77
|
+
"properties": {
|
|
78
|
+
"node": { "type": "string" },
|
|
79
|
+
"text": { "type": ["string", "null"] },
|
|
80
|
+
"blob": { "anyOf": [{ "type": "null" }, { "$ref": "content.schema.json#/$defs/Blob" }] },
|
|
81
|
+
"by": { "$ref": "#/$defs/Pubkey" },
|
|
82
|
+
"event": { "$ref": "#/$defs/EventId" },
|
|
83
|
+
"pin": { "type": "boolean" },
|
|
84
|
+
"provenance": { "$ref": "#/$defs/Provenance" }
|
|
85
|
+
},
|
|
86
|
+
"required": ["node", "by", "event", "provenance"]
|
|
87
|
+
},
|
|
88
|
+
"NoteItem": {
|
|
89
|
+
"type": "object",
|
|
90
|
+
"$comment": "1.0's working note entry (text, by, seq) plus event and provenance",
|
|
91
|
+
"properties": {
|
|
92
|
+
"text": { "type": ["string", "null"] },
|
|
93
|
+
"by": { "$ref": "#/$defs/Pubkey" },
|
|
94
|
+
"seq": { "type": "integer", "minimum": 1 },
|
|
95
|
+
"event": { "$ref": "#/$defs/EventId" },
|
|
96
|
+
"provenance": { "$ref": "#/$defs/Provenance" }
|
|
97
|
+
},
|
|
98
|
+
"required": ["by", "seq", "provenance"]
|
|
99
|
+
},
|
|
100
|
+
"SummaryItem": {
|
|
101
|
+
"type": "object",
|
|
102
|
+
"$comment": "1.0's child summary entry (node, kind, title, state, summary) plus the provenance of the summary and of the title",
|
|
103
|
+
"properties": {
|
|
104
|
+
"node": { "type": "string" },
|
|
105
|
+
"kind": { "type": "string" },
|
|
106
|
+
"title": { "type": ["string", "null"] },
|
|
107
|
+
"state": { "type": "string" },
|
|
108
|
+
"summary": {},
|
|
109
|
+
"provenance": { "anyOf": [{ "type": "null" }, { "$ref": "#/$defs/Provenance" }], "$comment": "of the summary; null when the child has none" },
|
|
110
|
+
"title_provenance": { "$ref": "#/$defs/Provenance" }
|
|
111
|
+
},
|
|
112
|
+
"required": ["node", "kind", "state", "provenance", "title_provenance"]
|
|
113
|
+
},
|
|
114
|
+
"LessonItem": {
|
|
115
|
+
"type": "object",
|
|
116
|
+
"$comment": "a lesson in the bundle: the lesson note (its provenance: an agent's text is untrusted even when pinned) and, for a pinned lesson, the pin (pinned_by: a person or steward)",
|
|
117
|
+
"properties": {
|
|
118
|
+
"note": { "$ref": "#/$defs/EventId" },
|
|
119
|
+
"node": { "type": "string", "$comment": "where the lesson note was written" },
|
|
120
|
+
"lesson": { "$ref": "execution.schema.json#/$defs/Lesson" },
|
|
121
|
+
"provenance": { "$ref": "#/$defs/Provenance" },
|
|
122
|
+
"pinned_on": { "type": ["string", "null"], "$comment": "the node the pin is on (this node or an ancestor); null for a candidate" },
|
|
123
|
+
"pinned_by": { "anyOf": [{ "type": "null" }, { "allOf": [{ "$ref": "#/$defs/Provenance" }, { "properties": { "role": { "enum": ["person", "steward"] } } }] }], "$comment": "the pin's provenance: a person or a steward only" }
|
|
124
|
+
},
|
|
125
|
+
"required": ["note", "node", "lesson", "provenance", "pinned_on", "pinned_by"]
|
|
126
|
+
},
|
|
127
|
+
"AttemptItem": {
|
|
128
|
+
"type": "object",
|
|
129
|
+
"$comment": "one attempt on this node or in a run whose claim is on this node, newest first: what an agent learns from before it tries again",
|
|
130
|
+
"properties": {
|
|
131
|
+
"run": { "$ref": "#/$defs/EventId" },
|
|
132
|
+
"step": { "type": "string" },
|
|
133
|
+
"round": { "type": "integer", "minimum": 1 },
|
|
134
|
+
"node": { "type": "string" },
|
|
135
|
+
"outcome": { "anyOf": [{ "type": "null" }, { "enum": ["completed", "failed", "budget_exceeded", "cancelled", "abandoned"] }], "$comment": "null while running" },
|
|
136
|
+
"record": { "anyOf": [{ "type": "null" }, { "$ref": "content.schema.json#/$defs/Blob" }] },
|
|
137
|
+
"reasons": { "type": "array", "items": { "type": "string" } },
|
|
138
|
+
"provenance": { "$ref": "#/$defs/Provenance", "$comment": "of attempt.ended (or attempt.started while running)" }
|
|
139
|
+
},
|
|
140
|
+
"required": ["run", "step", "round", "node", "outcome", "provenance"]
|
|
141
|
+
},
|
|
142
|
+
"EvidenceItem": {
|
|
143
|
+
"type": "object",
|
|
144
|
+
"$comment": "1.0's evidence slice entry (run_id, sha, stage, coverage, confidence, record_digest, deviations) plus provenance (system, verified)",
|
|
145
|
+
"properties": {
|
|
146
|
+
"run_id": { "type": "string" },
|
|
147
|
+
"sha": { "type": ["string", "null"] },
|
|
148
|
+
"stage": { "type": ["string", "null"] },
|
|
149
|
+
"coverage": { "type": ["string", "null"] },
|
|
150
|
+
"confidence": { "type": ["string", "null"] },
|
|
151
|
+
"record_digest": { "type": ["string", "null"] },
|
|
152
|
+
"deviations": { "type": ["integer", "null"], "minimum": 0, "$comment": "the fold's count of deviation verdicts (EvidenceObs.deviations, u32)" },
|
|
153
|
+
"provenance": { "$ref": "#/$defs/Provenance" }
|
|
154
|
+
},
|
|
155
|
+
"required": ["run_id", "provenance"]
|
|
156
|
+
},
|
|
157
|
+
"GoalItem": {
|
|
158
|
+
"type": "object",
|
|
159
|
+
"$comment": "one goal the node serves, directly or through an ancestor (crates/sharedcontext/src/work/reads.rs context_at: the goal's summary, via, pinned, measures). The goal's own fields stay lenient; its pins are the pins on the goal node, each a PinnedItem with provenance. Agents may pin on goals (who[\"context.pinned\"] is agent, person, steward, and the goal guards do not cover pins), so an agent's goal pin reaches every node that serves the goal: it arrives marked untrusted, and it is cut with agents' pins",
|
|
160
|
+
"properties": {
|
|
161
|
+
"pinned": { "type": "array", "items": { "$ref": "#/$defs/PinnedItem" } }
|
|
162
|
+
},
|
|
163
|
+
"required": ["pinned"]
|
|
164
|
+
},
|
|
165
|
+
"Budget": {
|
|
166
|
+
"type": "object",
|
|
167
|
+
"$comment": "The size budget this bundle was cut to (policy.context), its size as canonical JSON, and what was cut by section; over is true when the parts never cut exceed the budget on their own (served whole, never truncated further)",
|
|
168
|
+
"properties": {
|
|
169
|
+
"max_bytes": { "type": "integer", "minimum": 0 },
|
|
170
|
+
"bytes": { "type": "integer", "minimum": 0 },
|
|
171
|
+
"over": { "type": "boolean" },
|
|
172
|
+
"cut": {
|
|
173
|
+
"type": "array",
|
|
174
|
+
"items": {
|
|
175
|
+
"type": "object",
|
|
176
|
+
"properties": {
|
|
177
|
+
"section": { "enum": ["lesson_candidates", "working_notes", "attempts", "children_summaries", "pinned", "goal_pins"] },
|
|
178
|
+
"dropped": { "type": "integer", "minimum": 1 },
|
|
179
|
+
"kept": { "type": "integer", "minimum": 0 }
|
|
180
|
+
},
|
|
181
|
+
"required": ["section", "dropped", "kept"]
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
"required": ["max_bytes", "bytes", "over", "cut"]
|
|
186
|
+
},
|
|
187
|
+
"ContextBundle": {
|
|
188
|
+
"type": "object",
|
|
189
|
+
"$comment": "context(node) with provenance. The 1.0 keys keep their names and meaning (crates/sharedcontext/src/work/reads.rs context_at: node, goals, ancestors, pinned, working_notes, children_summaries, done_blockers, open_blockers, gate, evidence_slice, declaration_ref, linked_changes); new keys: node_provenance, lessons, lesson_candidates, attempts, at_seq, budget. node stays lenient (the folded view, unpinned in 1.0); a goal keeps its own fields lenient and its pins carry provenance (GoalItem). The fold's derived facts (state, gate, claim, blockers, linked changes) are the log's own and carry no provenance.",
|
|
190
|
+
"properties": {
|
|
191
|
+
"node": { "type": "object" },
|
|
192
|
+
"node_provenance": {
|
|
193
|
+
"type": "object",
|
|
194
|
+
"properties": { "title": { "$ref": "#/$defs/Provenance" }, "body": { "anyOf": [{ "type": "null" }, { "$ref": "#/$defs/Provenance" }] } },
|
|
195
|
+
"required": ["title", "body"],
|
|
196
|
+
"$comment": "of the last event that wrote the node's title and body (node.created, or node.updated for that field)"
|
|
197
|
+
},
|
|
198
|
+
"goals": { "type": "array", "items": { "$ref": "#/$defs/GoalItem" } },
|
|
199
|
+
"ancestors": { "type": "array", "items": { "type": "string" } },
|
|
200
|
+
"pinned": { "type": "array", "items": { "$ref": "#/$defs/PinnedItem" } },
|
|
201
|
+
"lessons": { "type": "array", "items": { "$ref": "#/$defs/LessonItem" }, "$comment": "pinned lessons in force here: pinned on this node or an ancestor, scope matching this node; each with pinned_by" },
|
|
202
|
+
"lesson_candidates": { "type": "array", "items": { "$ref": "#/$defs/LessonItem" }, "$comment": "unpinned lesson notes written on this node only; pinned_on and pinned_by null" },
|
|
203
|
+
"working_notes": { "type": "array", "items": { "$ref": "#/$defs/NoteItem" } },
|
|
204
|
+
"children_summaries": { "type": "array", "items": { "$ref": "#/$defs/SummaryItem" } },
|
|
205
|
+
"attempts": { "type": "array", "items": { "$ref": "#/$defs/AttemptItem" } },
|
|
206
|
+
"done_blockers": { "type": "array" },
|
|
207
|
+
"open_blockers": { "type": "array" },
|
|
208
|
+
"gate": {},
|
|
209
|
+
"evidence_slice": { "type": "array", "items": { "$ref": "#/$defs/EvidenceItem" } },
|
|
210
|
+
"declaration_ref": { "type": ["string", "null"] },
|
|
211
|
+
"linked_changes": {},
|
|
212
|
+
"at_seq": { "type": "integer", "minimum": 0, "$comment": "the head seq the bundle was read at" },
|
|
213
|
+
"budget": { "$ref": "#/$defs/Budget" }
|
|
214
|
+
},
|
|
215
|
+
"required": ["node", "node_provenance", "ancestors", "pinned", "lessons", "lesson_candidates", "working_notes", "children_summaries", "attempts", "evidence_slice", "at_seq", "budget"]
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"title": "sharedcontext/1 event envelope",
|
|
4
|
+
"description": "One work event: a plain NIP-01 event of kind 7411, signed (BIP-340) by its own actor's key. Tags: w = the event type (with a dot), j = the project, c = the client id (idempotency, at most 64 bytes), v = the schema major, n = the node (every type except project.* and cost.recorded); e (causal reference) and p (counterparty) where a type uses them. Unknown single-letter tags are ignored. content is the event's payload as canonical JSON (content.schema.json, keyed by the w tag).",
|
|
5
|
+
"$comment": "Source: crates/sharedcontext/src/signed/event.rs: struct Event (deny_unknown_fields: id, pubkey, created_at, kind, tags, content, sig), TICKET_KIND = 7411, TYPE_TAG = w, SCHEMA_MAJOR = 1, CLIENT_ID_MAX = 64, Event::verify_shape (tag rules, required tags, node_tag_optional) and check_canonical_content. Beyond this schema, the log checks: id = sha256 of the NIP-01 serialization, the BIP-340 signature, created_at <= received_at + 900 (FUTURE_SKEW_S), c at most 64 bytes (this schema counts characters), canonical content (keys sorted bytewise at every level, no whitespace, integers never spelled as floats), then the log's rules (crates/sharedcontext/src/work/log.rs). contract-check.mjs adds the id and canonical-content checks; it does not verify signatures.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"additionalProperties": false,
|
|
8
|
+
"required": ["id", "pubkey", "created_at", "kind", "tags", "content", "sig"],
|
|
9
|
+
"properties": {
|
|
10
|
+
"id": { "type": "string", "pattern": "^[0-9a-f]{64}$", "$comment": "sha256 of [0, pubkey, created_at, kind, tags, content] (event.rs serialize_nip01, event_id)" },
|
|
11
|
+
"pubkey": { "type": "string", "pattern": "^[0-9a-f]{64}$", "$comment": "x-only public key of the signer" },
|
|
12
|
+
"created_at": { "type": "integer", "minimum": 0, "$comment": "unix seconds; informational, the log orders by seq" },
|
|
13
|
+
"kind": { "const": 7411, "$comment": "TICKET_KIND; any other kind is wrong_kind" },
|
|
14
|
+
"tags": {
|
|
15
|
+
"type": "array",
|
|
16
|
+
"items": {
|
|
17
|
+
"type": "array",
|
|
18
|
+
"minItems": 2,
|
|
19
|
+
"prefixItems": [
|
|
20
|
+
{ "type": "string", "pattern": "^[A-Za-z]$" },
|
|
21
|
+
{ "type": "string", "minLength": 1 }
|
|
22
|
+
],
|
|
23
|
+
"items": { "type": "string" },
|
|
24
|
+
"$comment": "every tag name is one ASCII letter with a non-empty value, else bad_tag (verify_shape)"
|
|
25
|
+
},
|
|
26
|
+
"allOf": [
|
|
27
|
+
{ "contains": { "$ref": "#/$defs/tagW" }, "$comment": "w required, with a dot (missing_tag, bad_tag)" },
|
|
28
|
+
{ "contains": { "$ref": "#/$defs/tagJ" }, "$comment": "j required" },
|
|
29
|
+
{ "contains": { "$ref": "#/$defs/tagC" }, "$comment": "c required, at most 64 bytes" },
|
|
30
|
+
{ "contains": { "$ref": "#/$defs/tagV" }, "$comment": "v required; this reader understands major 1 only (unsupported_schema_major)" },
|
|
31
|
+
{
|
|
32
|
+
"if": { "contains": { "$ref": "#/$defs/tagWNodeOptional" } },
|
|
33
|
+
"then": true,
|
|
34
|
+
"else": { "contains": { "$ref": "#/$defs/tagN" } },
|
|
35
|
+
"$comment": "n required unless w starts with project. or is cost.recorded (node_tag_optional)"
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
},
|
|
39
|
+
"content": {
|
|
40
|
+
"type": "string",
|
|
41
|
+
"contentMediaType": "application/json",
|
|
42
|
+
"contentSchema": { "$ref": "content.schema.json" },
|
|
43
|
+
"$comment": "canonical JSON object; validated per type by content.schema.json (contract-check.mjs applies it by the w tag)"
|
|
44
|
+
},
|
|
45
|
+
"sig": { "type": "string", "pattern": "^[0-9a-f]{128}$", "$comment": "BIP-340 Schnorr signature over id" }
|
|
46
|
+
},
|
|
47
|
+
"$defs": {
|
|
48
|
+
"tagW": { "type": "array", "prefixItems": [{ "const": "w" }, { "type": "string", "pattern": "^[^.]+\\..+$" }], "minItems": 2 },
|
|
49
|
+
"tagWNodeOptional": { "type": "array", "prefixItems": [{ "const": "w" }, { "type": "string", "pattern": "^(project\\..*|cost\\.recorded)$" }], "minItems": 2 },
|
|
50
|
+
"tagJ": { "type": "array", "prefixItems": [{ "const": "j" }, { "type": "string", "minLength": 1 }], "minItems": 2 },
|
|
51
|
+
"tagC": { "type": "array", "prefixItems": [{ "const": "c" }, { "type": "string", "minLength": 1, "maxLength": 64 }], "minItems": 2 },
|
|
52
|
+
"tagV": { "type": "array", "prefixItems": [{ "const": "v" }, { "const": "1" }], "minItems": 2 },
|
|
53
|
+
"tagN": { "type": "array", "prefixItems": [{ "const": "n" }, { "type": "string", "minLength": 1 }], "minItems": 2 }
|
|
54
|
+
}
|
|
55
|
+
}
|