olyx-guardrails 1.0.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +63 -23
  3. data/README.md +192 -531
  4. data/lib/generators/olyx_guardrails/templates/initializer.rb.tt +8 -8
  5. data/lib/generators/olyx_guardrails/templates/policy.yml.tt +19 -15
  6. data/lib/olyx/guardrails/check_analyzer.rb +9 -6
  7. data/lib/olyx/guardrails/check_pipeline.rb +2 -2
  8. data/lib/olyx/guardrails/check_result_builder.rb +34 -7
  9. data/lib/olyx/guardrails/check_runner.rb +4 -7
  10. data/lib/olyx/guardrails/errors.rb +20 -8
  11. data/lib/olyx/guardrails/injection_detector.rb +22 -2
  12. data/lib/olyx/guardrails/{ai → llm}/analysis_normalizer.rb +1 -1
  13. data/lib/olyx/guardrails/llm/analysis_pipeline.rb +37 -0
  14. data/lib/olyx/guardrails/{ai → llm}/boolean_validator.rb +2 -2
  15. data/lib/olyx/guardrails/{ai → llm}/result_sanitizer.rb +2 -2
  16. data/lib/olyx/guardrails/llm_analysis.rb +26 -0
  17. data/lib/olyx/guardrails/{ai_context_builder.rb → llm_context_builder.rb} +2 -2
  18. data/lib/olyx/guardrails/llm_failure_handler.rb +17 -0
  19. data/lib/olyx/guardrails/llm_finding_merger.rb +39 -0
  20. data/lib/olyx/guardrails/message_check_runner.rb +3 -3
  21. data/lib/olyx/guardrails/notification/delivery_dispatcher.rb +3 -1
  22. data/lib/olyx/guardrails/notification_event_builder.rb +5 -6
  23. data/lib/olyx/guardrails/notification_sanitizer.rb +1 -2
  24. data/lib/olyx/guardrails/notifier.rb +49 -22
  25. data/lib/olyx/guardrails/notifier_configuration.rb +1 -2
  26. data/lib/olyx/guardrails/pii/sin_validator.rb +2 -2
  27. data/lib/olyx/guardrails/pii_scrubber.rb +22 -2
  28. data/lib/olyx/guardrails/policy/configuration.rb +11 -5
  29. data/lib/olyx/guardrails/policy/redaction_result.rb +5 -1
  30. data/lib/olyx/guardrails/policy.rb +62 -5
  31. data/lib/olyx/guardrails/policy_aware_redactor.rb +1 -2
  32. data/lib/olyx/guardrails/policy_rule/configuration.rb +8 -2
  33. data/lib/olyx/guardrails/policy_rule.rb +34 -2
  34. data/lib/olyx/guardrails/policy_scanner.rb +0 -2
  35. data/lib/olyx/guardrails/rails/action_cable.rb +9 -2
  36. data/lib/olyx/guardrails/rails/active_job_handler.rb +16 -2
  37. data/lib/olyx/guardrails/rails/active_model_validator.rb +8 -1
  38. data/lib/olyx/guardrails/rails/configuration.rb +79 -19
  39. data/lib/olyx/guardrails/rails/configuration_finalizer.rb +0 -2
  40. data/lib/olyx/guardrails/rails/configuration_registry.rb +6 -3
  41. data/lib/olyx/guardrails/rails/configuration_values.rb +4 -2
  42. data/lib/olyx/guardrails/rails/controller.rb +19 -4
  43. data/lib/olyx/guardrails/rails/decision_service.rb +1 -1
  44. data/lib/olyx/guardrails/rails/enforcer.rb +22 -8
  45. data/lib/olyx/guardrails/rails/graphql.rb +11 -2
  46. data/lib/olyx/guardrails/rails/ingress.rb +2 -0
  47. data/lib/olyx/guardrails/rails/job.rb +38 -5
  48. data/lib/olyx/guardrails/rails/policy_document.rb +1 -1
  49. data/lib/olyx/guardrails/rails/runtime.rb +36 -10
  50. data/lib/olyx/guardrails/rails/upload.rb +21 -7
  51. data/lib/olyx/guardrails/rails.rb +75 -3
  52. data/lib/olyx/guardrails/railtie.rb +5 -2
  53. data/lib/olyx/guardrails/redactor.rb +2 -2
  54. data/lib/olyx/guardrails/risk/{ai_score.rb → llm_score.rb} +4 -4
  55. data/lib/olyx/guardrails/risk_scorer.rb +8 -8
  56. data/lib/olyx/guardrails/secret_scanner.rb +25 -2
  57. data/lib/olyx/guardrails/secrets/blocked.rb +17 -2
  58. data/lib/olyx/guardrails/supplemental_violation_labels.rb +1 -1
  59. data/lib/olyx/guardrails/validation.rb +6 -0
  60. data/lib/olyx/guardrails/version.rb +1 -1
  61. data/lib/olyx/guardrails.rb +77 -27
  62. metadata +44 -61
  63. data/CODE_OF_CONDUCT.md +0 -28
  64. data/CONTRIBUTING.md +0 -63
  65. data/SECURITY.md +0 -35
  66. data/docs/API.md +0 -460
  67. data/examples/claude_analyzer.rb +0 -53
  68. data/examples/custom_policy.rb +0 -41
  69. data/examples/notifier.rb +0 -37
  70. data/examples/openai_analyzer.rb +0 -45
  71. data/examples/rails_opt_in.rb +0 -99
  72. data/examples/ruby_only.rb +0 -53
  73. data/lib/olyx/guardrails/ai/analysis_pipeline.rb +0 -26
  74. data/lib/olyx/guardrails/ai/flag_finding_merger.rb +0 -16
  75. data/lib/olyx/guardrails/ai/secret_finding_merger.rb +0 -19
  76. data/lib/olyx/guardrails/ai/standard_finding_merger.rb +0 -24
  77. data/lib/olyx/guardrails/ai_analysis.rb +0 -29
  78. data/lib/olyx/guardrails/ai_failure_handler.rb +0 -17
  79. data/lib/olyx/guardrails/ai_finding_merger.rb +0 -30
  80. data/lib/olyx/guardrails/check_base_result.rb +0 -32
  81. data/lib/olyx/guardrails/integrations/openai/analyzer_setup.rb +0 -21
  82. data/lib/olyx/guardrails/integrations/openai/configuration_resolver.rb +0 -28
  83. data/lib/olyx/guardrails/integrations/openai/dependency_contracts.rb +0 -28
  84. data/lib/olyx/guardrails/integrations/openai/input_builder.rb +0 -39
  85. data/lib/olyx/guardrails/integrations/openai/member_reader.rb +0 -21
  86. data/lib/olyx/guardrails/integrations/openai/model_identifier.rb +0 -28
  87. data/lib/olyx/guardrails/integrations/openai/refusal_guard.rb +0 -28
  88. data/lib/olyx/guardrails/integrations/openai/request_builder.rb +0 -36
  89. data/lib/olyx/guardrails/integrations/openai/request_configuration.rb +0 -25
  90. data/lib/olyx/guardrails/integrations/openai/request_values.rb +0 -33
  91. data/lib/olyx/guardrails/integrations/openai/response_contents.rb +0 -22
  92. data/lib/olyx/guardrails/integrations/openai/response_option_keys.rb +0 -32
  93. data/lib/olyx/guardrails/integrations/openai/response_options.rb +0 -23
  94. data/lib/olyx/guardrails/integrations/openai/schema_registry.rb +0 -46
  95. data/lib/olyx/guardrails/integrations/openai/sdk.rb +0 -26
  96. data/lib/olyx/guardrails/integrations/openai/signal_summary.rb +0 -40
  97. data/lib/olyx/guardrails/integrations/openai_analyzer.rb +0 -107
  98. data/lib/olyx/guardrails/integrations/openai_analyzer_configuration.rb +0 -38
  99. data/lib/olyx/guardrails/integrations/openai_response_parser.rb +0 -34
  100. data/lib/olyx/guardrails/notification/delivery_summary.rb +0 -17
  101. data/lib/olyx/guardrails/policy/ai_failure_mode.rb +0 -15
  102. data/lib/olyx/guardrails/policy_redactor.rb +0 -28
  103. data/lib/olyx/guardrails/policy_rule/match_mode.rb +0 -15
  104. data/lib/olyx/guardrails/rails/evaluation_service.rb +0 -12
  105. data/lib/olyx/guardrails/rails/input_runtime.rb +0 -25
  106. data/lib/olyx/guardrails/rails/integration_configuration.rb +0 -27
  107. data/lib/olyx/guardrails/rails/message_evaluation_service.rb +0 -13
  108. data/lib/olyx/guardrails/rails/message_runtime.rb +0 -20
  109. data/lib/olyx/guardrails/rails/output_runtime.rb +0 -26
  110. data/lib/olyx/guardrails/rails/path_value.rb +0 -30
  111. data/lib/olyx/guardrails/rails/policy_configuration.rb +0 -25
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '069f552d05ca4f0ee61bf1496b27da5961477bb75eb422424b1cd19b31e1ac61'
4
- data.tar.gz: 9189f069fc540a3ecab429ebec194cb9c870917966837fb4c7fff428d705ed78
3
+ metadata.gz: 789eb5e71a301345c3fd0d28e59ffee0b0d9cf67ee9686f0912e5a743ccd093b
4
+ data.tar.gz: d89fc57b450761fe6e530fa116e39413eeb17edeb9c73023fbd8247ace98a727
5
5
  SHA512:
