The Judge (Compliance, Direction & Rollback)
Deterministic rules catch structural violations (shell bypasses, missing memory recall, forbidden locks), but they cannot evaluate nuanced project guidelines or tell when a 30-turn investigation has started going in circles. That is the role of Kompile's Judge plane.
Kompile splits LLM supervision into two distinct judges — a Compliance Judge (EnforcerJudge) and a Direction Judge (DirectionJudge) — paired with a per-turn Diff Archive (EnforcerDiffArchive) for safe rollback.
1. Compliance Judge (EnforcerJudge)
EnforcerJudge evaluates a subordinate agent against your project's enforcer rules, active /reminder / /reminder-global constraints (see Reminders), and explicitly selected workflow memories. A single persistent judge backend handles all three evaluation modes:
- Full-turn evaluation — reviews the completed assistant response and returns a structured JSON verdict:
compliant: true→ pass through.compliant: false, stop: false→ injectcorrection_promptand retry (up tomaxCorrections).compliant: false, stop: true→ critical violation; halt immediately and trigger rollback if configured.
- Partial / streaming evaluation — monitors output mid-stream (
RealtimeEnforcementTap) and interrupts only when text has already violated a rule in a way later output cannot repair. - MCP tool-call evaluation — returns
ALLOW,BLOCK, orREWRITEfor proposed tool calls before execution.
Precedence & Anti-Overreach Design
A common failure mode of LLM judges is becoming an overzealous micromanager that blocks normal engineering work. Kompile bakes strict anti-overreach rules directly into EnforcerJudge's contract:
- Clear precedence: explicit enforcer rules > active reminders > selected workflow memory constraints > advisory memory (which explains context but never creates new mandates).
- High-confidence exception, not default: when meaning, applicability, or context is ambiguous, the judge must return
compliant: true. - No invented requirements: the judge cannot infer missing tasks, police style/efficiency preferences, or block a tool simply because "it could be done another way."
- Exact command semantics:
git log/show/status/diff(inspect) are distinguished fromgit commit/revert(mutate) andgit reset --hard/clean/force-push (discard work). Filesystem admin commands (rm,mv,mkdir,chmod) are evaluated on exact targets and authorization rather than categorically banned. - Explicit user approval narrows prior guidance: if the user explicitly approves a specific action in the current turn, that approval supersedes earlier general judge guidance for that exact action (without bypassing hard deterministic enforcers).
- Format repair & resilience: if a judge returns non-JSON output, Kompile issues a bounded format-repair retry; persistent backend failures degrade safely rather than crashing your session.
2. Direction Judge (DirectionJudge)
Compliance rules check whether a turn broke a rule. Long agentic sessions fail in a second, subtler way: every individual turn is compliant, yet the agent is circling, re-litigating settled decisions, or chasing a tangent away from your actual goal.
DirectionJudge monitors conversation trajectory rather than per-turn rule compliance:
- Periodic review: inspects the recent conversation trail every
checkEveryturns against the configured session goal and returns:on_track— continue normally.off_track+redirect_prompt— injects the redirect back into the active conversation in place so the agent course-corrects without losing context (capped atmaxRedirects, hard max4).off_trackwithout a redirect (or past the redirect cap) — halts the turn and hands control back through the supervisor feedback lane.
- Cross-turn drift streak: each confidently drift-affected turn (confidence ≥
confidenceThreshold, default0.6) increments a persistent streak; a clean, confidently assessed turn resets it. ReachingcrossTurnDriftLimit(default3, hard max20) escalates instead of repeating ineffective redirects. Streak state persists across judge reloads and chat resumes. - Fail-open by construction: every backend error, timeout, parse error, or low-confidence verdict is treated as
on_trackand merely logged — a broken judge never derails a working session. - Separate from compliance override:
/judge override(one-shot report-only posture) applies to compliance judging, not to direction monitoring, which is configured explicitly via/judge direction.
3. Turn Diff Archive & Rollback (EnforcerDiffArchive)
Whenever an enforcer session is active, Kompile captures a pre-turn baseline before each agent turn under .kompile/enforcer-archive/<sessionId>/:
.kompile/enforcer-archive/<sessionId>/
manifest.json # ordered turn snapshots with timestamps and violation flags
snapshots/
turn-001/
originals/... # exact copies of files BEFORE the turn modified them
diff.patch # unified diff produced during the turn
metadata.json # turn number, timestamp, files touched, violation flagBecause original file bytes are archived per turn (independent of git staging), Kompile can auto-rollback file edits on critical violations without running git reset or clobbering unrelated changes in a shared working tree.
Manual controls inside chat:
/archive # list archived enforced turns
/diff <turn-id> # inspect a turn's unified diff
/rollback <turn-id> # restore originals from an archived turn
/purge # purge the session diff archive4. Controlling & Configuring the Judge (Wizards First)
Use Kompile's numbered interactive wizards instead of hand-editing JSON files:
- Interactive Enforcer & Judge menu (inside chat): run bare
/judge(or/enforcer) to open a numbered menu showing live status with one-keystroke toggles (session judge, global judge, memory mandate), rule/judgement inspection, reload, and option 1 to launch the full setup wizard (EnforcerSetupWizard). Or run/judge init(/enforcer init) to jump straight into the setup wizard. - Terminal setup wizards: run
kompile configure enforcer/kompile enforcer init(EnforcerSetupWizard),kompile configure judge(judge backend & performance harness), or barekompile configure(options 6 and 7). - Project judge model profiles: run
/setupinside chat and choose Manage project judge profiles and vendor defaults (JudgeDefaultsWizard) to pick live-discovered judge models and thinking levels per vendor. - Periodic subagent policy audits: run bare
/policy-enforce(or/policy-enforce-global) to open the staged terminal editor (PolicyEnforceWizard).
Direct Session Controls (/judge, /enforcer, /enforce)
Once configured, /judge (aliases: /enforcer, /enforce) controls the live session:
/judge # interactive numbered menu (prints status when non-interactive)
/judge status # print active backend, rules, direction state, global switch
/judge init # jump straight into the Enforcer & Judge setup wizard
/judge on | off # enable or disable for this session
/judge global on | off # persistent master switch across sessions (/judge-global)
/judge workflow # configure required skills, memories, and plan-before-mutation
/judge direction # configure goal-drift monitoring
/judge memory on | off # toggle MemoryResponseMandate
/judge rules # list active policy rules
/judge judgements # inspect recorded verdicts from judgements.jsonl
/judge feedback # add durable guidance applied to every verdict
/judge chat # converse directly with the judge about a verdict
/judge cost # dedicated token & dollar breakdown of judge overhead
/judge reload # reload project judge config without restarting chat