fix: preserve review diagnostics and fallback readback

This commit is contained in:
阿白叔 committed 2026-10-31 11:18:30 +08:00
1 parent e5e628de4a
commit 24b655cae1
4 files changed
+29 -4

No files matched your search

@@ -264,13 +264,20 @@ def _finish_response(root, journal, response, context):
if related:
raise resource_pending_error(journal['operation'], result, error, primary)
resource_path = internal_path(Path(root) / 'batch-resources' / journal['batch_id'] / 'session.json')
def preserve_shutdown_failure(detail):
try:
write_record(Path(root) / 'batch-resources' / journal['batch_id'] / 'supervisor.json', journal)
except OSError as record_error:
context.logger.error('supervisor_shutdown_record_failed batch_id=%s error=%s',
journal['batch_id'], record_error)
journal['shutdown_record_error'] = str(record_error)
try:
resource = json.loads(resource_path.read_text(encoding='utf-8'))
except FileNotFoundError:
resource = {}
except (OSError, ValueError, TypeError) as failure:
journal.update(state='blocked', shutdown_record_error=str(failure))
write_record(Path(root) / 'batch-resources' / journal['batch_id'] / 'supervisor.json', journal)
preserve_shutdown_failure(failure)
raise application_shutdown_error(result, error, primary) from failure
shutdown = resource.get('cad_shutdown') if isinstance(resource, dict) else None
if shutdown is None and isinstance(resource, dict):
@@ -279,7 +286,7 @@ def _finish_response(root, journal, response, context):
or not isinstance(shutdown.get('cleanup_errors', ()), (list, tuple))
or any(not isinstance(item, dict) for item in shutdown.get('cleanup_errors', ()))):
journal.update(state='blocked', shutdown_record_error='invalid shutdown record shape')
write_record(Path(root) / 'batch-resources' / journal['batch_id'] / 'supervisor.json', journal)
preserve_shutdown_failure('invalid shutdown record shape')
raise application_shutdown_error(result, error, primary)
if (shutdown.get('orderly_shutdown') is False or shutdown.get('forced_termination')
or shutdown.get('diagnostic_errors')