[PR #1604] [MERGED] fix(maps): use the chat's agent reference lorebook #1599

Closed
opened 2026-10-24 04:02:31 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Agents/pull/1604
Author: @SpicyMarinara
Created: 10/23/2026
Status: ✅ Merged
Merged: 10/23/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/maps-agent-reference-lorebook-1603


📝 Commits (10+)

  • 3bb2c92 fix(maps): start per-chat agent reference integration
  • 0e3bcb9 feat(maps): deliver scoped reference lorebook support
  • 4a84bd0 fix(maps): preserve reference host error responses
  • 25bc85e fix(maps): preserve complete reference prompts within model context
  • 0e5912e fix(maps): honor configured output caps in reference fit checks
  • d7ae712 fix(maps): accept omitted host context budget echoes
  • 726f5b1 fix(maps): use checked output reserve for reference calls
  • 8853eab fix(maps): retain checked reserve for JSON repair
  • 2aa9e03 Merge branch 'staging' into fix/maps-agent-reference-lorebook-1603
  • 1160410 fix(maps): ignore unusable output cap metadata

📊 Changes

18 files changed (+975 additions, -169 deletions)

View changed files

📝 README.md (+3 -1)
➕ artifacts/hierarchical-maps-1.7.0.zip (+0 -0)
📝 catalog/catalog.json (+12 -12)
📝 catalog/notes.json (+6 -0)
📝 catalog/v2/catalog.json (+12 -12)
📝 catalog/v2/notes.json (+6 -0)
📝 catalog/v3/catalog.json (+12 -12)
📝 catalog/v3/notes.json (+6 -0)
📝 packages/hierarchical-maps/CHANGELOG.md (+3 -0)
📝 packages/hierarchical-maps/client.js (+89 -81)
📝 packages/hierarchical-maps/engine-boundary.json (+3 -3)
📝 packages/hierarchical-maps/manifest.json (+9 -9)
📝 packages/hierarchical-maps/server.mjs (+31 -28)
📝 packages/hierarchical-maps/src/engine/packages/server/src/routes/spatial-context.routes.ts (+50 -2)
📝 packages/hierarchical-maps/src/engine/packages/server/src/services/spatial-context/package-runtime.ts (+40 -1)
📝 scripts/build-feature-packages.mjs (+4 -5)
📝 scripts/hierarchical-maps-boundary.mjs (+3 -3)
➕ tests/hierarchical-maps-agent-reference.regression.ts (+686 -0)

📄 Description

Runtime teardown is classified across the complete request

The exact 1.7.0 ZIP now covers36 held-await controls. In 18 teardown cases, preview, generation, configuration/model resolution, provider completion and formatting repair return503 spatial_runtime_unavailable, including successful and rejected awaits in chat and global-template requests. None starts another model call after teardown. The 18 live-runtime controls preserve their normal200/400/502 behavior. The negative control returned200 from a preview after its real activation cleanup ran.

A single scoped Fastify error boundary plus registration checks before requests and before responses cover the whole route plugin, including errors relabeled by nested catches. The guard retains only the runtime registration identity. Configured older hosts still return501 host_feature_unavailable. This fixes LOW4359687221 without changing the Engine API, English docs or reference/canon contracts.

Final scoped CodeRabbit completed with zero findings across 8 text files; the ZIP was excluded from source upload and validated separately. Full local checks, Maps TypeScript, all catalog/locale/lane/notes gates and the complete exact-ZIP lifecycle pass. Two rebuilds reproduce all 10 output hashes. Fresh strict base191e72 is merged, and every non-Maps entry remains unchanged across all 3 catalogs, including Slurp 0.4.0 and Gacha Forge 1.10.1.

Negative control,36-case result, validation logs, artifact reproduction hashes and final scoped review: all 11 raw proof files match local bytes. Earlier full feature and repair reviews remain in the PR history. Fresh hosted checks and an actual Viable Dottore verdict for this final head remain merge gates.

Linked issue

Closes #1603. Package-side completion of Pasta-Devs/Marinara-Engine#8145; requires the Engine host contract in Pasta-Devs/Marinara-Engine#8153. Owned by @SpicyMarinara (Codex).

Why this change

World Maps owns model requests outside the normal agent pipeline. The chat's selected reference lorebook therefore did not reach map generation, even when its setting appeared in the Engine. World Maps 1.7.0 supplies normally triggered entries to its chat-specific requests.

Review contract decisions

The per-agent lorebook is an extra reference, not a replacement for the builder’s authoritative, cited lore catalog. Lore-grounded requests still require explicit source IDs (generateSpatialMapDraftRequestSchema), and strict canon still requires catalog sourceKeys (groundingPromptLines and plan normalization). The review suggestion to bypass an unavailable catalog when reference entries exist would weaken that existing contract; it is intentionally declined. Actual preview/generation regressions prove lore_expand and lore_strict refuse missing or unavailable catalog selections even with an attached reference, while setup previews use the reference normally.

World Maps 1.7.0 is an unshipped version introduced only by this PR; live staging still has 1.6.0. Repairs to this unpublished archive stay in 1.7.0 rather than manufacturing a patch release.

Only a positive, finite whole-token output cap reduces the valid requested reserve. Hosts reporting zero as an uncapped sentinel, negative/non-finite values or fractional metadata retain the normal reserve; actual public-host route tests prove those calls remain valid.

The output-budget review finding is repaired at the public host boundary: the same capped reserve is passed to both fitContext and chatComplete, including the malformed-JSON repair call. The current Engine provider also clamps the connection cap, but a valid public host need not duplicate that behavior. A real-route fixture reproduced 12,000 requested after fitting 2,048 before the repair and now observes matching 2,048 values.

What changed

  • Add reference context to map creation, replacement, expansion and prompt previews, preserving the builder's explicit lore sources. Global map templates have no chat attachment.
  • Use the public, package-bound Engine resolver; no private scanner import or bundled scanner. An unsupported host fails clearly. When selected references make the complete map request exceed the model context, fail before the model call while preserving its instructions, references and configured response reserve. Honor an omitted budget echo from the public host fit contract and pass the exact checked output reserve to the model call.
  • Require Engine 2.5.1 with Capability API 1.379 and pin Engine source 46faa1ad32a945054a94b88971349908151b773b.
  • Rebuild World Maps, its ZIP, release notes and catalog lanes. The client rebuild also reflects the current Engine's Lucide build dependencies; no package UI source changed.

Validation

Required local npm run check, catalog lanes, package locales, catalog/artifact integrity and release-note checks pass. Maps typecheck and the existing UI contract regression pass. A second build reproduced all ten generated output hashes byte-for-byte.

The new regression activates the actual ZIP against the real Engine runtime and storage. It verifies Roleplay/Game chat isolation, default-off, disabled/missing books and unmatched entries, additive explicit sources, preview without model calls, create/replace/expand requests, global-template exclusion, normal host-budget enforcement, finite-model context rejection without model calls, the connection's saved output cap, omitted/reduced public budget echoes, actual fit/call reserve parity, authoritative-catalog refusal controls, and the actual missing-host preview/generation HTTP error envelopes (501, stable code and readable message). Running it on shipped World Maps 1.6.0 fails at the missing reference assertion. The missing-host route assertion also reproduced the previous generic “Not Implemented” message before its fix. Model completions use a local fixture; no paid provider was called.

The existing exact-artifact lifecycle regression passes, including update, offline restart, removal/reinstall, backup/restore, shared worlds, and chat history preservation. Hosted checks and Dottore Review remain separate merge gates. Local CodeRabbit review results are recorded in the PR conversation.

  • Manually verify installing/updating World Maps through Download Agents on a compatible Engine.
  • Manually verify per-chat attached references in map creation and expansion in the browser.
  • Manually verify restart, offline restart and uninstall preserve chat/map state on a physical installation.

🔄 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-Agents/pull/1604 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 10/23/2026 **Status:** ✅ Merged **Merged:** 10/23/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/maps-agent-reference-lorebook-1603` --- ### 📝 Commits (10+) - [`3bb2c92`](https://github.com/Pasta-Devs/Marinara-Agents/commit/3bb2c929519608065e7c2df3b31c74ca57aa1b5d) fix(maps): start per-chat agent reference integration - [`0e3bcb9`](https://github.com/Pasta-Devs/Marinara-Agents/commit/0e3bcb9a281416cfed0abfccaff4892ccbcd4ff6) feat(maps): deliver scoped reference lorebook support - [`4a84bd0`](https://github.com/Pasta-Devs/Marinara-Agents/commit/4a84bd09b599f1c6d3549ad0213d7f2fb9095d79) fix(maps): preserve reference host error responses - [`25bc85e`](https://github.com/Pasta-Devs/Marinara-Agents/commit/25bc85e214331ec9c348428d18eba4f419c7a11c) fix(maps): preserve complete reference prompts within model context - [`0e5912e`](https://github.com/Pasta-Devs/Marinara-Agents/commit/0e5912eed213fecdcf625222000d200cf2db2b6b) fix(maps): honor configured output caps in reference fit checks - [`d7ae712`](https://github.com/Pasta-Devs/Marinara-Agents/commit/d7ae712601b85b00a19844e8cad279bcae2c67ab) fix(maps): accept omitted host context budget echoes - [`726f5b1`](https://github.com/Pasta-Devs/Marinara-Agents/commit/726f5b1ff7e40ccb33bfdbcb9346ef0c6653d808) fix(maps): use checked output reserve for reference calls - [`8853eab`](https://github.com/Pasta-Devs/Marinara-Agents/commit/8853eabaa4bba891f6e3f986ea1290bc098f1920) fix(maps): retain checked reserve for JSON repair - [`2aa9e03`](https://github.com/Pasta-Devs/Marinara-Agents/commit/2aa9e032d67aff8461e06b491615a5d140421ded) Merge branch 'staging' into fix/maps-agent-reference-lorebook-1603 - [`1160410`](https://github.com/Pasta-Devs/Marinara-Agents/commit/116041083b0a16d32b1cf17fca4187ee2800d8b8) fix(maps): ignore unusable output cap metadata ### 📊 Changes **18 files changed** (+975 additions, -169 deletions) <details> <summary>View changed files</summary> 📝 `README.md` (+3 -1) ➕ `artifacts/hierarchical-maps-1.7.0.zip` (+0 -0) 📝 `catalog/catalog.json` (+12 -12) 📝 `catalog/notes.json` (+6 -0) 📝 `catalog/v2/catalog.json` (+12 -12) 📝 `catalog/v2/notes.json` (+6 -0) 📝 `catalog/v3/catalog.json` (+12 -12) 📝 `catalog/v3/notes.json` (+6 -0) 📝 `packages/hierarchical-maps/CHANGELOG.md` (+3 -0) 📝 `packages/hierarchical-maps/client.js` (+89 -81) 📝 `packages/hierarchical-maps/engine-boundary.json` (+3 -3) 📝 `packages/hierarchical-maps/manifest.json` (+9 -9) 📝 `packages/hierarchical-maps/server.mjs` (+31 -28) 📝 `packages/hierarchical-maps/src/engine/packages/server/src/routes/spatial-context.routes.ts` (+50 -2) 📝 `packages/hierarchical-maps/src/engine/packages/server/src/services/spatial-context/package-runtime.ts` (+40 -1) 📝 `scripts/build-feature-packages.mjs` (+4 -5) 📝 `scripts/hierarchical-maps-boundary.mjs` (+3 -3) ➕ `tests/hierarchical-maps-agent-reference.regression.ts` (+686 -0) </details> ### 📄 Description ## Runtime teardown is classified across the complete request The exact 1.7.0 ZIP now covers36 held-await controls. In 18 teardown cases, preview, generation, configuration/model resolution, provider completion and formatting repair return503 `spatial_runtime_unavailable`, including successful and rejected awaits in chat and global-template requests. None starts another model call after teardown. The 18 live-runtime controls preserve their normal200/400/502 behavior. The negative control returned200 from a preview after its real activation cleanup ran. A single scoped Fastify error boundary plus registration checks before requests and before responses cover the whole route plugin, including errors relabeled by nested catches. The guard retains only the runtime registration identity. Configured older hosts still return501 `host_feature_unavailable`. This fixes LOW4359687221 without changing the Engine API, English docs or reference/canon contracts. Final scoped CodeRabbit completed with zero findings across 8 text files; the ZIP was excluded from source upload and validated separately. Full local checks, Maps TypeScript, all catalog/locale/lane/notes gates and the complete exact-ZIP lifecycle pass. Two rebuilds reproduce all 10 output hashes. Fresh strict base191e72 is merged, and every non-Maps entry remains unchanged across all 3 catalogs, including Slurp 0.4.0 and Gacha Forge 1.10.1. [Negative control,36-case result, validation logs, artifact reproduction hashes and final scoped review](https://gist.github.com/SpicyMarinara/da4b668d5416ac3322b10c5481d898be): all 11 raw proof files match local bytes. Earlier full feature and repair reviews remain in the PR history. Fresh hosted checks and an actual Viable Dottore verdict for this final head remain merge gates. ## Linked issue Closes #1603. Package-side completion of Pasta-Devs/Marinara-Engine#8145; requires the Engine host contract in Pasta-Devs/Marinara-Engine#8153. Owned by @SpicyMarinara (Codex). ## Why this change World Maps owns model requests outside the normal agent pipeline. The chat's selected reference lorebook therefore did not reach map generation, even when its setting appeared in the Engine. World Maps 1.7.0 supplies normally triggered entries to its chat-specific requests. ## Review contract decisions The per-agent lorebook is an **extra reference**, not a replacement for the builder’s authoritative, cited lore catalog. Lore-grounded requests still require explicit source IDs (`generateSpatialMapDraftRequestSchema`), and strict canon still requires catalog `sourceKeys` (`groundingPromptLines` and plan normalization). The review suggestion to bypass an unavailable catalog when reference entries exist would weaken that existing contract; it is intentionally declined. Actual preview/generation regressions prove `lore_expand` and `lore_strict` refuse missing or unavailable catalog selections even with an attached reference, while setup previews use the reference normally. World Maps 1.7.0 is an unshipped version introduced only by this PR; live staging still has 1.6.0. Repairs to this unpublished archive stay in 1.7.0 rather than manufacturing a patch release. Only a positive, finite whole-token output cap reduces the valid requested reserve. Hosts reporting zero as an uncapped sentinel, negative/non-finite values or fractional metadata retain the normal reserve; actual public-host route tests prove those calls remain valid. The output-budget review finding is repaired at the public host boundary: the same capped reserve is passed to both `fitContext` and `chatComplete`, including the malformed-JSON repair call. The current Engine provider also clamps the connection cap, but a valid public host need not duplicate that behavior. A real-route fixture reproduced 12,000 requested after fitting 2,048 before the repair and now observes matching 2,048 values. ## What changed - Add reference context to map creation, replacement, expansion and prompt previews, preserving the builder's explicit lore sources. Global map templates have no chat attachment. - Use the public, package-bound Engine resolver; no private scanner import or bundled scanner. An unsupported host fails clearly. When selected references make the complete map request exceed the model context, fail before the model call while preserving its instructions, references and configured response reserve. Honor an omitted budget echo from the public host fit contract and pass the exact checked output reserve to the model call. - Require Engine 2.5.1 with Capability API 1.379 and pin Engine source `46faa1ad32a945054a94b88971349908151b773b`. - Rebuild World Maps, its ZIP, release notes and catalog lanes. The client rebuild also reflects the current Engine's Lucide build dependencies; no package UI source changed. ## Validation Required local `npm run check`, catalog lanes, package locales, catalog/artifact integrity and release-note checks pass. Maps typecheck and the existing UI contract regression pass. A second build reproduced all ten generated output hashes byte-for-byte. The new regression activates the actual ZIP against the real Engine runtime and storage. It verifies Roleplay/Game chat isolation, default-off, disabled/missing books and unmatched entries, additive explicit sources, preview without model calls, create/replace/expand requests, global-template exclusion, normal host-budget enforcement, finite-model context rejection without model calls, the connection's saved output cap, omitted/reduced public budget echoes, actual fit/call reserve parity, authoritative-catalog refusal controls, and the actual missing-host preview/generation HTTP error envelopes (501, stable code and readable message). Running it on shipped World Maps 1.6.0 fails at the missing reference assertion. The missing-host route assertion also reproduced the previous generic “Not Implemented” message before its fix. Model completions use a local fixture; no paid provider was called. The existing exact-artifact lifecycle regression passes, including update, offline restart, removal/reinstall, backup/restore, shared worlds, and chat history preservation. Hosted checks and Dottore Review remain separate merge gates. Local CodeRabbit review results are recorded in the PR conversation. - [ ] Manually verify installing/updating World Maps through Download Agents on a compatible Engine. - [ ] Manually verify per-chat attached references in map creation and expansion in the browser. - [ ] Manually verify restart, offline restart and uninstall preserve chat/map state on a physical installation. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-24 04:02:31 +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-Agents#1599
No description provided.