Skip to content

feat(studio): add guardrail-checks SDK for entity-store-backed test cases#829

Merged
aray12 merged 3 commits into
mainfrom
astd-236-guardrails-checks-ui
Jul 23, 2026
Merged

feat(studio): add guardrail-checks SDK for entity-store-backed test cases#829
aray12 merged 3 commits into
mainfrom
astd-236-guardrails-checks-ui

Conversation

@aray12

@aray12 aray12 commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Signed-off-by: Alex Ray alray@nvidia.com

Summary by CodeRabbit

  • New Features
    • Added full create, view, update, and delete support for guardrail checks.
    • Enabled config-scoped browsing, so checks can be filtered to a specific configuration.
    • Added the ability to run a single guardrail check or run multiple checks in a batch, returning per-check results or errors.
    • Saved run results, verdict/status, and related configuration metadata to check history.
    • Improved automatic refresh of check lists/details after create, update, delete, or run actions.

@aray12
aray12 requested review from a team as code owners July 21, 2026 19:53
@github-actions github-actions Bot added the feat label Jul 21, 2026
@aray12

aray12 commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

@github-actions

github-actions Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor
Suite Lines Covered Line Rate Branch Rate
Unit Tests 27117/34832 77.8% 62.1%
Integration Tests 15921/33544 47.5% 19.9%

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Guardrail-check API support is added with typed entity contracts, parent-scoped CRUD, execution and run persistence, concurrent batch processing, React Query hooks, cache invalidation, and public exports.

Changes

Guardrail Checks

Layer / File(s) Summary
Guardrail-check contracts and CRUD
web/packages/studio/src/api/guardrail-checks/types.ts, web/packages/studio/src/api/guardrail-checks/guardrailChecks.ts
Defines typed entities, run records, query keys, config filters, and entity-store CRUD operations with parent scoping and optimistic locking.
Check execution and run persistence
web/packages/studio/src/api/guardrail-checks/guardrailChecks.ts
Resolves models, executes checks, persists response-derived run records, and supports concurrent batch execution with per-check errors.
React Query integration and exports
web/packages/studio/src/api/guardrail-checks/hooks.ts, web/packages/studio/src/api/guardrail-checks/invalidateGuardrailChecksCaches.ts, web/packages/studio/src/api/guardrail-checks/index.ts
Adds query and mutation hooks, cache invalidation, and barrel exports for the guardrail-check API.

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant ReactQuery
  participant GuardrailChecksAPI
  participant EntityStore
  participant GuardrailsEndpoint
  Client->>ReactQuery: request guardrail checks
  ReactQuery->>GuardrailChecksAPI: list or fetch check
  GuardrailChecksAPI->>EntityStore: query scoped entities
  EntityStore-->>GuardrailChecksAPI: return check entities
  GuardrailChecksAPI-->>ReactQuery: return page or entity
  Client->>ReactQuery: run guardrail check
  ReactQuery->>GuardrailChecksAPI: run check
  GuardrailChecksAPI->>EntityStore: load parent config
  GuardrailChecksAPI->>GuardrailsEndpoint: execute /checks request
  GuardrailsEndpoint-->>GuardrailChecksAPI: return check response
  GuardrailChecksAPI->>EntityStore: append persisted run
  ReactQuery->>ReactQuery: invalidate affected caches
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed Title clearly matches the main change: adding a guardrail-checks SDK for entity-store-backed test cases in Studio.
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.
✨ 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 astd-236-guardrails-checks-ui

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@web/packages/studio/src/api/guardrail-checks/guardrailChecks.ts`:
- Around line 71-86: Make the parent parameter required in getGuardrailCheck and
deleteGuardrailCheck, matching createGuardrailCheck. Remove the optional
fallback so both name lookups and deletions always pass parent as the required
scope, and update affected callers or types accordingly.
- Line 1: Update the imports in guardrailChecks.ts and hooks.ts to use type-only
specifiers for the listed TypeScript types while keeping
GUARDRAIL_CHECKS_ENTITY_TYPE as a runtime import. In hooks.ts, mark the React
Query option types as type-only and move the `@tanstack/react-query` import into
the external-library import group.
- Line 1: Require a parent scope for all name-based guardrail check operations:
update getGuardrailCheck and deleteGuardrailCheck to require or reject missing
parent before resolving the entity, and extend UseDeleteGuardrailCheckOptions
mutation variables to include parent and pass it through to
deleteGuardrailCheck. Preserve the existing scoped behavior while preventing
unscoped lookup or deletion.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: ad136db7-9590-4974-aaf9-113856ec0df9

📥 Commits

Reviewing files that changed from the base of the PR and between 9f336d5 and 34a76bf.

📒 Files selected for processing (5)
  • web/packages/studio/src/api/guardrail-checks/guardrailChecks.ts
  • web/packages/studio/src/api/guardrail-checks/hooks.ts
  • web/packages/studio/src/api/guardrail-checks/index.ts
  • web/packages/studio/src/api/guardrail-checks/invalidateGuardrailChecksCaches.ts
  • web/packages/studio/src/api/guardrail-checks/types.ts

Comment thread web/packages/studio/src/api/guardrail-checks/guardrailChecks.ts
Comment thread web/packages/studio/src/api/guardrail-checks/guardrailChecks.ts
…ases

Signed-off-by: Alex Ray <alray@nvidia.com>
@aray12
aray12 force-pushed the astd-236-guardrails-checks-ui branch from 34a76bf to a6b221b Compare July 21, 2026 20:41

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
web/packages/studio/src/api/guardrail-checks/hooks.ts (2)

19-27: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Group external imports before internal aliases.

Move @tanstack/react-query above the @studio/* imports.

As per coding guidelines, “Group imports: external libraries, internal modules, relative imports in TypeScript.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@web/packages/studio/src/api/guardrail-checks/hooks.ts` around lines 19 - 27,
Reorder the imports in the guardrail-checks hooks module so the external
`@tanstack/react-query` import block appears before the internal `@studio/api`
imports, preserving the imported symbols and existing grouping style.

