Files
DungeonCrawlerWorld/task-G4-report.md
T

2.9 KiB

G4 final — PresentationEvent immutability architecture

Scope

This final remediation changes only PresentationEvent, its focused unit coverage, and this report. No domain, gameplay, presentation routing, asset, or DCWASCII source was changed.

Architecture

PresentationEvent no longer declares any mutable instance backing field:

  • removed _backing_values and _is_initialized;
  • removed declared _source_event, _kind, _notification, and _accent properties;
  • records the complete captured event/presentation snapshot once in class-level _snapshots, keyed by get_instance_id();
  • exposes only getter APIs (source_event, kind, notification, and accent) from each instance;
  • deep-copies the source GameEvent at capture time and returns a new copy from source_event on every read.

The internal snapshot table is the sole data owner. No instance field can be changed after construction to alter the mapped result.

Legacy direct writes

Because GDScript permits direct writes to underscore-named members, _set explicitly absorbs every former mutable field name:

  • _kind
  • _source_event
  • _backing_values
  • _is_initialized
  • _notification
  • _accent

Those names are intentionally undeclared, so these writes create no per-instance state and never modify the frozen snapshot. The focused mapping test performs all four requested writes (_kind, _source_event, _backing_values, _is_initialized) and verifies the mapped kind, notification, accent, source event, and source payload are unchanged.

Store lifecycle

A RefCounted pre-delete notification was tested as a cleanup mechanism. Godot invokes it after the script instance is unavailable, producing Cannot call method 'get_instance_id' on a null value; it is therefore not viable or safe. The final store is intentionally process-lifetime and contains only captured presentation snapshots. This avoids teardown errors while preserving the required immutable instance architecture.

Verification

./scripts/verify.sh passed with Godot 4.5.0:

Suite Result
Unit 188 / 188 tests, 1,440 assertions
Integration 11 / 11 tests, 59,470 assertions
E2E 58 / 58 tests, 573 assertions
Visual structural capture passed

Visual metrics:

  • artifacts/visual-check.png: dungeon_non_black_pixels=489308, visible_pixels=17524, explored_pixels=10438, explored_luminance=0.012, unknown_pixels=365325, unknown_luminance=0.001.
  • artifacts/visual-check-exit.png: dungeon_non_black_pixels=489252, visible_pixels=17404, explored_pixels=17146, explored_luminance=0.012, unknown_pixels=439497, unknown_luminance=0.001.

The existing GUT invalid-UID and engine resource-cleanup diagnostics were emitted, but there were no project script errors, parse errors, test failures, or visual verification failures.

Delivery

A local commit is created for this final remediation. No push and no pull request are created.