@toolproof-core/lib 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.
@@ -4,12 +4,10 @@ export type MutableBranchStepKey = `BRANCH_STEP-${string}`;
4
4
  export type MutableWhileStepKey = `WHILE_STEP-${string}`;
5
5
  export type MutableForStepKey = `FOR_STEP-${string}`;
6
6
  export type MutableLoopStepKey = MutableWhileStepKey | MutableForStepKey;
7
- export type MutableMacroStepKey = MutableBranchStepKey | MutableLoopStepKey;
8
- export type MutableStepKey = MutableToolStepKey | MutableMacroStepKey;
7
+ export type MutableStepKey = MutableToolStepKey | MutableBranchStepKey | MutableLoopStepKey;
9
8
  export type MutableMaterializedResource = MaterializedResource;
10
9
  export type MutableToolStepRoleAddress = Omit<ToolStepRoleAddress, 'toolStepPath'> & {
11
10
  stepKey: MutableToolStepKey;
12
- toolStepKey: MutableToolStepKey;
13
11
  };
14
12
  export type MutableInternalInputPotential = Omit<InternalInputPotential, 'toolStepRoleAddress'> & {
15
13
  toolStepRoleAddress: MutableToolStepRoleAddress;
@@ -20,7 +18,6 @@ export type MutableStrategyStateEntryByRoleName = Partial<Record<RoleName, Mutab
20
18
  export type MutableStrategyState = Partial<Record<MutableToolStepKey, MutableStrategyStateEntryByRoleName>>;
21
19
  export type MutableToolStep = ToolStep & {
22
20
  stepKey: MutableToolStepKey;
23
- toolStepKey: MutableToolStepKey;
24
21
  };
25
22
  export type MutableCase = Omit<Case, 'when' | 'what'> & {
26
23
  when: MutableToolStep;
@@ -28,17 +25,14 @@ export type MutableCase = Omit<Case, 'when' | 'what'> & {
28
25
  };
29
26
  export type MutableBranchStep = Omit<BranchStep, 'cases'> & {
30
27
  stepKey: MutableBranchStepKey;
31
- macroStepKey: MutableBranchStepKey;
32
28
  cases: [MutableCase, ...MutableCase[]];
33
29
  };
34
30
  export type MutableWhileStep = Omit<WhileStep, 'case'> & {
35
31
  stepKey: MutableWhileStepKey;
36
- macroStepKey: MutableWhileStepKey;
37
32
  case: MutableCase;
38
33
  };
39
34
  export type MutableForStep = Omit<ForStep, 'case'> & {
40
35
  stepKey: MutableForStepKey;
41
- macroStepKey: MutableForStepKey;
42
36
  case: MutableCase;
43
37
  };
44
38
  export type MutableStep = MutableToolStep | MutableBranchStep | MutableWhileStep | MutableForStep;
@@ -48,7 +42,7 @@ export type MutableStrategy = Omit<Strategy, 'stepsByThreadIndex' | 'strategySta
48
42
  };
49
43
  export declare function getAuthoringSteps(strategy: MutableStrategy): MutableStep[];
50
44
  export declare function setAuthoringSteps(strategy: MutableStrategy, steps: MutableStep[]): MutableStrategy;
51
- export declare function getStrategyStateEntryByRoleName(strategyState: MutableStrategyState, toolStepKey: MutableToolStepKey): MutableStrategyStateEntryByRoleName | undefined;
45
+ export declare function getStrategyStateEntryByRoleName(strategyState: MutableStrategyState, stepKey: MutableToolStepKey): MutableStrategyStateEntryByRoleName | undefined;
52
46
  export declare function getStrategyStateEntry(strategyState: MutableStrategyState, toolStepRoleAddress: MutableToolStepRoleAddress): MutableStrategyStateEntry | undefined;
53
47
  export declare function setStrategyStateEntry(strategyState: MutableStrategyState, toolStepRoleAddress: MutableToolStepRoleAddress, entry: MutableStrategyStateEntry): MutableStrategyState;
54
48
  export declare function clearInputBinding(strategyState: MutableStrategyState, toolStepRoleAddress: MutableToolStepRoleAddress): MutableStrategyState;
@@ -10,25 +10,25 @@ export function setAuthoringSteps(strategy, steps) {
10
10
  stepsByThreadIndex: nextStepsByThreadIndex,
11
11
  };
12
12
  }
