Files
dxdesigner-part-replacement/tools/verify_dsh_native_cancel.py
阿白叔 775bc23dc3
Core regression / Python 3.12 core, intervention UI and release configuration (push) Failing after 21s
Core regression / JavaScript syntax (push) Successful in 3s
Core regression / Python 3.12 core, intervention UI and release configuration (pull_request) Failing after 21s
Core regression / JavaScript syntax (pull_request) Successful in 3s
fix(dsh): address intervention cancellation and verification review
2026-11-05 11:58:32 +08:00

43 lines
1.9 KiB
Python

"""Verify cancellation through the real native Harness stdin/stdout protocol."""
import json
from time import monotonic
from uuid import uuid4
from verify_dsh_blocker_recovery import NativeDiagnosis, REPO
def main():
root = REPO / 'build' / ('dsh-native-cancel-' + uuid4().hex[:8])
native = NativeDiagnosis(root)
report = {'status': 'failed', 'driver': 'real native Harness', 'remoteIssueWrites': 0}
try:
assert native.events.get(timeout=180)['status'] == 'ready', 'native_runtime_not_ready'
request_id = uuid4().hex
request = {'type': 'diagnose', 'request_id': request_id, 'incident_id': uuid4().hex[:24],
'phase': 'diagnose', 'snapshot': {'task_id': '', 'issue_code': 'operation_stalled'},
'evidence': 'Controlled cancellation acceptance; no engineering mutation is permitted.'}
native.process.stdin.write(json.dumps(request) + '\n')
native.process.stdin.flush()
started = native.events.get(timeout=90)
assert started.get('request_id') == request_id and started['status'] == 'started'
before = monotonic()
native.process.stdin.write(json.dumps({'type': 'diagnose_cancel', 'request_id': request_id}) + '\n')
native.process.stdin.flush()
terminal = native.events.get(timeout=15)
assert terminal.get('request_id') == request_id and terminal['status'] == 'cancelled'
assert terminal['error'] == 'diagnosis_cancelled'
report.update(status='passed', cancellation_seconds=round(monotonic() - before, 3),
terminal_status=terminal['status'], session_created=bool(started.get('session_id')))
except Exception as error:
report['error_type'] = type(error).__name__
raise
finally:
native.close()
root.mkdir(parents=True, exist_ok=True)
(root / 'report.json').write_text(json.dumps(report, indent=2), encoding='utf8')
print(json.dumps(report))
if __name__ == '__main__':
main()