AI Change Proposals & Human Approval Queue

phramecms/proposal (ProposalModule) lets AI agents prepare validated, diffed changes to sensitive configuration, content models, or content without holding live write permissions. Every staged change lands in the phrame_proposals queue and is applied live only after an authorized human reviewer approves it.

How propose.* Scopes Work

Granting an agent a propose.<permission> scope lets it simulate and stage an operation via proposal.create, while still denying direct live writes:

  1. When an actor calls proposal.create with a target operation and input, ProposalCreateOperation checks that the target operation:
    • is not itself a proposal.* operation (recursive proposals are forbidden),
    • declares mutatesState: true, and
    • declares supportsDryRun: true.
  2. If the calling actor holds any propose.* scopes, ProposalCreateOperation wraps the actor in PhrameCms\Proposal\Security\ProposalPreviewActor, which promotes propose.<perm> to <perm> exclusively for a single dryRun: true execution on OperationBus.
  3. OperationBus runs full policy checks, JSON Schema validation, and dry-run diff calculation against live state without persisting anything.
  4. ProposalCreateOperation persists a Proposal (prop_<hex>) with status: pending, the computed canonical diff, beforeHash, afterHash, reason, proposedBy, proposedByType, and onBehalfOf.

Security invariant: ProposalPreviewActor is never used during live execution (dryRun: false). When a human later calls proposal.approve, the target operation executes strictly under the approving reviewer's identity and live permissions — so an agent holding proposal.create and propose.* can neither bypass the queue nor self-approve.

Minting a Propose-Only AI Agent Token

Grant proposal.create, proposal.read, any needed read scopes, and only the exact propose.<perm> scopes the agent is allowed to stage (omit live write scopes and omit proposal.review):

bash
./bin/phrame site:install \
  --issue-agent-token \
  --agent-name=proposal-assistant \
  --agent-scopes='schema.read,config.admin.settings.read,proposal.create,proposal.read,propose.config.admin.settings.write,propose.schema.modify' \
  --json

Proposal Lifecycle & Operations

A proposal moves from pending (ProposalStatus::Pending) to one of three terminal states: approved, rejected, or cancelled.

Operation MCP Tool Required Permission Dry-Run Input Fields
proposal.create proposal_create proposal.create (+ target permission or propose.<perm> for dry-run) Yes operation (required), input (required object), reason (optional, max 1000 chars)
proposal.list proposal_list proposal.read No status (pending|approved|rejected|cancelled), operation, proposed_by, limit (1–200), offset
proposal.get proposal_get proposal.read No id (required)
proposal.approve proposal_approve proposal.review (+ target operation's live permissions) Yes id (required), review_note (optional), force (optional boolean, default false)
proposal.reject proposal_reject proposal.review No id (required), review_note (optional)
proposal.cancel proposal_cancel proposal.create (original proposer); proposal.create + proposal.review (cancelling another actor's proposal) No id (required), reason (optional)

MCP Resources for Agents

When ProposalModule is active and the agent holds proposal.read, ProposalResourceProvider exposes two read-only MCP resources:

  • phrame://proposals/pending — Pending proposals awaiting human review.
  • phrame://proposals/recent — Recent proposals across all statuses, including rejected proposals with human review_note feedback so agents can revise and resubmit.

Staging a Proposal Example

Over Streamable HTTP MCP (POST /mcp), an agent with proposal.create and propose.config.admin.settings.write stages a branding update:

bash
curl -fsS -X POST http://127.0.0.1:8080/mcp \
  -H "Authorization: Bearer <AGENT_TOKEN>" \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "tools/call",
    "params": {
      "name": "proposal_create",
      "arguments": {
        "operation": "config.set",
        "input": {
          "name": "admin.settings",
          "data": {
            "brand_name": "Acme CMS",
            "theme": "default"
          }
        },
        "reason": "Update Admin UI brand name for Q4 rebrand"
      }
    }
  }'

The same operation can be invoked from the CLI via ./bin/phrame op:run proposal.create.

Optimistic Concurrency (beforeHash)

When a proposal is created, ProposalCreateOperation stores the target's beforeHash returned by the dry-run simulation.

When a reviewer approves the proposal (proposal.approve):

  1. ProposalApproveOperation first re-runs the target operation in dryRun: true mode as the approving actor to verify live permissions and compute a fresh actual_before_hash and freshDiff.
  2. It compares actual_before_hash against the stored proposal.beforeHash:
    • If they match, the target operation executes live (dryRun: false) through OperationBus, recording both the live operation's audit entry and the proposal.approve audit entry with the same appliedCorrelationId.
    • If the underlying state changed while the proposal was waiting (stale: true) and force is false, ProposalApproveOperation aborts without mutating state and throws ProposalConflictException (rendered as HTTP 409 Conflict in /admin/proposals alongside the fresh diff).
    • Reviewers can pass dry_run: true to proposal.approve at any time to re-check staleness and inspect the fresh diff before deciding whether to approve, reject, or explicitly pass force: true.

Reviewing Proposals in /admin/proposals

Human administrators sign in to the Admin UI and open /admin/proposals (ProposalAdminController):

  • Queue view (GET /admin/proposals): Filter by status tab (pending, approved, rejected, cancelled, all) with live status counts and pagination.
  • Detail view (GET /admin/proposals/{id}): Inspect the target operation, canonical JSON input, stored diff, proposing agent display label, on_behalf_of human attribution, and beforeHash / afterHash.
  • Dry-run re-check & Approve (POST /admin/proposals/{id}/approve): Re-check the proposal against current state (dry_run), or apply live with an optional review_note. If a 409 Conflict occurs due to a stale beforeHash, the page renders the fresh diff against current state so the reviewer can confirm before choosing Force Approve & Apply (force=1).
  • Reject (POST /admin/proposals/{id}/reject): Mark the proposal rejected with an optional review_note that the proposing agent can read back via proposal.get or phrame://proposals/recent.