[GH-ISSUE #6695] [Feature]: Diagnostics and launcher: build integrity check, memory telemetry, prompt debug files, background call cap, safer launcher #3752

Closed
opened 2026-10-21 06:06:50 +07:00 by bsakaguchi · 1 comment
Owner

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

Originally assigned to: @SpicyMarinara on GitHub.

Part of the contribution roadmap in #6624 (package H).

What problem does this solve?

  • A stale or partial build starts anyway and fails later with a confusing "Cannot find module", and the in-app updater can report success for a build that does not match its sources.
  • A memory spike or a stall leaves one bare log line, with nothing about what was running.
  • Debug mode prints whole prompts and replies to the console, where they flood everything else.
  • Automatic model calls have no overall ceiling. Server-scheduled autonomous messages and other background calls from many healthy chats can add up to a lot of paid calls.
  • The launchers run git clean -fd on the source trees, which silently deletes new source files that were never committed.
  • On Windows, start.bat opens the browser after a fixed delay, so a slow start lands on a connection error page.
  • A model that always reasons fails the whole generation when a request asks for reasoning off (seen with GLM 5.3 on NanoGPT).

Proposed solution

  • Build integrity check: the build records a source inventory, startup compares it with dist and logs one warning on a mismatch (it never blocks a start), and the updater fails clearly instead of reporting success.
  • Memory telemetry: heap, external memory and event-loop delay in the existing memory monitor, one warning per pressure episode, and cheap counters from background workers in stall lines and the runtime diagnostics route.
  • Prompt debug files: with LOG_PROMPT_DEBUG_FILES on, debug prompt output goes to size-limited rotating files under the data folder instead of the console.
  • Background call cap: a rolling hourly budget for automatic model calls (600 by default, adjustable). Once it is spent, a background call is refused locally before reaching the provider. Interactive requests are never counted or refused.
  • Launcher helpers: two small fork scripts may join this package, a pinned pnpm shim for nested Windows builds and a check of an installed build.
  • Launcher backup: before the clean, each launcher copies what it would remove into .tmp/untracked-src-backups/. It always exits cleanly, so it never blocks startup.
  • Open when ready: on Windows the launcher polls /api/health and opens the browser once the server answers. AUTO_OPEN_BROWSER still decides whether it opens at all.
  • Reasoning-off retry: on the Chat Completions path, a 400 saying the model cannot disable reasoning is retried once without that flag, before any output reached the user. Every request that works today is sent unchanged.

How it's switched: prompt debug files and the background call cap are off by default (LOG_PROMPT_DEBUG_FILES, and Background call cap in Settings > Advanced > Features, with MARINARA_BACKGROUND_CALLS_PER_HOUR as an override). The rest has no switch because it only reports, makes a backup copy, or fixes a hard failure.

  • Areas touched (for spotting overlap):
    • packages/server/src/lib: logger, rotating sink, runtime diagnostics, freeze detector, worker gauges, new build integrity check
    • packages/server/scripts: build.mjs, write-build-meta.mjs; config/build-info.ts, config/runtime-config.ts
    • packages/server/src/services/generation: new background call budget, connection admission
    • packages/server/src/services/llm/providers/openai.provider.ts and a small reasoning-off helper
    • Autonomous scheduler, sidecar process, file-backed store (worker counters only), updates route
    • Launchers: start.bat, start.sh, start-termux.sh, new scripts/preserve-untracked-src.mjs and scripts/open-when-ready.cmd, .gitattributes
    • Features settings (adds number settings to the switch registry), en.json, .env.example, docs under docs/configuration and docs/development/logging.md
  • Size: about 48 files, about 2,300 added lines, including regressions.
  • Status: implemented and tested in a fork, on Windows and on Linux (WSL, the CI-equivalent run).

Alternatives considered

  • Making a stale build refuse to start: rejected; a warning keeps every existing setup starting while making the cause visible.
  • Counting interactive calls in the cap: rejected; the cap is only there to stop unattended runaway use, never to block the user.
  • Removing the git clean step: it exists for good reasons, so the launcher keeps it and only backs up first.

Additional context

  • Implementation depends on #6647 (foundations); PRs will follow once it merges, one package at a time.
  • If you're working in any of these areas, please comment so we can coordinate before a PR.

Screenshots

Taken from the fork build with invented demo data (characters, lorebooks and a campaign made up for these shots). Model replies and token counts come from a local test stub, so no real model was called.

Background call cap in Settings > Advanced > Features, with the hourly budget.

Background call cap in Settings > Advanced > Features, with the hourly budget

Template check

  • I DID NOT read this template and provide the requested details.
Originally created by @SirAdoni on GitHub (Sep 26, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/6695 Originally assigned to: @SpicyMarinara on GitHub. <!-- roadmap issue H, draft v1.0 --> Part of the contribution roadmap in #6624 (package H). ## What problem does this solve? - **A stale or partial build starts anyway** and fails later with a confusing "Cannot find module", and the in-app updater can report success for a build that does not match its sources. - **A memory spike or a stall leaves one bare log line**, with nothing about what was running. - **Debug mode prints whole prompts and replies to the console**, where they flood everything else. - **Automatic model calls have no overall ceiling.** Server-scheduled autonomous messages and other background calls from many healthy chats can add up to a lot of paid calls. - **The launchers run `git clean -fd` on the source trees**, which silently deletes new source files that were never committed. - **On Windows, `start.bat` opens the browser after a fixed delay**, so a slow start lands on a connection error page. - **A model that always reasons fails the whole generation** when a request asks for reasoning off (seen with GLM 5.3 on NanoGPT). ## Proposed solution - **Build integrity check:** the build records a source inventory, startup compares it with `dist` and logs one warning on a mismatch (it never blocks a start), and the updater fails clearly instead of reporting success. - **Memory telemetry:** heap, external memory and event-loop delay in the existing memory monitor, one warning per pressure episode, and cheap counters from background workers in stall lines and the runtime diagnostics route. - **Prompt debug files:** with `LOG_PROMPT_DEBUG_FILES` on, debug prompt output goes to size-limited rotating files under the data folder instead of the console. - **Background call cap:** a rolling hourly budget for automatic model calls (600 by default, adjustable). Once it is spent, a background call is refused locally before reaching the provider. Interactive requests are never counted or refused. - **Launcher helpers:** two small fork scripts may join this package, a pinned pnpm shim for nested Windows builds and a check of an installed build. - **Launcher backup:** before the clean, each launcher copies what it would remove into `.tmp/untracked-src-backups/`. It always exits cleanly, so it never blocks startup. - **Open when ready:** on Windows the launcher polls `/api/health` and opens the browser once the server answers. `AUTO_OPEN_BROWSER` still decides whether it opens at all. - **Reasoning-off retry:** on the Chat Completions path, a 400 saying the model cannot disable reasoning is retried once without that flag, before any output reached the user. Every request that works today is sent unchanged. **How it's switched:** prompt debug files and the background call cap are off by default (`LOG_PROMPT_DEBUG_FILES`, and **Background call cap** in Settings > Advanced > Features, with `MARINARA_BACKGROUND_CALLS_PER_HOUR` as an override). The rest has no switch because it only reports, makes a backup copy, or fixes a hard failure. - **Areas touched (for spotting overlap):** - `packages/server/src/lib`: logger, rotating sink, runtime diagnostics, freeze detector, worker gauges, new build integrity check - `packages/server/scripts`: `build.mjs`, `write-build-meta.mjs`; `config/build-info.ts`, `config/runtime-config.ts` - `packages/server/src/services/generation`: new background call budget, connection admission - `packages/server/src/services/llm/providers/openai.provider.ts` and a small reasoning-off helper - Autonomous scheduler, sidecar process, file-backed store (worker counters only), updates route - Launchers: `start.bat`, `start.sh`, `start-termux.sh`, new `scripts/preserve-untracked-src.mjs` and `scripts/open-when-ready.cmd`, `.gitattributes` - Features settings (adds number settings to the switch registry), `en.json`, `.env.example`, docs under `docs/configuration` and `docs/development/logging.md` - **Size:** about 48 files, about 2,300 added lines, including regressions. - **Status:** implemented and tested in a fork, on Windows and on Linux (WSL, the CI-equivalent run). ## Alternatives considered - **Making a stale build refuse to start:** rejected; a warning keeps every existing setup starting while making the cause visible. - **Counting interactive calls in the cap:** rejected; the cap is only there to stop unattended runaway use, never to block the user. - **Removing the `git clean` step:** it exists for good reasons, so the launcher keeps it and only backs up first. ## Additional context - Implementation depends on #6647 (foundations); PRs will follow once it merges, one package at a time. - If you're working in any of these areas, please comment so we can coordinate before a PR. ## Screenshots Taken from the fork build with invented demo data (characters, lorebooks and a campaign made up for these shots). Model replies and token counts come from a local test stub, so no real model was called. **Background call cap in Settings > Advanced > Features, with the hourly budget.** ![Background call cap in Settings > Advanced > Features, with the hourly budget](https://raw.githubusercontent.com/SirAdoni/Marinara-Engine-contrib/e98c448478676a9b4a6fad4bed1b6c29c046e9a4/roadmap/H-1-background-call-cap.png) ## Template check - [ ] I DID NOT read this template and provide the requested details.
Author
Owner

@SpicyMarinara commented on GitHub (Sep 26, 2026):

Awaiting PR.

<!-- gh-comment-id:5848662908 --> @SpicyMarinara commented on GitHub (Sep 26, 2026): Awaiting PR.
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#3752
No description provided.