Skip to content

Agent Safety Architecture

LumenFlow enforces agent safety through 8 layered protection mechanisms working in a defense-in-depth model. No single layer provides complete coverage — understanding which layers apply to your agent client is essential for maintaining workflow integrity.

Layer 1: Tool-Level Bash Blocking (Claude Code)

Section titled “Layer 1: Tool-Level Bash Blocking (Claude Code)”

Intercepts Bash tool calls and blocks file-manipulation commands (cat >, echo >, sed -i, tee) that bypass Write/Edit tool validation.

  • Scope: Claude Code only
  • Enforcement: Fail-closed (blocks when uncertain)
  • File: .claude/hooks/block-bash-file-commands.sh

Layer 2: Worktree Path Validation (Claude Code)

Section titled “Layer 2: Worktree Path Validation (Claude Code)”

Intercepts Write and Edit tool calls and validates that target file paths are inside an active worktree or in the allowlist.

  • Scope: Claude Code only
  • Enforcement: Fail-closed
  • File: .claude/hooks/validate-worktree-path.sh

Runs before every git commit. Enforces format checking, blocks WU commits from main checkout, and validates commit messages.

  • Scope: All clients (universal, git-level)
  • Enforcement: Active
  • File: .husky/pre-commit.mjs

Runs before every git push. Validates branch naming, blocks force push to main, and ensures wu:done workflow compliance.

  • Scope: All clients (universal, git-level)
  • Enforcement: Active
  • File: .husky/pre-push.mjs

Wraps git and blocks destructive commands (reset --hard, clean -fd, push --force, worktree remove/prune).

  • Scope: Opt-in (recommended for Cursor)
  • Enforcement: Optional
  • File: scripts/safe-git

Workflow rules as markdown documents in .lumenflow/rules/.

  • Scope: Advisory (all clients)
  • Enforcement: None (depends on agent compliance)

Non-negotiable constraints in .lumenflow/constraints.md, injected into spawn prompts via wu:brief and wu:delegate.

  • Scope: All clients (injected for Claude Code spawns)
  • Enforcement: Soft (prompt-based)

Toggles in workspace.yaml for features like block_outside_worktree, require_wu_for_edits, and context_validation.

  • Scope: Varies by setting and client
  • Enforcement: Active for Claude Code, advisory for others
LayerMechanismClaude CodeCursorCodexWindsurfManual
1Bash blockingEnforced
2Path validationEnforced
3Pre-commit hookEnforcedEnforcedEnforcedEnforcedEnforced
4Pre-push hookEnforcedEnforcedEnforcedEnforcedEnforced
5Safe-git wrapperAvailableRecommendedAvailableAvailableAvailable
6Policy documentsAdvisoryAdvisoryAdvisoryAdvisoryAdvisory
7Constraints capsuleInjectedAdvisoryAdvisoryAdvisoryAdvisory
8Config enforcementEnforcedAdvisoryAdvisoryAdvisoryN/A

Legend: Enforced = actively blocks non-compliant operations. Recommended = configured but opt-in. Available = can be used. Advisory = documented policy only. Injected = included in spawn prompts. = not applicable.

Constraint 9: All YAML configuration files must be modified via CLI tooling only.

# Read a value
pnpm config:get --key software_delivery.methodology.testing

# Set a value (Zod-validated, atomic commit)
pnpm config:set --key software_delivery.methodology.testing --value test-after

# Set a boolean
pnpm config:set --key software_delivery.gates.enableCoverage --value false

Why CLI tooling:

  1. Schema validationconfig:set validates against the Zod schema before writing
  2. Atomic commits — Uses micro-worktree pattern for race-safe writes
  3. Audit trail — CLI commands produce structured log entries
  4. Type coercion — Automatic boolean, number, and array handling

Reading YAML files with Read tools is acceptable for inspection.

Claude Code has the strongest protection (Layers 1-8 all active).

# Generate enforcement hooks
pnpm lumenflow:integrate --client claude-code

Tool-level hooks block unsafe Bash commands and validate worktree paths. Constraints are injected into spawn prompts via wu:brief.

GapRiskDescriptionMitigation
YAML allowlistMediumPath validation allows raw YAML editsConstraint 9 policy; future hook enforcement
Non-Claude clientsHighNo tool-level enforcement for Cursor/Codex/WindsurfGit hooks + advisory docs
LUMENFLOW_FORCEMediumBypasses all hooks; logged but not alertedPolicy requires user approval; audit log
No branch protectionMediumAll enforcement is local hooks onlyFuture GitHub branch protection rules
Passive audit logsLowViolations logged but not monitoredLogs are git-tracked; future alerting