moca-reader 0.6.0__py3-none-any.whl

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 (55) hide show
  1. moca_reader/__init__.py +84 -0
  2. moca_reader/_js.py +291 -0
  3. moca_reader/attestations.py +271 -0
  4. moca_reader/audience.py +49 -0
  5. moca_reader/backends/__init__.py +1 -0
  6. moca_reader/backends/bm25.py +118 -0
  7. moca_reader/backends/dense.py +146 -0
  8. moca_reader/backends/hybrid.py +73 -0
  9. moca_reader/backends/lexical.py +112 -0
  10. moca_reader/backends/memory_store.py +122 -0
  11. moca_reader/citation.py +213 -0
  12. moca_reader/codes.py +110 -0
  13. moca_reader/conformance.py +249 -0
  14. moca_reader/content.py +312 -0
  15. moca_reader/diagnostics.py +45 -0
  16. moca_reader/digest.py +92 -0
  17. moca_reader/dsse.py +97 -0
  18. moca_reader/ed25519.py +83 -0
  19. moca_reader/embedders.py +224 -0
  20. moca_reader/evidence_text.py +187 -0
  21. moca_reader/frontmatter.py +151 -0
  22. moca_reader/library.py +176 -0
  23. moca_reader/manifest.py +186 -0
  24. moca_reader/metadata.py +58 -0
  25. moca_reader/profiles.py +5 -0
  26. moca_reader/py.typed +0 -0
  27. moca_reader/reader.py +468 -0
  28. moca_reader/relations.py +46 -0
  29. moca_reader/resolver.py +33 -0
  30. moca_reader/reviews.py +18 -0
  31. moca_reader/schemas/ag-ui-citations.schema.json +36 -0
  32. moca_reader/schemas/citation-record.schema.json +326 -0
  33. moca_reader/schemas/manifest.schema.json +171 -0
  34. moca_reader/schemas/node.schema.json +372 -0
  35. moca_reader/schemas/review-predicate.schema.json +42 -0
  36. moca_reader/schemas/search-hit.schema.json +62 -0
  37. moca_reader/schemas/sidecar-index.schema.json +155 -0
  38. moca_reader/schemas/structure.schema.json +93 -0
  39. moca_reader/schemas/trust-root.schema.json +130 -0
  40. moca_reader/schemas.py +44 -0
  41. moca_reader/search.py +346 -0
  42. moca_reader/sidecar.py +228 -0
  43. moca_reader/source.py +285 -0
  44. moca_reader/state.py +119 -0
  45. moca_reader/strategies/__init__.py +1 -0
  46. moca_reader/strategies/diversify.py +28 -0
  47. moca_reader/strategies/ontology_guided.py +63 -0
  48. moca_reader/structure.py +385 -0
  49. moca_reader/structure_ops.py +160 -0
  50. moca_reader/unicode.py +33 -0
  51. moca_reader-0.6.0.dist-info/METADATA +209 -0
  52. moca_reader-0.6.0.dist-info/RECORD +55 -0
  53. moca_reader-0.6.0.dist-info/WHEEL +4 -0
  54. moca_reader-0.6.0.dist-info/licenses/LICENSE +201 -0
  55. moca_reader-0.6.0.dist-info/licenses/NOTICE +15 -0
