[PR #7005] [MERGED] fix(mari): keep Professor Mari out of build output #7425

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/7005
Author: @SpicyMarinara
Created: 10/3/2026
Status: ✅ Merged
Merged: 10/3/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/mari-no-build-output-writes


📝 Commits (4)

  • 748a134 fix(mari): keep Professor Mari out of build output
  • 9501ad6 fix(mari): close gaps in the build-output guard found in review
  • d49c7a4 Merge remote-tracking branch 'origin/staging' into fix/mari-no-build-output-writes
  • 8b6d497 docs(changelog): point the build-output guard entry at its issue

📊 Changes

6 files changed (+475 additions, -41 deletions)

View changed files

📝 CHANGELOG.md (+2 -0)
📝 docs/home/professor-mari.md (+1 -0)
📝 packages/server/src/services/professor-mari/workspace-agent.service.ts (+33 -13)
📝 packages/server/src/services/professor-mari/workspace-change-review.service.ts (+126 -26)
📝 packages/server/src/services/professor-mari/workspace-shell-sandbox.ts (+45 -1)
📝 scripts/regressions/professor-mari/shell-sandbox.regression.ts (+268 -1)

📄 Description

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch or a same-repository hotfix/* branch to main.
Outside and first-time contributors also require an approving review from SpicyMarinara.

Linked issue

Closes #7003

Refs #6984. #6994 makes the launchers repair a damaged server build; this PR stops Professor Mari from damaging it.

Why this change

A Windows user's Marinara stopped starting because packages/server/dist/services/generation/conversation-command-runtime.js held if(, raw) { }, a line tsc cannot emit (#6984). Professor Mari is the only in-app writer that reaches dist. Her file tools are on by default in the Auto permissions mode and treated dist like any other workspace path, and her shell sandbox let any command write there.

On staging, a sandboxed command wrote that exact line into dist/index.js, created a missing client dist, and moved a package folder away and back. Build output is generated, so Mari should read it and change the source instead.

What changed

Build output means every packages/<pkg>/dist folder plus private builds such as packages/server/dist-sandbox. Mari can still read it, list it, search it and copy a file out of it, but nothing she does can change it. Every refusal is one plain sentence she can pass on: "Build files are generated and must not be edited; change the source and rebuild instead."

  • One shared check, isBuildOutputPath. It folds case the way case-insensitive volumes do, so "DIST", "diſt" (long s) and ligature spellings count as dist too. It also resolves .., accepts both slash styles, and catches the names Windows treats as dist (dist., dist::$INDEX_ALLOCATION, 8.3 short names).
  • File tools. The workspace path resolver refuses build output unless the caller only reads, so a future write tool is refused by default. It checks the real path behind links too, because node_modules/@marinara-engine/<pkg> leads into dist. write, edit, copy (destination), move and remove are refused in every permissions mode.
  • Reviews. A sensitive-file review cannot be staged for build output. A staged review records where its write really lands, and approval checks that again: if a link was swapped in after staging, approval reports "The file changed after Professor Mari staged it" instead of writing into dist.
  • Shell sandbox.
    • macOS (seatbelt) denies writes to dist by path pattern, which also covers a dist that does not exist yet, and denies moving the folders that hold it.
    • Linux (bubblewrap) mounts every existing build folder read-only. It also pins packages/ and each package folder, so a package cannot be moved away and rebuilt under its old name.
    • Common write commands into dist are refused before they run, so the refusal is not lost inside x; echo done.
  • A long command no longer freezes Marinara. The existing check for writes to sensitive files backtracked badly on long one-line commands: 51 to 97 s on the server's main thread at 200 to 450K characters. The new build-output check had the same problem. Both now share one single-pass scanner; the worst of 23 hostile shapes takes 25 ms. On 300,023 random commands, the build-output answers are identical to the old scan. The sensitive-path answers differ on two commands, neither of which the shell runs as a write.
  • docs/home/professor-mari.md gains one trust-boundary line. #7004 tracks the translations.
  • CHANGELOG entry.

Not covered, by design or platform:

  • mari code check still runs pnpm check, whose build step regenerates dist from source. That only writes compiler output, it is Mari's only full-check command, and #6994's start-time check repairs an interrupted build.
  • On Linux, a command that the pre-run check misses can still create a dist in a package that has none yet, because a mount needs an existing folder. macOS blocks this.
  • Windows has no shell sandbox, so Mari has no shell there. The file tools above are the only write path on the platform where #6984 happened.
  • Side effect on Linux: moving a file between two packages inside Mari's shell now crosses separately mounted folders. mv falls back to copy and delete; a Node script calling fs.rename across packages gets EXDEV.

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

Run by the agent:

  • pnpm check passes. All 29 Professor Mari regressions pass, and so do the 21 regressions that load the changed modules.
  • scripts/regressions/professor-mari/shell-sandbox.regression.ts is extended. It covers path cases (including Unicode spellings), every file tool, link routes, staging and approval, the shell-check tables, the sandbox profile and arguments, a real-sandbox runtime proof and a speed pin. Reverting any single fix makes it fail at that fix's own assertion.
  • The real macOS sandbox, staging against this branch: staging wrote if(, raw) { } into dist/index.js, created packages/client/dist, and moved packages/server away and back. With this branch all three get "Operation not permitted" and dist is unchanged.
  • Linux was checked in the ghcr.io/pasta-devs/marinara-engine:staging image with real bubblewrap 0.12. Moving packages/server or packages/ away now fails with "Device or resource busy". Ordinary writes and moves between packages still work.
  • An adversarial review found six problems, all reproduced and fixed: the Unicode spellings of dist, the approval redirect through a swapped link, the slow command checks, the Linux package-folder swap, the guide line, and a fragile test assertion.
  • After merging current staging: the Professor Mari regressions pass again.

Still to verify by hand:

  • On Windows, ask Professor Mari to edit packages/server/dist/services/generation/conversation-command-runtime.js. She is refused with the plain sentence and edits packages/server/src instead. Also try packages/server/diſt/index.js (long s) and packages/server/dıst/index.js (dotless i); NTFS case folding could not be tested here.
  • On a Linux or Docker install with a working bubblewrap sandbox, the Mari shell command mv packages/server packages/x fails with "Device or resource busy". Ordinary source edits, new files and folders, and mv between packages still work.
  • Approving a staged sensitive-file change (for example a package.json edit) still applies when nothing changed after staging. It shows "The file changed after Professor Mari staged it" when a folder on its path was replaced by a link.
  • Marinara stays responsive in the browser while Mari runs a one-line shell command tens of thousands of characters long.
  • Mari can still read, list and grep files in packages/*/dist and copy a built file out to a source folder.

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)

