okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221One decider: the app host's speed-switch table and Drafting families are generated from strata_control; the rules run shared vectorsa37d0a57e

main
1.8 KiB37 linesraw
1"""The app's host reads its launch-policy tables from apps/host/server/policy-generated.mjs, which strata_control/app_policy.py writes from the Python that owns them.
2A table changed in Python and not regenerated, or edited by hand in the JavaScript, fails here."""
3from __future__ import annotations
4
5import unittest
6
7from strata_control import app_policy, drafting, speed_switches
8
9
10class GeneratedPolicy(unittest.TestCase):
11    def test_the_committed_file_is_what_the_python_makes_now(self):
12        have = app_policy.TARGET.read_text(encoding="utf-8")
13        self.assertEqual(have, app_policy.render(), "run: python -m strata_control.app_policy")
14
15    def test_the_committed_vectors_are_what_the_python_answers_now(self):
16        self.assertEqual(app_policy.VECTORS.read_text(encoding="utf-8"), app_policy.render_vectors(), "run: python -m strata_control.app_policy")
17
18    def test_the_app_shows_every_switch_but_the_terminal_only_one(self):
19        ids = [r["id"] for r in app_policy.table()]
20        self.assertEqual(ids, [s.id for s in speed_switches.SWITCHES if not s.terminal_only])
21        self.assertNotIn("qwen_defaults_026", ids)
22
23    def test_a_row_carries_exactly_what_the_python_switch_holds(self):
24        for row in app_policy.table():
25            sw = speed_switches.BY_ID[row["id"]]
26            self.assertEqual((row["label"], row["hint"], row["default"], row["env"], row.get("legacy", {})),
27                             (sw.label, sw.effect, sw.default, dict(sw.env), dict(sw.legacy)))
28
29    def test_the_drafting_families_and_names_are_drafting_py_own(self):
30        text = app_policy.render()
31        for family in drafting.SUPPORTED_FAMILIES:
32            self.assertIn(f'"{family}"', text)
33        self.assertIn(drafting._SUPPORTED_NAME.pattern.replace("\\", "\\\\"), text)
34
35
36if __name__ == "__main__":
37    unittest.main()