Public: anyone can read this; the crew can change it.

Games: a mod-set install refuses a Modrinth slug that now points at a different project than the lock holds #18200

opened this

Merged 4h 19m ago, live in production

An install now checks Modrinth against the lock. If a slug the lock already holds now names a different project, or the same project under a different owner, Modrinth is asked fresh and the install is refused.

Notes

opened this

An install now checks Modrinth against the lock. If a slug the lock already holds now names a different project, or the same project under a different owner, Modrinth is asked fresh and the install is refused. Nothing is written, and the refusal names both: "essential-commands is now project ECid0002 by mallory; the lock holds ECid0001 by patbox — nothing installed. If it moved on purpose, remove Essential Commands and add essential-commands again." This covers single installs and sets (#18196).

What changed

  • src/games/modrinth.ts
    • Locked has an optional author: the project's owner on Modrinth, read from /v2/project/<id>/members.
    • resolve records the owner the first time a project is asked for, and keeps it on later updates. That is the trust-on-first-use record. Dependencies, and projects Modrinth names no owner for, get no author, so older locks and the existing tests are unchanged.
    • New slugsHold(app, lock, slugs) does the check. A slug Modrinth no longer has is left to the lock's project id, as before.
  • Freshness: the check skips the response cache. A ttlMs of 0 in api used to skip only writing to the cache, so the check was reading a 30-minute-old answer. Now 0 also skips reading.
  • src/games/mods.ts
    • planInstall and planSet call slugsHold before they resolve.
    • In an optional set (set:quality), a moved slug refuses the whole set. Otherwise it would have shown up as a "Left out …" line.
    • parseLock keeps author only when it is a string.
  • Same words everywhere: the page, the terminal (src/tui/screens/game_mods.ts) and the MCP mods_install action all show planInstall's error, so none of them changed.
  • Docs: docs/features/game-mods.md gains a "A slug that moved" entry.

Tests: test/game-mods.test.ts gains a members route on the fixture Modrinth and four tests:

  • the first install records the project id and owner;
  • a swapped project id is refused with the exact words in the planner, the page preview, MCP (dryRun: false) and the terminal (q), and the commit and lock stay unchanged;
  • the same id under a new owner is refused;
  • the same id and owner installs.

With the check switched off, the two refusal tests fail. The type check and 180 tests across 15 files pass, including the game suites, mcp-size, unused-exports, module-state and dupes. bun scripts/gate.ts reports 0 failures, and its --fix comment rewrap is in its own commit.

What I chose not to do

  • No new MCP tool or page code: the refusal comes through planInstall, which all three already share.
  • A project whose slug changes during an update (same id) is still followed, as before. Only a slug the lock holds, asked for again by install or set, is checked.
  • No reuse from bun scripts/similar.ts: ownerOf is small and Modrinth-specific, and slugsHold reuses the existing project and api helpers rather than adding new fetch paths.

Risk: a project that changes owner on purpose is refused until someone removes it and adds it again, and the refusal says so. No new outside host: api.modrinth.com is already in forge.json egress.

To try it: on a Fabric service whose lock holds essential-commands as a dependency, preview set:quality while Modrinth's slug points elsewhere. Or run bun test test/game-mods.test.ts -t 18196.

🤖 Generated with Claude Code

Closes #18196

commented

An install now checks Modrinth against the lock. If a slug the lock already holds now names a different project, or the same project under a different owner, Modrinth is asked fresh and the install is refused. Nothing is written, and the refusal names both: "essential-commands is now project ECid0002 by mallory; the lock holds ECid0001 by patbox — nothing installed. If it moved on purpose, remove Essential Commands and add essential-commands again." This covers single installs and sets (#18196).

What changed

  • src/games/modrinth.ts
    • Locked has an optional author: the project's owner on Modrinth, read from /v2/project/<id>/members.
    • resolve records the owner the first time a project is asked for, and keeps it on later updates. That is the trust-on-first-use record. Dependencies, and projects Modrinth names no owner for, get no author, so older locks and the existing tests are unchanged.
    • New slugsHold(app, lock, slugs) does the check. A slug Modrinth no longer has is left to the lock's project id, as before.
  • Freshness: the check skips the response cache. A ttlMs of 0 in api used to skip only writing to the cache, so the check was reading a 30-minute-old answer. Now 0 also skips reading.
  • src/games/mods.ts
    • planInstall and planSet call slugsHold before they resolve.
    • In an optional set (set:quality), a moved slug refuses the whole set. Otherwise it would have shown up as a "Left out …" line.
    • parseLock keeps author only when it is a string.
  • Same words everywhere: the page, the terminal (src/tui/screens/game_mods.ts) and the MCP mods_install action all show planInstall's error, so none of them changed.
  • Docs: docs/features/game-mods.md gains a "A slug that moved" entry.

Tests: test/game-mods.test.ts gains a members route on the fixture Modrinth and four tests:

  • the first install records the project id and owner;
  • a swapped project id is refused with the exact words in the planner, the page preview, MCP (dryRun: false) and the terminal (q), and the commit and lock stay unchanged;
  • the same id under a new owner is refused;
  • the same id and owner installs.

With the check switched off, the two refusal tests fail. The type check and 180 tests across 15 files pass, including the game suites, mcp-size, unused-exports, module-state and dupes. bun scripts/gate.ts reports 0 failures, and its --fix comment rewrap is in its own commit.

What I chose not to do

  • No new MCP tool or page code: the refusal comes through planInstall, which all three already share.
  • A project whose slug changes during an update (same id) is still followed, as before. Only a slug the lock holds, asked for again by install or set, is checked.
  • No reuse from bun scripts/similar.ts: ownerOf is small and Modrinth-specific, and slugsHold reuses the existing project and api helpers rather than adding new fetch paths.

Risk: a project that changes owner on purpose is refused until someone removes it and adds it again, and the refusal says so. No new outside host: api.modrinth.com is already in forge.json egress.

To try it: on a Fabric service whose lock holds essential-commands as a dependency, preview set:quality while Modrinth's slug points elsewhere. Or run bun test test/game-mods.test.ts -t 18196.

🤖 Generated with Claude Code

commented

Left #18196 open: 1 unticked item remain (When a set member (src/games/mod_sets.ts) resolves by slug through src/games/modrinth.ts, and the service's lockfile already holds that slug with a project id, a different project id or author is refused with words that name both ("essential-commands is now project X by Y; the lock holds Z by W — nothing installed").).

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs