test: close packaged stop recovery and real saved handoff workflows

This commit is contained in:
阿白叔 committed 2026-11-18 18:00:22 +08:00
1 parent d9bfc57900
commit b038951cc4
8 files changed
+359 -15

No files matched your search

@@ -1,6 +1,7 @@
import copy
import json
from pathlib import Path
from threading import Event
import pytest
from test_independent_verification_intake import service
@@ -110,5 +111,28 @@ def test_existing_replacement_history_is_allowed_but_new_replacement_is_rejected
operation('before-verification')
task, item, scope, run, report = complete(service, tmp_path, monkeypatch)
assert verify_closed_loop(service, task, scope, run, report, expected_verdicts={item: 'CONSISTENT'})['passed']
with service.repo.store.transaction():
service.repo.connection.execute("UPDATE execution_operations SET generation=1 WHERE operation_key='before-verification'")
assert not verify_closed_loop(service, task, scope, run, report, expected_verdicts={item: 'CONSISTENT'})['passed']
with service.repo.store.transaction():
service.repo.connection.execute("UPDATE execution_operations SET generation=0 WHERE operation_key='before-verification'")
operation('during-verification')
assert not verify_closed_loop(service, task, scope, run, report, expected_verdicts={item: 'CONSISTENT'})['passed']
def test_saved_handoff_freezes_current_source_without_reinventing_historical_before(service, tmp_path):
from tools.verification_closed_loop import freeze_inputs
from test_native_cli_netlist import project_fixture
folder=tmp_path/'live';folder.mkdir();path=project_fixture(folder)
before=service.artifacts.capture(path,stop_event=Event())
(path.parent/'database/icdb.dat').write_bytes(b'saved-after')
after=service.artifacts.capture(path,stop_event=Event())
expected=service.artifacts.put('expectations',{'changes':{}})
from dx_productivity.trial_task_center.verification.contracts import default_plan
task=service.create_task('交接',request_id='handoff')['task_id']
service.publish_inputs(task,({'item_key':'saved','project_key':str(path),'input_version':1,
'before_ref':before,'after_ref':after,'expectation_ref':expected,'check_plan':default_plan()},),submission_id='saved')
with pytest.raises(ValueError):freeze_inputs(service,task,expected_count=1)
scope=freeze_inputs(service,task,expected_count=1,historical_before=True)
assert scope['historical_before'] is True
assert service.artifacts.read(before,'snapshot')['source_hashes']!=scope['source_hashes']
@@ -0,0 +1,30 @@
import pytest
from test_independent_verification_intake import service
from test_independent_verification_runner import imported
from threading import Event
def test_stopped_acceptance_requires_unstarted_members_to_remain_waiting(service, tmp_path):
from tools.verification_control_acceptance import verify_stopped
task, item = imported(service, tmp_path)
attempt = service.repo.create_attempt(item, 1, request_id='attempt')
with service.repo.store.transaction():
service.repo.connection.execute("UPDATE verification_attempts SET state='cancelled',resource_state='released',reason='run_stopped_before_dispatch' WHERE attempt_id=?",(attempt['attempt_id'],))
run = {'members':[{'item_id':item, 'input_version':1, 'attempt_id':attempt['attempt_id']}]}
result = verify_stopped(service, run, unstarted={attempt['attempt_id']})
assert result['passed']
with service.repo.store.transaction():
service.repo.connection.execute("UPDATE verification_attempts SET state='running' WHERE attempt_id=?",(attempt['attempt_id'],))
assert not verify_stopped(service, run, unstarted={attempt['attempt_id']})['passed']
def test_unknown_acceptance_rejects_released_or_automatically_rerun_attempt(service, tmp_path):
from tools.verification_control_acceptance import verify_unknown
task, item = imported(service, tmp_path)
attempt = service.repo.create_attempt(item, 1, request_id='attempt')
service.repo.claim(attempt['attempt_id'], owner_id='lost-owner')
service.recover()
assert verify_unknown(service, attempt['attempt_id'], expected_attempts=1)['passed']
with service.repo.store.transaction():
service.repo.connection.execute("UPDATE verification_attempts SET resource_state='released' WHERE attempt_id=?",(attempt['attempt_id'],))
assert not verify_unknown(service, attempt['attempt_id'], expected_attempts=1)['passed']