22
33import quant_strategy_plugins .strategy_plugin_runner as strategy_plugin_runner
44from quant_strategy_plugins .plugin_policies import (
5+ AUDITABLE_POSITION_CONTROL_FIELDS ,
56 EVIDENCE_AUTOMATION_APPROVED ,
67 GENERAL_MARKET_REGIME_NOTIFICATION_TARGET ,
78 PLUGIN_COMPATIBLE_STRATEGIES ,
1112 PLUGIN_LIFECYCLE_POLICY_REGISTRY ,
1213 PLUGIN_MARKET_REGIME_CONTROL ,
1314 PLUGIN_NOTIFICATION_TARGET_POLICY_REGISTRY ,
15+ extract_auditable_position_control_context ,
1416)
1517
1618
@@ -37,3 +39,39 @@ def test_deprecated_plugin_lifecycle_blocks_new_mounts_but_keeps_replay() -> Non
3739 assert policy .new_mount_allowed is False
3840 assert policy .replay_only is True
3941 assert policy .successor == PLUGIN_MARKET_REGIME_CONTROL
42+
43+
44+ def test_extract_auditable_position_control_context_supports_nested_and_flat_shapes () -> None :
45+ nested = extract_auditable_position_control_context (
46+ {
47+ "auditable_position_control" : {
48+ "evidence_package_id" : "pkg_001" ,
49+ "evidence_valid_until" : "2026-08-01T00:00:00Z" ,
50+ "bounded_budget" : {"name" : "position_control" , "amount" : 0.5 , "unit" : "fraction" },
51+ "ignored" : "value" ,
52+ }
53+ }
54+ )
55+ flat = extract_auditable_position_control_context (
56+ {
57+ "evidence_package_id" : "pkg_002" ,
58+ "evidence_valid_until" : "2026-08-02T00:00:00Z" ,
59+ "bounded_budget" : {"name" : "position_control" , "amount" : 0.25 , "unit" : "fraction" },
60+ }
61+ )
62+
63+ assert tuple (AUDITABLE_POSITION_CONTROL_FIELDS ) == (
64+ "evidence_package_id" ,
65+ "evidence_valid_until" ,
66+ "bounded_budget" ,
67+ )
68+ assert nested == {
69+ "evidence_package_id" : "pkg_001" ,
70+ "evidence_valid_until" : "2026-08-01T00:00:00Z" ,
71+ "bounded_budget" : {"name" : "position_control" , "amount" : 0.5 , "unit" : "fraction" },
72+ }
73+ assert flat == {
74+ "evidence_package_id" : "pkg_002" ,
75+ "evidence_valid_until" : "2026-08-02T00:00:00Z" ,
76+ "bounded_budget" : {"name" : "position_control" , "amount" : 0.25 , "unit" : "fraction" },
77+ }
0 commit comments