[PR #5727] [MERGED] fix(mari): one confirmation per edit — remove the post-#4838 authorization gate; surface plans on local custom connections #6905

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

📋 Pull Request Information

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

Base: staging ← Head: fix/5721-mari-reasoning-and-edit-flow


📝 Commits (3)

  • aef524b fix(mari): remove the post-#4838 authorization gate; disable hidden reasoning on custom providers (#5721)
  • 5b6725d fix(mari): scope the reasoning disable to local endpoints; retire the gate's e2e suite (#5721 review round)
  • caa1048 Merge branch 'staging' into fix/5721-mari-reasoning-and-edit-flow

📊 Changes

9 files changed (+164 additions, -936 deletions)

View changed files

📝 CHANGELOG.md (+2 -0)
📝 e2e/core-flows.e2e.ts (+0 -87)
📝 packages/server/src/middleware/ip-allowlist.ts (+19 -0)
📝 packages/server/src/services/llm/providers/openai.provider.ts (+2 -11)
📝 packages/server/src/services/professor-mari/workspace-agent.service.ts (+32 -397)
📝 packages/shared/src/types/chat.ts (+0 -4)
📝 scripts/regressions/issue-sweep-5380-5434.regression.ts (+4 -52)
➕ scripts/regressions/mari-edit-flow-revert.regression.ts (+87 -0)
📝 scripts/regressions/prompt.regression.ts (+18 -385)

📄 Description

Linked issue

Closes #5721.

Why this change

Two Professor Mari problems from the same user report, both diagnosed in the issue. Problem B: the server-side authorization gate added after #4838 required every mutating command to quote a verbatim excerpt of the user's message that explicitly named the change. Intent-phrased requests ("rework her personality to be more cynical") failed it, so Mari's first, correct attempt was discarded with "Mutation blocked before execution", the user had to type an approval, and Mari regenerated the identical edit — which then passed through the Keep/Restore review card, a second confirmation. Two generations and two confirmations for one edit, with the first generation's tokens wasted. The gate was an overcorrection driven by complaints from users who didn't realize their own words implied a change request; with the memory system shipped (#4851), per-user preference is the right lever, not a blanket gate. Problem A: on custom connections with reasoning enabled, Mari's brainstorming plans and questions stayed inside the model's hidden reasoning — the disableHiddenReasoning guard that protects her JSON protocol deliberately excluded custom providers, which is exactly the reporter's local-Unsloth setup.

What changed

  • The post-#4838 gate is removed — the workspaceMutationAuthorizationIssue validator, its intent-regex battery, the JSON authorization field (prompt schema, rule, examples, parsing, echo), the approval-fingerprint message extras, and all threading. An intent-authorized edit now lands directly in the existing Keep/Restore review card: one generation, one confirmation. Kept deliberately: #4838's intent-not-grammar prompt guidance (the behavioral contract), Mari's own ask-first deferral (awaitingAuthorization + the Accept chips, including the output-limit continuation), and ordinary command validation.
  • A new "Proactive preference memories" prompt rule: when the same words-vs-reading mismatch happens twice (e.g. a user says "propose changes", Mari stages tool edits, and both times they react as though that wasn't wanted), Mari saves a short memory recording what the phrasing actually means, says so plainly, and adjusts immediately — gauging in both directions (a user who always answers previews with an instant "yes, apply it" gets the offer to stop previewing). Memories start disabled behind Keep & Enable, so the save is an offer the user controls.
  • The hidden-reasoning disable now covers custom providers pointed at local inference endpoints (llama.cpp/vLLM/Ollama/LM Studio — the reported Unsloth case), via a shared isLocalInferenceBaseUrl helper extracted from OpenAIProvider.isLocalInferenceEndpoint. Scoped to local deliberately: for generic custom providers the provider layer sends reasoning_effort: "none" ungated, and strict remote gateways 400 on it — so remote custom connections keep the previous send-nothing behavior. A local endpoint that still chokes can opt out by disabling the reasoning-effort parameter on the connection.
  • Tests: prompt.regression's gate suite is replaced with parse-tolerance pins (a model still emitting the retired authorization field parses harmlessly; awaitingAuthorization still round-trips); the orphaned gate e2e test is deleted (its premise is exactly what this PR removes) and two now-vacuous negative assertions in sibling tests are trimmed (their real assertions stay — they now double as parse-tolerance e2e coverage); the #5435 sweep pin of the old carve-out is updated; and a new mari-edit-flow-revert regression pins the full contract.

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

  • pnpm lint, the server and client production builds, and the e2e type lane are green locally; format:check fails repo-wide on this Windows checkout (pre-existing autocrlf CRLF; touched files were run through Prettier directly).
  • Regressions: mari-edit-flow-revert (new), prompt.regression, and issue-sweep-5380-5434 all pass; the new regression was differentially verified to FAIL against the pre-change tree.
  • A two-lens adversarial review (excision completeness incl. injection-resistance analysis; reasoning-change provider tracing) raised 8 findings; 2 were confirmed by independent verification and are fixed in the second commit — the orphaned e2e gate test (a would-be hard CI red), and the unscoped custom-provider reasoning disable whose claimed provider-layer mitigation did not actually exist for remote gateways (now scoped to local inference endpoints so remote custom behavior is byte-identical to before). The 6 refuted findings included three independent prompt-injection attacks on the new proactive-memory rule, each refuted on the rule's own scoping text plus the disabled-until-enabled mechanic.
  • Please verify manually: ask Mari to revise a character with intent phrasing (e.g. "this personality reads flat — rework it to be more cynical"): she should generate ONCE and the Keep/Restore card should appear, with no "Mutation blocked" round-trip. If you have a local GGUF endpoint handy, a brainstorming ask with reasoning enabled should now show the plan in her visible reply.

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)

CHANGELOG updated under [Unreleased] → Fixed (two entries). No user-facing docs under docs/ touched.

UI evidence (if applicable)

Behavioral change only — the visible difference is the absence of the "Mutation blocked" round-trip and Mari's plans appearing in her reply on local custom connections.

Summary by CodeRabbit

  • Bug Fixes
    • Professor Mari edits now proceed directly to the existing Keep/Restore review card with one generation and confirmation.
    • Custom providers using local inference servers now display plans and questions in the visible reply instead of hidden reasoning.
    • Professor Mari can record proactive preference memories.
    • Improved handling of legacy authorization details without blocking valid workspace commands.

🔄 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/5727 **Author:** [@kolacheee](https://github.com/kolacheee) **Created:** 9/1/2026 **Status:** ✅ Merged **Merged:** 9/1/2026 **Merged by:** [@kolacheee](https://github.com/kolacheee) **Base:** `staging` ← **Head:** `fix/5721-mari-reasoning-and-edit-flow` --- ### 📝 Commits (3) - [`aef524b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/aef524bcba7b2d69be2b8868d787f56eb7f2ea0c) fix(mari): remove the post-#4838 authorization gate; disable hidden reasoning on custom providers (#5721) - [`5b6725d`](https://github.com/Pasta-Devs/Marinara-Engine/commit/5b6725d27513d3cf6dd1b710f4c4b5846c092f0b) fix(mari): scope the reasoning disable to local endpoints; retire the gate's e2e suite (#5721 review round) - [`caa1048`](https://github.com/Pasta-Devs/Marinara-Engine/commit/caa1048dab35089bcd05a12f9f513d0f8a691780) Merge branch 'staging' into fix/5721-mari-reasoning-and-edit-flow ### 📊 Changes **9 files changed** (+164 additions, -936 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+2 -0) 📝 `e2e/core-flows.e2e.ts` (+0 -87) 📝 `packages/server/src/middleware/ip-allowlist.ts` (+19 -0) 📝 `packages/server/src/services/llm/providers/openai.provider.ts` (+2 -11) 📝 `packages/server/src/services/professor-mari/workspace-agent.service.ts` (+32 -397) 📝 `packages/shared/src/types/chat.ts` (+0 -4) 📝 `scripts/regressions/issue-sweep-5380-5434.regression.ts` (+4 -52) ➕ `scripts/regressions/mari-edit-flow-revert.regression.ts` (+87 -0) 📝 `scripts/regressions/prompt.regression.ts` (+18 -385) </details> ### 📄 Description ## Linked issue Closes #5721. ## Why this change Two Professor Mari problems from the same user report, both diagnosed in the issue. **Problem B:** the server-side authorization gate added after #4838 required every mutating command to quote a verbatim excerpt of the user's message that explicitly named the change. Intent-phrased requests ("rework her personality to be more cynical") failed it, so Mari's first, correct attempt was discarded with "Mutation blocked before execution", the user had to type an approval, and Mari regenerated the identical edit — which then passed through the Keep/Restore review card, a second confirmation. Two generations and two confirmations for one edit, with the first generation's tokens wasted. The gate was an overcorrection driven by complaints from users who didn't realize their own words implied a change request; with the memory system shipped (#4851), per-user preference is the right lever, not a blanket gate. **Problem A:** on custom connections with reasoning enabled, Mari's brainstorming plans and questions stayed inside the model's hidden reasoning — the `disableHiddenReasoning` guard that protects her JSON protocol deliberately excluded custom providers, which is exactly the reporter's local-Unsloth setup. ## What changed - **The post-#4838 gate is removed** — the `workspaceMutationAuthorizationIssue` validator, its intent-regex battery, the JSON `authorization` field (prompt schema, rule, examples, parsing, echo), the approval-fingerprint message extras, and all threading. An intent-authorized edit now lands directly in the existing Keep/Restore review card: one generation, one confirmation. Kept deliberately: #4838's intent-not-grammar prompt guidance (the behavioral contract), Mari's own ask-first deferral (`awaitingAuthorization` + the Accept chips, including the output-limit continuation), and ordinary command validation. - **A new "Proactive preference memories" prompt rule**: when the same words-vs-reading mismatch happens twice (e.g. a user says "propose changes", Mari stages tool edits, and both times they react as though that wasn't wanted), Mari saves a short memory recording what the phrasing actually means, says so plainly, and adjusts immediately — gauging in both directions (a user who always answers previews with an instant "yes, apply it" gets the offer to stop previewing). Memories start disabled behind Keep & Enable, so the save is an offer the user controls. - **The hidden-reasoning disable now covers custom providers pointed at local inference endpoints** (llama.cpp/vLLM/Ollama/LM Studio — the reported Unsloth case), via a shared `isLocalInferenceBaseUrl` helper extracted from `OpenAIProvider.isLocalInferenceEndpoint`. Scoped to local deliberately: for generic custom providers the provider layer sends `reasoning_effort: "none"` ungated, and strict remote gateways 400 on it — so remote custom connections keep the previous send-nothing behavior. A local endpoint that still chokes can opt out by disabling the reasoning-effort parameter on the connection. - **Tests**: `prompt.regression`'s gate suite is replaced with parse-tolerance pins (a model still emitting the retired `authorization` field parses harmlessly; `awaitingAuthorization` still round-trips); the orphaned gate e2e test is deleted (its premise is exactly what this PR removes) and two now-vacuous negative assertions in sibling tests are trimmed (their real assertions stay — they now double as parse-tolerance e2e coverage); the #5435 sweep pin of the old carve-out is updated; and a new `mari-edit-flow-revert` regression pins the full contract. ## 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 - `pnpm lint`, the server and client production builds, and the e2e type lane are green locally; `format:check` fails repo-wide on this Windows checkout (pre-existing autocrlf CRLF; touched files were run through Prettier directly). - Regressions: `mari-edit-flow-revert` (new), `prompt.regression`, and `issue-sweep-5380-5434` all pass; the new regression was differentially verified to FAIL against the pre-change tree. - A two-lens adversarial review (excision completeness incl. injection-resistance analysis; reasoning-change provider tracing) raised 8 findings; 2 were confirmed by independent verification and are fixed in the second commit — the orphaned e2e gate test (a would-be hard CI red), and the unscoped custom-provider reasoning disable whose claimed provider-layer mitigation did not actually exist for remote gateways (now scoped to local inference endpoints so remote custom behavior is byte-identical to before). The 6 refuted findings included three independent prompt-injection attacks on the new proactive-memory rule, each refuted on the rule's own scoping text plus the disabled-until-enabled mechanic. - **Please verify manually:** ask Mari to revise a character with intent phrasing (e.g. "this personality reads flat — rework it to be more cynical"): she should generate ONCE and the Keep/Restore card should appear, with no "Mutation blocked" round-trip. If you have a local GGUF endpoint handy, a brainstorming ask with reasoning enabled should now show the plan in her visible reply. ## 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) CHANGELOG updated under **[Unreleased] → Fixed** (two entries). No user-facing docs under `docs/` touched. ## UI evidence (if applicable) Behavioral change only — the visible difference is the absence of the "Mutation blocked" round-trip and Mari's plans appearing in her reply on local custom connections. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Professor Mari edits now proceed directly to the existing Keep/Restore review card with one generation and confirmation. * Custom providers using local inference servers now display plans and questions in the visible reply instead of hidden reasoning. * Professor Mari can record proactive preference memories. * Improved handling of legacy authorization details without blocking valid workspace commands. <!-- 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:14: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#6905
No description provided.