fix(ci): renew only existing unstarted Stage task 1a00
Bounded Stage v4 credential acceptance window / acceptance-window (push) Failing after 3m22s
Bounded Stage v4 credential acceptance window / acceptance-window (push) Failing after 3m22s
This commit is contained in:
1 parent
0837042865
commit
aff1da02f4
6 files changed
+56
-44
No files matched your search
@@ -11,16 +11,20 @@ import urllib.request
|
||||
import uuid
|
||||
|
||||
SHA='860324e3a91b31c2b6d4e784e458f6d120582cb8'
|
||||
SESSION='v4-ci-timeout-860324e-20261024'
|
||||
REQUEST='6e82f843-45e4-49e3-9164-11a6879e39ba'
|
||||
SESSION='v4-ci-resume-1a00-20261024'
|
||||
TASK='1a00bc08-3ca4-4519-ae1e-9eec7b098756'
|
||||
|
||||
def proposal(prior):
|
||||
if prior.get('state')!='FAILED' or prior.get('version')!=5: raise ValueError('Prior must remain FAILED v5')
|
||||
scope=prior['metadata']['scope']
|
||||
prefix='editorial-research-to-brief-v1\nTopic: '
|
||||
suffix='\nResearch and evidence-backed brief only. No publication, release, production changes or execution authorization.'
|
||||
if not scope.startswith(prefix) or not scope.endswith(suffix): raise ValueError('Exact prior scope required')
|
||||
return dict(requestId=REQUEST,pilotKind='editorial-research-to-brief-v1',operationMode='PREPARE',environment='staging',scope='EDITORIAL_RESEARCH_TO_BRIEF',researchTopic=scope[len(prefix):-len(suffix)],acceptanceCriteria=prior['metadata']['acceptanceCriteria'],commitSha=SHA,budgetLimitCents=20)
|
||||
def renew_existing(a):
|
||||
route='tasks/'+TASK
|
||||
row=a(route)
|
||||
if row['id']!=TASK or row['state']!='READY' or row['runs'] or row['budgetLedger'] or row['budgetLimitCents']!=20 or row['metadata']['commitSha']!=SHA:
|
||||
raise ValueError('Only exact unstarted zero-reservation READY task allowed')
|
||||
approved=a(route+'/gates/1/decide',{'decision':'APPROVED','expectedVersion':row['version'],'idempotencyKey':SESSION+':renew-gate1','expiresAt':time.strftime('%Y-%m-%dT%H:%M:%SZ',time.gmtime(time.time()+450)),'notes':'Owner-authorized continuation of existing unstarted task only; max20 existing budget; no QA/publication/Production authority.'})
|
||||
if approved['state']!='READY': raise ValueError('Gate1 must enqueue READY')
|
||||
refreshed=a(route)
|
||||
if refreshed['state']!='READY' or refreshed['version']!=approved['version'] or refreshed['runs'] or refreshed['budgetLedger']:
|
||||
raise ValueError('Renewal refresh mismatch')
|
||||
return TASK
|
||||
|
||||
def command(args,timeout=15):
|
||||
return subprocess.check_output(args,stderr=subprocess.DEVNULL,timeout=timeout)
|
||||
@@ -67,20 +71,13 @@ def main():
|
||||
a=lambda route,body=None,method=None:http(base,admin,'admin/orchestration/'+route,body,method)
|
||||
w=lambda route,body=None:http(base,worker,'internal/prepare-worker/'+route,body)
|
||||
tasks=a('tasks')
|
||||
prior=[t for t in tasks if t['id'].startswith('4a109')]
|
||||
if len(prior)!=1: raise ValueError('Exact prior task missing')
|
||||
prior=a('tasks/'+prior[0]['id'])
|
||||
# Preserve all old unknown costs and fence previous failed attempts.
|
||||
failed=[t for t in tasks if t.get('key','').startswith('editorial-v1:') and t['state']=='FAILED']
|
||||
frozen={t['id']:a('tasks/'+t['id'])['budgetLedger'] for t in failed}
|
||||
unknown=sum(sum(x['amountCents'] for x in ledger) for ledger in frozen.values())
|
||||
if unknown!=60: raise ValueError('Prior unknown reservation must be 60')
|
||||
p=w('editorial-proposals',proposal(prior))
|
||||
if p['state']!='GATE1_PENDING' or p['version']!=2: raise ValueError('Fresh proposal only; never replay execution')
|
||||
task=p['taskId']; route='tasks/'+task
|
||||
approved=a(route+'/gates/1/decide',{'decision':'APPROVED','expectedVersion':p['version'],'idempotencyKey':SESSION+':gate1','expiresAt':time.strftime('%Y-%m-%dT%H:%M:%SZ',time.gmtime(time.time()+450)),'notes':'Explicit owner-authorized bounded Stage acceptance only; no QA/publication/Production authority.'})
|
||||
# Gate1 approval atomically queues PREPARE tasks; no second queue request.
|
||||
if approved['state']!='READY': raise ValueError('Gate1 must enqueue READY')
|
||||
task=renew_existing(a); route='tasks/'+task
|
||||
# Existing Gate1 renewal atomically retains READY; no queue or proposal request.
|
||||
# Exactly one process, as hermes. Installed runner has 120-second profile cap,
|
||||
# CLI headroom30 and allowlisted timing evidence. Total330 fits window480.
|
||||
code="import sys,json;sys.path.insert(0,'/opt/data/editorial-v4/runtime-package');import runner;from pathlib import Path;runner.run(Path('/opt/data'),sys.argv[1],total_seconds=330)"
|
||||
|
||||
Reference in new issue
Block a user