'use strict'; const {windowForCutoff}=require('./window.cjs'); const eligibility=require('./restricted-test.cjs'); function discoveryBlockers(store,cutoff,allowed=()=>true){ if(!store.executionSources)return (store.deliveryBlockers?.(allowed)||[]).map(id=>'连接 '+id+' 本地执行线索尚未交付。'); const window=cutoff?windowForCutoff(cutoff,store.schedule(),store.calendar()):null; const relevant=store.all('execution-tasks').filter(task=>!task.removedAt&&!['sent','ignored'].includes(task.status)&&(!window||eligibility.eventInWindow(store,task.row,window))); const sources=new Set([...store.executionSources(),...relevant.map(task=>task.connectionId)].filter(allowed)); // Inactive sources cannot consume hints. Retain their evidence without // blocking unrelated work, unless a retained task still needs that source. const included=id=>sources.has(id); const blockers=(store.deliveryBlockers?.(included)||[]).filter(included).map(id=>'连接 '+id+' 本地执行线索尚未交付。'); const pendingSources=new Set([...store.all('execution-discoveries'),...store.all('execution-discovery-runs')].filter(hint=>hint.status==='pending'&&included(hint.connectionId)).map(hint=>hint.connectionId)); for(const id of pendingSources)blockers.push('连接 '+id+' 完整对账线索尚未处理。'); if(store.activeDiscoveries>0)blockers.push('待办扫描尚未完成,不能冻结或发送不完整类别。'); for(const id of sources){ const scan=store.get('execution-scans',id); if(scan?.status!=='complete')blockers.push('连接 '+id+' 尚无完整成功扫描'+(scan?.error?':'+scan.error:'。')); else if(cutoff&&Date.parse(scan.startedAt)