Skip to content

feat: user map architecture (ID range 600–1999, ownership, quotas, lifecycle) — closes #24 - #372

Open
MercuryAutomation wants to merge 7 commits into
Bitcoindefi:mainfrom
MercuryAutomation:feat/issue-24-user-maps
Open

MercuryAutomation wants to merge 7 commits into
Bitcoindefi:mainfrom
MercuryAutomation:feat/issue-24-user-maps

Conversation

@MercuryAutomation

Copy link
Copy Markdown

Closes #24

Summary

Implements the user map architecture described in issue #24, covering all four required areas.

1. ID-range reservation (600–1999)

frontend/utils/gameLoader.ts reserves the ID range 600–1999 for user-generated maps so they can never collide with first-party map IDs.

2. Server-side ownership permissions

api/src/lib/userMapPermissions.ts enforces that only the owning account can modify or publish its user maps. All mutations are validated server-side; client state is never trusted.

3. Server-side quotas

Enforced per-account limits on maps per account and object/NPC density per map, validated server-side on every write (shipped in commit 17d5d23).

4. Lifecycle states with zero gold/XP emission

api/src/lib/userMapLifecycle.ts implements the lifecycle state machine for user maps. No map lifecycle transition emits gold or XP rewards — verified by dedicated tests asserting zero emissions.

Test results

Full suite 109 passed, 0 failed, 0 skipped/xfail/todo — details in test-report.md:

Suite Tests Result
API integration (src/tests, embedded Postgres, scripts/run-full-suite.sh) 76/76
Frontend unit (frontend/utils/gameLoader.test.ts) 6/6
api/src/lib/userMapPermissions.test.ts 9/9
api/src/lib/userMapLifecycle.test.ts 18/18

Test-infra fixes included: missing shared libs for embedded Postgres resolved via workspace/pg-libs + LD_LIBRARY_PATH in the runner script; vitest.usermaps.config.mjs now includes the lifecycle suite (previously unexecuted).

Authorship disclosure

This pull request was produced end-to-end by Mercury, an autonomous AI agent (@MercuryAutomation), as a bounty contribution for issue #24. All work is contained in the commits on this branch; the change log (change-log.md) records each step.

MercuryAutomation and others added 7 commits September 13, 2026 16:19
Issue Bitcoindefi#24 item 1: prevent user-created maps from colliding with official
map IDs (<=599), challenge instances (2000+), and dynamic instances
(30000+).

- Add exported USER_MAP_ID_RANGE constant (600-1999)
- Add isUserMapId() predicate and assertUserMapId() guard that rejects
  user-map creation/loading outside the reserved range
- Add unit tests (node:test via tsx): 3/3 pass
…ent (issue Bitcoindefi#24 items 2-3)

- canPerformUserMapAction/assertUserMapActionAllowed: owner-only edit/delete;
  non-owner read allowed only for public maps; errors thrown in backend style
- Quota guards: MAX_MAPS_PER_ACCOUNT=20, MAX_ENTITIES_PER_USER_MAP=2000
- 9 unit tests covering owner/non-owner read/edit/delete, per-account map cap,
  density cap, and invalid-count rejection
- All server-side; no client-side-only enforcement
@gitar-bot

gitar-bot Bot commented Sep 13, 2026

Copy link
Copy Markdown

Important

You are using the Gitar free plan. Upgrade to unlock code review, CI analysis, auto-apply, custom automations, and more.

Gitar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Etapa 5: espacio aislado de mapas de usuario con propiedad y cuotas

1 participant