feat(backend): schema-targeted stat-block generation (#142) #210
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/142-schema-targeted-statblock"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Backend issue of the v3.9.0 Game-Aware Systems pillar. Targets the integration branch. A bolt-on to #130, using #139's schemas + validator.
Closes #142.
What
When a campaign links a system whose active schema covers the entry's type, the existing
generate_statblockdraft now targets that schema instead of producing free-form prose:generate_lore_entry_statblock_targetedprompts with the schema's field list and asks for a JSONvaluesobject, validates it via #139'svalidate_stats_values, retries once with the validation error appended as guidance, then falls back to #130's free-form generator if it still fails.sidebar_fields+ the markdown body are derived from the same validatedvaluesso the infobox, body, and structured envelope can't disagree.statsenvelope on the newlore_entry_drafts.current_statscolumn (migrationd8e9f0a1b2c3). Eager-loadsgame_system_refto avoid async lazy loads.entry.stats(skips + logs if the schema changed / system unlinked since generation); the version snapshot captures stats.current_statsis surfaced onLoreDraftResponsefor review parity withcurrent_sidebar_fields.resolve_system_prompt_contextinstead of the rawgame_systemcolumn.Fallback for no-linked-system /
generic/ uncovered type / validation-fails-after-retry is exactly #130's free-form behaviour (current_statsNULL, no regression).Verification (Docker, py3.12)
test_statblock_schema_targeting.pycovering targeted generation, retry-then-fallback, approval writingentry.stats, and the no-schema fallback) — no regressions.d8e9f0a1b2c3:upgrade head→downgrade -1→upgrade headclean against real Postgres;current_statscolumn added.webapp/CLAUDE.mdmigration chain updated (head →d8e9f0a1b2c3).Known follow-up (out of scope)
patch_draftdoesn't yet acceptcurrent_statsedits, so a GM editing a staged sidebar row in review won't retro-sync the structured envelope. Worth a small follow-up if inline stat editing during review is wanted. No bot API change;BOT_CONTRACT_VERSIONstays 1.🤖 Generated with Claude Code