mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #5793] [MERGED] feat(mari): applied mutations verify themselves via a store read-back #6937
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#6937
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/5793
Author: @kolacheee
Created: 9/2/2026
Status: ✅ Merged
Merged: 9/3/2026
Merged by: @kolacheee
Base:
staging← Head:feat/mari-write-readback📝 Commits (7)
a13a330feat(mari): applied mutations verify themselves via a store read-back620b0f8fix(mari): anchor read-back detection to an engine-written sentinel993320efix(mari): address adversarial review on the read-back (never-weaken holds)3ee319bfix(mari): pin the merged sentinel ordering after the #5776 rebase7702bcdfix(mari): make a store-observed persistence failure sticky (review round)d2e7589fix(mari): verify derived book syncs and key the mismatch alarm (CodeRabbit)af2dc00fix(mari): carry positional CLI targets in the mismatch key (CodeRabbit)📊 Changes
8 files changed (+757 additions, -41 deletions)
View changed files
📝
CHANGELOG.md(+1 -0)📝
packages/server/src/services/lorebook/character-book-sync.ts(+20 -5)📝
packages/server/src/services/mari-db/mari-db.service.ts(+168 -3)📝
packages/server/src/services/professor-mari/workspace-agent.service.ts(+142 -25)📝
packages/shared/src/types/professor-mari-workspace.ts(+36 -0)📝
scripts/regressions/mari-guard-sibling-paths.regression.ts(+4 -1)📝
scripts/regressions/mari-polish.regression.ts(+4 -7)➕
scripts/regressions/mari-write-readback.regression.ts(+382 -0)📄 Description
Linked issue
Follow-up to #5754 (the "verification round" issue closed by #5755), implementing the structural direction discussed there: engine-verified outcomes carried on results, per the maintainer's guidance that protecting against silent persistent failures takes priority. No separate issue exists for this follow-up; it was scoped in the #5754 discussion.
Why this change
applyPlan(and character-book sync), the engine re-reads the affected rows through the same store layer reads use, compares the persisted state against the intended change column-by-column, and carries the outcome structurally on the result. Mari's claims about persistence stop depending on her own diligence — the engine either confirmed the write or it didn't.What changed
buildReadBack(mari-db.service.ts): post-apply, re-reads every applied row viagetRawByIdand compares the known-column patch against the persisted raw values (stableJsonequality); statusesverified/mismatch/unavailable, with capped mismatch details. Cascade child deletions (rows the store deletes for a parent) are asserted absent even though they ride the plan withapply:false. Dry-runs get no read-back. Never throws — a read-back failure degrades tounavailable, which still demands a manual read.commandAppData/commandMariDirectemitReadback: store-verified/Readback: store-mismatchas the output's first line, and the guard trusts onlystartsWithat position zero — everything later in an output can contain model-authored text (echoed rows, command strings), so substring detection would be forgeable. Same anchoring pattern as #5775's staging marker and #5787's dry-run sentinel; in the mari-CLI runtime the read-back and dry-run sentinels are mutually exclusive (a read-back only rides applied mutations, a dry-run never applies), so position zero stays deterministic.resolveWorkspaceMutationVerification: every applied mutation without a store-verified read-back adds its own verification debt; only a later successful read clears outstanding debt; a self-verified mutation is debt-free for itself but never pays off an earlier mutation's debt (an adversarial review proved the naive single-boolean form did exactly that). Composed with the staged state from #5775 (priority: unverified > staged > verified/none) and the dry-run gate from #5787.readBack(file writes/edits, copy/move, bash mutations, mari image/code/theme writes) still requires a manual verification read exactly as before, andunavailableread-backs keep that requirement too. Amismatchis sticky: the engine positively observed that a write failed, so no read can clear it — the resolver carries a dedicatedmismatchstate whose interception coaching tells Mari to report the failure plainly, and only a later store-verified retry (an engine-observed persisted change) clears the alarm. The #5740 diagnostics record reports a mismatched round asfailed.readBackfield (not prose): results carrying it have verified themselves — no separate verification read needed; results without it keep the read-then-claim coaching. The write-then-verify boilerplate was removed only from bullets covering commands that now self-verify.mari-write-readbackregression lane: a live file-backed-store round-trip (create/update read backverified; dry-run carries no read-back), sentinel end-to-end and forgery cases, debt-semantics orderings,readBackValuesMatchunits, and source pins on the emitter gates/ordering, the cascade condition, and the record-mismatch consult.Validation
pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
node ./scripts/run-regressions.mjs --filter mari-write-readback(live-store round-trip lane), plus themari-guard-sibling-paths,prompt,mari-polish,mari-understood-request, andmari-ask-latchlanes;pnpm --filter @marinara-engine/server lint;pnpm build.Docs and release impact
docs-i18nbranch updated to match, or a[docs-i18n]follow-up issue opened (see CONTRIBUTING.md § Translated documentation)UI evidence (if applicable)
Not applicable — server-side verification behavior only.
Summary by CodeRabbit
New Features
Bug Fixes
Behavior Updates
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.