@o-lang/olang 1.2.37 → 1.2.38

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@o-lang/olang",
3
- "version": "1.2.37",
3
+ "version": "1.2.38",
4
4
  "author": "Olalekan Ogundipe <info@olang.cloud>",
5
5
  "description": "O-Lang: A governance language for user-directed, rule-enforced agent workflows",
6
6
  "main": "./src/runtime/index.js",
@@ -870,28 +870,44 @@ _validateInputs(inputs) {
870
870
  const isAfrican = ['yo', 'ig', 'ha', 'sw', 'zu', 'am', 'om', 'ff', 'so', 'sn'].includes(lang);
871
871
  const isFinancial = ['transfer', 'payment', 'withdrawal', 'deposit', 'financial_action'].includes(capability);
872
872
 
873
- // ✅ NEW: Check if this is a legal context with contextual allowlist
874
- const isLegalContext =
875
- this.context.__verified_intent?.scope === 'legal_analysis_only' ||
876
- inputs.doc_type === 'contract' ||
877
- inputs.doc_type === 'nda' ||
878
- inputs.doc_type === 'agreement' ||
879
- (typeof text === 'string' && /clause|term|agreement|contract|obligation|penalty|damages|breach|party|shall|herein/i.test(text));
873
+ // ✅ DECOUPLED: Check legal context via standardized signals (not UI fields)
874
+ const intent = this.context.__verified_intent || {};
875
+ const signals = intent.context_signals || {};
876
+
877
+ const isLegalContext =
878
+ // Signal 1: Explicit scope declaration
879
+ intent.scope === 'legal_analysis_only' ||
880
+
881
+ // Signal 2: Standardized context signals (server-mapped, UI-agnostic)
882
+ signals.isLegalDocument === true ||
883
+ signals.documentCategory === 'contract' ||
884
+ signals.documentCategory === 'nda' ||
885
+ signals.documentCategory === 'agreement' ||
886
+ signals.documentCategory === 'legal' ||
887
+
888
+ // Signal 3: Semantic fallback (works even if signals missing)
889
+ (typeof text === 'string' && /clause|term|agreement|contract|obligation|penalty|damages|breach|party|shall|herein/i.test(text));
880
890
 
881
891
  // ✅ NEW: Check contextual allowlist if in legal context
882
892
  if (isLegalContext && this.context.__verified_intent?.contextual_allowlist) {
883
893
  const allowlist = this.context.__verified_intent.contextual_allowlist;
884
894
  const triggerWord = match ? match[0].toLowerCase() : '';
885
895
 
886
- const allowed = allowlist.some(rule => {
887
- if (triggerWord.includes(rule.trigger.toLowerCase())) {
888
- // Check if required legal keywords are present
889
- return rule.requires.some(keyword =>
890
- text.toLowerCase().includes(keyword.toLowerCase())
891
- );
892
- }
893
- return false;
894
- });
896
+ // Inside the contextual allowlist check in _validateInputs:
897
+ const allowed = allowlist.some(rule => {
898
+ // Check if this pattern's capability matches the rule's trigger
899
+ const triggerMatch =
900
+ triggerWord.includes(rule.trigger.toLowerCase()) ||
901
+ capability.toLowerCase().includes(rule.trigger.toLowerCase()); // ← Handle capability-level triggers
902
+
903
+ if (triggerMatch) {
904
+ // Check if required legal keywords are present
905
+ return rule.requires.some(keyword =>
906
+ text.toLowerCase().includes(keyword.toLowerCase())
907
+ );
908
+ }
909
+ return false;
910
+ });
895
911
 
896
912
  if (allowed) {
897
913
  // ✅ AUDIT LOG: Contextual allowlist bypass