feat: user map architecture (ID range 600–1999, ownership, quotas, lifecycle) — closes #24 - #372
Open
MercuryAutomation wants to merge 7 commits into
Open
MercuryAutomation wants to merge 7 commits into
MercuryAutomation wants to merge 7 commits into
Conversation
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
…le); add reproducible full-suite runner
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.tsreserves 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.tsenforces 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.tsimplements 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:src/tests, embedded Postgres,scripts/run-full-suite.sh)frontend/utils/gameLoader.test.ts)api/src/lib/userMapPermissions.test.tsapi/src/lib/userMapLifecycle.test.tsTest-infra fixes included: missing shared libs for embedded Postgres resolved via
workspace/pg-libs+LD_LIBRARY_PATHin the runner script;vitest.usermaps.config.mjsnow 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.