Olyx Guardrails
In-process input and output checks, explicit redaction, and reusable policies for Ruby and Rails applications.
olyx-guardrails is a Ruby gem for checking text before you send it to a model
and after you receive a complete response. Its pattern checks run inside your
application. Rails applications can add the adapters described in this section.
This section documents the 1.2 release line. See the project changelog for release changes.
Capabilities
Section titled “Capabilities”| Capability | Application entry point |
|---|---|
| Input decisions | Olyx::Guardrails.check |
| Structured messages and adjacent-turn detection | Olyx::Guardrails.check_messages |
| Completed-output decisions | Olyx::Guardrails.check_output |
| PII, secret, and restricted-content redaction | Olyx::Guardrails.redact and .redact_output |
| Organization-specific restrictions | Immutable Policy and PolicyRule objects |
| Optional semantic analysis | Application-owned llm_provider callable |
| Rails enforcement and telemetry | Opt-in boundary adapters and Active Support events |
Requirements
Section titled “Requirements”| Component | Supported versions |
|---|---|
| Ruby | 3.4 or newer |
| Rails, when used | 8.0 and 8.1 |
The gem uses the bundled base64 gem as its only runtime gem dependency. The
framework-free API does not load Rails.
Check and redact
Section titled “Check and redact”require "olyx/guardrails"
input = "Contact ada@example.com"decision = Olyx::Guardrails.check(input)puts decision[:allowed] # true: default policy reports PII without blockingputs Olyx::Guardrails.redact(input)[:text] # Contact [EMAIL]Start building
Section titled “Start building”- Quickstart: install the gem and evaluate your first input.
- Policies: configure blocking, monitoring, replacements, and YAML.
- Rails integration: protect controllers, jobs, GraphQL, Action Cable, uploads, and model attributes.
- Operations: choose failure modes, notifications, and production behavior.
- Ruby API: verify exact signatures, result structures, and exceptions.
Application boundaries
Section titled “Application boundaries”Call Guardrails before sending text to a model and before returning a completed response to the caller. Your application makes the model call and handles access control, file reading, streaming, and saved audit records. To check a response before anyone sees it, collect the complete response, check it, and then return it.
You can use the gem with an application that calls Olyx CLI server mode or any other model client. Configure and invoke Guardrails in your application; it is a separate package and does not change the CLI’s configured route selection.
Pattern detection has documented coverage limits and can miss novel or encoded attacks. Read detection limits before choosing production enforcement behavior.
Project resources
Section titled “Project resources”Olyx Guardrails is licensed under Apache-2.0.