1717def build_jobs_service (tmp_path ) -> JobsService :
1818 settings = Settings (
1919 WORKER_MODE = "local" ,
20- WORKER_RUNTIME_DATA_DIR = tmp_path ,
20+ WORKER_RUNTIME_DATA_DIR = tmp_path / "data" / "runtime" ,
2121 )
2222 runtime_store = RuntimeStore (settings .runtime_data_dir )
2323 corpus_service = CorpusService (settings = settings )
@@ -53,8 +53,8 @@ def test_jobs_service_runs_evaluate_and_persists_files(tmp_path) -> None:
5353 completed = wait_for_terminal_status (service , started ["jobId" ])
5454 assert completed ["status" ] == "succeeded"
5555 assert completed ["result" ]["passCount" ] >= 1
56- assert (tmp_path / "jobs" / f"{ started ['jobId' ]} .json" ).exists ()
57- assert (tmp_path / "jobs" / f"{ started ['jobId' ]} .events.jsonl" ).exists ()
56+ assert (service . _runtime_store . jobs_dir () / f"{ started ['jobId' ]} .json" ).exists ()
57+ assert (service . _runtime_store . jobs_dir () / f"{ started ['jobId' ]} .events.jsonl" ).exists ()
5858
5959
6060def test_jobs_service_runs_ingest_and_writes_sync_state (tmp_path ) -> None :
@@ -65,7 +65,7 @@ def test_jobs_service_runs_ingest_and_writes_sync_state(tmp_path) -> None:
6565
6666 assert completed ["status" ] == "succeeded"
6767 assert completed ["result" ]["mode" ] == "mock"
68- assert (tmp_path / "sync-state.json" ).exists ()
68+ assert (service . _runtime_store . sync_state_path () ).exists ()
6969
7070
7171def test_jobs_service_runs_ingest_in_live_mode_when_corpus_path_is_provided (tmp_path ) -> None :
@@ -81,7 +81,7 @@ def test_jobs_service_runs_ingest_in_live_mode_when_corpus_path_is_provided(tmp_
8181
8282 assert completed ["status" ] == "succeeded"
8383 assert completed ["result" ]["mode" ] == "live"
84- assert (tmp_path / "sync-state.live.json" ).exists ()
84+ assert (service . _runtime_store . sync_state_path ( "live" ) ).exists ()
8585
8686
8787def test_jobs_service_runs_analyze_and_writes_analysis_artifacts (tmp_path ) -> None :
@@ -95,16 +95,16 @@ def test_jobs_service_runs_analyze_and_writes_analysis_artifacts(tmp_path) -> No
9595
9696 assert completed ["status" ] == "succeeded"
9797 assert completed ["result" ]["analyzed" ] == 5
98- assert (tmp_path / "analyzed-corpus.json" ).exists ()
99- assert (tmp_path / "analyze-report.json" ).exists ()
98+ assert (service . _runtime_store . analyzed_corpus_path () ).exists ()
99+ assert (service . _runtime_store . analyze_report_path () ).exists ()
100100
101101
102102def test_jobs_service_analyze_uses_extract_backed_text (tmp_path ) -> None :
103103 service = build_jobs_service (tmp_path )
104104 corpus = json .loads (service ._corpus_service .load_corpus_bytes ().decode ("utf-8" ))
105105 extract_path = "extracts/site-test/doc-extract.json"
106- (tmp_path / extract_path ).parent .mkdir (parents = True , exist_ok = True )
107- (tmp_path / extract_path ).write_text (
106+ (service . _runtime_store . runtime_dir / extract_path ).parent .mkdir (parents = True , exist_ok = True )
107+ (service . _runtime_store . runtime_dir / extract_path ).write_text (
108108 json .dumps ({"text" : "Real extracted body text. It contains actual policy obligations and review owners." }),
109109 encoding = "utf-8" ,
110110 )
@@ -135,11 +135,11 @@ def test_jobs_service_analyze_uses_extract_backed_text(tmp_path) -> None:
135135 completed = wait_for_terminal_status (service , started ["jobId" ])
136136
137137 assert completed ["status" ] == "succeeded"
138- analyzed_corpus = json .loads ((tmp_path / "analyzed-corpus.json" ).read_text (encoding = "utf-8" ))
138+ analyzed_corpus = json .loads ((service . _runtime_store . analyzed_corpus_path () ).read_text (encoding = "utf-8" ))
139139 section = analyzed_corpus ["documents" ][0 ]["analysis" ]["sections" ][0 ]["content" ]
140140 assert "Real extracted body text" in section
141141 assert not section .startswith ("Source:" )
142- report = json .loads ((tmp_path / "analyze-report.json" ).read_text (encoding = "utf-8" ))
142+ report = json .loads ((service . _runtime_store . analyze_report_path () ).read_text (encoding = "utf-8" ))
143143 assert report ["extractionQuality" ]["full_text" ] == 1
144144
145145
@@ -174,10 +174,10 @@ def test_jobs_service_analyze_excludes_metadata_only_placeholder(tmp_path) -> No
174174 completed = wait_for_terminal_status (service , started ["jobId" ])
175175
176176 assert completed ["status" ] == "succeeded"
177- analyzed_corpus = json .loads ((tmp_path / "analyzed-corpus.json" ).read_text (encoding = "utf-8" ))
177+ analyzed_corpus = json .loads ((service . _runtime_store . analyzed_corpus_path () ).read_text (encoding = "utf-8" ))
178178 assert analyzed_corpus ["documents" ][0 ]["analysis" ]["status" ] == "excluded"
179179 assert analyzed_corpus ["documents" ][0 ]["analysis" ]["excludedReason" ] == "metadata_only_extract"
180- report = json .loads ((tmp_path / "analyze-report.json" ).read_text (encoding = "utf-8" ))
180+ report = json .loads ((service . _runtime_store . analyze_report_path () ).read_text (encoding = "utf-8" ))
181181 assert report ["extractionQuality" ]["metadata_only" ] == 1
182182
183183
@@ -193,7 +193,7 @@ def test_jobs_service_analyze_falls_back_to_local_when_provider_requested(tmp_pa
193193
194194 assert completed ["status" ] == "succeeded"
195195 assert completed ["result" ]["provider" ] == "openai"
196- analyzed_corpus = (tmp_path / "analyzed-corpus.json" ).read_text (encoding = "utf-8" )
196+ analyzed_corpus = (service . _runtime_store . analyzed_corpus_path () ).read_text (encoding = "utf-8" )
197197 assert '"providerStatus": "fallback"' in analyzed_corpus
198198
199199
@@ -253,13 +253,13 @@ def json(self) -> dict:
253253 assert completed ["result" ]["providerSuccesses" ] == 1
254254 assert completed ["result" ]["providerFallbacks" ] == 0
255255
256- analyzed_corpus = json .loads ((tmp_path / "analyzed-corpus.json" ).read_text (encoding = "utf-8" ))
256+ analyzed_corpus = json .loads ((service . _runtime_store . analyzed_corpus_path () ).read_text (encoding = "utf-8" ))
257257 first_analysis = analyzed_corpus ["documents" ][0 ]["analysis" ]
258258 assert first_analysis ["provider" ] == "openai"
259259 assert first_analysis ["providerStatus" ] == "provider"
260260 assert first_analysis ["summary" ] == "Provider summary."
261261
262- report = json .loads ((tmp_path / "analyze-report.json" ).read_text (encoding = "utf-8" ))
262+ report = json .loads ((service . _runtime_store . analyze_report_path () ).read_text (encoding = "utf-8" ))
263263 assert report ["actualInputTokens" ] == 120
264264 assert report ["actualOutputTokens" ] == 45
265265 assert report ["tokenCountMode" ] == "actual"
@@ -282,9 +282,9 @@ def test_jobs_service_runs_export_live_and_writes_live_artifacts(tmp_path) -> No
282282
283283 assert completed ["status" ] == "succeeded"
284284 assert completed ["result" ]["sourceKind" ] == "mock-baseline"
285- assert (tmp_path . parent . parent / "public" / "live-corpus.json" ).exists ()
286- assert (tmp_path / "live-export-checkpoint.json" ).exists ()
287- assert (tmp_path / "sync-state.live.json" ).exists ()
285+ assert (service . _runtime_store . live_corpus_path () ).exists ()
286+ assert (service . _runtime_store . live_export_checkpoint_path () ).exists ()
287+ assert (service . _runtime_store . sync_state_path ( "live" ) ).exists ()
288288
289289
290290def test_jobs_service_export_live_accepts_explicit_input_override (tmp_path ) -> None :
@@ -303,8 +303,8 @@ def test_jobs_service_export_live_accepts_explicit_input_override(tmp_path) -> N
303303 )
304304 completed = wait_for_terminal_status (service , started ["jobId" ])
305305
306- published_corpus = (tmp_path . parent . parent / "public" / "live-corpus.json" ).read_text (encoding = "utf-8" )
307- checkpoint = (tmp_path / "live-export-checkpoint.json" ).read_text (encoding = "utf-8" )
306+ published_corpus = (service . _runtime_store . live_corpus_path () ).read_text (encoding = "utf-8" )
307+ checkpoint = (service . _runtime_store . live_export_checkpoint_path () ).read_text (encoding = "utf-8" )
308308
309309 assert completed ["status" ] == "succeeded"
310310 assert completed ["result" ]["sourceKind" ] == "explicit-input"
@@ -320,14 +320,14 @@ def test_jobs_service_runs_publish_analysis_after_analyze(tmp_path) -> None:
320320 options = {"env" : {"DEEPVAULT_DATA_MODE" : "mock" , "DEEPVAULT_ANALYZE_LIMIT" : "3" }},
321321 )
322322 wait_for_terminal_status (service , analyze ["jobId" ])
323- assert (tmp_path / "analyzed-corpus.json" ).exists ()
323+ assert (service . _runtime_store . analyzed_corpus_path () ).exists ()
324324
325325 publish = service .start_job (job_type = "publish-analysis" , options = {"env" : {"DEEPVAULT_DATA_MODE" : "mock" }})
326326 completed = wait_for_terminal_status (service , publish ["jobId" ])
327327
328328 assert completed ["status" ] == "succeeded"
329329 assert completed ["result" ]["analyzedCount" ] >= 1
330- published_path = tmp_path . parent . parent / "public" / "live-corpus.json"
330+ published_path = service . _runtime_store . live_corpus_path ()
331331 assert published_path .exists ()
332332 published = json .loads (published_path .read_text (encoding = "utf-8" ))
333333 analyzed_docs = [doc for doc in published ["documents" ] if isinstance (doc .get ("analysis" ), dict ) and doc ["analysis" ].get ("status" ) == "analyzed" ]
@@ -352,7 +352,7 @@ def test_jobs_service_run_job_blocks_until_terminal_status(tmp_path) -> None:
352352 assert completed ["status" ] == "succeeded"
353353 assert completed ["launchedBy" ] == "worker-cli"
354354 assert completed ["client" ] == "worker-cli"
355- assert (tmp_path / "jobs" / f"{ completed ['jobId' ]} .json" ).exists ()
355+ assert (service . _runtime_store . jobs_dir () / f"{ completed ['jobId' ]} .json" ).exists ()
356356
357357
358358def test_jobs_service_can_cancel_running_job (tmp_path ) -> None :
0 commit comments