22
33from __future__ import annotations
44
5+ import hashlib
56import json
67import os
78import subprocess
@@ -247,7 +248,7 @@ def test_authority_free_frontier_does_not_block_authorized_plan_creation(self) -
247248 "next" , "--repo" , self .repo , * goal , * flow ,
248249 "--human" , "contract" , "--repository-authority" ,
249250 )
250- self .assertEqual (progressing ["decision" ]["kind" ], "PRESCRIBED " )
251+ self .assertEqual (progressing ["decision" ]["kind" ], "CANDIDATE " )
251252 self .assertEqual (progressing ["decision" ]["transition" ]["id" ], "plan.create" )
252253
253254 plan = Path (self .work .name ) / "source-plan.md"
@@ -301,7 +302,7 @@ def test_one_delivery_context_rematerializes_repository_authority_after_initiali
301302 prescribed = self .helper_json (
302303 "next" , "--repo" , self .repo , * goal , * flow , * actor ,
303304 )
304- self .assertEqual (prescribed ["decision" ]["kind" ], "PRESCRIBED " )
305+ self .assertEqual (prescribed ["decision" ]["kind" ], "CANDIDATE " )
305306 self .assertEqual (
306307 prescribed ["decision" ]["transition" ]["id" ], "installation.initialize"
307308 )
@@ -321,6 +322,28 @@ def test_one_delivery_context_rematerializes_repository_authority_after_initiali
321322 }
322323 )
323324 )
325+ canonical_config = json .loads (config .read_text ())
326+ canonical_config ["hosts" ] = sorted (canonical_config ["hosts" ])
327+ canonical_config ["policy" ]["external_effect_authority" ] = (
328+ "human-or-autonomy-plus-provider"
329+ )
330+ config_fingerprint = hashlib .sha256 (
331+ json .dumps (canonical_config , separators = ("," , ":" )).encode ()
332+ ).hexdigest ()
333+ bound_initialization = self .helper_json (
334+ "next" , "--repo" , self .repo ,
335+ "--transition" , "installation.initialize" , * goal , * flow , * actor ,
336+ "--param" , f"source_revision={ self ._git (self .repo , 'rev-parse' , 'HEAD' ).stdout .strip ()} " ,
337+ "--param" , f"runtime_path={ self .binary .resolve ()} " ,
338+ "--param" , f"runtime_sha256={ hashlib .sha256 (self .binary .read_bytes ()).hexdigest ()} " ,
339+ "--param" , f"config_path={ config } " ,
340+ "--param" , f"config_sha256={ config_fingerprint } " ,
341+ )
342+ self .assertEqual (bound_initialization ["decision" ]["kind" ], "PRESCRIBED" )
343+ self .assertEqual (
344+ bound_initialization ["decision" ]["transition" ]["id" ],
345+ "installation.initialize" ,
346+ )
324347 initialized_process = self .run_helper (
325348 "init" , "--repo" , self .repo , * goal , * flow , * actor ,
326349 "--param" , f"config_path={ config } " ,
@@ -357,9 +380,20 @@ def test_one_delivery_context_rematerializes_repository_authority_after_initiali
357380 "next" , "--repo" , self .repo , * goal , * flow , * actor ,
358381 "--repository-authority" ,
359382 )
360- self .assertEqual (plan ["decision" ]["kind" ], "PRESCRIBED " )
383+ self .assertEqual (plan ["decision" ]["kind" ], "CANDIDATE " )
361384 self .assertEqual (plan ["decision" ]["transition" ]["id" ], "plan.create" )
362385
386+ plan_source = Path (self .work .name ) / "retained-authority-plan.md"
387+ plan_source .write_text ("# Retained authority\n \n Continue in one operation context.\n " )
388+ bound = self .helper_json (
389+ "next" , "--repo" , self .repo , "--transition" , "plan.create" ,
390+ * goal , * flow , * actor , "--repository-authority" ,
391+ "--param" , f"source_path={ plan_source } " ,
392+ "--param" , "delivery_id=preserve-repository-authority-context" ,
393+ )
394+ self .assertEqual (bound ["decision" ]["kind" ], "PRESCRIBED" )
395+ self .assertEqual (bound ["decision" ]["transition" ]["id" ], "plan.create" )
396+
363397 def test_repository_authority_rematerialization_fails_closed_without_verified_config (self ) -> None :
364398 # control-law: repository-authority-requires-exact-verified-fingerprint
365399 root = Path (self .work .name ) / "unverified"
0 commit comments