@haibun/core 2.0.0 → 3.0.0

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 (153) hide show
  1. package/build/applyEffectFeatures.d.ts.map +1 -1
  2. package/build/applyEffectFeatures.js +3 -6
  3. package/build/applyEffectFeatures.js.map +1 -1
  4. package/build/currentVersion.d.ts +1 -1
  5. package/build/currentVersion.js +1 -1
  6. package/build/jsprolog/converter.d.ts +9 -0
  7. package/build/jsprolog/converter.d.ts.map +1 -0
  8. package/build/jsprolog/converter.js +42 -0
  9. package/build/jsprolog/converter.js.map +1 -0
  10. package/build/jsprolog/stepper-utils.d.ts +8 -0
  11. package/build/jsprolog/stepper-utils.d.ts.map +1 -0
  12. package/build/jsprolog/stepper-utils.js +8 -0
  13. package/build/jsprolog/stepper-utils.js.map +1 -0
  14. package/build/jsprolog/test.jsprolog.d.ts +4 -0
  15. package/build/jsprolog/test.jsprolog.d.ts.map +1 -0
  16. package/build/jsprolog/test.jsprolog.js +19 -0
  17. package/build/jsprolog/test.jsprolog.js.map +1 -0
  18. package/build/jsprolog/test.kireji.d.ts +4 -0
  19. package/build/jsprolog/test.kireji.d.ts.map +1 -0
  20. package/build/jsprolog/test.kireji.js +19 -0
  21. package/build/jsprolog/test.kireji.js.map +1 -0
  22. package/build/jsprolog/withAction.d.ts +32 -0
  23. package/build/jsprolog/withAction.d.ts.map +1 -0
  24. package/build/jsprolog/withAction.js +65 -0
  25. package/build/jsprolog/withAction.js.map +1 -0
  26. package/build/kireji/converter.d.ts +9 -0
  27. package/build/kireji/converter.d.ts.map +1 -0
  28. package/build/kireji/converter.js +49 -0
  29. package/build/kireji/converter.js.map +1 -0
  30. package/build/kireji/test.kireji.d.ts +4 -0
  31. package/build/kireji/test.kireji.d.ts.map +1 -0
  32. package/build/kireji/test.kireji.js +19 -0
  33. package/build/kireji/test.kireji.js.map +1 -0
  34. package/build/kireji/withAction.d.ts +36 -0
  35. package/build/kireji/withAction.d.ts.map +1 -0
  36. package/build/kireji/withAction.js +66 -0
  37. package/build/kireji/withAction.js.map +1 -0
  38. package/build/lib/Logger.d.ts +2 -0
  39. package/build/lib/Logger.d.ts.map +1 -1
  40. package/build/lib/Logger.js +9 -5
  41. package/build/lib/Logger.js.map +1 -1
  42. package/build/lib/TestLogger.d.ts +1 -0
  43. package/build/lib/TestLogger.d.ts.map +1 -1
  44. package/build/lib/TestLogger.js +1 -0
  45. package/build/lib/TestLogger.js.map +1 -1
  46. package/build/lib/astepper.d.ts +4 -6
  47. package/build/lib/astepper.d.ts.map +1 -1
  48. package/build/lib/astepper.js +0 -1
  49. package/build/lib/astepper.js.map +1 -1
  50. package/build/lib/core-domains.d.ts +3 -3
  51. package/build/lib/core-domains.d.ts.map +1 -1
  52. package/build/lib/core-domains.js +3 -3
  53. package/build/lib/core-domains.js.map +1 -1
  54. package/build/lib/defs.d.ts +29 -23
  55. package/build/lib/defs.d.ts.map +1 -1
  56. package/build/lib/defs.js +2 -1
  57. package/build/lib/defs.js.map +1 -1
  58. package/build/lib/errors.d.ts +13 -0
  59. package/build/lib/errors.d.ts.map +1 -0
  60. package/build/lib/errors.js +18 -0
  61. package/build/lib/errors.js.map +1 -0
  62. package/build/lib/feature-variables.d.ts +4 -2
  63. package/build/lib/feature-variables.d.ts.map +1 -1
  64. package/build/lib/feature-variables.js +12 -2
  65. package/build/lib/feature-variables.js.map +1 -1
  66. package/build/lib/features.d.ts.map +1 -1
  67. package/build/lib/features.js +7 -3
  68. package/build/lib/features.js.map +1 -1
  69. package/build/lib/interfaces/logger.d.ts +4 -2
  70. package/build/lib/interfaces/logger.d.ts.map +1 -1
  71. package/build/lib/interfaces/logger.js +1 -0
  72. package/build/lib/interfaces/logger.js.map +1 -1
  73. package/build/lib/namedVars.d.ts.map +1 -1
  74. package/build/lib/namedVars.js +8 -1
  75. package/build/lib/namedVars.js.map +1 -1
  76. package/build/lib/populateActionArgs.js +1 -1
  77. package/build/lib/populateActionArgs.js.map +1 -1
  78. package/build/lib/test/TestSteps.d.ts +0 -5
  79. package/build/lib/test/TestSteps.d.ts.map +1 -1
  80. package/build/lib/test/TestSteps.js +0 -8
  81. package/build/lib/test/TestSteps.js.map +1 -1
  82. package/build/lib/test/lib.d.ts +4 -1
  83. package/build/lib/test/lib.d.ts.map +1 -1
  84. package/build/lib/test/lib.js +18 -5
  85. package/build/lib/test/lib.js.map +1 -1
  86. package/build/lib/test/resolvedTestFeatures.js +1 -1
  87. package/build/lib/test/resolvedTestFeatures.js.map +1 -1
  88. package/build/lib/util/featureStep-executor.d.ts +2 -1
  89. package/build/lib/util/featureStep-executor.d.ts.map +1 -1
  90. package/build/lib/util/featureStep-executor.js +31 -7
  91. package/build/lib/util/featureStep-executor.js.map +1 -1
  92. package/build/lib/util/index.d.ts +3 -1
  93. package/build/lib/util/index.d.ts.map +1 -1
  94. package/build/lib/util/index.js +2 -0
  95. package/build/lib/util/index.js.map +1 -1
  96. package/build/phases/Executor.d.ts +6 -1
  97. package/build/phases/Executor.d.ts.map +1 -1
  98. package/build/phases/Executor.js +156 -22
  99. package/build/phases/Executor.js.map +1 -1
  100. package/build/phases/Resolver.d.ts +4 -3
  101. package/build/phases/Resolver.d.ts.map +1 -1
  102. package/build/phases/Resolver.js +49 -31
  103. package/build/phases/Resolver.js.map +1 -1
  104. package/build/phases/collector.d.ts +1 -1
  105. package/build/phases/collector.d.ts.map +1 -1
  106. package/build/phases/collector.js +36 -7
  107. package/build/phases/collector.js.map +1 -1
  108. package/build/runner.d.ts.map +1 -1
  109. package/build/runner.js +4 -7
  110. package/build/runner.js.map +1 -1
  111. package/build/steps/activities-stepper.d.ts +79 -0
  112. package/build/steps/activities-stepper.d.ts.map +1 -0
  113. package/build/steps/activities-stepper.js +342 -0
  114. package/build/steps/activities-stepper.js.map +1 -0
  115. package/build/steps/conditions-stepper.d.ts +27 -0
  116. package/build/steps/conditions-stepper.d.ts.map +1 -0
  117. package/build/steps/conditions-stepper.js +99 -0
  118. package/build/steps/conditions-stepper.js.map +1 -0
  119. package/build/steps/debugger-stepper.d.ts +60 -2
  120. package/build/steps/debugger-stepper.d.ts.map +1 -1
  121. package/build/steps/debugger-stepper.js +5 -5
  122. package/build/steps/debugger-stepper.js.map +1 -1
  123. package/build/steps/haibun.d.ts +69 -22
  124. package/build/steps/haibun.d.ts.map +1 -1
  125. package/build/steps/haibun.js +138 -75
  126. package/build/steps/haibun.js.map +1 -1
  127. package/build/steps/narrator.d.ts +4 -4
  128. package/build/steps/parse.d.ts +1 -1
  129. package/build/steps/variables-stepper.d.ts +69 -4
  130. package/build/steps/variables-stepper.d.ts.map +1 -1
  131. package/build/steps/variables-stepper.js +44 -14
  132. package/build/steps/variables-stepper.js.map +1 -1
  133. package/package.json +1 -1
  134. package/build/lib/dependency-resolver.d.ts +0 -2
  135. package/build/lib/dependency-resolver.d.ts.map +0 -1
  136. package/build/lib/dependency-resolver.js +0 -3
  137. package/build/lib/dependency-resolver.js.map +0 -1
  138. package/build/lib/resolve-or-error.d.ts +0 -2
  139. package/build/lib/resolve-or-error.d.ts.map +0 -1
  140. package/build/lib/resolve-or-error.js +0 -3
  141. package/build/lib/resolve-or-error.js.map +0 -1
  142. package/build/lib/resolved-text-view.d.ts +0 -32
  143. package/build/lib/resolved-text-view.d.ts.map +0 -1
  144. package/build/lib/resolved-text-view.js +0 -103
  145. package/build/lib/resolved-text-view.js.map +0 -1
  146. package/build/lib/resolved-view.d.ts +0 -45
  147. package/build/lib/resolved-view.d.ts.map +0 -1
  148. package/build/lib/resolved-view.js +0 -133
  149. package/build/lib/resolved-view.js.map +0 -1
  150. package/build/phases/statement.test copy.d.ts +0 -2
  151. package/build/phases/statement.test copy.d.ts.map +0 -1
  152. package/build/phases/statement.test copy.js +0 -57
  153. package/build/phases/statement.test copy.js.map +0 -1