13
- export function getStrategyStateEntryByRoleName(strategyState, toolStepKey) {
14
- return strategyState[toolStepKey];
13
+ export function getStrategyStateEntryByRoleName(strategyState, stepKey) {
14
+ return strategyState[stepKey];
15
15
  }
16
16
  export function getStrategyStateEntry(strategyState, toolStepRoleAddress) {
17
- const inputEntryByRoleName = getStrategyStateEntryByRoleName(strategyState, toolStepRoleAddress.toolStepKey);
17
+ const inputEntryByRoleName = getStrategyStateEntryByRoleName(strategyState, toolStepRoleAddress.stepKey);
18
18
  return inputEntryByRoleName?.[toolStepRoleAddress.roleName];
19
19
  }
20
20
  export function setStrategyStateEntry(strategyState, toolStepRoleAddress, entry) {
21
- const inputEntryByRoleName = getStrategyStateEntryByRoleName(strategyState, toolStepRoleAddress.toolStepKey) ?? {};
21
+ const inputEntryByRoleName = getStrategyStateEntryByRoleName(strategyState, toolStepRoleAddress.stepKey) ?? {};
22
22
  return {
23
23
  ...strategyState,
24
- [toolStepRoleAddress.toolStepKey]: {
24
+ [toolStepRoleAddress.stepKey]: {
25
25
  ...inputEntryByRoleName,
26
26
  [toolStepRoleAddress.roleName]: entry,
27
27
  },
28
28
  };
29
29
  }
30
30
  export function clearInputBinding(strategyState, toolStepRoleAddress) {
31
- const inputEntryByRoleName = getStrategyStateEntryByRoleName(strategyState, toolStepRoleAddress.toolStepKey);
31
+ const inputEntryByRoleName = getStrategyStateEntryByRoleName(strategyState, toolStepRoleAddress.stepKey);
32
32
  if (!inputEntryByRoleName || !(toolStepRoleAddress.roleName in inputEntryByRoleName)) {
33
33
  return strategyState;
34
34
  }
@@ -36,12 +36,12 @@ export function clearInputBinding(strategyState, toolStepRoleAddress) {
36
36
  delete nextInputEntryByRoleName[toolStepRoleAddress.roleName];
37
37
  if (Object.keys(nextInputEntryByRoleName).length === 0) {
38
38
  const nextStrategyState = { ...strategyState };
39
- delete nextStrategyState[toolStepRoleAddress.toolStepKey];
39
+ delete nextStrategyState[toolStepRoleAddress.stepKey];
40
40
  return nextStrategyState;
41
41
  }
42
42
  return {
43
43
  ...strategyState,
44
- [toolStepRoleAddress.toolStepKey]: nextInputEntryByRoleName,
44
+ [toolStepRoleAddress.stepKey]: nextInputEntryByRoleName,
45
45
  };
46
46
  }
47
47
  export function bindMaterializedResource(strategyState, target, resource) {
@@ -58,13 +58,13 @@ function getOutputRoleValue(tool, roleName) {
58
58
  return tool.roleSpec.outputRoleValueByName[roleName];
59
59
  }
60
60
  export function bindInternalInputPotential(strategyState, targetAddress, sourceAddress, context) {
61
- const sourceToolStep = context.toolStepByKey.get(sourceAddress.toolStepKey);
61
+ const sourceToolStep = context.toolStepByKey.get(sourceAddress.stepKey);
62
62
  if (!sourceToolStep) {
63
- throw new Error(`Source tool step not found for '${sourceAddress.toolStepKey}'.`);
63
+ throw new Error(`Source tool step not found for '${sourceAddress.stepKey}'.`);
64
64
  }
65
- const targetToolStep = context.toolStepByKey.get(targetAddress.toolStepKey);
65
+ const targetToolStep = context.toolStepByKey.get(targetAddress.stepKey);
66
66
  if (!targetToolStep) {
67
- throw new Error(`Target tool step not found for '${targetAddress.toolStepKey}'.`);
67
+ throw new Error(`Target tool step not found for '${targetAddress.stepKey}'.`);
68
68
  }
69
69
  const sourceTool = context.toolMap.get(sourceToolStep.toolHandle);
70
70
  if (!sourceTool) {
@@ -76,11 +76,11 @@ export function bindInternalInputPotential(strategyState, targetAddress, sourceA
76
76
  }
77
77
  const targetInputRoleValue = getInputRoleValue(targetTool, targetAddress.roleName);
78
78
  if (!targetInputRoleValue) {
79
- throw new Error(`Target input role not found for (${targetAddress.toolStepKey}, ${targetAddress.roleName}).`);
79
+ throw new Error(`Target input role not found for (${targetAddress.stepKey}, ${targetAddress.roleName}).`);
80
80
  }
81
81
  const sourceOutputRoleValue = getOutputRoleValue(sourceTool, sourceAddress.roleName);
82
82
  const sourceInputRoleValue = getInputRoleValue(sourceTool, sourceAddress.roleName);
83
- const sourceInputEntryByRoleName = strategyState[sourceAddress.toolStepKey];
83
+ const sourceInputEntryByRoleName = strategyState[sourceAddress.stepKey];
84
84
  const sourceInputEntry = sourceInputEntryByRoleName?.[sourceAddress.roleName];
85
85
  const sourceRoleType = sourceOutputRoleValue
86
86
  ? extractResourceTypeHandleFromRoleValue(sourceOutputRoleValue)
@@ -90,20 +90,19 @@ export function bindInternalInputPotential(strategyState, targetAddress, sourceA
90
90
  const targetRoleType = extractResourceTypeHandleFromRoleValue(targetInputRoleValue);
91
91
  if (!sourceOutputRoleValue && sourceInputRoleValue) {
92
92
  if (!sourceInputEntry) {
93
- throw new Error(`Source input role is not bound for (${sourceAddress.toolStepKey}, ${sourceAddress.roleName}).`); // ATTENTION: not an ontological invariant, but it might help catch some mistakes early on.
93
+ throw new Error(`Source input role is not bound for (${sourceAddress.stepKey}, ${sourceAddress.roleName}).`); // ATTENTION: not an ontological invariant, but it might help catch some mistakes early on.
94
94
  }
95
95
  }
96
96
  if (!sourceOutputRoleValue && !sourceInputRoleValue) {
97
- throw new Error(`Source role not found for (${sourceAddress.toolStepKey}, ${sourceAddress.roleName}).`);
97
+ throw new Error(`Source role not found for (${sourceAddress.stepKey}, ${sourceAddress.roleName}).`);
98
98
  }
99
99
  if (!sourceRoleType || !targetRoleType || sourceRoleType !== targetRoleType) {
100
- throw new Error(`Reference type mismatch between source (${sourceAddress.toolStepKey}, ${sourceAddress.roleName}) and target (${targetAddress.toolStepKey}, ${targetAddress.roleName}).`);
100
+ throw new Error(`Reference type mismatch between source (${sourceAddress.stepKey}, ${sourceAddress.roleName}) and target (${targetAddress.stepKey}, ${targetAddress.roleName}).`);
101
101
  }
102
102
  return setStrategyStateEntry(strategyState, targetAddress, {
103
103
  strategyStateEntryKind: 'internalInputPotential',
104
104
  toolStepRoleAddress: {
105
105
  stepKey: sourceAddress.stepKey,
106
- toolStepKey: sourceAddress.toolStepKey,
107
106
  roleName: sourceAddress.roleName,
108
107
  },
109
108
  });
@@ -15,7 +15,6 @@ function getRoleBindingSpec(tool) {
15
15
  export function createToolStepFromTool(tool) {
16
16
  return {
17
17
  stepKey: generateIdentifier('ToolStepKey'),
18
- toolStepKey: generateIdentifier('ToolStepKey'),
19
18
  stepKind: CONSTANTS.Enums.StepKind.tool,
20
19
  toolHandle: tool.handle,
21
20
  roleBindingSpec: getRoleBindingSpec(tool),
@@ -34,14 +33,12 @@ export function createLoopStepFromCase(stepCase, stepKind) {
34
33
  if (stepKind === CONSTANTS.Enums.StepKind.for) {
35
34
  return {
36
35
  stepKey: generateIdentifier('ForStepKey'),
37
- macroStepKey: generateIdentifier('ForStepKey'),
38
36
  stepKind: CONSTANTS.Enums.StepKind.for,
39
37
  case: stepCase,
40
38
  };
41
39
  }
42
40
  return {
43
41
  stepKey: generateIdentifier('WhileStepKey'),
44
- macroStepKey: generateIdentifier('WhileStepKey'),
45
42
  stepKind: CONSTANTS.Enums.StepKind.while,
46
43
  case: stepCase,
47
44
  };
@@ -50,7 +47,6 @@ export function createBranchStepFromCases(cases) {
50
47
  assertNonEmpty(cases, 'createBranchStepFromCases requires at least one case');
51
48
  return {
52
49
  stepKey: generateIdentifier('BranchStepKey'),
53
- macroStepKey: generateIdentifier('BranchStepKey'),
54
50
  stepKind: CONSTANTS.Enums.StepKind.branch,
55
51
  cases,
56
52
  };
@@ -58,16 +54,15 @@ export function createBranchStepFromCases(cases) {
58
54
  export function cloneForStep(forStep) {
59
55
  return {
60
56
  stepKey: generateIdentifier('ForStepKey'),
61
- macroStepKey: generateIdentifier('ForStepKey'),
62
57
  stepKind: CONSTANTS.Enums.StepKind.for,
63
58
  case: {
64
59
  what: {
65
60
  ...forStep.case.what,
66
- toolStepKey: generateIdentifier('ToolStepKey'),
61
+ stepKey: generateIdentifier('ToolStepKey'),
67
62
  },
68
63
  when: {
69
64
  ...forStep.case.when,
70
- toolStepKey: generateIdentifier('ToolStepKey'),
65
+ stepKey: generateIdentifier('ToolStepKey'),
71
66
  },
72
67
  },
73
68
  };
@@ -75,16 +70,15 @@ export function cloneForStep(forStep) {
75
70
  export function cloneWhileStep(whileStep) {
76
71
  return {
77
72
  stepKey: generateIdentifier('WhileStepKey'),
78
- macroStepKey: generateIdentifier('WhileStepKey'),
79
73
  stepKind: CONSTANTS.Enums.StepKind.while,
80
74
  case: {
81
75
  what: {
82
76
  ...whileStep.case.what,
83
- toolStepKey: generateIdentifier('ToolStepKey'),
77
+ stepKey: generateIdentifier('ToolStepKey'),
84
78
  },
85
79
  when: {
86
80
  ...whileStep.case.when,
87
- toolStepKey: generateIdentifier('ToolStepKey'),
81
+ stepKey: generateIdentifier('ToolStepKey'),
88
82
  },
89
83
  },
90
84
  };
@@ -4,17 +4,17 @@ export function getIndependentThreads(steps, strategyState) {
4
4
  const step = steps[ownerIndex];
5
5
  return `steps[${ownerIndex}] stepKind=${step?.stepKind ?? 'unknown'}`;
6
6
  };
7
- const toolStepKeyToOwner = new Map();
7
+ const stepKeyToOwner = new Map();
8
8
  const toolStepByKey = new Map();
9
9
  const addToolStep = (toolStep, ownerIndex) => {
10
10
  if (!toolStep)
11
11
  return;
12
- const existingOwner = toolStepKeyToOwner.get(toolStep.toolStepKey);
12
+ const existingOwner = stepKeyToOwner.get(toolStep.stepKey);
13
13
  if (existingOwner !== undefined) {
14
- throw new Error(`Duplicate toolStepKey '${toolStep.toolStepKey}' found in ${getOwnerLabel(ownerIndex)} and ${getOwnerLabel(existingOwner)}`);
14
+ throw new Error(`Duplicate stepKey '${toolStep.stepKey}' found in ${getOwnerLabel(ownerIndex)} and ${getOwnerLabel(existingOwner)}`);
15
15
  }
16
- toolStepKeyToOwner.set(toolStep.toolStepKey, ownerIndex);
17
- toolStepByKey.set(toolStep.toolStepKey, toolStep);
16
+ stepKeyToOwner.set(toolStep.stepKey, ownerIndex);
17
+ toolStepByKey.set(toolStep.stepKey, toolStep);
18
18
  };
19
19
  steps.forEach((step, ownerIndex) => {
20
20
  for (const toolStep of extractToolStepsFromStep(step, { branchCaseOrder: 'what-when' })) {
@@ -32,22 +32,22 @@ export function getIndependentThreads(steps, strategyState) {
32
32
  for (let index = 0; index < steps.length; index++) {
33
33
  ensureOwner(index);
34
34
  }
35
- for (const [toolStepKey, ownerIndex] of toolStepKeyToOwner) {
35
+ for (const [stepKey, ownerIndex] of stepKeyToOwner) {
36
36
  ensureOwner(ownerIndex);
37
- const toolStep = toolStepByKey.get(toolStepKey);
37
+ const toolStep = toolStepByKey.get(stepKey);
38
38
  const inputBindings = toolStep?.roleBindingSpec?.inputBindings ?? [];
39
- const bucket = strategyState[toolStepKey];
39
+ const bucket = strategyState[stepKey];
40
40
  for (const inputRoleId of inputBindings) {
41
41
  const entry = bucket?.[inputRoleId];
42
42
  if (!entry || entry.strategyStateEntryKind !== 'internalInputPotential')
43
43
  continue;
44
- const producerToolStepKey = entry.toolStepRoleAddress?.toolStepKey;
45
- if (typeof producerToolStepKey !== 'string') {
46
- throw new Error(`Unresolvable internalInputPotential in toolStep '${toolStepKey}' (${getOwnerLabel(ownerIndex)}): missing toolStepRoleAddress.toolStepKey for role '${inputRoleId}'`);
44
+ const producerStepKey = entry.toolStepRoleAddress?.stepKey;
45
+ if (typeof producerStepKey !== 'string') {
46
+ throw new Error(`Unresolvable internalInputPotential in toolStep '${stepKey}' (${getOwnerLabel(ownerIndex)}): missing toolStepRoleAddress.stepKey for role '${inputRoleId}'`);
47
47
  }
48
- const producerOwner = toolStepKeyToOwner.get(producerToolStepKey);
48
+ const producerOwner = stepKeyToOwner.get(producerStepKey);
49
49
  if (producerOwner === undefined) {
50
- throw new Error(`Unresolvable internalInputPotential in toolStep '${toolStepKey}' (${getOwnerLabel(ownerIndex)}): source toolStepKey '${producerToolStepKey}' not found in strategy steps`);
50
+ throw new Error(`Unresolvable internalInputPotential in toolStep '${stepKey}' (${getOwnerLabel(ownerIndex)}): source stepKey '${producerStepKey}' not found in strategy steps`);
51
51
  }
52
52
  ensureOwner(producerOwner);
53
53
  ownerAdj.get(ownerIndex)?.add(producerOwner);
@@ -2,5 +2,5 @@ import type { Strategy, ToolStepPath } from '@toolproof-core/genesis';
2
2
  import type { MutableStrategy, MutableStrategyStateEntryByRoleName, MutableToolStepKey } from './mutableStrategyOverlay.js';
3
3
  export declare function strategyToMutableStrategy(strategy: Strategy): MutableStrategy;
4
4
  export declare function mutableStrategyToStrategy(mutableStrategy: MutableStrategy): Strategy;
5
- export declare function mutableToolStepKeyToToolStepPath(mutableStrategy: MutableStrategy, toolStepKey: MutableToolStepKey): ToolStepPath;
6
- export declare function projectMutableStrategyStateEntriesByToolStepKeyToCanonicalDelta(mutableStrategy: MutableStrategy, toolStepKey: MutableToolStepKey, entries: MutableStrategyStateEntryByRoleName): Strategy['strategyState'];
5
+ export declare function mutableStepKeyToToolStepPath(mutableStrategy: MutableStrategy, stepKey: MutableToolStepKey): ToolStepPath;
6
+ export declare function projectMutableStrategyStateEntriesByStepKeyToCanonicalDelta(mutableStrategy: MutableStrategy, stepKey: MutableToolStepKey, entries: MutableStrategyStateEntryByRoleName): Strategy['strategyState'];
@@ -2,8 +2,8 @@ import { CONSTANTS } from '../lookups/lookups.js';
2
2
  import { generateIdentifier } from './identifierGeneration.js';
3
3
  function stripMutableCase(stepCase) {
4
4
  const { when, what, ...rest } = stepCase;
5
- const { stepKey: _whenStepKey, toolStepKey: _whenToolStepKey, ...canonicalWhen } = when;
6
- const { stepKey: _whatStepKey, toolStepKey: _whatToolStepKey, ...canonicalWhat } = what;
5
+ const { stepKey: _whenStepKey, ...canonicalWhen } = when;
6
+ const { stepKey: _whatStepKey, ...canonicalWhat } = what;
7
7
  return {
8
8
  ...rest,
9
9
  when: canonicalWhen,
@@ -15,18 +15,18 @@ function buildExecutionPathMap(strategy) {
15
15
  const registerStep = (step, pathPrefix) => {
16
16
  switch (step.stepKind) {
17
17
  case CONSTANTS.Enums.StepKind.tool:
18
- executionPathByKey.set(step.toolStepKey, `${pathPrefix}/self`);
18
+ executionPathByKey.set(step.stepKey, `${pathPrefix}/self`);
19
19
  return;
20
20
  case CONSTANTS.Enums.StepKind.branch:
21
21
  step.cases.forEach((stepCase, caseIndex) => {
22
- executionPathByKey.set(stepCase.when.toolStepKey, `${pathPrefix}/cases/${caseIndex}/when`);
23
- executionPathByKey.set(stepCase.what.toolStepKey, `${pathPrefix}/cases/${caseIndex}/what`);
22
+ executionPathByKey.set(stepCase.when.stepKey, `${pathPrefix}/cases/${caseIndex}/when`);
23
+ executionPathByKey.set(stepCase.what.stepKey, `${pathPrefix}/cases/${caseIndex}/what`);
24
24
  });
25
25
  return;
26
26
  case CONSTANTS.Enums.StepKind.while:
27
27
  case CONSTANTS.Enums.StepKind.for:
28
- executionPathByKey.set(step.case.when.toolStepKey, `${pathPrefix}/case/when`);
29
- executionPathByKey.set(step.case.what.toolStepKey, `${pathPrefix}/case/what`);
28
+ executionPathByKey.set(step.case.when.stepKey, `${pathPrefix}/case/when`);
29
+ executionPathByKey.set(step.case.what.stepKey, `${pathPrefix}/case/what`);
30
30
  return;
31
31
  default:
32
32
  throw new Error('Unsupported step kind while projecting strategy.');
@@ -43,9 +43,9 @@ function toCanonicalStrategyStateEntry(entry, executionPathByKey) {
43
43
  if (entry.strategyStateEntryKind !== 'internalInputPotential') {
44
44
  return entry;
45
45
  }
46
- const sourceToolStepPath = executionPathByKey.get(entry.toolStepRoleAddress.toolStepKey);
46
+ const sourceToolStepPath = executionPathByKey.get(entry.toolStepRoleAddress.stepKey);
47
47
  if (!sourceToolStepPath) {
48
- throw new Error(`Cannot project strategy state: no execution path found for toolStepKey '${entry.toolStepRoleAddress.toolStepKey}'.`);
48
+ throw new Error(`Cannot project strategy state: no execution path found for stepKey '${entry.toolStepRoleAddress.stepKey}'.`);
49
49
  }
50
50
  return {
51
51
  strategyStateEntryKind: 'internalInputPotential',
@@ -58,11 +58,11 @@ function toCanonicalStrategyStateEntry(entry, executionPathByKey) {
58
58
  function toCanonicalStep(step) {
59
59
  switch (step.stepKind) {
60
60
  case CONSTANTS.Enums.StepKind.tool: {
61
- const { stepKey: _stepKey, toolStepKey: _toolStepKey, ...canonicalToolStep } = step;
61
+ const { stepKey: _stepKey, ...canonicalToolStep } = step;
62
62
  return canonicalToolStep;
63
63
  }
64
64
  case CONSTANTS.Enums.StepKind.branch: {
65
- const { stepKey: _stepKey, macroStepKey: _macroStepKey, cases, ...rest } = step;
65
+ const { stepKey: _stepKey, cases, ...rest } = step;
66
66
  return {
67
67
  ...rest,
68
68
  cases: cases.map(stripMutableCase),
@@ -70,7 +70,7 @@ function toCanonicalStep(step) {
70
70
  }
71
71
  case CONSTANTS.Enums.StepKind.while:
72
72
  case CONSTANTS.Enums.StepKind.for: {
73
- const { stepKey: _stepKey, macroStepKey: _macroStepKey, case: stepCase, ...rest } = step;
73
+ const { stepKey: _stepKey, case: stepCase, ...rest } = step;
74
74
  return {
75
75
  ...rest,
76
76
  case: stripMutableCase(stepCase),
@@ -92,7 +92,6 @@ function toMutableStrategyStateEntry(entry, executionKeyByPath) {
92
92
  strategyStateEntryKind: 'internalInputPotential',
93
93
  toolStepRoleAddress: {
94
94
  stepKey: sourceToolStepKey,
95
- toolStepKey: sourceToolStepKey,
96
95
  roleName: entry.toolStepRoleAddress.roleName,
97
96
  },
98
97
  };
@@ -102,7 +101,6 @@ function toMutableToolStep(step) {
102
101
  return {
103
102
  ...step,
104
103
  stepKey: key,
105
- toolStepKey: key,
106
104
  };
107
105
  }
108
106
  function toMutableCase(stepCase) {
@@ -119,7 +117,6 @@ function toMutableBranchStep(step) {
119
117
  return {
120
118
  ...rest,
121
119
  stepKey: key,
122
- macroStepKey: key,
123
120
  cases: cases.map(toMutableCase),
124
121
  };
125
122
  }
@@ -129,7 +126,6 @@ function toMutableWhileStep(step) {
129
126
  return {
130
127
  ...rest,
131
128
  stepKey: key,
132
- macroStepKey: key,
133
129
  case: toMutableCase(stepCase),
134
130
  };
135
131
  }
@@ -139,7 +135,6 @@ function toMutableForStep(step) {
139
135
  return {
140
136
  ...rest,
141
137
  stepKey: key,
142
- macroStepKey: key,
143
138
  case: toMutableCase(stepCase),
144
139
  };
145
140
  }
@@ -160,8 +155,8 @@ function toMutableStep(step) {
160
155
  function buildExecutionKeyMap(strategy) {
161
156
  const executionPathByKey = buildExecutionPathMap(strategy);
162
157
  const executionKeyByPath = new Map();
163
- for (const [toolStepKey, toolStepPath] of executionPathByKey.entries()) {
164
- executionKeyByPath.set(toolStepPath, toolStepKey);
158
+ for (const [stepKey, toolStepPath] of executionPathByKey.entries()) {
159
+ executionKeyByPath.set(toolStepPath, stepKey);
165
160
  }
166
161
  return executionKeyByPath;
167
162
  }
@@ -175,11 +170,11 @@ export function strategyToMutableStrategy(strategy) {
175
170
  const executionKeyByPath = buildExecutionKeyMap(seededMutableStrategy);
176
171
  const strategyState = {};
177
172
  for (const [toolStepPath, inputEntryByRoleName] of Object.entries(strategy.strategyState)) {
178
- const toolStepKey = executionKeyByPath.get(toolStepPath);
179
- if (!toolStepKey) {
173
+ const stepKey = executionKeyByPath.get(toolStepPath);
174
+ if (!stepKey) {
180
175
  throw new Error(`Cannot deproject strategy state: no mutable key found for toolStepPath '${toolStepPath}'.`);
181
176
  }
182
- strategyState[toolStepKey] = Object.fromEntries(Object.entries(inputEntryByRoleName).map(([roleName, entry]) => {
177
+ strategyState[stepKey] = Object.fromEntries(Object.entries(inputEntryByRoleName).map(([roleName, entry]) => {
183
178
  if (entry === undefined) {
184
179
  throw new Error(`Cannot deproject strategy state: role '${roleName}' on toolStepPath '${toolStepPath}' is explicitly undefined.`);
185
180
  }
@@ -198,17 +193,17 @@ export function strategyToMutableStrategy(strategy) {
198
193
  export function mutableStrategyToStrategy(mutableStrategy) {
199
194
  const executionPathByKey = buildExecutionPathMap(mutableStrategy);
200
195
  const strategyState = {};
201
- for (const [toolStepKey, inputEntryByRoleName] of Object.entries(mutableStrategy.strategyState)) {
196
+ for (const [stepKey, inputEntryByRoleName] of Object.entries(mutableStrategy.strategyState)) {
202
197
  if (!inputEntryByRoleName) {
203
198
  continue;
204
199
  }
205
- const toolStepPath = executionPathByKey.get(toolStepKey);
200
+ const toolStepPath = executionPathByKey.get(stepKey);
206
201
  if (!toolStepPath) {
207
- throw new Error(`Cannot project strategy state: no execution path found for toolStepKey '${toolStepKey}'.`);
202
+ throw new Error(`Cannot project strategy state: no execution path found for stepKey '${stepKey}'.`);
208
203
  }
209
204
  strategyState[toolStepPath] = Object.fromEntries(Object.entries(inputEntryByRoleName).map(([roleName, entry]) => {
210
205
  if (entry === undefined) {
211
- throw new Error(`Cannot project strategy state: role '${roleName}' on toolStepKey '${toolStepKey}' is explicitly undefined.`);
206
+ throw new Error(`Cannot project strategy state: role '${roleName}' on stepKey '${stepKey}' is explicitly undefined.`);
212
207
  }
213
208
  return [
214
209
  roleName,
@@ -222,25 +217,25 @@ export function mutableStrategyToStrategy(mutableStrategy) {
222
217
  strategyState,
223
218
  };
224
219
  }
225
- export function mutableToolStepKeyToToolStepPath(mutableStrategy, toolStepKey) {
220
+ export function mutableStepKeyToToolStepPath(mutableStrategy, stepKey) {
226
221
  const executionPathByKey = buildExecutionPathMap(mutableStrategy);
227
- const toolStepPath = executionPathByKey.get(toolStepKey);
222
+ const toolStepPath = executionPathByKey.get(stepKey);
228
223
  if (!toolStepPath) {
229
- throw new Error(`Cannot project toolStepPath: no execution path found for toolStepKey '${toolStepKey}'.`);
224
+ throw new Error(`Cannot project toolStepPath: no execution path found for stepKey '${stepKey}'.`);
230
225
  }
231
226
  return toolStepPath;
232
227
  }
233
- export function projectMutableStrategyStateEntriesByToolStepKeyToCanonicalDelta(mutableStrategy, toolStepKey, entries) {
228
+ export function projectMutableStrategyStateEntriesByStepKeyToCanonicalDelta(mutableStrategy, stepKey, entries) {
234
229
  const executionPathByKey = buildExecutionPathMap(mutableStrategy);
235
- const toolStepPath = executionPathByKey.get(toolStepKey);
230
+ const toolStepPath = executionPathByKey.get(stepKey);
236
231
  if (!toolStepPath) {
237
- throw new Error(`Cannot project strategy state delta: no execution path found for toolStepKey '${toolStepKey}'.`);
232
+ throw new Error(`Cannot project strategy state delta: no execution path found for stepKey '${stepKey}'.`);
238
233
  }
239
234
  const canonicalEntries = Object.fromEntries(Object.entries(entries)
240
235
  .filter(([, entry]) => entry !== undefined)
241
236
  .map(([roleName, entry]) => {
242
237
  if (entry === undefined) {
243
- throw new Error(`Cannot project strategy state delta: role '${roleName}' on toolStepKey '${toolStepKey}' is explicitly undefined.`);
238
+ throw new Error(`Cannot project strategy state delta: role '${roleName}' on stepKey '${stepKey}' is explicitly undefined.`);
244
239
  }
245
240
  return [
246
241
  roleName,
@@ -6,7 +6,7 @@ export function resolveStrategyStateChain(strategyState, start, opts) {
6
6
  let current = start;
7
7
  for (let depth = 0; depth <= maxDepth; depth++) {
8
8
  path.push(current);
9
- const visitKey = `${current.toolStepKey}::${current.roleName}`;
9
+ const visitKey = `${current.stepKey}::${current.roleName}`;
10
10
  if (visited.has(visitKey)) {
11
11
  return { status: 'unresolved', reason: 'cycle', path };
12
12
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toolproof-core/lib",
3
- "version": "1.0.48",
3
+ "version": "1.0.50",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "keywords": [],