[PR #4545] [MERGED] Hide generated World Maps directives from chat text #6417

Closed
opened 2026-10-23 04:10:13 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/4545
Author: @thetopham
Created: 8/4/2026
Status: ✅ Merged
Merged: 8/4/2026
Merged by: @thetopham

Base: staging ← Head: agent/4433-spatial-directive-cleanup


📝 Commits (4)

  • 9bb3995 fix(spatial): hide generated movement directives
  • d557ea7 fix(spatial): address review feedback
  • 95ebe4b fix: sanitize inline thinking replacements
  • e8e62c7 fix: sanitize spatial rewrite output

📊 Changes

3 files changed (+205 additions, -32 deletions)

View changed files

📝 packages/server/src/routes/generate.routes.ts (+52 -32)
📝 packages/server/src/services/spatial-context/state-resolution.ts (+66 -0)
📝 scripts/regressions/spatial-context.regression.ts (+87 -0)

📄 Description

Important

Contributions target staging. Only SpicyMarinara may promote this repository staging branch or a same-repository hotfix branch to main.

Linked issue

Closes #4433

Paired World Maps release: Pasta-Devs/Marinara-Agents#220

Why this change

  • World Maps movement directives could appear transiently while streaming and persist in user-visible messages generated by /impersonate.
  • Once persisted, the raw hidden directive was replayed in later prompt history, making the intermittent leak repeat.
  • Inline-thinking cleanup could emit an early content_replace before the same spatial sanitization ran.

What changed

  • Withhold complete spatial_move and spatial_discover directives from Roleplay and Game token streams.
  • Strip those directives from impersonated output before the generated user message is saved, while the queued movement still commits through the authoritative transition payload.
  • Preserve non-directive impersonated content byte-for-byte, including bracketed prose and surrounding/repeated newlines.
  • Accept whitespace-only line breaks immediately after a directive prefix without leaking the candidate stream.
  • Route inline-thinking cleanup through the consolidated post-processing replacement, after spatial sanitization.
  • Sanitize post-processing text rewrites before duplicate/protected-markup checks, persistence, rewrite metadata, and text_rewrite emission; directives introduced only by a rewrite are discarded and never applied.
  • Add regression coverage for split chunks, ordinary content preservation, and replacement event order.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Automated evidence:

  • pnpm regression:spatial passes at exact head e8e62c79d8f026f274117206ebb84d3f7630f6a7.
  • pnpm lint passes.
  • Exact committed pnpm build passes and embeds Engine commit e8e62c79d8f0.
  • Exact World Maps 1.3.1 artifact lifecycle passes against this head, including guided queue isolation, impersonate success/provider failure/stale rejection, restart, uninstall/reinstall, backup, and restore.
  • Earlier GitHub pnpm-validate and container-build-test checks passed; current-head checks remain authoritative in the checks tab.
  • The repository-level pnpm check wrapper still stops at the Impeccable wrapper's invalid nested-JSON report; its substantive regression, lint, localization, build, catalog, and lifecycle checks were run separately.

Review follow-up:

  • d557ea7dd preserves ordinary impersonated content and fixes whitespace-only directive-prefix streaming.
  • 95ebe4b51 prevents inline-thinking content_replace from preceding spatial sanitization.
  • e8e62c79d strips spatial directives introduced by post-processing text rewrites before persistence or emission.
  • Every current inline CodeRabbit thread was replied to and resolved without manually triggering another review.

Exact artifacts

  • Engine head: e8e62c79d8f026f274117206ebb84d3f7630f6a7
  • Client entry: assets/index-34m9qbDB.js
  • Compiled generate.routes.js SHA-256: e86efa97e00e55690e3e571393a41921a8c9180fb3467188543eec680893bc85
  • Paired World Maps head: c82af3fafb435a32b4a1cfd082fcbba01dd89057
  • World Maps ZIP SHA-256: 7c296732b9c4a1fd30f507794a3d96645d67378e14ef7ea156df41096fae614b
  • World Maps client SHA-256: cc74f11979213c6f6fed54db60493bd9b84e069082126865741afcdcdf1e5773
  • World Maps server SHA-256: ea0af5f7c206aff577db94a2ee854b21d79c2e79776bb74bcd70ceb4f512ee76

Local review installation

  • The exact Engine and World Maps files above are running in the locked local review environment at http://100.93.53.36:7860/.
  • marinara.service is active/running; /api/health reports Engine 2.4.1+e8e62c79d8f0 and World Maps 1.3.1 as active / ready with both server and client loaded.
  • Engine client/server dist directories match the exact PR worktree byte-for-byte. The served assets/index-34m9qbDB.js SHA-256 is 0d6c98fa66f0777f51b77b83fbb2a24e09ee93e3ef7f3582c069139ed889f424, matching the validated build.
  • World Maps was installed through the package manager as 1.3.1; the served client SHA-256 is cc74f11979213c6f6fed54db60493bd9b84e069082126865741afcdcdf1e5773, matching the installed and PR-head payloads. The active server payload matches ea0af5f7c206aff577db94a2ee854b21d79c2e79776bb74bcd70ceb4f512ee76.

Manual verification notes

  • Recheck ordinary Roleplay/Game generation, /guided, regeneration, continuation, and /impersonate with World Maps active.
  • Confirm no [spatial_move: ...] or [spatial_discover: ...] text appears while streaming, during inline-thinking replacement, or in the saved message.
  • Confirm a valid queued impersonate movement commits once while guided/regenerated/continued assistant turns do not consume it.
  • Confirm provider failure and stale movement leave recoverable review state without a phantom commit.
  • Confirm ordinary bracketed prose and its whitespace remain unchanged.
  • Confirm a post-processing text-rewrite agent cannot persist, emit, or apply a spatial directive it introduces.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Translated docs on the docs-i18n branch updated to match, or a docs-i18n follow-up issue opened
  • Version/release files updated (only if this PR includes a version bump)

UI evidence (if applicable)

  • The change is stream/persistence cleanup. Automated proof covers split-stream filtering, exact ordinary-content preservation, inline-thinking replacement order, and saved impersonate output.
  • Agent-operated desktop (1440x900) and mobile (390x844) Chromium smoke loaded the exact live build with a populated React root, no page exceptions, no failed requests, and no horizontal overflow. The visible 2.4.1 update dialog was correctly framed on both viewports.
  • The browser reported only the expected plain-HTTP COOP warning and an unrelated missing saved background (grassy dirt path, HTTP 404). User workflow verification remains separate and unchecked above.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/4545 **Author:** [@thetopham](https://github.com/thetopham) **Created:** 8/4/2026 **Status:** ✅ Merged **Merged:** 8/4/2026 **Merged by:** [@thetopham](https://github.com/thetopham) **Base:** `staging` ← **Head:** `agent/4433-spatial-directive-cleanup` --- ### 📝 Commits (4) - [`9bb3995`](https://github.com/Pasta-Devs/Marinara-Engine/commit/9bb3995f567fd7597c4488e113b0fe59a2ecaf39) fix(spatial): hide generated movement directives - [`d557ea7`](https://github.com/Pasta-Devs/Marinara-Engine/commit/d557ea7dd6ee9ce7c91cea823680d13a0a6bf29c) fix(spatial): address review feedback - [`95ebe4b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/95ebe4b51fc07355fb658c6edddb6c00a19f61fa) fix: sanitize inline thinking replacements - [`e8e62c7`](https://github.com/Pasta-Devs/Marinara-Engine/commit/e8e62c79d8f026f274117206ebb84d3f7630f6a7) fix: sanitize spatial rewrite output ### 📊 Changes **3 files changed** (+205 additions, -32 deletions) <details> <summary>View changed files</summary> 📝 `packages/server/src/routes/generate.routes.ts` (+52 -32) 📝 `packages/server/src/services/spatial-context/state-resolution.ts` (+66 -0) 📝 `scripts/regressions/spatial-context.regression.ts` (+87 -0) </details> ### 📄 Description > [!IMPORTANT] > Contributions target staging. Only SpicyMarinara may promote this repository staging branch or a same-repository hotfix branch to main. ## Linked issue Closes #4433 Paired World Maps release: Pasta-Devs/Marinara-Agents#220 ## Why this change - World Maps movement directives could appear transiently while streaming and persist in user-visible messages generated by `/impersonate`. - Once persisted, the raw hidden directive was replayed in later prompt history, making the intermittent leak repeat. - Inline-thinking cleanup could emit an early `content_replace` before the same spatial sanitization ran. ## What changed - Withhold complete `spatial_move` and `spatial_discover` directives from Roleplay and Game token streams. - Strip those directives from impersonated output before the generated user message is saved, while the queued movement still commits through the authoritative transition payload. - Preserve non-directive impersonated content byte-for-byte, including bracketed prose and surrounding/repeated newlines. - Accept whitespace-only line breaks immediately after a directive prefix without leaking the candidate stream. - Route inline-thinking cleanup through the consolidated post-processing replacement, after spatial sanitization. - Sanitize post-processing text rewrites before duplicate/protected-markup checks, persistence, rewrite metadata, and `text_rewrite` emission; directives introduced only by a rewrite are discarded and never applied. - Add regression coverage for split chunks, ordinary content preservation, and replacement event order. ## Validation - [x] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [x] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed CONTRIBUTING.md Automated evidence: - `pnpm regression:spatial` passes at exact head `e8e62c79d8f026f274117206ebb84d3f7630f6a7`. - `pnpm lint` passes. - Exact committed `pnpm build` passes and embeds Engine commit `e8e62c79d8f0`. - Exact World Maps 1.3.1 artifact lifecycle passes against this head, including guided queue isolation, impersonate success/provider failure/stale rejection, restart, uninstall/reinstall, backup, and restore. - Earlier GitHub `pnpm-validate` and `container-build-test` checks passed; current-head checks remain authoritative in the checks tab. - The repository-level `pnpm check` wrapper still stops at the Impeccable wrapper's invalid nested-JSON report; its substantive regression, lint, localization, build, catalog, and lifecycle checks were run separately. Review follow-up: - `d557ea7dd` preserves ordinary impersonated content and fixes whitespace-only directive-prefix streaming. - `95ebe4b51` prevents inline-thinking `content_replace` from preceding spatial sanitization. - `e8e62c79d` strips spatial directives introduced by post-processing text rewrites before persistence or emission. - Every current inline CodeRabbit thread was replied to and resolved without manually triggering another review. ### Exact artifacts - Engine head: `e8e62c79d8f026f274117206ebb84d3f7630f6a7` - Client entry: `assets/index-34m9qbDB.js` - Compiled `generate.routes.js` SHA-256: `e86efa97e00e55690e3e571393a41921a8c9180fb3467188543eec680893bc85` - Paired World Maps head: `c82af3fafb435a32b4a1cfd082fcbba01dd89057` - World Maps ZIP SHA-256: `7c296732b9c4a1fd30f507794a3d96645d67378e14ef7ea156df41096fae614b` - World Maps client SHA-256: `cc74f11979213c6f6fed54db60493bd9b84e069082126865741afcdcdf1e5773` - World Maps server SHA-256: `ea0af5f7c206aff577db94a2ee854b21d79c2e79776bb74bcd70ceb4f512ee76` ### Local review installation - The exact Engine and World Maps files above are running in the locked local review environment at `http://100.93.53.36:7860/`. - `marinara.service` is active/running; `/api/health` reports Engine `2.4.1+e8e62c79d8f0` and World Maps `1.3.1` as `active` / `ready` with both server and client loaded. - Engine client/server dist directories match the exact PR worktree byte-for-byte. The served `assets/index-34m9qbDB.js` SHA-256 is `0d6c98fa66f0777f51b77b83fbb2a24e09ee93e3ef7f3582c069139ed889f424`, matching the validated build. - World Maps was installed through the package manager as `1.3.1`; the served client SHA-256 is `cc74f11979213c6f6fed54db60493bd9b84e069082126865741afcdcdf1e5773`, matching the installed and PR-head payloads. The active server payload matches `ea0af5f7c206aff577db94a2ee854b21d79c2e79776bb74bcd70ceb4f512ee76`. ### Manual verification notes - Recheck ordinary Roleplay/Game generation, `/guided`, regeneration, continuation, and `/impersonate` with World Maps active. - Confirm no `[spatial_move: ...]` or `[spatial_discover: ...]` text appears while streaming, during inline-thinking replacement, or in the saved message. - Confirm a valid queued impersonate movement commits once while guided/regenerated/continued assistant turns do not consume it. - Confirm provider failure and stale movement leave recoverable review state without a phantom commit. - Confirm ordinary bracketed prose and its whitespace remain unchanged. - Confirm a post-processing text-rewrite agent cannot persist, emit, or apply a spatial directive it introduces. ## Docs and release impact - [x] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Translated docs on the docs-i18n branch updated to match, or a docs-i18n follow-up issue opened - [ ] Version/release files updated (only if this PR includes a version bump) ## UI evidence (if applicable) - The change is stream/persistence cleanup. Automated proof covers split-stream filtering, exact ordinary-content preservation, inline-thinking replacement order, and saved impersonate output. - Agent-operated desktop (1440x900) and mobile (390x844) Chromium smoke loaded the exact live build with a populated React root, no page exceptions, no failed requests, and no horizontal overflow. The visible 2.4.1 update dialog was correctly framed on both viewports. - The browser reported only the expected plain-HTTP COOP warning and an unrelated missing saved background (`grassy dirt path`, HTTP 404). User workflow verification remains separate and unchecked above. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:10:13 +07:00
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-Engine#6417
No description provided.