Back to article list

Phase 5 Complete: FSM Persistence Refactor & E2E Test Verification

2 min read

Technical Changes at a Glance

This commit completes Phase 5 of the FSM refactor, with the following core changes:

  • E2E Test Coverage: 20 new integration tests covering IssueFSM/PRFSM paths, cross-machine coordination, state recovery, etc.
  • Persistence Paradigm Shift: Replace JSON file persistence with FSM database hydration
  • State Authority Transfer: FSM database becomes the single source of truth; Map objects demoted to in-memory cache
// Core change: restore state from DB on startup
const hydrated = await this.issueFsmDb.getAllStates();
for (const [issue, state] of hydrated) {
  this.issueFsmEngine.forceState(issue, state.state, "hydration", state.context);
}

Reflection: Is This "Phased Big Bang" Refactoring Approach Really Reasonable?

Snarky Take: Here we go again—Phase 1 → Phase 5. Last FSM architecture refactor also had "5 phases," each promised to be the "final step." Surprise: we ended up in the same loop.

1. Naming Deception

"Phase 5" sounds like the finish line, but the designer knew from day one there'd be Phase 6, 7, N. This isn't agile iteration—it's chronic technical debt accumulation disguised as evolution.

2. Tests as Security Blanket Illusion

Added 52 tests (32 unit + 20 E2E) and now claiming "verified"? Test coverage has never equal correctness. Using test count as KPI is the easiest form of self-deception.

3. Hidden Costs of Persistence Refactor

Swapping JSON files for SQLite looks elegant, but:

  • What's the rollback plan during migration?
  • Did you handle historical data compatibility?
  • Any performance benchmarks?

None of these show up in commit messages.


The Real Challenges Ahead

  1. State Migration Gray Release: How to gradually switch in production?
  2. Observability: FSM state transitions need Tracing
  3. Rollback Mechanism: DB rollback is far more complex than file rollback

Code's done. The battle just started.


This is the 6th post in the FSM Refactor series; see Phase 1-4 Review

Found this helpful? Buy me a coffee

If this article was helpful, consider supporting continued content creation.

WeChat
WeChat
Alipay
Alipay

评论