[GH-ISSUE #5756] Staged sensitive file changes count as applied mutations, so a read of the unchanged file can satisfy the verification guard #3182

Closed
opened 2026-10-21 06:00:18 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @kolacheee on GitHub (Sep 2, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/5756

Originally assigned to: @kolacheee on GitHub.

In one sentence: the workspace verification guard classifies every successful non-app_data mutation as applied, but write/edit on a sensitive file can succeed while only staging the change behind an approval — so a follow-up read of the (unchanged) file satisfies the guard and Mari may claim completion while the approval is still pending.

The gap (flagged by CodeRabbit on #5755, pre-existing)

isAppliedWorkspaceMutation (workspace-agent.service.ts) treats any successful mutating command that isn't app_data as an applied change; only app_data results are additionally gated on "saved": true. But the sensitive-file path (workspace-change-review.service.ts) lets commandWrite/commandEdit return success with an output saying the file was not changed and an approval is pending. A subsequent successful read then flips the verification state to verified, and the completion-claim interception won't fire — even though nothing was applied.

Mitigations that keep this from being acute today: the read in that scenario returns the old content, so a model actually comparing what it reads against what it wrote sees the discrepancy; and the pending approval is prominently surfaced to the user. But the guard's own signal is wrong, and the #5754-era coaching ("a successful read after the write satisfies verification") leans on it harder.

Possible directions (maintainer's call)

  • Return an explicit applied-vs-staged outcome from mutation execution (structured on the command result, like the store read-back sentinel pattern from the #5754 follow-up) and require verification only for mutations that actually applied — a staged mutation would count as neither applied nor verified, and a completion claim would be intercepted with "the change is staged behind an approval; say so instead of claiming completion".
  • Minimal version: gate isAppliedWorkspaceMutation for write/edit on the absence of the engine-written staging marker in the output (the staging text is engine-authored, so an anchored check is available).
  • Coaching-only version: teach Mari that a staged sensitive change must be reported as pending, never as done — weakest, since the whole point of the guard is not trusting the model on this.

Related: the #5754 follow-up (store read-back for app_data mutations) established the pattern of engine-verified outcomes carried structurally on results — this is the same idea applied to the staging path.

Originally created by @kolacheee on GitHub (Sep 2, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/5756 Originally assigned to: @kolacheee on GitHub. **In one sentence:** the workspace verification guard classifies every successful non-app_data mutation as *applied*, but `write`/`edit` on a sensitive file can succeed while only **staging** the change behind an approval — so a follow-up read of the (unchanged) file satisfies the guard and Mari may claim completion while the approval is still pending. ## The gap (flagged by CodeRabbit on #5755, pre-existing) `isAppliedWorkspaceMutation` (workspace-agent.service.ts) treats any successful mutating command that isn't `app_data` as an applied change; only `app_data` results are additionally gated on `"saved": true`. But the sensitive-file path (`workspace-change-review.service.ts`) lets `commandWrite`/`commandEdit` return success with an output saying the file was *not* changed and an approval is pending. A subsequent successful read then flips the verification state to `verified`, and the completion-claim interception won't fire — even though nothing was applied. Mitigations that keep this from being acute today: the read in that scenario returns the *old* content, so a model actually comparing what it reads against what it wrote sees the discrepancy; and the pending approval is prominently surfaced to the user. But the guard's own signal is wrong, and the #5754-era coaching ("a successful read after the write satisfies verification") leans on it harder. ## Possible directions (maintainer's call) - Return an explicit applied-vs-staged outcome from mutation execution (structured on the command result, like the store read-back sentinel pattern from the #5754 follow-up) and require verification only for mutations that actually applied — a staged mutation would count as neither applied nor verified, and a completion claim would be intercepted with "the change is staged behind an approval; say so instead of claiming completion". - Minimal version: gate `isAppliedWorkspaceMutation` for `write`/`edit` on the absence of the engine-written staging marker in the output (the staging text is engine-authored, so an anchored check is available). - Coaching-only version: teach Mari that a staged sensitive change must be reported as pending, never as done — weakest, since the whole point of the guard is not trusting the model on this. Related: the #5754 follow-up (store read-back for app_data mutations) established the pattern of engine-verified outcomes carried structurally on results — this is the same idea applied to the staging path.
bsakaguchi 2026-10-21 06:00:18 +07:00
Author
Owner

@mikemikimike commented on GitHub (Sep 2, 2026):

Status update: opened PR #5757 targeting the repository-required staging branch: https://github.com/Pasta-Devs/Marinara-Engine/pull/5757

The fix keeps sensitive write/edit approval-stage results out of the applied-mutation set, so a read of an unchanged file cannot satisfy the verification guard. Regression coverage covers both staged command types and preserves ordinary applied-write behavior.

Local validation: focused prompt regression 1/1 passed; server lint passed; full build passed; git diff --check passed. The full Node regression suite completed 153/158, with five existing Windows/baseline failures; the changed-path regression passed. The changed-file Prettier check is blocked by the repository's existing CRLF/full-file formatting baseline, and the added sections match Prettier output.

Online triage/template checks pass after retargeting to staging and updating the PR template. Remaining CI is subject to the repository's outside-contributor owner approval/action-required gate.

<!-- gh-comment-id:5504929180 --> @mikemikimike commented on GitHub (Sep 2, 2026): Status update: opened PR #5757 targeting the repository-required `staging` branch: https://github.com/Pasta-Devs/Marinara-Engine/pull/5757 The fix keeps sensitive `write`/`edit` approval-stage results out of the applied-mutation set, so a read of an unchanged file cannot satisfy the verification guard. Regression coverage covers both staged command types and preserves ordinary applied-write behavior. Local validation: focused prompt regression 1/1 passed; server lint passed; full build passed; `git diff --check` passed. The full Node regression suite completed 153/158, with five existing Windows/baseline failures; the changed-path regression passed. The changed-file Prettier check is blocked by the repository's existing CRLF/full-file formatting baseline, and the added sections match Prettier output. Online triage/template checks pass after retargeting to `staging` and updating the PR template. Remaining CI is subject to the repository's outside-contributor owner approval/action-required gate.
Author
Owner

@kolacheee commented on GitHub (Sep 2, 2026):

@mikemikimike Unfortunately @SpicyMarinara is on holiday and only she can merge PRs from non-contributors, so I have to clone your PR and apply fixes and such. I cannot merge it if it belongs to you. I have to close your PR but you will be credited accordingly.

<!-- gh-comment-id:5511786474 --> @kolacheee commented on GitHub (Sep 2, 2026): @mikemikimike Unfortunately @SpicyMarinara is on holiday and only she can merge PRs from non-contributors, so I have to clone your PR and apply fixes and such. I cannot merge it if it belongs to you. I have to close your PR but you will be credited accordingly.
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#3182
No description provided.