feat: integrate native diagnostics and coordinated CBB transactions

This commit is contained in:
阿白叔 committed 2026-11-05 23:18:00 +08:00
1 parent 9e230e1a46
commit da67de026f
91 files changed
+14370 -435

No files matched your search

+19 -8
View File
@@ -41,6 +41,7 @@ def refresh_integration(pi, *, emit=lambda **event: None, settle_seconds=5, time
deadline = ActivityDeadline(timeout_seconds, clock=clock) if timeout_seconds is not None else None
in_flight = {}
executed = set()
protected_green = set()
action_history = []
green_entry = None
previous_state = None
@@ -65,6 +66,8 @@ def refresh_integration(pi, *, emit=lambda **event: None, settle_seconds=5, time
# NoCES=3 is recorded as unsupported, never claimed green.
if status not in (1, 2):
raise IntegrationError(f'{name}: unsupported status {status}')
if status != 2:
protected_green.discard(name)
for name in tuple(in_flight):
if state[name] == 2:
started, call_elapsed = in_flight.pop(name)
@@ -74,11 +77,14 @@ def refresh_integration(pi, *, emit=lambda **event: None, settle_seconds=5, time
# When all four lamps start green, mirror the manual refresh: one
# ForwardAnnotate, then only repair statuses that actually become Required.
# Non-green entry keeps the previously validated four-action route.
refreshed = ('ForwardAnnotation' in executed if green_entry
else len(executed) == len(ACTIONS))
checked = executed | protected_green
refreshed = ('ForwardAnnotation' in checked if green_entry
else len(checked) == len(ACTIONS))
if refreshed and not in_flight and all(status == 2 for status in state.values()):
emit(stage='integration_complete', statuses=state, actions=action_history,
policy='green_first_only' if green_entry else 'required_full_sequence')
policy='green_first_only' if green_entry else
'required_with_native_gates' if protected_green else 'required_full_sequence',
skipped_synchronized=sorted(protected_green))
return state
if deadline is not None and deadline.expired():
raise IntegrationError('Project Integration timeout')
@@ -87,14 +93,19 @@ def refresh_integration(pi, *, emit=lambda **event: None, settle_seconds=5, time
continue
action_started = False
for name, method in ACTIONS:
if state[name] == 2 and (name in executed or
if state[name] == 2 and (name in checked or
(green_entry and name != 'ForwardAnnotation')):
continue
allowed = bool(value(pi, 'Is' + name + 'Allowed'))
# A green item still has to receive one Verify refresh attempt.
# Mentor may report the capability as false for that item; this
# flag is a gate only for a genuinely Required (status=1) item.
if state[name] != 2 and not allowed:
# Restored, previously verified CBBs can forbid a synchronized
# action even while another action is Required. Do not invoke a
# native-prohibited method or misreport the skip as a performed call.
if state[name] == 2 and not allowed:
protected_green.add(name)
emit(stage='integration_action_skipped', action=method, initial_status=2,
reason='synchronized_native_action_disallowed')
continue
if not allowed:
emit(stage='integration_action_unavailable', action=method,
initial_status=state[name], reason='mentor_not_allowed')
raise IntegrationError(f'{name}: required but not allowed')