@ixo/topic-protocol 1.0.0-rc.4 → 1.0.0-rc.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/README.md +9 -0
  2. package/dist/schemas/v2/capsule.schema.json +29 -0
  3. package/dist/schemas/v2/common.schema.json +68 -0
  4. package/dist/schemas/v2/operation.schema.json +308 -0
  5. package/dist/schemas/v2/projection.schema.json +205 -0
  6. package/dist/schemas/v2/record.schema.json +56 -0
  7. package/dist/schemas/v2/topic.schema.json +84 -0
  8. package/dist/src/shapes/canonical.js +3 -2
  9. package/dist/src/shapes/canonical.js.map +1 -1
  10. package/dist/src/shapes/progress.js +14 -1
  11. package/dist/src/shapes/progress.js.map +1 -1
  12. package/dist/src/v2/canonical.d.ts +3 -0
  13. package/dist/src/v2/canonical.js +25 -0
  14. package/dist/src/v2/canonical.js.map +1 -0
  15. package/dist/src/v2/capsule.d.ts +10 -0
  16. package/dist/src/v2/capsule.js +46 -0
  17. package/dist/src/v2/capsule.js.map +1 -0
  18. package/dist/src/v2/compat.d.ts +14 -0
  19. package/dist/src/v2/compat.js +96 -0
  20. package/dist/src/v2/compat.js.map +1 -0
  21. package/dist/src/v2/ids.d.ts +3 -0
  22. package/dist/src/v2/ids.js +11 -0
  23. package/dist/src/v2/ids.js.map +1 -0
  24. package/dist/src/v2/index.d.ts +9 -0
  25. package/dist/src/v2/index.js +9 -0
  26. package/dist/src/v2/index.js.map +1 -0
  27. package/dist/src/v2/matrix.d.ts +46 -0
  28. package/dist/src/v2/matrix.js +151 -0
  29. package/dist/src/v2/matrix.js.map +1 -0
  30. package/dist/src/v2/project.d.ts +14 -0
  31. package/dist/src/v2/project.js +268 -0
  32. package/dist/src/v2/project.js.map +1 -0
  33. package/dist/src/v2/types.d.ts +195 -0
  34. package/dist/src/v2/types.js +19 -0
  35. package/dist/src/v2/types.js.map +1 -0
  36. package/dist/src/v2/validate.d.ts +650 -0
  37. package/dist/src/v2/validate.js +45 -0
  38. package/dist/src/v2/validate.js.map +1 -0
  39. package/package.json +7 -1
package/README.md CHANGED
@@ -24,6 +24,15 @@ security gates have passed. In particular, complete cold-cache thread discovery,
24
24
  E2EE agent participation, encrypted index migration, UCAN replay protection,
25
25
  and external action execution require their dedicated conformance evidence.
26
26
 
27
+ ## Protocol 2.0 draft
28
+
29
+ `@ixo/topic-protocol/v2` exports a draft of the simplified core recommended in the
30
+ [Topics audit](docs/audit/topics-model-audit.md): five fields, one status, typed
31
+ records, one projector, and a small capsule. It is specified in
32
+ [Topic Protocol 2.0](docs/protocol-2/README.md). Protocol 1.x (rc.4) is frozen for
33
+ existing Topics and remains the package root export; nothing below this section
34
+ changes for 1.x consumers.
35
+
27
36
  ## Read this first
28
37
 
29
38
  - [Architecture decisions](docs/adr/README.md)
