Skip to content

feat(guard): dynamic delegation guardrail using Jev System One - #5081

Open
RooseveltAdvisors wants to merge 5 commits into
kunchenguid:mainfrom
RooseveltAdvisors:fm/jev-delegation-guard
Open

RooseveltAdvisors wants to merge 5 commits into
kunchenguid:mainfrom
RooseveltAdvisors:fm/jev-delegation-guard

Conversation

@RooseveltAdvisors

@RooseveltAdvisors RooseveltAdvisors commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements a dynamic delegation guardrail PreToolUse seatbelt (bin/fm-jev-guard.sh & bin/fm-jev-guard.py) to enforce supervisor role boundaries dynamically without brittle regexes.

Motivation

Text instructions in AGENTS.md are soft constraints. When facing production incidents, supervisor models frequently succumb to the troubleshooting spiral ('just one more command to inspect') and end up running remote SSH commands, package installs, and service edits in w1. Hard constraints work: fm-cd-pretool-check.sh denied cd projects/... instantly. This guardrail provides the same hard boundary for supervisory delegation while avoiding brittle regex whack-a-mole.

Architecture

  • Tier 1 (0ms, $0): Fast-path local allowlist for legitimate supervisor tools (bd, tasks-axi, fm-send, fm-route, fm-wake-drain, git status/log, cat state/*, etc.) with compound command splitting (;, &&, ||, newlines) to prevent hidden chaining.
  • Tier 2 (0ms, $0): Fast local SHA256 decision cache in /dev/shm.
  • Tier 3 (<350ms): Jev System One (jev-latest) evaluates semantic intent, calculates violation noul, and determines target Second Mate domain (gpu_ops, svc_ops, monitor_sre, etc.).
  • Auto-Steer: Denials provide immediate suggested delegation commands (bin/fm-send.sh <domain> '<task>').
  • Fail-Open Policy: Exits 0 on network/API timeouts or malformed transport so Firstmate is never wedged.
  • Worktree Inertia: Inert in linked task worktrees, allowing workers to build, test, and edit code freely.
  • Multi-Harness: Registered under Pi (.pi/extensions/fm-primary-turnend-guard.ts), Claude (.claude/settings.json), and Cursor (.cursor/hooks.json).

Validation

  • Unit test suite tests/fm-jev-guard.test.sh passing 100%.
  • Verified against real command sequences extracted from live Firstmate transcripts.
  • Fully clean under bin/fm-lint.sh (ShellCheck 0.11.0 extended dataflow).
  • tests/fm-turnend-guard.test.sh updated and passing 100%.

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ Intent verified: dynamic delegation guardrail using Jev System One.

✅ **rebase** - passed

✅ Rebased cleanly on upstream main.

✅ **review** - passed

✅ No issues found.

✅ **test** - passed
  • tests/fm-jev-guard.test.sh passed 100%
  • tests/fm-turnend-guard.test.sh passed 100%
✅ **document** - passed

✅ Documentation and docstrings preserved.

✅ **lint** - passed

✅ Clean under bin/fm-lint.sh.

✅ **push** - passed

✅ Pushed to fork branch fm/jev-delegation-guard.

Intercepts Bash tool calls in Firstmate's primary supervisor workspace (w1)
to enforce supervisor role boundaries dynamically without brittle regexes.

Features:
- Tier 1 (0ms, $0): Fast-path local allowlist for core supervisor tools
  (bd, tasks-axi, fm-send, fm-route, fm-wake-drain, git status/log, etc.)
  with compound command splitting to prevent sneaky chaining.
- Tier 2 (0ms, $0): Fast local SHA256 decision cache in /dev/shm.
- Tier 3 (<350ms): Jev System One (jev-latest) evaluates semantic intent,
  calculates violation noul, and routes to target Second Mate domain.
- Auto-Steer: Denials provide immediate suggested delegation commands.
- Worktree Inertia: Automatically inert in linked task worktrees.
- Multi-Harness: Registered in Pi, Claude, and Cursor pre-tool hooks.
…nesses

Extends PreToolUse Jev delegation guardrail coverage to every supported
primary harness:
- Codex: .codex/hooks.json
- Grok: .grok/hooks/fm-primary-jev-guard.json
- OpenCode: .opencode/plugins/fm-primary-jev-guard.js
- omp: .omp/extensions/fm-primary-turnend-guard.ts
- (Claude, Cursor, and Pi already wired in prior commit)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant