mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #5751] [MERGED] fix(mari): make an approval question binding for the rest of the run #6917
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#6917
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/5751
Author: @kolacheee
Created: 9/2/2026
Status: ✅ Merged
Merged: 9/2/2026
Merged by: @kolacheee
Base:
staging← Head:fix/5748-mari-ask-latch📝 Commits (4)
f869c27fix(mari): make an approval question binding for the rest of the run (#5748)2c63e11fix(mari): harden the ask latch per adversarial review (#5748)5771349fix(mari): survive navigation with a held proposal; sharpen the ask detector (#5748)9e5130bfix(mari): defer a same-frame ask the strict detector recognizes (#5748)📊 Changes
5 files changed (+369 additions, -19 deletions)
View changed files
📝
CHANGELOG.md(+1 -0)📝
packages/client/src/components/chat/HomeProfessorMariChat.tsx(+28 -7)📝
packages/server/src/services/professor-mari/workspace-agent.service.ts(+88 -12)📝
packages/shared/src/types/professor-mari-workspace.ts(+12 -0)➕
scripts/regressions/mari-ask-latch.regression.ts(+240 -0)📄 Description
Linked issue
Closes #5748.
Why this change
A maintainer playtest of the understood-request tool (#5740) surfaced this live: "propose your edits" ended with Mari asking "Let me know if you want me to apply these changes!" — and then applying anyway one round later, with no user reply in between ("Ah, my bad! To properly show you the Keep/Restore review card I need to actually submit"). The five-agent investigation on the issue verified the chain end to end: the approval detector fired on her question, but the deferral requires a mutating command in the same frame, and her attached
apply:falsepreview is classified non-mutating — so the engine had nothing to hold, granted the next round, and its own dry-run result text ("Use apply:true only if the user asked you to make the change") coached the pivot. Empirical counterfactual from the investigation: her identical prose withapply:truewould have been held. The preview boolean alone defeated the hold.What changed
Engine — the floor. A run-scoped ask latch: any round that asks the user for apply-permission arms a run-LOCAL flag, regardless of that round's commands — precisely the conjunct that failed. Two precision decisions came out of the adversarial review below and matter for reviewing this:
visibleTextAsksApplyPermission, anchored on interrogative forms: do you want me to / should I / shall I / let me know if you want) plus the explicitawaitingAuthorizationfield. The existing loose detector (whose bare "want me to" also matches Mari's routine restatements like "Got it — you want me to update…") stays untouched for the same-frame deferral, where a false positive is inert unless that frame also stages a mutation. Arming the latch off the loose detector would have forced an Accept on plainly requested edits — #5721's double-generation again.Once armed:
shouldDeferMutationsdisjunction — same hold, same chip, same next-run apply);manualApprovalArmedgovern the post-Accept silent re-send, which must keep working); Bypass never holds; Plan's floor already refuses everything.A user reply or Accept starts a new run with a fresh latch, so the approval path itself is never blocked.
Prompt + result coaching — the efficiency.
apply:falserenders no card or diff) — replacing the old text that re-posed the apply decision to Mari every round. It is deliberately conditional: "if the user already asked for this change, proceed per your Permissions Mode; if instead you asked them whether to apply, wait for their answer." A blanket later-round ban (the first draft) would have broken the prompt's own sanctioned inspect-then-apply flows — validating a risky requested change, and the lorebook raw-db-delete dry-run-first rule.say, the realapply:truecommands in the same frame,awaitingAuthorization: true. One generation, one Accept, no preview-then-regenerate double work (the reported run generated the full patch twice). The hold claims are scoped "outside Plan and Bypass" — Plan refuses mutations and Bypass never holds, so an unconditional promise would have been false in both.Regression — new
mari-ask-latchlane. Functional: the reported ask-phrasing and genuine questions arm the strict detector; Mari's restatements do not (the #5721 anti-regression tests); the declarative self-answer matches neither detector (why the latch, not phrasing, is the guard); the loose detector's restatement match is pinned as documentation of why it must never arm the latch. Structural pins run against a whitespace-flattened copy (Prettier-proof) and bind the properties the fix rests on: declaration-before-the-round-loop ordering, exact write counts (initialized once, armed once, never reset mid-run), arming lexically adjacent to the streamed-text append, the deferral disjunct, the silent floor with its Manual/Bypass carve-outs, the conditional dry-run text (withdoesNotMatchguards on both rejected drafts), and the mode-scoped hold claims. Differentially verified: removing the latch from the deferral, and the two scope-destroying reverts the adversarial review proved slipped past the first-draft pins (declaration into the loop body was killed by the ordering pin's design; a mid-run reset was replayed and fails the write-count pin). Both detectors are exported for the lane.Durable Accept affordance (from the maintainer's live playtest of this branch: "the Accept button disappeared when I returned to the chat"). The chips store is a single app-wide ephemeral slot: a regular chat starting a generation clears it (
use-generate.ts), the suggestions-disabled mount sweeps clear it without theauthorization-acceptexemption the delivery path has, and a reload never restores it. Since this PR makes held proposals the standard flow, that fragility would orphan them. The deferral itself is already persisted (mariDeferredMutationson the assistant message's extra — the exact flag the server arms the next run from), so the client now re-derives the Accept chip from that persisted truth whenever the deferral is still the chat's last word — making the affordance precisely as durable as the deferral it answers, and self-dismissing the moment the user replies. The chip object moves to a shared constant (MARI_AUTHORIZATION_ACCEPT_CHIP) used by both the server event and the client derivation, so they can never drift.Deliberately not in this PR: a user-visible preview card for
apply:falsedry-runs (the issue's largest direction — needs a design call on a "shown but NOT saved" vocabulary distinct from the Keep/Restore card), and honoringstopafter a command batch (blast radius across every legitimate multi-step sequence). Both remain open options on #5748's list. Nothing here touches #5740's understood-request record (hard constraint: diagnostic only) — a latch-held round records outcomeheld, accurately.Validation
pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
pnpm lint, the fullpnpm build(shared/server/client), andpnpm check:e2e-typesare green locally;format:checkfails repo-wide on this Windows checkout (pre-existing autocrlf CRLF; touched files were run through Prettier directly).mari-ask-latch(differentially verified — removing the latch from the deferral disjunction fails the lane), plusmari-permissions-mode,mari-understood-request,mari-edit-flow-revert,prompt.regression, andopen-issuesall pass.Docs and release impact
docs-i18nbranch updated to match, or a[docs-i18n]follow-up issue opened (see CONTRIBUTING.md § Translated documentation)CHANGELOG updated under [Unreleased] → Fixed. No user-facing docs under
docs/touched (docs-i18n debt stays batched per the standing call).UI evidence (if applicable)
No new UI. The visible behavior change: a proposal round now ends with the existing Accept chip instead of a self-answered apply, and a post-ask hidden edit surfaces as a refused command in the workspace trace.
Summary by CodeRabbit
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.