6
- metadata.gz: 264d94b6a842c268cd30430ecf1cb6f2d49557d12266f331e594160e7100d8539b1c35351e4dbab58dd0525c97760c738a4f139270aefcb8d2f251835bd04e5c
7
- data.tar.gz: 75bd129939354ed2333d622cc215cc4a34b0967e39fcb482345719ddd312f9637ceb6a13beddfd27cbfa242f6057bd82178590e8ab98e63e10d79a461fe99b6d
6
+ metadata.gz: 17390bf8cbd4961a4e4a669a5ca0b8f80afcf2663fceaea85e5fe31050e789252b5952ef8063ef80d8ffaa5b78f7e69d4a4c96dba8ce1724fcfe090ccb5f3e50
7
+ data.tar.gz: d3e28269e0760c9c09c83f25f8499b74391ee1d7ebf5d3d9ab1a4fe9236d56c2f90b63daa6c603068f6a40fa2398577d08a2f8631d1c05c37e01a478d9ec3a2a
data/CHANGELOG.md CHANGED
@@ -3,6 +3,40 @@
3
3
  All notable changes to olyx-guardrails are documented here.
4
4
  Format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
5
5
 
6
+ ## [1.1.1] - 2026-07-24
7
+
8
+ ### Changed
9
+
10
+ - The published gem now contains only runtime code, generator templates, and
11
+ its README, changelog, and license. Guides and runnable examples remain
12
+ available from the canonical repository.
13
+ - Removed two internal, one-use indirection layers from Rails policy-path
14
+ normalization and policy redaction. Public behavior is unchanged.
15
+ - The package manifest is now tested as an exact consumer-facing contract, and
16
+ path-like Rails policy configuration has direct boundary coverage.
17
+
18
+ ## [1.1.0] - 2026-07-23
19
+
20
+ ### Changed
21
+
22
+ - Rails metadata now validates consistently as a Hash at every facade and
23
+ adapter boundary.
24
+ - Blocking exceptions use boundary-neutral wording, Active Job selectors
25
+ validate when declared, and inherited job declarations remain effective.
26
+ - Notifier misuse raises `ArgumentError`; `nil` now means only that a valid
27
+ decision has zero risk.
28
+ - The Rails generator provides copyable policy customization instructions and
29
+ tests the customized YAML path.
30
+ - Contributor setup, complete local quality validation, and maintainer release
31
+ verification have canonical commands and documentation.
32
+ - Closely coupled proxy objects were folded into their owning runtime,
33
+ configuration, result-building, and notification components.
34
+ - Provider risk scores now require a finite Numeric value; numeric strings are
35
+ ignored instead of being coerced across the untrusted provider boundary.
36
+ - Contributor and Rails appraisal locks use the current `net-imap` patch.
37
+ - CI refreshes the Ruby advisory database and blocks known-vulnerable locked
38
+ dependencies without making the offline local quality gate network-dependent.
39
+
6
40
  ## [1.0.0] - 2026-07-21
