@@ -100,6 +100,56 @@ def test_run_live_cycle_emits_structured_runtime_events(self):
100100 self .assertEqual (end_log ["event" ], "strategy_cycle_completed" )
101101 self .assertEqual (end_log ["status" ], "ok" )
102102
103+ def test_run_live_cycle_uses_shared_runtime_report_archive (self ):
104+ observed = {}
105+
106+ with tempfile .TemporaryDirectory () as tmp_dir :
107+ output_path = os .path .join (tmp_dir , "execution_report.json" )
108+ with patch .dict (
109+ os .environ ,
110+ {
111+ "STRATEGY_PROFILE" : "crypto_leader_rotation" ,
112+ "SERVICE_NAME" : "binance-quant" ,
113+ "EXECUTION_REPORT_GCS_URI" : "gs://demo-bucket/runtime-reports" ,
114+ "GCP_PROJECT_ID" : "demo-project" ,
115+ },
116+ clear = False ,
117+ ):
118+ with patch (
119+ "application.cycle_service.persist_runtime_report" ,
120+ lambda report , ** kwargs : observed .update (
121+ {
122+ "status" : report ["status" ],
123+ "kwargs" : kwargs ,
124+ }
125+ )
126+ or SimpleNamespace (
127+ local_path = kwargs .get ("output_path" ),
128+ gcs_uri = "gs://demo-bucket/runtime-reports/binance/crypto_leader_rotation/2026-04/run-001.json" ,
129+ ),
130+ ):
131+ report , persisted_path = run_live_cycle (
132+ runtime_builder = lambda : SimpleNamespace (run_id = "run-001" , dry_run = False ),
133+ execute_cycle = lambda _runtime : {
134+ "status" : "ok" ,
135+ "log_lines" : [],
136+ "error_summary" : {"errors" : []},
137+ },
138+ output_printer = lambda _text : None ,
139+ report_writer = lambda report : write_execution_report (
140+ report ,
141+ reports_dir = tmp_dir ,
142+ filename = "execution_report.json" ,
143+ ),
144+ )
145+
146+ self .assertEqual (report ["status" ], "ok" )
147+ self .assertEqual (persisted_path , output_path )
148+ self .assertEqual (observed ["status" ], "ok" )
149+ self .assertEqual (observed ["kwargs" ]["output_path" ], output_path )
150+ self .assertEqual (observed ["kwargs" ]["gcs_prefix_uri" ], "gs://demo-bucket/runtime-reports" )
151+ self .assertEqual (observed ["kwargs" ]["gcp_project_id" ], "demo-project" )
152+
103153 def test_run_live_cycle_calls_exit_on_error (self ):
104154 observed = {"exit_code" : None }
105155
0 commit comments