Generated page · the analysis is hand-written
Chaos Hockey cover art
last updated 2026-11-08

Systems Map

The major systems, how they actually talk to each other, and where the cost is. The Code Inventory lists every class; this page is the argument about how they fit together — which is the thing you cannot scrape.

Program flow

Launch to a running match. Each arrow is a real scene change or a real call, not an abstraction.

CharacterSelectScene pick or create a profile │ DrillSession.Player = profile → ProfileActivation.Activate ▼ ModeSelectScene Vision Training, or Chaos │ ├──────────────► DrillSelectionScene ──► VisionTrainingScene │ pick a drill, DrillHost owns the run: │ difficulty, length ready gate → countdown → play → results ▼ MatchSetupScene periods and length → MatchSetup.Request(...) │ ▼ main.tscn the rink │ ├─ PlayerMain._Ready binds the active profile, builds every player-facing screen ├─ MatchFlowManager StartMatch → MatchClock ticks while State == Playing ├─ TeamTacticalManager rebuilds a per-team snapshot; picks ONE active puck ├─ AITeamCoordinator turns the snapshot into per-player assignments └─ AIPlayer × N resolves a movement target, then an offensive action

How the systems are wired together

Four mechanisms carry almost all the coupling in this codebase. Knowing which one a dependency uses tells you most of what you need to know about it.

MechanismReachWhat it means in practice
GameServices 29 services
103 files
A static service locator. Nearly every system reaches nearly every other through it, which makes the dependency graph almost fully connected on paper and very hard to reason about. Its saving grace is that every access is null-checked, so a missing service degrades rather than crashes — the same instinct that makes the AI coordinator optional.
Static session state DrillSession
MatchSetup
Carries choices across scene changes, where nothing else survives. This is the single most bug-prone mechanism in the project: it has caused a dead Escape key in Chaos mode and a dead D-pad, both because a static outlived the scene that set it and nothing clears it. MatchSetup is the corrected pattern — it is consumed, so it cannot leak into a later match.
Scene-tree scans GetNodesInGroup
21 call sites
How pucks and players are found. Four of those sites sit inside per-frame methods. Correct, and the reason several "which puck?" bugs were possible — scene-tree order is not a gameplay rule, and until recently pickup and steal both treated it as one.
Polled input Input.IsActionPressed Distinct from Godot's event pipeline, and the distinction has bitten twice. SetInputAsHandled() stops an event propagating and does nothing to a poll, which is why the pause panel flickered open and closed on one press.
Pure model plus thin adapter the newest
and the least coupled
A Godot-free class holds the rule or the arithmetic and is unit tested directly; a small partial or helper turns engine state into its inputs. PuckTouchHistory/Puck_TouchHistory, PlayEventRecord/BasicPlayer_PlayEvents, IcingRule/MatchFlowManager_RulesWatch and RinkZones/RinkZoneLocator are all this shape. It is the best mechanism here and it carries the project's worst failure mode, which is the next section — the adapter is the part nothing tests, and when it is simply missing the model is perfect, green and dead.

The failure mode this codebase actually has

Seven instances, and the only reason the seventh was found is that somebody happened to grep. This section is judgement rather than measurement, which is why it lives on this page.

The shape is always the same. A model is written, documented and unit tested. It is correct. Nothing calls it. The suite is green the entire time, because a test that calls a model cannot detect that nothing else does.

The instances, in order of discovery: the aiming reticle (17 passing tests, never added to the scene); the aiming system itself (untriggerable, because two actions shared a mouse button); three stray pucks in the scene silently disqualifying pass receivers; three game modes no player could select; a toggle_scoring_heatmap action that existed in the Input Map while the code read the raw keycode; the Energy Shield's IPuckReflector (one implementor, zero consumers — still open); and on 2026-10-02 the whole zone and rules layer, where RinkZones, OffsideRule, OffsideScenarioCatalog, IcingRule and StoppageRules were all unreachable at once.

Two defences exist and neither is sufficient. The verification page tracks "built" separately from "seen working", which is the right distinction and caught several of these — but it is a page of judgements, and it missed the seventh, because the entries for offside and icing were written by the same session that failed to notice they had no caller. ModelsAreWiredTests asserts the absence of a caller for specifically named models, which works and is a list rather than a rule: a list only ever contains what somebody already suspected.

It now exists, and it found eight more. This paragraph used to end "what would actually catch it is mechanical and does not exist" — written on 2026-10-02 and built the same day. SourceReachability builds a mention graph over every .cs file, treats a file as a root if it touches Godot (the engine is what runs) or belongs to DataExport (which produces this website), and reports every Godot-free type no root can reach. Tests are not roots, and that is the entire point: being called only by the suite is precisely the defect.