7
41
 
8
42
  Initial public release.
@@ -13,7 +47,7 @@ Initial public release.
13
47
  prompt-injection, secret, and restricted-policy findings without
14
48
  transforming the input. Returns `allowed`, per-category detection flags,
15
49
  `risk_score`, and a `checks` array with one entry per category. The
16
- `length` check runs first; content and AI checks are skipped (not just
50
+ `length` check runs first; content and LLM checks are skipped (not just
17
51
  failed) when it does, so an oversized payload never pays their cost.
18
52
  - `Olyx::Guardrails.redact` — transforms text by removing every
19
53
  regex-detected PII, secret, and restricted-policy match, without making an
@@ -33,9 +67,9 @@ Initial public release.
33
67
  monitoring-only restricted-content rules, `substring`/`whole_word`/`regexp`
34
68
  term matching, case-aware regex support, configurable safe replacements,
35
69
  and `Policy.from_h` for YAML/JSON-style Hash loading.
36
- - `ai_failure_mode:` controls how an analyzer failure is handled: `:allow`
37
- (default, keeps the deterministic result), `:block` (adds a failed `ai`
38
- check and rejects), or `:raise` (`AiAnalyzerError`).
70
+ - `llm_failure_mode:` controls how a provider failure is handled: `:allow`
71
+ (default, keeps the deterministic result), `:block` (adds a failed `llm`
72
+ check and rejects), or `:raise` (`LlmProviderError`).
39
73
  - Invalid configuration — duplicate rule names, empty-matching or invalid
40
74
  patterns, malformed message arrays, invalid custom regexes — raises
41
75
  `ArgumentError` at construction time rather than silently degrading into a
@@ -61,31 +95,29 @@ Initial public release.
61
95
  span. Custom patterns extend detection and are classified as secrets; use
62
96
  `PolicyRule` for named business restrictions instead.
63
97
 
64
- ### AI analyzer hook
98
+ ### LLM provider hook
65
99
 
66
- - Optional `ai_analyzer:` callable receives `(text, context)` and returns a
100
+ - Optional `llm_provider:` callable receives `(text, context)` and returns a
67
101
  Hash or a schema-model object implementing `deep_to_h`/`to_h`. Findings
68
102
  can add a violation but cannot clear a deterministic one. Boolean fields
69
103
  must be actual `true`/`false` values; non-finite risk scores are ignored
70
104
  rather than crashing. Exceptions and malformed responses are bounded under
71
- `result[:ai_analysis][:error]` and handled per `ai_failure_mode`.
72
- - Optional `Integrations::OpenAIAnalyzer` connector for the official OpenAI
73
- Ruby SDK: sends a strict `OpenAI::BaseModel` schema through the Responses
74
- API, consumes the parsed schema-model result, defaults to `store: false`,
75
- and has no model allowlist — it forwards any String/Symbol model
76
- identifier and relies on Structured Outputs support as the compatibility
77
- check. Refusals, API failures, and missing parsed output degrade into the
78
- same `result[:ai_analysis][:error]` path. The `openai` gem is optional and
79
- loaded lazily.
105
+ `result[:llm_analysis][:error]` and handled per `llm_failure_mode`.
106
+ - Provider transport is application-owned. The gem has no vendor SDK adapters,
107
+ endpoint assumptions, model allowlists, or model-specific parameters.
108
+ A framework-free local HTTP example demonstrates an open-source-first
109
+ classifier boundary using only Ruby standard-library HTTP and JSON support.
80
110
 
81
111
  ### Notifications
82
112
 
83
113
  - Vendor-neutral `Notifier` dispatches one sanitized, deeply frozen,
84
114
  versioned event to named callable handlers. Handlers run synchronously and
85
115
  independently — one failure doesn't stop the others, and errors are
86
- returned per handler rather than raised. Input previews, AI reasons,
116
+ returned per handler rather than raised. Input previews, LLM reasons,
87
117
  metadata keys/values, and handler errors are bounded and redacted with the
88
118
  policy's restricted-content rules and the built-in PII/secret detectors.
119
+ - Notification events expose optional provider reasoning as `llm_reason`;
120
+ the pre-release `ai_reason` field is not retained.
89
121
 
90
122
  ### Rails integration
91
123
 
@@ -103,15 +135,23 @@ Initial public release.
103
135
  - `Rails::ActiveJobHandler` enqueues sanitized notification events through
104
136
  any Active Job backend, resolving a reload-safe String/Symbol job
105
137
  constant at delivery time.
138
+ - The initial compatibility window covers Rails 8.0 and 8.1. Only listed Rails
139
+ series are tested and supported; subsequent gem releases may remove a series
140
+ after its upstream security support ends.
106
141
 
107
142
  ### Quality and security posture
108
143
 
109
- - No runtime dependencies for the core checks; Rails and the OpenAI SDK are
110
- both optional and loaded only when used.
111
- - CI enforces RuboCop, a Flog structural-complexity gate (max 10 per
112
- ordinary method, 60 per class/module, with documented DSL exemptions
113
- only), and a RubyCritic maintainability gate, alongside the Appraisal
114
- matrix across Rails 7.2, 8.0, and 8.1.
144
+ - The core has one lightweight runtime dependency, Ruby's `base64` bundled gem.
145
+ Rails remains optional and is loaded only when used.
146
+ - CI enforces RuboCop — including calibrated structural-complexity cops
147
+ (`Metrics/AbcSize`, `CyclomaticComplexity`, `PerceivedComplexity`,
148
+ `ClassLength`) in place of a separate complexity tool — and a RubyCritic
149
+ maintainability gate, alongside the Appraisal matrix across Rails 8.0
150
+ and 8.1.
151
+ - Native RDoc covers every supported public class, module, constant, attribute,
152
+ and method. CI blocks undocumented additions to the explicit public API
153
+ manifest while leaving implementation-only constants outside the
154
+ compatibility contract.
115
155
  - Least-privilege, SHA-pinned CI actions; CodeQL and OpenSSF Scorecard
116
156
  scanning; a private vulnerability-reporting process (see
117
- [SECURITY.md](SECURITY.md)).
157
+ [security policy](https://github.com/Olyx-labs/olyx-guardrails/security/policy)).