Skip to content

feat(cli): E6 approval gates — Approver trait, glob allowlist, interactive CLI - #21

Merged
ajianaz merged 1 commit into
developfrom
feat/e6-approval-cli
Aug 27, 2026
Merged

ajianaz merged 1 commit into
developfrom
feat/e6-approval-cli

Conversation

@ajianaz

@ajianaz ajianaz commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

What

  • Core Approver trait (tole-core/src/approval.rs): policy engine decoupled from hosts — decide(&ToolRequest) -> Verdict + interactive() marker. AllowlistApprover now implements it with glob patterns (glob_match, no new deps) and enforces the PRD rule: Destructive is always Deny regardless of pattern ("cannot be allowlisted").
  • Structural Destructive rule (tole-core/src/tool.rs): ToolRegistry refuses to register a Destructive tool behind a non-interactive approver — wiring-time enforcement instead of runtime hope.
  • CLI host (tole-cli): clap with run/resume/status subcommands and --sessions-dir. InteractiveApprover prompts y/N over stdio (injectable PromptFn for tests): Destructive always prompts; --allow <glob> and --yes only ever cover Write risk.
  • write_file tool (Write risk) jailed to the cwd: per-component parent walk that refuses symlinked components (via symlink_metadata), O_NOFOLLOW leaf open via libc — TOCTOU-safe against symlink escapes.

Why

E6 (issue #6, Phase 2 W4) ships the approval-gate UX: the CLI is the first real consumer of tole-core and needs to gate Write/Destructive tools on human y/N per call, with a limited-automatic mode (--allow globs) for trusted workflows. The PRD risk table mandates Destructive can never be auto-allowed, so the enforcement lives in three layers (trait contract, allowlist deny, interactive prompt) instead of one hope-based check.

Testing

  • cargo test --workspace: 77/77 passing (was 71) — 6 new integration tests in crates/tole-cli/tests/approval_flow.rs over the real turn loop + JSONL storage:
    • write → prompted → denied → tool NOT executed + durable approval required record
    • write → prompted → allowed → file written, loop continues to Final
    • --allow write_* skips the prompt entirely (denying canned human never asked)
    • Destructive prompts despite --allow '*' + --yes
    • registry refuses Destructive behind AllowlistApprover at wiring time
    • ToolRequest carries tool/risk/input/description for the prompt
  • cargo clippy --workspace --all-targets: 0 warnings
  • cargo fmt: clean
  • cora review on the branch diff: No issues found (2 MAJOR fixed pre-commit: TOCTOU path-jail hardening, libc::O_NOFOLLOW per-platform constant)

…ctive CLI

Core:
- Add `Approver` trait (decide per tool/risk/input, interactive marker)
- `AllowlistApprover`: glob patterns, always Deny for Destructive
- `ToolRegistry`: holds `Box<dyn Approver>`; refuses Destructive
  registration behind a non-interactive approver (structural rule)
- `Tool::describe()` for human-readable approval prompts
- `Risk::as_str` public for prompt labels

CLI:
- clap host: run/resume/status subcommands, --sessions-dir
- `InteractiveApprover` (y/N over stdio, injectable PromptFn):
  Destructive always prompts; --allow glob and --yes cover Write only
- `write_file` tool (Write risk) jailed to cwd: per-component parent
  walk refusing symlinks, O_NOFOLLOW leaf open via libc (TOCTOU-safe)

Tests: 77 passing (6 new approval-flow e2e over the real turn loop:
denied/allowed/pattern-skip/destructive-always-prompts/registry-
refusal/prompt-fields), clippy clean
@github-actions

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

@ajianaz
ajianaz merged commit 6f3ed42 into develop Aug 27, 2026
11 checks passed
@ajianaz
ajianaz deleted the feat/e6-approval-cli branch August 27, 2026 00:19
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