# PR-05e Assets Staged Mutations Preview and Apply

## Briefing

Implement the preview-first mutation flows for the `Assets` workspace.

This PR applies the staged mutation rules from:

- [`../specs/4. Assets Workspace Specification.md`](../specs/4.%20Assets%20Workspace%20Specification.md)

## Objective

Deliver inline staged mutation review for sensitive asset operations, including:

- preview generation
- blockers, warnings, and safe-fix separation
- registry vs workspace impact explanation
- apply gating
- activity integration for preview/apply lifecycle

## Dependencies

- [`./PR-05a-assets-workspace-foundation-and-service-state.md`](./PR-05a-assets-workspace-foundation-and-service-state.md)
- [`./PR-05c-selected-asset-details-contract-and-preview.md`](./PR-05c-selected-asset-details-contract-and-preview.md)
- [`./PR-05d-assets-activity-progress-and-logs-integration.md`](./PR-05d-assets-activity-progress-and-logs-integration.md)

## Scope

- implement inline staged review panel inside the `Assets` workspace
- support preview-first handling for:
  - `Adopt`
  - `Forget`
  - `Remove`
  - `Quarantine`
  - relocational mutations
  - batch mutations when available
- render proposed actions, blockers, warnings, safe fixes, and diff-style effects
- disable `Apply` while blockers exist
- use modal confirmation only for high-risk final commits

## Non-Goals

- no fully generic mutation framework for every Studio workspace
- no speculative batch authoring flows that do not yet exist in services

## Execution Method

1. Define the staged review panel and its state model.
2. Integrate preview requests and preview-ready responses from services.
3. Render registry impact and workspace impact separately.
4. Gate apply on blockers.
5. Wire `preview_ready`, `action_applied`, and `action_failed` into activity.
6. Add modal confirmation only where the final commit is high-risk.

## Acceptance Criteria

- sensitive asset mutations do not execute directly from a single click
- preview clearly shows what will change in registry and workspace
- blockers prevent apply
- safe fixes remain visually distinct from destructive actions
- preview/apply lifecycle events surface correctly in workspace and activity

## Validation

- unit tests for preview state mapping and apply gating
- unit tests for registry/workspace impact rendering rules
- UI smoke validation for staged mutation flows

## Affected Artifacts

- staged review panel
- asset mutation action wiring
- preview/apply state models
- activity integration for mutation lifecycle
- tests for preview and apply behavior
