[PR #8301] [MERGED] feat(macros): expose the tracked world clock in prompts #8266

Closed
opened 2026-10-26 04:04:13 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: staging ← Head: fix/world-state-time-macros-1669


📝 Commits (6)

  • e89a113 feat(macros): expose tracked world date and time
  • 9d95594 test(macros): verify tracked clocks across agent prompts and selected swipes
  • 6bce9ed fix(macros): keep tracked clock values literal and previews on the selected snapshot
  • f269258 test(macros): capture tracked clocks at the generation boundary
  • 4d96103 fix(macros): localize world-clock reference descriptions
  • 79a2c41 fix(macros): load stored clocks for assembly-only previews

📊 Changes

15 files changed (+436 additions, -11 deletions)

View changed files

📝 docs/prompts/macros.md (+8 -1)
📝 e2e/core-flows.e2e.ts (+4 -0)
📝 packages/client/src/components/ui/MacroTextarea.tsx (+5 -1)
📝 packages/client/src/lib/slash-commands.ts (+7 -4)
📝 packages/client/src/localization/locales/en.json (+3 -0)
📝 packages/server/src/routes/chats.routes.ts (+7 -5)
📝 packages/server/src/routes/generate.routes.ts (+2 -0)
📝 packages/server/src/routes/generate/dry-run-route.ts (+2 -0)
📝 packages/server/src/routes/generate/retry-agents-route.ts (+13 -0)
📝 packages/server/src/services/agents/agent-executor.ts (+10 -0)
📝 packages/server/src/services/prompt/assembler.ts (+3 -0)
📝 packages/server/src/services/prompt/macro-context.ts (+9 -0)
📝 packages/shared/src/utils/macro-engine.ts (+59 -0)
📝 scripts/regressions/prompt.regression.ts (+1 -0)
➕ scripts/regressions/world-state-time-macros.regression.ts (+303 -0)

📄 Description

Linked issue

Closes Pasta-Devs/Marinara-Agents#1669

Why this change

Prompt authors can read the real clock but cannot use World State's scene clock to control other agents. A fictional date must also stay fictional when the user changes swipes or regenerates a reply.

What changed

Add {{date.world_state}}, {{time.world_state}}, and {{weekday.world_state}} to prompts, conditionals and agent templates. Date/time retain their tracked text; weekday accepts a custom Weekday/Day of Week field, an explicit weekday, or a valid ISO date. Missing values are empty. Existing real-world macros retain their behavior.

Generation, dry-run, retry agents and live prompt preview use the selected story state. Assembly-only callers also load the stored clock when neither state input is supplied; explicit null preserves an intentionally empty clock. One cached snapshot promise keeps preview clock and lorebook processing consistent. Tracked strings are inserted literally after executable macro passes.

The reference modal and current-language slash help use semantic localization keys for the new descriptions.

Validation

  • Full pnpm check and complete pnpm regression:prompt passed on repair head 79a2c4179, including localization, formatting, lint/types and production builds.

  • The new real-database assembly-only regression fails on the prior head and passes with the fallback repair. Explicit worldState: null and gameState: null stay empty. Existing prompt, assembler-macro-budget and past-reasoning-history regressions pass unchanged apart from declaring a card-only fixture's intentionally absent snapshot store.

  • The maintained world-clock regression also covers literal/conditional macros, agent-template escaping, selected-swipe dry-run/preview, and prompts captured by a local SSE provider in Conversation, Roleplay, Game, merged group and both individual speakers. No external provider calls.

  • Existing reasoning-macro regressions passed. The macro-reference UI case passed on desktop Chromium, mobile Chromium and mobile WebKit.

  • Substantive local CodeRabbit findings were addressed. One earlier missing-generation-wiring finding was rejected after a current-code trace and an unchanged provider regression replay; that disposition is recorded in the conversation. The final three-file assembler repair review completed with zero findings.

  • Dottore's assembler fallback defect was reproduced and repaired. Its lorebook-context/null-return questions were traced separately: content resolvers retain the selected macro context and the storage methods return null when no snapshot exists.

  • Local container validation is unavailable because the installed Docker daemon is not running. Hosted container checks remain a merge gate.

  • Manually verify tracked scene clocks in prompt and agent templates.

  • Manually verify swipe/regeneration clocks and existing real-world timezone behavior.

Docs and release impact

Updated docs/prompts/macros.md; translated documentation follow-up #8303. No release or storage-format 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/8301 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 10/25/2026 **Status:** ✅ Merged **Merged:** 10/25/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/world-state-time-macros-1669` --- ### 📝 Commits (6) - [`e89a113`](https://github.com/Pasta-Devs/Marinara-Engine/commit/e89a11358dad7b0d0fa2a8f62778ea25d8ba025d) feat(macros): expose tracked world date and time - [`9d95594`](https://github.com/Pasta-Devs/Marinara-Engine/commit/9d9559491316ee401e4d58da100dff34a41f1e26) test(macros): verify tracked clocks across agent prompts and selected swipes - [`6bce9ed`](https://github.com/Pasta-Devs/Marinara-Engine/commit/6bce9edff502dafd42cf5c677ce80644a37c73be) fix(macros): keep tracked clock values literal and previews on the selected snapshot - [`f269258`](https://github.com/Pasta-Devs/Marinara-Engine/commit/f2692588ea2eeb779669f3609cd97d576b7debe8) test(macros): capture tracked clocks at the generation boundary - [`4d96103`](https://github.com/Pasta-Devs/Marinara-Engine/commit/4d961038417610a4ae53a5c4066ba1c903b935fd) fix(macros): localize world-clock reference descriptions - [`79a2c41`](https://github.com/Pasta-Devs/Marinara-Engine/commit/79a2c4179b0a0e33ce2af8e0c8fbce071fe7a656) fix(macros): load stored clocks for assembly-only previews ### 📊 Changes **15 files changed** (+436 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `docs/prompts/macros.md` (+8 -1) 📝 `e2e/core-flows.e2e.ts` (+4 -0) 📝 `packages/client/src/components/ui/MacroTextarea.tsx` (+5 -1) 📝 `packages/client/src/lib/slash-commands.ts` (+7 -4) 📝 `packages/client/src/localization/locales/en.json` (+3 -0) 📝 `packages/server/src/routes/chats.routes.ts` (+7 -5) 📝 `packages/server/src/routes/generate.routes.ts` (+2 -0) 📝 `packages/server/src/routes/generate/dry-run-route.ts` (+2 -0) 📝 `packages/server/src/routes/generate/retry-agents-route.ts` (+13 -0) 📝 `packages/server/src/services/agents/agent-executor.ts` (+10 -0) 📝 `packages/server/src/services/prompt/assembler.ts` (+3 -0) 📝 `packages/server/src/services/prompt/macro-context.ts` (+9 -0) 📝 `packages/shared/src/utils/macro-engine.ts` (+59 -0) 📝 `scripts/regressions/prompt.regression.ts` (+1 -0) ➕ `scripts/regressions/world-state-time-macros.regression.ts` (+303 -0) </details> ### 📄 Description ## Linked issue Closes Pasta-Devs/Marinara-Agents#1669 ## Why this change Prompt authors can read the real clock but cannot use World State's scene clock to control other agents. A fictional date must also stay fictional when the user changes swipes or regenerates a reply. ## What changed Add `{{date.world_state}}`, `{{time.world_state}}`, and `{{weekday.world_state}}` to prompts, conditionals and agent templates. Date/time retain their tracked text; weekday accepts a custom Weekday/Day of Week field, an explicit weekday, or a valid ISO date. Missing values are empty. Existing real-world macros retain their behavior. Generation, dry-run, retry agents and live prompt preview use the selected story state. Assembly-only callers also load the stored clock when neither state input is supplied; explicit null preserves an intentionally empty clock. One cached snapshot promise keeps preview clock and lorebook processing consistent. Tracked strings are inserted literally after executable macro passes. The reference modal and current-language slash help use semantic localization keys for the new descriptions. ## Validation - Full `pnpm check` and complete `pnpm regression:prompt` passed on repair head 79a2c4179, including localization, formatting, lint/types and production builds. - The new real-database assembly-only regression fails on the prior head and passes with the fallback repair. Explicit `worldState: null` and `gameState: null` stay empty. Existing prompt, assembler-macro-budget and past-reasoning-history regressions pass unchanged apart from declaring a card-only fixture's intentionally absent snapshot store. - The maintained world-clock regression also covers literal/conditional macros, agent-template escaping, selected-swipe dry-run/preview, and prompts captured by a local SSE provider in Conversation, Roleplay, Game, merged group and both individual speakers. No external provider calls. - Existing reasoning-macro regressions passed. The macro-reference UI case passed on desktop Chromium, mobile Chromium and mobile WebKit. - Substantive local CodeRabbit findings were addressed. One earlier missing-generation-wiring finding was rejected after a current-code trace and an unchanged provider regression replay; that disposition is recorded in the conversation. The final three-file assembler repair review completed with zero findings. - Dottore's assembler fallback defect was reproduced and repaired. Its lorebook-context/null-return questions were traced separately: content resolvers retain the selected macro context and the storage methods return null when no snapshot exists. - Local container validation is unavailable because the installed Docker daemon is not running. Hosted container checks remain a merge gate. - [ ] Manually verify tracked scene clocks in prompt and agent templates. - [ ] Manually verify swipe/regeneration clocks and existing real-world timezone behavior. ## Docs and release impact Updated `docs/prompts/macros.md`; translated documentation follow-up #8303. No release or storage-format change. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-26 04:04:13 +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#8266
No description provided.