Skip to content

hitl: named permission modes (Manual / Accept Edits / Locked) - #197

Merged
github-actions[bot] merged 1 commit into
mainfrom
hitl-named-permission-modes
Aug 3, 2026
Merged

github-actions[bot] merged 1 commit into
mainfrom
hitl-named-permission-modes

Conversation

@mohitranka

Copy link
Copy Markdown
Contributor

Summary

  • Phase 4, the final phase of the HITL/permission-model redesign (see docs/hitl-permission-model-research.md).
  • Adds forge_governance::PermissionMode (Manual, AcceptEdits, Locked) and Governance::apply_mode — a thin layer that pre-seeds hitl_classes/a new deny_unapproved fallback in place, never touching hitl_tools, the ACL, or loaded pattern rules from phases 2–3.
    • Manual: file writes ask for approval, same as shell commands.
    • Accept Edits: file writes run free; shell (and anything else gated) still asks.
    • Locked: for scripted/non-interactive runs — a gated call not covered by an explicit allow pattern is denied outright instead of prompting, since nothing can answer a prompt.
  • Deliberate behavior change, called out explicitly: Manual is stricter than the bare Governance::default() (which leaves hitl_classes empty, so writes are currently unguarded). A mode is an explicit, opt-in policy — the TUI applies Manual at session startup so the sidebar label and actual enforcement agree from the first frame, which means file writes now ask for approval by default in the TUI, where they previously didn't. Callers that never touch modes (e.g. tests constructing Governance::default() directly) are unaffected.
  • TUI wiring: Alt+P cycles the mode (AgentSession::apply_permission_mode mutates the session's live governance in place), shown in the sidebar under "Mode", confirmed via a feedback toast on change, documented in ? help and the README keybinding table.
  • docs/sandboxing-followup.md: the required note on what an OS-level sandboxing follow-up would need to hook into — explicitly out of scope per the brief, since it's the larger, separate effort that makes the rest of this redesign safe to loosen with confidence.

Test plan

  • cargo fmt --all -- --check
  • cargo clippy --workspace --all-targets --locked -- -D warnings
  • cargo test --workspace --all-targets --locked (0 failures across all 18 crates; 693 in forge-tui, 44 in forge-governance)
  • New tests: mode gating semantics + ACL/pattern-rule preservation across a mode switch + cycle order (forge-governance), keybinding mapping + end-to-end dispatch proving Locked mode actually denies through the real turn loop instead of pausing (forge-tui).

…ked)

Add PermissionMode::{Manual, AcceptEdits, Locked} and Governance::apply_mode,
a thin layer over hitl_classes/pattern rules (phases 2-3) rather than a new
authorization mechanism: a mode only pre-seeds hitl_classes and a new
deny_unapproved fallback, never touching hitl_tools, the ACL, or loaded
pattern rules.

- Manual: file writes ask for approval, same as shell commands.
- Accept Edits: file writes run free; shell still gated.
- Locked: for scripted/non-interactive runs — anything not covered by an
  explicit `allow` pattern is denied outright instead of prompting, since
  nothing can answer a prompt.

