feat: execute independent verification on immutable inputs

This commit is contained in:
阿白叔 committed 2026-11-17 15:40:23 +08:00
1 parent b3c8c9c126
commit 4da211d5d2
2 files changed
+114

No files matched your search

@@ -0,0 +1,46 @@
from threading import Event
from test_independent_verification_intake import service
from test_native_cli_netlist import project_fixture, graph
def imported(service,tmp_path):
a=tmp_path/'a';b=tmp_path/'b';a.mkdir();b.mkdir()
task=service.create_task('独立',request_id='c')['task_id']
item=service.import_pair(task,project_fixture(a),project_fixture(b),request_id='i',stop_event=Event())['accepted'][0]['item_id']
return task,item
def test_runner_uses_frozen_captures_and_publishes_attempt(service,tmp_path,monkeypatch):
from dx_productivity.trial_task_center.verification.runner import run_attempt
from dx_productivity.trial_task_center import netlist_verification
task,item=imported(service,tmp_path)
before=service.repo.revision(item,1)['payload']
captured=service.artifacts.read(before['before_ref'],'snapshot')
original=open(captured['database_path'],'rb').read()
calls=[]
def export(capture,directory,*,stop_event):
calls.append(capture['root'])
directory.mkdir(parents=True,exist_ok=True)
return {'status':'success','complete':True,'graph':graph(directory),'outputs':{}}
monkeypatch.setattr(netlist_verification,'_export_saved_capture',export)
attempt=service.repo.create_attempt(item,1,request_id='a')
result=run_attempt(service,attempt['attempt_id'],stop_event=Event())
assert result['published'] and len(calls)==2
assert service.repo.attempt(attempt['attempt_id'])['state']=='succeeded'
assert open(captured['database_path'],'rb').read()==original
assert service.repo.store._connection.execute('SELECT COUNT(*) FROM execution_operations').fetchone()[0]==0
assert not run_attempt(service,attempt['attempt_id'],stop_event=Event())['published']
def test_corrupt_input_does_not_export_and_failure_is_not_green(service,tmp_path,monkeypatch):
from dx_productivity.trial_task_center.verification.runner import run_attempt
from dx_productivity.trial_task_center import netlist_verification
_,item=imported(service,tmp_path)
capture=service.artifacts.read(service.repo.revision(item,1)['payload']['before_ref'],'snapshot')
open(capture['database_path'],'wb').write(b'corrupt')
def forbidden(*a,**k):raise AssertionError('must not export corrupt capture')
monkeypatch.setattr(netlist_verification,'_export_saved_capture',forbidden)
attempt=service.repo.create_attempt(item,1,request_id='a')
run_attempt(service,attempt['attempt_id'],stop_event=Event())
assert service.repo.attempt(attempt['attempt_id'])['state']=='failed'
assert service.read_item(item)['status']=='unavailable'