Repository navigation
Intercept judge: closed-question mode (JEV), fail-closed to ask - #208
Merged
Merged
Conversation
The LLM fallback judge gets a closed mode (default when the judge is on): the model answers eight code-owned questions with yes|no|unknown and one evidence line each, in one call; the decision is taken in code. Every failure (invalid output, missing key, value outside the vocabulary, a failed call, arguments above the 256 KiB cap) is ask. The custom judge prompt becomes bounded operator-policy data (8000 runes). The answers are stored in the intercept audit and shown in the approval detail. freeform keeps the previous behaviour; defaultJudgeFailAction changes from allow to ask.
- A destructive or operator_policy unknown asks, even when read_only is yes. - An enabled closed judge with no completer wired asks (judge_not_wired) instead of falling through to allow. - The argument cap is checked before the review input is built. - MaxTokens for the closed reply raised to 1536. - The operator_policy question also covers a whitelist policy that fails to authorize the action; golden digest updated.
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.
What
The LLM fallback judge gets a closed-question mode (
llm_judge_mode = closed, the default when the judge is enabled). The model no longer chooses allow/ask/deny. It answers eight fixed questions that the code owns, withyes | no | unknownand one evidence line for each. The code then takes the decision from those answers. Any failure now leads to ask. The previous behaviour is kept unchanged asllm_judge_mode = freeform.Why
defaultJudgeFailActionwasallow, so an invalid reply or a failed judge call could let a tool call through. In closed mode every failure is ask. The default fail action (still used by freeform) is now ask.internal/hitl/jev.go: a stable question set with short IDs, strict JSON answers, and a decision owned by the code.Design
Questions (
intercept/closed_judge.go, stable IDs, in prompt and audit order):read_only,availability,data_loss,credentials_acl,live_config,dos,pentest_action,operator_policy.One call per judged tool call answers all eight questions: MaxTokens 1536, temperature 0, thinking disabled. The reply must be exactly one JSON object holding every ID once. Each ID maps to
{"answer": "yes|no|unknown", "evidence": "<one line, at most 200 runes>"}. Any other reply is invalid: a code fence, prose, a missing, extra or duplicate key, an extra field, null, an upper-case or out-of-vocabulary answer, or a multi-line or over-long evidence line.Decision table (
decideClosed, fixed, no score), evaluated in order:data_loss,availability,dos,credentials_acl,live_configpentest_actionandread_only)operator_policy= yesoperator_policy= unknown (even whenread_only= yes)read_only= yesread_onlyis not yes) and any answer = unknownpentest_action= yesReason. The reason names the question that triggered the decision and keeps the
[model]prefix, for example[model] deny data_loss=yes: <evidence>,[model] ask live_config=unknown: ...,[model] ask invalid_output: ...or[model] ask arguments_over_cap: ....decision_sourceanddecided_bystaymodel, as they are today.Argument cap.
JudgeArgumentCap = 256 KiB(a constant). If the arguments are larger, the decision is ask and the model is not called. Arguments are never truncated.Operator policy as data. A custom
llm_judge_promptis no longer a system prompt in closed mode. It is sent asoperator_policyin the review input (input version 5), limited to 8000 runes with an explicit[operator policy truncated at 8000 runes]marker. Only theoperator_policyquestion refers to it. The built-in template is not treated as a policy, because the default criteria now live in the code-owned questions.System prompt. The closed-mode system prompt is a fixed contract and has a golden test (sha256 pin). Its input boundary section is the updated boundary: the operator policy is data, and the arguments are either complete or the call goes to ask.
Mode setting.
llm_judge_modesits in the same settings table and judge config API as the otherllm_judge_*keys (JudgeConfig.mode,GET/PUT /api/intercept/judge). No new environment variable was needed. An empty or unknown value reads asclosed.PUTrejects any value other thanclosedorfreeform.Precedence is unchanged. Intercept rules run first, and the judge sees only the calls that no rule covered.
Audit and UI.
intercept_pending.audit.judge_answers(JSONB) stores the eight answers. The approval detail shows them as a plain list in the formid: answer - evidence. The judge settings card has a mode selector.Wiring. The server installs a new
Completerthat returns the raw reply text. Parsing and the decision happen in theinterceptpackage. Freeform still uses the existingReviewer.Behaviour changes
defaultJudgeFailActionchanges from allow to ask. Closed mode ignoresfail_actionand always asks on failure. In freeform mode, an operator who explicitly savedfail_action = allowkeeps it.freeform.llm_judge_enabledis unchanged.ConfigDigestof judge verdicts now includes themodefield, so digests differ from the ones computed before this change.Choices (where the brief left room)
data_loss, availability, dos, credentials_acl, live_config. The first yes in that order is the recorded trigger.operator_policyunknown asks even whenread_only= yes (review fix). Other unknowns (pentest_action) do not block a read-only allow. An unknownread_onlycounts as a write and asks.pentest_actionno) allows, which matches the old default-allow clause.JudgeContextBoundary, review input (version 4, no new keys) and fail-action handling are unchanged, and it has no argument cap. The updated boundary is part of the closed-mode prompt only.Reviewernow setMode: freeform.TestCaptureApprovalLifecyclealso setsFailAction: allowso that it keeps its old expectation; it is still skipped (Add CI: go build/vet/tests with postgres + web typecheck and static build #9).Review fixes
New decision order in
decideClosed, evaluated top to bottom:operator_policy= yes: deny.operator_policy= unknown: ask, with the trigger in the reason (for example[model] ask data_loss=unknown: ...). This now applies even whenread_only= yes.read_only= yes: allow.pentest_action= yes: allow.Other review fixes:
[model] ask judge_not_wired). Before this fix the judge was treated as off, and the guard allowed the call.BuildReviewInput, so over-cap arguments are never parsed or copied.operator_policyquestion reworded. It now asks whether the policy forbids or fails to authorize the action, so a whitelist policy that does not cover the action produces yes. The closed-prompt golden digest was updated to match.read_only=yeswithdata_loss=unknownnow expects ask (the old allow expectation is replaced).read_only=yeswithoperator_policy=unknownexpects ask.read_only=yeswith every destructive answer andoperator_policy= no expects allow.arguments_over_cap, which shows the cap is checked first.judge_not_wired.Limitations
notodata_losson a destructive call still gets an allow.operator_policyanswer.Tests run locally (Kali, go1.26.10)
The PG tests ran against a throwaway
postgres:16-alpinecontainer (cjtest-pg16, bound to 127.0.0.1, removed after each run).gofmt -lon the changed Go files: cleango build ./...: exit 0go vet ./...: exit 0go test -count=1 -p 1 ./...: exit 0, all packages okgo test -race -count=1 -p 1 ./intercept ./guard ./db ./server ./agent(on the review-fix head): intercept, guard, db and agent are ok. server exits 1 with a race that is not related to this PR and that moves between tests from run to run:TestTaskDetailReturnsListMetrics.TestLLMTestStoredKeyFallbackIsTrimmed.server.New()→wireAgentAugmentwrites agent package globals while a planner goroutine started by an earlier test reads them (agent.renderSystem/agent.AugmentTools).New tests:
TestClosedJudgeDecisionTable: the full table, including destructive overriding pentest, unknown on a write giving ask, read-only giving allow, policy yes giving deny, invalid, fenced, missing, duplicate, extra and out-of-vocabulary output giving ask, judge failure giving ask, arguments over the cap giving ask with no call, andfail_action = allowstill giving ask.TestClosedJudgeArgumentCapBoundaryTestClosedJudgeAuditRecordsAnswersTestClosedJudgeIsTheDefaultModeTestClosedJudgePromptGoldenTestFreeformJudgeUnchanged: a golden of the previous prompt digest, the input shape, verdict pass-through, the configured fail action, and no cap.TestOperatorPolicyIsBoundedData: 8000 runes plus the marker.TestDefaultJudgeFailActionIsAskguard/TestRuleMatchDoesNotCallJudge: a counting fake judge confirms that a matched rule never reaches the judge.intercept/TestClosedJudgeAnswersStored(PG): the answers, reason anddecision_sourceround-trip throughintercept_pending.audit.Not verified
tsc/next buildwere not run locally (nonode_modulesin the worktree).