Add moving mob singleton audit cleanup - #227
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5be3e459dd
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Pull request overview
Adds moving-mob singleton audit/cleanup tooling and runtime safeguards to detect and prevent dryad/Zar (dragon) room-object drift, and surfaces diagnostics through admin endpoints and a CLI wrapper.
Changes:
- Introduces
kyrgame.moving_mobsaudit + confirmation-gated cleanup flow, plus a backend CLI (kyrgame.scripts.audit_moving_mobs) and repo-root wrapper (tools/mob_audit.py). - Hardens runtime movement: dryad re-anchors when tracker origin is missing and emits drift audit telemetry; Zar initialization/relocation clears stale dragons outside the active room.
- Extends
/admin/mobswith singleton diagnostics and blocks admin drops of singleton mob objects (45/52); adds focused tests.
Manual E2E Demo Checklist
- Run
python -m kyrgame.scripts.audit_moving_mobs audit --format tableand confirm dryad/Zar each showcopy_count=1andsingleton_status=ok. - Visit
/admin/mobsand confirm singleton fields (copy count, object_rooms, tracker_room_id, singleton_status) populate for dryad/Zar. - Attempt admin-drop of
dryad/ object45(and Zar/dragon52) and confirm it is rejected with guidance to use the audit/cleanup tool. - Wait through at least one dryad tick and one Zar relocation opportunity, then re-run audit to confirm no orphan copies appear.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/mob_audit.py | Adds repo-root wrapper that imports and runs the backend audit/cleanup CLI. |
| docs/PORTING_PLAN.md | Checks off the moving-mob singleton audit/cleanup work in the porting plan. |
| backend/tests/world/test_animation_tick_system.py | Adds coverage for dryad re-anchoring drift handling and stale-dragon removal during Zar init/relocation. |
| backend/tests/test_moving_mob_audit.py | Adds end-to-end tests for audit output, dry-run vs confirmed apply, and wrapper import behavior. |
| backend/tests/test_admin_endpoints.py | Extends /admin/mobs assertions for singleton diagnostics and verifies admin-drop rejection for singleton mobs. |
| backend/kyrgame/world/animation_tick_system.py | Implements dryad re-anchoring + drift audit events; adds Zar stale-dragon cleanup and room-id enumeration support. |
| backend/kyrgame/webapp.py | Replaces ad-hoc room scanning with moving_mobs audit for admin diagnostics; blocks singleton mob drops. |
| backend/kyrgame/scripts/audit_moving_mobs.py | Adds CLI entrypoint for audit and confirmation-gated cleanup with table/json output. |
| backend/kyrgame/runtime.py | Wires room-id enumeration into animation routines to support drift cleanup/hardening. |
| backend/kyrgame/moving_mobs.py | New audit/cleanup service defining singleton mob specs, proposed cleanup changes, and confirmation tokens. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3b894719cd
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 526b2c49d0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4b854d3ee9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c47061e390
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Summary
Adds guarded audit and cleanup tooling for moving mob singleton drift, then hardens dryad and Zar runtime movement so stale room-object copies do not accumulate again.
Changes
kyrgame.moving_mobsaudit/cleanup service for dryad object45, Zar/dragon object52, and tracker-only brownie/elf state./admin/mobswith backward-compatible singleton diagnostics.45and52.Motivation & Context
Intent
Admins need a safe way to inspect and repair moving mob singleton drift without racing the scheduler or manually editing room object arrays. Dryad had accumulated many persisted copies in live data, so this change adds explicit diagnostics, a confirmation-token cleanup flow, and runtime guards to prevent re-orphaning.
Context
legacy/KYRANIM.C.Legacy code being ported
legacy/KYRANIM.C—inianm,chkzar,rmvzar,pzinlc,dryadsbackend/kyrgame/world/animation_tick_system.py—ZarDragonRoutine,DryadWanderRoutinebackend/kyrgame/moving_mobs.py— audit and guarded cleanup servicebackend/kyrgame/scripts/audit_moving_mobs.py— backend CLItools/mob_audit.py— repo-root wrapperTesting
cd legacy && make -f ELWKYR(Worldgroup build).venv\Scripts\python.exe -m pytest backend\tests\test_moving_mob_audit.py backend\tests\world\test_animation_tick_system.py backend\tests\world\test_animation_tick_runtime_bridge.py backend\tests\test_runtime_tick_scheduler.py backend\tests\test_admin_endpoints.pycd backend && python -m kyrgame.scripts.package_content --output ../legacy/Dist/offline-content.json.venv\Scripts\python.exe tools\mob_audit.py --helpgit diff --checkDetails:
75 passed.copy_count=1, Zar/dragoncopy_count=1, both tracker-aligned withsingleton_status=ok..local-backups/postgres/kyrgame-local-20260622-120843.dump.local-backups/moving-mobs/audit-final-latest-20260622-121608.jsonManual E2E Demo Checklist
python -m kyrgame.scripts.audit_moving_mobs audit --format tableand confirm dryad/Zar each show one copy andok.dryador object45and confirm the request is rejected with guidance to use the audit/cleanup tool.Risk & Rollback
.local-backups/postgres/kyrgame-local-20260622-120843.dumpbackup if the cleanup needs to be undone.UI Changes