Adv 2.0 L5b: babysit state migration off AdvCharacter to player_meta

Five player_meta columns (babysit_active, babysit_expires_at,
babysit_skill_focus, auto_babysit, auto_babysit_focus). BabysitState
struct with IsActive() marker mirrors SkillState/HouseState shape.
loadBabysitState / upsertPlayerMetaBabysitState /
backfillPlayerMetaBabysitState / babysitStateFromAdvChar helpers.

Dual-writes wired at handleBabysitStart, handleBabysitCancel,
checkBabysitExpiry. Backfill is idempotent — only fills inactive rows
whose legacy counterpart is active.

AutoBabysit / AutoBabysitFocus / BabysitSkillFocus are dormant in
current code but preserved for the schema migration.

Tests: TestPlayerMetaBabysitStateBackfill_Idempotent,
TestLoadBabysitState_FallsBackToAdvCharacter,
TestUpsertPlayerMetaBabysitState_RoundTrip.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
prosolis
2026-05-09 11:20:24 -07:00
parent 79e5d19d23
commit d5b4834d44
6 changed files with 325 additions and 1 deletions

View File

@@ -230,6 +230,11 @@ func (p *AdventurePlugin) Init() error {
if err := backfillPlayerMetaSkillState(); err != nil {
slog.Error("player_meta: skill state backfill failed", "err", err)
}
// Adv 2.0 Phase L5b — one-shot babysit state backfill into player_meta.
// Idempotent (only fills inactive rows whose legacy counterpart is active).
if err := backfillPlayerMetaBabysitState(); err != nil {
slog.Error("player_meta: babysit state backfill failed", "err", err)
}
// Phase L3 — cancel any open/active legacy coop dungeon runs and
// refund member contributions + unsettled bets. Idempotent.
closeAndRefundLegacyCoopRuns(p.euro)