Note Manual is stricter than the bare `Governance::default()` (which leaves
hitl_classes empty) — a mode is an explicit, opt-in policy a session adopts,
distinct from the minimal library default any caller gets by not touching
modes at all. The TUI applies Manual at session startup so the footer label
and actual enforcement agree from the first frame; this is a deliberate,
documented behavior change (file writes now ask by default in the TUI,
where they didn't before).

Wired into forge-tui: Alt+P cycles the mode (AgentSession::apply_permission_mode
mutates governance in place), shown in the sidebar under Mode and confirmed
via feedback toast on change.

Phase 4 (final phase) of the HITL/permission-model redesign in
docs/hitl-permission-model-research.md. OS-level sandboxing was explicitly
out of scope per the brief; docs/sandboxing-followup.md notes what a
follow-up would need to hook into.
@github-actions
github-actions Bot enabled auto-merge (squash) August 3, 2026 07:43
@github-actions
github-actions Bot merged commit f8103ce into main Aug 3, 2026
7 checks passed
github-actions Bot pushed a commit that referenced this pull request Aug 3, 2026
…de (#198)

Two corrections to the just-merged permission-mode PR (#197), caught in
review before landing further work:

1. Manual mode was gating file writes by default (hitl_classes =
   [Write]). That's backwards for a coding agent whose core job is
   writing files — it would make every session nag constantly. Manual
   now matches today's actual default (writes free, only bash gated),
   as originally intended. Accept Edits currently behaves identically to
   Manual as a result, since Forge doesn't gate any other write-class
   tool by default; documented as such rather than papering over it.

2. Cut PermissionMode::Locked and Governance::deny_unapproved entirely.
   Locked's only reason to exist was CI/scripted runs where nothing can
   answer a prompt, but Forge has no non-interactive/headless entry
   point today — reachable only via Alt+P inside an interactive TUI
   session, which is a strange thing to want interactively. Re-add it
   once headless execution is real; docs/sandboxing-followup.md notes
   the dependency.

The mode cycle is now Manual <-> Accept Edits only.
mohitranka added a commit that referenced this pull request Aug 21, 2026
…ked) (#197)

Add PermissionMode::{Manual, AcceptEdits, Locked} and Governance::apply_mode,
a thin layer over hitl_classes/pattern rules (phases 2-3) rather than a new
authorization mechanism: a mode only pre-seeds hitl_classes and a new
deny_unapproved fallback, never touching hitl_tools, the ACL, or loaded
pattern rules.

- Manual: file writes ask for approval, same as shell commands.
- Accept Edits: file writes run free; shell still gated.
- Locked: for scripted/non-interactive runs — anything not covered by an
  explicit `allow` pattern is denied outright instead of prompting, since
  nothing can answer a prompt.

Note Manual is stricter than the bare `Governance::default()` (which leaves
hitl_classes empty) — a mode is an explicit, opt-in policy a session adopts,
distinct from the minimal library default any caller gets by not touching
modes at all. The TUI applies Manual at session startup so the footer label
and actual enforcement agree from the first frame; this is a deliberate,
documented behavior change (file writes now ask by default in the TUI,
where they didn't before).

Wired into forge-tui: Alt+P cycles the mode (AgentSession::apply_permission_mode
mutates governance in place), shown in the sidebar under Mode and confirmed
via feedback toast on change.

Phase 4 (final phase) of the HITL/permission-model redesign in
docs/hitl-permission-model-research.md. OS-level sandboxing was explicitly
out of scope per the brief; docs/sandboxing-followup.md notes what a
follow-up would need to hook into.
mohitranka added a commit that referenced this pull request Aug 21, 2026
…de (#198)

Two corrections to the just-merged permission-mode PR (#197), caught in
review before landing further work:

1. Manual mode was gating file writes by default (hitl_classes =
   [Write]). That's backwards for a coding agent whose core job is
   writing files — it would make every session nag constantly. Manual
   now matches today's actual default (writes free, only bash gated),
   as originally intended. Accept Edits currently behaves identically to
   Manual as a result, since Forge doesn't gate any other write-class
   tool by default; documented as such rather than papering over it.

2. Cut PermissionMode::Locked and Governance::deny_unapproved entirely.
   Locked's only reason to exist was CI/scripted runs where nothing can
   answer a prompt, but Forge has no non-interactive/headless entry
   point today — reachable only via Alt+P inside an interactive TUI
   session, which is a strange thing to want interactively. Re-add it
   once headless execution is real; docs/sandboxing-followup.md notes
   the dependency.

The mode cycle is now Manual <-> Accept Edits only.
mohitranka added a commit that referenced this pull request Sep 11, 2026
…ked) (#197)

Add PermissionMode::{Manual, AcceptEdits, Locked} and Governance::apply_mode,
a thin layer over hitl_classes/pattern rules (phases 2-3) rather than a new
authorization mechanism: a mode only pre-seeds hitl_classes and a new
deny_unapproved fallback, never touching hitl_tools, the ACL, or loaded
pattern rules.

- Manual: file writes ask for approval, same as shell commands.
- Accept Edits: file writes run free; shell still gated.
- Locked: for scripted/non-interactive runs — anything not covered by an
  explicit `allow` pattern is denied outright instead of prompting, since
  nothing can answer a prompt.

Note Manual is stricter than the bare `Governance::default()` (which leaves
hitl_classes empty) — a mode is an explicit, opt-in policy a session adopts,
distinct from the minimal library default any caller gets by not touching
modes at all. The TUI applies Manual at session startup so the footer label
and actual enforcement agree from the first frame; this is a deliberate,
documented behavior change (file writes now ask by default in the TUI,
where they didn't before).

Wired into forge-tui: Alt+P cycles the mode (AgentSession::apply_permission_mode
mutates governance in place), shown in the sidebar under Mode and confirmed
via feedback toast on change.

Phase 4 (final phase) of the HITL/permission-model redesign in
docs/hitl-permission-model-research.md. OS-level sandboxing was explicitly
out of scope per the brief; docs/sandboxing-followup.md notes what a
follow-up would need to hook into.
mohitranka added a commit that referenced this pull request Sep 11, 2026
…de (#198)

Two corrections to the just-merged permission-mode PR (#197), caught in
review before landing further work:

1. Manual mode was gating file writes by default (hitl_classes =
   [Write]). That's backwards for a coding agent whose core job is
   writing files — it would make every session nag constantly. Manual
   now matches today's actual default (writes free, only bash gated),
   as originally intended. Accept Edits currently behaves identically to
   Manual as a result, since Forge doesn't gate any other write-class
   tool by default; documented as such rather than papering over it.

2. Cut PermissionMode::Locked and Governance::deny_unapproved entirely.
   Locked's only reason to exist was CI/scripted runs where nothing can
   answer a prompt, but Forge has no non-interactive/headless entry
   point today — reachable only via Alt+P inside an interactive TUI
   session, which is a strange thing to want interactively. Re-add it
   once headless execution is real; docs/sandboxing-followup.md notes
   the dependency.

The mode cycle is now Manual <-> Accept Edits only.
mohitranka added a commit that referenced this pull request Sep 11, 2026
…ked) (#197)

Add PermissionMode::{Manual, AcceptEdits, Locked} and Governance::apply_mode,
a thin layer over hitl_classes/pattern rules (phases 2-3) rather than a new
authorization mechanism: a mode only pre-seeds hitl_classes and a new
deny_unapproved fallback, never touching hitl_tools, the ACL, or loaded
pattern rules.

- Manual: file writes ask for approval, same as shell commands.
- Accept Edits: file writes run free; shell still gated.
- Locked: for scripted/non-interactive runs — anything not covered by an
  explicit `allow` pattern is denied outright instead of prompting, since
  nothing can answer a prompt.

Note Manual is stricter than the bare `Governance::default()` (which leaves
hitl_classes empty) — a mode is an explicit, opt-in policy a session adopts,
distinct from the minimal library default any caller gets by not touching
modes at all. The TUI applies Manual at session startup so the footer label
and actual enforcement agree from the first frame; this is a deliberate,
documented behavior change (file writes now ask by default in the TUI,
where they didn't before).

Wired into forge-tui: Alt+P cycles the mode (AgentSession::apply_permission_mode
mutates governance in place), shown in the sidebar under Mode and confirmed
via feedback toast on change.

Phase 4 (final phase) of the HITL/permission-model redesign in
docs/hitl-permission-model-research.md. OS-level sandboxing was explicitly
out of scope per the brief; docs/sandboxing-followup.md notes what a
follow-up would need to hook into.
mohitranka added a commit that referenced this pull request Sep 11, 2026
…de (#198)

Two corrections to the just-merged permission-mode PR (#197), caught in
review before landing further work:

1. Manual mode was gating file writes by default (hitl_classes =
   [Write]). That's backwards for a coding agent whose core job is
   writing files — it would make every session nag constantly. Manual
   now matches today's actual default (writes free, only bash gated),
   as originally intended. Accept Edits currently behaves identically to
   Manual as a result, since Forge doesn't gate any other write-class
   tool by default; documented as such rather than papering over it.

2. Cut PermissionMode::Locked and Governance::deny_unapproved entirely.
   Locked's only reason to exist was CI/scripted runs where nothing can
   answer a prompt, but Forge has no non-interactive/headless entry
   point today — reachable only via Alt+P inside an interactive TUI
   session, which is a strange thing to want interactively. Re-add it
   once headless execution is real; docs/sandboxing-followup.md notes
   the dependency.

The mode cycle is now Manual <-> Accept Edits only.
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