feat(execution): bind immutable task grants before native effects
Assistant: codex Assistant-Model: gpt-6-astra Assistant-Session: 01a140c4-354a-7823-8f0d-8f717397f786
This commit is contained in:
parent
4021ca5e79
commit
d042d468df
7 changed files with 460 additions and 7 deletions
|
|
@ -14,6 +14,7 @@ import http.client
|
|||
import json
|
||||
import subprocess
|
||||
import time
|
||||
from pathlib import Path
|
||||
from urllib.parse import urlsplit
|
||||
|
||||
from task_execution_cleanup import CleanupResult
|
||||
|
|
@ -44,6 +45,8 @@ class NativeFixtureAdapter:
|
|||
self.compiler,self.plan,self.journal,self.binding=compiler,plan,journal,binding
|
||||
self.admission=admission
|
||||
self.meta=plan.metadata()
|
||||
if self.meta.get('execution_grant',{}).get('status')!='approved':
|
||||
raise Refused('independently source-bound synthetic approved grant required')
|
||||
descriptor=json.loads(admission.descriptor)
|
||||
fresh=compiler.bind_execution(compiler.compile(self.meta['request']),descriptor,admission.descriptor)
|
||||
if fresh.serialized != plan.serialized or binding.plan_digest != plan.content_digest:
|
||||
|
|
@ -73,6 +76,8 @@ class NativeFixtureAdapter:
|
|||
paths=sorted({call.path for call in calls})
|
||||
self.hcl=''.join('path '+json.dumps(path)+' {\n capabilities = ["read", "create", "update"]\n}\n' for path in paths)
|
||||
self.hcl+='path "auth/token/revoke-self" {\n capabilities = ["update"]\n}\n'
|
||||
if self.meta['execution_grant']['openbao']['policy']!={'name':self.policy_name,'hcl':self.hcl}:
|
||||
raise Refused('native grant body differs from bound owner projection')
|
||||
self.cleanup=tuple(Cleanup(item['kind'],item['call_digest']) for item in cleanup_specs(binding.operation_id))
|
||||
if self.meta['cleanup'] != cleanup_specs(binding.operation_id): raise Refused('cleanup plan mismatch')
|
||||
self.task=None; self._mint_attempted=False; self._policy_attempted=False; self._ordinal=0; self._next_metadata=0
|
||||
|
|
@ -86,7 +91,11 @@ class NativeFixtureAdapter:
|
|||
self._live()
|
||||
if min((self.deadline-datetime.now(timezone.utc)).total_seconds(),self.monotonic_deadline-time.monotonic())<=5:
|
||||
raise Refused('business deadline exhausted')
|
||||
self.compiler.before_call(self.plan,0)
|
||||
# The constructor independently rebuilt the complete immutable Plan and
|
||||
# grant. Recheck every pinned byte before each native effect. Metadata
|
||||
# dispatch additionally reconstructs its exact ordinal/body below; grant
|
||||
# creation reconstructs and compares its fixed body before issuance.
|
||||
for path in self.compiler.pins:self.compiler.read(Path(path))
|
||||
|
||||
def _http(self, method, path, token, body=b''):
|
||||
# Fixed caller-generated paths only; http.client has no proxy or redirect
|
||||
|
|
@ -148,6 +157,8 @@ class NativeFixtureAdapter:
|
|||
body={'policies':[self.policy_name],'no_default_policy':True,'renewable':False,
|
||||
'ttl':str(self.ttl)+'s','explicit_max_ttl':str(self.ttl)+'s','num_uses':self.uses,
|
||||
'type':'service','display_name':'task-exec-'+self.binding.operation_id,'no_parent':False}
|
||||
if body!=self.meta['execution_grant']['openbao']['token_create_body']:
|
||||
raise Refused('native token body differs from bound owner projection')
|
||||
self._mint_attempted=True
|
||||
status,data=self._business('POST','auth/token/create',root,encoded(body));self._ok(status,data,{200})
|
||||
auth=data.get('auth',{})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue