[PR #569] [MERGED] Pixelforge: prototype-key reads end at a shared own() — theme resolution, resident names, brief defaults #1029

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

📋 Pull Request Information

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

Base: staging ← Head: fix/515-prototype-keys


📝 Commits (5)

  • 4bca8fa fix(pixelforge): three theme lookups whose fallback could not fire
  • 10b0a05 build(pixelforge): the shipped artifact carries the three guards
  • d6b113d fix(pixelforge): a mount and a bindings table that took the prototype's word
  • 134ce89 build(pixelforge): the shipped artifact carries the mount and table guards
  • e32ebfd docs(pixelforge): the teleport comment now names the save the bare guard was corrupting

📊 Changes

9 files changed (+377 additions, -14 deletions)

View changed files

📝 artifacts/pixelforge-0.12.0.zip (+0 -0)
📝 packages/pixelforge/client.js (+75 -6)
📝 packages/pixelforge/manifest.json (+2 -2)
📝 packages/pixelforge/src/00-prelude.js (+20 -0)
📝 packages/pixelforge/src/10-art.js (+6 -1)
📝 packages/pixelforge/src/18-brief.js (+8 -1)
📝 packages/pixelforge/src/20-world.js (+30 -3)
📝 packages/pixelforge/src/30-sim.js (+11 -1)
📝 packages/pixelforge/test-brief.mjs (+225 -0)

📄 Description

Pull request

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch to main.
Outside and first-time contributors also require an approving review from SpicyMarinara.

Linked issue

Closes #515
Closes #567

Why this change

  • #515 names two surviving sites of the prototype-key bug class the S5 gates have now caught three separate times (zone lookups, player-block maps, economy tables): setTheme's truthiness read lets "constructor" pin itself as the active theme and reach world.theme in a save row, and RESIDENT_NAMES' ??-fallback can never fire for prototype-named keys, so compile() throws and the world silently degrades to the 3-zone legacy layout with only a console warning. Probe-verified on staging: a save row themed "constructor" round-trips the hostile theme, renders every legacy zone nameless, and feeds it back into the next flush.
  • The issue's suggested cure — a shared own-property helper ending the per-site whack-a-mole — is taken as specified.

What changed

  • Affected package ID: pixelforge (catalog-excluded; the uncatalogued-manifest sweep validates it).
  • src/00-prelude.js: PF.own(map, key) — an own-property read returning the value or undefined, null-safe, immune to shadowed hasOwnProperty. Its comment records the bug class and the three prior gate catches so call sites stop re-arguing it.
  • Three sites routed through it: 10-art.js setTheme (unknown/prototype ids now resolve to the fixed default, per its own docstring), 20-world.js RESIDENT_NAMES (the documented fallback is now reachable), and a third found by survey — 18-brief.js defaults(), where defaults("__proto__") previously passed shape-validation and returned an empty brief (0 features, floored population) instead of the worked example.
  • Four fail-first harness reds (per-site guard-reverts each go red independently, plus an end-to-end red driving a hostile-themed save row through the real load path).
  • Generated outputs rebuilt in-commit per the shipped-artifact rule: client.js (772,417 B; the diff vs staging is exactly the helper + three call sites, 40 insertions / 3 deletions), manifest.json, the artifact zip. Rebuild-after-commit produces zero delta (parity).
  • Expanded per maintainer request to also close #567 (the two sites found during this branch's own verification): the zone-mount early return now own-property-tests through PF.own (the save layer's hasZone precedent — pre-fix, a prototype-named teleport id corrupted the save AND killed the frame loop), and world.bindings becomes a null-prototype map at creation. That second fix corrected #567's predicted mechanism: pre-fix the "__proto__" write was never even reached — the adoption read got Object.prototype back, the export refused its own adoption on the FIRST sync and posted a permanent twin location onto the player's real map (additive route, no delete), while the churn lived at the first-sight seeding write, which also suppressed the export entirely. A site guard would have fixed neither symptom; null-proto at creation fixes both plus the predicted one. Old saves are covered by construction (restore copies into the built table, never assigns), and the frozen envelope literal is untouched (an empty null-proto map stringifies identically).
  • Deliberately not fixed here, filed instead: the load path trusts the stored brief raw (~14 compiler read sites, one seam) → #566 with the seam fix proposed; the two further latent sites originally deferred to #567 are now IN this PR per maintainer request (see above).

Package and security impact

  • Affected package IDs: pixelforge only
  • Engine compatibility impact: none — read-side guards; no save shape changes
  • New or changed permissions/entrypoints: none
  • Restart, storage, update, or uninstall impact: none. Honest-theme worlds are byte-identical (digest-compared across both themes × multiple seeds, compiled + legacy + snapshot bytes); only prototype-named inputs change behavior — they now heal to the default instead of pinning or degrading.

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

Boxes are the human contributor's list. Agent-verified, independently replayed by a second adversarial agent:

  • A 12-assertion standalone repro (three hostile theme ids × four behaviors) goes 12-red on untouched staging, 0-red on this branch — including the silent-legacy-degrade mechanism confirmed verbatim from staging stderr (TypeError … reading 'length' out of the resident-names read).
  • Each guard reverted alone re-reds its own harness case; the tree restored clean after each.
  • PF.own survived a 25-case hostile battery (null/undefined maps, prototype keys, shadowed hasOwnProperty, throwing Proxy, null-prototype maps, inherited-vs-shadowed) with correct semantics throughout.
  • Byte-stability: both real themes × seeds — legacy digests, compiled digests, sealed-brief digests, snapshot bytes all identical to staging; frozen wire literal untouched; full harness exit 0; repo format:check/lint exit 0 (prettier 3.9.6, eslint 10.8.1); catalog lanes + locale validation exit 0.
  • Artifact parity: rebuild at head → zero git delta; manifest sha and byte counts match the shipped bundle exactly.
  • Manually verify in-app if desired: a chat whose saved theme was hand-edited to a prototype name should now load the default-theme world instead of a nameless legacy one — needs a hand-edited save, so it is optional.

Documentation impact

  • No documentation changes needed — the helper and each guarded site carry their rationale in-code; no user-facing docs describe theme resolution internals
  • Updated this README catalog and package guidance
  • Updated linked Marinara Engine documentation

Summary by CodeRabbit

  • Bug Fixes

    • Improved handling of reserved names such as constructor and __proto__ across theme selection, world generation, saved games, and teleportation.
    • Invalid or unknown theme and zone IDs are now rejected safely, with themes consistently falling back to Cozy Village.
    • Save restoration and world layouts are more resilient, with valid names retaining their existing behavior.
  • Tests

    • Added regression coverage for reserved-name handling, theme defaults, world compilation, save restoration, and teleportation.

🔄 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/569 **Author:** [@kolacheee](https://github.com/kolacheee) **Created:** 8/25/2026 **Status:** ✅ Merged **Merged:** 8/25/2026 **Merged by:** [@kolacheee](https://github.com/kolacheee) **Base:** `staging` ← **Head:** `fix/515-prototype-keys` --- ### 📝 Commits (5) - [`4bca8fa`](https://github.com/Pasta-Devs/Marinara-Agents/commit/4bca8fadf578798fddc21fdeeaa122806307dd4a) fix(pixelforge): three theme lookups whose fallback could not fire - [`10b0a05`](https://github.com/Pasta-Devs/Marinara-Agents/commit/10b0a0568deff45736088f1b35348a7ea2219fa9) build(pixelforge): the shipped artifact carries the three guards - [`d6b113d`](https://github.com/Pasta-Devs/Marinara-Agents/commit/d6b113de2db678f3e0d9e45766b63e8968d0abe4) fix(pixelforge): a mount and a bindings table that took the prototype's word - [`134ce89`](https://github.com/Pasta-Devs/Marinara-Agents/commit/134ce896d179b6469351df6e08502e77c1aa2ccc) build(pixelforge): the shipped artifact carries the mount and table guards - [`e32ebfd`](https://github.com/Pasta-Devs/Marinara-Agents/commit/e32ebfd96b45e083de5a724ba119098946052194) docs(pixelforge): the teleport comment now names the save the bare guard was corrupting ### 📊 Changes **9 files changed** (+377 additions, -14 deletions) <details> <summary>View changed files</summary> 📝 `artifacts/pixelforge-0.12.0.zip` (+0 -0) 📝 `packages/pixelforge/client.js` (+75 -6) 📝 `packages/pixelforge/manifest.json` (+2 -2) 📝 `packages/pixelforge/src/00-prelude.js` (+20 -0) 📝 `packages/pixelforge/src/10-art.js` (+6 -1) 📝 `packages/pixelforge/src/18-brief.js` (+8 -1) 📝 `packages/pixelforge/src/20-world.js` (+30 -3) 📝 `packages/pixelforge/src/30-sim.js` (+11 -1) 📝 `packages/pixelforge/test-brief.mjs` (+225 -0) </details> ### 📄 Description # Pull request > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch to `main`. > Outside and first-time contributors also require an approving review from `SpicyMarinara`. ## Linked issue Closes #515 Closes #567 ## Why this change - #515 names two surviving sites of the prototype-key bug class the S5 gates have now caught three separate times (zone lookups, player-block maps, economy tables): `setTheme`'s truthiness read lets `"constructor"` pin itself as the active theme and reach `world.theme` in a save row, and `RESIDENT_NAMES`' `??`-fallback can never fire for prototype-named keys, so `compile()` throws and the world **silently degrades to the 3-zone legacy layout** with only a console warning. Probe-verified on staging: a save row themed `"constructor"` round-trips the hostile theme, renders every legacy zone nameless, and feeds it back into the next flush. - The issue's suggested cure — a shared own-property helper ending the per-site whack-a-mole — is taken as specified. ## What changed - Affected package ID: `pixelforge` (catalog-excluded; the uncatalogued-manifest sweep validates it). - `src/00-prelude.js`: **`PF.own(map, key)`** — an own-property read returning the value or `undefined`, null-safe, immune to shadowed `hasOwnProperty`. Its comment records the bug class and the three prior gate catches so call sites stop re-arguing it. - Three sites routed through it: `10-art.js` `setTheme` (unknown/prototype ids now resolve to the fixed default, per its own docstring), `20-world.js` `RESIDENT_NAMES` (the documented fallback is now reachable), and a third found by survey — `18-brief.js` `defaults()`, where `defaults("__proto__")` previously passed shape-validation and returned an **empty** brief (0 features, floored population) instead of the worked example. - Four fail-first harness reds (per-site guard-reverts each go red independently, plus an end-to-end red driving a hostile-themed save row through the real load path). - Generated outputs rebuilt in-commit per the shipped-artifact rule: `client.js` (772,417 B; the diff vs staging is exactly the helper + three call sites, 40 insertions / 3 deletions), `manifest.json`, the artifact zip. Rebuild-after-commit produces zero delta (parity). - **Expanded per maintainer request to also close #567** (the two sites found during this branch's own verification): the zone-mount early return now own-property-tests through `PF.own` (the save layer's `hasZone` precedent — pre-fix, a prototype-named teleport id corrupted the save AND killed the frame loop), and `world.bindings` becomes a **null-prototype map at creation**. That second fix corrected #567's predicted mechanism: pre-fix the `"__proto__"` write was never even reached — the adoption read got `Object.prototype` back, the export refused its own adoption on the FIRST sync and **posted a permanent twin location onto the player's real map** (additive route, no delete), while the churn lived at the first-sight seeding write, which also suppressed the export entirely. A site guard would have fixed neither symptom; null-proto at creation fixes both plus the predicted one. Old saves are covered by construction (restore copies into the built table, never assigns), and the frozen envelope literal is untouched (an empty null-proto map stringifies identically). - Deliberately **not** fixed here, filed instead: the load path trusts the stored brief raw (~14 compiler read sites, one seam) → **#566** with the seam fix proposed; the two further latent sites originally deferred to #567 are now IN this PR per maintainer request (see above). ## Package and security impact - Affected package IDs: `pixelforge` only - Engine compatibility impact: none — read-side guards; no save shape changes - New or changed permissions/entrypoints: none - Restart, storage, update, or uninstall impact: none. Honest-theme worlds are byte-identical (digest-compared across both themes × multiple seeds, compiled + legacy + snapshot bytes); only prototype-named inputs change behavior — they now heal to the default instead of pinning or degrading. ## Validation <!-- These are human tasks. Never tick a box for a check that was not actually performed. --> - [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 Boxes are the human contributor's list. Agent-verified, independently replayed by a second adversarial agent: - A 12-assertion standalone repro (three hostile theme ids × four behaviors) goes **12-red on untouched staging, 0-red on this branch** — including the silent-legacy-degrade mechanism confirmed verbatim from staging stderr (`TypeError … reading 'length'` out of the resident-names read). - Each guard reverted **alone** re-reds its own harness case; the tree restored clean after each. - `PF.own` survived a 25-case hostile battery (null/undefined maps, prototype keys, shadowed `hasOwnProperty`, throwing Proxy, null-prototype maps, inherited-vs-shadowed) with correct semantics throughout. - Byte-stability: both real themes × seeds — legacy digests, compiled digests, sealed-brief digests, snapshot bytes all identical to staging; frozen wire literal untouched; full harness exit 0; repo `format:check`/`lint` exit 0 (prettier 3.9.6, eslint 10.8.1); catalog lanes + locale validation exit 0. - Artifact parity: rebuild at head → zero git delta; manifest sha and byte counts match the shipped bundle exactly. - Manually verify in-app if desired: a chat whose saved theme was hand-edited to a prototype name should now load the default-theme world instead of a nameless legacy one — needs a hand-edited save, so it is optional. ## Documentation impact - [x] No documentation changes needed — the helper and each guarded site carry their rationale in-code; no user-facing docs describe theme resolution internals - [ ] Updated this README catalog and package guidance - [ ] Updated linked Marinara Engine documentation <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved handling of reserved names such as `constructor` and `__proto__` across theme selection, world generation, saved games, and teleportation. * Invalid or unknown theme and zone IDs are now rejected safely, with themes consistently falling back to Cozy Village. * Save restoration and world layouts are more resilient, with valid names retaining their existing behavior. * **Tests** * Added regression coverage for reserved-name handling, theme defaults, world compilation, save restoration, and teleportation. <!-- 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:33:21 +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#1029
No description provided.