diff --git a/docs/superpowers/specs/2026-04-30-pz-analysers-design.md b/docs/superpowers/specs/2026-04-30-pz-analysers-design.md new file mode 100644 index 0000000..705db3c --- /dev/null +++ b/docs/superpowers/specs/2026-04-30-pz-analysers-design.md @@ -0,0 +1,121 @@ +# ProjectZomboid analyser design (Phase B.1) + +## Summary + +Implement the three top-priority ServerLog analysers — engine version, mod load order plus missing-mod problems, and server exception coalescing — by adding five Insight classes that plug into the framework's existing `PatternAnalyser`. Wire `ProjectZomboidServerLog::getDefaultAnalyser()` to return a configured `PatternAnalyser` carrying all four insight classes (`ModMissingSolution` is a Solution attached to `ModMissingProblem`, not a separately registered insight). + +This document covers Phase B.1. Phase B.2 (PvpDamageAnalyser and AdminAuditAnalyser) ships separately and gets its own spec. + +## Scope + +- **In scope:** All work needed to make `(new ProjectZomboidServerLog())->setLogFile(path)->parse()->analyse()` return an `Analysis` populated with engine-version information, mod-load information, missing-mod problems with attached solutions, and server-exception problems coalesced by exception type. +- **Out of scope (B.1):** PvP damage, admin audit, codex-side redaction, custom Solution wording for `ServerExceptionProblem`, Hytale/Minecraft/SevenDaysToDie analysers, the empty `src/Analyser/ProjectZomboid/.gitkeep` placeholder. + +## Architectural decision: no Analyser subclasses + +The original Step-D plan called for a custom `ServerExceptionAnalyser` subclass to capture the tab-indented stack-trace lines that follow each `ERROR` header. On a closer reading of the framework, this is unnecessary: + +- `Entry::__toString()` joins all of an entry's `Line`s with `\n`. +- `PatternAnalyser::analyseEntry()` calls `preg_match_all($pattern, $entry, ...)` against the stringified entry. +- A regex with the `s` flag captures across the embedded newlines and grabs the stack body in the same match. + +The single `PatternAnalyser` instance configured with multiple insight classes covers all three analysers. No subclassing required. + +## Components + +All under `src/Analysis/ProjectZomboid/`: + +| Class | Type | Purpose | Coalescing | +|---|---|---|---| +| `EngineVersionInformation` | Information | Capture `version=X.Y.Z