refactor(bootstrap): split XC_Bootstrap into an injectable BootKernel pipeline

Replace the fully-static XC_Bootstrap god-class with a stage pipeline so the boot
logic becomes unit-testable and the per-context sequences are explicit.

- BootState replaces the 8 static readiness flags with a value object threaded
  through the pipeline; stages read/write it instead of static state.
- BootStageInterface + BootPipeline run an ordered stage list and abort loudly
  on a throwing stage.
- 16 stages under Core/Bootstrap/Stage/ hold one subsystem each, extracted
  verbatim from the old private methods (constants, config, flood, host, session,
  database, legacy core, redis, process title, admin API, translator, admin
  shutdown, status constants, admin globals, container populate, health check).
- StageProfiles builds the ordered list per context, mirroring the exact previous
  sequence; BootKernel resolves options, sets up the container and runs it.
- XC_Bootstrap is now a thin BC facade delegating to BootKernel; its getters read
  the returned BootState. reset() also clears EventDispatcher and the new
  DatabaseFactory::reset() (a side-effect-free registry clear for test isolation).

The DB-touching contexts (Cli/Stream/Admin) still require a live MySQL and the
xcvm_core extension, so they are verified on a canary rather than in CI; the
Minimal context and the pipeline/profile composition are covered by new tests.
This commit is contained in:
Divarion_D
2026-09-16 16:58:49 +03:00
parent 45b82938a0
commit e1bb80672e
25 changed files with 1213 additions and 589 deletions
@@ -65,4 +65,15 @@ class DatabaseFactory {
}
self::$instance = null;
}
/**
* Clears the singleton registry without closing the connection.
*
* Test seam for deterministic per-test state: unlike close(), it does not
* touch the global $db or call close_mysql(), so it is safe with the fake
* DatabaseHandler subtypes tests inject.
*/
public static function reset(): void {
self::$instance = null;
}
}