[PR #1471] [MERGED] Fix Professor Mari context bloat #5108

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/1471
Author: @cha1latte
Created: 5/28/2026
Status: ✅ Merged
Merged: 5/28/2026
Merged by: @cha1latte

Base: refactor ← Head: fix/refactor-issue-1468-mari-context


📝 Commits (6)

  • d3c8039 Fix Professor Mari context bloat
  • 22f1ccc Merge remote-tracking branch 'upstream/refactor' into fix/refactor-issue-1468-mari-context
  • 98e88e2 Fix refactor Rust clippy warnings
  • 07d3be9 Address Mari context review gaps
  • ceb2bba Merge remote-tracking branch 'upstream/refactor' into fix/refactor-issue-1468-mari-context
  • fb3bdc3 Merge remote-tracking branch 'upstream/refactor' into fix/refactor-issue-1468-mari-context

📊 Changes

10 files changed (+2036 additions, -241 deletions)

View changed files

📝 graphify-out/GRAPH_REPORT.md (+20 -20)
➕ graphify-out/cache/ast/5f42ee6414fbc8070179b52ea7d0fb3be1294a30890153fd7bdd8be8a370808c.json (+1 -0)
➕ graphify-out/cache/ast/6902a62981792f94ce3078f6836cde162dece27376da5e712cc96fbdfe5556c0.json (+1 -0)
➕ graphify-out/cache/ast/b2913a4e7ea62ebaffcc149f9cffd6b117c582af363717992ce4c01f60170e54.json (+1 -0)
➕ graphify-out/cache/ast/c8fdea76e97db753e5325b10e68e3af594e3446c98c26bce526df4fd5a97c76a.json (+1 -0)
📝 graphify-out/cache/stat-index.json (+1 -1)
📝 graphify-out/graph.json (+1644 -184)
📝 graphify-out/manifest.json (+33 -18)
📝 src-tauri/src/commands/storage/mari.rs (+311 -12)
📝 src/features/shell/mari/components/ProfessorMariSurface.tsx (+23 -6)

📄 Description

Linked issue

Closes #1468

Why this change

  • Professor Mari could inflate requests by placing raw image/base64 attachment content, oversized text attachments, or generated repository artifacts into model/tool context.
  • This keeps Mari's codebase assistant behavior useful while adding an explicit context-admission gate at the Rust command boundary.

What changed

  • Added Professor Mari attachment prompt sanitization: image/binary-like content is represented as metadata plus an omission note, readable text attachments are bounded per file and across the prompt, and encoded blobs are rejected.
  • Tightened Professor Mari code tools so generated/cache directories such as graphify-out, .pnpm-store, .codex, and coverage output are not searchable/readable, and binary-like source payloads are rejected before tool context is returned.
  • Updated the Mari shell attachment reader to avoid loading raw image data URLs and to cap browser-side text reads before sending attachment content to the Rust command.
  • Added Rust regression tests for raw image data URLs, large text attachments, generated Graphify paths, encoded source payloads, and readable-source negative controls.
  • Refreshed Graphify output after the code changes.

Refactor impact

Primary owner:

Professor Mari / Rust storage command boundary / shell tool UI

Impact areas reviewed:

  • Professor Mari prompt assembly
  • Professor Mari code search/read tools
  • Professor Mari shell attachment ingestion
  • Graphify repository map refresh

Boundary notes:

  • The trust boundary lives in src-tauri/src/commands/storage/mari.rs; the UI now avoids sending raw image data, but the Rust command still sanitizes incoming attachment content.
  • No shared generation prompt assembly, chat mode, roleplay mode, game mode, schema, dependency, provider, auth, or storage migration behavior changed.

Pressure points touched:

  • src-tauri/src/commands/storage/mari.rs
  • src/features/shell/mari/components/ProfessorMariSurface.tsx
  • graphify-out/* generated map files

Validation

  • pnpm check passes locally
  • pnpm typecheck passes locally
  • pnpm build passes locally
  • pnpm check:architecture passes locally
  • pnpm check:docs passes locally
  • cargo check --manifest-path src-tauri/Cargo.toml --workspace passes locally
  • Rust clippy/tests were run for Rust behavior changes
  • Browser or Tauri app manual verification completed
  • Playwright, screenshot, or recording evidence added for UI changes
  • Remote runtime smoke checked when relevant

Manual verification notes

  • Codex machine verification:
    • cargo test --manifest-path src-tauri/Cargo.toml professor_mari --lib first failed before the fix on the raw image, large attachment, and Graphify path regression tests, then passed after the fix.
    • CodeRabbit follow-up added regression coverage for bounded attachment metadata and wrapped base64 source payloads.
    • pnpm check passed.
    • pnpm build passed.
    • cargo test --manifest-path src-tauri/Cargo.toml --workspace -j 1 passed.
    • cargo clippy --manifest-path src-tauri/Cargo.toml --workspace --all-targets -- -D warnings passed after the small src/state.rs CI-unblock cleanup.
    • graphify update . passed.
    • node C:\Users\celia\.codex\tools\marinara-proof-gate.mjs scratch\bugfix-verification.json passed.
  • No human-only verification is required for the core claim. This is a non-UI prompt/tool-context fix; screenshot evidence is not applicable.

Docs and release impact

  • No docs changes needed
  • Updated README.md
  • Updated CONTRIBUTING.md
  • Updated docs/developer/
  • Updated repo skills or AGENTS.md
  • Confirmed this PR does not restore old staging/package-workspace/release claims

UI evidence

N/A - non-visual Professor Mari prompt/tool context fix.


🔄 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/1471 **Author:** [@cha1latte](https://github.com/cha1latte) **Created:** 5/28/2026 **Status:** ✅ Merged **Merged:** 5/28/2026 **Merged by:** [@cha1latte](https://github.com/cha1latte) **Base:** `refactor` ← **Head:** `fix/refactor-issue-1468-mari-context` --- ### 📝 Commits (6) - [`d3c8039`](https://github.com/Pasta-Devs/Marinara-Engine/commit/d3c803939d950c7489f5cda01774f983ded0d86e) Fix Professor Mari context bloat - [`22f1ccc`](https://github.com/Pasta-Devs/Marinara-Engine/commit/22f1ccc445e1efa6c2f034d2d46bb8db6d74f3be) Merge remote-tracking branch 'upstream/refactor' into fix/refactor-issue-1468-mari-context - [`98e88e2`](https://github.com/Pasta-Devs/Marinara-Engine/commit/98e88e2fab1e49080eefe47b44ca321b217b048b) Fix refactor Rust clippy warnings - [`07d3be9`](https://github.com/Pasta-Devs/Marinara-Engine/commit/07d3be94276a48b97dbacdb6e492ed37923a23b4) Address Mari context review gaps - [`ceb2bba`](https://github.com/Pasta-Devs/Marinara-Engine/commit/ceb2bbad13ce1af2c4dcb778179b953a333f2ad4) Merge remote-tracking branch 'upstream/refactor' into fix/refactor-issue-1468-mari-context - [`fb3bdc3`](https://github.com/Pasta-Devs/Marinara-Engine/commit/fb3bdc35f43d0423693df055f44e40984b6a5dd3) Merge remote-tracking branch 'upstream/refactor' into fix/refactor-issue-1468-mari-context ### 📊 Changes **10 files changed** (+2036 additions, -241 deletions) <details> <summary>View changed files</summary> 📝 `graphify-out/GRAPH_REPORT.md` (+20 -20) ➕ `graphify-out/cache/ast/5f42ee6414fbc8070179b52ea7d0fb3be1294a30890153fd7bdd8be8a370808c.json` (+1 -0) ➕ `graphify-out/cache/ast/6902a62981792f94ce3078f6836cde162dece27376da5e712cc96fbdfe5556c0.json` (+1 -0) ➕ `graphify-out/cache/ast/b2913a4e7ea62ebaffcc149f9cffd6b117c582af363717992ce4c01f60170e54.json` (+1 -0) ➕ `graphify-out/cache/ast/c8fdea76e97db753e5325b10e68e3af594e3446c98c26bce526df4fd5a97c76a.json` (+1 -0) 📝 `graphify-out/cache/stat-index.json` (+1 -1) 📝 `graphify-out/graph.json` (+1644 -184) 📝 `graphify-out/manifest.json` (+33 -18) 📝 `src-tauri/src/commands/storage/mari.rs` (+311 -12) 📝 `src/features/shell/mari/components/ProfessorMariSurface.tsx` (+23 -6) </details> ### 📄 Description <!-- Target branch: `refactor`. Change the base to `refactor` before submitting unless a maintainer explicitly asked for another base. --> <!-- Keep all checkboxes unchecked until a human has actually verified them. --> ## Linked issue Closes #1468 ## Why this change - Professor Mari could inflate requests by placing raw image/base64 attachment content, oversized text attachments, or generated repository artifacts into model/tool context. - This keeps Mari's codebase assistant behavior useful while adding an explicit context-admission gate at the Rust command boundary. ## What changed - Added Professor Mari attachment prompt sanitization: image/binary-like content is represented as metadata plus an omission note, readable text attachments are bounded per file and across the prompt, and encoded blobs are rejected. - Tightened Professor Mari code tools so generated/cache directories such as `graphify-out`, `.pnpm-store`, `.codex`, and coverage output are not searchable/readable, and binary-like source payloads are rejected before tool context is returned. - Updated the Mari shell attachment reader to avoid loading raw image data URLs and to cap browser-side text reads before sending attachment content to the Rust command. - Added Rust regression tests for raw image data URLs, large text attachments, generated Graphify paths, encoded source payloads, and readable-source negative controls. - Refreshed Graphify output after the code changes. ## Refactor impact Primary owner: Professor Mari / Rust storage command boundary / shell tool UI Impact areas reviewed: - Professor Mari prompt assembly - Professor Mari code search/read tools - Professor Mari shell attachment ingestion - Graphify repository map refresh Boundary notes: - The trust boundary lives in `src-tauri/src/commands/storage/mari.rs`; the UI now avoids sending raw image data, but the Rust command still sanitizes incoming attachment content. - No shared generation prompt assembly, chat mode, roleplay mode, game mode, schema, dependency, provider, auth, or storage migration behavior changed. Pressure points touched: - `src-tauri/src/commands/storage/mari.rs` - `src/features/shell/mari/components/ProfessorMariSurface.tsx` - `graphify-out/*` generated map files ## Validation <!-- Check only what you personally ran or manually verified. Treat unchecked items as explicit TODOs. --> - [ ] `pnpm check` passes locally - [ ] `pnpm typecheck` passes locally - [ ] `pnpm build` passes locally - [ ] `pnpm check:architecture` passes locally - [ ] `pnpm check:docs` passes locally - [ ] `cargo check --manifest-path src-tauri/Cargo.toml --workspace` passes locally - [ ] Rust clippy/tests were run for Rust behavior changes - [ ] Browser or Tauri app manual verification completed - [ ] Playwright, screenshot, or recording evidence added for UI changes - [ ] Remote runtime smoke checked when relevant ### Manual verification notes - Codex machine verification: - `cargo test --manifest-path src-tauri/Cargo.toml professor_mari --lib` first failed before the fix on the raw image, large attachment, and Graphify path regression tests, then passed after the fix. - CodeRabbit follow-up added regression coverage for bounded attachment metadata and wrapped base64 source payloads. - `pnpm check` passed. - `pnpm build` passed. - `cargo test --manifest-path src-tauri/Cargo.toml --workspace -j 1` passed. - `cargo clippy --manifest-path src-tauri/Cargo.toml --workspace --all-targets -- -D warnings` passed after the small `src/state.rs` CI-unblock cleanup. - `graphify update .` passed. - `node C:\Users\celia\.codex\tools\marinara-proof-gate.mjs scratch\bugfix-verification.json` passed. - No human-only verification is required for the core claim. This is a non-UI prompt/tool-context fix; screenshot evidence is not applicable. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated `README.md` - [ ] Updated `CONTRIBUTING.md` - [ ] Updated `docs/developer/` - [ ] Updated repo skills or `AGENTS.md` - [ ] Confirmed this PR does not restore old staging/package-workspace/release claims ## UI evidence N/A - non-visual Professor Mari prompt/tool context fix. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:13:21 +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#5108
No description provided.