Skip to content

refactor(self-check): name the rail selector variant end-to-end#2182

Merged
Pouyanpi merged 1 commit into
developfrom
pouyanpi/self-check-variant-action-param
Jul 17, 2026
Merged

refactor(self-check): name the rail selector variant end-to-end#2182
Pouyanpi merged 1 commit into
developfrom
pouyanpi/self-check-variant-action-param

Conversation

@Pouyanpi

@Pouyanpi Pouyanpi commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

Description

The self-check flow passed its $variant value into the action as task=, so the action signature read self_check_input(task=...) while the config-facing selector is $variant=. Rename the carrier to variant across the flow-to-action boundary: both flows.co calls (variant=$variant), both action signatures (task -> variant), and resolve_self_check_task input parameter. The resolved value stays task from resolve_self_check_task return onward, since it keys the prompt template and model routing. The action parameter is unreleased (added with the multiple-self-check feature), so no compatibility path is needed.

follow-up on #2175

Related Issue(s)

#2175

Verification

AI Assistance

  • No AI tools were used.
  • AI tools were used; a human reviewed and can explain every change (tool: ___).

Checklist

  • I've read the CONTRIBUTING guidelines.
  • This PR links to a triaged issue assigned to me.
  • My PR title follows the project commit convention.
  • I've updated the documentation if applicable.
  • I've added tests if applicable.
  • I've noted any verification beyond CI and any checks I couldn't run.
  • I did not update generated changelog files manually.
  • I addressed all CodeRabbit, Greptile, and other review comments, or replied with why no change is needed.
  • @mentions of the person or team responsible for reviewing proposed changes.

Summary by CodeRabbit

  • Bug Fixes
    • Improved self-check configuration so input and output safety checks consistently honor the selected variant.
    • Ensured variant-based task resolution works correctly across configured rails and event-based flows.
    • Preserved existing default behavior when no variant is specified or when a variant cannot be resolved.
    • Updated validation coverage for variant selection, placeholder handling, and fallback task behavior.

The self-check flow passed its $variant value into the action as task=, so
the action signature read self_check_input(task=...) while the config-facing
selector is $variant=. Rename the carrier to variant across the flow-to-action
boundary: both flows.co calls (variant=$variant), both action signatures
(task -> variant), and resolve_self_check_task input parameter. The resolved
value stays task from resolve_self_check_task return onward, since it keys the
prompt template and model routing. The action parameter is unreleased (added
with the multiple-self-check feature), so no compatibility path is needed.
@Pouyanpi Pouyanpi self-assigned this Jul 17, 2026
@github-actions github-actions Bot added status: needs triage New issues that have not yet been reviewed or categorized. size: S labels Jul 17, 2026
@Pouyanpi Pouyanpi added status: triaged Triaged by a maintainer; eligible for automated review (CodeRabbit/Greptile). and removed status: needs triage New issues that have not yet been reviewed or categorized. labels Jul 17, 2026
@greptile-apps

greptile-apps Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR renames the parameter that carries the rail selector value from task to variant at the flow-to-action boundary, eliminating the confusing mismatch where $variant in .co flows was forwarded as task= to the action. The resolved string is still stored as task inside the actions and run_self_check_task, keeping all prompt-template and model-routing keys unchanged.

  • Both .co files updated: SelfCheckInputAction(task=$variant) and SelfCheckOutputAction(task=$variant)…(variant=$variant).
  • Action signatures and the resolve_self_check_task utility's first parameter renamed from task to variant; all downstream usage of the resolved value (task = resolve_self_check_task(...)) is untouched.
  • Test helper _resolve_input_task and every call site updated from task= to variant=.

Confidence Score: 5/5

Purely a rename refactor within unreleased code; no logic changes, no public API breakage, and all call sites are consistently updated.

Every renamed site (both .co flows, both action functions, the shared utility, and the tests) has been updated in lockstep. The resolved value continues to be stored as task before it reaches prompt templates and model routing, so no downstream behaviour changes. No other callers in the codebase pass task= to these actions.

