feat(dsh): harden health decisions and issue transport

This commit is contained in:
阿白叔 committed 2026-10-31 09:50:35 +08:00
1 parent 736b582bc1
commit eee4e6bde9
18 files changed
+592 -11

No files matched your search

@@ -9,6 +9,8 @@ const experience=row=>({...fields(row,['incident_id','issue_code','verified','ve
summary:short(row.summary,1200),message:short(row.message)});
const ticket=row=>({...fields(row,['incident_id','number','url','state','status','last_sync_at','last_attempt_at','error','reason']),
comments:row.comments?.slice(-3).map(c=>({...fields(c,['id','created_at','updated_at','author']),body:short(c.body)}))});
const health=row=>({...fields(row,['status','checked_utc']),checks:(row.checks||[]).slice(0,10).map(check=>fields(check,['name','status','code','message','updated_utc']))});
const decision=row=>fields(row,['sequence','at_utc','previous_hash','record_hash','incident_id','trigger','evidence_refs','gates','candidate_action','authorized_scope','outcome','human_takeover']);
function impact(report){
if(!report||typeof report!=='object')return report;
const rows=report.rows||[];
@@ -29,13 +31,15 @@ export function compactResult(value){
if(result.experiences)result.experiences=result.experiences.slice(0,5).map(experience);
if(result.tickets)result.tickets=result.tickets.slice(0,5).map(ticket);
if(result.ticket)result.ticket=ticket(result.ticket);
if(result.health)result.health=health(result.health);
if(result.decisions)result.decisions=result.decisions.slice(0,10).map(decision);
return JSON.parse(JSON.stringify(result));
}
export function modelSnapshot(value){
const result=fields(value,['task_id','revision','task_name','status','progress','rules_count','issue','issue_code','events','action_result']);
const ops=value.operations||{};
result.operations=compactResult({busy:ops.busy===true,live_run:ops.live_run,last_execution:ops.last_execution,
runs:ops.runs||[],schedules:ops.schedules||[],experiences:ops.experiences||[],tickets:ops.tickets||[]});
runs:ops.runs||[],schedules:ops.schedules||[],experiences:ops.experiences||[],tickets:ops.tickets||[],health:ops.health,decisions:ops.decisions||[]});
if(value.automation?.incident_id)result.automation=fields(value.automation,['incident_id','task_id','issue_code','status','attempts','verification']);
if(value.lifecycle?.status)result.lifecycle=fields(value.lifecycle,['request_id','status','task_ids','run_id']);
return result;