Three cheaper versions were measured and rejected, and the numbers are the argument: counting unreferenced types flagged 42 of 382, mostly data carriers reached through their container; counting uncalled static methods flagged 114, mostly one unused helper beside a used one; types whose whole static surface is uncalled flagged 15, about half of them factories invoked by reflection. None would have caught the real thing, because the dead set was a mutually-referencing cluster — OffsideRule mentioned RinkZones, OffsideScenarioCatalog mentioned OffsideRule. All five were "mentioned somewhere". What was true of every one is that nothing engine-facing mentioned any of them.

The first run found 26 unreachable types across 18 subsystems, several of which the roadmap calls built. The worst was BadgeEvaluator: Ch.30 PR-13 describes it as built with 24 tests, this site generates its badge table from the catalogue beside it, and nothing called it — so no badge had ever been awarded. That was the eighth instance, and it was wired up the same hour. Also found: a four-type formula subsystem with no consumer, AbilityCooldownTracker (Ch.25a GA-10 is "Cooldowns"), SharePolicy and ShareSummary (Ch.30 PR-14 calls them built), and the AI's entire ability-decision model — which is directly relevant to the AI skill-use work that was deferred, since it turns out to be already modelled and merely unwired.

It is a ratchet rather than a zero, deliberately and uncomfortably. Fixing eighteen subsystems is not one sitting's work, and a check that failed until they were all done would be switched off within a day — which is how the project arrived here. So the floor stops it getting worse, the list is written out as the agenda rather than hidden in a number, and a test asserts the written list and the scan agree in both directions. Wiring one up forces the list to be edited, which is the only way a written list stays true — and it fired on the first try: wiring the badges made the count fall, and the reverse ratchet refused to let the floor stay at 26. The remaining 23 are tracked.

The honest caveat, unchanged from when this was only a proposal: it needs an allow-list for models deliberately ahead of their callers, and an allow-list is a list again. The difference is that it is a list of exceptions rather than a list of suspicions — a new unreachable model has to be added to it by somebody, which is the point. It is also conservative by construction: it matches type names as whole words in comment-stripped source, so it under-reports dead code and never invents it.

Where the cost is

Measured — the heat-map grid rebuild

The one place with real numbers, from a performance audit recorded in the source and in git. ScoringOpportunityManager rebuilds a grid of the whole ice, and each rebuild does multi-ray raycasts per goal per cell plus O(cells × players) defender-distance checks.

The debounce (SpatialRebuildDelay, 0.01s in main.tscn) essentially never completes during live play — ten moving skaters and a puck keep crossing grid cells — so the hard cap MaximumRebuildDelay is the real governor. It was firing at 0.35s: a full rebuild ~2.86 times a second, continuously. Raised to 0.5s for a ~30% cut, changing cadence only — no ray count, cell size or scoring weight was touched.

This system already instruments itself: LastRebuildMilliseconds, RebuildCount and MergedRebuildRequestCount are live counters. It is the only system that can currently answer a performance question with data.

Measured — allocation, not frequency, is what hurts

Found on 2026-09-24 and worth repeating because it generalises: the expensive mistake in a per-frame HUD update is not the update count, it is what the update allocates. An AddThemeStyleboxOverride handed a freshly constructed StyleBoxFlat every frame is sixty throwaway Godot Resources a second to recolour one bar. Cache per state, write only on change, gate the redraw.

Optimisation candidates

These are candidates, not findings. They are reasoned from the code, and none has been profiled. Calling any of them "the bottleneck" without measuring would repeat a mistake this project has already paid for — a rendering bug that took eleven rounds because each round measured a hypothesis instead of the symptom.

1. Pass analysis is recomputed per carrier, per throttle tick

Every candidate receiver gets a lane evaluation, and LaneEvaluator fires a fan of rays per candidate. With a full roster that is rays × receivers × carriers. A deliberately-deferred caching fix for this is recorded in git — deferred because caching a pass target would make an in-flight pass aim at a frozen position, which is a correctness change rather than a tuning one. Any fix here must not freeze the target.

2. Per-frame scene-tree scans

Four GetNodesInGroup call sites are inside per-frame methods, and each walks every puck in the scene. Cheap with one puck; Mayhem allows a hundred. The puck list changes rarely compared to how often it is read, which is the classic shape for a cached, invalidated collection.

3. Fifty-four per-frame entry points

24 _PhysicsProcess and 30 _Process implementations. Many are throttled already — RefreshGate, DecisionInterval and MaximumRebuildDelay appear across 24 sites — but the coverage is uneven, and the project's own UI-08 milestone records that older readouts were never migrated onto the gate.

4. AI tactical rebuild for a single puck

Not a cost problem today — it is a cost problem waiting. The tactical snapshot is rebuilt per team on a cadence for one puck (see Chapter 32). Making the AI see all twenty would multiply that work, so the fix and the optimisation have to be designed together rather than in sequence.

What would settle this

Godot's Performance singleton, logging frame time and allocations per session, charted on the dashboard. It is on the roadmap and not started. Until it exists, the heat-map rebuild is the only cost anybody can speak about with evidence, and everything above it on this page is an argument rather than a measurement.