No files require special attention.

Important Files Changed

Filename Overview
nemoguardrails/library/self_check/input_check/flows.co Renames the action kwarg from task=$variant to variant=$variant to align the call-site with the config-facing selector name.
nemoguardrails/library/self_check/output_check/flows.co Same rename as input flows: task=$variantvariant=$variant in the SelfCheckOutputAction call.
nemoguardrails/library/self_check/input_check/actions.py Action parameter renamed from task to variant; resolved value is still stored as task before being forwarded to prompt/model routing — semantics unchanged.
nemoguardrails/library/self_check/output_check/actions.py Mirrors input action: parameter renamed from task to variant, downstream task local variable and routing logic untouched.
nemoguardrails/library/self_check/utils.py First positional parameter of resolve_self_check_task renamed from task to variant; early-return guard and all internal logic carry through correctly.
tests/test_multiple_self_check_rails.py Test helper _resolve_input_task and all call sites updated from task= to variant= keyword argument; no test logic changed.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
    participant Flow as flows.co
    participant Action as self_check_input/output
    participant Resolve as resolve_self_check_task
    participant Run as run_self_check_task

    Flow->>Action: "SelfCheckInputAction(variant=$variant)"
    Note over Flow,Action: renamed from task= to variant=
    Action->>Resolve: resolve_self_check_task(variant, context, events, ...)
    Note over Action,Resolve: first param renamed task→variant
    Resolve-->>Action: task (resolved string)
    Note over Resolve,Action: return value still called "task"
    Action->>Run: "run_self_check_task(task=task, ...)"
    Run-->>Action: (is_safe, response)
    Action-->>Flow: RailOutcome.allow() / .block()
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
    participant Flow as flows.co
    participant Action as self_check_input/output
    participant Resolve as resolve_self_check_task
    participant Run as run_self_check_task

    Flow->>Action: "SelfCheckInputAction(variant=$variant)"
    Note over Flow,Action: renamed from task= to variant=
    Action->>Resolve: resolve_self_check_task(variant, context, events, ...)
    Note over Action,Resolve: first param renamed task→variant
    Resolve-->>Action: task (resolved string)
    Note over Resolve,Action: return value still called "task"
    Action->>Run: "run_self_check_task(task=task, ...)"
    Run-->>Action: (is_safe, response)
    Action-->>Flow: RailOutcome.allow() / .block()
Loading

Reviews (1): Last reviewed commit: "refactor(self-check): name the rail sele..." | Re-trigger Greptile

@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Self-check input and output actions and flows now use variant instead of task for selecting self-check tasks. Resolution logic and tests were updated for explicit variants, placeholders, and default fallback behavior.

Changes

Self-check variant handling

Layer / File(s) Summary
Align self-check action and flow contracts
nemoguardrails/library/self_check/{input_check,output_check}/...
Self-check actions accept variant, and input/output flows pass $variant using the updated argument name.
Resolve and test variant selection
nemoguardrails/library/self_check/utils.py, tests/test_multiple_self_check_rails.py
Task resolution and tests now handle explicit variants, unresolved placeholders, missing values, and default task selection.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: robgeada

🚥 Pre-merge checks | ✅ 6
✅ Passed checks (6 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Test Results For Major Changes ✅ Passed This is a small parameter rename/refactor across self-check wiring; the PR has no test/perf/numerics impact to document beyond CI.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: renaming the self-check rail selector to variant across the flow-to-action path.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch pouyanpi/self-check-variant-action-param

Comment @coderabbitai help to get the list of available commands.

@Pouyanpi
Pouyanpi merged commit 4310fb2 into develop Jul 17, 2026
20 checks passed
@Pouyanpi
Pouyanpi deleted the pouyanpi/self-check-variant-action-param branch July 17, 2026 08:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: S status: triaged Triaged by a maintainer; eligible for automated review (CodeRabbit/Greptile).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant