@toolproof-core/lib 1.0.33 → 1.0.36

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 (90) hide show
  1. package/dist/integrations/firebase/createStep.d.ts +2 -3
  2. package/dist/integrations/firebase/createStep.js +7 -33
  3. package/dist/integrations/firebase/createThreadedStrategy.d.ts +2 -0
  4. package/dist/integrations/firebase/createThreadedStrategy.js +8 -0
  5. package/dist/integrations/firebase/firebaseAdminHelpers.d.ts +4 -10
  6. package/dist/integrations/firebase/firebaseAdminHelpers.js +43 -136
  7. package/dist/integrations/firebase/firebaseAdminInit.d.ts +0 -1
  8. package/dist/integrations/firebase/firebaseAdminInit.js +0 -1
  9. package/dist/lookups/lookups.d.ts +221 -0
  10. package/dist/lookups/lookups.js +23 -0
  11. package/dist/types/types.d.ts +8 -12
  12. package/dist/types/types.js +2 -3
  13. package/dist/utils/creation/resourceCreation.d.ts +18 -18
  14. package/dist/utils/creation/resourceCreation.js +49 -48
  15. package/dist/utils/creation/stepCreation.d.ts +7 -48
  16. package/dist/utils/creation/stepCreation.js +16 -42
  17. package/dist/utils/creation/threadedStrategyCreation.d.ts +18 -0
  18. package/dist/utils/creation/threadedStrategyCreation.js +16 -0
  19. package/dist/utils/extractData.d.ts +9 -10
  20. package/dist/utils/extractData.js +29 -25
  21. package/dist/utils/parallelizeSteps.d.ts +1 -2
  22. package/dist/utils/parallelizeSteps.js +52 -37
  23. package/dist/utils/resolveStrategyStateChain.d.ts +20 -0
  24. package/dist/utils/{resolveResourceChain.js → resolveStrategyStateChain.js} +6 -11
  25. package/dist/utils/roleSpec.d.ts +7 -3
  26. package/dist/utils/roleSpec.js +0 -1
  27. package/dist/utils/strategyState.d.ts +11 -6
  28. package/dist/utils/strategyState.js +41 -12
  29. package/dist/utils_2/threadedStrategyCreation.d.ts +5 -0
  30. package/dist/utils_2/threadedStrategyCreation.js +12 -0
  31. package/package.json +15 -15
  32. package/src/integrations/firebase/createStep.ts +9 -39
  33. package/src/integrations/firebase/createThreadedStrategy.ts +19 -0
  34. package/src/integrations/firebase/firebaseAdminHelpers.ts +61 -163
  35. package/src/lookups/lookups.ts +25 -0
  36. package/src/types/types.ts +9 -12
  37. package/src/utils/creation/resourceCreation.ts +140 -121
  38. package/src/utils/creation/stepCreation.ts +25 -95
  39. package/src/utils/creation/threadedStrategyCreation.ts +42 -0
  40. package/src/utils/extractData.ts +46 -38
  41. package/src/utils/parallelizeSteps.ts +92 -40
  42. package/src/utils/resolveStrategyStateChain.ts +58 -0
  43. package/src/utils/roleSpec.ts +7 -3
  44. package/src/utils/strategyState.ts +99 -27
  45. package/src/utils_2/threadedStrategyCreation.ts +19 -0
  46. package/tsconfig.tsbuildinfo +1 -1
  47. package/dist/artifacts/artifacts.d.ts +0 -175
  48. package/dist/artifacts/artifacts.d.ts.map +0 -1
  49. package/dist/artifacts/artifacts.js +0 -48
  50. package/dist/artifacts/artifacts.js.map +0 -1
  51. package/dist/integrations/firebase/createRunnableStrategy.d.ts +0 -3
  52. package/dist/integrations/firebase/createRunnableStrategy.d.ts.map +0 -1
  53. package/dist/integrations/firebase/createRunnableStrategy.js +0 -9
  54. package/dist/integrations/firebase/createRunnableStrategy.js.map +0 -1
  55. package/dist/integrations/firebase/createStep.d.ts.map +0 -1
  56. package/dist/integrations/firebase/createStep.js.map +0 -1
  57. package/dist/integrations/firebase/firebaseAdminHelpers.d.ts.map +0 -1
  58. package/dist/integrations/firebase/firebaseAdminHelpers.js.map +0 -1
  59. package/dist/integrations/firebase/firebaseAdminInit.d.ts.map +0 -1
  60. package/dist/integrations/firebase/firebaseAdminInit.js.map +0 -1
  61. package/dist/types/types.d.ts.map +0 -1
  62. package/dist/types/types.js.map +0 -1
  63. package/dist/utils/bindInputRoleToResource.d.ts +0 -6
  64. package/dist/utils/bindInputRoleToResource.d.ts.map +0 -1
  65. package/dist/utils/bindInputRoleToResource.js +0 -25
  66. package/dist/utils/bindInputRoleToResource.js.map +0 -1
  67. package/dist/utils/creation/resourceCreation.d.ts.map +0 -1
  68. package/dist/utils/creation/resourceCreation.js.map +0 -1
  69. package/dist/utils/creation/runnableStrategyCreation.d.ts +0 -4
  70. package/dist/utils/creation/runnableStrategyCreation.d.ts.map +0 -1
  71. package/dist/utils/creation/runnableStrategyCreation.js +0 -17
  72. package/dist/utils/creation/runnableStrategyCreation.js.map +0 -1
  73. package/dist/utils/creation/stepCreation.d.ts.map +0 -1
  74. package/dist/utils/creation/stepCreation.js.map +0 -1
  75. package/dist/utils/extractData.d.ts.map +0 -1
  76. package/dist/utils/extractData.js.map +0 -1
  77. package/dist/utils/parallelizeSteps.d.ts.map +0 -1
  78. package/dist/utils/parallelizeSteps.js.map +0 -1
  79. package/dist/utils/resolveResourceChain.d.ts +0 -19
  80. package/dist/utils/resolveResourceChain.d.ts.map +0 -1
  81. package/dist/utils/resolveResourceChain.js.map +0 -1
  82. package/dist/utils/roleSpec.d.ts.map +0 -1
  83. package/dist/utils/roleSpec.js.map +0 -1
  84. package/dist/utils/strategyState.d.ts.map +0 -1
  85. package/dist/utils/strategyState.js.map +0 -1
  86. package/src/artifacts/artifacts.ts +0 -49
  87. package/src/integrations/firebase/createRunnableStrategy.ts +0 -18
  88. package/src/utils/bindInputRoleToResource.ts +0 -53
  89. package/src/utils/creation/runnableStrategyCreation.ts +0 -28
  90. package/src/utils/resolveResourceChain.ts +0 -52
