| """Regression guard for config/levels.toml - the real 5-level defense ladder.""" |
|
|
| from jailbreak_dojo.levels import build_system_prompt, load_levels, make_secret_key |
|
|
|
|
| def test_config_loads_five_ordered_levels(): |
| ls = load_levels() |
| assert [level.id for level in ls] == [1, 2, 3, 4, 5] |
| assert all(level.persona for level in ls) |
| assert ls[0].temperature == 0.7 |
| assert all(level.temperature == 0.3 for level in ls[1:]) |
|
|
|
|
| def test_defense_ladder_is_additive(): |
| l1, l2, l3, l4, l5 = load_levels() |
| assert (l1.input_scan, l1.guardrails, l1.output_san, l1.input_ml) == (False, False, False, False) |
| assert l2.input_scan and not l2.guardrails and not l2.output_san |
| assert l3.guardrails and l3.input_scan and not l3.output_san |
| assert l4.output_san and l4.guardrails and not l4.input_ml |
| assert l5.input_ml and l5.output_san and l5.guardrails |
|
|
|
|
| def test_build_system_prompt_puts_key_last(): |
| level = load_levels()[0] |
| key = make_secret_key(level) |
| assert build_system_prompt(level, key).rstrip().endswith(key) |
|
|