[GH-ISSUE #178] [Issue]: World Maps API can permanently delete active locations #90

Closed
opened 2026-10-20 17:24:16 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @thetopham on GitHub (Aug 1, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Agents/issues/178

Originally assigned to: @thetopham on GitHub.

Summary

World Maps 1.2.5 added permanent deletion for archived locations, but the server update path does not enforce the archived-only precondition. A caller can submit a valid replacement definition that omits an active, otherwise-unreferenced location, and the server permanently deletes it.

The editor UI blocks this path, but the package API is the final data-integrity boundary and currently accepts it. The same omission is still present on current staging / World Maps 1.2.6.

Affected package

World Maps (hierarchical-maps) 1.2.5 and current 1.2.6 staging source.

Expected behavior

  • Every removed location must have been archived before it can be permanently deleted.
  • A PUT /api/chats/:chatId/spatial-context request that omits any previously active location should return 409 with a stable deletion-forbidden error.
  • Existing starting/current/history/Game-binding/shared-world protections should continue to apply after the archived-only check.
  • API regression coverage should include both a permitted archived removal and a rejected active removal.

Actual behavior

definition.service.ts computes removedLocations, then rejects only locations protected by shared-world linkage, starting/current identity, message history, or Game map bindings. It never rejects removedLocations.some(location => location.status !== "archived").

That means an active location which is not the starting/current location and has no history or Game binding is accepted as permanently removed. This contradicts the 1.2.5 editor contract and allows irreversible map data loss if another client path, package integration, or crafted request bypasses the UI check.

Steps to reproduce

  1. Create an independent World Map with active locations A and B.
  2. Keep A as the starting and current location; ensure B has no message-history snapshot or Game map binding.
  3. Read the current definition and revision.
  4. Send PUT /api/chats/:chatId/spatial-context with the expected revision/current location and a definition whose locations array omits active location B (and removes any links to it).
  5. Observe a successful response and that B is permanently absent.
  6. Expected: 409 spatial_history_location_removal_forbidden (or a dedicated stable code) explaining that locations must be archived before permanent deletion.

Environment

  • Marinara Engine version: Package declares support from 2.3.5 through below 3.0.0
  • Package version: World Maps 1.2.5; confirmed still present in current 1.2.6 staging source
  • Install type: Source review / exact merged package source
  • OS + version: N/A
  • Browser or app shell: N/A; server API invariant

Logs, screenshots, or video

No runtime log is required to locate the invariant gap. Source evidence:

  • PR #164 merged source: definition.service.ts lines 409-452 computes removed locations and protection references but has no archived-status check.
  • The lifecycle regression covers successful removal of an archived unreferenced location and rejection of a history-protected location, but has no negative case for removal of an active unreferenced location.
  • The client editor does contain the missing check, confirming the intended behavior, but that validation is not repeated at the server boundary.

Additional context

  • Introduced with the guarded permanent-deletion work in #164, which closed #159.
  • CodeRabbit also identified this as an outside-diff finding in its final review body, but it was not represented by a review thread and the merged head did not address it.
  • Keep the fix package-owned in Marinara-Agents and rebuild client.js, server.mjs, manifest hashes, the ZIP, and every catalog lane together.

Suggested focused regression: start with two active unreferenced locations, omit the non-current/non-starting one through the API, assert 409, then archive it and assert the otherwise-identical removal succeeds.

Template check

  • I DID NOT read this template and provide the requested details.
Originally created by @thetopham on GitHub (Aug 1, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Agents/issues/178 Originally assigned to: @thetopham on GitHub. ## Summary World Maps 1.2.5 added permanent deletion for archived locations, but the server update path does not enforce the archived-only precondition. A caller can submit a valid replacement definition that omits an active, otherwise-unreferenced location, and the server permanently deletes it. The editor UI blocks this path, but the package API is the final data-integrity boundary and currently accepts it. The same omission is still present on current `staging` / World Maps 1.2.6. ## Affected package World Maps (`hierarchical-maps`) 1.2.5 and current 1.2.6 staging source. ## Expected behavior - Every removed location must have been archived before it can be permanently deleted. - A `PUT /api/chats/:chatId/spatial-context` request that omits any previously active location should return `409` with a stable deletion-forbidden error. - Existing starting/current/history/Game-binding/shared-world protections should continue to apply after the archived-only check. - API regression coverage should include both a permitted archived removal and a rejected active removal. ## Actual behavior `definition.service.ts` computes `removedLocations`, then rejects only locations protected by shared-world linkage, starting/current identity, message history, or Game map bindings. It never rejects `removedLocations.some(location => location.status !== "archived")`. That means an active location which is not the starting/current location and has no history or Game binding is accepted as permanently removed. This contradicts the 1.2.5 editor contract and allows irreversible map data loss if another client path, package integration, or crafted request bypasses the UI check. ## Steps to reproduce 1. Create an independent World Map with active locations `A` and `B`. 2. Keep `A` as the starting and current location; ensure `B` has no message-history snapshot or Game map binding. 3. Read the current definition and revision. 4. Send `PUT /api/chats/:chatId/spatial-context` with the expected revision/current location and a definition whose `locations` array omits active location `B` (and removes any links to it). 5. Observe a successful response and that `B` is permanently absent. 6. Expected: `409 spatial_history_location_removal_forbidden` (or a dedicated stable code) explaining that locations must be archived before permanent deletion. ## Environment - Marinara Engine version: Package declares support from 2.3.5 through below 3.0.0 - Package version: World Maps 1.2.5; confirmed still present in current 1.2.6 staging source - Install type: Source review / exact merged package source - OS + version: N/A - Browser or app shell: N/A; server API invariant ## Logs, screenshots, or video No runtime log is required to locate the invariant gap. Source evidence: - PR #164 merged source: `definition.service.ts` lines 409-452 computes removed locations and protection references but has no archived-status check. - The lifecycle regression covers successful removal of an archived unreferenced location and rejection of a history-protected location, but has no negative case for removal of an active unreferenced location. - The client editor does contain the missing check, confirming the intended behavior, but that validation is not repeated at the server boundary. ## Additional context - Introduced with the guarded permanent-deletion work in #164, which closed #159. - CodeRabbit also identified this as an outside-diff finding in its final review body, but it was not represented by a review thread and the merged head did not address it. - Keep the fix package-owned in Marinara-Agents and rebuild `client.js`, `server.mjs`, manifest hashes, the ZIP, and every catalog lane together. Suggested focused regression: start with two active unreferenced locations, omit the non-current/non-starting one through the API, assert `409`, then archive it and assert the otherwise-identical removal succeeds. ## Template check - [ ] I DID NOT read this template and provide the requested details.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Agents#90
No description provided.