Rail Manifest Reference
A rail manifest is the versioned, declarative contract for a built-in rail under nemoguardrails/library. It identifies the rail, describes its configuration and dependencies, declares its actions and Colang flows, and exposes action-backed input, output, or retrieval surfaces.
The manifest keeps discovery separate from execution. Import references remain strings until the runtime needs the corresponding configuration factory or action. This lets the catalog inspect a rail without eagerly importing its optional integration dependencies.
File Layout
A manifest-backed library rail uses the following files:
Only rail.py and actions.py are required. Add the other files when the rail provides Colang flows or typed configuration.
The rail.py module must:
- Import manifest types from
nemoguardrails.manifests. - Define one module-level
RAILvalue containing aRailManifest. - Avoid importing the action implementation, configuration implementation, or optional provider packages.
The built-in catalog discovers rail.py modules under nemoguardrails/library. It does not discover arbitrary application or third-party package paths.
Minimal Manifest
The following manifest declares one action and one input surface:
Top-Level Fields
The following table describes the top-level manifest fields:
RailMetadata supports display text, categories, capabilities, tags, documentation URL, lifecycle, owner, and version. Categories and capabilities use the manifest taxonomies. Use tags for labels that do not belong to those taxonomies.
Actions
Declare each rail action with an ActionRef:
The name is the registered action name. It must agree with the action decorator. The target uses the module:attribute import-reference format.
List every action reference in RailActions, including actions used by surfaces:
The runtime registers manifest actions lazily. It imports the action module and its optional dependencies when it resolves the action, not when the catalog first reads the manifest.
Every action declared by a rail manifest must return a RailOutcome. Actions decide whether to allow, block, or transform content. Colang flows and other runtimes decide how to present and enforce that decision.
Colang Flows
Use RailFlows when the rail includes Colang implementations:
files lists Colang 2.x files, v1_files lists Colang 1.0 files, and flow_names declares the public flow names owned by the rail. The default file names are flows.co and flows.v1.co.
Keep both dialect implementations behaviorally equivalent when the rail supports both. The flows should consume RailOutcome properties and own presentation behavior such as refusal intents and stopping the flow.
Action-Backed Surfaces
A RailSurface describes how to invoke a declared action in one pipeline direction. It is independent of a Colang implementation.
The following table describes the surface fields:
Use binding constructors to identify where each action argument comes from:
Use Binding.model_param or Binding.model whenever the resolved value identifies a configured model type. These helpers set resource="model" so the runtime validates the model before invoking the action. A model resource cannot read its type from request context.
Manifest-driven IORails supplies conversation values only through explicit Binding.context entries. Declaring an action parameter named context does not inject the complete context dictionary on this execution path. Bind each conversation input the action requires.
The manifest does not bind runtime-owned collaborators. IORails injects llms, llm, llm_task_manager, config, http_client, model_caches, and events into actions that declare those parameters.
Set required=False on a context or surface-parameter binding only when the action can operate without that value. A surface cannot bind the same action parameter more than once.
When an action can return a transform outcome, set transform_target to the value it rewrites:
Typed Configuration
Use RailConfigSchema to project a rail-specific field under rails.config:
The referenced factory must return a RailConfigSpec. Keep the factory and its model types in rail_config.py so reading the manifest does not import the implementation eagerly.
Requirements and Privacy
Declare install and runtime requirements instead of leaving them implicit:
RailRequirements can declare package extras, environment variables, services, model resources, and optional dependencies. RailPrivacy records whether the rail sends user messages, bot messages, or retrieved chunks to remote services, and can describe provider retention behavior.
These declarations must match the action’s actual behavior. Do not include credentials or secret values in the manifest.
Catalog Validation
The built-in RailCatalog validates the combined manifest set. Catalog construction fails when it finds:
- Duplicate manifest names.
- Duplicate configuration keys.
- Duplicate public flow names.
- Duplicate action names.
- Duplicate surface names in the same direction.
- A surface that references an action not declared by its manifest.
You can inspect the built-in catalog through the public manifest API:
Author Checklist
Use the following checklist when you author a rail manifest:
- Define a lightweight
RAILvalue inrail.py. - Use stable, globally unique manifest, action, flow, configuration, and surface names.
- Keep import targets declarative and point them to the owning implementation modules.
- Return
RailOutcomefrom every declared action. - Keep Colang 1.0 and 2.x flows equivalent when both are present.
- Bind every conversation value, configured surface parameter, literal, and model resource that the action requires; declare runtime-owned collaborators only in the action signature.
- Declare transform targets, dependencies, external services, environment variables, and privacy behavior accurately.
- Add unit tests for the action and manifest contract and recorded tests for LLM or HTTP boundaries when applicable.
- Add or update the rail’s catalog documentation page.