fix: finalize acceptance identity and raw QA review evidence
Docker Build and Publish / build (push) Waiting to run

This commit is contained in:
hellcat committed 2026-10-17 15:32:03 +08:00
1 parent 5c9157f5d7
commit e26b5bc6ca
7 files changed
+110 -17

No files matched your search

+9 -4
View File
@@ -13,7 +13,7 @@ FILES=('stage.php','promote.php','operations.php','rollback.php','readiness.php'
'verify-node.py','panel-acceptance.php','install-node.sh','renew-node.sh','dpl-node.service')
def build(repo,source,base,branch,bundle):
def build(repo,source,base,branch,bundle,advance=False):
if not all(re.fullmatch('[0-9a-f]{40}',r) for r in (source,base)) or not re.fullmatch('codex/[A-Za-z0-9_/-]+',branch) or '..' in branch:
raise ValueError('Explicit full commits and a new codex branch required')
destination=Path(bundle)
@@ -24,7 +24,11 @@ def build(repo,source,base,branch,bundle):
return r.stdout
git('cat-file','-e',source+'^{commit}');git('cat-file','-e',base+'^{commit}');git('check-ref-format','refs/heads/'+branch)
exists=subprocess.run(['git','-C',str(repo),'show-ref','--verify','--quiet','refs/heads/'+branch]).returncode
if exists!=1:raise ValueError('Branch exists or outcome unknown; inspect it, do not overwrite')
expected_old='0'*40
if exists==0 and advance:
expected_old=git('rev-parse','refs/heads/'+branch).decode().strip()
if expected_old!=base:raise ValueError('Advance requires the exact current branch head as reviewed base')
elif exists!=1:raise ValueError('Branch exists or outcome unknown; inspect it, do not overwrite')
with tempfile.TemporaryDirectory(prefix='dpl-ops-index-',dir=destination.parent) as temp:
env=dict(os.environ,GIT_INDEX_FILE=str(Path(temp)/'index'))
git('read-tree',base,env=env)
@@ -36,7 +40,7 @@ def build(repo,source,base,branch,bundle):
git('update-index','--add','--cacheinfo',mode+','+sha+','+name,env=env)
tree=git('write-tree',env=env).decode().strip()
commit=git('commit-tree',tree,'-p',base,input=('DPL operations snapshot\n\nSource commit: '+source+'\n').encode()).decode().strip()
git('update-ref','refs/heads/'+branch,commit,'0'*40)
git('update-ref','refs/heads/'+branch,commit,expected_old)
git('bundle','create',str(destination),'refs/heads/'+branch)
destination.chmod(0o600)
return {'commit':commit,'source_commit':source,'branch':branch,'bundle_sha256':hashlib.sha256(destination.read_bytes()).hexdigest(),'files':len(FILES),'network':False}
@@ -46,9 +50,10 @@ def main():
p=argparse.ArgumentParser(description=__doc__)
p.add_argument('--repo',default=str(Path(__file__).resolve().parents[2]))
for k in ('source','base','branch','bundle'):p.add_argument('--'+k,required=True)
p.add_argument('--advance',action='store_true',help='Explicit fast-forward only from the exact --base current branch head')
a=p.parse_args()
try:
print(json.dumps(build(a.repo,a.source,a.base,a.branch,a.bundle)));return 0
print(json.dumps(build(a.repo,a.source,a.base,a.branch,a.bundle,a.advance)));return 0
except Exception:
print(json.dumps({'state':'blocked','reason':'Inspect source/base, branch and bundle outcome before retry; no network performed'}));return 2
+7 -1
View File
@@ -33,7 +33,13 @@ final class Acceptance {
$j['id']=$u->id;$j['state']='active';if($apply)writeJson($path,$j);
return ['state'=>'ready','id'=>$u->id,'owned'=>$j['owned']];
}
$u=User::where('group_id',$group)->where('banned',0)->whereRaw('u+d<transfer_enable')->where(fn($q)=>$q->whereNull('expired_at')->orWhere('expired_at','>=',time()))->where('email','not like','node-qa-%')->where('email','not like','batch-acceptance-%')->orderBy('id')->first();
$u=null;
$candidates=User::where('group_id',$group)->where('banned',0)->whereRaw('u+d<transfer_enable')->where(fn($q)=>$q->whereNull('expired_at')->orWhere('expired_at','>=',time()))->where('email','not like','node-qa-%')->where('email','not like','batch-acceptance-%')->orderByDesc('is_admin')->orderBy('id')->limit(20)->get();
foreach($candidates as $candidate){
$effective=true;
foreach(ServerService::getAvailableServers($candidate) as $s)if(!ServerService::getAvailableUsers(Server::findOrFail($s['id']))->contains('id',$candidate->id)){$effective=false;break;}
if($effective){$u=$candidate;break;}
}
if(!$apply)return ['state'=>$u?'existing':'would_create'];
$j=['group'=>$group,'state'=>'prepared','owned'=>!$u,'email'=>$u?->email??'batch-acceptance-'.substr(hash('sha256',$dir),0,12).'-'.Str::lower(Str::random(8)).'@example.invalid','uuid'=>$u?->uuid??(string)Str::uuid(),'token'=>$u?->token??Str::random(32),'quota'=>104857600,'expires_at'=>time()+3600];
// Persist identity before commit. A lost response resumes the same row, never another user.
+15 -6
View File
@@ -220,6 +220,15 @@ for attempt in range(3 if source['owned'] else 1):
# Persist only nonsecret, byte-bound results for coordinator/operator review.
self.atomic_json(self.directory/('formal-group-'+str(group)+'.json'),{'snapshot':before,'report':json.loads(report),'qas':json.loads(qas),'binding':binding})
def qa_evidence(self,n,raw,state):
# Bind the exact remote bytes, not a re-serialized nested report. Persist the latest
# online/traffic state so independent review never needs a separate task collector.
report=json.loads(raw)
self.atomic_json(self.directory/(n['key']+'-evidence.json'),{
'key':n['key'],'request_sha256':n['request_sha256'],
'report_sha256':hashlib.sha256(raw).hexdigest(),'report':report,
'panel':state,'collected_at':int(time.time())})
@staticmethod
def php_value(value):
return "json_decode(base64_decode('"+base64.b64encode(json.dumps(value).encode()).decode()+"'),true)"
@@ -376,20 +385,20 @@ for attempt in range(3 if source['owned'] else 1):
existing=read(panel,B+'/qa-report.json')
if existing:
report=json.loads(existing)
if report.get('state')=='live_verified' and report.get('qa_user_id')==s['manifest']['test_user_id'] and 0<=time.time()-report.get('verified_at',0)<=900 and s['node_online'] and s['u']+s['d']>0:
if report.get('state')=='live_verified' and report.get('qa_user_id')==s['manifest']['test_user_id'] and 0<=time.time()-report.get('verified_at',0)<=900 and s['node_online'] and s['u']>0 and s['d']>0:
self.qa_evidence(n,existing,s)
r=receipt('ready');r['valid_until']=min(r['valid_until'],report['verified_at']+900);return r
transfer(panel,gateway,node);fetch_qa(gateway)
execute(gateway,'python3 '+OPS+'/verify-node.py --qa '+Q+'/qa.json --subscription '+Q+'/subscription.json --binary '+ctx['client_binary']+' --port '+str(n['socks_port'])+' --expected-exit '+shlex.quote(n['expected_exit'])+' --expected-country '+n['country']+' --report '+Q+'/qa-report.json --run > '+Q+'/verify.stdout 2> '+Q+'/verify.stderr',300)
data=read(gateway,Q+'/qa-report.json');report=json.loads(data)
write(panel,B+'/qa-report.json',data)
# Reports contain endpoints and measured results, no passwords or tokens.
evidence={'key':key,'request_sha256':sha,'report':report,'panel':state(panel)}
(Path(a.state_dir)/(key+'-evidence.json')).write_text(json.dumps(evidence,ensure_ascii=False,indent=2))
for _ in range(24):
s=state(panel)
if s['node_online'] and s['u']+s['d']>0:
if s['node_online'] and s['u']>0 and s['d']>0:
self.qa_evidence(n,data,s)
r=receipt('ready');r['valid_until']=min(r['valid_until'],report['verified_at']+900);return r
time.sleep(5)
self.qa_evidence(n,data,s)
return receipt('waiting')
if a.phase=='publish':
s=state(panel)
@@ -404,7 +413,7 @@ for attempt in range(3 if source['owned'] else 1):
if not journal:return receipt('conflict')
j=json.loads(journal)
return receipt('ready' if j.get('manifest')==s['manifest'] and j.get('request',{}).get('mode')=='append' and j.get('request',{}).get('group')==n['formal_group_id'] and j.get('state')=='applied' else 'conflict')
if not s['node_online'] or s['u']+s['d']<=0:return receipt('waiting')
if not s['node_online'] or s['u']<=0 or s['d']<=0:return receipt('waiting')
if a.action=='probe':return receipt('absent',True)
cmd='cd '+APP+' && php '+OPS+'/promote.php --backup='+B+' --mode=append --group='+str(n['formal_group_id'])+' --verification='+B+'/qa-report.json'
execute(panel,cmd);execute(panel,cmd+' --apply');return receipt('ready')