[PR #5839] [MERGED] feat(storage): default the resident-chat cap to 8 on SteamOS and Termux #6963

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/5839
Author: @kolacheee
Created: 9/4/2026
Status: ✅ Merged
Merged: 9/4/2026
Merged by: @kolacheee

Base: staging ← Head: feat/5838-steamos-resident-chats-default


📝 Commits (2)

  • a9d00ae feat(storage): default the resident-chat cap to 8 on SteamOS and Termux (#5838)
  • 8b964ad docs: invalid cap values fall back to the platform default, they do not override it (CodeRabbit)

📊 Changes

4 files changed (+182 additions, -33 deletions)

View changed files

📝 CHANGELOG.md (+2 -0)
📝 docs/CONFIGURATION.md (+19 -19)
📝 packages/server/src/config/runtime-config.ts (+62 -10)
📝 scripts/regressions/lazy-chat-units.regression.ts (+99 -4)

📄 Description

Linked issue

Closes #5838

Why this change

A Steam Deck user's server kept dying silently mid session — no console output, "failed to fetch" on their phone, instant clean restart. The triage on #5838 fingerprinted it: every internal exit path on 2.4.4 logs before dying, so a silent death is SIGKILL, and on a device whose 16 GiB is shared with the GPU and the running game, that means the OOM killer. The timing signature confirms the mechanism — it survives idle overnight and dies only under interaction, which is exactly when load-and-keep grows the resident set (their diagnostics already showed RSS at 1.84 GiB).

Staging already has the cure (#5597 lazy loading + #5603 LRU eviction), but the cap defaults to 0 — disabled — everywhere except the Termux launcher. This PR gives constrained platforms the default engine-side.

What changed

  • When MARINARA_MAX_RESIDENT_CHATS is unset or invalid, getMaxResidentChatUnits() now returns a platform default: 8 on SteamOS (ID=steamos in /etc/os-release, read once and cached) and on Android/Termux, 0 everywhere else (the prior behavior, unchanged). An explicit value always wins, including 0 to disable.
  • Engine-side, not a launcher export, deliberately: the initial .env load never overrides inherited shell variables while hot reloads do, so a start.sh export would make a .env opt-out flap between boots and reloads. Engine-side has no competing writer, and covers systemd units and direct node dist/index.js launches too.
  • Android/Termux is included because the launcher's ${VAR:-8} only covers unset — an invalid value (=eight) was exported verbatim and silently disabled eviction on exactly the most constrained devices. Invalid values now fall back to the platform default, never to a bare 0, and the warning names the value that engaged.
  • The unset branch clears the warn-once latch, so removing and re-adding the same typo'd value warns again.
  • Docs row in docs/CONFIGURATION.md and a plain-language CHANGELOG entry.

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

  • lazy-chat-units lane extended and passing: functional detectSteamOs cases (quoted ID, CRLF, ID=steamosfoo and HOME_ID=steamos rejected, missing file fails closed, non-Linux short-circuits); the 8 is observed functionally through the exported seam (platformDefaultMaxResidentChatUnits(true) === 8), not just source-pinned; the invalid path is exercised functionally (banana → platform default); and the block is platform-aware, so it also passes — and then asserts the constrained default through the full production path — if a contributor runs it on a real Deck or in Termux.
  • Server lint clean; full build with zero TS errors.
  • An adversarial multi-agent review ran before this PR; its findings (false Termux-protection comment → fixed by actually protecting Termux; lane hard-failing on real SteamOS → fixed by platform-aware assertions; headline 8 never functionally observed → fixed via the test seam; warn-once latch gap → fixed) are folded in.
  • Not verified on real hardware: no SteamOS machine here. The reporter on #5838 effectively becomes the field test — once merged, "update to latest staging" is their entire fix, and their Support Diagnostics (staging now carries #5797) will show whether unclean exits stop.

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/CONFIGURATION.md changed, so this rides the batched [docs-i18n] follow-up per the standing convention (most of the diff there is prettier re-padding the table).

UI evidence (if applicable)

Not applicable — server configuration behavior only.

Summary by CodeRabbit

  • Bug Fixes

    • Prevented Marinara Engine from being silently force-closed during active use on Steam Deck.
    • SteamOS and Termux now limit resident chats to 8 by default, helping reduce memory usage.
    • Invalid settings now fall back to the appropriate platform default, while values below 2 are normalized.
    • The limit remains configurable; setting it to 0 disables eviction.
  • Documentation

    • Clarified platform-specific defaults, validation rules, and override behavior for resident chat limits.

🔄 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/5839 **Author:** [@kolacheee](https://github.com/kolacheee) **Created:** 9/4/2026 **Status:** ✅ Merged **Merged:** 9/4/2026 **Merged by:** [@kolacheee](https://github.com/kolacheee) **Base:** `staging` ← **Head:** `feat/5838-steamos-resident-chats-default` --- ### 📝 Commits (2) - [`a9d00ae`](https://github.com/Pasta-Devs/Marinara-Engine/commit/a9d00ae4377a737d87b75d151fdb848a0b0a1f5a) feat(storage): default the resident-chat cap to 8 on SteamOS and Termux (#5838) - [`8b964ad`](https://github.com/Pasta-Devs/Marinara-Engine/commit/8b964ada7c0b0cc8387ef1c918570e96058fc34a) docs: invalid cap values fall back to the platform default, they do not override it (CodeRabbit) ### 📊 Changes **4 files changed** (+182 additions, -33 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+2 -0) 📝 `docs/CONFIGURATION.md` (+19 -19) 📝 `packages/server/src/config/runtime-config.ts` (+62 -10) 📝 `scripts/regressions/lazy-chat-units.regression.ts` (+99 -4) </details> ### 📄 Description ## Linked issue Closes #5838 ## Why this change A Steam Deck user's server kept dying silently mid session — no console output, "failed to fetch" on their phone, instant clean restart. The triage on #5838 fingerprinted it: every internal exit path on 2.4.4 logs before dying, so a silent death is SIGKILL, and on a device whose 16 GiB is shared with the GPU and the running game, that means the OOM killer. The timing signature confirms the mechanism — it survives idle overnight and dies only under interaction, which is exactly when load-and-keep grows the resident set (their diagnostics already showed RSS at 1.84 GiB). Staging already has the cure (#5597 lazy loading + #5603 LRU eviction), but the cap defaults to `0` — disabled — everywhere except the Termux launcher. This PR gives constrained platforms the default engine-side. ## What changed - When `MARINARA_MAX_RESIDENT_CHATS` is unset **or invalid**, `getMaxResidentChatUnits()` now returns a platform default: **8 on SteamOS** (`ID=steamos` in `/etc/os-release`, read once and cached) **and on Android/Termux**, `0` everywhere else (the prior behavior, unchanged). An explicit value always wins, including `0` to disable. - **Engine-side, not a launcher export**, deliberately: the initial `.env` load never overrides inherited shell variables while hot reloads *do*, so a `start.sh` export would make a `.env` opt-out flap between boots and reloads. Engine-side has no competing writer, and covers systemd units and direct `node dist/index.js` launches too. - **Android/Termux is included** because the launcher's `${VAR:-8}` only covers *unset* — an invalid value (`=eight`) was exported verbatim and silently disabled eviction on exactly the most constrained devices. Invalid values now fall back to the platform default, never to a bare 0, and the warning names the value that engaged. - The unset branch clears the warn-once latch, so removing and re-adding the same typo'd value warns again. - Docs row in `docs/CONFIGURATION.md` and a plain-language CHANGELOG entry. ## 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 - `lazy-chat-units` lane extended and passing: functional `detectSteamOs` cases (quoted ID, CRLF, `ID=steamosfoo` and `HOME_ID=steamos` rejected, missing file fails closed, non-Linux short-circuits); the 8 is observed **functionally** through the exported seam (`platformDefaultMaxResidentChatUnits(true) === 8`), not just source-pinned; the invalid path is exercised functionally (`banana` → platform default); and the block is platform-aware, so it also passes — and then asserts the constrained default through the full production path — if a contributor runs it on a real Deck or in Termux. - Server lint clean; full build with zero TS errors. - An adversarial multi-agent review ran before this PR; its findings (false Termux-protection comment → fixed by actually protecting Termux; lane hard-failing on real SteamOS → fixed by platform-aware assertions; headline 8 never functionally observed → fixed via the test seam; warn-once latch gap → fixed) are folded in. - **Not verified on real hardware**: no SteamOS machine here. The reporter on #5838 effectively becomes the field test — once merged, "update to latest staging" is their entire fix, and their Support Diagnostics (staging now carries #5797) will show whether unclean exits stop. ## Docs and release impact - [ ] No docs changes needed - [x] 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/CONFIGURATION.md` changed, so this rides the batched `[docs-i18n]` follow-up per the standing convention (most of the diff there is prettier re-padding the table). ## UI evidence (if applicable) Not applicable — server configuration behavior only. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Bug Fixes** - Prevented Marinara Engine from being silently force-closed during active use on Steam Deck. - SteamOS and Termux now limit resident chats to 8 by default, helping reduce memory usage. - Invalid settings now fall back to the appropriate platform default, while values below 2 are normalized. - The limit remains configurable; setting it to `0` disables eviction. - **Documentation** - Clarified platform-specific defaults, validation rules, and override behavior for resident chat limits. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:15:16 +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#6963
No description provided.