@toolproof-core/genesis 1.0.48 → 1.0.50

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 (93) hide show
  1. package/dist/src/implementations/tools.d.ts +100 -0
  2. package/dist/src/implementations/tools.js +135 -0
  3. package/dist/src/index.d.ts +9 -8
  4. package/dist/src/index.js +4 -3
  5. package/dist/src/utils/resourceTypes.d.ts +2 -1
  6. package/dist/src/utils/resourceTypes.js +22 -6
  7. package/dist/src/utils/schemaRefNormalization.js +3 -3
  8. package/dist/src/utils/standaloneTypes.js +2 -2
  9. package/dist/src/utils/timestampedResources.d.ts +16 -0
  10. package/dist/src/utils/timestampedResources.js +17 -0
  11. package/dist/src/utils/typeGenerationPostProcess.js +2 -2
  12. package/dist/src/utils/zodCodegen.js +3 -3
  13. package/generated-src/declarations/booleans.json +4 -0
  14. package/generated-src/declarations/booleans.ts +2 -0
  15. package/generated-src/declarations/naturals.json +13 -0
  16. package/generated-src/declarations/naturals.ts +2 -0
  17. package/generated-src/{resourceTypes → declarations}/resourceTypes.json +176 -39
  18. package/generated-src/declarations/resourceTypes.ts +2 -0
  19. package/generated-src/declarations/tools.json +705 -0
  20. package/generated-src/declarations/tools.ts +2 -0
  21. package/generated-src/implementations/tools.ts +214 -0
  22. package/generated-src/{derived → lookups}/constants.ts +4 -5
  23. package/generated-src/metadata/Core.json +51 -114
  24. package/generated-src/metadata/dependencyMap.json +16 -2
  25. package/generated-src/metadata/terminals.json +3 -4
  26. package/generated-src/schemas/schemas.json +198 -29
  27. package/generated-src/schemas/standalone/Resource.json +4 -8
  28. package/generated-src/schemas/standalone/ResourceType.json +21 -5
  29. package/generated-src/schemas/standalone/Strategy.json +4 -8
  30. package/generated-src/schemas/standalone/StrategyTrace.json +4 -8
  31. package/generated-src/schemas/standalone/Suite.json +646 -0
  32. package/generated-src/schemas/standalone/Suite.ts +2 -0
  33. package/generated-src/schemas/standalone/Tool.json +48 -23
  34. package/generated-src/schemas/zod/Resource.ts +2 -2
  35. package/generated-src/schemas/zod/ResourceType.ts +1 -1
  36. package/generated-src/schemas/zod/Strategy.ts +3 -3
  37. package/generated-src/schemas/zod/StrategyTrace.ts +3 -3
  38. package/generated-src/schemas/zod/Suite.ts +44 -0
  39. package/generated-src/schemas/zod/Tool.ts +7 -2
  40. package/generated-src/schemas/zod/index.ts +1 -0
  41. package/{src/genesis/resources → generated-src/timestampedResources}/booleans.json +19 -23
  42. package/generated-src/timestampedResources/booleans.ts +2 -0
  43. package/{src/genesis/resources → generated-src/timestampedResources}/naturals.json +100 -111
  44. package/generated-src/timestampedResources/naturals.ts +2 -0
  45. package/generated-src/{resources → timestampedResources}/resourceTypes.json +202 -66
  46. package/generated-src/timestampedResources/resourceTypes.ts +2 -0
  47. package/{src/genesis/resources → generated-src/timestampedResources}/tools.json +824 -839
  48. package/generated-src/timestampedResources/tools.ts +2 -0
  49. package/generated-src/types/standalone/BooleanResource.d.ts +2 -2
  50. package/generated-src/types/standalone/ErrorResource.d.ts +2 -2
  51. package/generated-src/types/standalone/GoalResource.d.ts +2 -2
  52. package/generated-src/types/standalone/NaturalResource.d.ts +2 -2
  53. package/generated-src/types/standalone/ResourceResource.d.ts +2 -2
  54. package/generated-src/types/standalone/ResourceTypeResource.d.ts +2 -2
  55. package/generated-src/types/standalone/StrategyResource.d.ts +2 -2
  56. package/generated-src/types/standalone/StrategyTraceResource.d.ts +2 -2
  57. package/generated-src/types/standalone/SuiteResource.d.ts +3 -0
  58. package/generated-src/types/standalone/SuiteResource.js +1 -0
  59. package/generated-src/types/standalone/ToolResource.d.ts +2 -2
  60. package/generated-src/types/types.d.ts +57 -14
  61. package/package.json +18 -13
  62. package/src/declarations/booleans.json +4 -0
  63. package/src/declarations/naturals.json +13 -0
  64. package/src/{genesis → declarations/resourceTypes}/resourceTypeShells.json +52 -46
  65. package/src/{genesis → declarations/resourceTypes}/schemas.json +1838 -1669
  66. package/src/declarations/tools.json +705 -0
  67. package/src/implementations/tools.ts +214 -0
  68. package/src/index.ts +131 -27
  69. package/src/utils/constantsAndMappings.ts +194 -194
  70. package/src/utils/coreProjection.ts +52 -52
  71. package/src/utils/resourceTypes.ts +70 -38
  72. package/src/utils/schemaDependencies.ts +114 -114
  73. package/src/utils/schemaObjectNormalization.ts +70 -70
  74. package/src/utils/schemaRefNormalization.ts +82 -82
  75. package/src/utils/schemaShims.ts +16 -16
  76. package/src/utils/standaloneSchemas.ts +113 -113
  77. package/src/utils/standaloneTypes.ts +27 -27
  78. package/src/utils/standaloneZodSchemas.ts +71 -71
  79. package/src/utils/timestampedResources.ts +42 -0
  80. package/src/utils/typeGeneration.ts +30 -30
  81. package/src/utils/typeGenerationPostProcess.ts +245 -245
  82. package/src/utils/typeGenerationPreflight.ts +118 -118
  83. package/src/utils/zodCodegen.ts +548 -548
  84. package/toolproof.json +19 -0
  85. package/dist/src/genesis/resources/implementations/foo.d.ts +0 -1
  86. package/dist/src/genesis/resources/implementations/foo.js +0 -184
  87. package/dist/src/utils/resources.d.ts +0 -5
  88. package/dist/src/utils/resources.js +0 -17
  89. package/generated-src/resourceTypes/resourceTypes.ts +0 -2
  90. package/generated-src/resources/resourceTypes.ts +0 -2
  91. package/src/genesis/resources/implementations/foo.ts +0 -183
  92. package/src/utils/resources.ts +0 -26
  93. /package/generated-src/{derived → lookups}/mappings.ts +0 -0
