# Feature Specification: Backup Version Reuse (016)

**Feature Branch**: `016-backup-version-reuse`
**Created**: 2026-01-02
**Status**: Draft

## User Scenarios & Testing

### User Story 1 — Avoid unnecessary version growth (Priority: P1)
As an admin, I want adding policies to a backup set to reuse an existing recent policy version when safe, so backups don’t create redundant versions and operations stay fast.

**Acceptance Scenarios**
1. Given a policy already has an identical captured snapshot, when I add it to a backup set, then the backup item links to the existing version (no new version is created).
2. Given a policy has no suitable version, when I add it to a backup set, then a new version is captured and linked.

## Requirements

### Functional Requirements
- **FR-001**: Adding policies to a backup set SHOULD avoid creating redundant `PolicyVersion` records by reusing an existing version when the captured snapshot is unchanged.
- **FR-002**: If reuse is not safe/possible, the system MUST capture a new `PolicyVersion` as it does today.
- **FR-003**: Reuse MUST respect capture options:
  - If assignments are requested, the reused version must include assignments.
  - If scope tags are requested, the reused version must include scope tags.
- **FR-005**: Adding a policy to a backup set MUST capture from Intune to ensure the backup reflects the current state.
- **FR-004**: Behavior changes MUST be covered by automated tests.

## Success Criteria
- **SC-001**: Backups avoid creating redundant policy versions in the common case.
- **SC-002**: Backup correctness is preserved (no missing required data for restore/preview).
