@@ -312,6 +312,20 @@ def cmd_activate_evaluate(args: argparse.Namespace) -> int:
312312 return 0
313313
314314
315+ def resolve_activation_policy_and_grant (args : argparse .Namespace , agentpod : dict [str , Any ], policy_fabric : Any ) -> tuple [dict [str , Any ], dict [str , Any ]]:
316+ policy_json = args .policy_json
317+ grant_json = args .grant_json
318+ resolver_requested = bool (args .policy_file or args .policy_dir or args .policy_id or args .expected_status )
319+ if grant_json is None and policy_json is not None and resolver_requested :
320+ grant_json = policy_json
321+ policy_json = None
322+ if grant_json is None :
323+ raise AssertionError ("grant JSON is required. Use either `<agentpod> <policy.json> <grant.json>` or `<agentpod> <grant.json> --policy-dir <dir>`" )
324+ if policy_json is not None :
325+ return load_json (policy_json ), load_json (grant_json )
326+ policies = policy_fabric .load_policy_admissions (files = args .policy_file , directories = args .policy_dir , root = REPO_ROOT )
327+ policy = policy_fabric .resolve_policy_admission (policies = policies , agentpod_id = str (agentpod .get ("id" )), request_type = "activation" , deployment_receipt_id = args .deployment_receipt_id , agent_machine_id = args .agent_machine_id , provider_id = args .provider_id , policy_id = args .policy_id , expected_status = args .expected_status , allow_missing_stub = not args .no_missing_stub , decided_at = args .decided_at , root = REPO_ROOT )
328+ return policy , load_json (grant_json )
315329def agentpod_workload_default (agentpod : dict [str , Any ], key : str ) -> str | None :
316330 value = agentpod .get ("workload" , {}).get (key )
317331 return value if isinstance (value , str ) and value else None
@@ -569,7 +583,6 @@ def build_parser() -> argparse.ArgumentParser:
569583 stub_response .add_argument ("--status" , choices = ["not_configured" , "noop" ], default = "not_configured" )
570584 stub_response .add_argument ("--pretty" , action = "store_true" )
571585 stub_response .set_defaults (func = cmd_steer_stub_response )
572-
573586 serve_stub = steer_subcommands .add_parser ("serve-stub" , help = "Serve local POST /steer contract stub" )
574587 serve_stub .add_argument ("--host" , default = "127.0.0.1" )
575588 serve_stub .add_argument ("--port" , type = int , default = 8080 )
0 commit comments