@@ -1,5 +1,5 @@
1
- import type { BranchStep, ForStep, Tool, ToolStep, WhileStep } from '@toolproof-core/schema';
2
- import { CONSTANTS } from '../../artifacts/artifacts.js';
1
+ import type { BranchStep, ForStep, Tool, ToolStep, WhileStep } from '@toolproof-core/genesis';
2
+ import { CONSTANTS } from '../../lookups/lookups.js';
3
3
  export declare function createToolStepFromTool(tool: Tool): ToolStep;
4
4
  export declare function createLoopStepFromToolPair(whatTool: Tool, whenTool: Tool, stepKind: typeof CONSTANTS.Enums.StepKind.for | typeof CONSTANTS.Enums.StepKind.while): ForStep | WhileStep;
5
5
  export declare function createBranchStepFromToolPairs(cases: Array<{
@@ -8,4 +8,3 @@ export declare function createBranchStepFromToolPairs(cases: Array<{
8
8
  }>): BranchStep;
9
9
  export declare function cloneForStep(forStep: ForStep): ForStep;
10
10
  export declare function cloneWhileStep(whileStep: WhileStep): WhileStep;
11
- //# sourceMappingURL=createStep.d.ts.map
@@ -1,43 +1,17 @@
1
- import { CONSTANTS } from '../../artifacts/artifacts.js';
2
- import { buildBranchStepFromToolPairs, buildToolStepFromTool, buildLoopStepFromToolPair, cloneForStepWithIdentities, cloneWhileStepWithIdentities, } from '../../utils/creation/stepCreation.js';
3
- import { getNewStepId } from './firebaseAdminHelpers.js';
1
+ import { CONSTANTS } from '../../lookups/lookups.js';
2
+ import { buildBranchStepFromToolPairs, buildToolStepFromTool, buildLoopStepFromToolPair, cloneForStep as cloneForStepPure, cloneWhileStep as cloneWhileStepPure, } from '../../utils/creation/stepCreation.js';
4
3
  export function createToolStepFromTool(tool) {
5
- return buildToolStepFromTool(tool, getNewStepId(CONSTANTS.Enums.StepKind.tool));
4
+ return buildToolStepFromTool(tool);
6
5
  }
7
6
  export function createLoopStepFromToolPair(whatTool, whenTool, stepKind) {
8
- if (stepKind === CONSTANTS.Enums.StepKind.for) {
9
- return buildLoopStepFromToolPair(whatTool, whenTool, {
10
- stepKind,
11
- stepId: getNewStepId(CONSTANTS.Enums.StepKind.for),
12
- whatId: getNewStepId(CONSTANTS.Enums.StepKind.tool),
13
- whenId: getNewStepId(CONSTANTS.Enums.StepKind.tool),
14
- });
15
- }
16
- return buildLoopStepFromToolPair(whatTool, whenTool, {
17
- stepKind,
18
- stepId: getNewStepId(CONSTANTS.Enums.StepKind.while),
19
- whatId: getNewStepId(CONSTANTS.Enums.StepKind.tool),
20
- whenId: getNewStepId(CONSTANTS.Enums.StepKind.tool),
21
- });
7
+ return buildLoopStepFromToolPair(whatTool, whenTool, stepKind);
22
8
  }
23
9
  export function createBranchStepFromToolPairs(cases) {
24
- return buildBranchStepFromToolPairs(cases, getNewStepId(CONSTANTS.Enums.StepKind.branch), cases.map(() => ({
25
- whatId: getNewStepId(CONSTANTS.Enums.StepKind.tool),
26
- whenId: getNewStepId(CONSTANTS.Enums.StepKind.tool),
27
- })));
10
+ return buildBranchStepFromToolPairs(cases);
28
11
  }
29
12
  export function cloneForStep(forStep) {
30
- return cloneForStepWithIdentities(forStep, {
31
- stepId: getNewStepId(CONSTANTS.Enums.StepKind.for),
32
- whatId: getNewStepId(CONSTANTS.Enums.StepKind.tool),
33
- whenId: getNewStepId(CONSTANTS.Enums.StepKind.tool),
34
- });
13
+ return cloneForStepPure(forStep);
35
14
  }
36
15
  export function cloneWhileStep(whileStep) {
37
- return cloneWhileStepWithIdentities(whileStep, {
38
- stepId: getNewStepId(CONSTANTS.Enums.StepKind.while),
39
- whatId: getNewStepId(CONSTANTS.Enums.StepKind.tool),
40
- whenId: getNewStepId(CONSTANTS.Enums.StepKind.tool),
41
- });
16
+ return cloneWhileStepPure(whileStep);
42
17
  }
43
- //# sourceMappingURL=createStep.js.map
@@ -0,0 +1,2 @@
1
+ import { type ThreadableStrategy, type ThreadedStrategyLike } from '../../utils/creation/threadedStrategyCreation.js';
2
+ export declare function createThreadedStrategy<TStrategyState>(strategy: ThreadableStrategy<TStrategyState>): ThreadedStrategyLike<TStrategyState>;
@@ -0,0 +1,8 @@
1
+ import { CONSTANTS } from '../../lookups/lookups.js';
2
+ import { buildThreadedStrategy, getThreadedStrategyStepGroups, } from '../../utils/creation/threadedStrategyCreation.js';
3
+ import { getNewId } from './firebaseAdminHelpers.js';
4
+ export function createThreadedStrategy(strategy) {
5
+ const threadStepGroups = getThreadedStrategyStepGroups(strategy);
6
+ const strategyHandle = getNewId(CONSTANTS.Names.StrategyHandle);
7
+ return buildThreadedStrategy(threadStepGroups, strategyHandle, strategy);
8
+ }
@@ -1,10 +1,4 @@
1
- import type { ResourceTypeId, StepKind } from '@toolproof-core/schema';
2
- import type { IdName, IdStringByIdName, ResourcesByType } from '../../types/types.js';
3
- type StepIdStringByStepKind<K extends StepKind> = string & {
4
- readonly __stepKind?: K;
5
- };
6
- export declare function getNewId<K extends IdName>(idName: K): IdStringByIdName<K>;
7
- export declare function getNewStepId<K extends StepKind>(stepKind: K): StepIdStringByStepKind<K>;
8
- export declare function listResources(resourceTypeIds: ResourceTypeId[]): Promise<ResourcesByType>;
9
- export {};
10
- //# sourceMappingURL=firebaseAdminHelpers.d.ts.map
1
+ import type { ResourceTypeHandle } from '@toolproof-core/genesis';
2
+ import type { IdentifierName, IdentifierStringByName, ResourcesByType } from '../../types/types.js';
3
+ export declare function getNewId<K extends IdentifierName>(identifierName: K): IdentifierStringByName<K>;
4
+ export declare function listResources(resourceTypeHandles: ResourceTypeHandle[]): Promise<ResourcesByType>;
@@ -1,154 +1,61 @@
1
- import { CONSTANTS, MAPPINGS } from '../../artifacts/artifacts.js';
1
+ import { CONSTANTS, MAPPINGS } from '../../lookups/lookups.js';
2
2
  import { dbAdmin, storageAdmin } from './firebaseAdminInit.js';
3
- function capitalizeFirst(value) {
4
- if (!value) {
5
- return value;
6
- }
7
- return value.charAt(0).toUpperCase() + value.slice(1);
8
- }
9
- export function getNewId(idName) {
10
- const prefix = MAPPINGS.IdNameToIdPrefix[idName];
3
+ export function getNewId(identifierName) {
4
+ const prefix = MAPPINGS.IdentifierNameToPrefix[identifierName];
11
5
  const docRef = dbAdmin
12
6
  .collection(CONSTANTS.Persistence.Collections.resources)
13
- .doc(idName)
7
+ .doc(identifierName)
14
8
  .collection(CONSTANTS.Persistence.Collections.members)
15
9
  .doc();
16
10
  return (prefix + docRef.id);
17
11
  }
18
- export function getNewStepId(stepKind) {
19
- const idName = `${capitalizeFirst(stepKind)}StepId`;
20
- if (!(idName in MAPPINGS.IdNameToIdPrefix)) {
21
- throw new Error(`No IdNameToIdPrefix entry for derived step id name: ${idName}`);
22
- }
23
- return getNewId(idName);
24
- }
25
- export async function listResources(resourceTypeIds) {
12
+ export async function listResources(resourceTypeHandles) {
26
13
  const bucketResources = storageAdmin.bucket(CONSTANTS.Persistence.Buckets.tp_resources);
27
14
  const bucketStrategies = storageAdmin.bucket(CONSTANTS.Persistence.Buckets.tp_strategies);
28
- async function fetchFilesUnder(resourceTypeId) {
29
- const bucket = resourceTypeId === CONSTANTS.Cosmos.TYPE_RunnableStrategy
15
+ async function fetchTimestampedMetadataUnder(resourceTypeHandle) {
16
+ const snapshot = await dbAdmin
17
+ .collection(CONSTANTS.Persistence.Collections.resources)
18
+ .doc(resourceTypeHandle)
19
+ .collection(CONSTANTS.Persistence.Collections.members)
20
+ .get();
21
+ return snapshot.docs.map((doc) => {
22
+ const data = doc.data();
23
+ if (typeof data.id !== 'string' ||
24
+ typeof data.resourceTypeHandle !== 'string' ||
25
+ !data.provenance ||
26
+ typeof data.provenance !== 'object' ||
27
+ typeof data.provenance.provenanceKind !== 'string') {
28
+ throw new Error(`Invalid TimestampedResource document for ${resourceTypeHandle}/${doc.id}`);
29
+ }
30
+ return {
31
+ id: data.id,
32
+ resourceTypeHandle: data.resourceTypeHandle,
33
+ provenance: data.provenance,
34
+ };
35
+ });
36
+ }
37
+ async function fetchProjection(resourceTypeHandle, resourceId) {
38
+ const bucket = resourceTypeHandle === CONSTANTS.Handles.ResourceTypes.TYPE_Strategy
30
39
  ? bucketStrategies
31
40
  : bucketResources;
32
- const prefix = `${resourceTypeId}/`;
33
- const [found] = await bucket.getFiles({ prefix });
34
- const files = found.filter((file) => {
35
- const name = file.name || '';
36
- return !!name && !name.endsWith('/');
37
- });
38
- if (!files.length) {
39
- return [];
41
+ const file = bucket.file(`${resourceTypeHandle}/${resourceId}`);
42
+ const [exists] = await file.exists();
43
+ if (!exists) {
44
+ throw new Error(`Missing projection blob for ${resourceTypeHandle}/${resourceId}`);
40
45
  }
41
- const items = await Promise.all(files.map(async (file) => {
42
- try {
43
- const [buf] = await file.download();
44
- const meta = file.metadata || (await file.getMetadata())[0];
45
- const data = JSON.parse(buf.toString('utf8'));
46
- return { data, meta, name: file.name };
47
- }
48
- catch {
49
- return null;
50
- }
51
- }));
52
- return items.filter(Boolean);
46
+ const [buf] = await file.download();
47
+ return JSON.parse(buf.toString('utf8'));
53
48
  }
54
- const entries = await Promise.all(resourceTypeIds.map(async (resourceTypeId) => {
55
- const rows = await fetchFilesUnder(resourceTypeId);
56
- const items = rows.map(({ data, meta, name }) => {
57
- const flat = meta?.metadata ?? {};
58
- const root = {};
59
- for (const [key, valueRaw] of Object.entries(flat)) {
60
- if (typeof valueRaw !== 'string') {
61
- continue;
62
- }
63
- const valueString = valueRaw.trim();
64
- let value = valueString;
65
- if ((valueString.startsWith('{') && valueString.endsWith('}')) || (valueString.startsWith('[') && valueString.endsWith(']'))) {
66
- try {
67
- value = JSON.parse(valueString);
68
- }
69
- catch {
70
- value = valueString;
71
- }
72
- }
73
- const segments = key.split('.');
74
- let cursor = root;
75
- for (const [index, segment] of segments.entries()) {
76
- const arrIdxMatch = segment.match(/^(.*)\[(\d+)\]$/);
77
- if (arrIdxMatch) {
78
- const base = arrIdxMatch[1];
79
- const idxStr = arrIdxMatch[2];
80
- if (base === undefined || idxStr === undefined) {
81
- continue;
82
- }
83
- const idx = parseInt(idxStr, 10);
84
- if (!cursor[base] || !Array.isArray(cursor[base])) {
85
- cursor[base] = [];
86
- }
87
- while (cursor[base].length <= idx) {
88
- cursor[base].push(undefined);
89
- }
90
- if (index === segments.length - 1) {
91
- cursor[base][idx] = value;
92
- }
93
- else {
94
- if (!cursor[base][idx]) {
95
- cursor[base][idx] = {};
96
- }
97
- cursor = cursor[base][idx];
98
- }
99
- }
100
- else {
101
- if (index === segments.length - 1) {
102
- cursor[segment] = value;
103
- }
104
- else {
105
- if (!cursor[segment] || typeof cursor[segment] !== 'object') {
106
- cursor[segment] = {};
107
- }
108
- cursor = cursor[segment];
109
- }
110
- }
111
- }
112
- }
113
- const id = root.id;
114
- const resourceRoleId = root.creationContext.resourceRoleId;
115
- const toolStepId = root.creationContext.toolStepId;
116
- const resourceShellKind = root.resourceShellKind;
117
- const versionRaw = root.version;
118
- const version = typeof versionRaw === 'number'
119
- ? versionRaw
120
- : parseInt(String(versionRaw ?? ''), 10);
121
- const resourcePath = root.path;
122
- const timestamp = root.timestamp;
123
- const missing = [
124
- ['id', id],
125
- ['resourceRoleId', resourceRoleId],
126
- ['toolStepId', toolStepId],
127
- ['resourceShellKind', resourceShellKind],
128
- ['version', Number.isFinite(version) ? String(version) : ''],
129
- ['timestamp', timestamp],
130
- ['path', resourcePath],
131
- ].filter(([_, value]) => typeof value !== 'string' || value.length === 0);
132
- if (missing.length) {
133
- const keys = missing.map(([key]) => key).join(', ');
134
- throw new Error(`Missing required metadata keys [${keys}] for resource file: ${name}`);
135
- }
49
+ const entries = await Promise.all(resourceTypeHandles.map(async (resourceTypeHandle) => {
50
+ const pointers = await fetchTimestampedMetadataUnder(resourceTypeHandle);
51
+ const items = await Promise.all(pointers.map(async (resourcePointer) => {
52
+ const projection = await fetchProjection(resourceTypeHandle, resourcePointer.id);
136
53
  return {
137
- id,
138
- resourceTypeId,
139
- creationContext: {
140
- resourceRoleId,
141
- toolStepId,
142
- },
143
- resourceShellKind,
144
- version,
145
- timestamp: timestamp,
146
- path: resourcePath,
147
- nucleus: data,
54
+ ...resourcePointer,
55
+ projection,
148
56
  };
149
- });
150
- return [resourceTypeId, items];
57
+ }));
58
+ return [resourceTypeHandle, items];
151
59
  }));
152
60
  return Object.fromEntries(entries);
153
61
  }
154
- //# sourceMappingURL=firebaseAdminHelpers.js.map
@@ -1,4 +1,3 @@
1
1
  declare const dbAdmin: FirebaseFirestore.Firestore;
2
2
  declare const storageAdmin: import("firebase-admin/storage").Storage;
3
3
  export { dbAdmin, storageAdmin };
4
- //# sourceMappingURL=firebaseAdminInit.d.ts.map
@@ -30,4 +30,3 @@ const app = getApps().length ? getApp() : initializeApp({
30
30
  const dbAdmin = getFirestore(app);
31
31
  const storageAdmin = getStorage(app);
32
32
  export { dbAdmin, storageAdmin };
33
- //# sourceMappingURL=firebaseAdminInit.js.map
@@ -0,0 +1,221 @@
1
+ export declare const CONSTANTS: {
2
+ readonly Persistence: {
3
+ readonly Buckets: {
4
+ readonly tp_resources: "tp-resources";
5
+ readonly tp_strategies: "tp-strategies";
6
+ };
7
+ readonly Collections: {
8
+ readonly resources: "resources";
9
+ readonly members: "members";
10
+ };
11
+ };
12
+ readonly Engine: {
13
+ readonly Graphs: {
14
+ readonly GraphRunStrategy: "GraphRunStrategy";
15
+ readonly GraphBuildStrategy: "GraphBuildStrategy";
16
+ };
17
+ };
18
+ readonly Names: {
19
+ readonly AtomicTypeRef: "AtomicTypeRef";
20
+ readonly BaseResource: "BaseResource";
21
+ readonly BaseStrategy: "BaseStrategy";
22
+ readonly BaseToolStepPathSpec: "BaseToolStepPathSpec";
23
+ readonly BaseTracePoint: "BaseTracePoint";
24
+ readonly Boolean: "Boolean";
25
+ readonly BranchStep: "BranchStep";
26
+ readonly Case: "Case";
27
+ readonly ContainerKind: "ContainerKind";
28
+ readonly Description: "Description";
29
+ readonly DescriptionFacet: "DescriptionFacet";
30
+ readonly DocumentationSpec: "DocumentationSpec";
31
+ readonly Embedding: "Embedding";
32
+ readonly Error: "Error";
33
+ readonly ExternalInputPotential: "ExternalInputPotential";
34
+ readonly ForStep: "ForStep";
35
+ readonly GenesisProvenance: "GenesisProvenance";
36
+ readonly Goal: "Goal";
37
+ readonly GoalHandle: "GoalHandle";
38
+ readonly GraphEndTracePoint: "GraphEndTracePoint";
39
+ readonly GraphStartTracePoint: "GraphStartTracePoint";
40
+ readonly InputPotential: "InputPotential";
41
+ readonly InputResource: "InputResource";
42
+ readonly InternalInputPotential: "InternalInputPotential";
43
+ readonly InterruptTracePoint: "InterruptTracePoint";
44
+ readonly JsonScalarLink: "JsonScalarLink";
45
+ readonly JsonSchemaObject: "JsonSchemaObject";
46
+ readonly Name: "Name";
47
+ readonly NameFacet: "NameFacet";
48
+ readonly Natural: "Natural";
49
+ readonly Provenance: "Provenance";
50
+ readonly ProvenanceFacet: "ProvenanceFacet";
51
+ readonly ProvenanceKind: "ProvenanceKind";
52
+ readonly Resource: "Resource";
53
+ readonly ResourceId: "ResourceId";
54
+ readonly ResourcePointer: "ResourcePointer";
55
+ readonly ResourceType: "ResourceType";
56
+ readonly ResourceTypeHandle: "ResourceTypeHandle";
57
+ readonly RoleBindingSpec: "RoleBindingSpec";
58
+ readonly RoleBindingSpecFacet: "RoleBindingSpecFacet";
59
+ readonly RoleName: "RoleName";
60
+ readonly RoleNameArray: "RoleNameArray";
61
+ readonly RoleSpec: "RoleSpec";
62
+ readonly RoleSpecFacet: "RoleSpecFacet";
63
+ readonly RoleValue: "RoleValue";
64
+ readonly RoleValueByName: "RoleValueByName";
65
+ readonly RuntimeProvenance: "RuntimeProvenance";
66
+ readonly Step: "Step";
67
+ readonly StepArray: "StepArray";
68
+ readonly StepArrayArray: "StepArrayArray";
69
+ readonly StepKind: "StepKind";
70
+ readonly StepKindFacet: "StepKindFacet";
71
+ readonly StepsByThreadIndexFacet: "StepsByThreadIndexFacet";
72
+ readonly StepsFacet: "StepsFacet";
73
+ readonly Strategy: "Strategy";
74
+ readonly StrategyHandle: "StrategyHandle";
75
+ readonly StrategyKind: "StrategyKind";
76
+ readonly StrategyProvenance: "StrategyProvenance";
77
+ readonly StrategyStateInputEntry: "StrategyStateInputEntry";
78
+ readonly StrategyStateInputEntryByRoleName: "StrategyStateInputEntryByRoleName";
79
+ readonly StrategyStateInputKind: "StrategyStateInputKind";
80
+ readonly StrategyTrace: "StrategyTrace";
81
+ readonly StrategyTraceHandle: "StrategyTraceHandle";
82
+ readonly Suite: "Suite";
83
+ readonly SuiteIngestorInputSchema: "SuiteIngestorInputSchema";
84
+ readonly ThreadedStrategy: "ThreadedStrategy";
85
+ readonly ThreadedStrategyFacet: "ThreadedStrategyFacet";
86
+ readonly ThreadedStrategyState: "ThreadedStrategyState";
87
+ readonly ThreadedStrategyStateFacet: "ThreadedStrategyStateFacet";
88
+ readonly ThreadedToolStepPath: "ThreadedToolStepPath";
89
+ readonly ThreadedToolStepPathSpec: "ThreadedToolStepPathSpec";
90
+ readonly TickTracePoint: "TickTracePoint";
91
+ readonly TimestampedResource: "TimestampedResource";
92
+ readonly Tool: "Tool";
93
+ readonly ToolHandle: "ToolHandle";
94
+ readonly ToolStep: "ToolStep";
95
+ readonly ToolStepPath: "ToolStepPath";
96
+ readonly ToolStepPathSlot: "ToolStepPathSlot";
97
+ readonly ToolStepPathSlotFacet: "ToolStepPathSlotFacet";
98
+ readonly ToolStepRoleAddress: "ToolStepRoleAddress";
99
+ readonly TracePoint: "TracePoint";
100
+ readonly TracePointCounterSnapshot: "TracePointCounterSnapshot";
101
+ readonly TracePointDelta: "TracePointDelta";
102
+ readonly TracePointKind: "TracePointKind";
103
+ readonly TypeRef: "TypeRef";
104
+ readonly UnthreadedStrategy: "UnthreadedStrategy";
105
+ readonly UnthreadedStrategyState: "UnthreadedStrategyState";
106
+ readonly UnthreadedStrategyStateFacet: "UnthreadedStrategyStateFacet";
107
+ readonly UnthreadedToolStepPath: "UnthreadedToolStepPath";
108
+ readonly UnthreadedToolStepPathSpec: "UnthreadedToolStepPathSpec";
109
+ readonly WhileStep: "WhileStep";
110
+ };
111
+ readonly Handles: {
112
+ readonly ResourceTypes: {
113
+ readonly TYPE_Boolean: "TYPE-Boolean";
114
+ readonly TYPE_Error: "TYPE-Error";
115
+ readonly TYPE_Goal: "TYPE-Goal";
116
+ readonly TYPE_Natural: "TYPE-Natural";
117
+ readonly TYPE_Resource: "TYPE-Resource";
118
+ readonly TYPE_ResourceType: "TYPE-ResourceType";
119
+ readonly TYPE_Strategy: "TYPE-Strategy";
120
+ readonly TYPE_StrategyTrace: "TYPE-StrategyTrace";
121
+ readonly TYPE_Suite: "TYPE-Suite";
122
+ readonly TYPE_Tool: "TYPE-Tool";
123
+ };
124
+ readonly Tools: {
125
+ readonly TOOL_Add: "TOOL-Add";
126
+ readonly TOOL_BooleanIdentity: "TOOL-BooleanIdentity";
127
+ readonly TOOL_Divide: "TOOL-Divide";
128
+ readonly TOOL_Double: "TOOL-Double";
129
+ readonly TOOL_Identity: "TOOL-Identity";
130
+ readonly TOOL_LessThan: "TOOL-LessThan";
131
+ readonly TOOL_Multiply: "TOOL-Multiply";
132
+ readonly TOOL_NaturalAdd: "TOOL-NaturalAdd";
133
+ readonly TOOL_NaturalDivide: "TOOL-NaturalDivide";
134
+ readonly TOOL_NaturalDouble: "TOOL-NaturalDouble";
135
+ readonly TOOL_NaturalIdentity: "TOOL-NaturalIdentity";
136
+ readonly TOOL_NaturalLessThan: "TOOL-NaturalLessThan";
137
+ readonly TOOL_NaturalMultiply: "TOOL-NaturalMultiply";
138
+ readonly TOOL_NaturalSubtract: "TOOL-NaturalSubtract";
139
+ readonly TOOL_Subtract: "TOOL-Subtract";
140
+ };
141
+ };
142
+ readonly ToolRoleNames: {
143
+ readonly TOOL_Add: {
144
+ readonly AddendOne: "AddendOne";
145
+ readonly AddendTwo: "AddendTwo";
146
+ readonly Sum: "Sum";
147
+ };
148
+ readonly TOOL_Divide: {
149
+ readonly Dividend: "Dividend";
150
+ readonly Divisor: "Divisor";
151
+ readonly Quotient: "Quotient";
152
+ readonly Remainder: "Remainder";
153
+ };
154
+ readonly TOOL_Double: {
155
+ readonly Doubled: "Doubled";
156
+ readonly N: "N";
157
+ };
158
+ readonly TOOL_Identity: {
159
+ readonly In: "In";
160
+ readonly Out: "Out";
161
+ };
162
+ readonly TOOL_LessThan: {
163
+ readonly LessThanDecision: "LessThanDecision";
164
+ readonly LessThanSource: "LessThanSource";
165
+ readonly LessThanTarget: "LessThanTarget";
166
+ };
167
+ readonly TOOL_Multiply: {
168
+ readonly Multiplicand: "Multiplicand";
169
+ readonly Multiplier: "Multiplier";
170
+ readonly Product: "Product";
171
+ };
172
+ readonly TOOL_Subtract: {
173
+ readonly Difference: "Difference";
174
+ readonly Minuend: "Minuend";
175
+ readonly Subtrahend: "Subtrahend";
176
+ };
177
+ };
178
+ readonly Enums: {
179
+ readonly ContainerKind: {
180
+ readonly scalar: "scalar";
181
+ readonly array: "array";
182
+ readonly map: "map";
183
+ };
184
+ readonly ProvenanceKind: {
185
+ readonly genesis: "genesis";
186
+ readonly runtime: "runtime";
187
+ readonly strategy: "strategy";
188
+ };
189
+ readonly StepKind: {
190
+ readonly tool: "tool";
191
+ readonly branch: "branch";
192
+ readonly while: "while";
193
+ readonly for: "for";
194
+ };
195
+ readonly StrategyKind: {
196
+ readonly unthreaded: "unthreaded";
197
+ readonly threaded: "threaded";
198
+ };
199
+ readonly StrategyStateInputKind: {
200
+ readonly inputResource: "inputResource";
201
+ readonly externalInputPotential: "externalInputPotential";
202
+ readonly internalInputPotential: "internalInputPotential";
203
+ };
204
+ readonly TracePointKind: {
205
+ readonly graph_start: "graph_start";
206
+ readonly tick: "tick";
207
+ readonly interrupt: "interrupt";
208
+ readonly graph_end: "graph_end";
209
+ };
210
+ };
211
+ };
212
+ export declare const MAPPINGS: {
213
+ readonly IdentifierNameToPrefix: {
214
+ readonly GoalHandle: "GOAL-";
215
+ readonly ResourceId: "RESOURCE-";
216
+ readonly ResourceTypeHandle: "TYPE-";
217
+ readonly StrategyHandle: "STRATEGY-";
218
+ readonly StrategyTraceHandle: "STRATEGY_TRACE-";
219
+ readonly ToolHandle: "TOOL-";
220
+ };
221
+ };
@@ -0,0 +1,23 @@
1
+ import { CONSTANTS as _CONSTANTS, MAPPINGS as _MAPPINGS } from '@toolproof-core/genesis';
2
+ export const CONSTANTS = {
3
+ ..._CONSTANTS,
4
+ Persistence: {
5
+ Buckets: {
6
+ tp_resources: 'tp-resources',
7
+ tp_strategies: 'tp-strategies',
8
+ },
9
+ Collections: {
10
+ resources: 'resources',
11
+ members: 'members',
12
+ },
13
+ },
14
+ Engine: {
15
+ Graphs: {
16
+ GraphRunStrategy: 'GraphRunStrategy',
17
+ GraphBuildStrategy: 'GraphBuildStrategy',
18
+ },
19
+ },
20
+ };
21
+ export const MAPPINGS = {
22
+ ..._MAPPINGS,
23
+ };
@@ -1,20 +1,16 @@
1
- import type { StepKind, Resource, ResourceTypeId } from '@toolproof-core/schema';
2
- import { CONSTANTS } from '../artifacts/artifacts.js';
3
- import { MAPPINGS } from '../artifacts/artifacts.js';
1
+ import type { Resource, ResourceTypeHandle } from '@toolproof-core/genesis/types';
2
+ import { CONSTANTS } from '../lookups/lookups.js';
3
+ import { MAPPINGS } from '../lookups/lookups.js';
4
4
  export type Bucket = typeof CONSTANTS.Persistence.Buckets.tp_resources;
5
5
  export type Collection = keyof typeof CONSTANTS.Persistence.Collections;
6
6
  export type SchemaLike = Record<string, unknown>;
7
- export type ResourcesByType = Record<ResourceTypeId, Resource[]>;
8
- export type IdName = keyof typeof MAPPINGS.IdNameToIdPrefix;
9
- export type IdStringByIdName<K extends IdName> = `${(typeof MAPPINGS.IdNameToIdPrefix)[K]}${string}`;
10
- export type StepIdStringByStepKind<K extends StepKind> = string & {
11
- readonly __stepKind?: K;
12
- };
13
- export interface NucleusBaseSmall<T extends string = string> {
7
+ export type ResourcesByType = Record<ResourceTypeHandle, Resource[]>;
8
+ export type IdentifierName = keyof typeof MAPPINGS.IdentifierNameToPrefix;
9
+ export type IdentifierStringByName<K extends IdentifierName> = `${(typeof MAPPINGS.IdentifierNameToPrefix)[K]}${string}`;
10
+ export interface SmallBaseProjection<T extends string = string> {
14
11
  id: T;
15
12
  }
16
- export interface NucleusBaseLarge<T extends string = string> extends NucleusBaseSmall<T> {
13
+ export interface LargeBaseProjection<T extends string = string> extends SmallBaseProjection<T> {
17
14
  name: string;
18
15
  description: string;
19
16
  }
20
- //# sourceMappingURL=types.d.ts.map
@@ -1,3 +1,2 @@
1
- import { CONSTANTS } from '../artifacts/artifacts.js';
2
- import { MAPPINGS } from '../artifacts/artifacts.js';
3
- //# sourceMappingURL=types.js.map
1
+ import { CONSTANTS } from '../lookups/lookups.js';
2
+ import { MAPPINGS } from '../lookups/lookups.js';
@@ -1,21 +1,21 @@
1
- import type { CreationContext, ExternalInput, ReferenceInput, ResourceId, Resource, ResourceTypeId, StrategyRunId } from '@toolproof-core/schema';
1
+ import type { ToolStepRoleAddress, ExternalInputPotential, InternalInputPotential, ResourceId, Resource, ResourcePointer, ResourceTypeHandle, StrategyProvenance, Provenance, StrategyTraceHandle } from '@toolproof-core/genesis';
2
+ type RuntimeProvenance = Extract<Provenance, {
3
+ provenanceKind: 'runtime';
4
+ }>;
2
5
  export interface OutputPotential {
3
6
  id: ResourceId;
4
- resourceTypeId: ResourceTypeId;
5
- creationContext: CreationContext;
6
- strategyRunId?: StrategyRunId;
7
+ resourceTypeHandle: ResourceTypeHandle;
8
+ toolStepRoleAddress?: ToolStepRoleAddress;
9
+ strategyTraceHandle?: StrategyTraceHandle;
10
+ provenanceKind?: Provenance['provenanceKind'];
7
11
  }
8
- export type InputPotential = ReferenceInput & {
9
- id: ResourceId;
10
- resourceTypeId: ResourceTypeId;
11
- creationContext: CreationContext;
12
- strategyRunId?: StrategyRunId;
13
- };
14
- export declare function generatePath(resourceTypeId: ResourceTypeId, id: ResourceId): string;
15
- export declare function createMaterializedFromOutputPotential(outputPotential: OutputPotential, nucleus: unknown, timestamp?: string): Resource;
16
- export declare function createMaterializedFromInputPotential(inputPotential: InputPotential, nucleus: unknown, timestamp?: string): Resource;
17
- export declare function createMaterializedFromPotential(potential: InputPotential | OutputPotential, nucleus: unknown, timestamp?: string): Resource;
18
- export declare function createExternalInputPotential(_id: ResourceId, _resourceTypeId: ResourceTypeId): ExternalInput;
19
- export declare function createInputPotential(id: ResourceId, resourceTypeId: ResourceTypeId, creationContext: CreationContext): InputPotential;
20
- export declare function createOutputPotential(id: ResourceId, resourceTypeId: ResourceTypeId, creationContext: CreationContext): OutputPotential;
21
- //# sourceMappingURL=resourceCreation.d.ts.map
12
+ export declare function createExternalInputPotential(): ExternalInputPotential;
13
+ export declare function createInternalInputPotential(toolStepRoleAddress: ToolStepRoleAddress): InternalInputPotential;
14
+ export declare function createStrategyProvenance(strategyTraceHandle: StrategyTraceHandle, toolStepRoleAddress: ToolStepRoleAddress): StrategyProvenance;
15
+ export declare function createRuntimeProvenance(): RuntimeProvenance;
16
+ export declare function createResourcePointer(id: ResourceId, resourceTypeHandle: ResourceTypeHandle, provenance: Provenance): ResourcePointer;
17
+ export declare function createResource(resourcePointer: ResourcePointer, projection: unknown): Resource;
18
+ export declare function createMaterializedFromOutputPotential(outputPotential: OutputPotential, projection: unknown): Resource;
19
+ export declare function createMaterializedFromPotential(outputPotential: OutputPotential, projection: unknown): Resource;
20
+ export declare function createOutputPotential(id: ResourceId, resourceTypeHandle: ResourceTypeHandle, toolStepRoleAddress?: ToolStepRoleAddress, strategyTraceHandle?: StrategyTraceHandle, provenanceKind?: Provenance['provenanceKind']): OutputPotential;
21
+ export {};