Extract character slot policy

This commit is contained in:
2026-06-27 08:30:41 +02:00
parent 3f251a6bb7
commit e9cc75bd5f
7 changed files with 484 additions and 244 deletions
+63
View File
@@ -30,6 +30,7 @@ import cast_context # noqa: E402
import category_template_metadata # noqa: E402
import character_config # noqa: E402
import character_profile # noqa: E402
import character_slot # noqa: E402
import category_cast_config # noqa: E402
import category_library # noqa: E402
import filter_config # noqa: E402
@@ -804,6 +805,7 @@ def smoke_character_config_policy() -> None:
_expect(pb.CHARACTER_LABEL_CHOICES is character_config.CHARACTER_LABEL_CHOICES, "Prompt builder character choices are not delegated")
_expect("21-year-old adult" in character_config.character_age_choices(), "Character age choices lost adult ages")
_expect("fat" in character_config.character_man_body_choices(), "Man body pool lost fat option")
_expect(pb.character_figure_choices() == character_config.character_figure_choices(), "Character figure choices should delegate")
_expect("platinum_blonde" in character_config.character_hair_color_choices(), "Hair color choices lost platinum blonde")
traits = json.loads(
@@ -872,6 +874,67 @@ def smoke_character_config_policy() -> None:
"Krea POV composition cleanup should delegate shared replacements and strip builder annotation",
)
_expect(character_config.normalize_slot_seed(0xFFFFFFFF + 99) == 0xFFFFFFFF, "Slot seed clamp changed")
slot_result = character_slot.build_character_slot_json(
subject_type="man",
label="Man B",
slot_seed=123,
age="manual",
manual_age="44-year-old adult",
ethnicity="western_european",
figure="balanced",
body="manual",
manual_body="stocky",
descriptor_detail="compact",
expression_intensity=1.5,
softcore_expression_intensity=0.25,
hardcore_expression_intensity=-1,
presence_mode="pov",
hair_color="dark brown",
hair_length="short",
hair_style="straight",
softcore_outfit="buttoned shirt",
hardcore_clothing="shirt pushed open",
)
_expect(
pb.build_character_slot_json(
subject_type="man",
label="Man B",
slot_seed=123,
age="manual",
manual_age="44-year-old adult",
ethnicity="western_european",
figure="balanced",
body="manual",
manual_body="stocky",
descriptor_detail="compact",
expression_intensity=1.5,
softcore_expression_intensity=0.25,
hardcore_expression_intensity=-1,
presence_mode="pov",
hair_color="dark brown",
hair_length="short",
hair_style="straight",
softcore_outfit="buttoned shirt",
hardcore_clothing="shirt pushed open",
)
== slot_result,
"Prompt builder character slot JSON should delegate to character_slot",
)
slot = json.loads(slot_result["character_slot"])
_expect(slot.get("age") == "44-year-old adult", "Character slot manual age normalization changed")
_expect(slot.get("body") == "stocky", "Character slot manual body normalization changed")
_expect(slot.get("presence_mode") == "pov", "Character slot POV presence normalization changed")
_expect(slot.get("expression_intensity") == 1.0, "Character slot expression intensity clamp changed")
_expect(
character_slot.slot_expression_intensity_for_phase(slot, "softcore") == 0.25
and character_slot.slot_expression_intensity_for_phase(slot, "hardcore") == 1.0,
"Character slot phase expression fallback changed",
)
_expect(
pb._slot_effective_figure({"slot_seed": 123, "figure": "random"}, "woman", "curvy")
== character_slot.slot_effective_figure({"slot_seed": 123, "figure": "random"}, "woman", "curvy"),
"Prompt builder seeded slot figure should delegate to character_slot",
)
def smoke_character_profile_policy() -> None: