@vorionsys/atsf-core 0.2.3 → 0.3.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.
- package/CHANGELOG.md +1 -0
- package/LICENSE +1 -1
- package/README.md +82 -29
- package/dist/adapters/base-adapter.d.ts +94 -0
- package/dist/adapters/base-adapter.d.ts.map +1 -0
- package/dist/adapters/base-adapter.js +233 -0
- package/dist/adapters/base-adapter.js.map +1 -0
- package/dist/adapters/index.d.ts +9 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/index.js +5 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/adapters/types.d.ts +83 -0
- package/dist/adapters/types.d.ts.map +1 -0
- package/dist/adapters/types.js +4 -0
- package/dist/adapters/types.js.map +1 -0
- package/dist/adapters/webhook-handler.d.ts +64 -0
- package/dist/adapters/webhook-handler.d.ts.map +1 -0
- package/dist/adapters/webhook-handler.js +170 -0
- package/dist/adapters/webhook-handler.js.map +1 -0
- package/dist/api/index.d.ts +1 -1
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +3 -1
- package/dist/api/index.js.map +1 -1
- package/dist/api/server.d.ts +2 -2
- package/dist/api/server.d.ts.map +1 -1
- package/dist/api/server.js +149 -184
- package/dist/api/server.js.map +1 -1
- package/dist/arbitration/index.d.ts +4 -12
- package/dist/arbitration/index.d.ts.map +1 -1
- package/dist/arbitration/index.js +43 -46
- package/dist/arbitration/index.js.map +1 -1
- package/dist/arbitration/types.d.ts +10 -10
- package/dist/arbitration/types.d.ts.map +1 -1
- package/dist/arbitration/types.js +2 -8
- package/dist/arbitration/types.js.map +1 -1
- package/dist/basis/evaluator.d.ts +1 -6
- package/dist/basis/evaluator.d.ts.map +1 -1
- package/dist/basis/evaluator.js +56 -56
- package/dist/basis/evaluator.js.map +1 -1
- package/dist/basis/index.d.ts +3 -3
- package/dist/basis/index.d.ts.map +1 -1
- package/dist/basis/index.js +5 -3
- package/dist/basis/index.js.map +1 -1
- package/dist/basis/parser.d.ts +30 -30
- package/dist/basis/parser.d.ts.map +1 -1
- package/dist/basis/parser.js +27 -32
- package/dist/basis/parser.js.map +1 -1
- package/dist/basis/types.d.ts +2 -2
- package/dist/basis/types.d.ts.map +1 -1
- package/dist/basis/types.js +2 -3
- package/dist/basis/types.js.map +1 -1
- package/dist/chain/index.d.ts +0 -8
- package/dist/chain/index.d.ts.map +1 -1
- package/dist/chain/index.js +18 -16
- package/dist/chain/index.js.map +1 -1
- package/dist/cognigate/index.d.ts +1 -9
- package/dist/cognigate/index.d.ts.map +1 -1
- package/dist/cognigate/index.js +35 -44
- package/dist/cognigate/index.js.map +1 -1
- package/dist/common/adapters.d.ts +4 -4
- package/dist/common/adapters.d.ts.map +1 -1
- package/dist/common/adapters.js +54 -70
- package/dist/common/adapters.js.map +1 -1
- package/dist/common/config.d.ts +69 -68
- package/dist/common/config.d.ts.map +1 -1
- package/dist/common/config.js +52 -50
- package/dist/common/config.js.map +1 -1
- package/dist/common/index.d.ts +4 -4
- package/dist/common/index.d.ts.map +1 -1
- package/dist/common/index.js +6 -4
- package/dist/common/index.js.map +1 -1
- package/dist/common/logger.d.ts +1 -1
- package/dist/common/logger.d.ts.map +1 -1
- package/dist/common/logger.js +10 -8
- package/dist/common/logger.js.map +1 -1
- package/dist/common/types.d.ts +12 -12
- package/dist/common/types.d.ts.map +1 -1
- package/dist/common/types.js +7 -14
- package/dist/common/types.js.map +1 -1
- package/dist/containment/index.d.ts +3 -11
- package/dist/containment/index.d.ts.map +1 -1
- package/dist/containment/index.js +107 -119
- package/dist/containment/index.js.map +1 -1
- package/dist/containment/types.d.ts +11 -11
- package/dist/containment/types.d.ts.map +1 -1
- package/dist/containment/types.js +2 -8
- package/dist/containment/types.js.map +1 -1
- package/dist/contracts/index.d.ts +9 -17
- package/dist/contracts/index.d.ts.map +1 -1
- package/dist/contracts/index.js +56 -59
- package/dist/contracts/index.js.map +1 -1
- package/dist/contracts/types.d.ts +12 -12
- package/dist/contracts/types.d.ts.map +1 -1
- package/dist/contracts/types.js +2 -8
- package/dist/contracts/types.js.map +1 -1
- package/dist/crewai/callback.d.ts +2 -9
- package/dist/crewai/callback.d.ts.map +1 -1
- package/dist/crewai/callback.js +29 -27
- package/dist/crewai/callback.js.map +1 -1
- package/dist/crewai/executor.d.ts +95 -11
- package/dist/crewai/executor.d.ts.map +1 -1
- package/dist/crewai/executor.js +459 -16
- package/dist/crewai/executor.js.map +1 -1
- package/dist/crewai/index.d.ts +4 -4
- package/dist/crewai/index.d.ts.map +1 -1
- package/dist/crewai/index.js +6 -4
- package/dist/crewai/index.js.map +1 -1
- package/dist/crewai/tools.d.ts +1 -1
- package/dist/crewai/tools.d.ts.map +1 -1
- package/dist/crewai/tools.js +40 -46
- package/dist/crewai/tools.js.map +1 -1
- package/dist/crewai/types.d.ts +66 -3
- package/dist/crewai/types.d.ts.map +1 -1
- package/dist/crewai/types.js +2 -7
- package/dist/crewai/types.js.map +1 -1
- package/dist/enforce/index.d.ts +226 -19
- package/dist/enforce/index.d.ts.map +1 -1
- package/dist/enforce/index.js +55 -81
- package/dist/enforce/index.js.map +1 -1
- package/dist/enforce/trust-aware-enforcement-service.d.ts +8 -23
- package/dist/enforce/trust-aware-enforcement-service.d.ts.map +1 -1
- package/dist/enforce/trust-aware-enforcement-service.js +109 -125
- package/dist/enforce/trust-aware-enforcement-service.js.map +1 -1
- package/dist/governance/fluid-workflow.d.ts +8 -16
- package/dist/governance/fluid-workflow.d.ts.map +1 -1
- package/dist/governance/fluid-workflow.js +88 -114
- package/dist/governance/fluid-workflow.js.map +1 -1
- package/dist/governance/index.d.ts +7 -15
- package/dist/governance/index.d.ts.map +1 -1
- package/dist/governance/index.js +76 -81
- package/dist/governance/index.js.map +1 -1
- package/dist/governance/proof-bridge.d.ts +6 -6
- package/dist/governance/proof-bridge.d.ts.map +1 -1
- package/dist/governance/proof-bridge.js +6 -16
- package/dist/governance/proof-bridge.js.map +1 -1
- package/dist/governance/types.d.ts +9 -16
- package/dist/governance/types.d.ts.map +1 -1
- package/dist/governance/types.js +2 -8
- package/dist/governance/types.js.map +1 -1
- package/dist/index.d.ts +30 -29
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +33 -31
- package/dist/index.js.map +1 -1
- package/dist/intent/index.d.ts +55 -18
- package/dist/intent/index.d.ts.map +1 -1
- package/dist/intent/index.js +25 -26
- package/dist/intent/index.js.map +1 -1
- package/dist/intent/persistent-intent-service.d.ts +2 -17
- package/dist/intent/persistent-intent-service.d.ts.map +1 -1
- package/dist/intent/persistent-intent-service.js +33 -43
- package/dist/intent/persistent-intent-service.js.map +1 -1
- package/dist/intent/supabase-intent-repository.d.ts +107 -0
- package/dist/intent/supabase-intent-repository.d.ts.map +1 -0
- package/dist/intent/supabase-intent-repository.js +406 -0
- package/dist/intent/supabase-intent-repository.js.map +1 -0
- package/dist/intent-gateway/index.d.ts +5 -28
- package/dist/intent-gateway/index.d.ts.map +1 -1
- package/dist/intent-gateway/index.js +341 -508
- package/dist/intent-gateway/index.js.map +1 -1
- package/dist/langchain/callback.d.ts +2 -9
- package/dist/langchain/callback.d.ts.map +1 -1
- package/dist/langchain/callback.js +32 -30
- package/dist/langchain/callback.js.map +1 -1
- package/dist/langchain/executor.d.ts +4 -11
- package/dist/langchain/executor.d.ts.map +1 -1
- package/dist/langchain/executor.js +82 -82
- package/dist/langchain/executor.js.map +1 -1
- package/dist/langchain/index.d.ts +5 -5
- package/dist/langchain/index.d.ts.map +1 -1
- package/dist/langchain/index.js +7 -5
- package/dist/langchain/index.js.map +1 -1
- package/dist/langchain/tools.d.ts +1 -1
- package/dist/langchain/tools.d.ts.map +1 -1
- package/dist/langchain/tools.js +36 -43
- package/dist/langchain/tools.js.map +1 -1
- package/dist/langchain/types.d.ts +3 -3
- package/dist/langchain/types.d.ts.map +1 -1
- package/dist/langchain/types.js +2 -7
- package/dist/langchain/types.js.map +1 -1
- package/dist/layers/implementations/L0-request-format.d.ts +2 -2
- package/dist/layers/implementations/L0-request-format.d.ts.map +1 -1
- package/dist/layers/implementations/L0-request-format.js +54 -54
- package/dist/layers/implementations/L0-request-format.js.map +1 -1
- package/dist/layers/implementations/L1-input-size.d.ts +2 -2
- package/dist/layers/implementations/L1-input-size.d.ts.map +1 -1
- package/dist/layers/implementations/L1-input-size.js +41 -49
- package/dist/layers/implementations/L1-input-size.js.map +1 -1
- package/dist/layers/implementations/L2-charset-sanitizer.d.ts +2 -2
- package/dist/layers/implementations/L2-charset-sanitizer.d.ts.map +1 -1
- package/dist/layers/implementations/L2-charset-sanitizer.js +73 -81
- package/dist/layers/implementations/L2-charset-sanitizer.js.map +1 -1
- package/dist/layers/implementations/L3-schema-conformance.d.ts +3 -3
- package/dist/layers/implementations/L3-schema-conformance.d.ts.map +1 -1
- package/dist/layers/implementations/L3-schema-conformance.js +75 -82
- package/dist/layers/implementations/L3-schema-conformance.js.map +1 -1
- package/dist/layers/implementations/L4-injection-detector.d.ts +4 -4
- package/dist/layers/implementations/L4-injection-detector.d.ts.map +1 -1
- package/dist/layers/implementations/L4-injection-detector.js +83 -85
- package/dist/layers/implementations/L4-injection-detector.js.map +1 -1
- package/dist/layers/implementations/L5-rate-limiter.d.ts +2 -2
- package/dist/layers/implementations/L5-rate-limiter.d.ts.map +1 -1
- package/dist/layers/implementations/L5-rate-limiter.js +22 -20
- package/dist/layers/implementations/L5-rate-limiter.js.map +1 -1
- package/dist/layers/implementations/index.d.ts +6 -6
- package/dist/layers/implementations/index.d.ts.map +1 -1
- package/dist/layers/implementations/index.js +8 -6
- package/dist/layers/implementations/index.js.map +1 -1
- package/dist/layers/index.d.ts +3 -11
- package/dist/layers/index.d.ts.map +1 -1
- package/dist/layers/index.js +73 -99
- package/dist/layers/index.js.map +1 -1
- package/dist/layers/types.d.ts +16 -16
- package/dist/layers/types.d.ts.map +1 -1
- package/dist/layers/types.js +2 -8
- package/dist/layers/types.js.map +1 -1
- package/dist/paramesphere/activation-collector.d.ts +128 -0
- package/dist/paramesphere/activation-collector.d.ts.map +1 -0
- package/dist/paramesphere/activation-collector.js +260 -0
- package/dist/paramesphere/activation-collector.js.map +1 -0
- package/dist/paramesphere/cognitive-envelope.d.ts +73 -0
- package/dist/paramesphere/cognitive-envelope.d.ts.map +1 -0
- package/dist/paramesphere/cognitive-envelope.js +209 -0
- package/dist/paramesphere/cognitive-envelope.js.map +1 -0
- package/dist/paramesphere/envelope-integration.d.ts +60 -0
- package/dist/paramesphere/envelope-integration.d.ts.map +1 -0
- package/dist/paramesphere/envelope-integration.js +93 -0
- package/dist/paramesphere/envelope-integration.js.map +1 -0
- package/dist/paramesphere/fingerprint-monitor.d.ts +136 -0
- package/dist/paramesphere/fingerprint-monitor.d.ts.map +1 -0
- package/dist/paramesphere/fingerprint-monitor.js +212 -0
- package/dist/paramesphere/fingerprint-monitor.js.map +1 -0
- package/dist/paramesphere/fingerprint-store.d.ts +85 -0
- package/dist/paramesphere/fingerprint-store.d.ts.map +1 -0
- package/dist/paramesphere/fingerprint-store.js +68 -0
- package/dist/paramesphere/fingerprint-store.js.map +1 -0
- package/dist/paramesphere/index.d.ts +21 -0
- package/dist/paramesphere/index.d.ts.map +1 -0
- package/dist/paramesphere/index.js +18 -0
- package/dist/paramesphere/index.js.map +1 -0
- package/dist/paramesphere/monitor-integration.d.ts +37 -0
- package/dist/paramesphere/monitor-integration.d.ts.map +1 -0
- package/dist/paramesphere/monitor-integration.js +81 -0
- package/dist/paramesphere/monitor-integration.js.map +1 -0
- package/dist/paramesphere/paramesphere-engine.d.ts +111 -0
- package/dist/paramesphere/paramesphere-engine.d.ts.map +1 -0
- package/dist/paramesphere/paramesphere-engine.js +542 -0
- package/dist/paramesphere/paramesphere-engine.js.map +1 -0
- package/dist/paramesphere/types.d.ts +142 -0
- package/dist/paramesphere/types.d.ts.map +1 -0
- package/dist/paramesphere/types.js +4 -0
- package/dist/paramesphere/types.js.map +1 -0
- package/dist/persistence/file.d.ts +3 -10
- package/dist/persistence/file.d.ts.map +1 -1
- package/dist/persistence/file.js +30 -32
- package/dist/persistence/file.js.map +1 -1
- package/dist/persistence/index.d.ts +7 -7
- package/dist/persistence/index.d.ts.map +1 -1
- package/dist/persistence/index.js +20 -18
- package/dist/persistence/index.js.map +1 -1
- package/dist/persistence/memory.d.ts +3 -3
- package/dist/persistence/memory.d.ts.map +1 -1
- package/dist/persistence/memory.js +10 -17
- package/dist/persistence/memory.js.map +1 -1
- package/dist/persistence/sqlite.d.ts +3 -11
- package/dist/persistence/sqlite.d.ts.map +1 -1
- package/dist/persistence/sqlite.js +42 -39
- package/dist/persistence/sqlite.js.map +1 -1
- package/dist/persistence/supabase.d.ts +3 -3
- package/dist/persistence/supabase.d.ts.map +1 -1
- package/dist/persistence/supabase.js +46 -49
- package/dist/persistence/supabase.js.map +1 -1
- package/dist/persistence/types.d.ts +5 -5
- package/dist/persistence/types.d.ts.map +1 -1
- package/dist/persistence/types.js +2 -7
- package/dist/persistence/types.js.map +1 -1
- package/dist/phase6/ceiling.d.ts +5 -21
- package/dist/phase6/ceiling.d.ts.map +1 -1
- package/dist/phase6/ceiling.js +38 -69
- package/dist/phase6/ceiling.js.map +1 -1
- package/dist/phase6/context.d.ts +3 -20
- package/dist/phase6/context.d.ts.map +1 -1
- package/dist/phase6/context.js +49 -93
- package/dist/phase6/context.js.map +1 -1
- package/dist/phase6/index.d.ts +12 -12
- package/dist/phase6/index.d.ts.map +1 -1
- package/dist/phase6/index.js +17 -15
- package/dist/phase6/index.js.map +1 -1
- package/dist/phase6/presets.d.ts +2 -18
- package/dist/phase6/presets.d.ts.map +1 -1
- package/dist/phase6/presets.js +35 -39
- package/dist/phase6/presets.js.map +1 -1
- package/dist/phase6/provenance.d.ts +4 -19
- package/dist/phase6/provenance.d.ts.map +1 -1
- package/dist/phase6/provenance.js +37 -42
- package/dist/phase6/provenance.js.map +1 -1
- package/dist/phase6/role-gates/index.d.ts +2 -2
- package/dist/phase6/role-gates/index.d.ts.map +1 -1
- package/dist/phase6/role-gates/index.js +4 -2
- package/dist/phase6/role-gates/index.js.map +1 -1
- package/dist/phase6/role-gates/kernel.d.ts.map +1 -1
- package/dist/phase6/role-gates/kernel.js +18 -16
- package/dist/phase6/role-gates/kernel.js.map +1 -1
- package/dist/phase6/role-gates/policy.d.ts +2 -2
- package/dist/phase6/role-gates/policy.d.ts.map +1 -1
- package/dist/phase6/role-gates/policy.js +8 -17
- package/dist/phase6/role-gates/policy.js.map +1 -1
- package/dist/phase6/role-gates.d.ts +4 -20
- package/dist/phase6/role-gates.d.ts.map +1 -1
- package/dist/phase6/role-gates.js +60 -80
- package/dist/phase6/role-gates.js.map +1 -1
- package/dist/phase6/types.d.ts +53 -23
- package/dist/phase6/types.d.ts.map +1 -1
- package/dist/phase6/types.js +131 -177
- package/dist/phase6/types.js.map +1 -1
- package/dist/phase6/weight-presets/canonical.d.ts.map +1 -1
- package/dist/phase6/weight-presets/canonical.js +12 -10
- package/dist/phase6/weight-presets/canonical.js.map +1 -1
- package/dist/phase6/weight-presets/deltas.d.ts +2 -2
- package/dist/phase6/weight-presets/deltas.d.ts.map +1 -1
- package/dist/phase6/weight-presets/deltas.js +29 -37
- package/dist/phase6/weight-presets/deltas.js.map +1 -1
- package/dist/phase6/weight-presets/index.d.ts +3 -3
- package/dist/phase6/weight-presets/index.d.ts.map +1 -1
- package/dist/phase6/weight-presets/index.js +5 -3
- package/dist/phase6/weight-presets/index.js.map +1 -1
- package/dist/phase6/weight-presets/merger.d.ts +2 -12
- package/dist/phase6/weight-presets/merger.d.ts.map +1 -1
- package/dist/phase6/weight-presets/merger.js +45 -39
- package/dist/phase6/weight-presets/merger.js.map +1 -1
- package/dist/proof/index.d.ts +6 -13
- package/dist/proof/index.d.ts.map +1 -1
- package/dist/proof/index.js +63 -51
- package/dist/proof/index.js.map +1 -1
- package/dist/proof/merkle.d.ts +24 -19
- package/dist/proof/merkle.d.ts.map +1 -1
- package/dist/proof/merkle.js +118 -32
- package/dist/proof/merkle.js.map +1 -1
- package/dist/proof/zk-proofs.d.ts +6 -24
- package/dist/proof/zk-proofs.d.ts.map +1 -1
- package/dist/proof/zk-proofs.js +45 -42
- package/dist/proof/zk-proofs.js.map +1 -1
- package/dist/provenance/index.d.ts +3 -11
- package/dist/provenance/index.d.ts.map +1 -1
- package/dist/provenance/index.js +19 -19
- package/dist/provenance/index.js.map +1 -1
- package/dist/provenance/types.d.ts +4 -4
- package/dist/provenance/types.d.ts.map +1 -1
- package/dist/provenance/types.js +2 -8
- package/dist/provenance/types.js.map +1 -1
- package/dist/sandbox-training/challenges.d.ts +1 -1
- package/dist/sandbox-training/challenges.d.ts.map +1 -1
- package/dist/sandbox-training/challenges.js +230 -236
- package/dist/sandbox-training/challenges.js.map +1 -1
- package/dist/sandbox-training/graduation.d.ts +1 -1
- package/dist/sandbox-training/graduation.d.ts.map +1 -1
- package/dist/sandbox-training/graduation.js +17 -22
- package/dist/sandbox-training/graduation.js.map +1 -1
- package/dist/sandbox-training/index.d.ts +9 -9
- package/dist/sandbox-training/index.d.ts.map +1 -1
- package/dist/sandbox-training/index.js +8 -6
- package/dist/sandbox-training/index.js.map +1 -1
- package/dist/sandbox-training/promotion-service.d.ts +4 -4
- package/dist/sandbox-training/promotion-service.d.ts.map +1 -1
- package/dist/sandbox-training/promotion-service.js +7 -16
- package/dist/sandbox-training/promotion-service.js.map +1 -1
- package/dist/sandbox-training/runner.d.ts +1 -1
- package/dist/sandbox-training/runner.d.ts.map +1 -1
- package/dist/sandbox-training/runner.js +75 -82
- package/dist/sandbox-training/runner.js.map +1 -1
- package/dist/sandbox-training/scorer.d.ts +4 -4
- package/dist/sandbox-training/scorer.d.ts.map +1 -1
- package/dist/sandbox-training/scorer.js +7 -13
- package/dist/sandbox-training/scorer.js.map +1 -1
- package/dist/sandbox-training/types.d.ts +4 -4
- package/dist/sandbox-training/types.d.ts.map +1 -1
- package/dist/sandbox-training/types.js +9 -19
- package/dist/sandbox-training/types.js.map +1 -1
- package/dist/trust-engine/ceiling-enforcement/audit.d.ts +1 -9
- package/dist/trust-engine/ceiling-enforcement/audit.d.ts.map +1 -1
- package/dist/trust-engine/ceiling-enforcement/audit.js +6 -11
- package/dist/trust-engine/ceiling-enforcement/audit.js.map +1 -1
- package/dist/trust-engine/ceiling-enforcement/index.d.ts +2 -2
- package/dist/trust-engine/ceiling-enforcement/index.d.ts.map +1 -1
- package/dist/trust-engine/ceiling-enforcement/index.js +4 -2
- package/dist/trust-engine/ceiling-enforcement/index.js.map +1 -1
- package/dist/trust-engine/ceiling-enforcement/kernel.d.ts +12 -10
- package/dist/trust-engine/ceiling-enforcement/kernel.d.ts.map +1 -1
- package/dist/trust-engine/ceiling-enforcement/kernel.js +28 -20
- package/dist/trust-engine/ceiling-enforcement/kernel.js.map +1 -1
- package/dist/trust-engine/context-policy/enforcement.d.ts +0 -9
- package/dist/trust-engine/context-policy/enforcement.d.ts.map +1 -1
- package/dist/trust-engine/context-policy/enforcement.js +2 -9
- package/dist/trust-engine/context-policy/enforcement.js.map +1 -1
- package/dist/trust-engine/context-policy/factory.d.ts +1 -1
- package/dist/trust-engine/context-policy/factory.d.ts.map +1 -1
- package/dist/trust-engine/context-policy/factory.js +3 -1
- package/dist/trust-engine/context-policy/factory.js.map +1 -1
- package/dist/trust-engine/context-policy/index.d.ts +2 -2
- package/dist/trust-engine/context-policy/index.d.ts.map +1 -1
- package/dist/trust-engine/context-policy/index.js +4 -2
- package/dist/trust-engine/context-policy/index.js.map +1 -1
- package/dist/trust-engine/creation-modifiers/index.d.ts +1 -1
- package/dist/trust-engine/creation-modifiers/index.d.ts.map +1 -1
- package/dist/trust-engine/creation-modifiers/index.js +3 -1
- package/dist/trust-engine/creation-modifiers/index.js.map +1 -1
- package/dist/trust-engine/creation-modifiers/types.d.ts.map +1 -1
- package/dist/trust-engine/creation-modifiers/types.js +5 -2
- package/dist/trust-engine/creation-modifiers/types.js.map +1 -1
- package/dist/trust-engine/decay-profiles.d.ts +37 -136
- package/dist/trust-engine/decay-profiles.d.ts.map +1 -1
- package/dist/trust-engine/decay-profiles.js +61 -183
- package/dist/trust-engine/decay-profiles.js.map +1 -1
- package/dist/trust-engine/index.d.ts +327 -22
- package/dist/trust-engine/index.d.ts.map +1 -1
- package/dist/trust-engine/index.js +706 -130
- package/dist/trust-engine/index.js.map +1 -1
- package/dist/trust-engine/phase6-types.d.ts +15 -18
- package/dist/trust-engine/phase6-types.d.ts.map +1 -1
- package/dist/trust-engine/phase6-types.js +32 -36
- package/dist/trust-engine/phase6-types.js.map +1 -1
- package/dist/trust-engine/trust-verifier.d.ts +121 -0
- package/dist/trust-engine/trust-verifier.d.ts.map +1 -0
- package/dist/trust-engine/trust-verifier.js +226 -0
- package/dist/trust-engine/trust-verifier.js.map +1 -0
- package/package.json +140 -135
- package/dist/enforce/types.d.ts +0 -234
- package/dist/enforce/types.d.ts.map +0 -1
- package/dist/enforce/types.js +0 -10
- package/dist/enforce/types.js.map +0 -1
- package/dist/intent/types.d.ts +0 -69
- package/dist/intent/types.d.ts.map +0 -1
- package/dist/intent/types.js +0 -10
- package/dist/intent/types.js.map +0 -1
- package/dist/trust-engine/types.d.ts +0 -77
- package/dist/trust-engine/types.d.ts.map +0 -1
- package/dist/trust-engine/types.js +0 -20
- package/dist/trust-engine/types.js.map +0 -1
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// Copyright 2024-2026 Vorion LLC
|
|
1
3
|
/**
|
|
2
4
|
* INTENT GATEWAY - Jurisdictional Router & Governance Topology Selector
|
|
3
5
|
*
|
|
@@ -21,89 +23,61 @@
|
|
|
21
23
|
*
|
|
22
24
|
* @packageDocumentation
|
|
23
25
|
*/
|
|
24
|
-
import { createLogger } from
|
|
26
|
+
import { createLogger } from '../common/logger.js';
|
|
25
27
|
// ---------------------------------------------------------------------------
|
|
26
28
|
// Logger
|
|
27
29
|
// ---------------------------------------------------------------------------
|
|
28
|
-
const logger = createLogger({ component:
|
|
30
|
+
const logger = createLogger({ component: 'intent-gateway' });
|
|
29
31
|
// ---------------------------------------------------------------------------
|
|
30
32
|
// Constants & Union Types
|
|
31
33
|
// ---------------------------------------------------------------------------
|
|
32
34
|
/** Supported jurisdictional scopes. */
|
|
33
35
|
export const JURISDICTIONS = [
|
|
34
|
-
|
|
35
|
-
"EU",
|
|
36
|
-
"US",
|
|
37
|
-
"APAC",
|
|
38
|
-
"UK",
|
|
39
|
-
"CA",
|
|
40
|
-
"AU",
|
|
41
|
-
"JP",
|
|
42
|
-
"SG",
|
|
43
|
-
"CH",
|
|
36
|
+
'GLOBAL', 'EU', 'US', 'APAC', 'UK', 'CA', 'AU', 'JP', 'SG', 'CH',
|
|
44
37
|
];
|
|
45
38
|
/** Industry verticals that affect policy selection. */
|
|
46
39
|
export const INDUSTRIES = [
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
"finance",
|
|
50
|
-
"defense",
|
|
51
|
-
"government",
|
|
52
|
-
"education",
|
|
53
|
-
"energy",
|
|
40
|
+
'general', 'healthcare', 'finance', 'defense', 'government',
|
|
41
|
+
'education', 'energy',
|
|
54
42
|
];
|
|
55
43
|
/** Cryptographic suite requirements, ordered by strictness. */
|
|
56
44
|
export const CRYPTO_SUITES = [
|
|
57
|
-
|
|
58
|
-
"fips-140-2",
|
|
59
|
-
"post-quantum",
|
|
45
|
+
'standard', 'fips-140-2', 'post-quantum',
|
|
60
46
|
];
|
|
61
47
|
/** Proof anchoring methods, ordered by assurance level. */
|
|
62
48
|
export const PROOF_ANCHORING_METHODS = [
|
|
63
|
-
|
|
64
|
-
"merkle-tree",
|
|
65
|
-
"blockchain-l2",
|
|
66
|
-
"tsa-rfc3161",
|
|
49
|
+
'database', 'merkle-tree', 'blockchain-l2', 'tsa-rfc3161',
|
|
67
50
|
];
|
|
68
51
|
/** Consent models, ordered by strictness. */
|
|
69
52
|
export const CONSENT_MODELS = [
|
|
70
|
-
|
|
71
|
-
"opt-out",
|
|
72
|
-
"opt-in",
|
|
73
|
-
"explicit-granular",
|
|
53
|
+
'implicit', 'opt-out', 'opt-in', 'explicit-granular',
|
|
74
54
|
];
|
|
75
55
|
/** Escalation modes, ordered by severity. */
|
|
76
56
|
export const ESCALATION_MODES = [
|
|
77
|
-
|
|
78
|
-
"flag-review",
|
|
79
|
-
"block-escalate",
|
|
80
|
-
"hard-block",
|
|
57
|
+
'log-only', 'flag-review', 'block-escalate', 'hard-block',
|
|
81
58
|
];
|
|
82
59
|
/** EU AI Act risk classification tiers. */
|
|
83
60
|
export const AI_ACT_CLASSIFICATIONS = [
|
|
84
|
-
|
|
85
|
-
"high-risk",
|
|
86
|
-
"limited-risk",
|
|
87
|
-
"minimal-risk",
|
|
61
|
+
'unacceptable', 'high-risk', 'limited-risk', 'minimal-risk',
|
|
88
62
|
];
|
|
89
63
|
/** High-risk categories under Annex III of the EU AI Act. */
|
|
90
64
|
export const AI_ACT_HIGH_RISK_CATEGORIES = [
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
65
|
+
'biometric-identification',
|
|
66
|
+
'critical-infrastructure',
|
|
67
|
+
'education-vocational',
|
|
68
|
+
'employment-worker-management',
|
|
69
|
+
'essential-services',
|
|
70
|
+
'law-enforcement',
|
|
71
|
+
'migration-asylum-border',
|
|
72
|
+
'justice-democratic',
|
|
99
73
|
];
|
|
100
74
|
// ---------------------------------------------------------------------------
|
|
101
75
|
// Default Configuration
|
|
102
76
|
// ---------------------------------------------------------------------------
|
|
103
77
|
export const DEFAULT_GATEWAY_CONFIG = {
|
|
104
78
|
enabled: true,
|
|
105
|
-
defaultJurisdiction:
|
|
106
|
-
defaultIndustry:
|
|
79
|
+
defaultJurisdiction: 'GLOBAL',
|
|
80
|
+
defaultIndustry: 'general',
|
|
107
81
|
regimeCacheTtlMs: 5 * 60 * 1000, // 5 minutes
|
|
108
82
|
blockOnConflicts: true,
|
|
109
83
|
logRegimeDecisions: true,
|
|
@@ -115,75 +89,36 @@ export const DEFAULT_GATEWAY_CONFIG = {
|
|
|
115
89
|
* Data residency zones mapped to each jurisdiction.
|
|
116
90
|
*/
|
|
117
91
|
export const JURISDICTION_RESIDENCY_ZONES = {
|
|
118
|
-
GLOBAL:
|
|
119
|
-
EU:
|
|
120
|
-
US:
|
|
121
|
-
APAC:
|
|
122
|
-
UK:
|
|
123
|
-
CA:
|
|
124
|
-
AU:
|
|
125
|
-
JP:
|
|
126
|
-
SG:
|
|
127
|
-
CH:
|
|
92
|
+
GLOBAL: 'global',
|
|
93
|
+
EU: 'eu-west',
|
|
94
|
+
US: 'us-east',
|
|
95
|
+
APAC: 'ap-southeast-1',
|
|
96
|
+
UK: 'uk-south',
|
|
97
|
+
CA: 'ca-central',
|
|
98
|
+
AU: 'au-southeast',
|
|
99
|
+
JP: 'ap-northeast-1',
|
|
100
|
+
SG: 'ap-southeast-1',
|
|
101
|
+
CH: 'eu-central',
|
|
128
102
|
};
|
|
129
103
|
/** EU/EEA member state ISO 3166-1 alpha-2 codes. */
|
|
130
104
|
const EU_MEMBER_STATE_CODES = new Set([
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
"HR",
|
|
135
|
-
"CY",
|
|
136
|
-
"CZ",
|
|
137
|
-
"DK",
|
|
138
|
-
"EE",
|
|
139
|
-
"FI",
|
|
140
|
-
"FR",
|
|
141
|
-
"DE",
|
|
142
|
-
"GR",
|
|
143
|
-
"HU",
|
|
144
|
-
"IE",
|
|
145
|
-
"IT",
|
|
146
|
-
"LV",
|
|
147
|
-
"LT",
|
|
148
|
-
"LU",
|
|
149
|
-
"MT",
|
|
150
|
-
"NL",
|
|
151
|
-
"PL",
|
|
152
|
-
"PT",
|
|
153
|
-
"RO",
|
|
154
|
-
"SK",
|
|
155
|
-
"SI",
|
|
156
|
-
"ES",
|
|
157
|
-
"SE",
|
|
158
|
-
"IS",
|
|
159
|
-
"LI",
|
|
160
|
-
"NO",
|
|
105
|
+
'AT', 'BE', 'BG', 'HR', 'CY', 'CZ', 'DK', 'EE', 'FI', 'FR',
|
|
106
|
+
'DE', 'GR', 'HU', 'IE', 'IT', 'LV', 'LT', 'LU', 'MT', 'NL',
|
|
107
|
+
'PL', 'PT', 'RO', 'SK', 'SI', 'ES', 'SE', 'IS', 'LI', 'NO',
|
|
161
108
|
]);
|
|
162
109
|
/** APAC country codes for regional mapping. */
|
|
163
110
|
const APAC_COUNTRY_CODES = new Set([
|
|
164
|
-
|
|
165
|
-
"KR",
|
|
166
|
-
"SG",
|
|
167
|
-
"AU",
|
|
168
|
-
"NZ",
|
|
169
|
-
"IN",
|
|
170
|
-
"TH",
|
|
171
|
-
"MY",
|
|
172
|
-
"ID",
|
|
173
|
-
"PH",
|
|
174
|
-
"VN",
|
|
175
|
-
"TW",
|
|
176
|
-
"HK",
|
|
111
|
+
'JP', 'KR', 'SG', 'AU', 'NZ', 'IN', 'TH', 'MY', 'ID', 'PH', 'VN', 'TW', 'HK',
|
|
177
112
|
]);
|
|
178
113
|
/** Direct country-to-jurisdiction mapping for countries with specific regimes. */
|
|
179
114
|
const COUNTRY_JURISDICTION_MAP = {
|
|
180
|
-
US:
|
|
181
|
-
GB:
|
|
182
|
-
CA:
|
|
183
|
-
AU:
|
|
184
|
-
JP:
|
|
185
|
-
SG:
|
|
186
|
-
CH:
|
|
115
|
+
US: 'US',
|
|
116
|
+
GB: 'UK',
|
|
117
|
+
CA: 'CA',
|
|
118
|
+
AU: 'AU',
|
|
119
|
+
JP: 'JP',
|
|
120
|
+
SG: 'SG',
|
|
121
|
+
CH: 'CH',
|
|
187
122
|
};
|
|
188
123
|
/**
|
|
189
124
|
* Resolves jurisdictional context from tenant configuration, intent metadata,
|
|
@@ -207,17 +142,17 @@ export class JurisdictionResolver {
|
|
|
207
142
|
// Tier 1: Explicit tenant configuration
|
|
208
143
|
const tenantResult = this.resolveFromTenantConfig(tenantId);
|
|
209
144
|
if (tenantResult) {
|
|
210
|
-
logger.debug({ tenantId, source:
|
|
145
|
+
logger.debug({ tenantId, source: 'tenant-config' }, 'Jurisdiction from tenant config');
|
|
211
146
|
return tenantResult;
|
|
212
147
|
}
|
|
213
148
|
// Tier 2: Infer from intent metadata
|
|
214
149
|
const metadataResult = this.resolveFromMetadata(intentMetadata);
|
|
215
150
|
if (metadataResult) {
|
|
216
|
-
logger.debug({ tenantId, source:
|
|
151
|
+
logger.debug({ tenantId, source: 'metadata' }, 'Jurisdiction from metadata');
|
|
217
152
|
return metadataResult;
|
|
218
153
|
}
|
|
219
154
|
// Tier 3: Gateway defaults
|
|
220
|
-
logger.debug({ tenantId, source:
|
|
155
|
+
logger.debug({ tenantId, source: 'default' }, 'Jurisdiction from defaults');
|
|
221
156
|
return this.resolveDefault();
|
|
222
157
|
}
|
|
223
158
|
/**
|
|
@@ -225,7 +160,7 @@ export class JurisdictionResolver {
|
|
|
225
160
|
*/
|
|
226
161
|
registerTenantConfig(tenantId, config) {
|
|
227
162
|
this.tenantConfigs.set(tenantId, config);
|
|
228
|
-
logger.info({ tenantId, jurisdictions: config.jurisdictions },
|
|
163
|
+
logger.info({ tenantId, jurisdictions: config.jurisdictions }, 'Tenant config registered');
|
|
229
164
|
}
|
|
230
165
|
/**
|
|
231
166
|
* Retrieve a tenant's jurisdiction configuration.
|
|
@@ -240,7 +175,7 @@ export class JurisdictionResolver {
|
|
|
240
175
|
detectCrossBorderTransfer(jurisdictions) {
|
|
241
176
|
if (jurisdictions.length <= 1)
|
|
242
177
|
return false;
|
|
243
|
-
const zones = new Set(jurisdictions.map(
|
|
178
|
+
const zones = new Set(jurisdictions.map(j => JURISDICTION_RESIDENCY_ZONES[j]));
|
|
244
179
|
return zones.size > 1;
|
|
245
180
|
}
|
|
246
181
|
resolveFromTenantConfig(tenantId) {
|
|
@@ -252,9 +187,9 @@ export class JurisdictionResolver {
|
|
|
252
187
|
industry: config.industry,
|
|
253
188
|
dataResidency: config.dataResidency ??
|
|
254
189
|
JURISDICTION_RESIDENCY_ZONES[config.jurisdictions[0]] ??
|
|
255
|
-
|
|
190
|
+
'global',
|
|
256
191
|
crossBorderTransfer: this.detectCrossBorderTransfer(config.jurisdictions),
|
|
257
|
-
source:
|
|
192
|
+
source: 'tenant-config',
|
|
258
193
|
};
|
|
259
194
|
}
|
|
260
195
|
resolveFromMetadata(metadata) {
|
|
@@ -263,31 +198,27 @@ export class JurisdictionResolver {
|
|
|
263
198
|
const jurisdictions = this.extractJurisdictionsFromMetadata(metadata);
|
|
264
199
|
if (jurisdictions.length === 0)
|
|
265
200
|
return null;
|
|
266
|
-
const industry = typeof metadata.industry ===
|
|
267
|
-
this.isValidIndustry(metadata.industry)
|
|
201
|
+
const industry = typeof metadata.industry === 'string' && this.isValidIndustry(metadata.industry)
|
|
268
202
|
? metadata.industry
|
|
269
203
|
: this.config.defaultIndustry;
|
|
270
|
-
const dataResidency = (typeof metadata.dataResidency ===
|
|
271
|
-
? metadata.dataResidency
|
|
272
|
-
: undefined) ??
|
|
204
|
+
const dataResidency = (typeof metadata.dataResidency === 'string' ? metadata.dataResidency : undefined) ??
|
|
273
205
|
JURISDICTION_RESIDENCY_ZONES[jurisdictions[0]] ??
|
|
274
|
-
|
|
206
|
+
'global';
|
|
275
207
|
return {
|
|
276
208
|
primaryJurisdictions: jurisdictions,
|
|
277
209
|
industry,
|
|
278
210
|
dataResidency,
|
|
279
211
|
crossBorderTransfer: this.detectCrossBorderTransfer(jurisdictions),
|
|
280
|
-
source:
|
|
212
|
+
source: 'metadata-inference',
|
|
281
213
|
};
|
|
282
214
|
}
|
|
283
215
|
resolveDefault() {
|
|
284
216
|
return {
|
|
285
217
|
primaryJurisdictions: [this.config.defaultJurisdiction],
|
|
286
218
|
industry: this.config.defaultIndustry,
|
|
287
|
-
dataResidency: JURISDICTION_RESIDENCY_ZONES[this.config.defaultJurisdiction] ??
|
|
288
|
-
"global",
|
|
219
|
+
dataResidency: JURISDICTION_RESIDENCY_ZONES[this.config.defaultJurisdiction] ?? 'global',
|
|
289
220
|
crossBorderTransfer: false,
|
|
290
|
-
source:
|
|
221
|
+
source: 'default',
|
|
291
222
|
};
|
|
292
223
|
}
|
|
293
224
|
/**
|
|
@@ -298,7 +229,7 @@ export class JurisdictionResolver {
|
|
|
298
229
|
extractJurisdictionsFromMetadata(metadata) {
|
|
299
230
|
const jurisdictions = [];
|
|
300
231
|
// Direct jurisdiction field
|
|
301
|
-
if (typeof metadata.jurisdiction ===
|
|
232
|
+
if (typeof metadata.jurisdiction === 'string') {
|
|
302
233
|
const j = metadata.jurisdiction.toUpperCase();
|
|
303
234
|
if (this.isValidJurisdiction(j))
|
|
304
235
|
jurisdictions.push(j);
|
|
@@ -306,7 +237,7 @@ export class JurisdictionResolver {
|
|
|
306
237
|
// Jurisdictions array
|
|
307
238
|
if (Array.isArray(metadata.jurisdictions)) {
|
|
308
239
|
for (const item of metadata.jurisdictions) {
|
|
309
|
-
if (typeof item ===
|
|
240
|
+
if (typeof item === 'string') {
|
|
310
241
|
const j = item.toUpperCase();
|
|
311
242
|
if (this.isValidJurisdiction(j) && !jurisdictions.includes(j)) {
|
|
312
243
|
jurisdictions.push(j);
|
|
@@ -315,11 +246,11 @@ export class JurisdictionResolver {
|
|
|
315
246
|
}
|
|
316
247
|
}
|
|
317
248
|
// Country code inference
|
|
318
|
-
if (typeof metadata.countryCode ===
|
|
249
|
+
if (typeof metadata.countryCode === 'string') {
|
|
319
250
|
const code = metadata.countryCode.toUpperCase();
|
|
320
251
|
if (EU_MEMBER_STATE_CODES.has(code)) {
|
|
321
|
-
if (!jurisdictions.includes(
|
|
322
|
-
jurisdictions.push(
|
|
252
|
+
if (!jurisdictions.includes('EU'))
|
|
253
|
+
jurisdictions.push('EU');
|
|
323
254
|
}
|
|
324
255
|
else if (COUNTRY_JURISDICTION_MAP[code]) {
|
|
325
256
|
const j = COUNTRY_JURISDICTION_MAP[code];
|
|
@@ -327,24 +258,24 @@ export class JurisdictionResolver {
|
|
|
327
258
|
jurisdictions.push(j);
|
|
328
259
|
}
|
|
329
260
|
else if (APAC_COUNTRY_CODES.has(code)) {
|
|
330
|
-
if (!jurisdictions.includes(
|
|
331
|
-
jurisdictions.push(
|
|
261
|
+
if (!jurisdictions.includes('APAC'))
|
|
262
|
+
jurisdictions.push('APAC');
|
|
332
263
|
}
|
|
333
264
|
}
|
|
334
265
|
// Region string inference
|
|
335
|
-
if (typeof metadata.region ===
|
|
266
|
+
if (typeof metadata.region === 'string') {
|
|
336
267
|
const region = metadata.region.toUpperCase();
|
|
337
|
-
if ([
|
|
338
|
-
if (!jurisdictions.includes(
|
|
339
|
-
jurisdictions.push(
|
|
268
|
+
if (['EU', 'EUROPE', 'EEA'].includes(region)) {
|
|
269
|
+
if (!jurisdictions.includes('EU'))
|
|
270
|
+
jurisdictions.push('EU');
|
|
340
271
|
}
|
|
341
|
-
else if ([
|
|
342
|
-
if (!jurisdictions.includes(
|
|
343
|
-
jurisdictions.push(
|
|
272
|
+
else if (['US', 'UNITED STATES', 'NORTH AMERICA'].includes(region)) {
|
|
273
|
+
if (!jurisdictions.includes('US'))
|
|
274
|
+
jurisdictions.push('US');
|
|
344
275
|
}
|
|
345
|
-
else if ([
|
|
346
|
-
if (!jurisdictions.includes(
|
|
347
|
-
jurisdictions.push(
|
|
276
|
+
else if (['APAC', 'ASIA', 'ASIA-PACIFIC'].includes(region)) {
|
|
277
|
+
if (!jurisdictions.includes('APAC'))
|
|
278
|
+
jurisdictions.push('APAC');
|
|
348
279
|
}
|
|
349
280
|
}
|
|
350
281
|
return jurisdictions;
|
|
@@ -365,47 +296,39 @@ export class JurisdictionResolver {
|
|
|
365
296
|
* the strictest value wins.
|
|
366
297
|
*/
|
|
367
298
|
const CRYPTO_SUITE_STRICTNESS = {
|
|
368
|
-
standard: 0,
|
|
369
|
-
|
|
370
|
-
|
|
299
|
+
'standard': 0,
|
|
300
|
+
'fips-140-2': 1,
|
|
301
|
+
'post-quantum': 2,
|
|
371
302
|
};
|
|
372
303
|
const CONSENT_STRICTNESS = {
|
|
373
|
-
implicit: 0,
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
304
|
+
'implicit': 0,
|
|
305
|
+
'opt-out': 1,
|
|
306
|
+
'opt-in': 2,
|
|
307
|
+
'explicit-granular': 3,
|
|
377
308
|
};
|
|
378
309
|
const ESCALATION_STRICTNESS = {
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
310
|
+
'log-only': 0,
|
|
311
|
+
'flag-review': 1,
|
|
312
|
+
'block-escalate': 2,
|
|
313
|
+
'hard-block': 3,
|
|
383
314
|
};
|
|
384
315
|
const PROOF_ANCHORING_STRICTNESS = {
|
|
385
|
-
database: 0,
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
316
|
+
'database': 0,
|
|
317
|
+
'merkle-tree': 1,
|
|
318
|
+
'blockchain-l2': 2,
|
|
319
|
+
'tsa-rfc3161': 3,
|
|
389
320
|
};
|
|
390
321
|
const ENFORCEMENT_ORDER = {
|
|
391
|
-
advisory: 0,
|
|
392
|
-
required: 1,
|
|
393
|
-
mandatory: 2,
|
|
394
|
-
blocking: 3,
|
|
322
|
+
'advisory': 0,
|
|
323
|
+
'required': 1,
|
|
324
|
+
'mandatory': 2,
|
|
325
|
+
'blocking': 3,
|
|
395
326
|
};
|
|
396
327
|
/**
|
|
397
328
|
* Helper to create a PolicyConstraint with less boilerplate.
|
|
398
329
|
*/
|
|
399
330
|
function constraint(id, type, rule, enforcement, bundleId, jurisdiction, value) {
|
|
400
|
-
return {
|
|
401
|
-
id,
|
|
402
|
-
type,
|
|
403
|
-
rule,
|
|
404
|
-
enforcement,
|
|
405
|
-
sourceBundleId: bundleId,
|
|
406
|
-
sourceJurisdiction: jurisdiction,
|
|
407
|
-
value,
|
|
408
|
-
};
|
|
331
|
+
return { id, type, rule, enforcement, sourceBundleId: bundleId, sourceJurisdiction: jurisdiction, value };
|
|
409
332
|
}
|
|
410
333
|
/**
|
|
411
334
|
* Built-in policy bundles covering the major jurisdictional scopes.
|
|
@@ -415,98 +338,98 @@ function createBuiltinBundles() {
|
|
|
415
338
|
return [
|
|
416
339
|
// -- GLOBAL DEFAULT --
|
|
417
340
|
{
|
|
418
|
-
id:
|
|
419
|
-
name:
|
|
420
|
-
jurisdictions: [
|
|
341
|
+
id: 'global-default',
|
|
342
|
+
name: 'Global Default',
|
|
343
|
+
jurisdictions: ['GLOBAL'],
|
|
421
344
|
priority: 0,
|
|
422
345
|
constraints: [
|
|
423
|
-
constraint(
|
|
424
|
-
constraint(
|
|
425
|
-
constraint(
|
|
426
|
-
constraint(
|
|
427
|
-
constraint(
|
|
428
|
-
constraint(
|
|
429
|
-
constraint(
|
|
346
|
+
constraint('global-retention', 'retention', 'Min 365-day audit retention', 'required', 'global-default', 'GLOBAL', 365),
|
|
347
|
+
constraint('global-crypto', 'crypto', 'Standard cryptographic suite', 'required', 'global-default', 'GLOBAL', 'standard'),
|
|
348
|
+
constraint('global-consent', 'consent', 'Implicit consent model', 'required', 'global-default', 'GLOBAL', 'implicit'),
|
|
349
|
+
constraint('global-escalation', 'escalation', 'Flag for human review', 'required', 'global-default', 'GLOBAL', 'flag-review'),
|
|
350
|
+
constraint('global-trust', 'trust-level', 'Minimum trust T2 (Provisional)', 'required', 'global-default', 'GLOBAL', 2),
|
|
351
|
+
constraint('global-proof', 'proof-anchoring', 'Database proof anchoring', 'required', 'global-default', 'GLOBAL', 'database'),
|
|
352
|
+
constraint('global-external', 'external-services', 'External services allowed', 'advisory', 'global-default', 'GLOBAL', true),
|
|
430
353
|
],
|
|
431
354
|
},
|
|
432
355
|
// -- EU (GDPR + AI Act) --
|
|
433
356
|
{
|
|
434
|
-
id:
|
|
435
|
-
name:
|
|
436
|
-
jurisdictions: [
|
|
357
|
+
id: 'eu-gdpr',
|
|
358
|
+
name: 'EU GDPR',
|
|
359
|
+
jurisdictions: ['EU'],
|
|
437
360
|
priority: 10,
|
|
438
361
|
constraints: [
|
|
439
|
-
constraint(
|
|
440
|
-
constraint(
|
|
441
|
-
constraint(
|
|
442
|
-
constraint(
|
|
443
|
-
constraint(
|
|
444
|
-
constraint(
|
|
445
|
-
constraint(
|
|
362
|
+
constraint('eu-retention', 'retention', 'GDPR: 5-year audit retention', 'mandatory', 'eu-gdpr', 'EU', 1825),
|
|
363
|
+
constraint('eu-consent', 'consent', 'GDPR: Explicit granular consent', 'mandatory', 'eu-gdpr', 'EU', 'explicit-granular'),
|
|
364
|
+
constraint('eu-residency', 'data-residency', 'GDPR: EU data residency', 'mandatory', 'eu-gdpr', 'EU', 'eu-west'),
|
|
365
|
+
constraint('eu-proof', 'proof-anchoring', 'GDPR: Merkle tree proof anchoring', 'required', 'eu-gdpr', 'EU', 'merkle-tree'),
|
|
366
|
+
constraint('eu-trust', 'trust-level', 'GDPR: Minimum trust T3 (Monitored)', 'required', 'eu-gdpr', 'EU', 3),
|
|
367
|
+
constraint('eu-processing', 'processing-restriction', 'GDPR: Purpose limitation', 'mandatory', 'eu-gdpr', 'EU', 'purpose-limitation'),
|
|
368
|
+
constraint('eu-audit', 'audit-requirement', 'GDPR: Full audit trail', 'mandatory', 'eu-gdpr', 'EU', 'full-audit-trail'),
|
|
446
369
|
],
|
|
447
370
|
},
|
|
448
371
|
{
|
|
449
|
-
id:
|
|
450
|
-
name:
|
|
451
|
-
jurisdictions: [
|
|
372
|
+
id: 'eu-ai-act',
|
|
373
|
+
name: 'EU AI Act',
|
|
374
|
+
jurisdictions: ['EU'],
|
|
452
375
|
priority: 15,
|
|
453
376
|
constraints: [
|
|
454
|
-
constraint(
|
|
455
|
-
constraint(
|
|
456
|
-
constraint(
|
|
377
|
+
constraint('euai-escalation', 'escalation', 'AI Act: Block and escalate on violations', 'mandatory', 'eu-ai-act', 'EU', 'block-escalate'),
|
|
378
|
+
constraint('euai-audit', 'audit-requirement', 'AI Act: AI system audit trail', 'mandatory', 'eu-ai-act', 'EU', 'ai-system-audit'),
|
|
379
|
+
constraint('euai-processing', 'processing-restriction', 'AI Act: Risk assessment required', 'mandatory', 'eu-ai-act', 'EU', 'risk-assessment-required'),
|
|
457
380
|
],
|
|
458
381
|
},
|
|
459
382
|
// -- US --
|
|
460
383
|
{
|
|
461
|
-
id:
|
|
462
|
-
name:
|
|
463
|
-
jurisdictions: [
|
|
384
|
+
id: 'us-standard',
|
|
385
|
+
name: 'US Standard',
|
|
386
|
+
jurisdictions: ['US'],
|
|
464
387
|
priority: 10,
|
|
465
388
|
constraints: [
|
|
466
|
-
constraint(
|
|
467
|
-
constraint(
|
|
468
|
-
constraint(
|
|
469
|
-
constraint(
|
|
470
|
-
constraint(
|
|
471
|
-
constraint(
|
|
389
|
+
constraint('us-retention', 'retention', 'US: 7-year audit retention', 'mandatory', 'us-standard', 'US', 2555),
|
|
390
|
+
constraint('us-crypto', 'crypto', 'US: FIPS 140-2 cryptographic suite', 'mandatory', 'us-standard', 'US', 'fips-140-2'),
|
|
391
|
+
constraint('us-proof', 'proof-anchoring', 'US: TSA RFC 3161 proof anchoring', 'required', 'us-standard', 'US', 'tsa-rfc3161'),
|
|
392
|
+
constraint('us-trust', 'trust-level', 'US: Minimum trust T3 (Monitored)', 'required', 'us-standard', 'US', 3),
|
|
393
|
+
constraint('us-escalation', 'escalation', 'US: Block and escalate', 'mandatory', 'us-standard', 'US', 'block-escalate'),
|
|
394
|
+
constraint('us-consent', 'consent', 'US: Opt-out consent model', 'required', 'us-standard', 'US', 'opt-out'),
|
|
472
395
|
],
|
|
473
396
|
},
|
|
474
397
|
// -- APAC --
|
|
475
398
|
{
|
|
476
|
-
id:
|
|
477
|
-
name:
|
|
478
|
-
jurisdictions: [
|
|
399
|
+
id: 'apac-standard',
|
|
400
|
+
name: 'APAC Standard',
|
|
401
|
+
jurisdictions: ['APAC'],
|
|
479
402
|
priority: 8,
|
|
480
403
|
constraints: [
|
|
481
|
-
constraint(
|
|
482
|
-
constraint(
|
|
483
|
-
constraint(
|
|
484
|
-
constraint(
|
|
404
|
+
constraint('apac-retention', 'retention', 'APAC: 3-year audit retention', 'required', 'apac-standard', 'APAC', 1095),
|
|
405
|
+
constraint('apac-consent', 'consent', 'APAC: Opt-in consent model', 'required', 'apac-standard', 'APAC', 'opt-in'),
|
|
406
|
+
constraint('apac-trust', 'trust-level', 'APAC: Minimum trust T2 (Provisional)', 'required', 'apac-standard', 'APAC', 2),
|
|
407
|
+
constraint('apac-proof', 'proof-anchoring', 'APAC: Merkle tree proof anchoring', 'required', 'apac-standard', 'APAC', 'merkle-tree'),
|
|
485
408
|
],
|
|
486
409
|
},
|
|
487
410
|
// -- UK (post-Brexit, GDPR-adjacent) --
|
|
488
411
|
{
|
|
489
|
-
id:
|
|
490
|
-
name:
|
|
491
|
-
jurisdictions: [
|
|
412
|
+
id: 'uk-dpa',
|
|
413
|
+
name: 'UK Data Protection Act',
|
|
414
|
+
jurisdictions: ['UK'],
|
|
492
415
|
priority: 10,
|
|
493
416
|
constraints: [
|
|
494
|
-
constraint(
|
|
495
|
-
constraint(
|
|
496
|
-
constraint(
|
|
497
|
-
constraint(
|
|
417
|
+
constraint('uk-retention', 'retention', 'UK DPA: 5-year retention', 'mandatory', 'uk-dpa', 'UK', 1825),
|
|
418
|
+
constraint('uk-consent', 'consent', 'UK DPA: Explicit granular consent', 'mandatory', 'uk-dpa', 'UK', 'explicit-granular'),
|
|
419
|
+
constraint('uk-trust', 'trust-level', 'UK DPA: Minimum trust T3 (Monitored)', 'required', 'uk-dpa', 'UK', 3),
|
|
420
|
+
constraint('uk-residency', 'data-residency', 'UK DPA: UK data residency', 'mandatory', 'uk-dpa', 'UK', 'uk-south'),
|
|
498
421
|
],
|
|
499
422
|
},
|
|
500
423
|
// -- Canada --
|
|
501
424
|
{
|
|
502
|
-
id:
|
|
503
|
-
name:
|
|
504
|
-
jurisdictions: [
|
|
425
|
+
id: 'ca-pipeda',
|
|
426
|
+
name: 'Canada PIPEDA',
|
|
427
|
+
jurisdictions: ['CA'],
|
|
505
428
|
priority: 10,
|
|
506
429
|
constraints: [
|
|
507
|
-
constraint(
|
|
508
|
-
constraint(
|
|
509
|
-
constraint(
|
|
430
|
+
constraint('ca-consent', 'consent', 'PIPEDA: Opt-in consent', 'mandatory', 'ca-pipeda', 'CA', 'opt-in'),
|
|
431
|
+
constraint('ca-trust', 'trust-level', 'PIPEDA: Minimum trust T3', 'required', 'ca-pipeda', 'CA', 3),
|
|
432
|
+
constraint('ca-retention', 'retention', 'PIPEDA: 3-year retention', 'required', 'ca-pipeda', 'CA', 1095),
|
|
510
433
|
],
|
|
511
434
|
},
|
|
512
435
|
];
|
|
@@ -541,10 +464,10 @@ export class PolicyComposer {
|
|
|
541
464
|
*/
|
|
542
465
|
registerBundle(bundle) {
|
|
543
466
|
if (this.bundles.has(bundle.id)) {
|
|
544
|
-
logger.warn({ bundleId: bundle.id },
|
|
467
|
+
logger.warn({ bundleId: bundle.id }, 'Overwriting existing policy bundle');
|
|
545
468
|
}
|
|
546
469
|
this.bundles.set(bundle.id, bundle);
|
|
547
|
-
logger.info({ bundleId: bundle.id, priority: bundle.priority },
|
|
470
|
+
logger.info({ bundleId: bundle.id, priority: bundle.priority }, 'Policy bundle registered');
|
|
548
471
|
}
|
|
549
472
|
/**
|
|
550
473
|
* Compose a policy set by selecting applicable bundles for the given
|
|
@@ -554,7 +477,7 @@ export class PolicyComposer {
|
|
|
554
477
|
const applicable = this.selectApplicable(ctx, additionalBundleIds);
|
|
555
478
|
// Always include global default as a fallback
|
|
556
479
|
if (applicable.length === 0) {
|
|
557
|
-
const global = this.bundles.get(
|
|
480
|
+
const global = this.bundles.get('global-default');
|
|
558
481
|
if (global)
|
|
559
482
|
applicable.push(global);
|
|
560
483
|
}
|
|
@@ -582,10 +505,10 @@ export class PolicyComposer {
|
|
|
582
505
|
resolvedConflicts.push(...result.resolvedConflicts);
|
|
583
506
|
unresolvedConflicts.push(...result.unresolvedConflicts);
|
|
584
507
|
}
|
|
585
|
-
const isValid = unresolvedConflicts.every(
|
|
508
|
+
const isValid = unresolvedConflicts.every(c => c.severity !== 'critical');
|
|
586
509
|
return {
|
|
587
510
|
constraints: resolved,
|
|
588
|
-
sourceBundles: applicable.map(
|
|
511
|
+
sourceBundles: applicable.map(b => b.id),
|
|
589
512
|
resolvedConflicts,
|
|
590
513
|
unresolvedConflicts,
|
|
591
514
|
isValid,
|
|
@@ -601,7 +524,7 @@ export class PolicyComposer {
|
|
|
601
524
|
const selected = [];
|
|
602
525
|
const used = new Set();
|
|
603
526
|
for (const [id, bundle] of this.bundles) {
|
|
604
|
-
const applies = bundle.jurisdictions.some(
|
|
527
|
+
const applies = bundle.jurisdictions.some(j => j === 'GLOBAL' || ctx.primaryJurisdictions.includes(j));
|
|
605
528
|
if (applies && !used.has(id)) {
|
|
606
529
|
selected.push(bundle);
|
|
607
530
|
used.add(id);
|
|
@@ -627,34 +550,30 @@ export class PolicyComposer {
|
|
|
627
550
|
resolveGroup(type, constraints, bundles) {
|
|
628
551
|
// No conflict possible with a single constraint
|
|
629
552
|
if (constraints.length <= 1) {
|
|
630
|
-
return {
|
|
631
|
-
resolved: constraints,
|
|
632
|
-
resolvedConflicts: [],
|
|
633
|
-
unresolvedConflicts: [],
|
|
634
|
-
};
|
|
553
|
+
return { resolved: constraints, resolvedConflicts: [], unresolvedConflicts: [] };
|
|
635
554
|
}
|
|
636
555
|
switch (type) {
|
|
637
556
|
// Numeric max-wins
|
|
638
|
-
case
|
|
639
|
-
case
|
|
557
|
+
case 'retention':
|
|
558
|
+
case 'trust-level':
|
|
640
559
|
return this.resolveByMax(type, constraints);
|
|
641
560
|
// Ordered-enum strictest-wins
|
|
642
|
-
case
|
|
561
|
+
case 'crypto':
|
|
643
562
|
return this.resolveByStrictness(type, constraints, CRYPTO_SUITE_STRICTNESS);
|
|
644
|
-
case
|
|
563
|
+
case 'consent':
|
|
645
564
|
return this.resolveByStrictness(type, constraints, CONSENT_STRICTNESS);
|
|
646
|
-
case
|
|
565
|
+
case 'escalation':
|
|
647
566
|
return this.resolveByStrictness(type, constraints, ESCALATION_STRICTNESS);
|
|
648
|
-
case
|
|
567
|
+
case 'proof-anchoring':
|
|
649
568
|
return this.resolveByStrictness(type, constraints, PROOF_ANCHORING_STRICTNESS);
|
|
650
569
|
// Special resolution
|
|
651
|
-
case
|
|
570
|
+
case 'data-residency':
|
|
652
571
|
return this.resolveDataResidency(constraints);
|
|
653
|
-
case
|
|
572
|
+
case 'external-services':
|
|
654
573
|
return this.resolveExternalServices(constraints);
|
|
655
574
|
// Additive (keep all unique values)
|
|
656
|
-
case
|
|
657
|
-
case
|
|
575
|
+
case 'audit-requirement':
|
|
576
|
+
case 'processing-restriction':
|
|
658
577
|
return this.resolveAdditive(constraints);
|
|
659
578
|
// Fallback: by bundle priority
|
|
660
579
|
default:
|
|
@@ -663,46 +582,42 @@ export class PolicyComposer {
|
|
|
663
582
|
}
|
|
664
583
|
/** Resolve numeric constraints by taking the maximum value. */
|
|
665
584
|
resolveByMax(type, constraints) {
|
|
666
|
-
const valued = constraints.map(
|
|
585
|
+
const valued = constraints.map(c => ({
|
|
667
586
|
constraint: c,
|
|
668
|
-
numericValue: typeof c.value ===
|
|
587
|
+
numericValue: typeof c.value === 'number' ? c.value : 0,
|
|
669
588
|
}));
|
|
670
589
|
const winner = valued.reduce((max, v) => v.numericValue > max.numericValue ? v : max);
|
|
671
|
-
const hasConflict = new Set(valued.map(
|
|
590
|
+
const hasConflict = new Set(valued.map(v => v.numericValue)).size > 1;
|
|
672
591
|
return {
|
|
673
592
|
resolved: [winner.constraint],
|
|
674
593
|
resolvedConflicts: hasConflict
|
|
675
|
-
? [
|
|
676
|
-
{
|
|
594
|
+
? [{
|
|
677
595
|
constraintType: type,
|
|
678
596
|
constraints,
|
|
679
597
|
description: `${type}: resolved to max value ${winner.numericValue}`,
|
|
680
|
-
severity:
|
|
681
|
-
}
|
|
682
|
-
]
|
|
598
|
+
severity: 'low',
|
|
599
|
+
}]
|
|
683
600
|
: [],
|
|
684
601
|
unresolvedConflicts: [],
|
|
685
602
|
};
|
|
686
603
|
}
|
|
687
604
|
/** Resolve ordered-enum constraints by taking the strictest value. */
|
|
688
605
|
resolveByStrictness(type, constraints, strictnessMap) {
|
|
689
|
-
const valued = constraints.map(
|
|
606
|
+
const valued = constraints.map(c => ({
|
|
690
607
|
constraint: c,
|
|
691
608
|
strictness: strictnessMap[String(c.value)] ?? 0,
|
|
692
609
|
}));
|
|
693
610
|
const winner = valued.reduce((max, v) => v.strictness > max.strictness ? v : max);
|
|
694
|
-
const hasConflict = new Set(valued.map(
|
|
611
|
+
const hasConflict = new Set(valued.map(v => v.strictness)).size > 1;
|
|
695
612
|
return {
|
|
696
613
|
resolved: [winner.constraint],
|
|
697
614
|
resolvedConflicts: hasConflict
|
|
698
|
-
? [
|
|
699
|
-
{
|
|
615
|
+
? [{
|
|
700
616
|
constraintType: type,
|
|
701
617
|
constraints,
|
|
702
618
|
description: `${type}: resolved to strictest value "${winner.constraint.value}"`,
|
|
703
|
-
severity:
|
|
704
|
-
}
|
|
705
|
-
]
|
|
619
|
+
severity: 'low',
|
|
620
|
+
}]
|
|
706
621
|
: [],
|
|
707
622
|
unresolvedConflicts: [],
|
|
708
623
|
};
|
|
@@ -713,63 +628,50 @@ export class PolicyComposer {
|
|
|
713
628
|
* both places. This is surfaced as an unresolved critical conflict.
|
|
714
629
|
*/
|
|
715
630
|
resolveDataResidency(constraints) {
|
|
716
|
-
const zones = new Set(constraints.map(
|
|
631
|
+
const zones = new Set(constraints.map(c => String(c.value)));
|
|
717
632
|
if (zones.size <= 1) {
|
|
718
|
-
return {
|
|
719
|
-
resolved: [constraints[0]],
|
|
720
|
-
resolvedConflicts: [],
|
|
721
|
-
unresolvedConflicts: [],
|
|
722
|
-
};
|
|
633
|
+
return { resolved: [constraints[0]], resolvedConflicts: [], unresolvedConflicts: [] };
|
|
723
634
|
}
|
|
724
635
|
// Sort by enforcement level (strictest first)
|
|
725
|
-
const sorted = [...constraints].sort((a, b) => (ENFORCEMENT_ORDER[b.enforcement] ?? 0) -
|
|
726
|
-
|
|
727
|
-
const hasMandatory = sorted.some((c) => c.enforcement === "blocking" || c.enforcement === "mandatory");
|
|
636
|
+
const sorted = [...constraints].sort((a, b) => (ENFORCEMENT_ORDER[b.enforcement] ?? 0) - (ENFORCEMENT_ORDER[a.enforcement] ?? 0));
|
|
637
|
+
const hasMandatory = sorted.some(c => c.enforcement === 'blocking' || c.enforcement === 'mandatory');
|
|
728
638
|
if (hasMandatory) {
|
|
729
639
|
return {
|
|
730
640
|
resolved: [sorted[0]],
|
|
731
641
|
resolvedConflicts: [],
|
|
732
|
-
unresolvedConflicts: [
|
|
733
|
-
|
|
734
|
-
constraintType: "data-residency",
|
|
642
|
+
unresolvedConflicts: [{
|
|
643
|
+
constraintType: 'data-residency',
|
|
735
644
|
constraints,
|
|
736
|
-
description: `Incompatible data residency requirements: ${[...zones].join(
|
|
737
|
-
severity:
|
|
738
|
-
},
|
|
739
|
-
],
|
|
645
|
+
description: `Incompatible data residency requirements: ${[...zones].join(' vs ')}`,
|
|
646
|
+
severity: 'critical',
|
|
647
|
+
}],
|
|
740
648
|
};
|
|
741
649
|
}
|
|
742
650
|
return {
|
|
743
651
|
resolved: [sorted[0]],
|
|
744
|
-
resolvedConflicts: [
|
|
745
|
-
|
|
746
|
-
constraintType: "data-residency",
|
|
652
|
+
resolvedConflicts: [{
|
|
653
|
+
constraintType: 'data-residency',
|
|
747
654
|
constraints,
|
|
748
655
|
description: `Data residency resolved to ${sorted[0].value}`,
|
|
749
|
-
severity:
|
|
750
|
-
},
|
|
751
|
-
],
|
|
656
|
+
severity: 'medium',
|
|
657
|
+
}],
|
|
752
658
|
unresolvedConflicts: [],
|
|
753
659
|
};
|
|
754
660
|
}
|
|
755
661
|
/** External services: false (restrictive) wins over true (permissive). */
|
|
756
662
|
resolveExternalServices(constraints) {
|
|
757
|
-
const blocked = constraints.some(
|
|
758
|
-
const winner = blocked
|
|
759
|
-
|
|
760
|
-
: constraints[0];
|
|
761
|
-
const hasConflict = new Set(constraints.map((c) => c.value)).size > 1;
|
|
663
|
+
const blocked = constraints.some(c => c.value === false);
|
|
664
|
+
const winner = blocked ? constraints.find(c => c.value === false) : constraints[0];
|
|
665
|
+
const hasConflict = new Set(constraints.map(c => c.value)).size > 1;
|
|
762
666
|
return {
|
|
763
667
|
resolved: [winner],
|
|
764
668
|
resolvedConflicts: hasConflict
|
|
765
|
-
? [
|
|
766
|
-
|
|
767
|
-
constraintType: "external-services",
|
|
669
|
+
? [{
|
|
670
|
+
constraintType: 'external-services',
|
|
768
671
|
constraints,
|
|
769
672
|
description: `External services: resolved to ${winner.value}`,
|
|
770
|
-
severity:
|
|
771
|
-
}
|
|
772
|
-
]
|
|
673
|
+
severity: 'low',
|
|
674
|
+
}]
|
|
773
675
|
: [],
|
|
774
676
|
unresolvedConflicts: [],
|
|
775
677
|
};
|
|
@@ -785,28 +687,21 @@ export class PolicyComposer {
|
|
|
785
687
|
unique.push(c);
|
|
786
688
|
}
|
|
787
689
|
}
|
|
788
|
-
return {
|
|
789
|
-
resolved: unique,
|
|
790
|
-
resolvedConflicts: [],
|
|
791
|
-
unresolvedConflicts: [],
|
|
792
|
-
};
|
|
690
|
+
return { resolved: unique, resolvedConflicts: [], unresolvedConflicts: [] };
|
|
793
691
|
}
|
|
794
692
|
/** Fallback: resolve by bundle priority (highest priority wins). */
|
|
795
693
|
resolveByPriority(type, constraints, bundles) {
|
|
796
|
-
const priorityMap = new Map(bundles.map(
|
|
797
|
-
const sorted = [...constraints].sort((a, b) => (priorityMap.get(b.sourceBundleId) ?? 0) -
|
|
798
|
-
(priorityMap.get(a.sourceBundleId) ?? 0));
|
|
694
|
+
const priorityMap = new Map(bundles.map(b => [b.id, b.priority]));
|
|
695
|
+
const sorted = [...constraints].sort((a, b) => (priorityMap.get(b.sourceBundleId) ?? 0) - (priorityMap.get(a.sourceBundleId) ?? 0));
|
|
799
696
|
return {
|
|
800
697
|
resolved: [sorted[0]],
|
|
801
698
|
resolvedConflicts: constraints.length > 1
|
|
802
|
-
? [
|
|
803
|
-
{
|
|
699
|
+
? [{
|
|
804
700
|
constraintType: type,
|
|
805
701
|
constraints,
|
|
806
702
|
description: `${type}: resolved by priority to bundle "${sorted[0].sourceBundleId}"`,
|
|
807
|
-
severity:
|
|
808
|
-
}
|
|
809
|
-
]
|
|
703
|
+
severity: 'low',
|
|
704
|
+
}]
|
|
810
705
|
: [],
|
|
811
706
|
unresolvedConflicts: [],
|
|
812
707
|
};
|
|
@@ -817,140 +712,86 @@ export class PolicyComposer {
|
|
|
817
712
|
// ---------------------------------------------------------------------------
|
|
818
713
|
/** Keywords that trigger "unacceptable" (prohibited) classification under Art. 5. */
|
|
819
714
|
const PROHIBITED_KEYWORDS = [
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
"real-time facial recognition",
|
|
828
|
-
"mass surveillance",
|
|
829
|
-
"emotion recognition workplace",
|
|
830
|
-
"emotion recognition education",
|
|
831
|
-
"predictive policing individual",
|
|
832
|
-
"cognitive behavioral manipulation",
|
|
833
|
-
"biometric categorisation sensitive",
|
|
834
|
-
"untargeted scraping facial",
|
|
715
|
+
'social scoring', 'social credit', 'subliminal manipulation',
|
|
716
|
+
'subliminal technique', 'exploit vulnerability', 'exploit vulnerabilities',
|
|
717
|
+
'real-time biometric identification', 'real-time facial recognition',
|
|
718
|
+
'mass surveillance', 'emotion recognition workplace',
|
|
719
|
+
'emotion recognition education', 'predictive policing individual',
|
|
720
|
+
'cognitive behavioral manipulation', 'biometric categorisation sensitive',
|
|
721
|
+
'untargeted scraping facial',
|
|
835
722
|
];
|
|
836
723
|
/** Keywords mapped to Annex III high-risk categories. */
|
|
837
724
|
const HIGH_RISK_KEYWORDS = {
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
"facial recognition",
|
|
842
|
-
"fingerprint matching",
|
|
843
|
-
"voice identification",
|
|
844
|
-
"iris recognition",
|
|
725
|
+
'biometric-identification': [
|
|
726
|
+
'biometric identification', 'biometric verification', 'facial recognition',
|
|
727
|
+
'fingerprint matching', 'voice identification', 'iris recognition',
|
|
845
728
|
],
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
"water supply",
|
|
850
|
-
"traffic management",
|
|
851
|
-
"electricity distribution",
|
|
852
|
-
"energy management",
|
|
729
|
+
'critical-infrastructure': [
|
|
730
|
+
'critical infrastructure', 'power grid', 'water supply',
|
|
731
|
+
'traffic management', 'electricity distribution', 'energy management',
|
|
853
732
|
],
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
"learning evaluation",
|
|
858
|
-
"exam scoring",
|
|
859
|
-
"academic grading",
|
|
860
|
-
"educational placement",
|
|
733
|
+
'education-vocational': [
|
|
734
|
+
'student assessment', 'educational admission', 'learning evaluation',
|
|
735
|
+
'exam scoring', 'academic grading', 'educational placement',
|
|
861
736
|
],
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
"resume screening",
|
|
867
|
-
"employee evaluation",
|
|
868
|
-
"performance monitoring",
|
|
869
|
-
"promotion decision",
|
|
870
|
-
"termination decision",
|
|
871
|
-
"worker management",
|
|
737
|
+
'employment-worker-management': [
|
|
738
|
+
'recruitment', 'hiring decision', 'cv screening', 'resume screening',
|
|
739
|
+
'employee evaluation', 'performance monitoring', 'promotion decision',
|
|
740
|
+
'termination decision', 'worker management',
|
|
872
741
|
],
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
"insurance risk",
|
|
878
|
-
"social benefit",
|
|
879
|
-
"public assistance",
|
|
880
|
-
"emergency services dispatch",
|
|
881
|
-
"loan application",
|
|
882
|
-
"mortgage decision",
|
|
742
|
+
'essential-services': [
|
|
743
|
+
'credit scoring', 'creditworthiness', 'insurance pricing',
|
|
744
|
+
'insurance risk', 'social benefit', 'public assistance',
|
|
745
|
+
'emergency services dispatch', 'loan application', 'mortgage decision',
|
|
883
746
|
],
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
"recidivism prediction",
|
|
888
|
-
"crime prediction",
|
|
889
|
-
"evidence analysis",
|
|
890
|
-
"suspect profiling",
|
|
747
|
+
'law-enforcement': [
|
|
748
|
+
'law enforcement', 'criminal risk assessment', 'recidivism prediction',
|
|
749
|
+
'crime prediction', 'evidence analysis', 'suspect profiling',
|
|
891
750
|
],
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
"asylum application",
|
|
896
|
-
"visa application",
|
|
897
|
-
"migration management",
|
|
898
|
-
"refugee assessment",
|
|
751
|
+
'migration-asylum-border': [
|
|
752
|
+
'border control', 'immigration', 'asylum application',
|
|
753
|
+
'visa application', 'migration management', 'refugee assessment',
|
|
899
754
|
],
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
"legal outcome prediction",
|
|
905
|
-
"electoral",
|
|
906
|
-
"voting",
|
|
907
|
-
"election",
|
|
908
|
-
"democratic process",
|
|
755
|
+
'justice-democratic': [
|
|
756
|
+
'judicial decision', 'court ruling', 'sentencing',
|
|
757
|
+
'legal outcome prediction', 'electoral', 'voting',
|
|
758
|
+
'election', 'democratic process',
|
|
909
759
|
],
|
|
910
760
|
};
|
|
911
761
|
/** Keywords that trigger "limited-risk" classification (transparency obligations). */
|
|
912
762
|
const LIMITED_RISK_KEYWORDS = [
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
"synthetic media",
|
|
918
|
-
"generated content",
|
|
919
|
-
"ai-generated text",
|
|
920
|
-
"ai-generated image",
|
|
921
|
-
"ai-generated video",
|
|
922
|
-
"emotion detection",
|
|
923
|
-
"content generation",
|
|
924
|
-
"text generation",
|
|
925
|
-
"image generation",
|
|
763
|
+
'chatbot', 'conversational ai', 'virtual assistant', 'deepfake',
|
|
764
|
+
'synthetic media', 'generated content', 'ai-generated text',
|
|
765
|
+
'ai-generated image', 'ai-generated video', 'emotion detection',
|
|
766
|
+
'content generation', 'text generation', 'image generation',
|
|
926
767
|
];
|
|
927
768
|
/** Regulatory obligations per classification tier. */
|
|
928
769
|
const OBLIGATIONS_MAP = {
|
|
929
|
-
unacceptable: [
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
770
|
+
'unacceptable': [
|
|
771
|
+
'PROHIBITED - System must not be deployed in EU/EEA',
|
|
772
|
+
'Immediate cessation required for EU market',
|
|
773
|
+
'Notify national supervisory authority',
|
|
933
774
|
],
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
775
|
+
'high-risk': [
|
|
776
|
+
'Risk management system (Art. 9)',
|
|
777
|
+
'Data governance and management (Art. 10)',
|
|
778
|
+
'Technical documentation (Art. 11)',
|
|
779
|
+
'Record-keeping and logging (Art. 12)',
|
|
780
|
+
'Transparency and user information (Art. 13)',
|
|
781
|
+
'Human oversight measures (Art. 14)',
|
|
782
|
+
'Accuracy, robustness, cybersecurity (Art. 15)',
|
|
783
|
+
'Conformity assessment (Art. 43)',
|
|
784
|
+
'Post-market monitoring (Art. 61)',
|
|
785
|
+
'Serious incident reporting (Art. 62)',
|
|
945
786
|
],
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
787
|
+
'limited-risk': [
|
|
788
|
+
'Inform users of AI interaction (Art. 50)',
|
|
789
|
+
'Label AI-generated content (Art. 50)',
|
|
790
|
+
'Disclose deepfake/synthetic content (Art. 50)',
|
|
950
791
|
],
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
792
|
+
'minimal-risk': [
|
|
793
|
+
'Voluntary codes of conduct (Art. 95)',
|
|
794
|
+
'No mandatory obligations',
|
|
954
795
|
],
|
|
955
796
|
};
|
|
956
797
|
/**
|
|
@@ -986,10 +827,10 @@ export class AiActClassifier {
|
|
|
986
827
|
if (limited)
|
|
987
828
|
return limited;
|
|
988
829
|
return {
|
|
989
|
-
classification:
|
|
830
|
+
classification: 'minimal-risk',
|
|
990
831
|
confidence: 0.6,
|
|
991
|
-
reasoning:
|
|
992
|
-
obligations: OBLIGATIONS_MAP[
|
|
832
|
+
reasoning: 'No risk indicators detected; classified as minimal-risk',
|
|
833
|
+
obligations: OBLIGATIONS_MAP['minimal-risk'],
|
|
993
834
|
};
|
|
994
835
|
}
|
|
995
836
|
buildSearchText(goal, context, intentType) {
|
|
@@ -998,29 +839,29 @@ export class AiActClassifier {
|
|
|
998
839
|
parts.push(intentType.toLowerCase());
|
|
999
840
|
if (context) {
|
|
1000
841
|
for (const [key, value] of Object.entries(context)) {
|
|
1001
|
-
if (typeof value ===
|
|
842
|
+
if (typeof value === 'string') {
|
|
1002
843
|
parts.push(`${key}: ${value}`.toLowerCase());
|
|
1003
844
|
}
|
|
1004
845
|
else if (Array.isArray(value)) {
|
|
1005
846
|
for (const item of value) {
|
|
1006
|
-
if (typeof item ===
|
|
847
|
+
if (typeof item === 'string')
|
|
1007
848
|
parts.push(item.toLowerCase());
|
|
1008
849
|
}
|
|
1009
850
|
}
|
|
1010
851
|
}
|
|
1011
852
|
}
|
|
1012
|
-
return parts.join(
|
|
853
|
+
return parts.join(' ');
|
|
1013
854
|
}
|
|
1014
855
|
checkProhibited(text) {
|
|
1015
856
|
for (const keyword of PROHIBITED_KEYWORDS) {
|
|
1016
857
|
if (text.includes(keyword)) {
|
|
1017
|
-
logger.warn({ keyword },
|
|
858
|
+
logger.warn({ keyword }, 'EU AI Act: PROHIBITED system detected');
|
|
1018
859
|
return {
|
|
1019
|
-
classification:
|
|
860
|
+
classification: 'unacceptable',
|
|
1020
861
|
confidence: 0.9,
|
|
1021
862
|
reasoning: `Prohibited practice detected: "${keyword}" (Art. 5)`,
|
|
1022
|
-
annexReference:
|
|
1023
|
-
obligations: OBLIGATIONS_MAP[
|
|
863
|
+
annexReference: 'Article 5',
|
|
864
|
+
obligations: OBLIGATIONS_MAP['unacceptable'],
|
|
1024
865
|
};
|
|
1025
866
|
}
|
|
1026
867
|
}
|
|
@@ -1030,7 +871,7 @@ export class AiActClassifier {
|
|
|
1030
871
|
let bestMatch = null;
|
|
1031
872
|
for (const [category, keywords] of Object.entries(HIGH_RISK_KEYWORDS)) {
|
|
1032
873
|
let count = 0;
|
|
1033
|
-
let firstKeyword =
|
|
874
|
+
let firstKeyword = '';
|
|
1034
875
|
for (const keyword of keywords) {
|
|
1035
876
|
if (text.includes(keyword)) {
|
|
1036
877
|
count++;
|
|
@@ -1044,14 +885,14 @@ export class AiActClassifier {
|
|
|
1044
885
|
}
|
|
1045
886
|
if (bestMatch) {
|
|
1046
887
|
const confidence = Math.min(0.5 + bestMatch.count * 0.15, 0.95);
|
|
1047
|
-
logger.info({ category: bestMatch.category, confidence },
|
|
888
|
+
logger.info({ category: bestMatch.category, confidence }, 'EU AI Act: High-risk classification');
|
|
1048
889
|
return {
|
|
1049
|
-
classification:
|
|
890
|
+
classification: 'high-risk',
|
|
1050
891
|
highRiskCategory: bestMatch.category,
|
|
1051
892
|
confidence,
|
|
1052
893
|
reasoning: `High-risk system (Annex III: ${bestMatch.category}). Matched: "${bestMatch.keyword}"`,
|
|
1053
|
-
annexReference:
|
|
1054
|
-
obligations: OBLIGATIONS_MAP[
|
|
894
|
+
annexReference: 'Article 6, Annex III',
|
|
895
|
+
obligations: OBLIGATIONS_MAP['high-risk'],
|
|
1055
896
|
};
|
|
1056
897
|
}
|
|
1057
898
|
return null;
|
|
@@ -1060,11 +901,11 @@ export class AiActClassifier {
|
|
|
1060
901
|
for (const keyword of LIMITED_RISK_KEYWORDS) {
|
|
1061
902
|
if (text.includes(keyword)) {
|
|
1062
903
|
return {
|
|
1063
|
-
classification:
|
|
904
|
+
classification: 'limited-risk',
|
|
1064
905
|
confidence: 0.7,
|
|
1065
906
|
reasoning: `Limited-risk transparency obligation: "${keyword}"`,
|
|
1066
|
-
annexReference:
|
|
1067
|
-
obligations: OBLIGATIONS_MAP[
|
|
907
|
+
annexReference: 'Article 50',
|
|
908
|
+
obligations: OBLIGATIONS_MAP['limited-risk'],
|
|
1068
909
|
};
|
|
1069
910
|
}
|
|
1070
911
|
}
|
|
@@ -1080,17 +921,15 @@ export class AiActClassifier {
|
|
|
1080
921
|
*/
|
|
1081
922
|
function pickStrictest(defaults, policyValue, strictnessMap) {
|
|
1082
923
|
const all = policyValue ? [...defaults, policyValue] : defaults;
|
|
1083
|
-
return all.reduce((strictest, current) => (strictnessMap[current] ?? 0) > (strictnessMap[strictest] ?? 0)
|
|
1084
|
-
? current
|
|
1085
|
-
: strictest);
|
|
924
|
+
return all.reduce((strictest, current) => (strictnessMap[current] ?? 0) > (strictnessMap[strictest] ?? 0) ? current : strictest);
|
|
1086
925
|
}
|
|
1087
926
|
/** Check if a jurisdiction context includes any of the given jurisdictions. */
|
|
1088
927
|
function hasJurisdiction(ctx, ...jurisdictions) {
|
|
1089
|
-
return jurisdictions.some(
|
|
928
|
+
return jurisdictions.some(j => ctx.primaryJurisdictions.includes(j));
|
|
1090
929
|
}
|
|
1091
930
|
/** Extract a typed constraint value from a composed policy set. */
|
|
1092
931
|
function extractPolicyValue(policySet, type) {
|
|
1093
|
-
return policySet.constraints.find(
|
|
932
|
+
return policySet.constraints.find(c => c.type === type)?.value;
|
|
1094
933
|
}
|
|
1095
934
|
/**
|
|
1096
935
|
* Assembles a complete GovernanceRegime from a jurisdiction context and
|
|
@@ -1125,13 +964,13 @@ export class RegimeSelector {
|
|
|
1125
964
|
// Build human-readable name
|
|
1126
965
|
const jurisdictionPart = ctx.primaryJurisdictions.length === 1
|
|
1127
966
|
? ctx.primaryJurisdictions[0]
|
|
1128
|
-
: `Multi(${ctx.primaryJurisdictions.join(
|
|
1129
|
-
const name = ctx.industry !==
|
|
967
|
+
: `Multi(${ctx.primaryJurisdictions.join('+')})`;
|
|
968
|
+
const name = ctx.industry !== 'general'
|
|
1130
969
|
? `${jurisdictionPart}-${ctx.industry}`
|
|
1131
970
|
: jurisdictionPart;
|
|
1132
971
|
const regime = {
|
|
1133
972
|
regimeId,
|
|
1134
|
-
name: name ||
|
|
973
|
+
name: name || 'default',
|
|
1135
974
|
jurisdictions: ctx.primaryJurisdictions,
|
|
1136
975
|
policyNamespaces: policySet.sourceBundles,
|
|
1137
976
|
cryptoSuite,
|
|
@@ -1142,64 +981,64 @@ export class RegimeSelector {
|
|
|
1142
981
|
dataResidency: ctx.dataResidency,
|
|
1143
982
|
externalServicesAllowed,
|
|
1144
983
|
minimumTrustLevel,
|
|
1145
|
-
conformityAssessmentRequired: hasJurisdiction(ctx,
|
|
1146
|
-
transparencyRequired: hasJurisdiction(ctx,
|
|
984
|
+
conformityAssessmentRequired: hasJurisdiction(ctx, 'EU'),
|
|
985
|
+
transparencyRequired: hasJurisdiction(ctx, 'EU', 'CA', 'UK'),
|
|
1147
986
|
metadata: {},
|
|
1148
987
|
};
|
|
1149
|
-
logger.info({ regimeId, name, cryptoSuite, minimumTrustLevel },
|
|
988
|
+
logger.info({ regimeId, name, cryptoSuite, minimumTrustLevel }, 'Governance regime assembled');
|
|
1150
989
|
return regime;
|
|
1151
990
|
}
|
|
1152
991
|
resolveCryptoSuite(ctx, ps) {
|
|
1153
|
-
const pv = extractPolicyValue(ps,
|
|
1154
|
-
const defaults = [
|
|
1155
|
-
if (hasJurisdiction(ctx,
|
|
1156
|
-
defaults.push(
|
|
992
|
+
const pv = extractPolicyValue(ps, 'crypto');
|
|
993
|
+
const defaults = ['standard'];
|
|
994
|
+
if (hasJurisdiction(ctx, 'US'))
|
|
995
|
+
defaults.push('fips-140-2');
|
|
1157
996
|
return pickStrictest(defaults, pv, CRYPTO_SUITE_STRICTNESS);
|
|
1158
997
|
}
|
|
1159
998
|
resolveProofAnchoring(ctx, ps) {
|
|
1160
|
-
const pv = extractPolicyValue(ps,
|
|
1161
|
-
const defaults = [
|
|
1162
|
-
if (hasJurisdiction(ctx,
|
|
1163
|
-
defaults.push(
|
|
1164
|
-
else if (hasJurisdiction(ctx,
|
|
1165
|
-
defaults.push(
|
|
999
|
+
const pv = extractPolicyValue(ps, 'proof-anchoring');
|
|
1000
|
+
const defaults = ['database'];
|
|
1001
|
+
if (hasJurisdiction(ctx, 'US'))
|
|
1002
|
+
defaults.push('tsa-rfc3161');
|
|
1003
|
+
else if (hasJurisdiction(ctx, 'EU'))
|
|
1004
|
+
defaults.push('merkle-tree');
|
|
1166
1005
|
return pickStrictest(defaults, pv, PROOF_ANCHORING_STRICTNESS);
|
|
1167
1006
|
}
|
|
1168
1007
|
resolveConsentModel(ctx, ps) {
|
|
1169
|
-
const pv = extractPolicyValue(ps,
|
|
1170
|
-
const defaults = [
|
|
1171
|
-
if (hasJurisdiction(ctx,
|
|
1172
|
-
defaults.push(
|
|
1173
|
-
else if (hasJurisdiction(ctx,
|
|
1174
|
-
defaults.push(
|
|
1175
|
-
else if (hasJurisdiction(ctx,
|
|
1176
|
-
defaults.push(
|
|
1008
|
+
const pv = extractPolicyValue(ps, 'consent');
|
|
1009
|
+
const defaults = ['implicit'];
|
|
1010
|
+
if (hasJurisdiction(ctx, 'EU', 'UK'))
|
|
1011
|
+
defaults.push('explicit-granular');
|
|
1012
|
+
else if (hasJurisdiction(ctx, 'CA'))
|
|
1013
|
+
defaults.push('opt-in');
|
|
1014
|
+
else if (hasJurisdiction(ctx, 'US'))
|
|
1015
|
+
defaults.push('opt-out');
|
|
1177
1016
|
return pickStrictest(defaults, pv, CONSENT_STRICTNESS);
|
|
1178
1017
|
}
|
|
1179
1018
|
resolveEscalationMode(ctx, ps) {
|
|
1180
|
-
const pv = extractPolicyValue(ps,
|
|
1181
|
-
const defaults = [
|
|
1182
|
-
if (hasJurisdiction(ctx,
|
|
1183
|
-
defaults.push(
|
|
1019
|
+
const pv = extractPolicyValue(ps, 'escalation');
|
|
1020
|
+
const defaults = ['flag-review'];
|
|
1021
|
+
if (hasJurisdiction(ctx, 'US', 'EU'))
|
|
1022
|
+
defaults.push('block-escalate');
|
|
1184
1023
|
return pickStrictest(defaults, pv, ESCALATION_STRICTNESS);
|
|
1185
1024
|
}
|
|
1186
1025
|
resolveAuditRetentionDays(ctx, ps) {
|
|
1187
|
-
const pv = extractPolicyValue(ps,
|
|
1026
|
+
const pv = extractPolicyValue(ps, 'retention');
|
|
1188
1027
|
const defaults = [365];
|
|
1189
|
-
if (hasJurisdiction(ctx,
|
|
1028
|
+
if (hasJurisdiction(ctx, 'EU', 'UK'))
|
|
1190
1029
|
defaults.push(1825);
|
|
1191
|
-
if (hasJurisdiction(ctx,
|
|
1030
|
+
if (hasJurisdiction(ctx, 'US'))
|
|
1192
1031
|
defaults.push(2555);
|
|
1193
1032
|
return Math.max(...(pv !== undefined ? [...defaults, pv] : defaults));
|
|
1194
1033
|
}
|
|
1195
1034
|
resolveExternalServicesAllowed(ctx, ps) {
|
|
1196
|
-
const pv = extractPolicyValue(ps,
|
|
1035
|
+
const pv = extractPolicyValue(ps, 'external-services');
|
|
1197
1036
|
return pv !== undefined ? pv : true;
|
|
1198
1037
|
}
|
|
1199
1038
|
resolveMinimumTrustLevel(ctx, ps) {
|
|
1200
|
-
const pv = extractPolicyValue(ps,
|
|
1039
|
+
const pv = extractPolicyValue(ps, 'trust-level');
|
|
1201
1040
|
const defaults = [2];
|
|
1202
|
-
if (hasJurisdiction(ctx,
|
|
1041
|
+
if (hasJurisdiction(ctx, 'EU', 'US', 'UK', 'CA'))
|
|
1203
1042
|
defaults.push(3);
|
|
1204
1043
|
return Math.max(...(pv !== undefined ? [...defaults, pv] : defaults));
|
|
1205
1044
|
}
|
|
@@ -1224,10 +1063,10 @@ export class RegimeSelector {
|
|
|
1224
1063
|
let hash = 0;
|
|
1225
1064
|
for (let i = 0; i < str.length; i++) {
|
|
1226
1065
|
const char = str.charCodeAt(i);
|
|
1227
|
-
hash = (hash << 5) - hash + char;
|
|
1066
|
+
hash = ((hash << 5) - hash) + char;
|
|
1228
1067
|
hash = hash & hash; // Convert to 32-bit integer
|
|
1229
1068
|
}
|
|
1230
|
-
return `regime-${Math.abs(hash).toString(16).padStart(8,
|
|
1069
|
+
return `regime-${Math.abs(hash).toString(16).padStart(8, '0')}`;
|
|
1231
1070
|
}
|
|
1232
1071
|
}
|
|
1233
1072
|
// ---------------------------------------------------------------------------
|
|
@@ -1240,9 +1079,9 @@ export class RegimeSelector {
|
|
|
1240
1079
|
export class GatewayConflictError extends Error {
|
|
1241
1080
|
conflicts;
|
|
1242
1081
|
constructor(conflicts) {
|
|
1243
|
-
super(
|
|
1244
|
-
conflicts.map(
|
|
1245
|
-
this.name =
|
|
1082
|
+
super('Intent blocked by unresolved policy conflicts: ' +
|
|
1083
|
+
conflicts.map(c => c.description).join('; '));
|
|
1084
|
+
this.name = 'GatewayConflictError';
|
|
1246
1085
|
this.conflicts = conflicts;
|
|
1247
1086
|
}
|
|
1248
1087
|
}
|
|
@@ -1250,7 +1089,7 @@ export class GatewayConflictError extends Error {
|
|
|
1250
1089
|
// Intent Gateway (Orchestrator)
|
|
1251
1090
|
// ---------------------------------------------------------------------------
|
|
1252
1091
|
/** EU/EEA jurisdiction codes that trigger AI Act classification. */
|
|
1253
|
-
const EU_JURISDICTION_CODES = new Set([
|
|
1092
|
+
const EU_JURISDICTION_CODES = new Set(['EU']);
|
|
1254
1093
|
/**
|
|
1255
1094
|
* The Intent Gateway is the policy-aware orchestrator for all agent intents.
|
|
1256
1095
|
*
|
|
@@ -1299,10 +1138,7 @@ export class IntentGateway {
|
|
|
1299
1138
|
this.policyComposer = new PolicyComposer();
|
|
1300
1139
|
this.regimeSelector = new RegimeSelector();
|
|
1301
1140
|
this.aiActClassifier = new AiActClassifier();
|
|
1302
|
-
logger.info({
|
|
1303
|
-
enabled: this.config.enabled,
|
|
1304
|
-
defaultJurisdiction: this.config.defaultJurisdiction,
|
|
1305
|
-
}, "IntentGateway initialized");
|
|
1141
|
+
logger.info({ enabled: this.config.enabled, defaultJurisdiction: this.config.defaultJurisdiction }, 'IntentGateway initialized');
|
|
1306
1142
|
}
|
|
1307
1143
|
/**
|
|
1308
1144
|
* Dispatch an intent through the full governance pipeline.
|
|
@@ -1341,13 +1177,11 @@ export class IntentGateway {
|
|
|
1341
1177
|
}
|
|
1342
1178
|
// Step 3: EU AI Act classification (when EU jurisdiction applies)
|
|
1343
1179
|
let aiActResult;
|
|
1344
|
-
if (jurisdictionContext.primaryJurisdictions.some(
|
|
1345
|
-
const goal = typeof submission.goal ===
|
|
1346
|
-
const intentType = typeof submission.intentType ===
|
|
1347
|
-
? submission.intentType
|
|
1348
|
-
: undefined;
|
|
1180
|
+
if (jurisdictionContext.primaryJurisdictions.some(j => EU_JURISDICTION_CODES.has(j))) {
|
|
1181
|
+
const goal = typeof submission.goal === 'string' ? submission.goal : '';
|
|
1182
|
+
const intentType = typeof submission.intentType === 'string' ? submission.intentType : undefined;
|
|
1349
1183
|
aiActResult = this.aiActClassifier.classify(goal, intentMetadata, intentType);
|
|
1350
|
-
if (aiActResult.classification ===
|
|
1184
|
+
if (aiActResult.classification === 'unacceptable') {
|
|
1351
1185
|
warnings.push(`EU AI Act: PROHIBITED - ${aiActResult.reasoning}`);
|
|
1352
1186
|
}
|
|
1353
1187
|
}
|
|
@@ -1375,8 +1209,7 @@ export class IntentGateway {
|
|
|
1375
1209
|
},
|
|
1376
1210
|
};
|
|
1377
1211
|
// Enforce minimum trust level
|
|
1378
|
-
if (!enrichedOptions.trustLevel ||
|
|
1379
|
-
enrichedOptions.trustLevel < regime.minimumTrustLevel) {
|
|
1212
|
+
if (!enrichedOptions.trustLevel || enrichedOptions.trustLevel < regime.minimumTrustLevel) {
|
|
1380
1213
|
enrichedOptions.trustLevel = regime.minimumTrustLevel;
|
|
1381
1214
|
}
|
|
1382
1215
|
// Log regime decision
|
|
@@ -1389,7 +1222,7 @@ export class IntentGateway {
|
|
|
1389
1222
|
minimumTrustLevel: regime.minimumTrustLevel,
|
|
1390
1223
|
aiActClassification: regime.aiActClassification,
|
|
1391
1224
|
bundles: policySet.sourceBundles,
|
|
1392
|
-
},
|
|
1225
|
+
}, 'Gateway regime decision');
|
|
1393
1226
|
}
|
|
1394
1227
|
// Submit the intent
|
|
1395
1228
|
const intent = await this.intentService.submit(submission, enrichedOptions);
|
|
@@ -1400,10 +1233,10 @@ export class IntentGateway {
|
|
|
1400
1233
|
if (error instanceof GatewayConflictError)
|
|
1401
1234
|
throw error;
|
|
1402
1235
|
// Degrade gracefully: submit without governance enrichment
|
|
1403
|
-
logger.error({ error: error instanceof Error ? error.message :
|
|
1236
|
+
logger.error({ error: error instanceof Error ? error.message : 'Unknown error' }, 'Gateway error - falling through to passthrough');
|
|
1404
1237
|
const intent = await this.intentService.submit(submission, options);
|
|
1405
1238
|
const result = this.createPassthroughResult(intent);
|
|
1406
|
-
result.warnings.push(`Gateway degraded: ${error instanceof Error ? error.message :
|
|
1239
|
+
result.warnings.push(`Gateway degraded: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
1407
1240
|
return result;
|
|
1408
1241
|
}
|
|
1409
1242
|
}
|
|
@@ -1444,16 +1277,16 @@ export class IntentGateway {
|
|
|
1444
1277
|
return {
|
|
1445
1278
|
intent,
|
|
1446
1279
|
regime: {
|
|
1447
|
-
regimeId:
|
|
1448
|
-
name:
|
|
1280
|
+
regimeId: 'regime-passthrough',
|
|
1281
|
+
name: 'passthrough',
|
|
1449
1282
|
jurisdictions: [this.config.defaultJurisdiction],
|
|
1450
1283
|
policyNamespaces: [],
|
|
1451
|
-
cryptoSuite:
|
|
1452
|
-
proofAnchoring:
|
|
1284
|
+
cryptoSuite: 'standard',
|
|
1285
|
+
proofAnchoring: 'database',
|
|
1453
1286
|
auditRetentionDays: 365,
|
|
1454
|
-
consentModel:
|
|
1455
|
-
escalationMode:
|
|
1456
|
-
dataResidency:
|
|
1287
|
+
consentModel: 'implicit',
|
|
1288
|
+
escalationMode: 'flag-review',
|
|
1289
|
+
dataResidency: 'global',
|
|
1457
1290
|
externalServicesAllowed: true,
|
|
1458
1291
|
minimumTrustLevel: 2,
|
|
1459
1292
|
conformityAssessmentRequired: false,
|
|
@@ -1463,9 +1296,9 @@ export class IntentGateway {
|
|
|
1463
1296
|
jurisdictionContext: {
|
|
1464
1297
|
primaryJurisdictions: [this.config.defaultJurisdiction],
|
|
1465
1298
|
industry: this.config.defaultIndustry,
|
|
1466
|
-
dataResidency:
|
|
1299
|
+
dataResidency: 'global',
|
|
1467
1300
|
crossBorderTransfer: false,
|
|
1468
|
-
source:
|
|
1301
|
+
source: 'default',
|
|
1469
1302
|
},
|
|
1470
1303
|
policySet: {
|
|
1471
1304
|
constraints: [],
|