fix(plugin): serialize project refresh mutations

This commit is contained in:
2026-08-27 21:42:33 +08:00
parent 405b9f64fd
commit e3e34d3803
3 changed files with 283 additions and 27 deletions

View File

@@ -0,0 +1,64 @@
# Task: Remediate accepted MakeLore ML-07 R3 finding
## Identity
- Task ID: 20260827-plugin-ml07-remediation-r3-7f4a2d91
- Mode: Feature
- Branch: codex/20260827-plugin-ml07-remediation-r3-7f4a2d91-plugin-ml07-remediation-r3
- Worktree: D:\Datas\OthersProjects\makelore-plugin-ml07-remediation-r3-7f4a2d91
- Base commit: 405b9f64fd6872f6b4bd4c4429e6aaff2fa0b84a
- Owner: ml07-remediator
- Status: Ready for Integration
## Scope
- Correct same-project load/mutation ordering in `src/stores/coding-plugins.ts` with one project-scoped operation epoch.
- Add focused red/green coverage in `tests/unit/coding-plugins-store.test.ts` for both load-before-mutation and refresh-during-mutation orderings, including every adjacent Data Service mutation path.
- Preserve the existing project A-to-B stale-response guards and avoid UI changes unless store correctness cannot stand alone.
## Intent And Constraints
- A successful mutation must be the latest authority for its project: an older or concurrently started read cannot overwrite it, and any required post-mutation reload must not coalesce with an invalidated read.
- Keep the existing store shape and dependency seams; do not add a new store layer, framework, or UI-only correctness guard.
- Work only in the fresh isolated task worktree from exact base `405b9f64fd6872f6b4bd4c4429e6aaff2fa0b84a`; do not touch root/coordinator worktrees, push, open a PR, or revert peers.
## Project Context Loaded
- Concurrent Task Gate and Planning Gate passed for this exact task ID, feature mode, branch, worktree, base, and owner.
- Read the memory index, project positioning, integrated current state, decision index, system overview, architecture/data-flow/domain/success criteria, ADR-006, evidence/reflection/commitment/stale indexes, coordinator record, and R3 reviewer records.
- Coordinator owns integration; R3 standards/spec tasks are read-only reviews at the same base. Other active tasks do not overlap these two owned files. Older planning-only reviewer records contain no competing semantic decision.
- Relevant boundary: project configuration and Plugin Center state remain local/project-scoped, while Pi/Main authority and plugin policy contracts are unchanged by this Renderer store ordering fix.
## Plan
1. Add red tests proving an older same-project load cannot overwrite a completed enable and that a refresh started during a delayed enable cannot suppress the successful mutation.
2. Add table coverage for configure, reset, remove-collection, and remove-project under the same delayed-mutation/refresh ordering.
3. Replace load-generation coupling inside same-project mutations with a project operation epoch: successful mutations advance the epoch; loads capture it; epoch-specific load coalescing permits required authoritative post-mutation reloads. Retain active-project checks and the global generation for A-to-B load selection.
4. Run the focused store tests, typecheck, scoped/full lint checks, drift gate, and return one clean commit with the exact sole parent.
## Outcome
- Added one project-scoped operation epoch to the existing store. Loads capture the current epoch and may commit only when both the global latest-load generation and their project epoch remain current.
- Successful enable/configure/reset/remove-collection/remove-project mutations advance the project epoch before committing. Same-project refresh no longer suppresses a mutation, while the latest requested project check retains the project A-to-B guard.
- Load flights use an epoch-specific internal key, so a required post-mutation authoritative load cannot coalesce with an invalidated older read. A small pending-key reference count preserves the existing public `load:<projectId>` contract while overlapping stale/current flights settle.
- Enable/reset commit their authoritative results directly; configure/remove-project trigger a new authoritative projection load; remove-collection commits successful inspection or triggers a fresh load when post-removal inspection fails.
- No Plugin Center UI change was needed: store correctness is independent of button disabling and existing page pending keys remain unchanged.
## Verification
- Initial red run: `coding-plugins-store` had 6 failures / 12 tests. An older load overwrote a completed enable; refresh during delayed enable suppressed the success; configure/remove-project skipped reload; reset/remove-collection skipped their commits.
- Additional red run: successful collection removal followed by failed inspection did not request an authoritative reload (1 failure / 13 tests).
- Green focused store run: 1 file / 13 tests passed.
- Expanded Renderer/plugin regression: `coding-plugins-store`, `coding-plugins-client`, `project-plugins-page`, and `data-service-plugin-settings` — 4 files / 22 tests passed.
- `corepack pnpm run typecheck` passed.
- Scoped ESLint for both changed product/test files passed with no output.
- `corepack pnpm run lint:check` passed.
- No build was run because no UI, Main, Preload, packaging import, or asset file changed; the coordinator will run the full integration ledger.
## Follow-ups
- Coordinator should rerun the full suite after integrating the sole remediation commit.
## Promotion Candidates
- None recorded.