1414from jacobian .capability_adapters import CapabilityAdapter
1515from jacobian .capability_errors import CapabilityError , CapabilityInvocationError
1616from jacobian .checker_artifacts import put_witness_envelope
17- from jacobian .checker_identity import batch_checker_manifest_measurement
1817from jacobian .checker_installation import CheckerInstaller
1918from jacobian .checker_operations import CheckerOperation , ExactReplayCheckerDeclaration
2019from jacobian .contracts .capabilities import (
@@ -160,6 +159,8 @@ class _InstalledDeclaration:
160159
161160
162161def _provider_runtime_key (declaration : ExactReplayCheckerDeclaration ) -> str :
162+ if declaration .provider_runtime is not None :
163+ return f"declaration:{ declaration .capability_id } "
163164 if declaration .entrypoint_module == "jacobian_checkers.linear" :
164165 return {
165166 "check_rational_solution" : "linear-solution" ,
@@ -234,76 +235,86 @@ def install_exact_domain_checkers(
234235 features = ("standard-library-rational-replay" , "clean-process-checker" ),
235236 ),
236237 }
238+ available_declarations = _available_declaration_bundles (bundles )
237239 provider_runtimes = {
238240 runtime_key : factory () for runtime_key , factory in runtime_factories .items ()
239241 }
242+ for _installed , declaration in available_declarations :
243+ if declaration .provider_runtime is None :
244+ continue
245+ runtime_key = _provider_runtime_key (declaration )
246+ previous = provider_runtimes .setdefault (
247+ runtime_key ,
248+ declaration .provider_runtime ,
249+ )
250+ if previous != declaration .provider_runtime :
251+ raise ValueError (
252+ "exact replay declarations disagree on their owned provider runtime"
253+ )
240254 checker_ids : dict [str , str | None ] = {}
241255 declarations_by_id : dict [str , ExactReplayCheckerDeclaration ] = {}
242256 diagnostics : list [CapabilityDiagnostic ] = []
243257 exact_checker_source_available = (
244258 exact_domain_checker_source_provider_runtime ().availability
245259 is CapabilityProviderAvailability .AVAILABLE
246260 )
247- with batch_checker_manifest_measurement ():
248- for installed , declaration in _available_declaration_bundles (bundles ):
249- declarations_by_id [declaration .capability_id ] = declaration
250- runtime_key = _provider_runtime_key (declaration )
251- provider_runtime = provider_runtimes [runtime_key ]
252- operation = CheckerOperation (
253- name = f"{ declaration .capability_id } independent { declaration .replay_method } " ,
254- entrypoint = (f"{ declaration .entrypoint_module } :{ declaration .function } " ),
255- evidence_kind = EvidenceKind .WITNESS ,
256- format_id = declaration .format_id ,
257- format_version = "1" ,
258- claim_schema_uris = (
259- installed .input_schema_uris [declaration .request_model ],
261+ for installed , declaration in available_declarations :
262+ declarations_by_id [declaration .capability_id ] = declaration
263+ runtime_key = _provider_runtime_key (declaration )
264+ provider_runtime = provider_runtimes [runtime_key ]
265+ operation = CheckerOperation (
266+ name = f"{ declaration .capability_id } independent { declaration .replay_method } " ,
267+ entrypoint = (f"{ declaration .entrypoint_module } :{ declaration .function } " ),
268+ evidence_kind = EvidenceKind .WITNESS ,
269+ format_id = declaration .format_id ,
270+ format_version = "1" ,
271+ claim_schema_uris = (installed .input_schema_uris [declaration .request_model ],),
272+ semantics_uris = (installed .semantics_uri ,),
273+ candidate_schema_uris = (
274+ installed .result_schema_uris [declaration .capability_id ],
275+ ),
276+ reason = declaration .reason ,
277+ provider_runtime = provider_runtime ,
278+ )
279+ if (
280+ provider_runtime .availability
281+ is not CapabilityProviderAvailability .AVAILABLE
282+ ):
283+ can_omit = (
284+ runtime_key in _OPTIONAL_EXACT_REPLAY_PROVIDER_KEYS
285+ and exact_checker_source_available
286+ )
287+ if not can_omit :
288+ checker_ids [declaration .capability_id ] = installer .install (
289+ operation ,
290+ authorize = authorize ,
291+ ).checker_id
292+ continue
293+ diagnostic = CapabilityDiagnostic (
294+ code = "EXACT_REPLAY_PROVIDER_UNAVAILABLE" ,
295+ stage = "provider_availability" ,
296+ message = (
297+ f"Independent replay for { declaration .capability_id !r} is "
298+ "not installed: "
299+ f"{ provider_runtime .diagnostic or 'the provider is unavailable.' } "
260300 ),
261- semantics_uris = (installed .semantics_uri ,),
262- candidate_schema_uris = (
263- installed .result_schema_uris [declaration .capability_id ],
301+ hint = (
302+ "Install or repair the optional python-flint backend, then retry."
264303 ),
265- reason = declaration .reason ,
266- provider_runtime = provider_runtime ,
304+ details = {
305+ "capability_id" : declaration .capability_id ,
306+ "provider" : provider_runtime .provider ,
307+ "checker_authorization_affected" : True ,
308+ },
267309 )
268- if (
269- provider_runtime .availability
270- is not CapabilityProviderAvailability .AVAILABLE
271- ):
272- can_omit = (
273- runtime_key in _OPTIONAL_EXACT_REPLAY_PROVIDER_KEYS
274- and exact_checker_source_available
275- )
276- if not can_omit :
277- checker_ids [declaration .capability_id ] = installer .install (
278- operation ,
279- authorize = authorize ,
280- ).checker_id
281- continue
282- diagnostic = CapabilityDiagnostic (
283- code = "EXACT_REPLAY_PROVIDER_UNAVAILABLE" ,
284- stage = "provider_availability" ,
285- message = (
286- f"Independent replay for { declaration .capability_id !r} is "
287- "not installed: "
288- f"{ provider_runtime .diagnostic or 'the provider is unavailable.' } "
289- ),
290- hint = (
291- "Install or repair the optional python-flint backend, then retry."
292- ),
293- details = {
294- "capability_id" : declaration .capability_id ,
295- "provider" : provider_runtime .provider ,
296- "checker_authorization_affected" : True ,
297- },
298- )
299- diagnostics .append (diagnostic )
300- _LOGGER .warning ("%s" , diagnostic .message )
301- checker_ids [declaration .capability_id ] = None
302- continue
303- checker_ids [declaration .capability_id ] = installer .install (
304- operation ,
305- authorize = authorize ,
306- ).checker_id
310+ diagnostics .append (diagnostic )
311+ _LOGGER .warning ("%s" , diagnostic .message )
312+ checker_ids [declaration .capability_id ] = None
313+ continue
314+ checker_ids [declaration .capability_id ] = installer .install (
315+ operation ,
316+ authorize = authorize ,
317+ ).checker_id
307318 authorized_ids = {
308319 runtime_key : tuple (
309320 checker_id
@@ -313,13 +324,21 @@ def install_exact_domain_checkers(
313324 )
314325 for runtime_key in provider_runtimes
315326 }
327+ resolved_provider_runtimes : dict [str , CapabilityProviderRuntime ] = {}
328+ for runtime_key , provider_runtime in provider_runtimes .items ():
329+ checker_ids_for_runtime = authorized_ids [runtime_key ]
330+ factory = runtime_factories .get (runtime_key )
331+ resolved_provider_runtimes [runtime_key ] = (
332+ factory (checker_ids = checker_ids_for_runtime )
333+ if factory is not None
334+ else provider_runtime .model_copy (
335+ update = {"checker_ids" : checker_ids_for_runtime }
336+ )
337+ )
316338 return ExactDomainCheckerInstallation (
317339 checker_ids = checker_ids ,
318340 diagnostics = tuple (diagnostics ),
319- provider_runtimes = {
320- runtime_key : factory (checker_ids = authorized_ids [runtime_key ])
321- for runtime_key , factory in runtime_factories .items ()
322- },
341+ provider_runtimes = resolved_provider_runtimes ,
323342 )
324343
325344
0 commit comments