Skip to content

backends: enforce the policy's command deny and confirm rules and keep each block in the session's governance record #1661

Closed

Description

@schlessera

Guardrail class: G1 (system integrity), for commands the user rules out. Ruling 4 on #1636 asks for a command and tool audit with policy-based blocks.

Context

Delivered prerequisite outputs: #1651. Their output references remain relevant, but they are no longer active blockers.

Decision: docs/decisions/governed-writable-workers.md ("Tool and command audit").

  • Every tool call's input is already recorded as an Activity span event ("tool_input", packages/ui-server/src/activity/recorder.ts:268), and span detail is pruned after 7 days.
  • Confirmation patterns already raise an approval card in the mutating hook (const mutatingHook, packages/ui-backend-claude/src/permission-hooks.ts:235).
  • Pi decides in the server (decideToolPermission, packages/ui-backend-pi/src/worker-session.ts:297).

Scope

  • commands.deny from the policy refuses a matching Bash input in both adapters, before execution. The refusal names the policy rule and its reason.
  • commands.confirm is added to the compiled confirmation patterns for the turn.
  • Each deny and each confirmation decision writes a governance event (policy_block / policy_confirm) with the input, the rule and the attribution. It is retained with the session.
  • The capabilities note lists the active deny and confirm patterns.

Out of scope

  • Outward-action classification (G5 sibling).
  • A command allowlist mode.

Acceptance criteria

  • With deny: ^git push (-f|--force), a turn's git push --force is refused in both adapters, and nothing executes. A test asserts this with a fake git on the path that would record the run.
  • A confirm pattern raises the existing card, and declining it refuses the command.
  • Both cases produce governance events that survive the span-detail prune.
  • Mutation receipt: skip the deny check in one adapter and its test fails.

Verification

Backend tests for both adapters, then bun run check:pr --base origin/main.

Contract impact

Additive minor: server-only BackendActivityEvent observations policy_block and policy_confirm feed the existing retained governance-event kinds. No new client frame, accepted policy key, CLI envelope field or execution authority. Update the package contract and API report in the implementation PR.

Blocked by #1650

Updated 2026-10-12: removed completed blocker declarations, retained delivered-output context and all remaining prerequisites; readiness and existing rulings preserved.

Updated 2026-10-12: verified current policy-reader candidate 2ff55fffe and refreshed the moved Activity and pi permission anchors; scope, acceptance criteria and #1650 dependency remain unchanged.

Activity

  1. added
    type: feat
    area: ui-server
    area: backends
    priority: p1
    agent-ready
    blocked
    on Oct 11, 2026
  2. added this to the 0.42.0 milestone on Oct 12, 2026
  3. self-assigned this
    on Oct 12, 2026
  4. schlessera commented on Oct 12, 2026

    @schlessera
    OwnerAuthor

    Claim: commands-1661-20261012-78381f66; branch feat/1661-policy-commands-78381f66. Coordinated implementation stacks on the immutable policy-reader candidate 2ff55fffe80a56fb0cbc8971ecf4d8a43d4925e8 from #1741. Existing #1650 dependency and blocked label remain until prerequisite merge. Scope is deny/confirm enforcement for actual Bash inputs in both adapters, existing approval authority/cards, retained governance records and active-pattern capability disclosure. Milestone: 0.42.0; any initial PR remains draft with Refs.

  5. schlessera commented on Oct 12, 2026

    @schlessera
    OwnerAuthor

    2026-10-12 source correction: verified immutable policy-reader candidate 2ff55ff. Activity tool_input now starts at recorder.ts:268 and the pi server permission decision at worker-session.ts:297; folded these moved anchors into the body. Existing scope, acceptance criteria and Blocked by #1650 remain intact.

  6. schlessera commented on Oct 12, 2026

    @schlessera
    OwnerAuthor

    Unblocked: #1650 is closed, so scripts/sync-project.ts is removing the blocked label.

  7. removed
    blocked
    on Oct 12, 2026
  8. schlessera commented on Oct 12, 2026

    @schlessera
    OwnerAuthor

    Merged in #1747 for milestone 0.42.0. Squash 52cbd1db182b618706cd7edca72159ba62768a63 is present on main; its parent is 966bed83 and its tree exactly matches the verified candidate. The bounded journal, confirmed next-turn profile preferences and captured command policy are delivered; the diagnosed Search opening-focus fix is included.

    All 14 selected jobs passed in PR CI run38306139332, attempt1. Each actual job checked out a45084c02c8e1986aeaeca75d3ad8c553eeb37d9, with verified main/head parents and tree. Behavioral mutations, real worker/browser receipts and preflight are recorded in the PR. All 14 selected main-push CI jobs also passed. Every actual job checkout was verified as squash 52cbd1db182b618706cd7edca72159ba62768a63.

    Completing issues and PR are closed/merged with milestone0.42.0 read back. Coordinator claims for this delivery are released. Remaining programme work stays with its own issues; this is not a release publication or whole-programme completion claim.

  9. removed their assignment
    on Oct 12, 2026
  10. removed
    agent-ready
    on Oct 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: backendsarea: ui-serverpriority: p1type: feat

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions