# Story-Level Backlog

## Epic A: Persistence and Lifecycle

## Story A1: Proposal and Event Persistence Baseline

Description:
- Ensure proposal and proposal-events persistence are migration-safe and queryable.

Acceptance Criteria:
1. Proposal and event tables migrate up/down in dev
2. Required indexes exist and are used in key queries
3. Referential integrity between proposals and events is valid

Estimate:
- 3 points

Dependencies:
- None

## Story A2: Lifecycle Transition Service

Description:
- Implement service-level transition rules and event append.

Acceptance Criteria:
1. Allowed transitions succeed
2. Disallowed transitions fail with explicit errors
3. Every successful transition writes lifecycle event

Estimate:
- 5 points

Dependencies:
- Story A1

## Epic B: API and Security

## Story B1: Proposal Create and Fetch APIs

Acceptance Criteria:
1. Create endpoint stores proposal and initial event
2. Get endpoint returns proposal + validation status + status

Estimate:
- 3 points

Dependencies:
- Story A2

## Story B2: Approve and Reject APIs

Acceptance Criteria:
1. Approval enforces validation pass
2. Reject captures reason in event payload
3. Authz rules enforced

Estimate:
- 5 points

Dependencies:
- Story B1

## Story B3: Feature Flags and RBAC Guards

Acceptance Criteria:
1. Proposal APIs disabled when flag off
2. Non-admin users blocked for privileged actions

Estimate:
- 3 points

Dependencies:
- Story B1

## Epic C: Normalizer and Validator

## Story C1: Normalizer v1

Acceptance Criteria:
1. Maps raw graph to canonical canvas shape
2. Node and edge enum checks enforced
3. Deterministic ids generated where missing

Estimate:
- 8 points

Dependencies:
- Story B1

## Story C2: Validator and Policy Gate v1

Acceptance Criteria:
1. Structural validation checks acyclic and required path constraints
2. Policy validation checks adapter allow-list and timeout bounds
3. Validation result persisted in proposal

Estimate:
- 8 points

Dependencies:
- Story C1

## Epic D: Flow Builder Integration

## Story D1: Open Proposal into Existing Draft Flow

Acceptance Criteria:
1. Approved proposal opens into current draft flow
2. Existing save and publish behavior remains unchanged

Estimate:
- 5 points

Dependencies:
- Story C2

## Story D2: Proposal Review Surface (Minimal)

Acceptance Criteria:
1. Proposal status and validation summary visible
2. Warning and error details visible before actions

Estimate:
- 3 points

Dependencies:
- Story D1

## Epic E: Observability and Quality

## Story E1: Lifecycle Telemetry

Acceptance Criteria:
1. Generated, approved, rejected, opened events emitted
2. Event metadata includes proposal_id and actor_id

Estimate:
- 3 points

Dependencies:
- Story B2

## Story E2: Regression Safety Pack

Acceptance Criteria:
1. Existing manual flow save and publish tests pass
2. Proposal path tests pass
3. Release checklist completed

Estimate:
- 5 points

Dependencies:
- Stories B2, C2, D1

## Total Estimated Points (Initial)

- 51 points

## Suggested In-Sprint Cut Line (1 week)

Primary (must):
1. A1, A2, B1, B2, C1, D1, E2

Secondary (if capacity):
1. B3, C2, D2, E1
