huskies: merge 919

This commit is contained in:
dave
2026-05-13 06:22:22 +00:00
parent 9ce5a8df0c
commit 09a8edc0a1
7 changed files with 146 additions and 48 deletions
+16 -14
View File
@@ -1,22 +1,24 @@
# Plan: Story 945 — Delete WorkItem flag soup
Goal: Fold `blocked`, `review_hold`, `frozen`, and `mergemaster_attempted`
flag fields into `Stage` / `ArchiveReason` / `ExecutionState` variants so the
typed state machine is the single source of truth.
# Plan: Story 919
## ACs → implementation locations
- AC 1 (delete flag fields): `server/src/crdt_state/types.rs` (PipelineItemCrdt, WorkItem) — DONE; `server/src/pipeline_state/types.rs` (PipelineItem) — DONE.
- AC 2 (variants + `match`-based callers): New variants `Stage::MergeFailureFinal`, `Stage::Frozen { resume_to }`, `Stage::ReviewHold { resume_to, reason }` in `pipeline_state/types.rs` — DONE. Auto-assigner, watchdog, unblock/freeze/unfreeze, merge pipeline all `match` on Stage — DONE.
- AC 3 (no Option<bool> flag-poking): grep for `set_blocked|set_review_hold|set_frozen|set_mergemaster_attempted` returns no results — DONE.
- AC 4 (cargo check/clippy/test pass): `run_check` clean, `run_tests` reports 2908 passed / 0 failed — DONE.
- AC 1 (`MergeFailure + Unblock → Merge`): `server/src/pipeline_state/transition.rs:295` — change `Ok(Coding)` to `Ok(Merge { feature_branch, commits_ahead })`. Also requires adding `feature_branch: BranchName` and `commits_ahead: NonZeroU32` to `Stage::MergeFailure` in `server/src/pipeline_state/types.rs:113`, and carrying those fields through the `Merge → MergeFailure` transition at `transition.rs:200`.
- AC 2 (`Coding (blocked) + Unblock → Coding` unchanged): `server/src/pipeline_state/transition.rs:289``(Blocked { .. }, Unblock) => Ok(Coding)` already correct; no change needed.
- AC 3 (regression test): `server/src/pipeline_state/tests.rs` — add `merge_failure_unblock_returns_to_merge` CRDT-based test.
## Decisions
- Resume target for `Frozen`/`ReviewHold`: stored as a sibling `resume_to: LwwRegisterCrdt<String>` on `PipelineItemCrdt` rather than encoded into the stage string. Rejected: encoding into stage register (would require parsing variants out of strings and lose round-trip cleanness).
- Reason text for `Blocked`/`MergeFailure`/`MergeFailureFinal`/`ReviewHold`: kept on the Stage variant in memory, but the wire-form stage register only carries the canonical dir name (`"merge_failure_final"`, `"review_hold"`). Reasons are reconstructed at read time from companion CRDT data (MergeJob.error) where needed. Acceptable because reason is human-text, not load-bearing for routing.
- Pre-934 `7_frozen` legacy migration: rewrites stage to `"frozen"` and sets `resume_to = "backlog"`, restoring `Stage::Frozen { resume_to: Backlog }` on read. The defensive projection fallback still maps raw `7_frozen``Backlog` for un-migrated reads.
- Add `feature_branch` and `commits_ahead` to `MergeFailure` (rather than use synthetic defaults in the transition): allows the exact merge state to be restored on Unblock. Rejected: synthetic values at transition time (would require story_id not available in the transition function, or use a placeholder that loses the real branch name).
- Update all `Stage::MergeFailure { reason }` construction sites to include the new fields with synthetic defaults where real values are unavailable (CRDT read, `from_dir`, migration).
## Current state
All flag fields removed; all 47 modified files compile; 2908 tests pass; doc coverage clean.
Not started — fresh session.
## What's left
- [x] Commit changes
- [ ] Add `feature_branch: BranchName` and `commits_ahead: NonZeroU32` to `Stage::MergeFailure` in `types.rs`
- [ ] Update `types.rs` `from_dir` construction of `MergeFailure`
- [ ] Update `transition.rs`: carry fields in `Merge → MergeFailure`, self-loop, fix `MergeFailure + Unblock → Merge`
- [ ] Update `crdt_state/read.rs` `MergeFailure` construction
- [ ] Update `crdt_state/write/migrations.rs` `MergeFailure` construction
- [ ] Update `tests.rs`: all `Stage::MergeFailure { .. }` constructions, rename+fix unblock test
- [ ] Add CRDT-based regression test (AC3)
- [ ] Run run_check, fix any clippy/fmt issues
- [ ] Run run_tests, commit