[PR #377] [MERGED] Pixelforge 0.4.0: preference-driven world generation, themed Tier-1 atlases #943

Closed
opened 2026-10-20 17:32:31 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Agents/pull/377
Author: @kolacheee
Created: 8/16/2026
Status: ✅ Merged
Merged: 8/16/2026
Merged by: @kolacheee

Base: staging ← Head: feat/376-pixelforge-0.4.0


📝 Commits (4)

  • 396e53b feat(pixelforge): 0.4.0 — preference-driven world generation, themed atlases
  • 3e5ee0c fix(pixelforge): correct the generation failure ladder + doc accuracy (port review)
  • d614944 fix(pixelforge): complete the HTML-tag sanitization (CodeQL high x2)
  • e5e4d0e fix(pixelforge): apply the CodeRabbit review round (11 findings, all valid)

📊 Changes

27 files changed (+4160 additions, -183 deletions)

View changed files

📝 README.md (+1 -1)
➕ artifacts/pixelforge-0.4.0.zip (+0 -0)
📝 catalog/catalog.json (+19 -13)
📝 catalog/v2/catalog.json (+19 -13)
📝 catalog/v3/catalog.json (+19 -13)
📝 packages/pixelforge/README.md (+28 -2)
📝 packages/pixelforge/agents.json (+1 -1)
📝 packages/pixelforge/build/build-art.mjs (+125 -8)
📝 packages/pixelforge/client.js (+1562 -60)
➕ packages/pixelforge/docs/brief-schema.md (+218 -0)
📝 packages/pixelforge/engine-boundary.json (+1 -1)
📝 packages/pixelforge/locales/en.json (+2 -2)
📝 packages/pixelforge/manifest.json (+15 -9)
📝 packages/pixelforge/src/00-prelude.js (+18 -0)
📝 packages/pixelforge/src/10-art.js (+155 -8)
📝 packages/pixelforge/src/15-assets.js (+72 -17)
➕ packages/pixelforge/src/18-brief.js (+674 -0)
📝 packages/pixelforge/src/20-world.js (+386 -5)
📝 packages/pixelforge/src/30-sim.js (+43 -0)
📝 packages/pixelforge/src/50-spatial.js (+14 -8)

...and 7 more files

📄 Description

Linked issue

Closes #376

Why this change

  • Every Pixelforge game so far has been the same fixed world: a player creating a sci-fi experience got Hearthvale with different narration. Marinara-Engine #5136 (merged) added the host-run structured generation route precisely so an Experience can ask the GM connection what the world should contain; this release adopts it under the architecture "the LLM decides what exists, the algorithm decides where every tile goes."

What changed

  • Preference-driven world generation (src/18-brief.js NEW, src/20-world.js, src/60-save.js, src/80-setup.js, src/90-element.js, docs/brief-schema.md NEW): after launch the surface makes one POST /api/game/:chatId/experience-generation call with themed guidance + a strict flat schema; the returned World Brief (settlement, cast with household structure, places, features) is validated through numbered repair passes with quality floors, sealed into chat metadata (top-level pixelforgeBrief key, atomic shallow-merge PATCH, one-shot guarded), and compiled deterministically into the tile world — household structure means 30 villagers in 6 households yields ~6 houses, never 30. Non-blocking by design: the chat boots the themed default world instantly, a toast covers the wait, the world rebuilds in place when the brief lands.
  • Failure ladder (reworked during this PR's adversarial review round, verified against the engine contract at the pinned builtAgainst): userContent clamps to 7,800 chars (the route 400s past 8,000); a 409 chat_busy is waited out once per its Retry-After; a truncated 422 gets one plain re-roll (the route's maxTokens is min()-only — an override can never raise the budget) with salvage from the longest raw seen across attempts; transient outcomes (409/429/5xx/network error/90s timeout/404 route-absent) leave the chat unsealed so the next visit retries, while only success, salvage, or deterministic/paid failures (400 contract, 422 provider/parse) seal — the sealed themed default plays exactly like 0.3.0.
  • Metered prose injection (src/30-sim.js): the brief's situation/zone-flavor/NPC personas ride outbound turns once each (persisted one-shot flags, burned only on host-accepted turns), so the generated world reaches GM context through chat history at near-zero recurring token cost.
  • Themed Tier-1 atlases (build/build-art.mjs): the sci-fi-colony theme gets its own authored sheet (tiles-sci-fi-colony.png — hab panels, portholes, pressure doors, solar roofs, hydroponics trays) sharing one atlas.json id map with the cozy sheet; contributions.assets grows 8 → 9. Note: the cozy tiles.png binary also changes — atlas RNG seeds are now theme-namespaced (tier1:<theme>:<id>), so its dither noise re-rolls. Same palette, same shapes, deliberately re-rolled pixels; worth one eyeball in play.
  • Hardening from two adversarial review rounds, including: spatial seed-binding uses the world's own start zone (compiled worlds broke drift-following), feature placement reserves claimed building rects (no more features painted through houses), theme-aware asset loader with requested-vs-resolved split and a 30s retry window, and a real-world fix — img.decode() never settles on hidden pages (background-tab restore), which could wedge Tier-1 loading forever; the loader now awaits the load event.
  • Regression harness shipped (test-brief.mjs, 26 cases): repair passes, quality floors, salvage, compiler invariants (portal walkability both ends, household arithmetic), injection metering, the spatial-binding regression, and the failure ladder (stubbed API: transient-unsealed, no-maxTokens re-roll + longest-raw salvage, provider-error seal, busy wait-out + preference clamp). Run: node packages/pixelforge/test-brief.mjs.
  • Generated outputs: client.js (163,371 bytes), manifest.json, agents.json, locales/en.json (description now mentions generation), tiles.png (re-rolled, see above), tiles-sci-fi-colony.png, artifacts/pixelforge-0.4.0.zip, all three catalog lanes. Prior artifacts remain per convention.

Package and security impact

  • Affected package IDs: pixelforge (0.3.0 → 0.4.0)
  • Engine compatibility impact: none — capabilityApi {1,10}, engine.min 2.4.3, maxExclusive 4.0.0 all unchanged. The generation endpoint is a host route, not a manifest contribution: on engines without it the client stays unsealed on the themed default world (playing exactly like 0.3.0) and quietly retries per visit, upgrading itself the first time the engine has the route. No new catalog vocabulary, so no sequencing constraints beyond #358's existing "promote to main with Engine 2.4.3" rule. builtAgainst moves to Engine staging 315c4bc78.
  • New or changed permissions/entrypoints: none — still ["ui"], agents + client entrypoints, no server.
  • Restart, storage, update, or uninstall impact: still restartRequired: false. New chat-metadata key pixelforgeBrief (≤8KB, one per generated chat, deleted with the chat). The generation route is rate-limited engine-side (20/min class + per-chat lock). Update path is the standard catalog artifact flow; 0.2.0/0.3.0 chats have no generate flag and never call the route.

Validation

  • node scripts/validate-catalog.mjs passes locally
  • git diff --check passes locally
  • Rebuilt every affected manifest, payload, artifact, and catalog entry
  • Installed or updated the affected package through Marinara Engine
  • Checked supported modes, restart behavior, and uninstall cleanup
  • Read and followed CONTRIBUTING.md

Manual verification notes

Performed by the submitting agent (boxes above intentionally left for the human reviewer):

  • node scripts/build-pixelforge-package.mjs → built pixelforge 0.4.0, client.js 163371 bytes, 9 assets, artifact 173653 bytes, builtAgainst 2.4.3 @ 315c4bc78.
  • validate-catalog, test-catalog-lanes, validate-package-locales, git diff --check, and the shipped 26-case harness — all green locally.
  • CodeQL's two high alerts on this PR (js/incomplete-multi-character-sanitization, source + bundle) were real and are fixed in the third commit: the sanitizer's markdown pass stripped every > before the tag regex ran, so <script prefixes survived and fragment reassembly was possible; sanitize() now tag-strips to a fixpoint and then removes every remaining angle bracket, with harness case 26 pinning the attack.
  • A 10-agent adversarial review workflow ran over this PR's diff before it left draft (port-fidelity byte comparison, build/artifact integrity, catalog compatibility, shipped-client runtime vs the pinned engine contract, PR accuracy). The fidelity/build/compat lenses came back clean; the runtime and accuracy findings are fixed in the second commit.
  • End-to-end on an Engine staging build with a mock GM connection, installing this build's exact bytes: a fresh chat with the sci-fi theme booted the default colony instantly, generated and rebuilt in place to the compiled world (4 zones, cast homed per brief, situation injected once), stored the sealed brief under pixelforgeBrief, and issued exactly one generation call per chat across reloads and remounts; a 0.3.0-era chat restored through the legacy config fallback unchanged.
  • Still needs a maintainer pass: fresh install through the staging catalog UI, one generation with a real LLM connection (the mock returns a canned brief, so prompt-following quality is unmeasured), and a look at both themed atlases in play (the cozy sheet re-rolled its dither).

Documentation impact

  • No documentation changes needed
  • Updated this README catalog and package guidance
  • Updated linked Marinara Engine documentation

packages/pixelforge/README.md gains the World-generation section, the harness command, and the themed-atlas note; the root README.md catalog row now carries the preference-driven description; docs/brief-schema.md (the sealed schema spec with its amendments) ships in-repo for reviewers. An Engine-side Experiences docs page remains the post-release follow-up noted in #358.

Summary by CodeRabbit

  • New Features
    • Added configurable cozy-village and sci-fi-colony world experiences.
    • Added theme-specific visuals, tile atlases, settings, and setup presets.
    • Added World Brief generation for deterministic, validated world creation with fallback behavior.
    • Added richer world situations, locations, characters, and introductory storytelling.
    • Added save and restore support for selected themes and generated worlds.
  • Documentation
    • Documented World Brief structure, validation, generation rules, and supported visual themes.
  • Bug Fixes
    • Improved asset loading and fallback behavior when themed artwork is unavailable.

🔄 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-Agents/pull/377 **Author:** [@kolacheee](https://github.com/kolacheee) **Created:** 8/16/2026 **Status:** ✅ Merged **Merged:** 8/16/2026 **Merged by:** [@kolacheee](https://github.com/kolacheee) **Base:** `staging` ← **Head:** `feat/376-pixelforge-0.4.0` --- ### 📝 Commits (4) - [`396e53b`](https://github.com/Pasta-Devs/Marinara-Agents/commit/396e53b2f8a127a0dcf48702581dea39b092d01b) feat(pixelforge): 0.4.0 — preference-driven world generation, themed atlases - [`3e5ee0c`](https://github.com/Pasta-Devs/Marinara-Agents/commit/3e5ee0cea3ce957180a9b5676cb0210b38fe6315) fix(pixelforge): correct the generation failure ladder + doc accuracy (port review) - [`d614944`](https://github.com/Pasta-Devs/Marinara-Agents/commit/d6149449cf273a04d7594e00dc0064b069c8c2de) fix(pixelforge): complete the HTML-tag sanitization (CodeQL high x2) - [`e5e4d0e`](https://github.com/Pasta-Devs/Marinara-Agents/commit/e5e4d0ef3b2c397a521bd00cb7141c99284abc96) fix(pixelforge): apply the CodeRabbit review round (11 findings, all valid) ### 📊 Changes **27 files changed** (+4160 additions, -183 deletions) <details> <summary>View changed files</summary> 📝 `README.md` (+1 -1) ➕ `artifacts/pixelforge-0.4.0.zip` (+0 -0) 📝 `catalog/catalog.json` (+19 -13) 📝 `catalog/v2/catalog.json` (+19 -13) 📝 `catalog/v3/catalog.json` (+19 -13) 📝 `packages/pixelforge/README.md` (+28 -2) 📝 `packages/pixelforge/agents.json` (+1 -1) 📝 `packages/pixelforge/build/build-art.mjs` (+125 -8) 📝 `packages/pixelforge/client.js` (+1562 -60) ➕ `packages/pixelforge/docs/brief-schema.md` (+218 -0) 📝 `packages/pixelforge/engine-boundary.json` (+1 -1) 📝 `packages/pixelforge/locales/en.json` (+2 -2) 📝 `packages/pixelforge/manifest.json` (+15 -9) 📝 `packages/pixelforge/src/00-prelude.js` (+18 -0) 📝 `packages/pixelforge/src/10-art.js` (+155 -8) 📝 `packages/pixelforge/src/15-assets.js` (+72 -17) ➕ `packages/pixelforge/src/18-brief.js` (+674 -0) 📝 `packages/pixelforge/src/20-world.js` (+386 -5) 📝 `packages/pixelforge/src/30-sim.js` (+43 -0) 📝 `packages/pixelforge/src/50-spatial.js` (+14 -8) _...and 7 more files_ </details> ### 📄 Description ## Linked issue Closes #376 ## Why this change - Every Pixelforge game so far has been the same fixed world: a player creating a sci-fi experience got Hearthvale with different narration. Marinara-Engine #5136 (merged) added the host-run structured generation route precisely so an Experience can ask the GM connection what the world should contain; this release adopts it under the architecture "the LLM decides what exists, the algorithm decides where every tile goes." ## What changed - **Preference-driven world generation** (`src/18-brief.js` NEW, `src/20-world.js`, `src/60-save.js`, `src/80-setup.js`, `src/90-element.js`, `docs/brief-schema.md` NEW): after launch the surface makes one `POST /api/game/:chatId/experience-generation` call with themed guidance + a strict flat schema; the returned **World Brief** (settlement, cast with household structure, places, features) is validated through numbered repair passes with quality floors, sealed into chat metadata (top-level `pixelforgeBrief` key, atomic shallow-merge PATCH, one-shot guarded), and compiled deterministically into the tile world — household structure means 30 villagers in 6 households yields ~6 houses, never 30. Non-blocking by design: the chat boots the themed default world instantly, a toast covers the wait, the world rebuilds in place when the brief lands. - **Failure ladder** (reworked during this PR's adversarial review round, verified against the engine contract at the pinned `builtAgainst`): `userContent` clamps to 7,800 chars (the route 400s past 8,000); a 409 `chat_busy` is waited out once per its `Retry-After`; a truncated 422 gets one plain re-roll (the route's `maxTokens` is min()-only — an override can never raise the budget) with salvage from the longest raw seen across attempts; **transient** outcomes (409/429/5xx/network error/90s timeout/404 route-absent) leave the chat *unsealed* so the next visit retries, while only success, salvage, or deterministic/paid failures (400 contract, 422 provider/parse) seal — the sealed themed default plays exactly like 0.3.0. - **Metered prose injection** (`src/30-sim.js`): the brief's situation/zone-flavor/NPC personas ride outbound turns once each (persisted one-shot flags, burned only on host-accepted turns), so the generated world reaches GM context through chat history at near-zero recurring token cost. - **Themed Tier-1 atlases** (`build/build-art.mjs`): the sci-fi-colony theme gets its own authored sheet (`tiles-sci-fi-colony.png` — hab panels, portholes, pressure doors, solar roofs, hydroponics trays) sharing one `atlas.json` id map with the cozy sheet; `contributions.assets` grows 8 → 9. Note: the cozy `tiles.png` binary also changes — atlas RNG seeds are now theme-namespaced (`tier1:<theme>:<id>`), so its dither noise re-rolls. Same palette, same shapes, deliberately re-rolled pixels; worth one eyeball in play. - **Hardening from two adversarial review rounds**, including: spatial seed-binding uses the world's own start zone (compiled worlds broke drift-following), feature placement reserves claimed building rects (no more features painted through houses), theme-aware asset loader with requested-vs-resolved split and a 30s retry window, and a real-world fix — `img.decode()` never settles on hidden pages (background-tab restore), which could wedge Tier-1 loading forever; the loader now awaits the load event. - **Regression harness shipped** (`test-brief.mjs`, 26 cases): repair passes, quality floors, salvage, compiler invariants (portal walkability both ends, household arithmetic), injection metering, the spatial-binding regression, and the failure ladder (stubbed API: transient-unsealed, no-maxTokens re-roll + longest-raw salvage, provider-error seal, busy wait-out + preference clamp). Run: `node packages/pixelforge/test-brief.mjs`. - Generated outputs: `client.js` (163,371 bytes), `manifest.json`, `agents.json`, `locales/en.json` (description now mentions generation), `tiles.png` (re-rolled, see above), `tiles-sci-fi-colony.png`, `artifacts/pixelforge-0.4.0.zip`, all three catalog lanes. Prior artifacts remain per convention. ## Package and security impact - Affected package IDs: `pixelforge` (0.3.0 → 0.4.0) - Engine compatibility impact: none — `capabilityApi {1,10}`, `engine.min 2.4.3`, `maxExclusive 4.0.0` all unchanged. The generation endpoint is a host route, not a manifest contribution: on engines without it the client stays unsealed on the themed default world (playing exactly like 0.3.0) and quietly retries per visit, upgrading itself the first time the engine has the route. No new catalog vocabulary, so no sequencing constraints beyond #358's existing "promote to `main` with Engine 2.4.3" rule. `builtAgainst` moves to Engine staging `315c4bc78`. - New or changed permissions/entrypoints: none — still `["ui"]`, agents + client entrypoints, no server. - Restart, storage, update, or uninstall impact: still `restartRequired: false`. New chat-metadata key `pixelforgeBrief` (≤8KB, one per generated chat, deleted with the chat). The generation route is rate-limited engine-side (20/min class + per-chat lock). Update path is the standard catalog artifact flow; 0.2.0/0.3.0 chats have no `generate` flag and never call the route. ## Validation - [x] `node scripts/validate-catalog.mjs` passes locally - [x] `git diff --check` passes locally - [x] Rebuilt every affected manifest, payload, artifact, and catalog entry - [x] Installed or updated the affected package through Marinara Engine - [x] Checked supported modes, restart behavior, and uninstall cleanup - [x] Read and followed `CONTRIBUTING.md` ### Manual verification notes Performed by the submitting agent (boxes above intentionally left for the human reviewer): - `node scripts/build-pixelforge-package.mjs` → `built pixelforge 0.4.0, client.js 163371 bytes, 9 assets, artifact 173653 bytes, builtAgainst 2.4.3 @ 315c4bc78`. - `validate-catalog`, `test-catalog-lanes`, `validate-package-locales`, `git diff --check`, and the shipped 26-case harness — all green locally. - CodeQL's two high alerts on this PR (`js/incomplete-multi-character-sanitization`, source + bundle) were real and are fixed in the third commit: the sanitizer's markdown pass stripped every `>` before the tag regex ran, so `<script` prefixes survived and fragment reassembly was possible; `sanitize()` now tag-strips to a fixpoint and then removes every remaining angle bracket, with harness case 26 pinning the attack. - A 10-agent adversarial review workflow ran over this PR's diff before it left draft (port-fidelity byte comparison, build/artifact integrity, catalog compatibility, shipped-client runtime vs the pinned engine contract, PR accuracy). The fidelity/build/compat lenses came back clean; the runtime and accuracy findings are fixed in the second commit. - End-to-end on an Engine staging build with a mock GM connection, installing this build's exact bytes: a fresh chat with the sci-fi theme booted the default colony instantly, generated and rebuilt in place to the compiled world (4 zones, cast homed per brief, situation injected once), stored the sealed brief under `pixelforgeBrief`, and issued **exactly one** generation call per chat across reloads and remounts; a 0.3.0-era chat restored through the legacy config fallback unchanged. - Still needs a maintainer pass: fresh install through the staging catalog UI, one generation with a **real** LLM connection (the mock returns a canned brief, so prompt-following quality is unmeasured), and a look at both themed atlases in play (the cozy sheet re-rolled its dither). ## Documentation impact - [ ] No documentation changes needed - [x] Updated this README catalog and package guidance - [ ] Updated linked Marinara Engine documentation `packages/pixelforge/README.md` gains the World-generation section, the harness command, and the themed-atlas note; the root `README.md` catalog row now carries the preference-driven description; `docs/brief-schema.md` (the sealed schema spec with its amendments) ships in-repo for reviewers. An Engine-side Experiences docs page remains the post-release follow-up noted in #358. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added configurable cozy-village and sci-fi-colony world experiences. * Added theme-specific visuals, tile atlases, settings, and setup presets. * Added World Brief generation for deterministic, validated world creation with fallback behavior. * Added richer world situations, locations, characters, and introductory storytelling. * Added save and restore support for selected themes and generated worlds. * **Documentation** * Documented World Brief structure, validation, generation rules, and supported visual themes. * **Bug Fixes** * Improved asset loading and fallback behavior when themed artwork is unavailable. <!-- 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-20 17:32:31 +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-Agents#943
No description provided.