@haibun/core 2.1.1 → 2.2.1
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.
- package/build/currentVersion.d.ts +1 -1
- package/build/currentVersion.js +2 -1
- package/package.json +1 -1
- package/build/jsprolog/converter.d.ts +0 -9
- package/build/jsprolog/converter.d.ts.map +0 -1
- package/build/jsprolog/converter.js +0 -42
- package/build/jsprolog/converter.js.map +0 -1
- package/build/jsprolog/stepper-utils.d.ts +0 -8
- package/build/jsprolog/stepper-utils.d.ts.map +0 -1
- package/build/jsprolog/stepper-utils.js +0 -8
- package/build/jsprolog/stepper-utils.js.map +0 -1
- package/build/jsprolog/test.jsprolog.d.ts +0 -4
- package/build/jsprolog/test.jsprolog.d.ts.map +0 -1
- package/build/jsprolog/test.jsprolog.js +0 -19
- package/build/jsprolog/test.jsprolog.js.map +0 -1
- package/build/jsprolog/test.kireji.d.ts +0 -4
- package/build/jsprolog/test.kireji.d.ts.map +0 -1
- package/build/jsprolog/test.kireji.js +0 -19
- package/build/jsprolog/test.kireji.js.map +0 -1
- package/build/jsprolog/withAction.d.ts +0 -32
- package/build/jsprolog/withAction.d.ts.map +0 -1
- package/build/jsprolog/withAction.js +0 -65
- package/build/jsprolog/withAction.js.map +0 -1
- package/build/kireji/converter.d.ts +0 -9
- package/build/kireji/converter.d.ts.map +0 -1
- package/build/kireji/converter.js +0 -48
- package/build/kireji/converter.js.map +0 -1
- package/build/kireji/test.kireji.d.ts +0 -4
- package/build/kireji/test.kireji.d.ts.map +0 -1
- package/build/kireji/test.kireji.js +0 -19
- package/build/kireji/test.kireji.js.map +0 -1
- package/build/kireji/withAction.d.ts +0 -36
- package/build/kireji/withAction.d.ts.map +0 -1
- package/build/kireji/withAction.js +0 -66
- package/build/kireji/withAction.js.map +0 -1
- package/build/lib/errors.d.ts +0 -13
- package/build/lib/errors.d.ts.map +0 -1
- package/build/lib/errors.js +0 -18
- package/build/lib/errors.js.map +0 -1
- package/build/steps/activities-stepper.d.ts +0 -73
- package/build/steps/activities-stepper.d.ts.map +0 -1
- package/build/steps/activities-stepper.js +0 -341
- package/build/steps/activities-stepper.js.map +0 -1
- package/build/steps/conditions-stepper.d.ts +0 -27
- package/build/steps/conditions-stepper.d.ts.map +0 -1
- package/build/steps/conditions-stepper.js +0 -99
- package/build/steps/conditions-stepper.js.map +0 -1
- package/build/steps/outcomesRegistry.d.ts +0 -8
- package/build/steps/outcomesRegistry.d.ts.map +0 -1
- package/build/steps/outcomesRegistry.js +0 -3
- package/build/steps/outcomesRegistry.js.map +0 -1
- package/build/steps/registeredOutcomesStore.d.ts +0 -12
- package/build/steps/registeredOutcomesStore.d.ts.map +0 -1
- package/build/steps/registeredOutcomesStore.js +0 -11
- package/build/steps/registeredOutcomesStore.js.map +0 -1
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { AStepper, IHasCycles, TStepperSteps } from '../lib/astepper.js';
|
|
2
|
-
import { TStepArgs, TFeatureStep, TWorld, IStepperCycles, TStepperStep, TFeatures } from '../lib/defs.js';
|
|
3
|
-
type TActivitiesFixedSteps = {
|
|
4
|
-
activity: TStepperStep;
|
|
5
|
-
waypoint: TStepperStep;
|
|
6
|
-
ensure: TStepperStep;
|
|
7
|
-
showWaypoints: TStepperStep;
|
|
8
|
-
};
|
|
9
|
-
type TActivitiesStepperSteps = TStepperSteps & TActivitiesFixedSteps;
|
|
10
|
-
/**
|
|
11
|
-
* Stepper that dynamically builds virtual steps from `waypoint` statements.
|
|
12
|
-
* implements this logic: P ∨ (¬P ∧ [A]P)
|
|
13
|
-
*/
|
|
14
|
-
export declare class ActivitiesStepper extends AStepper implements IHasCycles {
|
|
15
|
-
private steppers;
|
|
16
|
-
private backgroundOutcomePatterns;
|
|
17
|
-
private featureOutcomePatterns;
|
|
18
|
-
private outcomeToFeaturePath;
|
|
19
|
-
private currentFeaturePath;
|
|
20
|
-
private lastFeaturePath;
|
|
21
|
-
private ensuredInstances;
|
|
22
|
-
private registeredOutcomeMetadata;
|
|
23
|
-
cycles: IStepperCycles;
|
|
24
|
-
cyclesWhen: {
|
|
25
|
-
startExecution: number;
|
|
26
|
-
startFeature: number;
|
|
27
|
-
};
|
|
28
|
-
private readonly baseSteps;
|
|
29
|
-
readonly typedSteps: {
|
|
30
|
-
readonly activity: {
|
|
31
|
-
readonly gwta: "Activity: {activity}";
|
|
32
|
-
readonly action: () => import("../lib/defs.js").TOKActionResult;
|
|
33
|
-
};
|
|
34
|
-
readonly waypoint: {
|
|
35
|
-
readonly gwta: "waypoint {outcome} with {proof:statement}";
|
|
36
|
-
readonly resolveFeatureLine: (line: string, path: string, stepper: AStepper, _backgrounds: TFeatures, allLines?: string[], lineIndex?: number) => boolean;
|
|
37
|
-
readonly action: ({ proof }: {
|
|
38
|
-
proof: TFeatureStep[];
|
|
39
|
-
}, featureStep: TFeatureStep) => Promise<import("../lib/defs.js").TOKActionResult | import("../lib/defs.js").TNotOKActionResult>;
|
|
40
|
-
};
|
|
41
|
-
readonly ensure: {
|
|
42
|
-
readonly description: "Ensure a waypoint condition by always running the proof. If proof passes, waypoint is already satisfied. If proof fails, run the full activity to satisfy it.";
|
|
43
|
-
readonly gwta: "ensure {outcome:statement}";
|
|
44
|
-
readonly action: ({ outcome }: {
|
|
45
|
-
outcome: TFeatureStep[];
|
|
46
|
-
}, featureStep: TFeatureStep) => Promise<import("../lib/defs.js").TOKActionResult | import("../lib/defs.js").TNotOKActionResult>;
|
|
47
|
-
};
|
|
48
|
-
readonly showWaypoints: {
|
|
49
|
-
readonly exact: "show waypoints";
|
|
50
|
-
readonly action: (_args: TStepArgs, featureStep: TFeatureStep) => Promise<import("../lib/defs.js").TOKActionResult>;
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
steps: TActivitiesStepperSteps;
|
|
54
|
-
setWorld(world: TWorld, steppers: AStepper[]): Promise<void>;
|
|
55
|
-
/**
|
|
56
|
-
* Register a dynamic outcome step.
|
|
57
|
-
* This is called when parsing `waypoint` statements.
|
|
58
|
-
*
|
|
59
|
-
* @param outcome - The outcome pattern (e.g., "Is logged in as {user}")
|
|
60
|
-
* @param proofStatements - Array of statement strings from the DOMAIN_STATEMENT proof
|
|
61
|
-
* @param proofPath - The path of the feature containing the proof
|
|
62
|
-
* @param isBackground - Whether this outcome is defined in a background (persists across features)
|
|
63
|
-
* @param activityBlockSteps - Optional array of all steps in the containing activity block
|
|
64
|
-
*/
|
|
65
|
-
registerOutcome(outcome: string, proofStatements: string[], proofPath: string, isBackground?: boolean, activityBlockSteps?: string[]): void;
|
|
66
|
-
/**
|
|
67
|
-
* Re-emit GRAPH_LINK messages for waypoint metadata.
|
|
68
|
-
* MonitorHandler subscribes after resolution, so we retransmit stored metadata.
|
|
69
|
-
*/
|
|
70
|
-
sendGraphLinkMessages(): void;
|
|
71
|
-
}
|
|
72
|
-
export default ActivitiesStepper;
|
|
73
|
-
//# sourceMappingURL=activities-stepper.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"activities-stepper.d.ts","sourceRoot":"","sources":["../../src/steps/activities-stepper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEzE,OAAO,EAAiB,SAAS,EAAE,YAAY,EAAM,MAAM,EAAE,cAAc,EAAE,YAAY,EAAE,SAAS,EAAa,MAAM,gBAAgB,CAAC;AAQxI,KAAK,qBAAqB,GAAG;IAC5B,QAAQ,EAAE,YAAY,CAAC;IACvB,QAAQ,EAAE,YAAY,CAAC;IACvB,MAAM,EAAE,YAAY,CAAC;IACrB,aAAa,EAAE,YAAY,CAAC;CAC5B,CAAC;AAEF,KAAK,uBAAuB,GAAG,aAAa,GAAG,qBAAqB,CAAC;AAErE;;;GAGG;AACH,qBAAa,iBAAkB,SAAQ,QAAS,YAAW,UAAU;IACpE,OAAO,CAAC,QAAQ,CAAkB;IAClC,OAAO,CAAC,yBAAyB,CAA0B;IAC3D,OAAO,CAAC,sBAAsB,CAA0B;IACxD,OAAO,CAAC,oBAAoB,CAAkC;IAC9D,OAAO,CAAC,kBAAkB,CAAc;IACxC,OAAO,CAAC,eAAe,CAAc;IACrC,OAAO,CAAC,gBAAgB,CAA+D;IACvF,OAAO,CAAC,yBAAyB,CAAkI;IAEnK,MAAM,EAAE,cAAc,CA+BrB;IACD,UAAU;;;MAGT;IAED,OAAO,CAAC,QAAQ,CAAC,SAAS,CAqMiB;IAE3C,QAAQ,CAAC,UAAU;;;;;;;gDA/LU,MAAM,QAAQ,MAAM,WAAW,QAAQ,gBAAgB,SAAS,aAAa,MAAM,EAAE,cAAc,MAAM;yCAyD1G;gBAAE,KAAK,EAAE,YAAY,EAAE,CAAA;aAAE,eAAe,YAAY;;;;;2CAgBlD;gBAAE,OAAO,EAAE,YAAY,EAAE,CAAA;aAAE,eAAe,YAAY;;;;6DAoE/C,YAAY;;MAkDZ;IAErC,KAAK,EAAE,uBAAuB,CAAyB;IAEjD,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE;IAKlD;;;;;;;;;OASG;IACH,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,OAAO,EAAE,kBAAkB,CAAC,EAAE,MAAM,EAAE;IAoHpI;;;OAGG;IACH,qBAAqB,IAAI,IAAI;CAe7B;AAED,eAAe,iBAAiB,CAAC"}
|
|
@@ -1,341 +0,0 @@
|
|
|
1
|
-
import { AStepper } from '../lib/astepper.js';
|
|
2
|
-
import { OK, CycleWhen } from '../lib/defs.js';
|
|
3
|
-
import { executeSubFeatureSteps, findFeatureStepsFromStatement } from '../lib/util/featureStep-executor.js';
|
|
4
|
-
import { ExecMode } from '../lib/defs.js';
|
|
5
|
-
import { actionOK, actionNotOK, getActionable } from '../lib/util/index.js';
|
|
6
|
-
import { DOMAIN_STATEMENT } from '../lib/domain-types.js';
|
|
7
|
-
import { EExecutionMessageType } from '../lib/interfaces/logger.js';
|
|
8
|
-
/**
|
|
9
|
-
* Stepper that dynamically builds virtual steps from `waypoint` statements.
|
|
10
|
-
* implements this logic: P ∨ (¬P ∧ [A]P)
|
|
11
|
-
*/
|
|
12
|
-
export class ActivitiesStepper extends AStepper {
|
|
13
|
-
steppers = [];
|
|
14
|
-
backgroundOutcomePatterns = new Set();
|
|
15
|
-
featureOutcomePatterns = new Set();
|
|
16
|
-
outcomeToFeaturePath = new Map();
|
|
17
|
-
currentFeaturePath = '';
|
|
18
|
-
lastFeaturePath = '';
|
|
19
|
-
ensuredInstances = new Map();
|
|
20
|
-
registeredOutcomeMetadata = new Map();
|
|
21
|
-
cycles = {
|
|
22
|
-
startExecution: () => {
|
|
23
|
-
this.sendGraphLinkMessages();
|
|
24
|
-
},
|
|
25
|
-
startFeature: (startFeature) => {
|
|
26
|
-
this.getWorld().logger.debug(`ActivitiesStepper.startFeature: starting feature at path "${startFeature.resolvedFeature.path}"`);
|
|
27
|
-
if (this.lastFeaturePath && this.lastFeaturePath !== startFeature.resolvedFeature.path) {
|
|
28
|
-
this.getWorld().logger.debug(`ActivitiesStepper.startFeature: clearing outcomes from previous feature "${this.lastFeaturePath}"`);
|
|
29
|
-
const outcomesToClear = [];
|
|
30
|
-
for (const [outcome, featurePath] of this.outcomeToFeaturePath.entries()) {
|
|
31
|
-
if (featurePath === this.lastFeaturePath) {
|
|
32
|
-
outcomesToClear.push(outcome);
|
|
33
|
-
delete this.steps[outcome];
|
|
34
|
-
this.featureOutcomePatterns.delete(outcome);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
for (const outcome of outcomesToClear) {
|
|
38
|
-
this.outcomeToFeaturePath.delete(outcome);
|
|
39
|
-
}
|
|
40
|
-
this.getWorld().logger.debug(`ActivitiesStepper.startFeature: cleared ${outcomesToClear.length} outcomes from previous feature`);
|
|
41
|
-
}
|
|
42
|
-
this.currentFeaturePath = startFeature.resolvedFeature.path;
|
|
43
|
-
this.sendGraphLinkMessages();
|
|
44
|
-
},
|
|
45
|
-
endFeature: () => {
|
|
46
|
-
this.lastFeaturePath = this.currentFeaturePath;
|
|
47
|
-
this.ensuredInstances.clear();
|
|
48
|
-
return Promise.resolve();
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
cyclesWhen = {
|
|
52
|
-
startExecution: CycleWhen.FIRST,
|
|
53
|
-
startFeature: CycleWhen.FIRST,
|
|
54
|
-
};
|
|
55
|
-
baseSteps = {
|
|
56
|
-
activity: {
|
|
57
|
-
gwta: 'Activity: {activity}',
|
|
58
|
-
action: () => OK
|
|
59
|
-
},
|
|
60
|
-
waypoint: {
|
|
61
|
-
gwta: `waypoint {outcome} with {proof:${DOMAIN_STATEMENT}}`,
|
|
62
|
-
resolveFeatureLine: (line, path, stepper, _backgrounds, allLines, lineIndex) => {
|
|
63
|
-
if (!line.match(/^waypoint\s+.+?\s+with\s+/i)) {
|
|
64
|
-
return false;
|
|
65
|
-
}
|
|
66
|
-
const activitiesStepper = stepper;
|
|
67
|
-
const match = line.match(/^waypoint\s+(.+?)\s+with\s+(.+?)$/i);
|
|
68
|
-
if (!match) {
|
|
69
|
-
return false;
|
|
70
|
-
}
|
|
71
|
-
const outcome = match[1].trim();
|
|
72
|
-
// Skip if already registered (prevents infinite loops)
|
|
73
|
-
if (activitiesStepper.backgroundOutcomePatterns.has(outcome) || activitiesStepper.featureOutcomePatterns.has(outcome)) {
|
|
74
|
-
return true;
|
|
75
|
-
}
|
|
76
|
-
const isBackground = path.includes('backgrounds/');
|
|
77
|
-
const proofRaw = match[2].trim();
|
|
78
|
-
const proofFromRemember = proofRaw.split('\n').map(s => s.trim()).filter(s => s.length > 0);
|
|
79
|
-
// Scan backwards to find containing Activity block
|
|
80
|
-
let activityBlockSteps;
|
|
81
|
-
if (allLines && lineIndex !== undefined) {
|
|
82
|
-
let activityStartLine = -1;
|
|
83
|
-
for (let i = lineIndex - 1; i >= 0; i--) {
|
|
84
|
-
const prevLine = getActionable(allLines[i]);
|
|
85
|
-
if (prevLine.match(/^Activity:/i)) {
|
|
86
|
-
activityStartLine = i;
|
|
87
|
-
break;
|
|
88
|
-
}
|
|
89
|
-
if (prevLine.match(/^(Feature|Scenario|Background):/i)) {
|
|
90
|
-
break;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
if (activityStartLine !== -1) {
|
|
94
|
-
// Collect steps between Activity: and waypoint (excluding waypoint itself)
|
|
95
|
-
const blockLines = [];
|
|
96
|
-
for (let i = activityStartLine + 1; i < lineIndex; i++) {
|
|
97
|
-
const stepLine = getActionable(allLines[i]);
|
|
98
|
-
if (stepLine) {
|
|
99
|
-
blockLines.push(stepLine);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
activityBlockSteps = blockLines;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
activitiesStepper.registerOutcome(outcome, proofFromRemember, path, isBackground, activityBlockSteps);
|
|
106
|
-
return true;
|
|
107
|
-
},
|
|
108
|
-
action: async ({ proof }, featureStep) => {
|
|
109
|
-
this.getWorld().logger.debug(`waypoint action: executing ${proof?.length || 0} proof steps`);
|
|
110
|
-
const result = await executeSubFeatureSteps(featureStep, proof, this.steppers, this.getWorld(), ExecMode.NO_CYCLES);
|
|
111
|
-
if (!result.ok) {
|
|
112
|
-
return actionNotOK(`waypoint: failed to execute proof steps`);
|
|
113
|
-
}
|
|
114
|
-
return actionOK();
|
|
115
|
-
},
|
|
116
|
-
},
|
|
117
|
-
ensure: {
|
|
118
|
-
description: 'Ensure a waypoint condition by always running the proof. If proof passes, waypoint is already satisfied. If proof fails, run the full activity to satisfy it.',
|
|
119
|
-
gwta: `ensure {outcome:${DOMAIN_STATEMENT}}`,
|
|
120
|
-
action: async ({ outcome }, featureStep) => {
|
|
121
|
-
const outcomeKey = outcome.map(step => step.in).join(' ');
|
|
122
|
-
// Log ENSURE_START
|
|
123
|
-
const startMessageContext = {
|
|
124
|
-
incident: EExecutionMessageType.ENSURE_START,
|
|
125
|
-
incidentDetails: { waypoint: outcomeKey, step: featureStep }
|
|
126
|
-
};
|
|
127
|
-
this.getWorld().logger.log(`⏳ Ensuring ${outcomeKey}`, startMessageContext);
|
|
128
|
-
this.getWorld().logger.debug(`ensure: verifying waypoint "${outcomeKey}"`);
|
|
129
|
-
const pattern = outcome[0]?.action?.actionName || outcomeKey;
|
|
130
|
-
const registeredWaypoint = this.steps[pattern];
|
|
131
|
-
if (!registeredWaypoint) {
|
|
132
|
-
const messageContext = {
|
|
133
|
-
incident: EExecutionMessageType.ACTION,
|
|
134
|
-
incidentDetails: { waypoint: outcomeKey, error: 'waypoint not registered' }
|
|
135
|
-
};
|
|
136
|
-
return actionNotOK(`ensure: waypoint "${outcomeKey}" (pattern "${pattern}") is not registered`, { messageContext });
|
|
137
|
-
}
|
|
138
|
-
const result = await executeSubFeatureSteps(featureStep, outcome, this.steppers, this.getWorld(), ExecMode.NO_CYCLES);
|
|
139
|
-
if (!result.ok) {
|
|
140
|
-
// Log ENSURE_END for failure
|
|
141
|
-
const endMessageContext = {
|
|
142
|
-
incident: EExecutionMessageType.ENSURE_END,
|
|
143
|
-
incidentDetails: { waypoint: outcomeKey, satisfied: false, error: result, actionResult: { ok: false } }
|
|
144
|
-
};
|
|
145
|
-
this.getWorld().logger.log(`❌ Failed ensuring ${outcomeKey}`, endMessageContext);
|
|
146
|
-
const messageContext = {
|
|
147
|
-
incident: EExecutionMessageType.ACTION,
|
|
148
|
-
incidentDetails: { waypoint: outcomeKey, satisfied: false, error: result }
|
|
149
|
-
};
|
|
150
|
-
return actionNotOK(`ensure: waypoint "${outcomeKey}" proof failed`, { messageContext });
|
|
151
|
-
}
|
|
152
|
-
const proofStatements = result.stepActionResult?.messageContext?.incidentDetails?.proofStatements;
|
|
153
|
-
if (proofStatements) {
|
|
154
|
-
this.ensuredInstances.set(outcomeKey, { proof: proofStatements, valid: true });
|
|
155
|
-
}
|
|
156
|
-
this.getWorld().logger.debug(`ensure: waypoint "${outcomeKey}" verified and satisfied`);
|
|
157
|
-
// Log ENSURE_END for success at trace level (just to hide the ENSURE_START)
|
|
158
|
-
const endMessageContext = {
|
|
159
|
-
incident: EExecutionMessageType.ENSURE_END,
|
|
160
|
-
incidentDetails: { waypoint: outcomeKey, satisfied: true, proofStatements, actionResult: { ok: true } }
|
|
161
|
-
};
|
|
162
|
-
this.getWorld().logger.trace(`✓ Ensured ${outcomeKey}`, endMessageContext);
|
|
163
|
-
const messageContext = {
|
|
164
|
-
incident: EExecutionMessageType.ACTION,
|
|
165
|
-
incidentDetails: {
|
|
166
|
-
waypoint: outcomeKey,
|
|
167
|
-
satisfied: true,
|
|
168
|
-
proofStatements
|
|
169
|
-
}
|
|
170
|
-
};
|
|
171
|
-
return actionOK({ messageContext });
|
|
172
|
-
},
|
|
173
|
-
},
|
|
174
|
-
showWaypoints: {
|
|
175
|
-
exact: 'show waypoints',
|
|
176
|
-
action: async (_args, featureStep) => {
|
|
177
|
-
const waypointResults = {};
|
|
178
|
-
for (const [instanceKey, instanceData] of this.ensuredInstances.entries()) {
|
|
179
|
-
this.getWorld().logger.debug(`show waypoints: verifying "${instanceKey}"`);
|
|
180
|
-
try {
|
|
181
|
-
const resolvedSteps = [];
|
|
182
|
-
for (let i = 0; i < instanceData.proof.length; i++) {
|
|
183
|
-
const statement = instanceData.proof[i];
|
|
184
|
-
const resolved = findFeatureStepsFromStatement(statement, this.steppers, this.getWorld(), featureStep.path, [...featureStep.seqPath, i], 1);
|
|
185
|
-
const contextualizedSteps = resolved.map(step => ({
|
|
186
|
-
...step,
|
|
187
|
-
in: `[${instanceKey} proof] ${step.in}`
|
|
188
|
-
}));
|
|
189
|
-
resolvedSteps.push(...contextualizedSteps);
|
|
190
|
-
}
|
|
191
|
-
const result = await executeSubFeatureSteps(featureStep, resolvedSteps, this.steppers, this.getWorld(), ExecMode.NO_CYCLES);
|
|
192
|
-
waypointResults[instanceKey] = {
|
|
193
|
-
proof: instanceData.proof.join('; '),
|
|
194
|
-
currentlyValid: result.ok
|
|
195
|
-
};
|
|
196
|
-
}
|
|
197
|
-
catch (error) {
|
|
198
|
-
waypointResults[instanceKey] = {
|
|
199
|
-
proof: instanceData.proof.join('; '),
|
|
200
|
-
currentlyValid: false,
|
|
201
|
-
error: error instanceof Error ? error.message : String(error)
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
this.getWorld().logger.info(`Waypoints (${Object.keys(waypointResults).length} ensured):\n${JSON.stringify(waypointResults, null, 2)}`);
|
|
206
|
-
return actionOK({ messageContext: { incident: EExecutionMessageType.ACTION, incidentDetails: { waypoints: waypointResults } } });
|
|
207
|
-
},
|
|
208
|
-
},
|
|
209
|
-
};
|
|
210
|
-
typedSteps = this.baseSteps;
|
|
211
|
-
steps = { ...this.baseSteps };
|
|
212
|
-
async setWorld(world, steppers) {
|
|
213
|
-
await super.setWorld(world, steppers);
|
|
214
|
-
this.steppers = steppers;
|
|
215
|
-
}
|
|
216
|
-
/**
|
|
217
|
-
* Register a dynamic outcome step.
|
|
218
|
-
* This is called when parsing `waypoint` statements.
|
|
219
|
-
*
|
|
220
|
-
* @param outcome - The outcome pattern (e.g., "Is logged in as {user}")
|
|
221
|
-
* @param proofStatements - Array of statement strings from the DOMAIN_STATEMENT proof
|
|
222
|
-
* @param proofPath - The path of the feature containing the proof
|
|
223
|
-
* @param isBackground - Whether this outcome is defined in a background (persists across features)
|
|
224
|
-
* @param activityBlockSteps - Optional array of all steps in the containing activity block
|
|
225
|
-
*/
|
|
226
|
-
registerOutcome(outcome, proofStatements, proofPath, isBackground, activityBlockSteps) {
|
|
227
|
-
// Prevent duplicate outcome registration
|
|
228
|
-
if (this.steps[outcome]) {
|
|
229
|
-
throw new Error(`Outcome "${outcome}" is already registered. Each outcome can only be defined once.`);
|
|
230
|
-
}
|
|
231
|
-
// Store metadata for runtime re-emission via TEST_LINKS messages
|
|
232
|
-
this.registeredOutcomeMetadata.set(outcome, {
|
|
233
|
-
proofStatements,
|
|
234
|
-
proofPath,
|
|
235
|
-
isBackground: isBackground ?? false,
|
|
236
|
-
activityBlockSteps: activityBlockSteps ?? [],
|
|
237
|
-
});
|
|
238
|
-
// Track whether this is a background or feature outcome
|
|
239
|
-
if (isBackground) {
|
|
240
|
-
this.backgroundOutcomePatterns.add(outcome);
|
|
241
|
-
}
|
|
242
|
-
else {
|
|
243
|
-
this.featureOutcomePatterns.add(outcome);
|
|
244
|
-
// Track which feature this outcome belongs to
|
|
245
|
-
this.outcomeToFeaturePath.set(outcome, proofPath);
|
|
246
|
-
}
|
|
247
|
-
this.getWorld().logger.debug(`ActivitiesStepper: registerOutcome called with ${proofStatements.length} proof steps for "${outcome}"`);
|
|
248
|
-
this.getWorld().logger.debug(`ActivitiesStepper: outcome is background=${isBackground}, will be added to ${isBackground ? 'backgroundOutcomePatterns' : 'featureOutcomePatterns'}`);
|
|
249
|
-
// Store proofStatements for later retrieval
|
|
250
|
-
const outcomeProofStatements = proofStatements;
|
|
251
|
-
this.steps[outcome] = {
|
|
252
|
-
gwta: outcome,
|
|
253
|
-
virtual: true, // Dynamically registered outcomes are virtual
|
|
254
|
-
description: `Outcome: ${outcome}. Proof: ${proofStatements.join('; ')}`,
|
|
255
|
-
action: async (args, featureStep) => {
|
|
256
|
-
this.getWorld().logger.debug(`ActivitiesStepper: executing recipe for outcome "${outcome}" with args ${JSON.stringify(args)}`);
|
|
257
|
-
// Interpolate args into statements (e.g., {user} -> "admin")
|
|
258
|
-
const expandStatements = (statements) => statements.map(statement => {
|
|
259
|
-
let expanded = statement;
|
|
260
|
-
for (const [key, value] of Object.entries(args)) {
|
|
261
|
-
expanded = expanded.replace(new RegExp(`\\{${key}\\}`, 'g'), String(value));
|
|
262
|
-
}
|
|
263
|
-
return expanded;
|
|
264
|
-
});
|
|
265
|
-
const resolveAndExecute = async (statements, stepOffset = 0, execMode = ExecMode.NO_CYCLES) => {
|
|
266
|
-
const expandedStatements = expandStatements(statements);
|
|
267
|
-
const resolvedSteps = [];
|
|
268
|
-
for (let i = 0; i < expandedStatements.length; i++) {
|
|
269
|
-
const statement = expandedStatements[i];
|
|
270
|
-
this.getWorld().logger.debug(`ActivitiesStepper: resolving statement ${i}: "${statement}"`);
|
|
271
|
-
const resolved = findFeatureStepsFromStatement(statement, this.steppers, this.getWorld(), proofPath, [...featureStep.seqPath, stepOffset + i], 1);
|
|
272
|
-
resolvedSteps.push(...resolved);
|
|
273
|
-
}
|
|
274
|
-
return await executeSubFeatureSteps(featureStep, resolvedSteps, this.steppers, this.getWorld(), execMode);
|
|
275
|
-
};
|
|
276
|
-
// ALWAYS-VERIFY: Try proof first (P ∨ (¬P ∧ [A]P) semantics)
|
|
277
|
-
this.getWorld().logger.debug(`ActivitiesStepper: checking proof for outcome "${outcome}"`);
|
|
278
|
-
this.getWorld().logger.debug(`ActivitiesStepper: proof statements: ${JSON.stringify(proofStatements)}`);
|
|
279
|
-
const proofResult = await resolveAndExecute(proofStatements, 0, ExecMode.NO_CYCLES);
|
|
280
|
-
if (proofResult.ok) {
|
|
281
|
-
this.getWorld().logger.debug(`ActivitiesStepper: proof passed for outcome "${outcome}", skipping activity body`);
|
|
282
|
-
const interpolatedProof = expandStatements(outcomeProofStatements);
|
|
283
|
-
return actionOK({
|
|
284
|
-
messageContext: {
|
|
285
|
-
incident: EExecutionMessageType.ACTION,
|
|
286
|
-
incidentDetails: { proofStatements: interpolatedProof, proofSatisfied: true }
|
|
287
|
-
}
|
|
288
|
-
});
|
|
289
|
-
}
|
|
290
|
-
// Proof failed - run activity body, then verify proof passes
|
|
291
|
-
if (activityBlockSteps && activityBlockSteps.length > 0) {
|
|
292
|
-
this.getWorld().logger.debug(`ActivitiesStepper: proof failed for outcome "${outcome}", running activity body`);
|
|
293
|
-
// Execute activity steps (WITH_CYCLES to allow hooks)
|
|
294
|
-
const activityResult = await resolveAndExecute(activityBlockSteps, 100, ExecMode.WITH_CYCLES);
|
|
295
|
-
if (!activityResult.ok) {
|
|
296
|
-
return actionNotOK(`ActivitiesStepper: activity body failed for outcome "${outcome}"`);
|
|
297
|
-
}
|
|
298
|
-
// Verify proof now passes after running activity
|
|
299
|
-
this.getWorld().logger.debug(`ActivitiesStepper: verifying proof after activity body for outcome "${outcome}"`);
|
|
300
|
-
const verifyResult = await resolveAndExecute(proofStatements, 200, ExecMode.NO_CYCLES);
|
|
301
|
-
if (!verifyResult.ok) {
|
|
302
|
-
return actionNotOK(`ActivitiesStepper: proof verification failed after activity body for outcome "${outcome}"`);
|
|
303
|
-
}
|
|
304
|
-
const interpolatedProof = expandStatements(outcomeProofStatements);
|
|
305
|
-
return actionOK({
|
|
306
|
-
messageContext: {
|
|
307
|
-
incident: EExecutionMessageType.ACTION,
|
|
308
|
-
incidentDetails: { proofStatements: interpolatedProof }
|
|
309
|
-
}
|
|
310
|
-
});
|
|
311
|
-
}
|
|
312
|
-
else {
|
|
313
|
-
// No activity body, just proof - and it failed
|
|
314
|
-
return actionNotOK(`ActivitiesStepper: proof failed and no activity body available for outcome "${outcome}"`);
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
};
|
|
318
|
-
this.getWorld().logger.debug(`ActivitiesStepper: registered outcome pattern "${outcome}" with ${proofStatements.length} proof steps`);
|
|
319
|
-
}
|
|
320
|
-
/**
|
|
321
|
-
* Re-emit GRAPH_LINK messages for waypoint metadata.
|
|
322
|
-
* MonitorHandler subscribes after resolution, so we retransmit stored metadata.
|
|
323
|
-
*/
|
|
324
|
-
sendGraphLinkMessages() {
|
|
325
|
-
for (const [outcome, metadata] of this.registeredOutcomeMetadata.entries()) {
|
|
326
|
-
const messageContext = {
|
|
327
|
-
incident: EExecutionMessageType.GRAPH_LINK,
|
|
328
|
-
incidentDetails: {
|
|
329
|
-
outcome,
|
|
330
|
-
proofStatements: metadata.proofStatements,
|
|
331
|
-
proofPath: metadata.proofPath,
|
|
332
|
-
isBackground: metadata.isBackground,
|
|
333
|
-
activityBlockSteps: metadata.activityBlockSteps ?? null,
|
|
334
|
-
}
|
|
335
|
-
};
|
|
336
|
-
this.getWorld().logger.debug(`waypoint registered: "${outcome}"`, messageContext);
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
export default ActivitiesStepper;
|
|
341
|
-
//# sourceMappingURL=activities-stepper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"activities-stepper.js","sourceRoot":"","sources":["../../src/steps/activities-stepper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAA6B,MAAM,oBAAoB,CAAC;AAEzE,OAAO,EAA0C,EAAE,EAAmD,SAAS,EAAE,MAAM,gBAAgB,CAAC;AACxI,OAAO,EAAE,sBAAsB,EAAE,6BAA6B,EAAE,MAAM,qCAAqC,CAAC;AAC5G,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAmB,MAAM,6BAA6B,CAAC;AAYrF;;;GAGG;AACH,MAAM,OAAO,iBAAkB,SAAQ,QAAQ;IACtC,QAAQ,GAAe,EAAE,CAAC;IAC1B,yBAAyB,GAAgB,IAAI,GAAG,EAAE,CAAC;IACnD,sBAAsB,GAAgB,IAAI,GAAG,EAAE,CAAC;IAChD,oBAAoB,GAAwB,IAAI,GAAG,EAAE,CAAC;IACtD,kBAAkB,GAAW,EAAE,CAAC;IAChC,eAAe,GAAW,EAAE,CAAC;IAC7B,gBAAgB,GAAqD,IAAI,GAAG,EAAE,CAAC;IAC/E,yBAAyB,GAAwH,IAAI,GAAG,EAAE,CAAC;IAEnK,MAAM,GAAmB;QACxB,cAAc,EAAE,GAAG,EAAE;YACpB,IAAI,CAAC,qBAAqB,EAAE,CAAC;QAC9B,CAAC;QACD,YAAY,EAAE,CAAC,Y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IAAI;iBACvD;aACD,CAAC;YACF,IAAI,CAAC,QAAQ,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,yBAAyB,OAAO,GAAG,EAAE,cAAc,CAAC,CAAC;QACnF,CAAC;IACF,CAAC;CACD;AAED,eAAe,iBAAiB,CAAC"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { AStepper } from '../lib/astepper.js';
|
|
2
|
-
import { TStepperSteps } from '../lib/astepper.js';
|
|
3
|
-
/**
|
|
4
|
-
* Virtual stepper that dynamically builds steps from `remember` statements.
|
|
5
|
-
* During pre-Resolve phase, this stepper is populated with conditions
|
|
6
|
-
* extracted from all `remember {condition} with {proof}` statements in features.
|
|
7
|
-
*
|
|
8
|
-
* When `ensure {condition}` is called, it will match against these conditions via
|
|
9
|
-
* normal GWTA resolution, check if already cached, and execute the recipe if needed.
|
|
10
|
-
*/
|
|
11
|
-
export declare class ConditionsStepper extends AStepper {
|
|
12
|
-
steps: TStepperSteps;
|
|
13
|
-
steppers: AStepper[];
|
|
14
|
-
forgetsMap: Record<string, string[]>;
|
|
15
|
-
/**
|
|
16
|
-
* Register a condition with its proof steps.
|
|
17
|
-
* This is called when parsing `remember` statements.
|
|
18
|
-
*
|
|
19
|
-
* @param condition - The condition (e.g., "Is logged in as {user}")
|
|
20
|
-
* @param proofStatements - Array of statement strings that prove this condition
|
|
21
|
-
* @param proofPath - The path of the feature containing the proof
|
|
22
|
-
* @param forgets - Optional condition that this condition forgets
|
|
23
|
-
*/
|
|
24
|
-
registerCondition(condition: string, proofStatements: string[], proofPath: string, forgets?: string): void;
|
|
25
|
-
}
|
|
26
|
-
export default ConditionsStepper;
|
|
27
|
-
//# sourceMappingURL=conditions-stepper.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"conditions-stepper.d.ts","sourceRoot":"","sources":["../../src/steps/conditions-stepper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAMnD;;;;;;;GAOG;AACH,qBAAa,iBAAkB,SAAQ,QAAQ;IAC7C,KAAK,EAAE,aAAa,CAAM;IAC1B,QAAQ,EAAE,QAAQ,EAAE,CAAM;IAG1B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAM;IAE1C;;;;;;;;OAQG;IACH,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM;CA0FpG;AAED,eAAe,iBAAiB,CAAC"}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { AStepper } from '../lib/astepper.js';
|
|
2
|
-
import { executeSubFeatureSteps, findFeatureStepsFromStatement } from '../lib/util/featureStep-executor.js';
|
|
3
|
-
import { ExecMode } from '../lib/defs.js';
|
|
4
|
-
import { actionOK, actionNotOK } from '../lib/util/index.js';
|
|
5
|
-
/**
|
|
6
|
-
* Virtual stepper that dynamically builds steps from `remember` statements.
|
|
7
|
-
* During pre-Resolve phase, this stepper is populated with conditions
|
|
8
|
-
* extracted from all `remember {condition} with {proof}` statements in features.
|
|
9
|
-
*
|
|
10
|
-
* When `ensure {condition}` is called, it will match against these conditions via
|
|
11
|
-
* normal GWTA resolution, check if already cached, and execute the recipe if needed.
|
|
12
|
-
*/
|
|
13
|
-
export class ConditionsStepper extends AStepper {
|
|
14
|
-
steps = {};
|
|
15
|
-
steppers = [];
|
|
16
|
-
// Track which conditions cause other conditions to be forgotten
|
|
17
|
-
// Key: condition, Value: array of conditions to forget
|
|
18
|
-
forgetsMap = {};
|
|
19
|
-
/**
|
|
20
|
-
* Register a condition with its proof steps.
|
|
21
|
-
* This is called when parsing `remember` statements.
|
|
22
|
-
*
|
|
23
|
-
* @param condition - The condition (e.g., "Is logged in as {user}")
|
|
24
|
-
* @param proofStatements - Array of statement strings that prove this condition
|
|
25
|
-
* @param proofPath - The path of the feature containing the proof
|
|
26
|
-
* @param forgets - Optional condition that this condition forgets
|
|
27
|
-
*/
|
|
28
|
-
registerCondition(condition, proofStatements, proofPath, forgets) {
|
|
29
|
-
// Prevent duplicate condition registration
|
|
30
|
-
if (this.steps[condition]) {
|
|
31
|
-
throw new Error(`Condition "${condition}" is already registered. Each condition can only be defined once.`);
|
|
32
|
-
}
|
|
33
|
-
// Store forgets relationship if provided
|
|
34
|
-
if (forgets) {
|
|
35
|
-
this.forgetsMap[condition] = [forgets];
|
|
36
|
-
}
|
|
37
|
-
this.getWorld().logger.info(`ConditionsStepper: registerCondition called with ${proofStatements.length} steps for "${condition}"`);
|
|
38
|
-
this.steps[condition] = {
|
|
39
|
-
gwta: condition,
|
|
40
|
-
description: `Condition: ${condition}. Proof: ${proofStatements.join('; ')}`,
|
|
41
|
-
action: async (args, featureStep) => {
|
|
42
|
-
this.getWorld().logger.debug(`ConditionsStepper: executing recipe for condition "${condition}" with args ${JSON.stringify(args)}`);
|
|
43
|
-
// If this condition forgets other conditions, handle that first
|
|
44
|
-
if (this.forgetsMap[condition]) {
|
|
45
|
-
const satisfied = this.getWorld().runtime.satisfiedConditions;
|
|
46
|
-
for (const forgottenCondition of this.forgetsMap[condition]) {
|
|
47
|
-
// Build the forgotten key the same way ensure builds it: from resolved step.in
|
|
48
|
-
// We need to resolve the forgotten condition with the same args
|
|
49
|
-
let forgottenKey = forgottenCondition;
|
|
50
|
-
// Replace placeholders with their values as they appear in featureStep.in
|
|
51
|
-
// The args values already have quotes if they were quoted in the input
|
|
52
|
-
for (const [key, value] of Object.entries(args)) {
|
|
53
|
-
// Need to add quotes back since args are unquoted
|
|
54
|
-
const quotedValue = typeof value === 'string' ? `"${value}"` : String(value);
|
|
55
|
-
forgottenKey = forgottenKey.replace(new RegExp(`\\{${key}\\}`, 'g'), quotedValue);
|
|
56
|
-
}
|
|
57
|
-
// Delete the matching cache entry
|
|
58
|
-
if (satisfied[forgottenKey]) {
|
|
59
|
-
delete satisfied[forgottenKey];
|
|
60
|
-
this.getWorld().logger.debug(`ConditionsStepper: auto-forgot "${forgottenKey}" due to forgets clause`);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
// Expand variables in proof statements using the matched args
|
|
65
|
-
const expandedProofStatements = proofStatements.map(statement => {
|
|
66
|
-
let expanded = statement;
|
|
67
|
-
for (const [key, value] of Object.entries(args)) {
|
|
68
|
-
expanded = expanded.replace(new RegExp(`\\{${key}\\}`, 'g'), String(value));
|
|
69
|
-
}
|
|
70
|
-
return expanded;
|
|
71
|
-
});
|
|
72
|
-
// Re-resolve the proof statements in the current execution context
|
|
73
|
-
const resolvedProofSteps = [];
|
|
74
|
-
for (let i = 0; i < expandedProofStatements.length; i++) {
|
|
75
|
-
const statement = expandedProofStatements[i];
|
|
76
|
-
this.getWorld().logger.debug(`ConditionsStepper: resolving proof statement ${i}: "${statement}"`);
|
|
77
|
-
const resolved = findFeatureStepsFromStatement(statement, this.steppers, this.world, proofPath, [...featureStep.seqPath, i], 1);
|
|
78
|
-
resolvedProofSteps.push(...resolved);
|
|
79
|
-
}
|
|
80
|
-
// Execute the re-resolved proof steps
|
|
81
|
-
const result = await executeSubFeatureSteps(featureStep, resolvedProofSteps, this.steppers, this.getWorld(), ExecMode.WITH_CYCLES);
|
|
82
|
-
if (!result.ok) {
|
|
83
|
-
return actionNotOK(`ConditionsStepper: failed to satisfy condition "${condition}"`);
|
|
84
|
-
}
|
|
85
|
-
// Cache the satisfied condition with provenance
|
|
86
|
-
const conditionKey = featureStep.in;
|
|
87
|
-
this.getWorld().runtime.satisfiedConditions[conditionKey] = {
|
|
88
|
-
seqPath: featureStep.seqPath,
|
|
89
|
-
proof: expandedProofStatements
|
|
90
|
-
};
|
|
91
|
-
this.getWorld().logger.debug(`ConditionsStepper: cached condition "${conditionKey}" at ${JSON.stringify(featureStep.seqPath)}`);
|
|
92
|
-
return actionOK();
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
this.getWorld().logger.info(`ConditionsStepper: registered condition "${condition}" with ${proofStatements.length} proof steps`);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
export default ConditionsStepper;
|
|
99
|
-
//# sourceMappingURL=conditions-stepper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"conditions-stepper.js","sourceRoot":"","sources":["../../src/steps/conditions-stepper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAG9C,OAAO,EAAE,sBAAsB,EAAE,6BAA6B,EAAE,MAAM,qCAAqC,CAAC;AAC5G,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAE7D;;;;;;;GAOG;AACH,MAAM,OAAO,iBAAkB,SAAQ,QAAQ;IAC7C,KAAK,GAAkB,EAAE,CAAC;IAC1B,QAAQ,GAAe,EAAE,CAAC;IAC1B,gEAAgE;IAChE,uDAAuD;IACvD,UAAU,GAA6B,EAAE,CAAC;IAE1C;;;;;;;;OAQG;IACH,iBAAiB,CAAC,SAAiB,EAAE,eAAyB,EAAE,SAAiB,EAAE,OAAgB;QACjG,2CAA2C;QAC3C,IAAI,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC;YAC1B,MAAM,IAAI,KAAK,CAAC,cAAc,SAAS,mEAAmE,CAAC,CAAC;QAC9G,CAAC;QAED,yCAAyC;QACzC,IAAI,OAAO,EAAE,CAAC;YACZ,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACzC,CAAC;QAED,IAAI,CAAC,QAAQ,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,oDAAoD,eAAe,CAAC,MAAM,eAAe,SAAS,GAAG,CAAC,CAAC;QAEnI,IAAI,CAAC,KAA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,EAAE,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC;gBAEnI,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;oBACf,OAAO,WAAW,CAAC,mDAAmD,SAAS,GAAG,CAAC,CAAC;gBACtF,CAAC;gBAED,gDAAgD;gBAChD,MAAM,YAAY,GAAG,WAAW,CAAC,EAAE,CAAC;gBACpC,IAAI,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,mBAAoB,CAAC,YAAY,CAAC,GAAG;oBAC3D,OAAO,EAAE,WAAW,CAAC,OAAO;oBAC5B,KAAK,EAAE,uBAAuB;iBAC/B,CAAC;gBACF,IAAI,CAAC,QAAQ,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,wCAAwC,YAAY,QAAQ,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;gBAEhI,OAAO,QAAQ,EAAE,CAAC;YACpB,CAAC;SACF,CAAC;QAEF,IAAI,CAAC,QAAQ,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,4CAA4C,SAAS,UAAU,eAAe,CAAC,MAAM,cAAc,CAAC,CAAC;IACnI,CAAC;CACF;AAED,eAAe,iBAAiB,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export type TRegisteredOutcome = {
|
|
2
|
-
proofStatements: string[];
|
|
3
|
-
proofPath: string;
|
|
4
|
-
isBackground?: boolean;
|
|
5
|
-
activityBlockSteps?: string[];
|
|
6
|
-
};
|
|
7
|
-
export declare const registeredOutcomesRegistry: Record<string, TRegisteredOutcome>;
|
|
8
|
-
//# sourceMappingURL=outcomesRegistry.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"outcomesRegistry.d.ts","sourceRoot":"","sources":["../../src/steps/outcomesRegistry.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,GAAG;IAC7B,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;CACjC,CAAC;AAGF,eAAO,MAAM,0BAA0B,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAM,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"outcomesRegistry.js","sourceRoot":"","sources":["../../src/steps/outcomesRegistry.ts"],"names":[],"mappings":"AAOA,2EAA2E;AAC3E,MAAM,CAAC,MAAM,0BAA0B,GAAuC,EAAE,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
type RegisteredOutcomeRecord = {
|
|
2
|
-
outcome: string;
|
|
3
|
-
proofStatements: string[];
|
|
4
|
-
proofPath: string;
|
|
5
|
-
isBackground?: boolean;
|
|
6
|
-
activityBlockSteps?: string[] | null;
|
|
7
|
-
};
|
|
8
|
-
export declare function addRegisteredOutcome(rec: RegisteredOutcomeRecord): void;
|
|
9
|
-
export declare function getRegisteredOutcomes(): RegisteredOutcomeRecord[];
|
|
10
|
-
export declare function clearRegisteredOutcomes(): void;
|
|
11
|
-
export {};
|
|
12
|
-
//# sourceMappingURL=registeredOutcomesStore.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"registeredOutcomesStore.d.ts","sourceRoot":"","sources":["../../src/steps/registeredOutcomesStore.ts"],"names":[],"mappings":"AAAA,KAAK,uBAAuB,GAAG;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,kBAAkB,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;CACtC,CAAC;AAIF,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,uBAAuB,QAEhE;AAED,wBAAgB,qBAAqB,IAAI,uBAAuB,EAAE,CAEjE;AAED,wBAAgB,uBAAuB,SAEtC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
const store = [];
|
|
2
|
-
export function addRegisteredOutcome(rec) {
|
|
3
|
-
store.push(rec);
|
|
4
|
-
}
|
|
5
|
-
export function getRegisteredOutcomes() {
|
|
6
|
-
return store.slice();
|
|
7
|
-
}
|
|
8
|
-
export function clearRegisteredOutcomes() {
|
|
9
|
-
store.length = 0;
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=registeredOutcomesStore.js.map
|