feat(dsh): add persistent automatic AI intervention switch
Core regression / Python core and release configuration (push) Successful in 21s
Core regression / JavaScript syntax (push) Successful in 3s
Core regression / Python core and release configuration (pull_request) Successful in 17s
Core regression / JavaScript syntax (pull_request) Successful in 3s

This commit is contained in:
阿白叔 committed 2026-11-04 21:52:58 +08:00
1 parent 9316cf4fc4
commit e28c6d0d6e
12 files changed
+292 -31

No files matched your search

+10 -5
View File
@@ -60,12 +60,14 @@ class IncidentRunner:
record['decision_log_status'] = 'unavailable'
evidence.event('decision_log_unavailable', error=type(error).__name__)
def run(self, task_id, issue_code, message, *, run_id='observation', execution_authorized=False, stop_event=None):
def run(self, task_id, issue_code, message, *, run_id='observation', execution_authorized=False, stop_event=None,
execution_enabled=None):
with _RUN_LOCK:
return self._run(task_id, issue_code, message, run_id=run_id,
execution_authorized=execution_authorized, stop_event=stop_event or Event())
execution_authorized=execution_authorized, stop_event=stop_event or Event(),
execution_enabled=execution_enabled)
def _run(self, task_id, issue_code, message, *, run_id, execution_authorized, stop_event):
def _run(self, task_id, issue_code, message, *, run_id, execution_authorized, stop_event, execution_enabled):
incident_id = sha256(f'{task_id}:{run_id}:{issue_code}'.encode()).hexdigest()[:24]
evidence = IncidentEvidence(self.data_root, incident_id)
state_path = evidence.directory / 'incident.json'
@@ -119,6 +121,7 @@ class IncidentRunner:
gates = {'context_available': context is not None, 'no_unverified_result': context is not None and not context.interrupted,
'retry_phase': context is not None and context.phase == 'retry', 'known_retryable_error': issue_code in RETRYABLE_CODES,
'execution_authorized': bool(execution_authorized), 'not_stopped': not stop_event.is_set(),
'auto_intervention_enabled': execution_enabled is None or execution_enabled.is_set(),
'retry_budget_available': budget_available,
'model_requested_retry': bool(suggestion and suggestion['action'] == 'retry_failed'),
'failure_policy': policy}
@@ -143,14 +146,16 @@ class IncidentRunner:
try:
# Re-read at the actual mutation boundary; the model never supplies parameters.
current = self.service.task_context(task_id)
if current.interrupted or current.phase != 'retry' or stop_event.is_set():
if (current.interrupted or current.phase != 'retry' or stop_event.is_set()
or (execution_enabled is not None and not execution_enabled.is_set())):
raise ValueError('retry_gate_changed')
self.service.prepare_failed_quick_run(task_id)
prepared = self.service.task_context(task_id)
p = prepared.progress
expected = (str(p.next_project_path), p.next_old_part_number, p.next_new_part_number,
'part_label' if prepared.task.copy_part_number_to_value else 'preserve')
if prepared.interrupted or not p.next_project_path or stop_event.is_set():
if (prepared.interrupted or not p.next_project_path or stop_event.is_set()
or (execution_enabled is not None and not execution_enabled.is_set())):
raise ValueError('retry_execution_gate_changed')
outcome = self.service.execute_quick_run_queue(task_id, expected_item=expected, stop_event=stop_event)
update('verifying')