[PR #1971] [MERGED] Fix World State explicit fact drift #5367

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/1971
Author: @cha1latte
Created: 6/2/2026
Status: ✅ Merged
Merged: 6/2/2026
Merged by: @cha1latte

Base: refactor ← Head: fix/issue-1950-world-state-facts


📝 Commits (2)

  • 98aeb1e Fix world state explicit fact drift
  • 5e8dc0a Merge upstream refactor

📊 Changes

7 files changed (+323 additions, -21 deletions)

View changed files

📝 src/engine/contracts/constants/agent-prompts.test.ts (+9 -0)
📝 src/engine/contracts/constants/agent-prompts.ts (+4 -3)
📝 src/engine/generation/start-generation.ts (+11 -3)
📝 src/engine/generation/tracker-snapshots.test.ts (+87 -6)
📝 src/engine/generation/tracker-snapshots.ts (+7 -2)
➕ src/engine/generation/world-state-agent-result.test.ts (+76 -0)
📝 src/engine/generation/world-state-agent-result.ts (+129 -7)

📄 Description

Linked issue

Closes #1950

Why this change

  • World State could miss explicit day/time/temperature facts from narration or replace prior exact values on follow-up turns where those facts were not repeated.
  • The default World State prompt also encouraged genre/default inference, which made exact fact drift more likely.

What changed

  • Tightened the default World State prompt so explicit day-of-week, exact clock time, and exact temperature are authoritative.
  • Added source-text stabilization to worldStatePatchFromAgentData so explicit facts in the assistant response override vague/null agent output.
  • Threaded the assistant response text and pre-generation tracker baseline through final tracker snapshot persistence.
  • Guarded against the live optimistic tracker-result path by using the pre-generation baseline when final persistence corrects silent date/time/temperature drift.
  • Added focused Vitest coverage for explicit fact override, silent preservation, adjacent time/temperature updates, and optimistic drift correction.

Refactor impact

Primary owner:

engine generation / world-state tracker

Impact areas reviewed:

  • World State agent result parsing
  • Tracker snapshot persistence
  • Retry/rerun tracker path
  • Default built-in World State prompt

Boundary notes:

  • Engine-only change; no React UI, shared API adapter, Tauri command, schema, dependency, or storage format changes.
  • Existing location/weather and freeform fallback behavior remains in place; the new stability guard is limited to date, time, and temperature.

Pressure points touched:

  • start-generation.ts final tracker snapshot persistence
  • tracker-snapshots.ts World State patch merge
  • world-state-agent-result.ts agent result parser/fallback

Validation

  • Matching validation command passes locally (for example pnpm typecheck, pnpm build, pnpm check:architecture, pnpm check:docs, or full pnpm check when warranted)
  • Full pnpm check passes before PR push/handoff
  • Human/manual validation completed by contributor or reviewer

Manual verification notes

  • Codex ran pnpm exec vitest run src/engine/generation/world-state-agent-result.test.ts src/engine/generation/tracker-snapshots.test.ts src/engine/contracts/constants/agent-prompts.test.ts and all 7 tests passed after merging latest upstream/refactor.
  • Codex ran pnpm typecheck and it passed.
  • Codex ran full pnpm check and it passed.
  • Codex ran node C:\Users\celia\.codex\tools\marinara-proof-gate.mjs scratch\bugfix-verification.json and it passed.
  • No app UI screenshot is attached because this is backend/engine tracker logic with no visible layout change.

Feature Discoverability

Check exactly one:

  • Updated src/features/shell/discovery/ because this PR adds or materially changes a user-discoverable feature, workflow, setting, mode, panel, import path, agent, media capability, or advanced tool.
  • N/A because this PR is only a bugfix, refactor, test, docs, internal wiring, visual polish, copy edit, or compatibility fix and does not add a new thing users need to find.

Reason:

  • Bugfix only; no new user-discoverable feature or workflow.

Docs and release impact

  • No docs changes needed
  • Updated README.md
  • Updated CONTRIBUTING.md
  • Updated docs/developer/
  • Updated repo skills or AGENTS.md
  • Confirmed this PR does not restore old staging/package-workspace/release claims

UI evidence

N/A - no visible UI change.


🔄 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/1971 **Author:** [@cha1latte](https://github.com/cha1latte) **Created:** 6/2/2026 **Status:** ✅ Merged **Merged:** 6/2/2026 **Merged by:** [@cha1latte](https://github.com/cha1latte) **Base:** `refactor` ← **Head:** `fix/issue-1950-world-state-facts` --- ### 📝 Commits (2) - [`98aeb1e`](https://github.com/Pasta-Devs/Marinara-Engine/commit/98aeb1ec58ac727b1b4d0e0a6c6bdb342f78fb77) Fix world state explicit fact drift - [`5e8dc0a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/5e8dc0a21b304d2283235162f4ca342025808a0a) Merge upstream refactor ### 📊 Changes **7 files changed** (+323 additions, -21 deletions) <details> <summary>View changed files</summary> 📝 `src/engine/contracts/constants/agent-prompts.test.ts` (+9 -0) 📝 `src/engine/contracts/constants/agent-prompts.ts` (+4 -3) 📝 `src/engine/generation/start-generation.ts` (+11 -3) 📝 `src/engine/generation/tracker-snapshots.test.ts` (+87 -6) 📝 `src/engine/generation/tracker-snapshots.ts` (+7 -2) ➕ `src/engine/generation/world-state-agent-result.test.ts` (+76 -0) 📝 `src/engine/generation/world-state-agent-result.ts` (+129 -7) </details> ### 📄 Description <!-- Target branch: `refactor`. Change the base to `refactor` before submitting unless a maintainer explicitly asked for another base. --> <!-- Keep all checkboxes unchecked until a human has actually verified them. --> ## Linked issue Closes #1950 ## Why this change - World State could miss explicit day/time/temperature facts from narration or replace prior exact values on follow-up turns where those facts were not repeated. - The default World State prompt also encouraged genre/default inference, which made exact fact drift more likely. ## What changed - Tightened the default World State prompt so explicit day-of-week, exact clock time, and exact temperature are authoritative. - Added source-text stabilization to `worldStatePatchFromAgentData` so explicit facts in the assistant response override vague/null agent output. - Threaded the assistant response text and pre-generation tracker baseline through final tracker snapshot persistence. - Guarded against the live optimistic tracker-result path by using the pre-generation baseline when final persistence corrects silent date/time/temperature drift. - Added focused Vitest coverage for explicit fact override, silent preservation, adjacent time/temperature updates, and optimistic drift correction. ## Refactor impact Primary owner: engine generation / world-state tracker Impact areas reviewed: - World State agent result parsing - Tracker snapshot persistence - Retry/rerun tracker path - Default built-in World State prompt Boundary notes: - Engine-only change; no React UI, shared API adapter, Tauri command, schema, dependency, or storage format changes. - Existing location/weather and freeform fallback behavior remains in place; the new stability guard is limited to date, time, and temperature. Pressure points touched: - `start-generation.ts` final tracker snapshot persistence - `tracker-snapshots.ts` World State patch merge - `world-state-agent-result.ts` agent result parser/fallback ## Validation <!-- Check only what you personally ran or manually verified. Treat unchecked items as explicit TODOs. --> <!-- Do not submit *.test.ts or *.test.tsx files as PR proof; cite existing checks, command output, app/browser/Tauri verification, or manual notes instead. --> - [ ] Matching validation command passes locally (for example `pnpm typecheck`, `pnpm build`, `pnpm check:architecture`, `pnpm check:docs`, or full `pnpm check` when warranted) - [ ] Full `pnpm check` passes before PR push/handoff - [ ] Human/manual validation completed by contributor or reviewer ### Manual verification notes - Codex ran `pnpm exec vitest run src/engine/generation/world-state-agent-result.test.ts src/engine/generation/tracker-snapshots.test.ts src/engine/contracts/constants/agent-prompts.test.ts` and all 7 tests passed after merging latest `upstream/refactor`. - Codex ran `pnpm typecheck` and it passed. - Codex ran full `pnpm check` and it passed. - Codex ran `node C:\Users\celia\.codex\tools\marinara-proof-gate.mjs scratch\bugfix-verification.json` and it passed. - No app UI screenshot is attached because this is backend/engine tracker logic with no visible layout change. ## Feature Discoverability Check exactly one: - [ ] Updated `src/features/shell/discovery/` because this PR adds or materially changes a user-discoverable feature, workflow, setting, mode, panel, import path, agent, media capability, or advanced tool. - [ ] N/A because this PR is only a bugfix, refactor, test, docs, internal wiring, visual polish, copy edit, or compatibility fix and does not add a new thing users need to find. Reason: - Bugfix only; no new user-discoverable feature or workflow. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated `README.md` - [ ] Updated `CONTRIBUTING.md` - [ ] Updated `docs/developer/` - [ ] Updated repo skills or `AGENTS.md` - [ ] Confirmed this PR does not restore old staging/package-workspace/release claims ## UI evidence N/A - no visible UI change. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:15:40 +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#5367
No description provided.