@o-lang/olang 1.1.2 → 1.1.3

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/runtime.js +15 -20
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@o-lang/olang",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "author": "Olalekan Ogundipe <info@workfily.com>",
5
5
  "description": "O-Lang: A governance language for user-directed, rule-enforced agent workflows",
6
6
  "main": "./src/index.js",
package/src/runtime.js CHANGED
@@ -343,7 +343,7 @@ class RuntimeAPI {
343
343
  }
344
344
  };
345
345
 
346
- // ✅ STRICT SAFETY: Updated runResolvers with failure halting
346
+ // ✅ CORRECTED: Strict safety WITH proper resolver chaining
347
347
  const runResolvers = async (action) => {
348
348
  const mathPattern =
349
349
  /^(Add|Subtract|Multiply|Divide|Sum|Avg|Min|Max|Round|Floor|Ceil|Abs)\b/i;
@@ -370,7 +370,7 @@ class RuntimeAPI {
370
370
  resolversToRun = [agentResolver];
371
371
  }
372
372
 
373
- // ✅ STRICT SAFETY: Fail fast on resolver errors or empty results
373
+ // ✅ CORRECTED SAFETY: Try ALL resolvers before halting
374
374
  for (let idx = 0; idx < resolversToRun.length; idx++) {
375
375
  const resolver = resolversToRun[idx];
376
376
  enforceResolverPolicy(resolver, step);
@@ -388,31 +388,26 @@ class RuntimeAPI {
388
388
  result = await resolver(action, this.context);
389
389
  }
390
390
 
391
- // ✅ SAFETY GUARD 1: Reject undefined/null results
392
- if (result === undefined || result === null) {
393
- throw new Error(
394
- `[O-Lang SAFETY] Resolver "${resolver.resolverName || resolver.name || 'anonymous'}" returned empty result for action: "${action}". ` +
395
- `Workflow halted to prevent unsafe data propagation.`
396
- );
391
+ // ✅ ACCEPT valid result immediately (non-null/non-undefined)
392
+ if (result !== undefined && result !== null) {
393
+ this.context[`__resolver_${idx}`] = result;
394
+ return result;
397
395
  }
398
-
399
- this.context[`__resolver_${idx}`] = result;
400
- return result;
396
+ // ❌ Resolver skipped this action (returned undefined/null) — continue to next resolver
397
+ // This is NORMAL resolver chaining behavior — NOT an error
401
398
 
402
399
  } catch (e) {
403
- // SAFETY GUARD 2: HALT workflow immediately on resolver failure
404
- throw new Error(
405
- `[O-Lang SAFETY] Resolver "${resolver?.resolverName || resolver?.name || idx}" failed for action "${action}": ${e.message}\n` +
406
- `Workflow execution halted.`
407
- );
400
+ // Resolver threw an error log warning but CONTINUE to next resolver
401
+ this.addWarning(`Resolver "${resolver?.resolverName || resolver?.name || idx}" threw error for action "${action}": ${e.message}`);
402
+ // Continue loop to try next resolver (don't halt yet)
408
403
  }
409
404
  }
410
405
 
411
- // ✅ SAFETY GUARD 3: No resolver handled the action — HALT
406
+ // ✅ SAFETY GUARD: ALL resolvers skipped/failed — HALT workflow
412
407
  throw new Error(
413
- `[O-Lang SAFETY] No resolver handled action: "${action}". ` +
414
- `Available resolvers: ${resolversToRun.map(r => r.resolverName || r.name || 'anonymous').join(', ')}. ` +
415
- `Workflow execution halted.`
408
+ `[O-Lang SAFETY] No resolver successfully handled action: "${action}". ` +
409
+ `Attempted resolvers: ${resolversToRun.map(r => r.resolverName || r.name || 'anonymous').join(', ')}. ` +
410
+ `Workflow execution halted to prevent unsafe data propagation.`
416
411
  );
417
412
  };
418
413