[PR #225] [CLOSED] fix(maps): distinguish malformed JSON from truncation #865

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Agents/pull/225
Author: @thetopham
Created: 8/3/2026
Status: ❌ Closed

Base: staging ← Head: fix/218-map-json-parse-errors


📝 Commits (1)

  • 11fb6b0 fix(maps): diagnose malformed map JSON

📊 Changes

9 files changed (+527 additions, -96 deletions)

View changed files

📝 artifacts/hierarchical-maps-1.3.0.zip (+0 -0)
📝 catalog/catalog.json (+5 -5)
📝 catalog/v2/catalog.json (+5 -5)
📝 catalog/v3/catalog.json (+5 -5)
📝 packages/hierarchical-maps/manifest.json (+2 -2)
📝 packages/hierarchical-maps/server.mjs (+70 -68)
📝 packages/hierarchical-maps/src/engine/packages/server/src/routes/spatial-context.routes.ts (+45 -11)
➕ packages/hierarchical-maps/src/engine/packages/server/src/services/spatial-context/map-json-response.ts (+255 -0)
➕ tests/map-json-response.regression.ts (+140 -0)

📄 Description

Pull request

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch to main.
Outside and first-time contributors also require an approving review from SpicyMarinara.

Linked issue

Closes #218

Why this change

  • Balanced but malformed World Map JSON was always labeled as likely token truncation, hiding the parser failure and recommending unsupported Max Output Tokens changes.

What changed

  • Classify parse failures using both the provider finish reason and JSON structural completeness.
  • Reserve output-limit guidance for explicit limit finishes or structurally incomplete responses.
  • Attempt one formatting-only repair for balanced malformed JSON, then return a retryable malformed-JSON error if repair fails.
  • Include primary and repair finish reason, response length, parser detail, and structural evidence in the error details and server log.
  • Rebuilt the hierarchical-maps 1.3.0 server payload, manifest hashes, ZIP artifact, and all catalog lanes.
  • Added a focused regression using the reported unquoted-property shape plus truncation and repair cases.

Package and security impact

  • Affected package IDs: hierarchical-maps
  • Engine compatibility impact: none; the package uses the existing capability language-model completion and context-fit facade.
  • New or changed permissions/entrypoints: none.
  • Restart, storage, update, or uninstall impact: no schema or storage changes; package server update requires the normal package reload/restart path.

Validation

  • node scripts/validate-catalog.mjs passes locally
  • git diff --check passes locally
  • Rebuilt every affected manifest, payload, artifact, and catalog entry
  • Installed or updated the affected package through Marinara Engine
  • Checked supported modes, restart behavior, and uninstall cleanup
  • Read and followed CONTRIBUTING.md

Automated verification notes

  • pnpm --filter @marinara-engine/server exec tsx /tmp/marinara-agents-218/tests/map-json-response.regression.ts
  • node scripts/test-catalog-lanes.mjs
  • node scripts/validate-catalog.mjs
  • git diff --check
  • unzip -t artifacts/hierarchical-maps-1.3.0.zip
  • Generated server bundle contains spatial_ai_output_truncated, spatial_ai_json_invalid, and the structured repair diagnostics.
  • The broader lifecycle regression could not start against the current Engine checkout because its existing @marinara-engine/shared build lacks the already-referenced noodleAutoPostingIntensitySchema export; this is outside the changed World Maps paths.

Manual verification notes

  • Live Engine installation and provider-backed malformed-output verification are pending. The focused regression uses deterministic completion/parser fixtures and does not claim the reporter's provider/model session.

Documentation impact

  • No documentation changes needed
  • Updated this README catalog and package guidance
  • Updated linked Marinara Engine documentation

UI evidence (if applicable)

  • Not captured; this changes API error classification and recovery behavior.

🔄 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/225 **Author:** [@thetopham](https://github.com/thetopham) **Created:** 8/3/2026 **Status:** ❌ Closed **Base:** `staging` ← **Head:** `fix/218-map-json-parse-errors` --- ### 📝 Commits (1) - [`11fb6b0`](https://github.com/Pasta-Devs/Marinara-Agents/commit/11fb6b0e313b61e3c179e36f49ee1cfdee42e54e) fix(maps): diagnose malformed map JSON ### 📊 Changes **9 files changed** (+527 additions, -96 deletions) <details> <summary>View changed files</summary> 📝 `artifacts/hierarchical-maps-1.3.0.zip` (+0 -0) 📝 `catalog/catalog.json` (+5 -5) 📝 `catalog/v2/catalog.json` (+5 -5) 📝 `catalog/v3/catalog.json` (+5 -5) 📝 `packages/hierarchical-maps/manifest.json` (+2 -2) 📝 `packages/hierarchical-maps/server.mjs` (+70 -68) 📝 `packages/hierarchical-maps/src/engine/packages/server/src/routes/spatial-context.routes.ts` (+45 -11) ➕ `packages/hierarchical-maps/src/engine/packages/server/src/services/spatial-context/map-json-response.ts` (+255 -0) ➕ `tests/map-json-response.regression.ts` (+140 -0) </details> ### 📄 Description # Pull request > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch to `main`. > Outside and first-time contributors also require an approving review from `SpicyMarinara`. ## Linked issue Closes #218 ## Why this change - Balanced but malformed World Map JSON was always labeled as likely token truncation, hiding the parser failure and recommending unsupported Max Output Tokens changes. ## What changed - Classify parse failures using both the provider finish reason and JSON structural completeness. - Reserve output-limit guidance for explicit limit finishes or structurally incomplete responses. - Attempt one formatting-only repair for balanced malformed JSON, then return a retryable malformed-JSON error if repair fails. - Include primary and repair finish reason, response length, parser detail, and structural evidence in the error details and server log. - Rebuilt the `hierarchical-maps` 1.3.0 server payload, manifest hashes, ZIP artifact, and all catalog lanes. - Added a focused regression using the reported unquoted-property shape plus truncation and repair cases. ## Package and security impact - Affected package IDs: `hierarchical-maps` - Engine compatibility impact: none; the package uses the existing capability language-model completion and context-fit facade. - New or changed permissions/entrypoints: none. - Restart, storage, update, or uninstall impact: no schema or storage changes; package server update requires the normal package reload/restart path. ## Validation - [ ] `node scripts/validate-catalog.mjs` passes locally - [ ] `git diff --check` passes locally - [ ] Rebuilt every affected manifest, payload, artifact, and catalog entry - [ ] Installed or updated the affected package through Marinara Engine - [ ] Checked supported modes, restart behavior, and uninstall cleanup - [ ] Read and followed `CONTRIBUTING.md` ### Automated verification notes - `pnpm --filter @marinara-engine/server exec tsx /tmp/marinara-agents-218/tests/map-json-response.regression.ts` - `node scripts/test-catalog-lanes.mjs` - `node scripts/validate-catalog.mjs` - `git diff --check` - `unzip -t artifacts/hierarchical-maps-1.3.0.zip` - Generated server bundle contains `spatial_ai_output_truncated`, `spatial_ai_json_invalid`, and the structured repair diagnostics. - The broader lifecycle regression could not start against the current Engine checkout because its existing `@marinara-engine/shared` build lacks the already-referenced `noodleAutoPostingIntensitySchema` export; this is outside the changed World Maps paths. ### Manual verification notes - Live Engine installation and provider-backed malformed-output verification are pending. The focused regression uses deterministic completion/parser fixtures and does not claim the reporter's provider/model session. ## Documentation impact - [ ] No documentation changes needed - [ ] Updated this README catalog and package guidance - [ ] Updated linked Marinara Engine documentation ## UI evidence (if applicable) - Not captured; this changes API error classification and recovery behavior. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-20 17:31:45 +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#865
No description provided.