[PR #4776] [MERGED] feat(mari): field-aware, navigable workspace app_data reads (#4767) #6492

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

📋 Pull Request Information

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

Base: staging ← Head: feat/4767-mari-output-limits


📝 Commits (4)

  • ed2e2a4 feat(mari): field-aware, navigable app_data reads (#4767)
  • c98594c fix(mari): guarantee the #4767 read bound; harden elision and paths
  • 8cad2ef Merge branch 'staging' into feat/4767-mari-output-limits
  • 6e8c705 fix(mari): harden #4767 field path resolution against inherited keys

📊 Changes

4 files changed (+455 additions, -16 deletions)

View changed files

📝 packages/server/src/services/mari-db/mari-db.service.ts (+234 -15)
📝 packages/server/src/services/professor-mari/workspace-agent.service.ts (+50 -1)
📝 packages/shared/src/types/professor-mari-workspace.ts (+17 -0)
📝 scripts/regressions/open-issues.regression.ts (+154 -0)

📄 Description

Linked issue

Closes #4767

Why this change

When the Home workspace assistant reads live app data (app_data { action: "character.get" } and the other .get reads), the result used to be sliced at a fixed 32k-character output cap with a raw string cut. On a heavy card — many long alternate greetings, a big lorebook body — that meant the read was truncated mid-JSON, silently, sometimes dropping name/description entirely, with no structured signal that anything was cut and no way for Mari to recover the lost content.

What changed

Single-object reads are now bounded structurally and stay fully navigable, instead of raw-sliced:

  • Field-aware elision. When a .get result is over budget, whole oversized fields (long strings and large arrays, as a unit) are elided largest-first and replaced with a short placeholder that names the field's path and length. Identity fields (id, name) are never elided; description is elided only as a last resort. The object stays valid JSON.
  • Structured signal. What was cut is reported in machine-readable truncation metadata and rendered as an explicit note, so a bounded read never looks like a silent slice.
  • Drill-down. Mari can re-read any elided field in full with app_data { field: "<path>", offset }, paging a long value across windows — so a single response stays under the cap while every byte remains reachable.
  • Guaranteed ceiling. A hard cap on the serialized overview (plus a capped note) guarantees the output stays under the command cap even for pathological rows, so the downstream char-level truncation never has to re-slice mid-JSON.

Applied centrally in MariDbService.executeAction and scoped to object reads (.get); already-summarized list/search arrays and mutations pass through untouched. Option C from the issue (a user-configurable limit setting) was intentionally not included, to keep this a focused server-only change — happy to add it as a stacked PR if wanted.

A follow-up (its own issue) is still worth doing: the workspace loop never calls fitMessagesToContext, so command output accumulates across rounds against the model window — a distinct, unreported context-budget concern this PR does not touch.

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

Automated checks already run by the author (green) — not a substitute for the human pass below:

  • pnpm check (TypeScript + ESLint + build) green.
  • pnpm regression:issues green — the new #4767 pin lives in open-issues.regression.ts next to the #4673 lorebook drill-down pin and asserts: a heavy card's get preserves name/description and reports the oversized field with its true length; the elided value reassembles exactly across field= windows; a 4000-tag card stays bounded (never inflated past the cap); a description-dominated card elides the description but keeps the name and recovers it via field=; an unknown field= path is flagged; a small read is untouched.
  • pnpm regression:prompt, regression:professor-mari-shell-sandbox, regression:professor-mari-wiki green.

Still needs a human pass in the app (behavior is only fully observable through the workspace assistant):

  • Manually verify in the Home workspace assistant: import/create a character with several long alternate greetings, ask Mari to read it, and confirm she reports the elided fields explicitly (rather than proceeding on partial data) and the trace panel renders the note readably.
  • Manually verify Mari can drill into an elided field with field= and quote content from the far end of it.
  • Manually verify a normal-sized card reads exactly as before (no truncation note).

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 (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

The app_data tool description and the new field/offset args are model-facing prompt text, not user docs — nothing under docs/ references them.

Summary by CodeRabbit

  • New Features

    • Structured data reads are now safely bounded for more reliable responses.
    • Key identity fields are preserved while oversized fields and arrays are elided.
    • Added field-specific and offset/limit reads to retrieve complete values in sections.
    • Results identify truncated, unresolved, or capped content and provide follow-up read guidance.
  • Bug Fixes

    • Prevented oversized structured responses from exceeding output limits.
    • Preserved existing behavior for small, untruncated reads.

🔄 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/4776 **Author:** [@kolacheee](https://github.com/kolacheee) **Created:** 8/8/2026 **Status:** ✅ Merged **Merged:** 8/8/2026 **Merged by:** [@kolacheee](https://github.com/kolacheee) **Base:** `staging` ← **Head:** `feat/4767-mari-output-limits` --- ### 📝 Commits (4) - [`ed2e2a4`](https://github.com/Pasta-Devs/Marinara-Engine/commit/ed2e2a48f469feb48c1f12a3655371c51e7562a8) feat(mari): field-aware, navigable app_data reads (#4767) - [`c98594c`](https://github.com/Pasta-Devs/Marinara-Engine/commit/c98594c2158db70ed8e4b61b5d6240bc746a3f01) fix(mari): guarantee the #4767 read bound; harden elision and paths - [`8cad2ef`](https://github.com/Pasta-Devs/Marinara-Engine/commit/8cad2ef01e1052526e5a83c03e7f55e1cf66b120) Merge branch 'staging' into feat/4767-mari-output-limits - [`6e8c705`](https://github.com/Pasta-Devs/Marinara-Engine/commit/6e8c705a00e5ac3f92f893e2b6604492b4de1934) fix(mari): harden #4767 field path resolution against inherited keys ### 📊 Changes **4 files changed** (+455 additions, -16 deletions) <details> <summary>View changed files</summary> 📝 `packages/server/src/services/mari-db/mari-db.service.ts` (+234 -15) 📝 `packages/server/src/services/professor-mari/workspace-agent.service.ts` (+50 -1) 📝 `packages/shared/src/types/professor-mari-workspace.ts` (+17 -0) 📝 `scripts/regressions/open-issues.regression.ts` (+154 -0) </details> ### 📄 Description ## Linked issue Closes #4767 ## Why this change When the Home workspace assistant reads live app data (`app_data { action: "character.get" }` and the other `.get` reads), the result used to be sliced at a fixed 32k-character output cap with a raw string cut. On a heavy card — many long alternate greetings, a big lorebook body — that meant the read was truncated **mid-JSON, silently**, sometimes dropping `name`/`description` entirely, with no structured signal that anything was cut and no way for Mari to recover the lost content. ## What changed Single-object reads are now **bounded structurally and stay fully navigable**, instead of raw-sliced: - **Field-aware elision.** When a `.get` result is over budget, whole oversized fields (long strings and large arrays, as a unit) are elided largest-first and replaced with a short placeholder that names the field's path and length. Identity fields (`id`, `name`) are never elided; `description` is elided only as a last resort. The object stays valid JSON. - **Structured signal.** What was cut is reported in machine-readable `truncation` metadata and rendered as an explicit note, so a bounded read never looks like a silent slice. - **Drill-down.** Mari can re-read any elided field in full with `app_data { field: "<path>", offset }`, paging a long value across windows — so a single response stays under the cap while every byte remains reachable. - **Guaranteed ceiling.** A hard cap on the serialized overview (plus a capped note) guarantees the output stays under the command cap even for pathological rows, so the downstream char-level truncation never has to re-slice mid-JSON. Applied centrally in `MariDbService.executeAction` and scoped to object reads (`.get`); already-summarized `list`/`search` arrays and mutations pass through untouched. Option C from the issue (a user-configurable limit setting) was intentionally **not** included, to keep this a focused server-only change — happy to add it as a stacked PR if wanted. A follow-up (its own issue) is still worth doing: the workspace loop never calls `fitMessagesToContext`, so command output accumulates across rounds against the model window — a distinct, unreported context-budget concern this PR does not touch. ## Validation - [x] `pnpm check` passes locally - [x] Container (Docker / Podman) built and ran without issue - [x] Ran the app, clicked through the changes manually - [x] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [x] Above manual verification completed (describe below) - [x] Read and followed `CONTRIBUTING.md` ### Manual verification notes Automated checks already run by the author (green) — **not** a substitute for the human pass below: - `pnpm check` (TypeScript + ESLint + build) green. - `pnpm regression:issues` green — the new `#4767` pin lives in `open-issues.regression.ts` next to the #4673 lorebook drill-down pin and asserts: a heavy card's `get` preserves name/description and reports the oversized field with its true length; the elided value reassembles exactly across `field=` windows; a **4000-tag card stays bounded (never inflated past the cap)**; a description-dominated card elides the description but keeps the name and recovers it via `field=`; an unknown `field=` path is flagged; a small read is untouched. - `pnpm regression:prompt`, `regression:professor-mari-shell-sandbox`, `regression:professor-mari-wiki` green. Still needs a human pass in the app (behavior is only fully observable through the workspace assistant): - **Manually verify** in the Home workspace assistant: import/create a character with several long alternate greetings, ask Mari to read it, and confirm she reports the elided fields explicitly (rather than proceeding on partial data) and the trace panel renders the note readably. - **Manually verify** Mari can drill into an elided field with `field=` and quote content from the far end of it. - **Manually verify** a normal-sized card reads exactly as before (no truncation note). ## 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 (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) The `app_data` tool description and the new `field`/`offset` args are model-facing prompt text, not user docs — nothing under `docs/` references them. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Structured data reads are now safely bounded for more reliable responses. * Key identity fields are preserved while oversized fields and arrays are elided. * Added field-specific and offset/limit reads to retrieve complete values in sections. * Results identify truncated, unresolved, or capped content and provide follow-up read guidance. * **Bug Fixes** * Prevented oversized structured responses from exceeding output limits. * Preserved existing behavior for small, untruncated reads. <!-- 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:10:56 +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#6492
No description provided.