fix(demo): seed NPC profiles, factions and chat styles (DM26) #65

Merged
whitlocktech merged 4 commits from feat/demo-seed-npcs-chat into edge 2026-10-27 20:22:46 -05:00
Member

What & why

The demo restores its rig from a baseline, then wipes the site; the fresh site imports what it finds on the rig (website DEMO_MODE.md §7.1). The first three restored wipes (website runs 367-369) brought the default set's groups, permissions and members back. Two things didn't come back:

  • NPC profiles. The restored rig's RunicNPC says it is already managed, by the site before this one. The fresh site therefore adopts nothing (D244: data.managed ? []), and its first push sends an empty profile set. Afterwards the baseline's placements bandit-1, bandit-2 and guard-1 sit at "profile 'bandit' is missing", with 0 NPCs alive.
  • Chat titles. The import never adopts a group's BetterChat style, so vip and moderator show chat: null.

The org lead chose (DM26) to seed them. onDemoSeed now also takes:

Key Written through Notes
npcs.factions npcs.setFactions the faction table
npcs.profiles[] npcs.create / npcs.update checked exactly as the admin page checks a profile; one that already exists by name is updated
chat[] { serverId, group, style } permissions.db.setGroupChat BetterChat's defaults filled in (chatStyle.defaults), validated whole

The seed runs before the site's first permission read, so a chat style's group doesn't exist on the site yet. The seed creates it for that server. The first import then treats the rig's group of that name as a change, and adopts its title, rank and permissions into the existing group (reconcile.js, the first-inventory branch). The style is stored separately, so the import leaves it alone.

The new parts of the section are checked before anything is written. Off the demo nothing changes: core calls onDemoSeed only from seed:demo, and only with DEMO_MODE=true.

Release: once this reaches main, the fix makes it v0.6.1 (same coreApi ^1.19.0, same protocol 14). The demo's wipe picks it up by itself. The fixture side is website#230.

How it was tested

  • test/demo.test.js has 2 new cases:

    • the shape checks: 6 problems on a bad section, nothing written on a bad style;
    • the writes, in order: factions, then update-or-create per profile, then for each group its style, creating the group when it's missing, plus markDirty.
  • Full server suite: 730 tests, 0 failures. check:imports and check:bundle pass.

  • The demo fixture (website/deploy/demo/seed.json on website#230) passes checkSection, apart from its two $env: placeholders, which the seed fills in before calling the hook. Both profile bodies pass npcProfile.checkBody.

  • The same model calls (setFactions, profile create, and the chat style through the group PATCH) were made live on the demo through the admin API on 2026-10-27, and the NPCs spawned.

  • Not yet run: the whole flow on a fresh demo database. The first wipe after v0.6.1 is released and website#230 is merged is that test, and I'll check it.

  • AI-assisted: Claude Code (Claude Opus 5.5)

🤖 Generated with Claude Code

https://claude.ai/code/session_01E14m6SuuY6i1vASFeGDBeY

## What & why The demo restores its rig from a baseline, then wipes the site; the fresh site imports what it finds on the rig (website `DEMO_MODE.md` §7.1). The first three restored wipes (website runs 367-369) brought the default set's **groups, permissions and members** back. Two things didn't come back: - **NPC profiles.** The restored rig's RunicNPC says it is already *managed*, by the site before this one. The fresh site therefore adopts nothing (D244: `data.managed ? []`), and its first push sends an empty profile set. Afterwards the baseline's placements `bandit-1`, `bandit-2` and `guard-1` sit at *"profile 'bandit' is missing"*, with 0 NPCs alive. - **Chat titles.** The import never adopts a group's BetterChat style, so `vip` and `moderator` show `chat: null`. The org lead chose (DM26) to **seed them**. `onDemoSeed` now also takes: | Key | Written through | Notes | | --- | --- | --- | | `npcs.factions` | `npcs.setFactions` | the faction table | | `npcs.profiles[]` | `npcs.create` / `npcs.update` | checked exactly as the admin page checks a profile; one that already exists by name is updated | | `chat[]` `{ serverId, group, style }` | `permissions.db.setGroupChat` | BetterChat's defaults filled in (`chatStyle.defaults`), validated whole | The seed runs **before** the site's first permission read, so a chat style's group doesn't exist on the site yet. The seed creates it for that server. The first import then treats the rig's group of that name as a change, and adopts its title, rank and permissions into the existing group (`reconcile.js`, the first-inventory branch). The style is stored separately, so the import leaves it alone. The new parts of the section are checked before anything is written. Off the demo nothing changes: core calls `onDemoSeed` only from `seed:demo`, and only with `DEMO_MODE=true`. **Release:** once this reaches `main`, the `fix` makes it **v0.6.1** (same `coreApi ^1.19.0`, same protocol 14). The demo's wipe picks it up by itself. The fixture side is website#230. ## How it was tested - `test/demo.test.js` has 2 new cases: - the shape checks: 6 problems on a bad section, nothing written on a bad style; - the writes, in order: factions, then update-or-create per profile, then for each group its style, creating the group when it's missing, plus `markDirty`. - Full server suite: **730 tests, 0 failures**. `check:imports` and `check:bundle` pass. - The demo fixture (`website/deploy/demo/seed.json` on website#230) passes `checkSection`, apart from its two `$env:` placeholders, which the seed fills in before calling the hook. Both profile bodies pass `npcProfile.checkBody`. - The same model calls (`setFactions`, profile create, and the chat style through the group PATCH) were made live on the demo through the admin API on 2026-10-27, and the NPCs spawned. - **Not yet run:** the whole flow on a fresh demo database. The first wipe after v0.6.1 is released and website#230 is merged is that test, and I'll check it. - [x] AI-assisted: Claude Code (Claude Opus 5.5) 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01E14m6SuuY6i1vASFeGDBeY
wtclaude added 4 commits 2026-10-27 20:16:49 -05:00
Reviewed-on: #58
Merge pull request 'release: weapon names and the admin copy fixes (v0.5.1)' (#61) from edge into main
All checks were successful
Release / release (push) Successful in -1m57s
bc529962b4
Reviewed-on: #61
Reviewed-on: #64
fix(demo): seed NPC profiles, factions and chat styles (DM26)
All checks were successful
PR Checks / server-tests (pull_request) Successful in 55s
PR Checks / client-build (pull_request) Successful in 1m7s
PR Checks / frozen-manifest (pull_request) Successful in 1m36s
1f4ad25edb
The demo's first restored wipes brought the default set's groups and
permissions back, but not its NPCs or chat titles. The restored rig's
RunicNPC says it is already managed (by the site before this one), so the
fresh site adopts nothing (D244) and its first push empties the profiles;
the placements then wait on missing profiles. The import never adopts a
group's chat style either.

onDemoSeed now also takes:
- npcs.factions: the faction table, through the NPC model's setFactions;
- npcs.profiles: each profile through the model's create/update, so it is
  checked exactly as the admin page checks it (an existing one is updated);
- chat: a BetterChat style per server and group, the defaults filled in. A
  group the rig's import has not brought in yet is created for that server,
  and the import then adopts the rig's title, rank and permissions into it.

The section's new parts are checked before anything is written.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E14m6SuuY6i1vASFeGDBeY
whitlocktech merged commit 5c9cefdbc2 into edge 2026-10-27 20:22:46 -05:00
whitlocktech deleted branch feat/demo-seed-npcs-chat 2026-10-27 20:22:48 -05:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: RunicGateway/Module-Rust#65
No description provided.