@@ -0,0 +1,29 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://topic-protocol.ixo.world/schemas/v2/capsule.schema.json",
4
+ "title": "Topic capsule (Protocol 2.0)",
5
+ "description": "The bounded context handed to an agent: the current projection, the most recent thread messages, and one plain-language hint about what would move the Topic forward.",
6
+ "type": "object",
7
+ "required": ["version", "topic", "messages", "hint"],
8
+ "properties": {
9
+ "version": { "const": 2 },
10
+ "topic": { "$ref": "projection.schema.json" },
11
+ "messages": {
12
+ "type": "array",
13
+ "maxItems": 50,
14
+ "items": {
15
+ "type": "object",
16
+ "required": ["eventId", "sender", "body", "at"],
17
+ "properties": {
18
+ "eventId": { "$ref": "common.schema.json#/$defs/eventId" },
19
+ "sender": { "$ref": "common.schema.json#/$defs/actor" },
20
+ "body": { "type": "string" },
21
+ "at": { "$ref": "common.schema.json#/$defs/dateTime" }
22
+ },
23
+ "additionalProperties": false
24
+ }
25
+ },
26
+ "hint": { "type": "string", "minLength": 1 }
27
+ },
28
+ "additionalProperties": false
29
+ }
@@ -0,0 +1,68 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://topic-protocol.ixo.world/schemas/v2/common.schema.json",
4
+ "title": "Topic Protocol 2.0 shared definitions",
5
+ "$defs": {
6
+ "topicId": { "type": "string", "pattern": "^ixo:topic:[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$" },
7
+ "eventId": { "type": "string", "minLength": 1 },
8
+ "actor": { "type": "string", "minLength": 1 },
9
+ "dateTime": { "type": "string", "format": "date-time" },
10
+ "text": { "type": "string", "minLength": 1, "maxLength": 2000 },
11
+ "title": { "type": "string", "minLength": 1, "maxLength": 200 },
12
+ "kind": {
13
+ "type": "string",
14
+ "oneOf": [
15
+ { "enum": ["discussion", "question", "task", "project"] },
16
+ { "pattern": "^(?!ixo\\.)[a-z][a-z0-9-]*(\\.[a-z][a-z0-9-]*)+$" }
17
+ ]
18
+ },
19
+ "baseKind": { "type": "string", "enum": ["discussion", "question", "task", "project"] },
20
+ "status": { "type": "string", "enum": ["open", "active", "waiting", "done", "dropped"] },
21
+ "recordType": { "type": "string", "enum": ["decision", "outcome", "artifact", "receipt"] },
22
+ "relation": { "type": "string", "enum": ["branches_from", "merged_into", "redirects_to", "references"] },
23
+ "ref": {
24
+ "type": "object",
25
+ "required": ["type", "id"],
26
+ "properties": {
27
+ "type": { "type": "string", "pattern": "^[a-z][a-z0-9-]*(\\.[a-z][a-z0-9-]*)+$" },
28
+ "id": { "type": "string", "minLength": 1 }
29
+ },
30
+ "additionalProperties": false
31
+ },
32
+ "file": {
33
+ "type": "object",
34
+ "required": ["provider", "resource", "fileId", "version", "cid", "name"],
35
+ "properties": {
36
+ "provider": { "const": "ixo.vfs" },
37
+ "resource": { "type": "string", "minLength": 1 },
38
+ "fileId": { "type": "string", "minLength": 1 },
39
+ "version": { "type": "integer", "minimum": 1 },
40
+ "cid": { "type": "string", "minLength": 1 },
41
+ "name": { "type": "string", "minLength": 1 },
42
+ "mimeType": { "type": "string", "minLength": 1 },
43
+ "size": { "type": "integer", "minimum": 0 }
44
+ },
45
+ "additionalProperties": false
46
+ },
47
+ "block": {
48
+ "type": "object",
49
+ "required": ["reason", "by", "since"],
50
+ "properties": {
51
+ "reason": { "$ref": "#/$defs/text" },
52
+ "on": { "type": "string", "minLength": 1 },
53
+ "by": { "$ref": "#/$defs/actor" },
54
+ "since": { "$ref": "#/$defs/dateTime" }
55
+ },
56
+ "additionalProperties": false
57
+ },
58
+ "anchor": {
59
+ "type": "object",
60
+ "required": ["roomId", "rootEventId"],
61
+ "properties": {
62
+ "roomId": { "type": "string", "pattern": "^!.+" },
63
+ "rootEventId": { "type": "string", "pattern": "^\\$.+" }
64
+ },
65
+ "additionalProperties": false
66
+ }
67
+ }
68
+ }
@@ -0,0 +1,308 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://topic-protocol.ixo.world/schemas/v2/operation.schema.json",
4
+ "title": "Topic operation (Protocol 2.0)",
5
+ "description": "An append-only change to a Topic. Operations carry no revision pointer; the projector orders them by createdAt then id and applies last-writer-wins per field.",
6
+ "type": "object",
7
+ "required": [
8
+ "version",
9
+ "id",
10
+ "topicId",
11
+ "type",
12
+ "actor",
13
+ "createdAt"
14
+ ],
15
+ "properties": {
16
+ "version": {
17
+ "const": 2
18
+ },
19
+ "id": {
20
+ "type": "string",
21
+ "pattern": "^ixo:topic-op:[A-Za-z0-9._-]{8,128}$",
22
+ "description": "Writers SHOULD use a UUIDv7 suffix."
23
+ },
24
+ "topicId": {
25
+ "$ref": "common.schema.json#/$defs/topicId"
26
+ },
27
+ "type": {
28
+ "type": "string",
29
+ "enum": [
30
+ "update",
31
+ "set-status",
32
+ "block",
33
+ "unblock",
34
+ "link",
35
+ "unlink",
36
+ "attach",
37
+ "detach",
38
+ "relate",
39
+ "unrelate",
40
+ "bind-flow",
41
+ "unbind-flow"
42
+ ]
43
+ },
44
+ "actor": {
45
+ "$ref": "common.schema.json#/$defs/actor"
46
+ },
47
+ "createdAt": {
48
+ "$ref": "common.schema.json#/$defs/dateTime"
49
+ },
50
+ "fields": {
51
+ "type": "object",
52
+ "minProperties": 1,
53
+ "properties": {
54
+ "title": {
55
+ "$ref": "common.schema.json#/$defs/title"
56
+ },
57
+ "owner": {
58
+ "oneOf": [
59
+ {
60
+ "$ref": "common.schema.json#/$defs/actor"
61
+ },
62
+ {
63
+ "type": "null"
64
+ }
65
+ ]
66
+ },
67
+ "due": {
68
+ "oneOf": [
69
+ {
70
+ "$ref": "common.schema.json#/$defs/dateTime"
71
+ },
72
+ {
73
+ "type": "null"
74
+ }
75
+ ]
76
+ },
77
+ "intent": {
78
+ "oneOf": [
79
+ {
80
+ "$ref": "common.schema.json#/$defs/text"
81
+ },
82
+ {
83
+ "type": "null"
84
+ }
85
+ ]
86
+ },
87
+ "outcome": {
88
+ "oneOf": [
89
+ {
90
+ "$ref": "common.schema.json#/$defs/text"
91
+ },
92
+ {
93
+ "type": "null"
94
+ }
95
+ ]
96
+ }
97
+ },
98
+ "additionalProperties": false
99
+ },
100
+ "status": {
101
+ "$ref": "common.schema.json#/$defs/status"
102
+ },
103
+ "reason": {
104
+ "$ref": "common.schema.json#/$defs/text"
105
+ },
106
+ "on": {
107
+ "type": "string",
108
+ "minLength": 1
109
+ },
110
+ "ref": {
111
+ "$ref": "common.schema.json#/$defs/ref"
112
+ },
113
+ "file": {
114
+ "$ref": "common.schema.json#/$defs/file"
115
+ },
116
+ "resource": {
117
+ "type": "string",
118
+ "minLength": 1
119
+ },
120
+ "fileId": {
121
+ "type": "string",
122
+ "minLength": 1
123
+ },
124
+ "relation": {
125
+ "$ref": "common.schema.json#/$defs/relation"
126
+ },
127
+ "targetTopicId": {
128
+ "$ref": "common.schema.json#/$defs/topicId"
129
+ },
130
+ "flowUri": {
131
+ "type": "string",
132
+ "minLength": 1
133
+ }
134
+ },
135
+ "allOf": [
136
+ {
137
+ "if": {
138
+ "properties": {
139
+ "type": {
140
+ "const": "update"
141
+ }
142
+ },
143
+ "required": [
144
+ "type"
145
+ ]
146
+ },
147
+ "then": {
148
+ "properties": {
149
+ "fields": true
150
+ },
151
+ "required": [
152
+ "fields"
153
+ ]
154
+ }
155
+ },
156
+ {
157
+ "if": {
158
+ "properties": {
159
+ "type": {
160
+ "const": "set-status"
161
+ }
162
+ },
163
+ "required": [
164
+ "type"
165
+ ]
166
+ },
167
+ "then": {
168
+ "properties": {
169
+ "status": true
170
+ },
171
+ "required": [
172
+ "status"
173
+ ]
174
+ }
175
+ },
176
+ {
177
+ "if": {
178
+ "properties": {
179
+ "type": {
180
+ "const": "block"
181
+ }
182
+ },
183
+ "required": [
184
+ "type"
185
+ ]
186
+ },
187
+ "then": {
188
+ "properties": {
189
+ "reason": true
190
+ },
191
+ "required": [
192
+ "reason"
193
+ ]
194
+ }
195
+ },
196
+ {
197
+ "if": {
198
+ "properties": {
199
+ "type": {
200
+ "enum": [
201
+ "link",
202
+ "unlink"
203
+ ]
204
+ }
205
+ },
206
+ "required": [
207
+ "type"
208
+ ]
209
+ },
210
+ "then": {
211
+ "properties": {
212
+ "ref": true
213
+ },
214
+ "required": [
215
+ "ref"
216
+ ]
217
+ }
218
+ },
219
+ {
220
+ "if": {
221
+ "properties": {
222
+ "type": {
223
+ "const": "attach"
224
+ }
225
+ },
226
+ "required": [
227
+ "type"
228
+ ]
229
+ },
230
+ "then": {
231
+ "properties": {
232
+ "file": true
233
+ },
234
+ "required": [
235
+ "file"
236
+ ]
237
+ }
238
+ },
239
+ {
240
+ "if": {
241
+ "properties": {
242
+ "type": {
243
+ "const": "detach"
244
+ }
245
+ },
246
+ "required": [
247
+ "type"
248
+ ]
249
+ },
250
+ "then": {
251
+ "properties": {
252
+ "resource": true,
253
+ "fileId": true
254
+ },
255
+ "required": [
256
+ "resource",
257
+ "fileId"
258
+ ]
259
+ }
260
+ },
261
+ {
262
+ "if": {
263
+ "properties": {
264
+ "type": {
265
+ "enum": [
266
+ "relate",
267
+ "unrelate"
268
+ ]
269
+ }
270
+ },
271
+ "required": [
272
+ "type"
273
+ ]
274
+ },
275
+ "then": {
276
+ "properties": {
277
+ "relation": true,
278
+ "targetTopicId": true
279
+ },
280
+ "required": [
281
+ "relation",
282
+ "targetTopicId"
283
+ ]
284
+ }
285
+ },
286
+ {
287
+ "if": {
288
+ "properties": {
289
+ "type": {
290
+ "const": "bind-flow"
291
+ }
292
+ },
293
+ "required": [
294
+ "type"
295
+ ]
296
+ },
297
+ "then": {
298
+ "properties": {
299
+ "flowUri": true
300
+ },
301
+ "required": [
302
+ "flowUri"
303
+ ]
304
+ }
305
+ }
306
+ ],
307
+ "additionalProperties": false
308
+ }
@@ -0,0 +1,205 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://topic-protocol.ixo.world/schemas/v2/projection.schema.json",
4
+ "title": "Topic projection (Protocol 2.0)",
5
+ "description": "The deterministic fold of a manifest, its operations, and its records. Derived data; never authoritative on its own.",
6
+ "type": "object",
7
+ "required": [
8
+ "version",
9
+ "id",
10
+ "anchor",
11
+ "title",
12
+ "kind",
13
+ "baseKind",
14
+ "status",
15
+ "createdBy",
16
+ "createdAt",
17
+ "updatedBy",
18
+ "updatedAt",
19
+ "links",
20
+ "files",
21
+ "relations",
22
+ "records",
23
+ "etag",
24
+ "rejected"
25
+ ],
26
+ "properties": {
27
+ "version": {
28
+ "const": 2
29
+ },
30
+ "id": {
31
+ "$ref": "common.schema.json#/$defs/topicId"
32
+ },
33
+ "anchor": {
34
+ "$ref": "common.schema.json#/$defs/anchor"
35
+ },
36
+ "title": {
37
+ "$ref": "common.schema.json#/$defs/title"
38
+ },
39
+ "kind": {
40
+ "$ref": "common.schema.json#/$defs/kind"
41
+ },
42
+ "baseKind": {
43
+ "$ref": "common.schema.json#/$defs/baseKind"
44
+ },
45
+ "status": {
46
+ "$ref": "common.schema.json#/$defs/status"
47
+ },
48
+ "owner": {
49
+ "$ref": "common.schema.json#/$defs/actor"
50
+ },
51
+ "due": {
52
+ "$ref": "common.schema.json#/$defs/dateTime"
53
+ },
54
+ "intent": {
55
+ "$ref": "common.schema.json#/$defs/text"
56
+ },
57
+ "outcome": {
58
+ "$ref": "common.schema.json#/$defs/text"
59
+ },
60
+ "blocked": {
61
+ "$ref": "common.schema.json#/$defs/block"
62
+ },
63
+ "createdBy": {
64
+ "$ref": "common.schema.json#/$defs/actor"
65
+ },
66
+ "createdAt": {
67
+ "$ref": "common.schema.json#/$defs/dateTime"
68
+ },
69
+ "updatedBy": {
70
+ "$ref": "common.schema.json#/$defs/actor"
71
+ },
72
+ "updatedAt": {
73
+ "$ref": "common.schema.json#/$defs/dateTime"
74
+ },
75
+ "links": {
76
+ "type": "array",
77
+ "items": {
78
+ "$ref": "common.schema.json#/$defs/ref"
79
+ }
80
+ },
81
+ "files": {
82
+ "type": "array",
83
+ "items": {
84
+ "$ref": "common.schema.json#/$defs/file"
85
+ }
86
+ },
87
+ "relations": {
88
+ "type": "array",
89
+ "items": {
90
+ "type": "object",
91
+ "required": [
92
+ "relation",
93
+ "topicId",
94
+ "by",
95
+ "at"
96
+ ],
97
+ "properties": {
98
+ "relation": {
99
+ "$ref": "common.schema.json#/$defs/relation"
100
+ },
101
+ "topicId": {
102
+ "$ref": "common.schema.json#/$defs/topicId"
103
+ },
104
+ "by": {
105
+ "$ref": "common.schema.json#/$defs/actor"
106
+ },
107
+ "at": {
108
+ "$ref": "common.schema.json#/$defs/dateTime"
109
+ }
110
+ },
111
+ "additionalProperties": false
112
+ }
113
+ },
114
+ "flow": {
115
+ "type": "object",
116
+ "required": [
117
+ "flowUri",
118
+ "by",
119
+ "at"
120
+ ],
121
+ "properties": {
122
+ "flowUri": {
123
+ "type": "string",
124
+ "minLength": 1
125
+ },
126
+ "by": {
127
+ "$ref": "common.schema.json#/$defs/actor"
128
+ },
129
+ "at": {
130
+ "$ref": "common.schema.json#/$defs/dateTime"
131
+ }
132
+ },
133
+ "additionalProperties": false
134
+ },
135
+ "records": {
136
+ "type": "object",
137
+ "required": [
138
+ "decisions",
139
+ "outcomes",
140
+ "artifacts",
141
+ "receipts"
142
+ ],
143
+ "properties": {
144
+ "decisions": {
145
+ "type": "array",
146
+ "items": {
147
+ "$ref": "record.schema.json"
148
+ }
149
+ },
150
+ "outcomes": {
151
+ "type": "array",
152
+ "items": {
153
+ "$ref": "record.schema.json"
154
+ }
155
+ },
156
+ "artifacts": {
157
+ "type": "array",
158
+ "items": {
159
+ "$ref": "record.schema.json"
160
+ }
161
+ },
162
+ "receipts": {
163
+ "type": "array",
164
+ "items": {
165
+ "$ref": "record.schema.json"
166
+ }
167
+ }
168
+ },
169
+ "additionalProperties": false
170
+ },
171
+ "etag": {
172
+ "type": "string",
173
+ "pattern": "^sha256:[0-9a-f]{64}$",
174
+ "description": "SHA-256 of the canonical projected state, excluding etag and rejected."
175
+ },
176
+ "rejected": {
177
+ "type": "array",
178
+ "items": {
179
+ "type": "object",
180
+ "required": [
181
+ "id",
182
+ "reason"
183
+ ],
184
+ "properties": {
185
+ "id": {
186
+ "type": "string",
187
+ "minLength": 1
188
+ },
189
+ "reason": {
190
+ "type": "string",
191
+ "enum": [
192
+ "conflict",
193
+ "duplicate",
194
+ "topic-mismatch",
195
+ "unauthorized",
196
+ "unknown-supersedes"
197
+ ]
198
+ }
199
+ },
200
+ "additionalProperties": false
201
+ }
202
+ }
203
+ },
204
+ "additionalProperties": false
205
+ }
@@ -0,0 +1,56 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://topic-protocol.ixo.world/schemas/v2/record.schema.json",
4
+ "title": "Topic record (Protocol 2.0)",
5
+ "description": "An accepted fact posted into a Topic thread: a decision, an outcome, an artifact reference, or an execution receipt. A record may supersede an earlier record of the same type.",
6
+ "type": "object",
7
+ "required": [
8
+ "version",
9
+ "id",
10
+ "topicId",
11
+ "type",
12
+ "text",
13
+ "author",
14
+ "createdAt"
15
+ ],
16
+ "properties": {
17
+ "version": {
18
+ "const": 2
19
+ },
20
+ "id": {
21
+ "type": "string",
22
+ "pattern": "^ixo:topic-record:[A-Za-z0-9._-]{8,128}$",
23
+ "description": "Writers SHOULD use a UUIDv7 suffix."
24
+ },
25
+ "topicId": {
26
+ "$ref": "common.schema.json#/$defs/topicId"
27
+ },
28
+ "type": {
29
+ "$ref": "common.schema.json#/$defs/recordType"
30
+ },
31
+ "text": {
32
+ "$ref": "common.schema.json#/$defs/text"
33
+ },
34
+ "author": {
35
+ "$ref": "common.schema.json#/$defs/actor"
36
+ },
37
+ "createdAt": {
38
+ "$ref": "common.schema.json#/$defs/dateTime"
39
+ },
40
+ "refs": {
41
+ "type": "array",
42
+ "items": {
43
+ "$ref": "common.schema.json#/$defs/ref"
44
+ },
45
+ "maxItems": 20
46
+ },
47
+ "data": {
48
+ "type": "object"
49
+ },
50
+ "supersedes": {
51
+ "type": "string",
52
+ "pattern": "^ixo:topic-record:[A-Za-z0-9._-]{8,128}$"
53
+ }
54
+ },
55
+ "additionalProperties": false
56
+ }