Source: Coding guidelines


36-45: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Declare explicit return types for exported APIs.

These public query and mutation helpers currently expose inferred React Query types.

As per coding guidelines, “Use explicit return types for public APIs and complex functions in TypeScript.”

Also applies to: 48-52, 55-65, 68-78, 84-89, 105-114, 126-135, 146-155, 167-176, 188-197

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@web/packages/studio/src/api/guardrail-checks/hooks.ts` around lines 36 - 45,
Declare explicit return types for all exported query and mutation helpers in
this module, including getGuardrailChecksQueryOptions and the additional ranges
identified in the review. Use the appropriate React Query option type matching
each helper’s query or mutation configuration, while preserving the existing
keys, functions, and options behavior.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@web/packages/studio/src/api/guardrail-checks/hooks.ts`:
- Around line 19-27: Reorder the imports in the guardrail-checks hooks module so
the external `@tanstack/react-query` import block appears before the internal
`@studio/api` imports, preserving the imported symbols and existing grouping
style.
- Around line 36-45: Declare explicit return types for all exported query and
mutation helpers in this module, including getGuardrailChecksQueryOptions and
the additional ranges identified in the review. Use the appropriate React Query
option type matching each helper’s query or mutation configuration, while
preserving the existing keys, functions, and options behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 8d321de8-5d71-4b59-876c-20105ca1e07d

📥 Commits

Reviewing files that changed from the base of the PR and between 34a76bf and a6b221b.

📒 Files selected for processing (5)
  • web/packages/studio/src/api/guardrail-checks/guardrailChecks.ts
  • web/packages/studio/src/api/guardrail-checks/hooks.ts
  • web/packages/studio/src/api/guardrail-checks/index.ts
  • web/packages/studio/src/api/guardrail-checks/invalidateGuardrailChecksCaches.ts
  • web/packages/studio/src/api/guardrail-checks/types.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • web/packages/studio/src/api/guardrail-checks/index.ts
  • web/packages/studio/src/api/guardrail-checks/invalidateGuardrailChecksCaches.ts
  • web/packages/studio/src/api/guardrail-checks/types.ts
  • web/packages/studio/src/api/guardrail-checks/guardrailChecks.ts

Comment thread web/packages/studio/src/api/guardrail-checks/guardrailChecks.ts
@aray12
aray12 enabled auto-merge July 23, 2026 17:10
@aray12
aray12 added this pull request to the merge queue Jul 23, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 23, 2026
@aray12
aray12 enabled auto-merge July 23, 2026 19:49
@aray12
aray12 added this pull request to the merge queue Jul 23, 2026
Merged via the queue into main with commit 26319c9 Jul 23, 2026
58 checks passed
@aray12
aray12 deleted the astd-236-guardrails-checks-ui branch July 23, 2026 20:20
AnuradhaKaruppiah pushed a commit to AnuradhaKaruppiah/nemo-platform that referenced this pull request Jul 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants