Skip to content

Remove every pointer to an entity from its location - #72

Merged
dmccoystephenson merged 2 commits into
masterfrom
feature/remove-every-matching-pointer
Nov 5, 2026
Merged

dmccoystephenson merged 2 commits into
masterfrom
feature/remove-every-matching-pointer

Conversation

@dmccoystephenson

@dmccoystephenson dmccoystephenson commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Location::removeEntity now erases every pointer whose id matches, instead of only the first. Grid::removeEntity, Environment::removeEntity, and the move methods all go through it, so an entity added twice to one location is fully removed and a move leaves a single pointer at the destination.
  • Test 66 previously pinned the leftover pointer. It now asserts the fixed result, and its function is renamed to match. Tests 69-71 are added.
  • The README paragraph that described the old behaviour is rewritten.

Design choice

The issue offered two options. The fix was placed in Location::removeEntity rather than in a repeat loop in Grid::removeEntity, so that a direct Location::removeEntity call gets the same guarantee: the entity is no longer present afterwards.

One consequence: because matching is by id, a distinct same-id twin stored in that location is erased too, and the twin keeps its ids. That agrees with the README's "Entity Identity" section, which treats such objects as the same entity, and it is pinned by Test 71.

Test plan

  • CI "Library tests" failed on the tests-only commit a3463cd, aborting on the Test 66 assertion at src/tests.cpp:1100 (exit 134)
  • CI "Library tests" passed on the fix commit 0d69d11, with 71 of 71 registered tests reporting success
  • Strata frontend and browser build jobs passed on the fix commit
  • run_tests_asan.sh was not run: CI has no AddressSanitizer job, and local execution is denied. The change erases vector elements and alters no allocation or object lifetime.

Local execution of tests_executable is denied in this session, so CI is the test anchor.

Closes #70

This PR description was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).

🤖 Generated with Claude Code


drafted by Claude on behalf of Daniel Stephenson

dmccoystephenson and others added 2 commits November 5, 2026 02:33
Test 66 pinned the leftover pointer as a known quirk; it now asserts the
intended result, and Tests 69-71 cover ordering, moves, and same-id twins.
These fail until the fix lands, which records the red half of the
regression check on CI.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Location::removeEntity stopped at the first id match, so an entity added
twice to one location stayed present with its ids already reset, and a
directional move then threw on location id "N/S". Erase every match
instead, which also leaves a single pointer after a move.

Closes #70

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dmccoystephenson

Copy link
Copy Markdown
Member Author

Self-review rubric (head 0d69d11):

  • Scope: PASS — the diff touches only src/location.cpp, src/tests.cpp, and README.md, each needed for Environment::removeEntity leaves an entity present when it was added twice to one location #70.
  • Tests-new: PASS — no public method was added; the changed behaviour is covered by Tests 66, 69, 70, and 71.
  • Tests-fix: PASS, with a limit — a local stash-and-run is denied, so the check was done on CI: the tests-only commit a3463cd aborted at src/tests.cpp:1100 and the fix commit passed. The abort stopped the run at Test 66, so Tests 69-71 were observed passing with the fix but were not individually observed failing without it.
  • Sibling structure: PASS — new tests follow the existing void test<Behavior>() and Test N - ... --- Success pattern. No new files.
  • Sibling renames: PASS — the only rename is the Test 66 function, which has no parallel sibling.
  • Docs: PASS — the README "Removal takes out..." paragraph was rewritten, and the class table is unaffected.
  • Issue resolution: PASS — Environment::removeEntity leaves an entity present when it was added twice to one location #70's named surface is fixed at its root, and both reported symptoms (the leftover pointer on removal, and the double storage after moveEntityToNewLocation) are asserted by Tests 66 and 70.
  • Local test suite: PASS via CI — Library tests (make + CMake) reported 71 successes against 71 registered tests. The Strata and browser jobs are also green.
  • Header/definition parity: PASS — no header changed.
  • Include guards: PASS — no new header.
  • Test registration: PASS — all three new tests are called from main(), and the count of 71 matches.

Judgment call flagged: this is a behaviour change for same-id twins stored in one location. Previously only the first match was erased; now both are, and the twin keeps stale ids. This is consistent with the README's id-matching rule and is pinned by Test 71, so it was not treated as blocking.

src/location.cpp:33 — the [entity] capture dereferences the caller's pointer on every comparison, which is safe because remove_if moves pointers only and never destroys an Entity.

Gap: run_tests_asan.sh was not run, since CI has no AddressSanitizer job and local execution is denied. The change affects no allocation or object lifetime, so that script's expectation does not apply here.

This comment was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).


drafted by Claude on behalf of Daniel Stephenson

@dmccoystephenson

Copy link
Copy Markdown
Member Author

Correction to the self-review above: the remove_if note belongs at src/location.cpp:36, not src/location.cpp:33. The rubric results are unchanged.

This comment was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).


drafted by Claude on behalf of Daniel Stephenson

@dmccoystephenson
dmccoystephenson merged commit e5dc5f1 into master Nov 5, 2026
3 checks passed
@dmccoystephenson
dmccoystephenson deleted the feature/remove-every-matching-pointer branch November 5, 2026 09:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Environment::removeEntity leaves an entity present when it was added twice to one location

1 participant