docs/home/professor-mari.md and CHANGELOG updated. #7004 is the [docs-i18n] follow-up.


🔄 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/7005 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 10/3/2026 **Status:** ✅ Merged **Merged:** 10/3/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/mari-no-build-output-writes` --- ### 📝 Commits (4) - [`748a134`](https://github.com/Pasta-Devs/Marinara-Engine/commit/748a134d025e3c179d0f1ad331e1296898a32fda) fix(mari): keep Professor Mari out of build output - [`9501ad6`](https://github.com/Pasta-Devs/Marinara-Engine/commit/9501ad6cc5cdc553ee122739cf3e15eb7a1032c8) fix(mari): close gaps in the build-output guard found in review - [`d49c7a4`](https://github.com/Pasta-Devs/Marinara-Engine/commit/d49c7a4b5bf414aca1c0bac36d62ffb57da74649) Merge remote-tracking branch 'origin/staging' into fix/mari-no-build-output-writes - [`8b6d497`](https://github.com/Pasta-Devs/Marinara-Engine/commit/8b6d4971f70545901ea685f1a6a9f7909dce335b) docs(changelog): point the build-output guard entry at its issue ### 📊 Changes **6 files changed** (+475 additions, -41 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+2 -0) 📝 `docs/home/professor-mari.md` (+1 -0) 📝 `packages/server/src/services/professor-mari/workspace-agent.service.ts` (+33 -13) 📝 `packages/server/src/services/professor-mari/workspace-change-review.service.ts` (+126 -26) 📝 `packages/server/src/services/professor-mari/workspace-shell-sandbox.ts` (+45 -1) 📝 `scripts/regressions/professor-mari/shell-sandbox.regression.ts` (+268 -1) </details> ### 📄 Description > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch or a same-repository `hotfix/*` branch to `main`. > Outside and first-time contributors also require an approving review from `SpicyMarinara`. ## Linked issue Closes #7003 Refs #6984. #6994 makes the launchers repair a damaged server build; this PR stops Professor Mari from damaging it. ## Why this change A Windows user's Marinara stopped starting because `packages/server/dist/services/generation/conversation-command-runtime.js` held `if(, raw) { }`, a line `tsc` cannot emit (#6984). Professor Mari is the only in-app writer that reaches `dist`. Her file tools are on by default in the Auto permissions mode and treated `dist` like any other workspace path, and her shell sandbox let any command write there. On staging, a sandboxed command wrote that exact line into `dist/index.js`, created a missing client `dist`, and moved a package folder away and back. Build output is generated, so Mari should read it and change the source instead. ## What changed Build output means every `packages/<pkg>/dist` folder plus private builds such as `packages/server/dist-sandbox`. Mari can still read it, list it, search it and copy a file out of it, but nothing she does can change it. Every refusal is one plain sentence she can pass on: "Build files are generated and must not be edited; change the source and rebuild instead." - **One shared check, `isBuildOutputPath`.** It folds case the way case-insensitive volumes do, so "DIST", "diſt" (long s) and ligature spellings count as `dist` too. It also resolves `..`, accepts both slash styles, and catches the names Windows treats as `dist` (`dist.`, `dist::$INDEX_ALLOCATION`, 8.3 short names). - **File tools.** The workspace path resolver refuses build output unless the caller only reads, so a future write tool is refused by default. It checks the real path behind links too, because `node_modules/@marinara-engine/<pkg>` leads into `dist`. write, edit, copy (destination), move and remove are refused in every permissions mode. - **Reviews.** A sensitive-file review cannot be staged for build output. A staged review records where its write really lands, and approval checks that again: if a link was swapped in after staging, approval reports "The file changed after Professor Mari staged it" instead of writing into `dist`. - **Shell sandbox.** - macOS (seatbelt) denies writes to `dist` by path pattern, which also covers a `dist` that does not exist yet, and denies moving the folders that hold it. - Linux (bubblewrap) mounts every existing build folder read-only. It also pins `packages/` and each package folder, so a package cannot be moved away and rebuilt under its old name. - Common write commands into `dist` are refused before they run, so the refusal is not lost inside `x; echo done`. - **A long command no longer freezes Marinara.** The existing check for writes to sensitive files backtracked badly on long one-line commands: 51 to 97 s on the server's main thread at 200 to 450K characters. The new build-output check had the same problem. Both now share one single-pass scanner; the worst of 23 hostile shapes takes 25 ms. On 300,023 random commands, the build-output answers are identical to the old scan. The sensitive-path answers differ on two commands, neither of which the shell runs as a write. - `docs/home/professor-mari.md` gains one trust-boundary line. #7004 tracks the translations. - CHANGELOG entry. Not covered, by design or platform: - `mari code check` still runs `pnpm check`, whose build step regenerates `dist` from source. That only writes compiler output, it is Mari's only full-check command, and #6994's start-time check repairs an interrupted build. - On Linux, a command that the pre-run check misses can still create a `dist` in a package that has none yet, because a mount needs an existing folder. macOS blocks this. - Windows has no shell sandbox, so Mari has no shell there. The file tools above are the only write path on the platform where #6984 happened. - Side effect on Linux: moving a file between two packages inside Mari's shell now crosses separately mounted folders. `mv` falls back to copy and delete; a Node script calling `fs.rename` across packages gets `EXDEV`. ## 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 Run by the agent: - `pnpm check` passes. All 29 Professor Mari regressions pass, and so do the 21 regressions that load the changed modules. - `scripts/regressions/professor-mari/shell-sandbox.regression.ts` is extended. It covers path cases (including Unicode spellings), every file tool, link routes, staging and approval, the shell-check tables, the sandbox profile and arguments, a real-sandbox runtime proof and a speed pin. Reverting any single fix makes it fail at that fix's own assertion. - The real macOS sandbox, staging against this branch: staging wrote `if(, raw) { }` into `dist/index.js`, created `packages/client/dist`, and moved `packages/server` away and back. With this branch all three get "Operation not permitted" and `dist` is unchanged. - Linux was checked in the `ghcr.io/pasta-devs/marinara-engine:staging` image with real bubblewrap 0.12. Moving `packages/server` or `packages/` away now fails with "Device or resource busy". Ordinary writes and moves between packages still work. - An adversarial review found six problems, all reproduced and fixed: the Unicode spellings of `dist`, the approval redirect through a swapped link, the slow command checks, the Linux package-folder swap, the guide line, and a fragile test assertion. - After merging current staging: the Professor Mari regressions pass again. Still to verify by hand: - On Windows, ask Professor Mari to edit `packages/server/dist/services/generation/conversation-command-runtime.js`. She is refused with the plain sentence and edits `packages/server/src` instead. Also try `packages/server/diſt/index.js` (long s) and `packages/server/dıst/index.js` (dotless i); NTFS case folding could not be tested here. - On a Linux or Docker install with a working bubblewrap sandbox, the Mari shell command `mv packages/server packages/x` fails with "Device or resource busy". Ordinary source edits, new files and folders, and `mv` between packages still work. - Approving a staged sensitive-file change (for example a `package.json` edit) still applies when nothing changed after staging. It shows "The file changed after Professor Mari staged it" when a folder on its path was replaced by a link. - Marinara stays responsive in the browser while Mari runs a one-line shell command tens of thousands of characters long. - Mari can still read, list and grep files in `packages/*/dist` and copy a built file out to a source folder. ## 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) `docs/home/professor-mari.md` and CHANGELOG updated. #7004 is the `[docs-i18n]` follow-up. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:19:38 +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#7425
No description provided.