package/build/runner.js CHANGED
@@ -1,4 +1,3 @@
1
- import { applyEffectFeatures } from './applyEffectFeatures.js';
2
1
  import { expand } from './lib/features.js';
3
2
  import { verifyRequiredOptions, verifyExtraOptions, createSteppers, setStepperWorldsAndDomains } from './lib/util/index.js';
4
3
  import { getSteppers } from './lib/util/workspace-lib.js';
@@ -13,7 +12,7 @@ export class Runner {
13
12
  this.world = world;
14
13
  }
15
14
  errorBail = (phase, error, details) => {
16
- this.world.logger.error(`errorBail ${phase} ${error} ${details}`, error.stack);
15
+ // this.world.logger.error(`errorBail ${phase} ${error} ${details}`, error.stack);
17
16
  this.result = {
18
17
  ok: false,
19
18
  shared: this.world.shared,
@@ -27,7 +26,7 @@ export class Runner {
27
26
  async run(steppers, featureFilter = []) {
28
27
  let featuresBackgrounds = undefined;
29
28
  try {
30
- featuresBackgrounds = getFeaturesAndBackgrounds(this.world.bases, featureFilter);
29
+ featuresBackgrounds = await getFeaturesAndBackgrounds(this.world.bases, featureFilter);
31
30
  }
32
31
  catch (error) {
33
32
  this.errorBail('Collector', error);
@@ -45,11 +44,9 @@ export class Runner {
45
44
  // Make backgrounds available at runtime for inline `Backgrounds:` expansion
46
45
  this.world.runtime.backgrounds = featuresBackgrounds.backgrounds;
47
46
  const expandedFeatures = await expand(featuresBackgrounds).catch((error) => this.errorBail('Expand', error));
48
- const resolver = new Resolver(this.steppers);
47
+ const resolver = new Resolver(this.steppers, featuresBackgrounds.backgrounds);
49
48
  const resolvedFeatures = await resolver.resolveStepsFromFeatures(expandedFeatures).catch((error) => this.errorBail('Resolve', error));
50
- const appliedResolvedFeatures = await applyEffectFeatures(this.world, resolvedFeatures, this.steppers);
51
- this.world.logger.log(`features: ${appliedResolvedFeatures.length} (${appliedResolvedFeatures.map((e) => e.path)}) backgrounds: ${featuresBackgrounds.backgrounds.length}`);
52
- this.result = await Executor.executeFeatures(this.steppers, this.world, appliedResolvedFeatures).catch((error) => this.errorBail('Execute', error));
49
+ this.result = await Executor.executeFeatures(this.steppers, this.world, resolvedFeatures).catch((error) => this.errorBail('Execute', error));
53
50
  }
54
51
  catch (error) {
55
52
  if (!this.result) {
@@ -1 +1 @@
1
- {"version":3,"file":"runner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C,OAAO,CAAC,WAAW,GAAG,mBAAmB,CAAC,WAAW,CAAC;YACjE,MAAM,gBAAgB,GAAG,MAAM,MAAM,CAAC,mBAAmB,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC;YAE7G,MAAM,QAAQ,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE,mBAAmB,CAAC,WAAW,CAAC,CAAC;YAC9E,MAAM,gBAAgB,GAAG,MAAM,QAAQ,CAAC,wBAAwB,CAAC,gBAAgB,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC;YAEtI,IAAI,CAAC,MAAM,GAAG,MAAM,QAAQ,CAAC,eAAe,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CACzG,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,KAAK,CAAC,CAChC,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;gBAClB,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;YAChC,CAAC;QACF,CAAC;QAED,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;CACD"}
@@ -0,0 +1,79 @@
1
+ import { AStepper, 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
+ forget: TStepperStep;
8
+ waypointed: TStepperStep;
9
+ showWaypoints: TStepperStep;
10
+ };
11
+ type TActivitiesStepperSteps = TStepperSteps & TActivitiesFixedSteps;
12
+ /**
13
+ * Stepper that dynamically builds virtual steps from `waypoint` statements.
14
+ * implements this logic: P ∨ (¬P ∧ [A]P)
15
+ */
16
+ export declare class ActivitiesStepper extends AStepper {
17
+ private steppers;
18
+ private backgroundOutcomePatterns;
19
+ private featureOutcomePatterns;
20
+ private outcomeToFeaturePath;
21
+ private currentFeaturePath;
22
+ private lastFeaturePath;
23
+ private ensuredInstances;
24
+ private readonly baseSteps;
25
+ readonly typedSteps: {
26
+ readonly activity: {
27
+ readonly gwta: "Activity: {activity}";
28
+ readonly action: () => import("../lib/defs.js").TOKActionResult;
29
+ };
30
+ readonly waypoint: {
31
+ readonly gwta: "waypoint {outcome} with {proof:statement}";
32
+ readonly resolveFeatureLine: (line: string, path: string, stepper: AStepper, _backgrounds: TFeatures, allLines?: string[], lineIndex?: number) => boolean;
33
+ readonly action: ({ proof }: {
34
+ proof: TFeatureStep[];
35
+ }, featureStep: TFeatureStep) => Promise<import("../lib/defs.js").TOKActionResult | import("../lib/defs.js").TNotOKActionResult>;
36
+ };
37
+ readonly ensure: {
38
+ 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.";
39
+ readonly gwta: "ensure {outcome:statement}";
40
+ readonly action: ({ outcome }: {
41
+ outcome: TFeatureStep[];
42
+ }, featureStep: TFeatureStep) => Promise<import("../lib/defs.js").TOKActionResult | import("../lib/defs.js").TNotOKActionResult>;
43
+ };
44
+ readonly forget: {
45
+ readonly description: "Deprecated: forget is no longer needed since ensure always re-verifies outcomes";
46
+ readonly gwta: "forget {outcome:statement}";
47
+ readonly action: ({ outcome }: {
48
+ outcome: TFeatureStep[];
49
+ }, featureStep: TFeatureStep) => import("../lib/defs.js").TOKActionResult;
50
+ };
51
+ readonly waypointed: {
52
+ readonly description: "Deprecated: waypointed is no longer meaningful since outcomes are not cached";
53
+ readonly gwta: "waypointed {outcome:statement}";
54
+ readonly action: ({ outcome }: {
55
+ outcome: TFeatureStep[];
56
+ }) => import("../lib/defs.js").TOKActionResult;
57
+ };
58
+ readonly showWaypoints: {
59
+ readonly exact: "show waypoints";
60
+ readonly action: (_args: TStepArgs, featureStep: TFeatureStep) => Promise<import("../lib/defs.js").TOKActionResult>;
61
+ };
62
+ };
63
+ steps: TActivitiesStepperSteps;
64
+ cycles: IStepperCycles;
65
+ setWorld(world: TWorld, steppers: AStepper[]): Promise<void>;
66
+ /**
67
+ * Register a dynamic outcome step.
68
+ * This is called when parsing `waypoint` statements.
69
+ *
70
+ * @param outcome - The outcome pattern (e.g., "Is logged in as {user}")
71
+ * @param proofStatements - Array of statement strings from the DOMAIN_STATEMENT proof
72
+ * @param proofPath - The path of the feature containing the proof
73
+ * @param isBackground - Whether this outcome is defined in a background (persists across features)
74
+ * @param activityBlockSteps - Optional array of all steps in the containing activity block
75
+ */
76
+ registerOutcome(outcome: string, proofStatements: string[], proofPath: string, isBackground?: boolean, activityBlockSteps?: string[]): void;
77
+ }
78
+ export default ActivitiesStepper;
79
+ //# sourceMappingURL=activities-stepper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"activities-stepper.d.ts","sourceRoot":"","sources":["../../src/steps/activities-stepper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAiB,SAAS,EAAE,YAAY,EAAM,MAAM,EAAE,cAAc,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAQ7H,KAAK,qBAAqB,GAAG;IAC5B,QAAQ,EAAE,YAAY,CAAC;IACvB,QAAQ,EAAE,YAAY,CAAC;IACvB,MAAM,EAAE,YAAY,CAAC;IACrB,MAAM,EAAE,YAAY,CAAC;IACrB,UAAU,EAAE,YAAY,CAAC;IACzB,aAAa,EAAE,YAAY,CAAC;CAC5B,CAAC;AAEF,KAAK,uBAA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atement } 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
+ // Track which outcome patterns were defined in backgrounds vs features
15
+ backgroundOutcomePatterns = new Set();
16
+ featureOutcomePatterns = new Set();
17
+ // Track which feature each feature-scoped outcome belongs to (for proper cleanup)
18
+ outcomeToFeaturePath = new Map();
19
+ // Track the currently running feature path
20
+ currentFeaturePath = '';
21
+ // Track the last feature path to clear outcomes from it when starting a new feature
22
+ lastFeaturePath = '';
23
+ // Track ensured waypoint instances with their interpolated proofs
24
+ ensuredInstances = new Map();
25
+ baseSteps = {
26
+ activity: {
27
+ gwta: 'Activity: {activity}',
28
+ action: () => OK
29
+ },
30
+ waypoint: {
31
+ gwta: `waypoint {outcome} with {proof:${DOMAIN_STATEMENT}}`,
32
+ resolveFeatureLine: (line, path, stepper, _backgrounds, allLines, lineIndex) => {
33
+ // Simple regex match to check if this is a waypoint statement
34
+ if (!line.match(/^waypoint\s+.+?\s+with\s+/i)) {
35
+ return false;
36
+ }
37
+ const activitiesStepper = stepper;
38
+ // Extract outcome name
39
+ const match = line.match(/^waypoint\s+(.+?)\s+with\s+(.+?)$/i);
40
+ if (!match) {
41
+ return false;
42
+ }
43
+ const outcome = match[1].trim();
44
+ // Skip if this outcome pattern is already registered
45
+ // This prevents infinite loops if resolveFeatureLine is called multiple times
46
+ if (activitiesStepper.backgroundOutcomePatterns.has(outcome) || activitiesStepper.featureOutcomePatterns.has(outcome)) {
47
+ return true;
48
+ }
49
+ const isBackground = path.includes('backgrounds/');
50
+ const proofRaw = match[2].trim();
51
+ // Parse the proof statements from the waypoint clause (DOMAIN_STATEMENT)
52
+ const proofFromRemember = proofRaw.split('\n').map(s => s.trim()).filter(s => s.length > 0);
53
+ // Check if we're in an activity block by scanning backwards through allLines
54
+ let activityBlockSteps;
55
+ if (allLines && lineIndex !== undefined) {
56
+ // Scan backwards from current line to find the Activity: marker
57
+ let activityStartLine = -1;
58
+ for (let i = lineIndex - 1; i >= 0; i--) {
59
+ const prevLine = getActionable(allLines[i]);
60
+ if (prevLine.match(/^Activity:/i)) {
61
+ activityStartLine = i;
62
+ break;
63
+ }
64
+ // Stop if we hit another major section marker
65
+ if (prevLine.match(/^(Feature|Scenario|Background):/i)) {
66
+ break;
67
+ }
68
+ }
69
+ if (activityStartLine !== -1) {
70
+ // Collect ALL steps in the activity block up to and including the current waypoint statement
71
+ const blockLines = [];
72
+ for (let i = activityStartLine + 1; i < lineIndex; i++) { // Use < instead of <= to exclude waypoint line
73
+ const stepLine = getActionable(allLines[i]);
74
+ if (stepLine) {
75
+ blockLines.push(stepLine);
76
+ }
77
+ }
78
+ activityBlockSteps = blockLines;
79
+ }
80
+ }
81
+ // Register the outcome with its proof from the DOMAIN_STATEMENT
82
+ activitiesStepper.registerOutcome(outcome, proofFromRemember, path, isBackground, activityBlockSteps);
83
+ return true; // Skip normal step resolution since we've registered the outcome
84
+ },
85
+ action: async ({ proof }, featureStep) => {
86
+ // Execute the proof statements to satisfy this outcome
87
+ this.getWorld().logger.debug(`waypoint action: executing ${proof?.length || 0} proof steps`);
88
+ const result = await executeSubFeatureSteps(featureStep, proof, this.steppers, this.getWorld(), ExecMode.NO_CYCLES);
89
+ if (!result.ok) {
90
+ return actionNotOK(`waypoint: failed to execute proof steps`);
91
+ }
92
+ return actionOK();
93
+ },
94
+ },
95
+ ensure: {
96
+ 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.',
97
+ gwta: `ensure {outcome:${DOMAIN_STATEMENT}}`,
98
+ action: async ({ outcome }, featureStep) => {
99
+ // Build outcome key from the resolved outcome steps
100
+ const outcomeKey = outcome.map(step => step.in).join(' ');
101
+ this.getWorld().logger.debug(`ensure: verifying waypoint "${outcomeKey}"`);
102
+ // Get the pattern from the first outcome step's action
103
+ const pattern = outcome[0]?.action?.actionName || outcomeKey;
104
+ // Get the registered waypoint to access its proof
105
+ const registeredWaypoint = this.steps[pattern];
106
+ if (!registeredWaypoint) {
107
+ const messageContext = {
108
+ incident: EExecutionMessageType.ACTION,
109
+ incidentDetails: { waypoint: outcomeKey, error: 'waypoint not registered' }
110
+ };
111
+ return actionNotOK(`ensure: waypoint "${outcomeKey}" (pattern "${pattern}") is not registered`, { messageContext });
112
+ }
113
+ // Always execute the full waypoint (which includes the proof verification)
114
+ const result = await executeSubFeatureSteps(featureStep, outcome, this.steppers, this.getWorld(), ExecMode.NO_CYCLES);
115
+ if (!result.ok) {
116
+ const messageContext = {
117
+ incident: EExecutionMessageType.ACTION,
118
+ incidentDetails: { waypoint: outcomeKey, satisfied: false, error: result }
119
+ };
120
+ return actionNotOK(`ensure: waypoint "${outcomeKey}" could not be satisfied`, { messageContext });
121
+ }
122
+ // Extract the interpolated proof statements from the result
123
+ const proofStatements = result.stepActionResult?.messageContext?.incidentDetails?.proofStatements;
124
+ // Track this ensured instance
125
+ if (proofStatements) {
126
+ this.ensuredInstances.set(outcomeKey, { proof: proofStatements, valid: true });
127
+ }
128
+ this.getWorld().logger.debug(`ensure: waypoint "${outcomeKey}" verified and satisfied`);
129
+ const messageContext = {
130
+ incident: EExecutionMessageType.ACTION,
131
+ incidentDetails: {
132
+ waypoint: outcomeKey,
133
+ satisfied: true,
134
+ proofStatements
135
+ }
136
+ };
137
+ return actionOK({ messageContext });
138
+ },
139
+ },
140
+ forget: {
141
+ description: 'Deprecated: forget is no longer needed since ensure always re-verifies outcomes',
142
+ gwta: `forget {outcome:${DOMAIN_STATEMENT}}`,
143
+ action: ({ outcome }, featureStep) => {
144
+ const outcomeKey = outcome.map(step => step.in).join(' ');
145
+ this.getWorld().logger.debug(`forget: deprecated no-op for outcome "${outcomeKey}" (from ${featureStep.in}). Outcomes are no longer cached, so forget is unnecessary.`);
146
+ const messageContext = { incident: EExecutionMessageType.ACTION, incidentDetails: { outcome: outcomeKey, deprecated: true } };
147
+ return actionOK({ messageContext });
148
+ },
149
+ },
150
+ waypointed: {
151
+ description: 'Deprecated: waypointed is no longer meaningful since outcomes are not cached',
152
+ gwta: `waypointed {outcome:${DOMAIN_STATEMENT}}`,
153
+ action: ({ outcome }) => {
154
+ const outcomeKey = outcome.map(step => step.in).join(' ');
155
+ this.getWorld().logger.debug(`waypointed: deprecated for outcome "${outcomeKey}". Outcomes are verified on each ensure, not cached.`);
156
+ const messageContext = { incident: EExecutionMessageType.ACTION, incidentDetails: { outcome: outcomeKey, deprecated: true } };
157
+ return actionOK({ messageContext });
158
+ },
159
+ },
160
+ showWaypoints: {
161
+ exact: 'show waypoints',
162
+ action: async (_args, featureStep) => {
163
+ // Show ensured waypoint instances with their current validity
164
+ const waypointResults = {};
165
+ // Check validity of all ensured instances
166
+ for (const [instanceKey, instanceData] of this.ensuredInstances.entries()) {
167
+ this.getWorld().logger.debug(`show waypoints: verifying "${instanceKey}"`);
168
+ try {
169
+ // Re-verify the proof for this instance
170
+ const resolvedSteps = [];
171
+ for (let i = 0; i < instanceData.proof.length; i++) {
172
+ const statement = instanceData.proof[i];
173
+ const resolved = findFeatureStepsFromStatement(statement, this.steppers, this.getWorld(), featureStep.path, [...featureStep.seqPath, i], 1);
174
+ // Add waypoint context to each proof step
175
+ const contextualizedSteps = resolved.map(step => ({
176
+ ...step,
177
+ in: `[${instanceKey} proof] ${step.in}`
178
+ }));
179
+ resolvedSteps.push(...contextualizedSteps);
180
+ }
181
+ // Execute the proof statements with NO_CYCLES to check current validity
182
+ const result = await executeSubFeatureSteps(featureStep, resolvedSteps, this.steppers, this.getWorld(), ExecMode.NO_CYCLES);
183
+ waypointResults[instanceKey] = {
184
+ proof: instanceData.proof.join('; '),
185
+ currentlyValid: result.ok
186
+ };
187
+ }
188
+ catch (error) {
189
+ waypointResults[instanceKey] = {
190
+ proof: instanceData.proof.join('; '),
191
+ currentlyValid: false,
192
+ error: error instanceof Error ? error.message : String(error)
193
+ };
194
+ }
195
+ }
196
+ this.getWorld().logger.info(`Waypoints (${Object.keys(waypointResults).length} ensured):\n${JSON.stringify(waypointResults, null, 2)}`);
197
+ return actionOK({ messageContext: { incident: EExecutionMessageType.ACTION, incidentDetails: { waypoints: waypointResults } } });
198
+ },
199
+ },
200
+ };
201
+ typedSteps = this.baseSteps;
202
+ steps = { ...this.baseSteps };
203
+ cycles = {
204
+ startFeature: (startFeature) => {
205
+ this.getWorld().logger.info(`ActivitiesStepper.startFeature: starting feature at path "${startFeature.resolvedFeature.path}"`);
206
+ // If we were running a different feature before, clear its outcomes
207
+ if (this.lastFeaturePath && this.lastFeaturePath !== startFeature.resolvedFeature.path) {
208
+ this.getWorld().logger.info(`ActivitiesStepper.startFeature: clearing outcomes from previous feature "${this.lastFeaturePath}"`);
209
+ const outcomesToClear = [];
210
+ for (const [outcome, featurePath] of this.outcomeToFeaturePath.entries()) {
211
+ if (featurePath === this.lastFeaturePath) {
212
+ outcomesToClear.push(outcome);
213
+ delete this.steps[outcome];
214
+ this.featureOutcomePatterns.delete(outcome);
215
+ }
216
+ }
217
+ for (const outcome of outcomesToClear) {
218
+ this.outcomeToFeaturePath.delete(outcome);
219
+ }
220
+ this.getWorld().logger.info(`ActivitiesStepper.startFeature: cleared ${outcomesToClear.length} outcomes from previous feature`);
221
+ }
222
+ this.currentFeaturePath = startFeature.resolvedFeature.path;
223
+ },
224
+ endFeature: async () => {
225
+ // Track this feature path so we can clean it up when the next feature starts
226
+ this.lastFeaturePath = this.currentFeaturePath;
227
+ // Clear ensured instances for next feature
228
+ this.ensuredInstances.clear();
229
+ return Promise.resolve();
230
+ }
231
+ };
232
+ async setWorld(world, steppers) {
233
+ await super.setWorld(world, steppers);
234
+ this.steppers = steppers;
235
+ }
236
+ /**
237
+ * Register a dynamic outcome step.
238
+ * This is called when parsing `waypoint` statements.
239
+ *
240
+ * @param outcome - The outcome pattern (e.g., "Is logged in as {user}")
241
+ * @param proofStatements - Array of statement strings from the DOMAIN_STATEMENT proof
242
+ * @param proofPath - The path of the feature containing the proof
243
+ * @param isBackground - Whether this outcome is defined in a background (persists across features)
244
+ * @param activityBlockSteps - Optional array of all steps in the containing activity block
245
+ */
246
+ registerOutcome(outcome, proofStatements, proofPath, isBackground, activityBlockSteps) {
247
+ // Prevent duplicate outcome registration
248
+ if (this.steps[outcome]) {
249
+ throw new Error(`Outcome "${outcome}" is already registered. Each outcome can only be defined once.`);
250
+ }
251
+ // Track whether this is a background or feature outcome
252
+ if (isBackground) {
253
+ this.backgroundOutcomePatterns.add(outcome);
254
+ }
255
+ else {
256
+ this.featureOutcomePatterns.add(outcome);
257
+ // Track which feature this outcome belongs to
258
+ this.outcomeToFeaturePath.set(outcome, proofPath);
259
+ }
260
+ this.getWorld().logger.info(`ActivitiesStepper: registerOutcome called with ${proofStatements.length} proof steps for "${outcome}"`);
261
+ this.getWorld().logger.info(`ActivitiesStepper: outcome is background=${isBackground}, will be added to ${isBackground ? 'backgroundOutcomePatterns' : 'featureOutcomePatterns'}`);
262
+ // Store proofStatements for later retrieval
263
+ const outcomeProofStatements = proofStatements;
264
+ this.steps[outcome] = {
265
+ gwta: outcome,
266
+ virtual: true, // Dynamically registered outcomes are virtual
267
+ description: `Outcome: ${outcome}. Proof: ${proofStatements.join('; ')}`,
268
+ action: async (args, featureStep) => {
269
+ this.getWorld().logger.debug(`ActivitiesStepper: executing recipe for outcome "${outcome}" with args ${JSON.stringify(args)}`);
270
+ // Helper to expand variables in statements
271
+ const expandStatements = (statements) => statements.map(statement => {
272
+ let expanded = statement;
273
+ for (const [key, value] of Object.entries(args)) {
274
+ expanded = expanded.replace(new RegExp(`\\{${key}\\}`, 'g'), String(value));
275
+ }
276
+ return expanded;
277
+ });
278
+ // Helper to resolve and execute statements
279
+ const resolveAndExecute = async (statements, stepOffset = 0, execMode = ExecMode.NO_CYCLES) => {
280
+ const expandedStatements = expandStatements(statements);
281
+ const resolvedSteps = [];
282
+ for (let i = 0; i < expandedStatements.length; i++) {
283
+ const statement = expandedStatements[i];
284
+ this.getWorld().logger.debug(`ActivitiesStepper: resolving statement ${i}: "${statement}"`);
285
+ const resolved = findFeatureStepsFromStatement(statement, this.steppers, this.getWorld(), proofPath, [...featureStep.seqPath, stepOffset + i], 1);
286
+ resolvedSteps.push(...resolved);
287
+ }
288
+ return await executeSubFeatureSteps(featureStep, resolvedSteps, this.steppers, this.getWorld(), execMode);
289
+ };
290
+ // ALWAYS-VERIFY SEMANTICS: Try proof first
291
+ // Use NO_CYCLES for proof checking to avoid triggering hooks
292
+ this.getWorld().logger.debug(`ActivitiesStepper: checking proof for outcome "${outcome}"`);
293
+ this.getWorld().logger.debug(`ActivitiesStepper: proof statements: ${JSON.stringify(proofStatements)}`);
294
+ const proofResult = await resolveAndExecute(proofStatements, 0, ExecMode.NO_CYCLES);
295
+ // If proof passes, we're done (waypoint already satisfied)
296
+ if (proofResult.ok) {
297
+ this.getWorld().logger.debug(`ActivitiesStepper: proof passed for outcome "${outcome}", skipping activity body`);
298
+ const interpolatedProof = expandStatements(outcomeProofStatements);
299
+ return actionOK({
300
+ messageContext: {
301
+ incident: EExecutionMessageType.ACTION,
302
+ incidentDetails: { proofStatements: interpolatedProof, proofSatisfied: true }
303
+ }
304
+ });
305
+ }
306
+ // Proof failed - execute activity body (WITHOUT waypoint line), then verify proof
307
+ // Flow: 1) Execute activity body steps, 2) Execute proof to verify, 3) Success or fail
308
+ if (activityBlockSteps && activityBlockSteps.length > 0) {
309
+ this.getWorld().logger.debug(`ActivitiesStepper: proof failed for outcome "${outcome}", running activity body`);
310
+ // Step 1: Execute activity body (does NOT include the waypoint line to avoid recursion)
311
+ // Use WITH_CYCLES so that activity body steps can trigger hooks
312
+ const activityResult = await resolveAndExecute(activityBlockSteps, 100, ExecMode.WITH_CYCLES);
313
+ if (!activityResult.ok) {
314
+ return actionNotOK(`ActivitiesStepper: activity body failed for outcome "${outcome}"`);
315
+ }
316
+ // Step 2: Activity body succeeded - now verify the proof passes
317
+ // Use NO_CYCLES for proof verification to avoid triggering hooks
318
+ this.getWorld().logger.debug(`ActivitiesStepper: verifying proof after activity body for outcome "${outcome}"`);
319
+ const verifyResult = await resolveAndExecute(proofStatements, 200, ExecMode.NO_CYCLES);
320
+ if (!verifyResult.ok) {
321
+ return actionNotOK(`ActivitiesStepper: proof verification failed after activity body for outcome "${outcome}"`);
322
+ }
323
+ // Step 3: Success - proof now passes
324
+ const interpolatedProof = expandStatements(outcomeProofStatements);
325
+ return actionOK({
326
+ messageContext: {
327
+ incident: EExecutionMessageType.ACTION,
328
+ incidentDetails: { proofStatements: interpolatedProof }
329
+ }
330
+ });
331
+ }
332
+ else {
333
+ // No activity body, just proof - and it failed
334
+ return actionNotOK(`ActivitiesStepper: proof failed and no activity body available for outcome "${outcome}"`);
335
+ }
336
+ }
337
+ };
338
+ this.getWorld().logger.info(`ActivitiesStepper: registered outcome pattern "${outcome}" with ${proofStatements.length} proof steps`);
339
+ }
340
+ }
341
+ export default ActivitiesStepper;
342
+ //# sourceMappingURL=activities-stepper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"activities-stepper.js","sourceRoot":"","sources":["../../src/steps/activities-stepper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAiB,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAA0C,EAAE,EAAmD,MAAM,gBAAgB,CAAC;AAC7H,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,CA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G,CAAC,CAAC;oBACjH,CAAC;oBAED,qCAAqC;oBACrC,MAAM,iBAAiB,GAAG,gBAAgB,CAAC,sBAAsB,CAAC,CAAC;oBACnE,OAAO,QAAQ,CAAC;wBACf,cAAc,EAAE;4BACf,QAAQ,EAAE,qBAAqB,CAAC,MAAM;4BACtC,eAAe,EAAE,EAAE,eAAe,EAAE,iBAAiB,EAAE;yBACvD;qBACD,CAAC,CAAC;gBACJ,CAAC;qBAAM,CAAC;oBACP,+CAA+C;oBAC/C,OAAO,WAAW,CAAC,+EAA+E,OAAO,GAAG,CAAC,CAAC;gBAC/G,CAAC;YACF,CAAC;SACD,CAAC;QAEF,IAAI,CAAC,QAAQ,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,kDAAkD,OAAO,UAAU,eAAe,CAAC,MAAM,cAAc,CAAC,CAAC;IACtI,CAAC;CACD;AAED,eAAe,iBAAiB,CAAC"}
@@ -0,0 +1,27 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,99 @@
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