cmvr-wms/ruoyi-project/docs/stage-execution-graph-plan.md

61 lines
3.4 KiB
Markdown
Raw Normal View History

# Stage Execution Graph Implementation Plan
> **For agentic workers:** Implement task-by-task in this session; each task includes a meaningful verification step.
**Goal:** Turn the collaboration stage view into an editable execution graph whose stage predecessors gate work item starts.
**Architecture:** Store stage links explicitly, load them into the same project-locked business graph as work items and task dependencies, and compute stage readiness from current state. Vue Flow renders these links and submits manager drag/drop and connection actions to the backend.
**Tech Stack:** Spring Boot, MyBatis, MySQL, Vue 3, TypeScript, Vue Flow, JUnit, Vitest.
**Spec:** `ruoyi-project/docs/stage-execution-graph-spec.md`
## Global Constraints
- Frontend files stay under `ruoyi-ui-vue3/src/views/project/manage`.
- Backend files and SQL stay under `ruoyi-project`.
- Project-level database lock guards every graph mutation and start.
- New and modified methods receive concise Chinese design comments.
## Review Focus
- Empty intermediate stage cannot bypass an unfinished ancestor; cover with rules test.
- Adding an unfinished item upstream cannot newly invalidate an already started successor; cover with real database test.
- Cross-stage task dependency cannot create an execution deadlock; cover with graph test.
- Two concurrent link additions cannot commit a cycle; cover with real database test.
- Browser positions remain local while stage links are shared; cover with frontend test.
### Task 1: Persistence and graph rules
**Files:** `src/main/resources/db/007_stage_execution_graph.sql`, `domain/StageLink.java`, `domain/Graph.java`, `mapper/PmStageMapper.java` and XML, `service/support/PmGraphService.java`, `rule/PmStageRules.java`, rules tests (all under `ruoyi-project`).
- [ ] Write failing graph tests for completion, ancestor gate, cycles and regression.
- [ ] Add schema and migration from adjacent sort-order levels.
- [ ] Load explicit stage links and names into the transaction graph.
- [ ] Implement stage readiness, combined cycle detection and regression validation.
- [ ] Run focused JUnit tests.
### Task 2: Transactional service and API
**Files:** `PmStageServiceImpl`, `IPmStageService`, `PmStageController`, `PmServiceImpl`, DTOs, real database tests (under `ruoyi-project`).
- [ ] Write failing integration tests for CRUD, gating, rollback, assignment, concurrency and permission.
- [ ] Add manager-only link create/delete under project lock, versioning, audit and outbox.
- [ ] Apply stage checks to start and graph-affecting writes, preserving grandfathered starts.
- [ ] Return stage blockers and links in existing API snapshots.
- [ ] Apply migration to the permitted development database and run integration tests.
### Task 3: Canvas interactions
**Files:** `WorkFlow.vue`, `FlowStageNode.vue`, `StageManager.vue`, `flow.ts`, `api.ts`, `types.ts`, frontend tests (under `ruoyi-ui-vue3/src/views/project/manage`).
- [ ] Update failing flow tests to expect explicit links and graph-based layout.
- [ ] Render a draggable stage palette, name dialog, connect/disconnect controls and backend error feedback.
- [ ] Display stage completion and blockers while preserving local layout preferences and task cards.
- [ ] Run Vitest, Vue type check and production build.
### Task 4: Final verification
- [ ] Review requirement/spec/code/comments/tests for drift.
- [ ] Record actual test results, migration/start commands and known limits in delivery report.