fix: diagnose iCDB lost sessions and stop unsafe verification

This commit is contained in:
阿白叔 committed 2026-10-27 16:38:51 +08:00
1 parent a11eb3c766
commit 8a517d6f38
9 files changed
+685 -14

No files matched your search

@@ -113,6 +113,8 @@ def collect_native_failure_logs(pcb_path, evidence_root, *, max_bytes=NATIVE_LOG
target = destination/(label+'-'+source.name)
target.write_bytes(data)
item.update(evidence=str(target), copied_bytes=len(data))
if label == 'pcb-logfiles' and source.name != 'ReusableBlock.txt':
_collect_icdb_recovery(source, evidence_root)
except FileNotFoundError:
item['exists'] = False
except OSError as error:
@@ -120,6 +122,23 @@ def collect_native_failure_logs(pcb_path, evidence_root, *, max_bytes=NATIVE_LOG
return _write_record(destination.parent/'native-logs.json', record)
def _collect_icdb_recovery(source, evidence_root):
"""Only promote a native error whose log changed after this launch."""
from .icdb_recovery import read_log_failure
root = Path(evidence_root)/'diagnostics'
try:
baseline = json.loads((root/'startup-log-baseline.json').read_text('utf-8'))
checkpoint = (baseline['baseline'] if baseline['source'] == str(source) else
baseline.get('integration_logs', {}).get(str(source)))
if checkpoint is None:
return
_, recovery = read_log_failure(source, checkpoint)
if recovery:
_write_record(root/'icdb-recovery.json', {**recovery, 'source': str(source)})
except (OSError, ValueError, KeyError, TypeError):
pass # Unknown freshness must not replace the original failure.
def failure_logs_main(request_path):
job = json.loads(Path(request_path).read_text(encoding='utf-8'))