fix(dsh): isolate damaged decision audit from operations refresh
This commit is contained in:
1 parent
a99f84b25e
commit
cd66d63f4f
7 files changed
+149
-5
No files matched your search
@@ -75,6 +75,7 @@ class DshOperationsController(QObject):
|
||||
self.request_id = None
|
||||
self.results = {}
|
||||
self.cache = {'runs': [], 'schedules': [], 'experiences': [], 'tickets': [], 'decisions': [],
|
||||
'decision_audit': {'status': 'unknown'},
|
||||
'health': {'status': 'degraded', 'checks': []}, 'activity': {}}
|
||||
self.timer = QTimer(self)
|
||||
self.timer.setInterval(15000)
|
||||
@@ -149,6 +150,22 @@ class DshOperationsController(QObject):
|
||||
self.window._update_gates()
|
||||
QThreadPool.globalInstance().start(worker)
|
||||
|
||||
def _read_decisions(self):
|
||||
# A corrupt audit chain must fail closed for append/verification without
|
||||
# making independent history, tickets, health or scheduling unreadable.
|
||||
try:
|
||||
rows = self.decisions.list(20)
|
||||
except ValueError as error:
|
||||
return [], {'status': 'corrupt', 'code': 'audit_log_corrupt',
|
||||
'checked': getattr(error, 'checked', 0),
|
||||
'message': '审计日志损坏,原文件已保留;请导出证据并人工核对。'}
|
||||
except OSError:
|
||||
return [], {'status': 'unavailable', 'code': 'audit_log_unavailable',
|
||||
'message': '审计日志暂不可读,请检查访问权限并保留原文件。'}
|
||||
return rows, {'status': 'ok', 'code': 'audit_log_verified',
|
||||
'checked': rows[-1]['sequence'] if rows else 0,
|
||||
'message': '审计日志完整性校验通过。'}
|
||||
|
||||
def _read(self, *, synchronize_tickets=False):
|
||||
service = self.window.service
|
||||
runs = []
|
||||
@@ -165,9 +182,15 @@ class DshOperationsController(QObject):
|
||||
if candidates:
|
||||
self.tickets.refresh(candidates[0]['incident_id'])
|
||||
tickets = self.tickets.list_tickets()
|
||||
decisions, audit = self._read_decisions()
|
||||
health = self.health.snapshot(service)
|
||||
health['checks'].append({'name': 'decision_audit', 'status': 'ok' if audit['status'] == 'ok' else 'degraded',
|
||||
'code': audit['code'], 'message': audit['message']})
|
||||
if audit['status'] != 'ok' and health['status'] == 'ok':
|
||||
health['status'] = 'degraded'
|
||||
return {'runs': runs, 'schedules': self.schedules.evaluate(service),
|
||||
'experiences': self.experiences.refresh()[:20], 'tickets': tickets[:20],
|
||||
'health': self.health.snapshot(service), 'decisions': self.decisions.list(20)}
|
||||
'health': health, 'decisions': decisions, 'decision_audit': audit}
|
||||
|
||||
def refresh(self, *, synchronize_tickets=False):
|
||||
if self.window._closed or self.window._workers or self.busy or self._other_dialog():
|
||||
|
||||
Reference in new issue
Block a user