Skip to content

[codex] unify policy management#2938

Draft
vishalg0wda wants to merge 15 commits into
mainfrom
codex/rebase-zesty-plum-targets
Draft

[codex] unify policy management#2938
vishalg0wda wants to merge 15 commits into
mainfrom
codex/rebase-zesty-plum-targets

Conversation

@vishalg0wda
Copy link
Copy Markdown
Member

Summary

This PR updates policy management so Standard Risk Policies and LLM Judge Policies are treated as sibling first-class policy types instead of modeling LLM Judge policies as a rule within Risk policies. It also adds a Risk policy detail page to match the existing LLM Judge detail flow, normalizes policy scope/behavior vocabulary, and regenerates the API/SDK surfaces for policy targets.

Changes

  • Adds a + New Policy dropdown with Standard Risk Policy and LLM Judge Policy creation paths.
  • Removes LLM Judge/NL policy from the Risk rule-category UI and Risk create/update payload construction.
  • Adds a Risk policy detail page with Configure and Activity tabs.
  • Updates LLM Judge create/configure/detail copy and target configuration to use consistent Policy Scope terminology.
  • Normalizes behavior display to Monitor/Enforce while preserving existing backend values.
  • Regenerates Goa/OpenAPI/client SDK outputs for NL policy targets and Risk policy targets.

Validation

  • rtk git diff --check
  • cd client/dashboard && rtk mise x -- npx tsc --noEmit
  • MOCK_IDP_HOST=localhost rtk mise build:server

simplesagar and others added 15 commits May 19, 2026 17:51
Adds the design spec for a new policy type in the Gram Policy Center,
inspired by brexhq/CrabTrap. Covers per-call inline enforcement at the
MCP tool-call seam, async session-scope evaluation via the existing
Hooks pipeline, audit/enforce/disabled modes, scoped replay, and a
three-PR build order (UI-with-stubs → migration → real backend).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
30 tasks across three PRs. PR 1 (Tasks 1-14): Goa design + stubbed
service + dashboard UI with real generated SDK types backed by
fixtures. PR 2 (Tasks 15-17): five-table migration. PR 3 (Tasks
18-30): real backend with TDD-covered evaluator, judge, static rules,
caches, observer, Temporal workflows, and rpc_tools_call.go integration.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds the natural-language policy service definition with 12 RPC methods
covering CRUD, mode transition, decision feed, session verdicts, and
replay runs. Generates Go server scaffolding; impl follows in subsequent
commits.
- Rename pagination param page_limit → limit (matches codebase convention)
- Add Format(FormatDateTime) to RFC3339 timestamp fields
- Add Enum(...) validators to mode, fail_mode, decision, decided_by,
  verdict, status fields

Generates richer TS types in the SDK and rejects malformed inputs
at the API boundary.
Returns hardcoded fixture data for all 12 RPC methods so the dashboard
can be built and reviewed before the real backend lands. DB-backed
impl ships in PR 3.
- Replace errors.New("not found") with oops.E(oops.CodeNotFound, ...)
  so handlers return correct 404 instead of generic 500
- Add loud WarnContext log to APIKeyAuth stub to prevent accidentally
  shipping open auth in PR 3
- Delete unused ptrString/ptrInt helpers (fixtures use Go 1.26+ new())
- Use attr.SlogComponent("nlpolicies") for logger init (codebase convention)
- Move misplaced doc comment above fixturePolicies()

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Mounts the nlpolicies stub on the HTTP mux so the dashboard can hit
/rpc/nlpolicies.* calls. Regenerates the TypeScript SDK to produce
useNLPolicies* React Query hooks consumed by the upcoming UI bundle.
Companion to 24e47f8 — mise gen:sdk also regenerates
.speakeasy/out.openapi.yaml (full surface incl. nlpolicies) and
.speakeasy/workflow.lock. Per project convention, these ship with
the SDK regen commit.
Adds the NLPolicy detail page (Configure / Audit Feed / Quarantines tabs),
mode-promote and replay dialogs, and the create-form sheet.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Registers the /risk-policies/nl/:policyId nested route, adds NL policies
into the unified Policy Center table with a Type column, and replaces the
single New button with a dropdown that opens either the existing risk
sheet or the new NL create form.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds enabled: !!policyId guard to useNlPoliciesGet so the query
doesn't fire with an empty id during route mount races. Surfaces
a "Policy not found" branch instead of an indefinite spinner when
the route param is missing.

Addresses Important #1 from PR-1 UI code review.
The replay run fixture used "r3a8f2" as its ID, which the Goa-generated
UUID format validator rejected on subsequent useNlPoliciesGetReplayRun
and useNlPoliciesListReplayResults calls — silently breaking the
Replay-modal click-through that's one of PR 1's explicit demos.

Switching to a real UUID literal in both fixtures.go and impl.go
keeps the deterministic-looking 'a8f2' tail for memorability while
satisfying the validator.

Addresses C1 from final ship-readiness review.
Goa's FormatUUID validator enforces RFC4122 (version + variant bits),
not just the 8-4-4-4-12 hex layout. The previous fixture UUIDs
(11111111-..., 22222222-..., 33333333-..., 00000000-...-a8f2) had
non-RFC4122 variant bits and were rejected by the policy_id and
run_id validators on every detail-page load and replay polling call.

Patches version (position 13) to "4" and variant (position 17) to
"a"/"b" so all four fixture UUIDs are valid RFC4122 v4 strings.

Caught during click-through verification.
Rebase onto main resolved generated-file conflicts via --theirs (per
project memory's playbook). This commit re-runs gen:goa-server, gen:sqlc,
gen:sdk to layer the nlpolicies entries back on top of main's surface.
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 19, 2026

⚠️ No Changeset found

Latest commit: 558cce2

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link
Copy Markdown

vercel Bot commented May 19, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
gram-docs-redirect Ready Ready Preview, Comment May 19, 2026 11:59pm

Request Review

@github-actions github-actions Bot added the preview Spawn a preview environment label May 20, 2026
@speakeasybot
Copy link
Copy Markdown
Collaborator

speakeasybot commented May 20, 2026

🚀 Preview Environment (PR #2938)

Preview URL: https://pr-2938.dev.getgram.ai

Component Status Details Updated (UTC)
✅ Database Ready Existing database reused 2026-05-20 12:02:03.
✅ Images Available Container images ready 2026-05-20 12:01:45.

Gram Preview Bot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

preview Spawn a preview environment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants