[PR #5241] [MERGED] fix(agents): merge Beholder wounds by identity instead of replacing #6688

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/5241
Author: @GetBeholder
Created: 8/19/2026
Status: ✅ Merged
Merged: 8/19/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/beholder-wounds-merge-by-identity


📝 Commits (4)

  • 6cdf3fe fix(agents): merge Beholder wounds by identity instead of replacing
  • 8ae5bcb fix(agents): bound merged Beholder wounds at the slot capacity
  • 3d8615b fix(agents): keep delta-updated wounds during overflow trimming
  • 9847753 test(agents): assert the wound re-description actually changes severity

📊 Changes

2 files changed (+164 additions, -3 deletions)

View changed files

📝 packages/server/src/services/agents/beholder-state.ts (+44 -3)
➕ scripts/regressions/beholder-wound-merge.regression.ts (+120 -0)

📄 Description

Linked issue

Closes #5242

Why this change

The Beholder delta protocol emits only what changed this turn. mergeSlotDelta replaced a slot's whole wounds list on any non-empty wounds delta, so a new wound on an already-wounded slot silently erased the wounds the delta did not re-mention.

Example: a character has head.wounds = [{ text: "fractured skull", severity: "critical" }]. A later turn adds a broken nose, the model emits head.wounds: [{ text: "broken nose", severity: "serious" }], and the fractured skull disappears from tracked state.

worn, holding, bare, and missing were already handled correctly; only wounds replaced.

What changed

  • Added woundIdentity() (the injury text, trimmed + lowercased) and mergeWounds(), mirroring the existing wornItemIdentity() / mergeWornItems() pattern directly above them.
  • mergeSlotDelta now merges wounds by identity instead of assigning the delta list: unseen wounds are appended, a re-described wound updates in place (newer severity / bleeding wins), and wounds the delta omits are kept.
  • wounds: [] still clears the slot wholesale — that branch is untouched.
  • No schema, API, storage-shape, or prompt change. Full-snapshot responses are unaffected (they never reach mergeSlotDelta).

Scope note: distinct-wound healing (dropping one of several co-located wounds) is not expressible in the current delta protocol, so wholesale clearing plus a manual edit remains the interim path — unchanged here. This PR only stops silent wound loss.

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

Manual verification notes

Being explicit rather than ticking boxes I did not earn: I could not run pnpm check locally — pnpm install fails in my environment at the onnxruntime-node postinstall (it tries to download a CUDA build and cannot resolve a host), so the workspace has no usable node_modules. I am relying on CI for typecheck/lint here, and a maintainer should confirm the runtime behaviour in-app before merge.

What I did verify:

  • The change is confined to one file and mirrors the adjacent, already-shipped mergeWornItems implementation exactly (same types, same update-or-append shape, no new imports).
  • Reviewed the surrounding branches by hand: the wounds: [] clear path, the missing short-circuit, and the worn/holding/bare paths are all unchanged.
  • The delta payloads referenced above are the real shapes emitted by the extraction prompt this agent ships with, so the failing case in #5242 is the expected wire behaviour rather than a hypothetical.

Suggested manual check for a reviewer: wound a slot, confirm it renders in the Beholder panel, then wound the same slot differently on a later turn and confirm both wounds are now listed (before this change, only the newest survived).

Summary by CodeRabbit

  • Bug Fixes
    • Improved wound updates so matching injuries are updated correctly without overwriting other wounds in the same location.
    • New injuries are now added while preserving existing wound information.
    • Empty wound updates continue to clear all wounds in the specified location.
    • Limited wound lists to the 12 most recent injuries per location.

🔄 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/5241 **Author:** [@GetBeholder](https://github.com/GetBeholder) **Created:** 8/19/2026 **Status:** ✅ Merged **Merged:** 8/19/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/beholder-wounds-merge-by-identity` --- ### 📝 Commits (4) - [`6cdf3fe`](https://github.com/Pasta-Devs/Marinara-Engine/commit/6cdf3fe4713833010de807b392afea6461ee1360) fix(agents): merge Beholder wounds by identity instead of replacing - [`8ae5bcb`](https://github.com/Pasta-Devs/Marinara-Engine/commit/8ae5bcb46c91f06f7133db98558a0055942a1538) fix(agents): bound merged Beholder wounds at the slot capacity - [`3d8615b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/3d8615b0a63ecac9a8e45b36186793d9352c0bad) fix(agents): keep delta-updated wounds during overflow trimming - [`9847753`](https://github.com/Pasta-Devs/Marinara-Engine/commit/9847753ea7f5fa549c8c107a1def0839f42f2dbe) test(agents): assert the wound re-description actually changes severity ### 📊 Changes **2 files changed** (+164 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `packages/server/src/services/agents/beholder-state.ts` (+44 -3) ➕ `scripts/regressions/beholder-wound-merge.regression.ts` (+120 -0) </details> ### 📄 Description ## Linked issue Closes #5242 ## Why this change The Beholder delta protocol emits **only what changed this turn**. `mergeSlotDelta` replaced a slot's whole `wounds` list on any non-empty wounds delta, so a new wound on an already-wounded slot silently erased the wounds the delta did not re-mention. Example: a character has `head.wounds = [{ text: "fractured skull", severity: "critical" }]`. A later turn adds a broken nose, the model emits `head.wounds: [{ text: "broken nose", severity: "serious" }]`, and the fractured skull disappears from tracked state. `worn`, `holding`, `bare`, and `missing` were already handled correctly; only `wounds` replaced. ## What changed - Added `woundIdentity()` (the injury `text`, trimmed + lowercased) and `mergeWounds()`, mirroring the existing `wornItemIdentity()` / `mergeWornItems()` pattern directly above them. - `mergeSlotDelta` now merges wounds by identity instead of assigning the delta list: unseen wounds are appended, a re-described wound updates in place (newer severity / bleeding wins), and wounds the delta omits are kept. - `wounds: []` still clears the slot wholesale — that branch is untouched. - No schema, API, storage-shape, or prompt change. Full-snapshot responses are unaffected (they never reach `mergeSlotDelta`). Scope note: distinct-wound *healing* (dropping one of several co-located wounds) is not expressible in the current delta protocol, so wholesale clearing plus a manual edit remains the interim path — unchanged here. This PR only stops silent wound loss. ## 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` ### Manual verification notes Being explicit rather than ticking boxes I did not earn: **I could not run `pnpm check` locally** — `pnpm install` fails in my environment at the `onnxruntime-node` postinstall (it tries to download a CUDA build and cannot resolve a host), so the workspace has no usable `node_modules`. I am relying on CI for typecheck/lint here, and a maintainer should confirm the runtime behaviour in-app before merge. What I did verify: - The change is confined to one file and mirrors the adjacent, already-shipped `mergeWornItems` implementation exactly (same types, same update-or-append shape, no new imports). - Reviewed the surrounding branches by hand: the `wounds: []` clear path, the `missing` short-circuit, and the worn/holding/bare paths are all unchanged. - The delta payloads referenced above are the real shapes emitted by the extraction prompt this agent ships with, so the failing case in #5242 is the expected wire behaviour rather than a hypothetical. Suggested manual check for a reviewer: wound a slot, confirm it renders in the Beholder panel, then wound the same slot differently on a later turn and confirm **both** wounds are now listed (before this change, only the newest survived). <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved wound updates so matching injuries are updated correctly without overwriting other wounds in the same location. * New injuries are now added while preserving existing wound information. * Empty wound updates continue to clear all wounds in the specified location. * Limited wound lists to the 12 most recent injuries per location. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:12: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-Engine#6688
No description provided.