@@ -1,24 +1,28 @@
1
- {
2
- "ResourceType": {
3
- "handle": "TYPE-RESOURCE-TYPE",
1
+ [
2
+ {
3
+ "handle": "TYPE-ResourceType",
4
4
  "name": "ResourceType",
5
5
  "description": "",
6
- "valueSchema": {
6
+ "projectionSchema": {
7
7
  "$schema": "https://json-schema.org/draft/2020-12/schema",
8
8
  "type": "object",
9
9
  "required": [
10
10
  "handle"
11
11
  ],
12
+ "semanticValidation": "If ingestorToolHandle is present, verify that it references an existing non-template Tool whose distinguished raw-instance input semantically matches ingestorToolInputSchema when provided, whose distinguished Boolean output reports whether the raw instance is valid for this ResourceType, and whose distinguished projection output is typed as this ResourceType and conforms to projectionSchema when projectionSchema is present.",
12
13
  "properties": {
13
14
  "handle": {
14
15
  "$ref": "#/$defs/ResourceTypeHandle"
15
16
  },
16
- "valueSchema": {
17
+ "projectionSchema": {
17
18
  "$ref": "#/$defs/JsonSchemaObject"
18
19
  },
19
- "parserToolHandle": {
20
+ "ingestorToolHandle": {
20
21
  "$ref": "#/$defs/ToolHandle"
21
22
  },
23
+ "ingestorToolInputSchema": {
24
+ "$ref": "#/$defs/JsonSchemaObject"
25
+ },
22
26
  "embeddingModelTools": {
23
27
  "type": "array",
24
28
  "items": {
@@ -33,29 +37,41 @@
33
37
  "$ref": "#/$defs/DocumentationSpec"
34
38
  },
35
39
  {
36
- "$comment": "A ResourceType must specify either a valueSchema or a parserToolHandle, or both. If only a valueSchema is specified, the author assumes no burden of implementing a parser for the ResourceType. They can rely on the valueSchema for validation. If only a parserToolHandle is specified, the author assumes the burden of implementing a parser that can validate instances of the ResourceType. If both are specified, the author assumes the burden of implementing an augmented parser that also serves as a generator between the raw data and an instance of the valueSchema.",
40
+ "$comment": "A ResourceType ultimately describes both raw instances and their Core-visible JSON projection. Inside ToolProof Core, the ResourceType denotes the projection. projectionSchema describes the shape of that Core-visible projection. ingestorToolHandle identifies the Tool that ingests raw instances for this ResourceType by validating them against the built-in format grammar and, when projectionSchema is present, emitting the corresponding projection for Core. ingestorToolInputSchema describes the raw-instance input accepted by that ingestor. A ResourceType must specify either a projectionSchema or an ingestorToolHandle, or both. If only a projectionSchema is specified, the author relies on schema-based validation of the Core-visible projection and does not designate an ingestor. If only an ingestorToolHandle is specified, the author designates an ingestor that is authoritative for validating raw instances of the ResourceType. If both are specified, the ingestor must emit projections that conform to projectionSchema.",
37
41
  "anyOf": [
38
42
  {
39
43
  "required": [
40
- "valueSchema"
44
+ "projectionSchema"
41
45
  ]
42
46
  },
43
47
  {
44
48
  "required": [
45
- "parserToolHandle"
49
+ "ingestorToolHandle"
46
50
  ]
47
51
  }
48
52
  ]
53
+ },
54
+ {
55
+ "if": {
56
+ "required": [
57
+ "ingestorToolInputSchema"
58
+ ]
59
+ },
60
+ "then": {
61
+ "required": [
62
+ "ingestorToolHandle"
63
+ ]
64
+ }
49
65
  }
50
66
  ],
51
67
  "unevaluatedProperties": false
52
68
  }
53
69
  },
54
- "Tool": {
55
- "handle": "TYPE-TOOL",
70
+ {
71
+ "handle": "TYPE-Tool",
56
72
  "name": "Tool",
57
73
  "description": "",
58
- "valueSchema": {
74
+ "projectionSchema": {
59
75
  "$schema": "https://json-schema.org/draft/2020-12/schema",
60
76
  "type": "object",
61
77
  "required": [
@@ -66,17 +82,17 @@
66
82
  "handle": {
67
83
  "$ref": "#/$defs/ToolHandle"
68
84
  },
69
- "isTemplate": {
70
- "type": "boolean"
71
- },
72
85
  "templateToolHandle": {
73
86
  "$ref": "#/$defs/ToolHandle"
74
87
  },
88
+ "isTemplate": {
89
+ "type": "boolean"
90
+ },
75
91
  "instantiationRoleSpec": {
76
92
  "$ref": "#/$defs/RoleSpec"
77
93
  }
78
94
  },
79
- "$comment": "Template Tools own dispatch contract: Core scans all instantiation Tools grouped by templateToolHandle, derives a specializationKey from each tool's generic role assignment (canonical order of genericRoleName -> resourceTypeHandle pairs), and asserts injectivity (no two instantiation Tools share the same key for the same template). At invocation time Core injects the specializationKey -> instantiationToolHandle lookup as the second input, then resolves the first input against it to return one instantiation Tool. Cross-resource compatibility between an instantiation Tool's roleSpec and the template's instantiationRoleSpec is deferred to the validation package.",
95
+ "$comment": "Template Tools own dispatch contract: Core scans all instantiation Tools grouped by templateToolHandle, derives a specializationKey from each instantiation tool's generic assignment by taking the canonical order of genericRoleName -> assigned ResourceType.resourceTypeHandle pairs, and asserts injectivity (no two instantiation Tools share the same key for the same template). At invocation time Core injects the specializationKey -> instantiationToolHandle lookup as the second input, then the template resolves the first input against it to return one instantiation Tool. Cross-resource compatibility between an instantiation Tool's roleSpec and the template's instantiationRoleSpec is deferred to the validation package.",
80
96
  "semanticValidation": "Deferred: verify injectivity of specializationKey map per template; verify instantiation Tool roleSpec matches template instantiationRoleSpec; verify every supplied generic assignment key-set exactly equals roleSpec.inputRoleValueByName.GenericAssignmentByRoleName.mapKeys; verify every supplied generic assignment matches a registered specializationKey.",
81
97
  "allOf": [
82
98
  {
@@ -107,7 +123,7 @@
107
123
  }
108
124
  },
109
125
  {
110
- "$comment": "Template Tools must declare named roles: two map inputs (GenericAssignmentByRoleName and InstantiationToolHandleBySpecializationKey) and one scalar TYPE-Tool output (InstantiationTool). Runtime semantic validation enforces that invocation input keys for GenericAssignmentByRoleName exactly match this role's declared mapKeys.",
126
+ "$comment": "Template Tools must declare named roles: two map inputs (GenericAssignmentByRoleName and InstantiationToolHandleBySpecializationKey) and one scalar TYPE-Tool output (InstantiationTool). GenericAssignmentByRoleName.mapKeys declares the generic parameter names accepted by the template. Runtime semantic validation enforces that each invocation's GenericAssignmentByRoleName object has exactly that key set: no missing keys, no extra keys. These keys are the generic parameter names later referenced via roleSchema refs such as #OperandType; they are not required to match the top-level role names of instantiationRoleSpec.",
111
127
  "if": {
112
128
  "required": [
113
129
  "isTemplate"
@@ -228,11 +244,11 @@
228
244
  "unevaluatedProperties": false
229
245
  }
230
246
  },
231
- "Strategy": {
232
- "handle": "TYPE-STRATEGY",
247
+ {
248
+ "handle": "TYPE-Strategy",
233
249
  "name": "Strategy",
234
250
  "description": "",
235
- "valueSchema": {
251
+ "projectionSchema": {
236
252
  "$schema": "https://json-schema.org/draft/2020-12/schema",
237
253
  "oneOf": [
238
254
  {
@@ -244,11 +260,11 @@
244
260
  ]
245
261
  }
246
262
  },
247
- "StrategyTrace": {
248
- "handle": "TYPE-STRATEGY_TRACE",
263
+ {
264
+ "handle": "TYPE-StrategyTrace",
249
265
  "name": "StrategyTrace",
250
266
  "description": "",
251
- "valueSchema": {
267
+ "projectionSchema": {
252
268
  "$schema": "https://json-schema.org/draft/2020-12/schema",
253
269
  "type": "object",
254
270
  "required": [
@@ -274,11 +290,11 @@
274
290
  "unevaluatedProperties": false
275
291
  }
276
292
  },
277
- "Goal": {
278
- "handle": "TYPE-GOAL",
293
+ {
294
+ "handle": "TYPE-Goal",
279
295
  "name": "Goal",
280
296
  "description": "",
281
- "valueSchema": {
297
+ "projectionSchema": {
282
298
  "$schema": "https://json-schema.org/draft/2020-12/schema",
283
299
  "type": "object",
284
300
  "required": [
@@ -320,11 +336,11 @@
320
336
  "unevaluatedProperties": false
321
337
  }
322
338
  },
323
- "Error": {
324
- "handle": "TYPE-ERROR",
339
+ {
340
+ "handle": "TYPE-Error",
325
341
  "name": "Error",
326
342
  "description": "",
327
- "valueSchema": {
343
+ "projectionSchema": {
328
344
  "$schema": "https://json-schema.org/draft/2020-12/schema",
329
345
  "type": "object",
330
346
  "allOf": [
@@ -342,34 +358,155 @@
342
358
  "unevaluatedProperties": false
343
359
  }
344
360
  },
345
- "Boolean": {
346
- "handle": "TYPE-BOOLEAN",
361
+ {
362
+ "handle": "TYPE-Boolean",
347
363
  "name": "Boolean",
348
364
  "description": "",
349
- "valueSchema": {
365
+ "projectionSchema": {
350
366
  "$schema": "https://json-schema.org/draft/2020-12/schema",
351
367
  "type": "boolean"
352
368
  }
353
369
  },
354
- "Natural": {
355
- "handle": "TYPE-NATURAL",
370
+ {
371
+ "handle": "TYPE-Natural",
356
372
  "name": "Natural",
357
373
  "description": "",
358
- "valueSchema": {
374
+ "projectionSchema": {
359
375
  "$schema": "https://json-schema.org/draft/2020-12/schema",
360
376
  "type": "integer",
361
377
  "minimum": 0
362
378
  }
363
379
  },
364
- "Resource": {
365
- "handle": "TYPE-RESOURCE",
380
+ {
381
+ "handle": "TYPE-Resource",
366
382
  "name": "Resource",
367
383
  "description": "",
368
- "valueSchema": {
384
+ "projectionSchema": {
369
385
  "$schema": "https://json-schema.org/draft/2020-12/schema",
370
386
  "type": "object",
371
387
  "$ref": "#/$defs/BaseResource",
372
388
  "unevaluatedProperties": false
373
389
  }
390
+ },
391
+ {
392
+ "handle": "TYPE-Suite",
393
+ "name": "Suite",
394
+ "description": "",
395
+ "ingestorToolInputSchema": {
396
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
397
+ "type": "object",
398
+ "allOf": [
399
+ {
400
+ "type": "object",
401
+ "required": [
402
+ "name",
403
+ "version",
404
+ "description"
405
+ ],
406
+ "properties": {
407
+ "name": {
408
+ "oneOf": [
409
+ {
410
+ "$ref": "#/$defs/Name"
411
+ },
412
+ {
413
+ "$ref": "#/$defs/JsonScalarLink"
414
+ }
415
+ ]
416
+ },
417
+ "version": {
418
+ "oneOf": [
419
+ {
420
+ "type": "string",
421
+ "minLength": 1
422
+ },
423
+ {
424
+ "$ref": "#/$defs/JsonScalarLink"
425
+ }
426
+ ]
427
+ },
428
+ "description": {
429
+ "oneOf": [
430
+ {
431
+ "$ref": "#/$defs/Description"
432
+ },
433
+ {
434
+ "$ref": "#/$defs/JsonScalarLink"
435
+ }
436
+ ]
437
+ }
438
+ }
439
+ },
440
+ {
441
+ "type": "object",
442
+ "required": [
443
+ "resourceTypesPath",
444
+ "toolsPath"
445
+ ],
446
+ "properties": {
447
+ "resourceTypesPath": {
448
+ "type": "string",
449
+ "minLength": 1
450
+ },
451
+ "toolsPath": {
452
+ "type": "string",
453
+ "minLength": 1
454
+ }
455
+ }
456
+ }
457
+ ],
458
+ "semanticValidation": "Verify that resourceTypesPath and toolsPath are relative paths rooted within the suite root, that toolproof.json provides the required suite metadata, and that the referenced files exist and match the expected declaration schemas.",
459
+ "unevaluatedProperties": false
460
+ },
461
+ "projectionSchema": {
462
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
463
+ "type": "object",
464
+ "allOf": [
465
+ {
466
+ "type": "object",
467
+ "required": [
468
+ "name",
469
+ "version",
470
+ "description"
471
+ ],
472
+ "properties": {
473
+ "name": {
474
+ "$ref": "#/$defs/Name"
475
+ },
476
+ "version": {
477
+ "type": "string",
478
+ "minLength": 1
479
+ },
480
+ "description": {
481
+ "$ref": "#/$defs/Description"
482
+ }
483
+ }
484
+ },
485
+ {
486
+ "type": "object",
487
+ "required": [
488
+ "resourceTypes",
489
+ "tools"
490
+ ],
491
+ "properties": {
492
+ "resourceTypes": {
493
+ "type": "array",
494
+ "items": {
495
+ "$ref": "#/$defs/ResourceType"
496
+ },
497
+ "uniqueItems": true
498
+ },
499
+ "tools": {
500
+ "type": "array",
501
+ "items": {
502
+ "$ref": "#/$defs/Tool"
503
+ },
504
+ "uniqueItems": true
505
+ }
506
+ }
507
+ }
508
+ ],
509
+ "unevaluatedProperties": false
510
+ }
374
511
  }
375
- }
512
+ ]
@@ -0,0 +1,2 @@
1
+ import declarations from './resourceTypes.json' with { type: 'json' };
2
+ export default declarations;