@@ -0,0 +1,372 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://w3id.org/moca/schemas/v1/node.schema.json",
4
+ "title": "MOCA content node frontmatter",
5
+ "description": "OKF v0.2 concept-document frontmatter plus MOCA's `moca` extension mapping. See spec/moca-package-spec.md section 5.",
6
+ "type": "object",
7
+ "required": [
8
+ "type"
9
+ ],
10
+ "properties": {
11
+ "type": {
12
+ "type": "string",
13
+ "minLength": 1,
14
+ "pattern": "[^\\t\\n\\v\\f\\r    - 

   ]",
15
+ "description": "Required by OKF: not empty and not only white space."
16
+ },
17
+ "title": {
18
+ "type": "string"
19
+ },
20
+ "description": {
21
+ "type": "string"
22
+ },
23
+ "resource": {
24
+ "type": "string"
25
+ },
26
+ "tags": {
27
+ "type": "array",
28
+ "items": {
29
+ "type": "string"
30
+ }
31
+ },
32
+ "generated": {
33
+ "type": "object",
34
+ "required": [
35
+ "by"
36
+ ],
37
+ "properties": {
38
+ "by": {
39
+ "type": "string",
40
+ "minLength": 1
41
+ },
42
+ "at": {
43
+ "type": "string",
44
+ "anyOf": [
45
+ {
46
+ "format": "date-time"
47
+ },
48
+ {
49
+ "format": "date"
50
+ }
51
+ ]
52
+ }
53
+ },
54
+ "additionalProperties": true
55
+ },
56
+ "verified": {
57
+ "oneOf": [
58
+ {
59
+ "type": "object",
60
+ "required": [
61
+ "by",
62
+ "at"
63
+ ],
64
+ "properties": {
65
+ "by": {
66
+ "type": "string",
67
+ "minLength": 1
68
+ },
69
+ "at": {
70
+ "type": "string",
71
+ "anyOf": [
72
+ {
73
+ "format": "date-time"
74
+ },
75
+ {
76
+ "format": "date"
77
+ }
78
+ ]
79
+ }
80
+ },
81
+ "additionalProperties": true
82
+ },
83
+ {
84
+ "type": "array",
85
+ "items": {
86
+ "type": "object",
87
+ "required": [
88
+ "by",
89
+ "at"
90
+ ],
91
+ "properties": {
92
+ "by": {
93
+ "type": "string",
94
+ "minLength": 1
95
+ },
96
+ "at": {
97
+ "type": "string",
98
+ "anyOf": [
99
+ {
100
+ "format": "date-time"
101
+ },
102
+ {
103
+ "format": "date"
104
+ }
105
+ ]
106
+ }
107
+ },
108
+ "additionalProperties": true
109
+ }
110
+ }
111
+ ]
112
+ },
113
+ "sources": {
114
+ "type": "array",
115
+ "items": {
116
+ "$ref": "#/$defs/source"
117
+ }
118
+ },
119
+ "status": {
120
+ "enum": [
121
+ "draft",
122
+ "stable",
123
+ "deprecated"
124
+ ]
125
+ },
126
+ "stale_after": {
127
+ "type": "string",
128
+ "anyOf": [
129
+ {
130
+ "format": "date-time"
131
+ },
132
+ {
133
+ "format": "date"
134
+ }
135
+ ]
136
+ },
137
+ "moca": {
138
+ "$ref": "#/$defs/moca"
139
+ }
140
+ },
141
+ "additionalProperties": true,
142
+ "$defs": {
143
+ "source": {
144
+ "type": "object",
145
+ "required": [
146
+ "resource"
147
+ ],
148
+ "properties": {
149
+ "resource": {
150
+ "type": "string",
151
+ "minLength": 1
152
+ },
153
+ "id": {
154
+ "type": "string",
155
+ "minLength": 1
156
+ },
157
+ "title": {
158
+ "type": "string"
159
+ },
160
+ "author": {
161
+ "type": "string"
162
+ },
163
+ "usage_count": {
164
+ "type": "integer",
165
+ "minimum": 0
166
+ },
167
+ "last_modified": {
168
+ "type": "string",
169
+ "anyOf": [
170
+ {
171
+ "format": "date-time"
172
+ },
173
+ {
174
+ "format": "date"
175
+ }
176
+ ]
177
+ },
178
+ "usage_window": {
179
+ "type": "object",
180
+ "properties": {
181
+ "from": {
182
+ "type": "string",
183
+ "anyOf": [
184
+ {
185
+ "format": "date-time"
186
+ },
187
+ {
188
+ "format": "date"
189
+ }
190
+ ]
191
+ },
192
+ "to": {
193
+ "type": "string",
194
+ "anyOf": [
195
+ {
196
+ "format": "date-time"
197
+ },
198
+ {
199
+ "format": "date"
200
+ }
201
+ ]
202
+ }
203
+ }
204
+ }
205
+ },
206
+ "additionalProperties": true
207
+ },
208
+ "moca": {
209
+ "type": "object",
210
+ "properties": {
211
+ "evidence": {
212
+ "type": "array",
213
+ "items": {
214
+ "$ref": "#/$defs/evidence"
215
+ }
216
+ },
217
+ "valid_from": {
218
+ "type": "string",
219
+ "anyOf": [
220
+ {
221
+ "format": "date-time"
222
+ },
223
+ {
224
+ "format": "date"
225
+ }
226
+ ]
227
+ },
228
+ "valid_until": {
229
+ "type": "string",
230
+ "anyOf": [
231
+ {
232
+ "format": "date-time"
233
+ },
234
+ {
235
+ "format": "date"
236
+ }
237
+ ]
238
+ },
239
+ "contested_by": {
240
+ "type": "array",
241
+ "items": {
242
+ "type": "string",
243
+ "minLength": 1
244
+ }
245
+ },
246
+ "audience": {
247
+ "type": "string",
248
+ "minLength": 1
249
+ },
250
+ "profiles": {
251
+ "type": "object",
252
+ "additionalProperties": {
253
+ "type": "object"
254
+ }
255
+ },
256
+ "concepts": {
257
+ "type": "array",
258
+ "description": "Concepts from the package's structure.ttl this node is bound to (spec/moca-package-spec.md §5.6).",
259
+ "items": {
260
+ "type": "object",
261
+ "required": [
262
+ "iri"
263
+ ],
264
+ "properties": {
265
+ "iri": {
266
+ "type": "string",
267
+ "pattern": "^[A-Za-z][A-Za-z0-9+.-]*:[^\\t\\n\\v\\f\\r    - 

   ]+(?![\\s\\S])"
268
+ },
269
+ "role": {
270
+ "enum": [
271
+ "primary",
272
+ "supporting"
273
+ ]
274
+ }
275
+ },
276
+ "additionalProperties": false
277
+ }
278
+ }
279
+ },
280
+ "additionalProperties": true
281
+ },
282
+ "evidence": {
283
+ "type": "object",
284
+ "required": [
285
+ "source",
286
+ "selector"
287
+ ],
288
+ "properties": {
289
+ "source": {
290
+ "type": "string",
291
+ "minLength": 1
292
+ },
293
+ "selector": {
294
+ "$ref": "#/$defs/selector"
295
+ },
296
+ "note": {
297
+ "type": "string"
298
+ }
299
+ },
300
+ "additionalProperties": false
301
+ },
302
+ "selector": {
303
+ "oneOf": [
304
+ {
305
+ "type": "object",
306
+ "required": [
307
+ "type",
308
+ "value"
309
+ ],
310
+ "properties": {
311
+ "type": {
312
+ "const": "FragmentSelector"
313
+ },
314
+ "value": {
315
+ "type": "string",
316
+ "minLength": 1
317
+ },
318
+ "conformsTo": {
319
+ "type": "string"
320
+ }
321
+ },
322
+ "additionalProperties": false
323
+ },
324
+ {
325
+ "type": "object",
326
+ "required": [
327
+ "type",
328
+ "exact"
329
+ ],
330
+ "properties": {
331
+ "type": {
332
+ "const": "TextQuoteSelector"
333
+ },
334
+ "exact": {
335
+ "type": "string",
336
+ "minLength": 1
337
+ },
338
+ "prefix": {
339
+ "type": "string"
340
+ },
341
+ "suffix": {
342
+ "type": "string"
343
+ }
344
+ },
345
+ "additionalProperties": false
346
+ },
347
+ {
348
+ "type": "object",
349
+ "required": [
350
+ "type",
351
+ "start",
352
+ "end"
353
+ ],
354
+ "properties": {
355
+ "type": {
356
+ "const": "TextPositionSelector"
357
+ },
358
+ "start": {
359
+ "type": "integer",
360
+ "minimum": 0
361
+ },
362
+ "end": {
363
+ "type": "integer",
364
+ "minimum": 0
365
+ }
366
+ },
367
+ "additionalProperties": false
368
+ }
369
+ ]
370
+ }
371
+ }
372
+ }
@@ -0,0 +1,42 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://w3id.org/moca/schemas/v1/review-predicate.schema.json",
4
+ "title": "MOCA review attestation predicate",
5
+ "description": "Predicate for predicateType https://w3id.org/moca/attestation/review/v1. See spec/moca-attestations.md section 4.",
6
+ "type": "object",
7
+ "required": [
8
+ "package",
9
+ "reviewer",
10
+ "reviewedAt",
11
+ "outcome"
12
+ ],
13
+ "properties": {
14
+ "package": {
15
+ "type": "string",
16
+ "pattern": "^[A-Za-z][A-Za-z0-9+.-]*:[^\\t\\n\\v\\f\\r \u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+(?![\\s\\S])"
17
+ },
18
+ "reviewer": {
19
+ "type": "string",
20
+ "minLength": 1,
21
+ "description": "OKF actor, e.g. human:jane.doe"
22
+ },
23
+ "reviewedAt": {
24
+ "type": "string",
25
+ "format": "date-time"
26
+ },
27
+ "outcome": {
28
+ "enum": [
29
+ "accurate",
30
+ "needs-change",
31
+ "inaccurate"
32
+ ]
33
+ },
34
+ "scope": {
35
+ "type": "string"
36
+ },
37
+ "note": {
38
+ "type": "string"
39
+ }
40
+ },
41
+ "additionalProperties": false
42
+ }
@@ -0,0 +1,62 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://w3id.org/moca/schemas/v1/search-hit.schema.json",
4
+ "title": "MOCA search hit",
5
+ "description": "What a search backend returns for one candidate match, before the search entry point resolves it into a citation record. Normative: spec/moca-reader-contract.md section 9.1.",
6
+ "type": "object",
7
+ "required": [
8
+ "digest",
9
+ "node",
10
+ "path",
11
+ "score"
12
+ ],
13
+ "properties": {
14
+ "digest": {
15
+ "type": "string",
16
+ "pattern": "^sha256:[a-f0-9]{64}(?![\\s\\S])",
17
+ "description": "The digest of the package the hit was indexed from."
18
+ },
19
+ "node": {
20
+ "type": "string",
21
+ "minLength": 1,
22
+ "description": "The node id."
23
+ },
24
+ "path": {
25
+ "type": "string",
26
+ "minLength": 1,
27
+ "description": "The node path relative to content/."
28
+ },
29
+ "locale": {
30
+ "type": "string",
31
+ "minLength": 1
32
+ },
33
+ "span": {
34
+ "type": "object",
35
+ "required": [
36
+ "start",
37
+ "end"
38
+ ],
39
+ "properties": {
40
+ "start": {
41
+ "type": "integer",
42
+ "minimum": 0
43
+ },
44
+ "end": {
45
+ "type": "integer",
46
+ "minimum": 0
47
+ }
48
+ },
49
+ "additionalProperties": false,
50
+ "description": "UTF-8 byte offsets into the node file."
51
+ },
52
+ "score": {
53
+ "type": "number",
54
+ "description": "Higher is a better match. Not comparable across backends."
55
+ },
56
+ "record": {
57
+ "type": "object",
58
+ "description": "A citation record written at ingest by a store backend. The Reader re-applies the clock and the policy to it, and checks its package digest against the loaded packages."
59
+ }
60
+ },
61
+ "additionalProperties": false
62
+ }
@@ -0,0 +1,155 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://w3id.org/moca/schemas/v1/sidecar-index.schema.json",
4
+ "title": "MOCA sidecar index manifest (index.json)",
5
+ "description": "See spec/moca-sidecar-index-spec.md.",
6
+ "type": "object",
7
+ "required": [
8
+ "indexVersion",
9
+ "target",
10
+ "indexType",
11
+ "storage"
12
+ ],
13
+ "properties": {
14
+ "indexVersion": {
15
+ "const": 1
16
+ },
17
+ "target": {
18
+ "type": "object",
19
+ "required": [
20
+ "id",
21
+ "version",
22
+ "digest"
23
+ ],
24
+ "properties": {
25
+ "id": {
26
+ "type": "string",
27
+ "pattern": "^[A-Za-z][A-Za-z0-9+.-]*:[^\\t\\n\\v\\f\\r \u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+(?![\\s\\S])"
28
+ },
29
+ "version": {
30
+ "type": "string",
31
+ "pattern": "^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(?:-[0-9A-Za-z.-]+)?(?:\\+[0-9A-Za-z.-]+)?(?![\\s\\S])"
32
+ },
33
+ "digest": {
34
+ "type": "string",
35
+ "pattern": "^sha256:[a-f0-9]{64}(?![\\s\\S])"
36
+ }
37
+ },
38
+ "additionalProperties": false
39
+ },
40
+ "indexType": {
41
+ "type": "string",
42
+ "minLength": 1,
43
+ "description": "lexical | dense | hybrid. Describes the sidecar; a Reader uses what it holds."
44
+ },
45
+ "model": {
46
+ "type": "object",
47
+ "required": [
48
+ "name"
49
+ ],
50
+ "properties": {
51
+ "name": {
52
+ "type": "string",
53
+ "minLength": 1
54
+ },
55
+ "version": {
56
+ "type": "string"
57
+ },
58
+ "dimensions": {
59
+ "type": "integer",
60
+ "minimum": 1
61
+ },
62
+ "distance": {
63
+ "enum": [
64
+ "cosine",
65
+ "dot",
66
+ "euclidean"
67
+ ]
68
+ },
69
+ "queryPrefix": {
70
+ "type": "string"
71
+ },
72
+ "documentPrefix": {
73
+ "type": "string"
74
+ }
75
+ },
76
+ "additionalProperties": true
77
+ },
78
+ "chunking": {
79
+ "type": "object",
80
+ "properties": {
81
+ "strategy": {
82
+ "type": "string"
83
+ }
84
+ },
85
+ "additionalProperties": true
86
+ },
87
+ "storage": {
88
+ "type": "object",
89
+ "required": [
90
+ "format",
91
+ "file"
92
+ ],
93
+ "properties": {
94
+ "format": {
95
+ "type": "string",
96
+ "minLength": 1
97
+ },
98
+ "file": {
99
+ "type": "string",
100
+ "minLength": 1
101
+ },
102
+ "vectors": {
103
+ "type": "object",
104
+ "description": "Vectors in a binary file: little-endian float32, row-major, one row per payload item in items order.",
105
+ "required": [
106
+ "file",
107
+ "dtype",
108
+ "dimensions"
109
+ ],
110
+ "properties": {
111
+ "file": {
112
+ "type": "string",
113
+ "minLength": 1
114
+ },
115
+ "dtype": {
116
+ "const": "float32"
117
+ },
118
+ "dimensions": {
119
+ "type": "integer",
120
+ "minimum": 1
121
+ }
122
+ },
123
+ "additionalProperties": false
124
+ }
125
+ },
126
+ "additionalProperties": false
127
+ },
128
+ "createdBy": {
129
+ "type": "string"
130
+ }
131
+ },
132
+ "allOf": [
133
+ {
134
+ "if": {
135
+ "properties": {
136
+ "indexType": {
137
+ "enum": [
138
+ "dense",
139
+ "hybrid"
140
+ ]
141
+ }
142
+ },
143
+ "required": [
144
+ "indexType"
145
+ ]
146
+ },
147
+ "then": {
148
+ "required": [
149
+ "model"
150
+ ]
151
+ }
152
+ }
153
+ ],
154
+ "additionalProperties": false
155
+ }