execweave 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- execweave/__init__.py +3 -0
- execweave/__main__.py +5 -0
- execweave/_conversation_records_core.py +902 -0
- execweave/_dashboard_shell_base.py +148 -0
- execweave/_http_proxy_base.py +565 -0
- execweave/_http_proxy_bounded.py +560 -0
- execweave/_http_proxy_stage.py +509 -0
- execweave/acceptance_output.py +19 -0
- execweave/agent_bootstrap.py +395 -0
- execweave/agent_topology.py +313 -0
- execweave/agent_trace.py +1162 -0
- execweave/agy_preview_sanitize.py +102 -0
- execweave/analysis.py +427 -0
- execweave/anthropic.py +228 -0
- execweave/anthropic_cli.py +171 -0
- execweave/anthropic_full_fidelity.py +385 -0
- execweave/antigravity_adapter.py +112 -0
- execweave/antigravity_adapter_base.py +479 -0
- execweave/antigravity_full_fidelity.py +656 -0
- execweave/antigravity_full_fidelity_base.py +172 -0
- execweave/antigravity_full_fidelity_collaboration_base.py +451 -0
- execweave/antigravity_hook_cli.py +209 -0
- execweave/antigravity_record.py +96 -0
- execweave/antigravity_subagent_linkage.py +449 -0
- execweave/antigravity_trace_capability.py +39 -0
- execweave/auto_specialized.py +547 -0
- execweave/backends.py +102 -0
- execweave/benchmark.py +80 -0
- execweave/claude_adapter.py +517 -0
- execweave/claude_child_transcript.py +314 -0
- execweave/claude_delegation.py +136 -0
- execweave/claude_full_fidelity.py +396 -0
- execweave/claude_hook_cli.py +209 -0
- execweave/claude_hook_contract.py +943 -0
- execweave/claude_model_observer.py +353 -0
- execweave/claude_record.py +106 -0
- execweave/cli.py +629 -0
- execweave/codex_adapter.py +455 -0
- execweave/codex_conversation.py +621 -0
- execweave/codex_full_fidelity.py +287 -0
- execweave/codex_hook_cli.py +301 -0
- execweave/codex_hook_entry.py +207 -0
- execweave/codex_hook_lifecycle.py +363 -0
- execweave/codex_message_diagnostics.py +322 -0
- execweave/codex_message_transport_diagnostics.py +399 -0
- execweave/codex_record.py +199 -0
- execweave/codex_rollout_structures.py +402 -0
- execweave/codex_rollout_trace.py +56 -0
- execweave/codex_rollout_trace_base.py +1509 -0
- execweave/collector.py +768 -0
- execweave/command.py +157 -0
- execweave/command_privacy.py +20 -0
- execweave/content_evidence.py +101 -0
- execweave/content_integrity.py +289 -0
- execweave/content_store.py +273 -0
- execweave/controlled_checks.py +561 -0
- execweave/conversation_archive.py +338 -0
- execweave/conversation_message_identity.py +264 -0
- execweave/conversation_preview.py +66 -0
- execweave/conversation_preview_antigravity.py +32 -0
- execweave/conversation_preview_claude.py +31 -0
- execweave/conversation_preview_codex.py +107 -0
- execweave/conversation_preview_common.py +180 -0
- execweave/conversation_preview_generic.py +188 -0
- execweave/conversation_preview_lines.py +133 -0
- execweave/conversation_preview_transcript.py +121 -0
- execweave/conversation_records.py +349 -0
- execweave/conversation_records_antigravity.py +370 -0
- execweave/conversation_records_codex.py +83 -0
- execweave/conversation_records_common.py +17 -0
- execweave/conversation_records_ollama.py +39 -0
- execweave/correlation.py +818 -0
- execweave/cursor_adapter.py +349 -0
- execweave/cursor_delegation.py +87 -0
- execweave/cursor_delegation_base.py +220 -0
- execweave/cursor_full_fidelity.py +489 -0
- execweave/cursor_hook_cli.py +195 -0
- execweave/cursor_hook_contract.py +439 -0
- execweave/cursor_lifecycle.py +159 -0
- execweave/cursor_record.py +96 -0
- execweave/dashboard_shell.py +283 -0
- execweave/delivery_status.py +94 -0
- execweave/entry.py +98 -0
- execweave/evidence_availability.py +113 -0
- execweave/evidence_grade.py +166 -0
- execweave/fidelity.py +304 -0
- execweave/filesystem.py +327 -0
- execweave/finalization.py +92 -0
- execweave/focus.py +118 -0
- execweave/framework_adapters/__init__.py +34 -0
- execweave/framework_adapters/autogen.py +398 -0
- execweave/framework_adapters/base.py +580 -0
- execweave/framework_adapters/camel.py +270 -0
- execweave/framework_adapters/camel_channel.py +71 -0
- execweave/framework_adapters/metagpt.py +315 -0
- execweave/framework_adapters/metagpt_ollama_compat.py +54 -0
- execweave/framework_adapters/metagpt_recording.py +342 -0
- execweave/framework_adapters/registry.py +90 -0
- execweave/graph.py +590 -0
- execweave/graph_ops.py +472 -0
- execweave/hook_command.py +32 -0
- execweave/hook_delivery.py +32 -0
- execweave/hook_input.py +16 -0
- execweave/http_proxy.py +187 -0
- execweave/http_proxy_cli.py +84 -0
- execweave/inference_gateway.py +476 -0
- execweave/inference_gateway_cli.py +211 -0
- execweave/inference_gateway_full_fidelity.py +613 -0
- execweave/inference_identity.py +76 -0
- execweave/inference_identity_cli.py +60 -0
- execweave/integrity.py +235 -0
- execweave/integrity_cli.py +55 -0
- execweave/investigation_index.py +445 -0
- execweave/litellm_callback.py +211 -0
- execweave/litellm_callback_cli.py +42 -0
- execweave/live.py +445 -0
- execweave/live_core.py +972 -0
- execweave/live_view.py +109 -0
- execweave/live_view_extra_style.py +11 -0
- execweave/live_view_markup.py +29 -0
- execweave/live_view_process_layout.py +650 -0
- execweave/live_view_readability.py +502 -0
- execweave/live_view_script_a.py +59 -0
- execweave/live_view_script_b.py +97 -0
- execweave/live_view_script_c.py +59 -0
- execweave/live_view_script_d.py +40 -0
- execweave/live_view_style.py +34 -0
- execweave/model_runtime.py +560 -0
- execweave/model_runtime_cli.py +265 -0
- execweave/model_runtime_full_fidelity.py +519 -0
- execweave/observation.py +53 -0
- execweave/observation_demo.py +69 -0
- execweave/openai_agents.py +267 -0
- execweave/openai_agents_sdk.py +453 -0
- execweave/openai_compatible.py +239 -0
- execweave/openai_compatible_cli.py +189 -0
- execweave/openai_compatible_full_fidelity.py +438 -0
- execweave/opencode_adapter.py +325 -0
- execweave/opencode_event_contract.py +734 -0
- execweave/opencode_full_fidelity.py +198 -0
- execweave/opencode_hook_cli.py +119 -0
- execweave/opencode_plugin_cli.py +150 -0
- execweave/opencode_record.py +96 -0
- execweave/opencode_task_linkage.py +225 -0
- execweave/overhead_benchmark.py +440 -0
- execweave/privacy.py +84 -0
- execweave/private_io.py +465 -0
- execweave/provider_capability.py +578 -0
- execweave/provider_lifecycle.py +282 -0
- execweave/provider_record.py +290 -0
- execweave/reader_identity.py +13 -0
- execweave/redacted_archive.py +906 -0
- execweave/risk.py +106 -0
- execweave/rule_pack.py +359 -0
- execweave/rule_pack_cli.py +57 -0
- execweave/run_assessment.py +200 -0
- execweave/runtime_endpoint_availability.py +44 -0
- execweave/scalability_benchmark.py +195 -0
- execweave/schema.py +62 -0
- execweave/scope.py +85 -0
- execweave/semantic.py +453 -0
- execweave/session_summary.py +159 -0
- execweave/sink.py +71 -0
- execweave/strace_backend.py +927 -0
- execweave/stream_assembly.py +363 -0
- execweave/task_artifacts.py +192 -0
- execweave/task_validation.py +317 -0
- execweave/theme.py +40 -0
- execweave/top.py +599 -0
- execweave/top_cli.py +150 -0
- execweave/validate.py +196 -0
- execweave/vendor/dagre.min.js +815 -0
- execweave/view_cli.py +49 -0
- execweave/viewer.py +474 -0
- execweave/viewer_agent_panel.py +630 -0
- execweave/viewer_agent_panel_antigravity.py +31 -0
- execweave/viewer_agent_panel_claude.py +9 -0
- execweave/viewer_agent_panel_codex.py +50 -0
- execweave/viewer_agent_panel_cursor.py +9 -0
- execweave/viewer_agent_panel_default.py +79 -0
- execweave/viewer_agent_panel_ollama.py +20 -0
- execweave/viewer_agent_panel_opencode.py +9 -0
- execweave/viewer_agent_panel_registry.py +20 -0
- execweave/viewer_archive_verifier.py +178 -0
- execweave/viewer_background_files.py +86 -0
- execweave/viewer_content_browser.py +307 -0
- execweave/viewer_content_health.py +208 -0
- execweave/viewer_content_inspector.py +309 -0
- execweave/viewer_controlled_checks.py +258 -0
- execweave/viewer_conversation_sync.py +115 -0
- execweave/viewer_dashboard_clean.py +405 -0
- execweave/viewer_dashboard_focus.py +127 -0
- execweave/viewer_dashboard_hardening.py +264 -0
- execweave/viewer_dashboard_hardening_v2.py +62 -0
- execweave/viewer_dashboard_projection.py +261 -0
- execweave/viewer_delivery_status.py +155 -0
- execweave/viewer_edge_decross.py +117 -0
- execweave/viewer_execution_flow.py +611 -0
- execweave/viewer_execution_flow_provider_normalization.py +107 -0
- execweave/viewer_execution_flow_safety.py +349 -0
- execweave/viewer_external_endpoints.py +307 -0
- execweave/viewer_flow_canvas.py +1140 -0
- execweave/viewer_flow_layout.py +922 -0
- execweave/viewer_fold_state.py +31 -0
- execweave/viewer_framework_flow.py +68 -0
- execweave/viewer_framework_model_output.py +133 -0
- execweave/viewer_gif.py +278 -0
- execweave/viewer_history_browser.py +225 -0
- execweave/viewer_investigation.py +268 -0
- execweave/viewer_layout_geometry.py +192 -0
- execweave/viewer_layout_v2.py +429 -0
- execweave/viewer_layout_v2_detached.py +25 -0
- execweave/viewer_limits.py +93 -0
- execweave/viewer_live_layout.py +61 -0
- execweave/viewer_message_handoffs.py +114 -0
- execweave/viewer_projection.py +488 -0
- execweave/viewer_projection_base.py +522 -0
- execweave/viewer_projection_bridges.py +214 -0
- execweave/viewer_recorded_sources.py +146 -0
- execweave/viewer_run_assessment.py +274 -0
- execweave/viewer_run_guide.py +175 -0
- execweave/viewer_runtime_evidence.py +258 -0
- execweave/viewer_semantic_projection.py +641 -0
- execweave/viewer_session_flow.py +491 -0
- execweave/viewer_structure_share.py +132 -0
- execweave/viewer_task_validation.py +241 -0
- execweave/viewer_tool_mirror_identity.py +75 -0
- execweave/viewer_workflow_mode.py +127 -0
- execweave/workflow.py +183 -0
- execweave-1.0.0.dist-info/METADATA +462 -0
- execweave-1.0.0.dist-info/RECORD +234 -0
- execweave-1.0.0.dist-info/WHEEL +4 -0
- execweave-1.0.0.dist-info/entry_points.txt +30 -0
- execweave-1.0.0.dist-info/licenses/LICENSE +16 -0
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
"""Lossless, presentation-only composition through hidden evidence details.
|
|
2
|
+
|
|
3
|
+
Only explicit incoming paths terminating at one visible agent justify composition.
|
|
4
|
+
Ambiguous/unattributed observations retain their original source as a visible context;
|
|
5
|
+
raw degree-zero nodes and deliberate file filters are never 'repaired' by deletion.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from .viewer_tool_mirror_identity import TOOL_MIRROR_SCRIPT
|
|
9
|
+
|
|
10
|
+
PROJECTION_SCRIPT = r"""
|
|
11
|
+
(function(){
|
|
12
|
+
const baseProjection=execweaveDashboardGraph;
|
|
13
|
+
const hiddenTypes=new Set([
|
|
14
|
+
'agent_execution','observed_content','tool_call','agent_turn','tool_call_observation',
|
|
15
|
+
'conversation_item','provider_session','permission_request','context_compaction',
|
|
16
|
+
'agent_turn_stop','compaction','compaction_request','terminal_operation',
|
|
17
|
+
'agent_trace_capability','session','command','inference_call','code_cell','agent_message'
|
|
18
|
+
]);
|
|
19
|
+
const text=value=>value===null||value===undefined?'':String(value).trim();
|
|
20
|
+
const key=edge=>text(edge.id)||JSON.stringify([edge.source,edge.relation,edge.target]);
|
|
21
|
+
const copy=value=>JSON.parse(JSON.stringify(value));
|
|
22
|
+
const sorted=values=>[...new Set(values)].sort();
|
|
23
|
+
function scope(value){
|
|
24
|
+
const a=value?.attributes||{};
|
|
25
|
+
// These aliases share an identity namespace. Never choose the first supplied
|
|
26
|
+
// value and silently discard contradictory evidence on the very same object.
|
|
27
|
+
// Top-level event.session_id is the recording run, NOT a provider session.
|
|
28
|
+
const groups={
|
|
29
|
+
provider:[a.provider,value?.provider],
|
|
30
|
+
conversation:[a.conversation_id,a.antigravity_conversation_id,value?.conversation_id,value?.antigravity_conversation_id],
|
|
31
|
+
session:[a.provider_session_id,a.session_id,value?.provider_session_id],
|
|
32
|
+
run:[a.execweave_session_id,a.run_id,value?.execweave_session_id,value?.run_id]
|
|
33
|
+
},result={};
|
|
34
|
+
for(const [name,values] of Object.entries(groups)){
|
|
35
|
+
const ids=sorted(values.map(text).filter(Boolean).map(v=>name==='provider'?v.toLowerCase():v));
|
|
36
|
+
if(ids.length>1)return null;
|
|
37
|
+
result[name]=ids[0]||'';
|
|
38
|
+
}
|
|
39
|
+
return result;
|
|
40
|
+
}
|
|
41
|
+
function joinScope(a,b){
|
|
42
|
+
if(!a||!b)return null;
|
|
43
|
+
const result={...a};
|
|
44
|
+
for(const [name,value] of Object.entries(b)){
|
|
45
|
+
if(value&&result[name]&&value!==result[name])return null;
|
|
46
|
+
if(value)result[name]=value;
|
|
47
|
+
}
|
|
48
|
+
return result;
|
|
49
|
+
}
|
|
50
|
+
function supportFor(leaf,visible,byId,incoming,omitLeaf=false){
|
|
51
|
+
const sources=new Set(),edges=new Map(omitLeaf?[]:[[key(leaf),leaf]]),nodes=new Set([leaf.source,leaf.target]);
|
|
52
|
+
const initial=joinScope(scope(leaf),scope(byId.get(leaf.source)));
|
|
53
|
+
if(!initial)return{sources:[],edges:omitLeaf?[]:[leaf],nodes:sorted(nodes),missingSources:[],identity:null,reason:'identity_conflict'};
|
|
54
|
+
const queue=[[leaf.source,initial]],seen=new Set(),reasons=new Set(),missingSources=new Set();
|
|
55
|
+
let resolvedIdentity={};
|
|
56
|
+
for(let index=0;index<queue.length;index++){
|
|
57
|
+
const [id,identity]=queue[index],state=JSON.stringify([id,identity]);
|
|
58
|
+
if(seen.has(state))continue;seen.add(state);
|
|
59
|
+
for(const edge of incoming.get(id)||[]){
|
|
60
|
+
edges.set(key(edge),edge);nodes.add(edge.source);
|
|
61
|
+
const source=byId.get(edge.source);
|
|
62
|
+
if(!source){
|
|
63
|
+
// A missing node is unknown, not proof that this competing path cannot
|
|
64
|
+
// lead to another agent. Keep context and diagnostics until it is known.
|
|
65
|
+
reasons.add('missing_source');missingSources.add(edge.source);continue;
|
|
66
|
+
}
|
|
67
|
+
const next=joinScope(joinScope(identity,scope(edge)),scope(source));
|
|
68
|
+
if(!next){reasons.add('identity_conflict');continue;}
|
|
69
|
+
if(visible.has(source.id)){
|
|
70
|
+
if(source.type==='agent'){
|
|
71
|
+
sources.add(source.id);resolvedIdentity=joinScope(resolvedIdentity,next);
|
|
72
|
+
if(!resolvedIdentity)reasons.add('identity_conflict');
|
|
73
|
+
}else reasons.add('non_agent_boundary');
|
|
74
|
+
}else if(hiddenTypes.has(String(source.type||''))){
|
|
75
|
+
queue.push([source.id,next]);
|
|
76
|
+
}else reasons.add('hidden_or_filtered_owner');
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const priority=['identity_conflict','missing_source','hidden_or_filtered_owner','non_agent_boundary'];
|
|
80
|
+
const reason=priority.find(r=>reasons.has(r))||(sources.size===1?'':sources.size?'ambiguous_ancestry':'unattributed_observation');
|
|
81
|
+
return{sources:sorted(sources),edges:[...edges.values()].sort((a,b)=>key(a).localeCompare(key(b))),
|
|
82
|
+
nodes:sorted(nodes),missingSources:sorted(missingSources),identity:resolvedIdentity,reason};
|
|
83
|
+
}
|
|
84
|
+
/* EXACT_TOOL_MIRROR_IDENTITY */
|
|
85
|
+
function repair(data,display){
|
|
86
|
+
const rawNodes=Array.isArray(data?.nodes)?data.nodes:[],rawEdges=Array.isArray(data?.edges)?data.edges:[];
|
|
87
|
+
const byId=new Map(rawNodes.filter(n=>n?.id).map(n=>[n.id,n])),incoming=new Map();
|
|
88
|
+
for(const edge of rawEdges){
|
|
89
|
+
if(!edge?.source||!edge?.target)continue;
|
|
90
|
+
if(!incoming.has(edge.target))incoming.set(edge.target,[]);
|
|
91
|
+
incoming.get(edge.target).push(edge);
|
|
92
|
+
}
|
|
93
|
+
const nodes=[...(display.nodes||[])];let edges=[...(display.edges||[])];
|
|
94
|
+
const visible=new Set(nodes.map(n=>n.id)),aliases=new Map(),groups=new Map(),contexts=new Map();
|
|
95
|
+
for(const node of nodes){
|
|
96
|
+
aliases.set(node.id,node.id);
|
|
97
|
+
const a=node.attributes||{};
|
|
98
|
+
const members=[...(a.viewer_occurrence_ids||[]),...(a.viewer_tool_entity_ids||[]),
|
|
99
|
+
...(a.viewer_folded_members||[]).map(n=>n.id)];
|
|
100
|
+
for(const id of members)if(byId.has(id)&&byId.get(id)?.type!=='agent')aliases.set(id,node.id);
|
|
101
|
+
}
|
|
102
|
+
// The existing tool presentation already composes call occurrences into one
|
|
103
|
+
// CALLED_TOOL relation. Validate that ownership and enrich its support rather
|
|
104
|
+
// than adding a second agent->tool RESOLVED_TOOL edge for the very same call.
|
|
105
|
+
const representedToolPaths=new Set(),acceptedToolCalls=new Set(),rejectedToolCalls=new Set();
|
|
106
|
+
let rejectedToolOccurrences=0;
|
|
107
|
+
const scopedRows=rows=>sorted(rows.map(row=>JSON.stringify(row))).map(row=>JSON.parse(row));
|
|
108
|
+
edges=edges.flatMap(presented=>{
|
|
109
|
+
if(presented.relation!=='CALLED_TOOL'||!Array.isArray(presented.viewer_tool_call_occurrences))return[presented];
|
|
110
|
+
const kept=[],allSupport=new Map(),allNodes=new Set(),identities=[];
|
|
111
|
+
for(const row of presented.viewer_tool_call_occurrences){
|
|
112
|
+
const ids=Array.isArray(row.call_ids)?row.call_ids:[];
|
|
113
|
+
const proofs=proveToolOccurrence(ids,presented,visible,byId,incoming,rawEdges,aliases);
|
|
114
|
+
if(!proofs){rejectedToolOccurrences++;for(const id of ids)rejectedToolCalls.add(id);continue;}
|
|
115
|
+
const scopes=scopedRows(proofs.map(proof=>proof.identity));
|
|
116
|
+
kept.push({...copy(row),viewer_identity_scopes:scopes,viewer_mirror_identity_evidence:proofs.filter(p=>p.mirror).map(p=>copy(p.mirror))});identities.push(...scopes);
|
|
117
|
+
for(const proof of proofs){for(const edge of proof.edges)allSupport.set(key(edge),edge);for(const id of proof.nodes)allNodes.add(id);}
|
|
118
|
+
for(const id of ids){acceptedToolCalls.add(id);representedToolPaths.add(JSON.stringify([id,presented.target]));}
|
|
119
|
+
}
|
|
120
|
+
if(!kept.length)return[];
|
|
121
|
+
const result={...presented,count:kept.length,evidence_call_count:kept.length,
|
|
122
|
+
viewer_tool_call_occurrences:kept,viewer_identity_scopes:scopedRows(identities),
|
|
123
|
+
viewer_supporting_edges:[...allSupport.values()].sort((a,b)=>key(a).localeCompare(key(b))).map(copy),
|
|
124
|
+
viewer_supporting_nodes:sorted(allNodes).filter(id=>byId.has(id)).map(id=>copy(byId.get(id)))};
|
|
125
|
+
// If some occurrences were rejected, do not leave the rejected chronology
|
|
126
|
+
// or multiplicity on the surviving summary. The raw calls remain untouched.
|
|
127
|
+
if(kept.length!==presented.viewer_tool_call_occurrences.length){
|
|
128
|
+
for(const field of ['first_sequence','last_sequence']){
|
|
129
|
+
const values=kept.map(row=>row[field]).filter(Number.isInteger);
|
|
130
|
+
result[field]=values.length?(field==='first_sequence'?Math.min(...values):Math.max(...values)):null;
|
|
131
|
+
}
|
|
132
|
+
for(const field of ['first_seen','last_seen']){
|
|
133
|
+
const values=kept.map(row=>row[field]).filter(Boolean).sort();
|
|
134
|
+
result[field]=(field==='first_seen'?values[0]:values.at(-1))||null;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return[result];
|
|
138
|
+
});
|
|
139
|
+
for(let index=0;index<nodes.length;index++){
|
|
140
|
+
const node=nodes[index],attrs=node.attributes||{};
|
|
141
|
+
if(node.type!=='tool'||!Array.isArray(attrs.viewer_tool_call_occurrences))continue;
|
|
142
|
+
const keep=row=>(row.call_ids||[]).every(id=>acceptedToolCalls.has(id)&&!rejectedToolCalls.has(id));
|
|
143
|
+
const kept=attrs.viewer_tool_call_occurrences.filter(keep),rejected=attrs.viewer_tool_call_occurrences.filter(row=>!keep(row));
|
|
144
|
+
if(!rejected.length)continue;
|
|
145
|
+
nodes[index]={...node,attributes:{...attrs,viewer_tool_call_occurrences:kept,viewer_occurrences:kept,
|
|
146
|
+
viewer_occurrence_ids:kept.map(row=>row.invocation_id),viewer_occurrence_count:kept.length,
|
|
147
|
+
viewer_aggregated_tool_call_count:kept.length,viewer_unattributed_tool_call_occurrences:rejected}};
|
|
148
|
+
}
|
|
149
|
+
const represented=new Set(edges.flatMap(edge=>[edge.id,...(edge.viewer_edge_occurrence_ids||[])]).filter(Boolean));
|
|
150
|
+
const unresolved=[];
|
|
151
|
+
for(const leaf of [...rawEdges].sort((a,b)=>key(a).localeCompare(key(b)))){
|
|
152
|
+
if(leaf?.id&&represented.has(leaf.id))continue;
|
|
153
|
+
const target=aliases.get(leaf?.target),source=byId.get(leaf?.source);
|
|
154
|
+
if(!target||!source||visible.has(source.id)||!hiddenTypes.has(String(source.type||'')))continue;
|
|
155
|
+
if(representedToolPaths.has(JSON.stringify([leaf.source,target])))continue;
|
|
156
|
+
const support=supportFor(leaf,visible,byId,incoming);
|
|
157
|
+
if(support.reason){
|
|
158
|
+
// Keep the original source and incident relation. This is not a guessed
|
|
159
|
+
// agent edge: the context exposes why an observation cannot be attributed.
|
|
160
|
+
if(!contexts.has(source.id))contexts.set(source.id,{...copy(source),
|
|
161
|
+
attributes:{...copy(source.attributes||{}),viewer_retained_context:true,
|
|
162
|
+
viewer_context_reason:support.reason,viewer_original_name:source.name||null}});
|
|
163
|
+
unresolved.push({source:source.id,target:leaf.target,reason:support.reason,ancestor_ids:support.sources,
|
|
164
|
+
missing_source_ids:support.missingSources,supporting_edge_ids:support.edges.map(key)});
|
|
165
|
+
edges.push({...copy(leaf),target,viewer_only:true,
|
|
166
|
+
viewer_original_target:leaf.target,viewer_retained_context_edge:true,
|
|
167
|
+
viewer_supporting_edges:copy(support.edges),viewer_missing_source_ids:support.missingSources});
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
const owner=support.sources[0],groupKey=JSON.stringify([owner,leaf.relation||'',target,support.identity]);
|
|
171
|
+
if(!groups.has(groupKey))groups.set(groupKey,{owner,target,relation:leaf.relation||'',identity:support.identity,leaves:[],supports:[]});
|
|
172
|
+
const group=groups.get(groupKey);group.leaves.push(leaf);group.supports.push(support);
|
|
173
|
+
}
|
|
174
|
+
for(const [groupKey,group] of [...groups].sort(([a],[b])=>a.localeCompare(b))){
|
|
175
|
+
const leaf=group.leaves[0],supportEdges=new Map();
|
|
176
|
+
for(const support of group.supports)for(const edge of support.edges)supportEdges.set(key(edge),edge);
|
|
177
|
+
const evidence=[...supportEdges.values()].sort((a,b)=>key(a).localeCompare(key(b)));
|
|
178
|
+
const hiddenSources=sorted(group.leaves.map(e=>e.source));
|
|
179
|
+
const nodeIds=sorted(group.supports.flatMap(s=>s.nodes));
|
|
180
|
+
const sequences=group.leaves.map(e=>e.first_sequence).filter(Number.isInteger);
|
|
181
|
+
const lastSequences=group.leaves.map(e=>e.last_sequence).filter(Number.isInteger);
|
|
182
|
+
const moments=field=>group.leaves.map(e=>e[field]).filter(v=>text(v)).sort((a,b)=>{
|
|
183
|
+
const x=Date.parse(a),y=Date.parse(b);return Number.isFinite(x)&&Number.isFinite(y)?x-y:text(a).localeCompare(text(b));
|
|
184
|
+
});
|
|
185
|
+
const first=moments('first_seen'),last=moments('last_seen');
|
|
186
|
+
edges.push({...copy(leaf),id:`viewer:hidden-bridge:${groupKey}`,source:group.owner,target:group.target,
|
|
187
|
+
relation:group.relation,viewer_only:true,inferred:true,causal:false,
|
|
188
|
+
attributes:{...copy(leaf.attributes||{}),inferred:true,causal:false},
|
|
189
|
+
count:group.leaves.reduce((n,e)=>n+(Number(e.count)||1),0),
|
|
190
|
+
first_sequence:sequences.length?Math.min(...sequences):null,
|
|
191
|
+
last_sequence:lastSequences.length?Math.max(...lastSequences):null,
|
|
192
|
+
first_seen:first[0]||null,last_seen:last.at(-1)||null,
|
|
193
|
+
evidence_ids:sorted(evidence.flatMap(e=>Array.isArray(e.evidence_ids)?e.evidence_ids:[])),
|
|
194
|
+
viewer_hidden_bridge:true,viewer_identity_scope:group.identity,viewer_hidden_bridge_reason:'unique_visible_agent_ancestor',
|
|
195
|
+
viewer_hidden_bridge_source:hiddenSources[0],viewer_hidden_bridge_sources:hiddenSources,
|
|
196
|
+
viewer_original_targets:sorted(group.leaves.map(e=>e.target)),
|
|
197
|
+
viewer_supporting_edges:copy(evidence),
|
|
198
|
+
viewer_supporting_nodes:nodeIds.filter(id=>byId.has(id)).map(id=>copy(byId.get(id))),
|
|
199
|
+
viewer_supporting_paths:group.leaves.map((e,i)=>({hidden_source:e.source,target:e.target,
|
|
200
|
+
edge_ids:group.supports[i].edges.map(key),node_ids:group.supports[i].nodes}))});
|
|
201
|
+
}
|
|
202
|
+
nodes.push(...[...contexts.values()].sort((a,b)=>text(a.id).localeCompare(text(b.id))));
|
|
203
|
+
const ids=new Set(nodes.map(n=>n.id));
|
|
204
|
+
const keptEdges=edges.filter(e=>ids.has(e.source)&&ids.has(e.target));
|
|
205
|
+
return{...display,nodes,edges:keptEdges,node_count:nodes.length,edge_count:keptEdges.length,
|
|
206
|
+
dashboard_projection:{...(display.dashboard_projection||{}),hidden_bridge_edge_count:groups.size,
|
|
207
|
+
represented_tool_path_count:representedToolPaths.size,rejected_tool_occurrence_count:rejectedToolOccurrences,
|
|
208
|
+
retained_context_node_count:contexts.size,unresolved_hidden_paths:unresolved,
|
|
209
|
+
removed_projection_orphan_count:0,removed_projection_orphan_ids:[]}};
|
|
210
|
+
}
|
|
211
|
+
execweaveDashboardGraph=data=>repair(data,baseProjection(data));
|
|
212
|
+
if(typeof window!=='undefined')window.__execweaveProjectionRepair=repair;
|
|
213
|
+
})();
|
|
214
|
+
""".strip().replace("/* EXACT_TOOL_MIRROR_IDENTITY */", TOOL_MIRROR_SCRIPT)
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"""Expose exact graph-backed source references in the shared inspector.
|
|
2
|
+
|
|
3
|
+
This is a content navigation surface, not a new conversation/ownership policy.
|
|
4
|
+
Only explicit graph edges are followed; names, message bodies and shared model
|
|
5
|
+
membership never select another agent's sources.
|
|
6
|
+
"""
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
RECORDED_SOURCES_JS = r"""
|
|
10
|
+
(()=>{
|
|
11
|
+
'use strict';
|
|
12
|
+
if(window.__execweaveRecordedSources)return;
|
|
13
|
+
const inspector=document.getElementById('details');
|
|
14
|
+
if(!inspector)return;
|
|
15
|
+
const PAGE=25,limits=new Map();
|
|
16
|
+
let panel=null,signature='',scheduled=false;
|
|
17
|
+
const list=value=>Array.isArray(value)?value:[];
|
|
18
|
+
const attr=node=>node?.attributes&&typeof node.attributes==='object'?node.attributes:{};
|
|
19
|
+
const make=(tag,text)=>{const node=document.createElement(tag);if(text!==undefined)node.textContent=text;return node};
|
|
20
|
+
function rowsFor(raw,display,id){
|
|
21
|
+
const byId=new Map();
|
|
22
|
+
for(const node of list(raw?.nodes)){
|
|
23
|
+
if(typeof node?.id!=='string')continue;
|
|
24
|
+
// Ambiguous raw identities must not become a last-writer-wins content join.
|
|
25
|
+
byId.set(node.id,byId.has(node.id)?null:node);
|
|
26
|
+
}
|
|
27
|
+
const shown=list(display?.nodes).find(node=>node?.id===id),selected=byId.get(id);
|
|
28
|
+
const owners=new Set();
|
|
29
|
+
if(selected)owners.add(id);
|
|
30
|
+
if(shown?.type==='agent')for(const alias of list(attr(shown).viewer_agent_member_ids)){
|
|
31
|
+
if(typeof alias==='string'&&byId.get(alias)?.type==='agent')owners.add(alias);
|
|
32
|
+
}
|
|
33
|
+
if(!owners.size)return [];
|
|
34
|
+
const links=list(raw?.edges),subjects=new Map([...owners].map(owner=>[owner,null]));
|
|
35
|
+
const callRelations=new Set(['REQUESTED_TOOL_CALL','REQUESTS_TOOL_CALL','REQUESTS_MODEL_CALL']);
|
|
36
|
+
for(const edge of links){
|
|
37
|
+
if(!edge||!owners.has(edge.source)||byId.get(edge.source)?.type!=='agent')continue;
|
|
38
|
+
const target=byId.get(edge.target);
|
|
39
|
+
if(callRelations.has(edge.relation)&&['tool_call','model_call','inference_request'].includes(target?.type)){
|
|
40
|
+
subjects.set(edge.target,edge);
|
|
41
|
+
}
|
|
42
|
+
if(edge.relation==='TASK_CREATED'&&target?.type==='task')subjects.set(edge.target,edge);
|
|
43
|
+
}
|
|
44
|
+
// Framework tasks use the adapter's task -> agent assignment contract.
|
|
45
|
+
// Provider delegation belongs to its own identity policy, not this task join.
|
|
46
|
+
// A presentation-only or inferred edge is not observed assignment evidence.
|
|
47
|
+
for(const edge of links)if(edge&&owners.has(edge.target)&&
|
|
48
|
+
edge.relation==='ASSIGNED_TO'&&byId.get(edge.source)?.type==='task'&&
|
|
49
|
+
byId.get(edge.target)?.type==='agent'&&edge.inferred!==true&&edge.viewer_only!==true){
|
|
50
|
+
subjects.set(edge.source,edge);
|
|
51
|
+
}
|
|
52
|
+
const rows=[];
|
|
53
|
+
for(const [index,edge] of links.entries()){
|
|
54
|
+
if(!edge)continue;
|
|
55
|
+
const forward=subjects.has(edge.source),subject=forward?edge.source:edge.target;
|
|
56
|
+
if(!subjects.has(subject))continue;
|
|
57
|
+
const content=byId.get(forward?edge.target:edge.source);
|
|
58
|
+
if(content?.type!=='observed_content')continue;
|
|
59
|
+
const parent=subjects.get(subject),node=byId.get(subject),a=attr(content);
|
|
60
|
+
rows.push({
|
|
61
|
+
key:JSON.stringify([index,edge.id,edge.source,edge.target,edge.relation]),
|
|
62
|
+
source_id:subject,source_name:node?.name||subject,
|
|
63
|
+
source_relation:parent?.relation||null,
|
|
64
|
+
edge_id:edge.id||null,relation:String(edge.relation||'CONTENT'),
|
|
65
|
+
first_sequence:Number.isInteger(edge.first_sequence)?edge.first_sequence:null,
|
|
66
|
+
timestamp:edge.first_seen||content.first_seen||null,
|
|
67
|
+
count:edge.count??null,
|
|
68
|
+
reference:{...a,id:content.id,relation:String(edge.relation||'CONTENT')}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
return rows.sort((a,b)=>{
|
|
72
|
+
if(a.first_sequence!==null&&b.first_sequence!==null&&a.first_sequence!==b.first_sequence)return b.first_sequence-a.first_sequence;
|
|
73
|
+
return String(b.timestamp||'').localeCompare(String(a.timestamp||''))||a.key.localeCompare(b.key);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
function refresh(){
|
|
77
|
+
scheduled=false;
|
|
78
|
+
const selected=document.querySelector('#nodes .node.selected');
|
|
79
|
+
const reader=window.__execweaveContentBrowser;
|
|
80
|
+
if(!selected||!reader?.attach){panel?.remove();panel=null;signature='';return}
|
|
81
|
+
const core=window.__execweaveCore,raw=core?.getGraph?.()||window.__execweaveStaticGraph||{};
|
|
82
|
+
const display=core?.getDisplayGraph?.()||raw,id=String(selected.dataset.id||'');
|
|
83
|
+
const rows=rowsFor(raw,display,id);
|
|
84
|
+
if(!rows.length){panel?.remove();panel=null;signature='';return}
|
|
85
|
+
const key=JSON.stringify([raw.run_id,raw.session_id,raw.source_path,id]);
|
|
86
|
+
const cap=limits.get(key)||PAGE,nextSignature=JSON.stringify([key,cap,rows]);
|
|
87
|
+
if(signature===nextSignature&&panel?.isConnected)return;
|
|
88
|
+
signature=nextSignature;panel?.remove();
|
|
89
|
+
panel=make('section');panel.id='execweave-recorded-sources';panel.dataset.sourceId=id;
|
|
90
|
+
panel.append(make('h3','Recorded source content'));
|
|
91
|
+
const notice=make('p',`Showing ${Math.min(cap,rows.length)} of ${rows.length} registered source references. Content is checked when opened; these records do not establish message delivery or task success.`);
|
|
92
|
+
notice.className='execweave-source-notice';panel.append(notice);
|
|
93
|
+
for(const row of rows.slice(0,cap)){
|
|
94
|
+
const card=make('section');card.className='execweave-source-card';card.dataset.sourceId=row.source_id;
|
|
95
|
+
const label=make('strong',[row.timestamp,row.source_name,row.relation].filter(Boolean).join(' · '));
|
|
96
|
+
const provenance=make('p',[row.source_id,row.source_relation,row.edge_id,
|
|
97
|
+
row.count!==null?`${row.count} recorded observation(s)`:null,
|
|
98
|
+
row.reference.content_kind].filter(Boolean).join(' · '));
|
|
99
|
+
card.append(label,provenance);
|
|
100
|
+
reader.attach(card,[row.reference],[id,row.source_id,row.edge_id,row.relation].filter(Boolean).join(' · '));
|
|
101
|
+
panel.append(card);
|
|
102
|
+
}
|
|
103
|
+
if(cap<rows.length){
|
|
104
|
+
const more=make('button','Load more sources');more.type='button';
|
|
105
|
+
more.onclick=()=>{limits.set(key,cap+PAGE);if(limits.size>128)limits.delete(limits.keys().next().value);refresh()};
|
|
106
|
+
panel.append(more);
|
|
107
|
+
}
|
|
108
|
+
inspector.append(panel);
|
|
109
|
+
}
|
|
110
|
+
function schedule(){if(scheduled)return;scheduled=true;queueMicrotask(refresh)}
|
|
111
|
+
new MutationObserver(records=>{
|
|
112
|
+
if(records.some(record=>!panel?.contains(record.target)))schedule();
|
|
113
|
+
}).observe(inspector,{childList:true,subtree:true});
|
|
114
|
+
const nodes=document.getElementById('nodes');
|
|
115
|
+
if(nodes)new MutationObserver(schedule).observe(nodes,{childList:true,subtree:true,attributes:true,attributeFilter:['class','data-id']});
|
|
116
|
+
const previous=window.__execweaveDashboard||{};
|
|
117
|
+
window.__execweaveDashboard={...previous,
|
|
118
|
+
onPayload(...args){previous.onPayload?.(...args);schedule()},
|
|
119
|
+
onFinished(...args){previous.onFinished?.(...args);schedule()}
|
|
120
|
+
};
|
|
121
|
+
window.__execweaveRecordedSources={refresh,rowsFor};refresh();
|
|
122
|
+
})();
|
|
123
|
+
""".strip()
|
|
124
|
+
|
|
125
|
+
RECORDED_SOURCES_CSS = r"""
|
|
126
|
+
#execweave-recorded-sources{margin-top:16px;overflow-wrap:anywhere}
|
|
127
|
+
#execweave-recorded-sources h3{font-size:15px}
|
|
128
|
+
#execweave-recorded-sources .execweave-source-notice{font-size:12px;color:var(--muted)}
|
|
129
|
+
#execweave-recorded-sources .execweave-source-card{padding:10px;margin:8px 0;border:1px solid var(--border,#888);border-radius:8px}
|
|
130
|
+
#execweave-recorded-sources .execweave-source-card strong{font-size:13px}
|
|
131
|
+
#execweave-recorded-sources .execweave-source-card p{font-size:12px}
|
|
132
|
+
""".strip()
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
def inject_recorded_sources(html: str) -> str:
|
|
136
|
+
if 'id="execweave-recorded-sources-script"' in html:
|
|
137
|
+
return html
|
|
138
|
+
if "</body>" not in html:
|
|
139
|
+
raise RuntimeError("recorded sources require a dashboard body")
|
|
140
|
+
return html.replace(
|
|
141
|
+
"</body>",
|
|
142
|
+
'<style>' + RECORDED_SOURCES_CSS + '</style>'
|
|
143
|
+
'<script id="execweave-recorded-sources-script">' + RECORDED_SOURCES_JS
|
|
144
|
+
+ '</script>\n</body>',
|
|
145
|
+
1,
|
|
146
|
+
)
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
"""One run-level assessment panel shared by Live and static Dashboards."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
from .viewer_delivery_status import delivery_scripts
|
|
5
|
+
from .viewer_task_validation import inject_task_reports
|
|
6
|
+
from .viewer_controlled_checks import inject_controlled_checks
|
|
7
|
+
|
|
8
|
+
RUN_ASSESSMENT_JS = r"""
|
|
9
|
+
(()=>{
|
|
10
|
+
'use strict';
|
|
11
|
+
if(window.__execweaveRunAssessment)return;
|
|
12
|
+
const host=document.getElementById('inspector');if(!host)return;
|
|
13
|
+
const make=(tag,text)=>{const n=document.createElement(tag);if(text!==undefined)n.textContent=String(text);return n};
|
|
14
|
+
const object=value=>value&&typeof value==='object'&&!Array.isArray(value)?value:{};
|
|
15
|
+
const count=value=>Number.isSafeInteger(value)&&value>=0?String(value):'unknown';
|
|
16
|
+
let lastSignature='',currentKey='',latest=null;
|
|
17
|
+
const panel=make('section');panel.id='execweave-run-assessment';panel.className='run-assessment-section';
|
|
18
|
+
panel.setAttribute('aria-label','Run assessment');
|
|
19
|
+
// Preserve the historical first/second inspector-section CSS contracts.
|
|
20
|
+
const selectionHost=document.getElementById('details')?.closest('.inspector-section');
|
|
21
|
+
if(selectionHost?.parentElement===host)selectionHost.prepend(panel);else host.append(panel);
|
|
22
|
+
function graphNow(){return window.__execweaveCore?.getGraph?.()||window.__execweaveStaticGraph||{}}
|
|
23
|
+
function compatible(value,graph){
|
|
24
|
+
return value?.schema_version==='0.1'&&value.scope==='published_graph_metadata'&&
|
|
25
|
+
typeof graph.session_id==='string'&&value.session_id===graph.session_id&&
|
|
26
|
+
(value.source_path||null)===(graph.source_path||null);
|
|
27
|
+
}
|
|
28
|
+
function card(key,title,state,label,description){
|
|
29
|
+
const n=make('div');n.className='run-assessment-card';n.dataset.axis=key;n.dataset.state=state;
|
|
30
|
+
n.append(make('h3',title),make('strong',label),make('p',description));panel.append(n);return n;
|
|
31
|
+
}
|
|
32
|
+
const handoffHost=make('section');
|
|
33
|
+
handoffHost.id='execweave-handoff-alerts';handoffHost.setAttribute('aria-label','Observed process exit warnings and unconfirmed agent handoffs');
|
|
34
|
+
// Mount within the graph panel so the alert occupies the first viewport
|
|
35
|
+
// instead of becoming an auto-placed bottom row in the #app grid.
|
|
36
|
+
const graphPanel=document.getElementById('graph-panel');
|
|
37
|
+
const panelBar=graphPanel?.querySelector('.panel-bar');
|
|
38
|
+
if(panelBar)panelBar.insertAdjacentElement('afterend',handoffHost);
|
|
39
|
+
else if(graphPanel)graphPanel.prepend(handoffHost);
|
|
40
|
+
else host.prepend(handoffHost);
|
|
41
|
+
function renderHandoffAlerts(packet){
|
|
42
|
+
const graph=graphNow(),assessment=graph.observation_assessment||
|
|
43
|
+
object(packet).observation_assessment||object(object(packet).graph).observation_assessment||{};
|
|
44
|
+
const delivery=object(assessment.message_delivery),outcome=graph.session_outcome||{};
|
|
45
|
+
const finished=outcome.recorder_finished===true||object(packet).live_finished===true||
|
|
46
|
+
window.__execweaveStaticMode===true;
|
|
47
|
+
const raw=finished&&Array.isArray(delivery.diagnostics)&&delivery.diagnostics.length?
|
|
48
|
+
delivery.diagnostics:(finished&&Array.isArray(delivery.unconfirmed)?delivery.unconfirmed:[]);
|
|
49
|
+
const rows=raw.filter(row=>row&&row.message_id&&row.recipient_id&&
|
|
50
|
+
row.sender_id&&row.delivery_failure_proven!==true&&
|
|
51
|
+
(row.delivery_status==='receive_not_observed'||row.state==='receive_not_observed'))
|
|
52
|
+
.slice(0,20).sort((a,b)=>[a.sender_id,a.recipient_id,a.message_id].join('\0')
|
|
53
|
+
.localeCompare([b.sender_id,b.recipient_id,b.message_id].join('\0')));
|
|
54
|
+
const nodes=Array.isArray(graph.nodes)?graph.nodes:[];
|
|
55
|
+
const resolve=id=>{
|
|
56
|
+
const exact=nodes.filter(n=>n.type==='agent'&&n.id===id);
|
|
57
|
+
if(exact.length===1)return exact[0];
|
|
58
|
+
const part=String(id).split(':').pop()?.toLowerCase();
|
|
59
|
+
const near=nodes.filter(n=>n.type==='agent'&&
|
|
60
|
+
(String(n.name||'').toLowerCase()===String(id).toLowerCase()||
|
|
61
|
+
String(n.name||'').toLowerCase()===part||
|
|
62
|
+
String(n.id||'').toLowerCase().endsWith(':'+part)));
|
|
63
|
+
return near.length===1?near[0]:null;
|
|
64
|
+
};
|
|
65
|
+
const failedProcesses=nodes.filter(n=>n.type==='process'&&
|
|
66
|
+
Number.isSafeInteger(n.attributes?.exit_code)&&n.attributes.exit_code!==0)
|
|
67
|
+
.slice(0,20);
|
|
68
|
+
handoffHost.replaceChildren();handoffHost.hidden=!rows.length&&!failedProcesses.length;
|
|
69
|
+
// Re-rendered SVGs can replace the nodes/edges without a new run payload.
|
|
70
|
+
// Only update changed markers, so class-attribute observers cannot loop.
|
|
71
|
+
const markedNodes=new Set(),markedEdges=new Set();
|
|
72
|
+
for(const row of rows){
|
|
73
|
+
const sender=resolve(row.sender_id),recipient=resolve(row.recipient_id);
|
|
74
|
+
const label=id=>resolve(id)?.name||String(id).split(':').pop();
|
|
75
|
+
const line=make('button',label(row.sender_id)+' → '+label(row.recipient_id)+' — receive not observed');
|
|
76
|
+
line.type='button';line.className='execweave-handoff-alert';
|
|
77
|
+
line.dataset.messageId=row.message_id;line.dataset.recipientId=row.recipient_id;
|
|
78
|
+
line.onclick=()=>{
|
|
79
|
+
if(!recipient)return;
|
|
80
|
+
const api=window.__execweaveCore;
|
|
81
|
+
if(typeof api?.selectNode==='function'){
|
|
82
|
+
api.selectNode(recipient.id);api.focusNode?.(recipient.id);
|
|
83
|
+
}else{
|
|
84
|
+
const element=[...document.querySelectorAll('.node[data-id]')]
|
|
85
|
+
.find(n=>n.dataset.id===recipient.id);
|
|
86
|
+
element?.dispatchEvent(new MouseEvent('click',{bubbles:true}));
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
handoffHost.append(line);
|
|
90
|
+
if(!recipient)continue;
|
|
91
|
+
const nodeElement=[...document.querySelectorAll('.node[data-id]')]
|
|
92
|
+
.find(n=>n.dataset.id===recipient.id);
|
|
93
|
+
if(nodeElement)markedNodes.add(nodeElement);
|
|
94
|
+
if(!sender)continue;
|
|
95
|
+
for(const edge of (graph.edges||[])){
|
|
96
|
+
if(edge.source!==sender.id||edge.target!==recipient.id)continue;
|
|
97
|
+
const relation=String(edge.relation||'').toUpperCase();
|
|
98
|
+
if(!['MESSAGE_SENT','ADDRESSED_TO','SENT_MESSAGE','SENT_TO'].includes(relation))continue;
|
|
99
|
+
const edgeMid=edge.message_id||edge.attributes?.message_id;
|
|
100
|
+
if(edgeMid&&edgeMid!==row.message_id)continue;
|
|
101
|
+
const edgeIdValue=edge.id||edge.source+':'+edge.relation+':'+edge.target;
|
|
102
|
+
for(const element of document.querySelectorAll('.edge[data-edge-id]')){
|
|
103
|
+
if(element.dataset.edgeId===edgeIdValue)markedEdges.add(element);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
// These are observed child-process exits, not inferred overall run failures.
|
|
108
|
+
const failedNodeElements=new Set();
|
|
109
|
+
for(const process of failedProcesses){
|
|
110
|
+
const label=process.name||process.id;
|
|
111
|
+
const line=make('button',label+' — process exit '+process.attributes.exit_code);
|
|
112
|
+
line.type='button';line.className='execweave-handoff-alert execweave-process-exit-alert';
|
|
113
|
+
line.dataset.processId=process.id;
|
|
114
|
+
line.onclick=()=>{
|
|
115
|
+
const core=window.__execweaveCore;
|
|
116
|
+
if(typeof core?.selectNode==='function'){
|
|
117
|
+
core.selectNode(process.id);
|
|
118
|
+
core.focusNode?.(process.id);
|
|
119
|
+
}else{
|
|
120
|
+
document.querySelectorAll('.node[data-id]').forEach(n=>{
|
|
121
|
+
if(n.dataset.id===process.id)n.dispatchEvent(new MouseEvent('click',{bubbles:true}));
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
handoffHost.append(line);
|
|
126
|
+
document.querySelectorAll('.node[data-id]').forEach(n=>{
|
|
127
|
+
if(n.dataset.id===process.id)failedNodeElements.add(n);
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
document.querySelectorAll('.node[data-process-exit="nonzero"]').forEach(n=>{
|
|
131
|
+
if(!failedNodeElements.has(n))delete n.dataset.processExit;
|
|
132
|
+
});
|
|
133
|
+
failedNodeElements.forEach(n=>{
|
|
134
|
+
if(n.dataset.processExit!=='nonzero')n.dataset.processExit='nonzero';
|
|
135
|
+
});
|
|
136
|
+
document.querySelectorAll('.node[data-warning="receive-not-observed"]').forEach(n=>{
|
|
137
|
+
if(!markedNodes.has(n))delete n.dataset.warning;
|
|
138
|
+
});
|
|
139
|
+
document.querySelectorAll('.edge.handoff-unconfirmed').forEach(e=>{
|
|
140
|
+
if(!markedEdges.has(e))e.classList.remove('handoff-unconfirmed');
|
|
141
|
+
});
|
|
142
|
+
markedNodes.forEach(n=>{if(n.dataset.warning!=='receive-not-observed')n.dataset.warning='receive-not-observed'});
|
|
143
|
+
markedEdges.forEach(e=>{if(!e.classList.contains('handoff-unconfirmed'))e.classList.add('handoff-unconfirmed')});
|
|
144
|
+
}
|
|
145
|
+
function render(value){
|
|
146
|
+
const next=JSON.stringify(value);if(next===lastSignature)return;lastSignature=next;
|
|
147
|
+
// Keep disclosure choice while updating facts; do not replace the selection inspector.
|
|
148
|
+
const selected=document.getElementById('details'),anchor=selected?.getBoundingClientRect().top,scroll=host.scrollTop;
|
|
149
|
+
const expanded=panel.querySelector('details')?.open||false;panel.replaceChildren();
|
|
150
|
+
panel.append(make('h2','Run assessment'));
|
|
151
|
+
const execution=object(value?.execution),task=object(value?.task_validation),content=object(value?.content);
|
|
152
|
+
const labels={succeeded:'Process exited successfully',failed:'Process failed',interrupted:'Interrupted',collector_failed:'Collector failed',unknown:'Terminal result unknown'};
|
|
153
|
+
const state=Object.hasOwn(labels,execution.state)?execution.state:'unknown';
|
|
154
|
+
const exit=Number.isSafeInteger(execution.return_code)?`Recorded exit code: ${execution.return_code}.`:'Exit code unavailable.';
|
|
155
|
+
card('execution','Execution',state,labels[state],
|
|
156
|
+
exit+' Task outcome is assessed separately.');
|
|
157
|
+
card('task','Task verification','unverified','Not independently verified',
|
|
158
|
+
`Recorded task reports: ${count(task.reported_completed)} completed; ${count(task.reported_failed)} failed. These are not test results.`);
|
|
159
|
+
if(Number.isSafeInteger(task.both_reported)&&task.both_reported>0){
|
|
160
|
+
panel.lastElementChild.append(make('p',`${task.both_reported} task(s) have both completion and failure reports; neither report is discarded.`));
|
|
161
|
+
}
|
|
162
|
+
const observation=object(value?.observation),incomplete=observation.state==='observation_incomplete';
|
|
163
|
+
card('observation','Observation completeness',incomplete?'incomplete':'not_verified',
|
|
164
|
+
incomplete?'OBSERVATION INCOMPLETE':'Completeness not verified',
|
|
165
|
+
(Array.isArray(observation.reasons)?observation.reasons.join('; '):'No observation assessment recorded.')+
|
|
166
|
+
' Process exit and task verification do not establish observation completeness.');
|
|
167
|
+
const gaps=content.state==='declared_gaps';
|
|
168
|
+
card('content','Recorded content',gaps?'declared_gaps':'not_verified',gaps?'Declared content gaps':'Bytes not verified in this view',
|
|
169
|
+
`${count(content.declared)} content record(s); ${count(content.invalid_references)} invalid reference(s); `+
|
|
170
|
+
`${count(content.source_partial)} source-incomplete; ${count(content.source_completeness_unknown)} with unknown source completeness.`);
|
|
171
|
+
const details=make('details');details.open=expanded;
|
|
172
|
+
details.append(make('summary','Evidence scope and limitations'));
|
|
173
|
+
if(execution.event_id)details.append(make('p','Source event: '+execution.event_id));
|
|
174
|
+
if(execution.reason)details.append(make('p','Terminal evidence status: '+execution.reason));
|
|
175
|
+
details.append(make('p','FINISHED only describes recording/view state. Native completion reports, termination text, and exit code 0 do not establish task quality or independent validation.'));
|
|
176
|
+
details.append(make('p',`${count(content.unique_declared_files)} unique declared content file(s); `+
|
|
177
|
+
`${count(content.opaque)} opaque record(s); ${count(content.redacted)} explicitly redacted record(s). `+
|
|
178
|
+
'These are metadata counts, not readable-body coverage or end-to-end recall.'));
|
|
179
|
+
details.append(make('p','The content inventory above does not verify bytes. The separate delivery checks distinguish recorded export verification, current folder verification, and final history synchronization.'));
|
|
180
|
+
const inspection=object(value?.inspection);
|
|
181
|
+
if(!value||inspection.state!=='declared_graph'){
|
|
182
|
+
const warning=make('p','Inventory is partial or unavailable. Hidden, malformed, ambiguous, or uninspected records are not counted as absent.');
|
|
183
|
+
warning.dataset.warning='partial';details.append(warning);
|
|
184
|
+
}
|
|
185
|
+
if(inspection.limit_reached)details.append(make('p','Metadata inspection reached its safety budget. Counts are lower bounds, not a complete inventory.'));
|
|
186
|
+
details.append(make('p',`Ambiguous node IDs: ${count(inspection.ambiguous_node_ids)}; malformed records: ${count(inspection.invalid_records)}.`));
|
|
187
|
+
for(const report of (Array.isArray(task.reports)?task.reports:[]).slice(0,20)){
|
|
188
|
+
details.append(make('p',[report.relation,report.task_id,report.edge_id].filter(v=>typeof v==='string').join(' · ')));
|
|
189
|
+
}
|
|
190
|
+
panel.append(details);
|
|
191
|
+
if(scroll>0&&selected&&Number.isFinite(anchor))host.scrollTop+=selected.getBoundingClientRect().top-anchor;
|
|
192
|
+
}
|
|
193
|
+
function refresh(packet){
|
|
194
|
+
const graph=graphNow(),key=JSON.stringify([graph.session_id||null,graph.source_path||null]);
|
|
195
|
+
if(key!==currentKey){currentKey=key;latest=null;lastSignature='';panel.querySelector('details')?.remove()}
|
|
196
|
+
const candidate=object(packet).run_assessment||object(object(packet).graph).run_assessment;
|
|
197
|
+
if(candidate){latest=compatible(candidate,graph)?candidate:null}
|
|
198
|
+
else if(!latest){
|
|
199
|
+
const embedded=graph.run_assessment||window.__execweaveStaticRunAssessment;
|
|
200
|
+
if(compatible(embedded,graph))latest=embedded;
|
|
201
|
+
}
|
|
202
|
+
// Never infer success from a legacy label, absent fields, or a completed viewer.
|
|
203
|
+
window.__execweaveDeliveryStatus?.accept(packet);
|
|
204
|
+
render(latest);
|
|
205
|
+
renderHandoffAlerts(packet);
|
|
206
|
+
window.__execweaveDeliveryStatus?.mount(panel);
|
|
207
|
+
}
|
|
208
|
+
const previous=window.__execweaveDashboard||{};
|
|
209
|
+
window.__execweaveDashboard={...previous,
|
|
210
|
+
onPayload(data){previous.onPayload?.(data);refresh(data)},
|
|
211
|
+
onFinished(...args){previous.onFinished?.(...args);refresh()}
|
|
212
|
+
};
|
|
213
|
+
window.__execweaveRunAssessment={refresh};refresh();
|
|
214
|
+
// Workflow filters, selection, replay, and layout controls replace SVG DOM
|
|
215
|
+
// without necessarily delivering a new run snapshot. Restore markers after
|
|
216
|
+
// each replacement, using a coalesced frame and idempotent DOM writes.
|
|
217
|
+
const renderRoots=['nodes','edges'].map(id=>document.getElementById(id)).filter(Boolean);
|
|
218
|
+
if(renderRoots.length){
|
|
219
|
+
let pending=false;
|
|
220
|
+
const schedule=()=>{
|
|
221
|
+
if(pending)return;
|
|
222
|
+
pending=true;
|
|
223
|
+
requestAnimationFrame(()=>{pending=false;renderHandoffAlerts()});
|
|
224
|
+
};
|
|
225
|
+
const observer=new MutationObserver(schedule);
|
|
226
|
+
for(const root of renderRoots){
|
|
227
|
+
observer.observe(root,{subtree:true,childList:true,
|
|
228
|
+
attributes:true,attributeFilter:['class','data-warning']});
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
})();
|
|
233
|
+
""".strip()
|
|
234
|
+
|
|
235
|
+
RUN_ASSESSMENT_CSS = r"""
|
|
236
|
+
|
|
237
|
+
/* The workflow toolbar is injected after this alert. Both must occupy
|
|
238
|
+
explicit rows; otherwise CSS Grid auto-places one below the canvas. */
|
|
239
|
+
#graph-panel:has(> #execweave-handoff-alerts:not([hidden])){grid-template-rows:46px auto auto minmax(0,1fr)}
|
|
240
|
+
#graph-panel > #execweave-handoff-alerts:not([hidden]){grid-row:2;min-width:0;align-self:stretch}
|
|
241
|
+
#graph-panel:has(> #execweave-handoff-alerts:not([hidden])) > #execweave-workflow-controls{grid-row:3}
|
|
242
|
+
#graph-panel:has(> #execweave-handoff-alerts:not([hidden])) > #wrap{grid-row:4}
|
|
243
|
+
#graph-panel:has(> #execweave-handoff-alerts[hidden]) > #execweave-workflow-controls{grid-row:2}
|
|
244
|
+
#graph-panel:has(> #execweave-handoff-alerts[hidden]) > #wrap{grid-row:3}
|
|
245
|
+
#execweave-handoff-alerts{display:flex;flex-wrap:wrap;gap:8px;padding:6px 14px;border-bottom:1px solid var(--border,#888);background:var(--panel,#222);position:sticky;top:0;z-index:12}
|
|
246
|
+
#execweave-handoff-alerts[hidden]{display:none}
|
|
247
|
+
.execweave-handoff-alert{cursor:pointer;border:1px solid var(--noncausal,#b56a16);border-left:4px solid var(--noncausal,#b56a16);border-radius:5px;padding:7px 10px;background:transparent;color:inherit;font-size:13px;font-weight:600}
|
|
248
|
+
.execweave-handoff-alert:hover,.execweave-handoff-alert:focus-visible{outline:2px solid var(--noncausal,#b56a16)}
|
|
249
|
+
.node[data-warning="receive-not-observed"] rect{stroke:var(--noncausal,#b56a16)!important;stroke-width:3px!important;stroke-dasharray:7 3}
|
|
250
|
+
.edge.handoff-unconfirmed{stroke:var(--noncausal,#b56a16)!important;stroke-width:3.5px!important;stroke-dasharray:7 3}
|
|
251
|
+
.node[data-process-exit="nonzero"] rect{stroke:var(--noncausal,#b56a16)!important;stroke-width:3px!important}
|
|
252
|
+
.execweave-process-exit-alert{border-left-color:var(--noncausal,#b56a16)}
|
|
253
|
+
#execweave-run-assessment{overflow-wrap:anywhere;margin-bottom:16px;padding-bottom:12px;border-bottom:1px solid var(--border,#888)}
|
|
254
|
+
#execweave-delivery-status{overflow-wrap:anywhere;margin:-8px 0 16px}
|
|
255
|
+
#execweave-run-assessment h2{font-size:15px;margin:0 0 10px}
|
|
256
|
+
:is(#execweave-run-assessment,#execweave-delivery-status) h3{font-size:12px;text-transform:uppercase;letter-spacing:.04em;margin:0 0 5px;color:var(--muted)}
|
|
257
|
+
:is(#execweave-run-assessment,#execweave-delivery-status) .run-assessment-card{border:1px solid var(--border,#888);border-radius:8px;padding:8px;margin:6px 0}
|
|
258
|
+
:is(#execweave-run-assessment,#execweave-delivery-status) strong{font-size:14px}
|
|
259
|
+
:is(#execweave-run-assessment,#execweave-delivery-status) p{font-size:12px;line-height:1.5;margin:5px 0}
|
|
260
|
+
:is(#execweave-run-assessment,#execweave-delivery-status) details{font-size:12px;margin-top:8px}
|
|
261
|
+
:is(#execweave-run-assessment,#execweave-delivery-status) summary{cursor:pointer}
|
|
262
|
+
:is(#execweave-run-assessment,#execweave-delivery-status) [data-state="failed"],:is(#execweave-run-assessment,#execweave-delivery-status) [data-state="collector_failed"]{border-left:4px solid var(--danger,#c2414f)}
|
|
263
|
+
:is(#execweave-run-assessment,#execweave-delivery-status) [data-state="incomplete"],:is(#execweave-run-assessment,#execweave-delivery-status) [data-state="not_verified"],:is(#execweave-run-assessment,#execweave-delivery-status) [data-state="declared_gaps"]{border-left:4px solid var(--noncausal,#b56a16)}
|
|
264
|
+
""".strip()
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
def inject_run_assessment(html: str) -> str:
|
|
268
|
+
if 'id="execweave-run-assessment-script"' in html:
|
|
269
|
+
return html
|
|
270
|
+
if "</body>" not in html:
|
|
271
|
+
raise RuntimeError("run assessment requires a dashboard body")
|
|
272
|
+
return inject_controlled_checks(inject_task_reports(html.replace("</body>", "<style>" + RUN_ASSESSMENT_CSS + "</style>"
|
|
273
|
+
+ delivery_scripts() + '<script id="execweave-run-assessment-script">' + RUN_ASSESSMENT_JS
|
|
274
|
+
+ "</script>\n</body>", 1)))
|