[codex] unify policy management#2938
Draft
vishalg0wda wants to merge 15 commits into
Draft
Conversation
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.
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Collaborator
🚀 Preview Environment (PR #2938)Preview URL: https://pr-2938.dev.getgram.ai
Gram Preview Bot |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
+ New Policydropdown with Standard Risk Policy and LLM Judge Policy creation paths.Policy Scopeterminology.Validation
rtk git diff --checkcd client/dashboard && rtk mise x -- npx tsc --noEmitMOCK_IDP_HOST=localhost rtk mise build:server