Add spec vetting and PC hard rules to encounter builder skill

Spec files are ephemeral (/tmp fine); the server DB is the durable
record — encounter docs carry hpFormula/ac/init, so past builds can be
reconstructed by querying live data, not from kept files.

Vetting before any write (vetSpec):
- monster/npc with neither maxHp nor hpFormula = hard reject (exit 3);
  silent 10 HP defaults caused real damage. --allow-defaults escape
  hatch warns loudly.
- character type in build spec = hard reject. PCs are added only from
  campaign roster verbatim; tooling never invents or edits PC stats.
- missing ac or initMod/initiative = warning, build continues.
- duplicate participant names in one encounter = warning.

Flag parsing: --flags split from args, usage updated.
This commit is contained in:
david raistrick committed 2026-11-18 11:11:56 -05:00
1 parent 15347bfdc8
commit dda8ed9790
2 files changed
+94 -2

No files matched your search

@@ -53,6 +53,47 @@ Returns JSON array of campaign docs = server mode confirmed. HTML (SPA shell)
= firebase mode OR backend not mounted. Either way, this skill won't work —
tell the user.
## Spec files
Spec files are EPHEMERAL. /tmp is fine — they get cleaned, that's expected.
- Source of truth for stats = the user's message at ask-time. Spec JSON is a
transit format, not an archive.
- If a spec is gone, rebuild it from the original message. Never reconstruct
from memory.
- **The durable record is the server DB.** Encounter docs are self-describing:
participant name, type, hpFormula, maxHp, ac, initiative, status all stored.
"Fix the thing from 2 weeks ago" → query `campaigns/{cid}/encounters`, read
the docs, reconstruct context from live data. `logs/{id}` entries add the
action history.
- Therefore: store enough in the DB to reconstruct later. hpFormula always
kept on monster/npc participants; never strip it. Never write campaign or
encounter data into the tracker repo.
## Spec vetting (before build)
Validate the spec before writing anything. Reject, don't guess:
- **Monster/npc with neither `maxHp` nor `hpFormula`** → hard error. A silent
default of 10 HP has caused real damage; never fall back to defaults.
Escape hatch: `--allow-defaults` flag permits it with a loud warning.
- **Missing `ac`** → warning (build continues).
- **Missing `initMod` and `initiative`** → warning; initMod defaults 0.
- **`type: "character"` in spec** → see PC rules below.
- **Duplicate participant names within one encounter** → allowed but warn
(numbered names preferred for display clarity).
## PC rules (hard)
- **Allowed:** add a PC to the campaign roster (`players[]`), or add a PC
from the roster into an encounter, copying stats verbatim from the roster.
- **Forbidden:** creating a `character` participant with invented stats, or
editing any existing character-type participant's HP, AC, formula,
conditions, or status. Player stat fixes happen in the UI or from the
user's explicit values — tooling never "repairs" PCs.
- A build spec containing `type: "character"` without `originalCharacterId`
resolving to a roster entry → hard error.
## Data model (read this before writing)
Three nested entities, all opaque JSON docs in a path-keyed KV store: