# Lifecycle Phase 3 Audit

## Scope

Phase 3 persists delivery assessment separately from verification status and migrates legacy rows that stored no-change outcomes in `verify_status`.

Files reviewed:

- `src/types/delivery.rs`
- `src/types/status.rs`
- `src/types/task.rs`
- `src/store/schema.rs`
- `src/store/mutations.rs`
- `src/store/queries/`
- `src/cmd/run_lifecycle.rs`
- `src/cmd/run_post.rs`
- `src/cmd/show*`
- `src/cmd/board*`
- `src/web/api.rs`
- related task fixtures and tests

## Verdict

Approve with repository-level audit blocker noted.

The slice resolves the structural status-model issue: `verify_status` now represents verification only, while `delivery_assessment` carries empty-diff and hollow-output outcomes. Runtime writers no longer store delivery outcomes in `verify_status`, and legacy rows are normalized by migration.

## Findings

### No blocking findings in the slice

- `Task` now has `delivery_assessment: Option<DeliveryAssessment>` and renderers consume that field.
- SQLite schema, inserts, waiting-task replacement, row mapping, and query projections include `delivery_assessment`.
- Legacy `verify_status IN ('empty_diff', 'hollow_output')` values are copied to `delivery_assessment` and then normalized to `skipped`.
- `VerifyStatus::EmptyDiff` and `VerifyStatus::HollowOutput` were removed to prevent future semantic drift.
- Empty-diff and hollow-output runtime paths now call `Store::update_delivery_assessment`.
- Web JSON exposes `pending_reason` and `delivery_assessment` when the `web` feature is enabled.

## Follow-Up

### Generated audit artifacts remain untracked

The `.aic/` directory is generated by audit runs and should not be committed as part of this slice unless the project decides to version audit reports.

### Existing repo-wide audit blocker

`aic audit --diff /tmp/phase3-delivery-persistence.diff` was blocked by the repository's existing `cargo clippy -- -D warnings` failure:

- `src/agent/gemini_support.rs` is loaded as a module multiple times through `src/agent/gemini.rs`.

## Evidence

- `cargo test delivery_assessment -- --nocapture`
- `cargo test insert_and_update_task_persists_delivery_assessment -- --nocapture`
- `cargo test migrate_moves_legacy_delivery_status_out_of_verify_status -- --nocapture`
- `cargo test migrate_adds_repo_path_column -- --nocapture`
- `cargo test list_running_filter -- --nocapture`
- `cargo test --features web task_response_serializes_delivery_assessment -- --nocapture`
- `cargo test audit_ -- --nocapture`
- `cargo test final_assertion -- --nocapture`
- `rg -n "VerifyStatus::EmptyDiff|VerifyStatus::HollowOutput" src tests -g '*.rs'`
- `rg -n "audit_report_path$|audit_report_path\\s*$" src/store/queries -g '*.rs'`
- `git diff --check`
- `aic audit --diff /tmp/phase3-delivery-persistence.diff`:
  - blocked by existing `cargo clippy -- -D warnings` failure
