mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #6647] [MERGED] feat: engine foundations (isolated regression runs, request id trail, feature switches, opt-in lorebook and robustness settings) #7273
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#7273
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/6647
Author: @SirAdoni
Created: 9/25/2026
Status: ✅ Merged
Merged: 9/26/2026
Merged by: @SpicyMarinara
Base:
staging← Head:contrib/foundations📝 Commits (10+)
35ec310test: isolate each regression file's storage and .env in the runner1c52f07feat(server): request id trail, startup timeline and one line per failure in logsbd3982fperf(server): stable lorebook group winners and compact stored lorebook scans (both opt-in)6f67626fix(server): opt-in robustness settings for storage writes, Windows boot, shutdown and provider retry, plus runtime diagnostics00dfecbfix(server): hold early internal inject() calls until startup registration ends12319f4feat: feature switches in Settings > Advanced > Features39a456arefactor(server): logged best-effort helpers for deliberately swallowed failures1143b4adocs: map the engine foundations series in one overview883869dfix(server): give the runtime diagnostics route its own rate limit806d4cdfix(test): make the shutdown source checks linear-time regexes📊 Changes
87 files changed (+6268 additions, -246 deletions)
View changed files
📝
.env.example(+33 -0)📝
CHANGELOG.md(+6 -0)📝
CONTRIBUTING.md(+12 -0)📝
docs/CONFIGURATION.md(+32 -0)➕
docs/configuration/features.md(+57 -0)➕
docs/contrib/engine-foundations-overview.md(+308 -0)➕
docs/development/logging.md(+104 -0)📝
docs/settings/settings-overview.md(+2 -2)📝
packages/client/src/components/panels/SettingsPanel.tsx(+19 -0)➕
packages/client/src/components/panels/settings/FeatureSwitchesSettings.tsx(+71 -0)➕
packages/client/src/hooks/use-feature-settings.ts(+46 -0)📝
packages/client/src/localization/locales/en.json(+9 -0)📝
packages/server/src/app.ts(+83 -36)📝
packages/server/src/config/cors-config.ts(+2 -1)📝
packages/server/src/config/env-watcher.ts(+9 -0)📝
packages/server/src/config/runtime-config.ts(+72 -0)📝
packages/server/src/db/connection.ts(+11 -1)📝
packages/server/src/db/file-backed-store.ts(+269 -25)➕
packages/server/src/db/writer-boot-id-cache.ts(+83 -0)📝
packages/server/src/index.ts(+52 -18)...and 67 more files
📄 Description
Base:
staging(e15c9e558) · Head:contrib/foundations(d4c282404)Linked issue
Closes #6624
Part 1 of the engine foundations series, see #6624.
This PR is independent of the other parts. It targets
stagingdirectly and can be merged, reviewed or declined on its own. Parts 4 to 8 (D to H) build on it and open after it merges. Parts 2 and 3 (B, C) do not need it.Why this change
DATA_DIR,FILE_STORAGE_DIRor the.envfile."error"on later starts.Every piece builds on code that already exists and works. Nothing renames an upstream API, replaces the shared logger or changes a file's conventions.
docs/contrib/engine-foundations-overview.mdexplains each piece in five parts: what exists today, what this adds, what stays exactly the same, how to check it, and how to turn it off or revert it. It also maps the whole series.What changed
17 commits on
staginge15c9e558, oldest first, 86 files:5c5bce0a1test: isolate each regression file's storage and .env in the runner.b1576f4e4feat(server): request id trail, startup timeline and one line per failure in logs.aab0080cdperf(server): stable lorebook group winners and compact stored lorebook scans (both opt-in).11c94dfe6fix(server): opt-in robustness settings for storage writes, Windows boot, shutdown and provider retry, plus runtime diagnostics.8a1a71e06fix(server): hold early internal inject() calls until startup registration ends.b50dec60cfeat: feature switches in Settings > Advanced > Features.416f7fe2erefactor(server): logged best-effort helpers for deliberately swallowed failures.6629ab7e9docs: map the engine foundations series in one overview.fa7daa8b2fix(server): give the runtime diagnostics route its own rate limit.69a196ebbfix(test): make the shutdown source checks linear-time regexes.5fe1c57c8fix(server): let the lorebook group seed also decide the Active Context preview.14451af75fix(server): pass a synchronous inject() throw to a held call's callback.a35f5fb81fix(client): refresh the feature switches after 30 seconds, like the extension policy.230ef84cbfix: leave the two switch variables commented out in .env.example.0cb02af33fix(server): resolve macros in stored lorebook text used by agent retries.7037ec93efix(server): make seeded lorebook group picks independent of activation order.d4c282404fix(server): keep JSON parse messages out of the scene wrap warning.Defaults. Anything that changes stored data, prompts or retries is off by default, behind an environment variable or a switch in Settings > Advanced > Features. With nothing turned on, upstream behaviour is unchanged. The pieces with no switch are bug fixes, the test runner and additive helpers.
Regression runner isolation (
5c5bce0a1)runRegression()gives each file a temporary folder with its ownDATA_DIR,FILE_STORAGE_DIRandMARINARA_ENV_FILE, removed when the file finishes. A regression can no longer read the developer's.envor collide with the writer lease on their real data folder.--filterand--listflags, timeouts, summary output, scripts and CI are unchanged.Logging: request id trail, startup timeline, one line per failure (
b1576f4e4)req.loglines use the same serializers and followLOG_LEVELhot reloads, asCONTRIBUTING.mdalready describes.requestId(also returned asx-request-id), and every line carriesbootId.[startup] Ready in N msline at info, and a failed boot names the step it failed in.causechain. User stops log at info, repeating failures are rate limited, and model or provider text stays at debug.LOG_LEVEL=warn. Details, including the renamedreqIdfield, are indocs/development/logging.md.Lorebooks (
aab0080cd, opt-in)LOREBOOK_STABLE_GROUP_WINNERS(switch Stable lorebook picks): the same inclusion-group winner in a chat while its candidates stay the same, so the prompt prefix stays cacheable. Uses upstream's ownstableHashandcreateSeededRandom, moved unchanged intolorebook/seeded-random.ts.LOREBOOK_COMPACT_STORED_SCANS: only the newest reply keeps the full entry text in its stored scan.scripts/compact-lorebook-scans.mjsapplies the same rule to older chats, dry run by default.Robustness (
11c94dfe6, opt-in)PROVIDER_RETRY_TRANSIENT_ERRORS(switch Retry failed provider calls): a refused connection or a gateway 502/503 is retried at most twice, only before any output reached the user, and never on the primary leg of a connection with a fallback.GET /api/admin/runtime-diagnostics: a read-only, privileged snapshot of storage residency and capability runtime state. It is rate limited to 30 requests a minute through an entry in the rate-limit middleware's route list (ROUTE_RULES), becausestaging's middleware does not read a route's ownconfig.rateLimit.Startup inject gate (
8a1a71e06, bug fix, always on)app.inject()calls made beforebuildApp()has finished registering are held and run once registration ends.inject()made directly from a package'sactivate()orselfCheck()fails at once instead of hanging startup, and only that package fails to activate."error", and is retried on the next start.Feature switches (
b50dec60c)packages/shared/src/schemas/feature-settings.schema.ts) and one settings section, Settings > Advanced > Features. Server code reads an in-memory copy throughisFeatureEnabled(), so busy paths pay nothing.stableLorebookGroupPicksandproviderRetry. Both are off.LOREBOOK_STABLE_GROUP_WINNERSandPROVIDER_RETRY_TRANSIENT_ERRORSwin when set, and the switch is then shown locked with the variable's name.Best-effort helpers (
416f7fe2e)lib/best-effort.ts:logSuppressed,orFallbackandbestEffortlog a deliberately swallowed failure throughlogRateLimited. Nothing calls them yet in this PR. The reviewed fixes in parts 4 and 5 (D, E) use them.Hand security review (
fa7daa8b2,69a196ebb)Review fixes (local CodeRabbit)
0cb02af33).7037ec93e).5fe1c57c8).inject()throw in a held callback call reaches the callback (14451af75).d4c282404)..env.exampleno longer locks the two switches off (230ef84cb).a35f5fb81).Matching existing UI
SettingsSectionandToggleSetting(SettingsPanel.tsx,SettingControls.tsx).Validation
pnpm checkpasses locally - Had 2 steps fail, but it is from M.E code, not my own.CONTRIBUTING.mdThe boxes are left unticked for a human, per
AGENTS.md. Everything below ran on the tipd4c282404. No paid model calls were made.complete-node-regressions384 / 384decision-sidecar-runtime,gallery-previews,request-timeouts,server-signal-shutdown,storage-writer-lock) and fail the same way on plainstaging.tsc --noEmit(shared, server, client, root, token estimation)mobile-chromium, settings specs (core-flows,issue-sweep-settings,ux-feedback-sweep,afternoon-sweep,client-runtime-diagnostics)mobile-webkit, same specsstaging.Manual verification notes
logging-request-trail,logging-failure-lines,logging-startup-timeline,lorebook-group-seed,lorebook-scan-compaction,robustness-storage-write,robustness-boot-performance,robustness-shutdown-safety,robustness-provider-resilience,robustness-runtime-diagnostics,startup-inject-gate,feature-settings,best-effort.Human to tick
Based on the evidence above:
pnpm checkpasses locally: supported. Its steps (tsc, lint, Prettier, locales, builds, regressions) all passed, apart from the 5 known Windows-only failures, and Linux is 384 / 384. If you want the literal command, runpnpm checkonce before ticking.CHANGELOG.md,CONTRIBUTING.md,.env.example,docs/CONFIGURATION.md,docs/configuration/features.md,docs/development/logging.md,docs/settings/settings-overview.mdand the overview).Not supported by the evidence, leave unticked unless done by hand:
CONTRIBUTING.md: only a human can confirm these.Needs manual verification
mobile-chromiumandmobile-webkit.CONTRIBUTING.mdLogging line and the new docs need a[docs-i18n]follow-up issue for the translated guides.Docs and release impact
docs-i18nbranch updated to match, or a[docs-i18n]follow-up issue opened (see CONTRIBUTING.md § Translated documentation)The PR adds six CHANGELOG entries under
[Unreleased], a link from the Logging section ofCONTRIBUTING.mdtodocs/development/logging.md, a Lorebooks and a Robustness table indocs/CONFIGURATION.md,docs/configuration/features.md, commented-out entries in.env.example, anddocs/contrib/engine-foundations-overview.md. No version bump.UI evidence (if applicable)
Screenshot from a test instance with invented data, taken on this branch.
Settings > Advanced > Features
Remaining steps
🤖 Generated with Claude Code
Summary by CodeRabbit
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.