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,261 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from .viewer_projection_bridges import PROJECTION_SCRIPT
|
|
4
|
+
from .viewer_layout_geometry import LAYOUT_GEOMETRY_SCRIPT
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
PROJECTION_DASHBOARD_SCRIPT = PROJECTION_SCRIPT + "\n" + LAYOUT_GEOMETRY_SCRIPT + "\n" + r"""
|
|
8
|
+
(function(){
|
|
9
|
+
let geometryTopology=null,geometrySignature='';
|
|
10
|
+
function signature(topo){
|
|
11
|
+
return [...positions].map(([id,p])=>`${id}:${p.x},${p.y},${topo.width?.get(id)},${topo.height?.get(id)}`).join('|');
|
|
12
|
+
}
|
|
13
|
+
function projectionPorts(edge,topo,placement){
|
|
14
|
+
const sp=placement.get(edge.source)||{x:0,y:0},tp=placement.get(edge.target)||{x:0,y:0};
|
|
15
|
+
const sw=topo.width?.get(edge.source)||execweaveWidthOf(edge.source),tw=topo.width?.get(edge.target)||execweaveWidthOf(edge.target);
|
|
16
|
+
const forward=tp.x+tw/2>=sp.x+sw/2;
|
|
17
|
+
const y=(id,p,port)=>{const h=topo.height?.get(id)||execweaveHeightOf(id);return p.y+(!port||port.total<=1?h/2:10+(h-20)*port.index/(port.total-1))};
|
|
18
|
+
const source={x:forward?sp.x+sw:sp.x,y:y(edge.source,sp,topo.sourcePort.get(edgeId(edge)))};
|
|
19
|
+
const target={x:forward?tp.x:tp.x+tw,y:y(edge.target,tp,topo.targetPort.get(edgeId(edge)))};
|
|
20
|
+
return{source,target,forward};
|
|
21
|
+
}
|
|
22
|
+
function retarget(points,source,target){
|
|
23
|
+
const first=points[0],last=points[points.length-1];
|
|
24
|
+
return points.map((point,index)=>{
|
|
25
|
+
const t=index/(points.length-1),u=1-t;
|
|
26
|
+
// Affinely map the Dagre corridor onto the actual side ports. Translating
|
|
27
|
+
// endpoints alone preserves obsolete vertical excursions after lane packing.
|
|
28
|
+
const axis=(key)=>Math.abs(last[key]-first[key])>1e-7
|
|
29
|
+
?source[key]+(point[key]-first[key])/(last[key]-first[key])*(target[key]-source[key])
|
|
30
|
+
:point[key]+(source[key]-first[key])*u+(target[key]-last[key])*t;
|
|
31
|
+
return{x:axis('x'),y:axis('y')};
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
function projectionRetargetDagreRoutePoints(topo){
|
|
35
|
+
if(!(topo?.routePoints instanceof Map))return topo;
|
|
36
|
+
// Never retarget an already retargeted path. These immutable points remain the
|
|
37
|
+
// provenance of every subsequent render, collision adjustment and manual drag.
|
|
38
|
+
if(!topo.rawDagreRoutePoints)topo.rawDagreRoutePoints=new Map([...topo.routePoints].map(([k,p])=>[k,p.map(v=>({...v}))]));
|
|
39
|
+
const representatives=new Map();
|
|
40
|
+
for(const edge of [...edgeById.values()].sort((a,b)=>edgeId(a).localeCompare(edgeId(b)))){
|
|
41
|
+
const key=`${edge.source}\u0000${edge.target}`;if(!representatives.has(key))representatives.set(key,edge);
|
|
42
|
+
}
|
|
43
|
+
for(const [key,points] of topo.rawDagreRoutePoints){
|
|
44
|
+
const edge=representatives.get(key);if(!edge||points.length<2)continue;
|
|
45
|
+
const ports=projectionPorts(edge,topo,topo.spec);
|
|
46
|
+
topo.routePoints.set(key,retarget(points,ports.source,ports.target));
|
|
47
|
+
}
|
|
48
|
+
return topo;
|
|
49
|
+
}
|
|
50
|
+
function syncGeometry(){
|
|
51
|
+
const topo=execweaveTopology,next=signature(topo);
|
|
52
|
+
if(geometryTopology===topo&&geometrySignature===next)return;
|
|
53
|
+
for(const [id,p] of positions){const s=topo.spec.get(id);if(s){s.x=p.x;s.y=p.y}}
|
|
54
|
+
if(typeof execweaveRecomputePorts==='function')execweaveRecomputePorts(topo);
|
|
55
|
+
projectionRetargetDagreRoutePoints(topo);
|
|
56
|
+
geometryTopology=topo;geometrySignature=next;
|
|
57
|
+
}
|
|
58
|
+
const projectionBuildTopologyBase=execweaveBuildTopology;
|
|
59
|
+
execweaveBuildTopology=function(){
|
|
60
|
+
const topo=projectionBuildTopologyBase();
|
|
61
|
+
return optimize(projectionRetargetDagreRoutePoints(topo));
|
|
62
|
+
};
|
|
63
|
+
const projectionRouteBase=execweaveRoute;
|
|
64
|
+
const routeCache=new Map();
|
|
65
|
+
function route(edge){
|
|
66
|
+
const topo=execweaveTopology,bundle=topo.bundleByEdge.get(edgeId(edge));
|
|
67
|
+
if(bundle&&bundle.size>1){
|
|
68
|
+
const base=projectionRouteBase(edge),pts=execweaveGeometry.polyline(base.d);
|
|
69
|
+
if(!pts||pts.length!==4)return base;
|
|
70
|
+
const [a,,,b]=pts,rail=pts[1].x;
|
|
71
|
+
const boxes=[...positions].filter(([id])=>id!==edge.source&&id!==edge.target).map(([id,p])=>
|
|
72
|
+
({x:p.x,y:p.y,w:topo.width?.get(id)||execweaveWidthOf(id),h:topo.height?.get(id)||execweaveHeightOf(id)}));
|
|
73
|
+
const candidates=[rail,...boxes.flatMap(box=>[box.x-2,box.x+box.w+2])]
|
|
74
|
+
.filter(x=>x>=Math.min(a.x,b.x)&&x<=Math.max(a.x,b.x)).sort((x,y)=>Math.abs(x-rail)-Math.abs(y-rail)||x-y);
|
|
75
|
+
for(const x of candidates){
|
|
76
|
+
const p={x,y:a.y},q={x,y:b.y};
|
|
77
|
+
if(boxes.some(box=>execweaveGeometry.throughBox(a,p,box)||execweaveGeometry.throughBox(p,q,box)||execweaveGeometry.throughBox(q,b,box)))continue;
|
|
78
|
+
return{...base,d:`M ${a.x} ${a.y} H ${x} V ${b.y} H ${b.x}`,labelX:(x+b.x)/2};
|
|
79
|
+
}
|
|
80
|
+
return base;
|
|
81
|
+
}
|
|
82
|
+
if(typeof execweaveIsStopped==='function'&&execweaveIsStopped(edge))return projectionRouteBase(edge);
|
|
83
|
+
const points=topo.rawDagreRoutePoints?.get(`${edge.source}\u0000${edge.target}`);
|
|
84
|
+
if(!points||points.length<2)return projectionRouteBase(edge);
|
|
85
|
+
const ports=projectionPorts(edge,topo,positions),adjusted=retarget(points,ports.source,ports.target);
|
|
86
|
+
const boxes=[...positions].filter(([id])=>id!==edge.source&&id!==edge.target).map(([id,p])=>
|
|
87
|
+
({id,x:p.x,y:p.y,w:topo.width?.get(id)||execweaveWidthOf(id),h:topo.height?.get(id)||execweaveHeightOf(id)}));
|
|
88
|
+
const cacheKey=JSON.stringify([adjusted,boxes]);
|
|
89
|
+
let clearance=routeCache.get(cacheKey);
|
|
90
|
+
if(!clearance){clearance=execweaveGeometry.avoidNodes(adjusted,boxes);if(routeCache.size>=2048)routeCache.delete(routeCache.keys().next().value);routeCache.set(cacheKey,clearance)}
|
|
91
|
+
const d=clearance.points.map((p,i)=>`${i?'L':'M'} ${p.x} ${p.y}`).join(' ');
|
|
92
|
+
const label=clearance.points[Math.floor(clearance.points.length/2)];
|
|
93
|
+
const spawn=typeof execweaveIsSpawn==='function'&&execweaveIsSpawn(edge);
|
|
94
|
+
return{d,labelX:label.x,labelY:label.y-8,kind:spawn?'spawn':(ports.forward?'forward':'reverse'),
|
|
95
|
+
geometryKind:'dagre-polyline',bundle:null,usesDagrePoints:true,obstacleDetours:clearance.detours,obstructedDagreGuides:clearance.obstructedGuides};
|
|
96
|
+
}
|
|
97
|
+
execweaveRoute=function(edge){syncGeometry();return route(edge)};
|
|
98
|
+
|
|
99
|
+
function currentMetrics(){
|
|
100
|
+
syncGeometry();
|
|
101
|
+
const nodes=[...positions].filter(([id])=>nodeById.has(id)).map(([id,p])=>({id,x:p.x,y:p.y,w:execweaveWidthOf(id),h:execweaveHeightOf(id)}));
|
|
102
|
+
const edges=[...edgeById.values()].filter(e=>positions.has(e.source)&&positions.has(e.target)).map(e=>({...e,d:route(e).d}));
|
|
103
|
+
return execweaveGeometry.measure(nodes,edges);
|
|
104
|
+
}
|
|
105
|
+
function paint(){
|
|
106
|
+
syncGeometry();
|
|
107
|
+
for(const [id,p] of positions){const group=nodeElements.get(id);if(group)group.setAttribute('transform',`translate(${p.x} ${p.y})`)}
|
|
108
|
+
for(const edge of edgeById.values())updateEdgeElement(edge);
|
|
109
|
+
}
|
|
110
|
+
function restore(priorY,topo){
|
|
111
|
+
if(!priorY.size)return{restored:false,reason:'initial'};
|
|
112
|
+
const next=new Map([...positions].map(([id,p])=>[id,{...p}]));
|
|
113
|
+
const newMetrics=currentMetrics(),newCrossings=newMetrics.EDGE_CROSSINGS;
|
|
114
|
+
for(const [id,y] of priorY){const p=positions.get(id);if(p&&Number.isFinite(y))p.y=y}
|
|
115
|
+
if(typeof execweaveSeparateOverlappingNodes==='function')execweaveSeparateOverlappingNodes({spec:positions});
|
|
116
|
+
const priorMetrics=currentMetrics(),priorCrossings=priorMetrics.EDGE_CROSSINGS;
|
|
117
|
+
const restored=priorCrossings<=newCrossings&&priorMetrics.NODE_OVERLAPS===0&&priorMetrics.EDGE_NODE_INTERSECTIONS<=newMetrics.EDGE_NODE_INTERSECTIONS;
|
|
118
|
+
if(!restored)positions=next;
|
|
119
|
+
syncGeometry();
|
|
120
|
+
topo.liveDecross={restored,priorCrossings,newCrossings,priorMetrics,newMetrics};
|
|
121
|
+
return topo.liveDecross;
|
|
122
|
+
}
|
|
123
|
+
const layoutCache=new Map();
|
|
124
|
+
function optimize(topo){
|
|
125
|
+
if(typeof document==='undefined'||typeof nodeById==='undefined'||!topo.spec?.size)return topo;
|
|
126
|
+
const previousTopology=execweaveTopology,previousPositions=positions;
|
|
127
|
+
execweaveTopology=topo;
|
|
128
|
+
positions=new Map([...topo.spec].map(([id,s])=>[id,{x:s.x,y:s.y}]));
|
|
129
|
+
geometryTopology=null;
|
|
130
|
+
try{
|
|
131
|
+
const inputKey=JSON.stringify({nodes:[...topo.spec].map(([id,s])=>[id,s.x,s.y,topo.width.get(id),topo.height.get(id)]).sort(),
|
|
132
|
+
edges:[...edgeById.values()].map(e=>[edgeId(e),e.source,e.target,e.relation]).sort()});
|
|
133
|
+
if(layoutCache.has(inputKey)){
|
|
134
|
+
const hit=layoutCache.get(inputKey);
|
|
135
|
+
for(const [id,y] of hit.ys)positions.get(id).y=y;
|
|
136
|
+
syncGeometry();topo.layoutQuality=hit.diagnostics;return topo;
|
|
137
|
+
}
|
|
138
|
+
const started=performance.now(),postDagre=currentMetrics();
|
|
139
|
+
const dagrePositions=new Map([...positions].map(([id,p])=>[id,{...p}]));
|
|
140
|
+
for(const [id,p] of positions){const before=topo.dagrePipeline?.stages?.PRE_DAGRE?.get(id);if(before)p.y=before.y}
|
|
141
|
+
if(typeof execweaveSeparateOverlappingNodes==='function')execweaveSeparateOverlappingNodes({spec:positions});
|
|
142
|
+
const preLayout=currentMetrics();
|
|
143
|
+
if(postDagre.NODE_OVERLAPS===0&&(preLayout.NODE_OVERLAPS>0||postDagre.EDGE_CROSSINGS<=preLayout.EDGE_CROSSINGS))positions=dagrePositions;
|
|
144
|
+
let best=currentMetrics(),evaluations=0;
|
|
145
|
+
// Bound work by displayed edges, never elapsed time: identical payloads must
|
|
146
|
+
// produce identical geometry on slow and fast hosts. Hitting the budget is
|
|
147
|
+
// diagnostic, not a claim of global optimality.
|
|
148
|
+
const budget=Math.max(24,Math.min(512,Math.floor(24000/Math.max(1,edgeById.size))));
|
|
149
|
+
const crossingCeiling=best.EDGE_CROSSINGS;
|
|
150
|
+
const better=m=>m.NODE_OVERLAPS===0&&m.EDGE_CROSSINGS<=crossingCeiling&&
|
|
151
|
+
(m.EDGE_NODE_INTERSECTIONS<best.EDGE_NODE_INTERSECTIONS||
|
|
152
|
+
m.EDGE_NODE_INTERSECTIONS===best.EDGE_NODE_INTERSECTIONS&&m.EDGE_CROSSINGS<best.EDGE_CROSSINGS);
|
|
153
|
+
const lanes=['model','tool','file','endpoint','agent'];
|
|
154
|
+
const eligible=id=>lanes.includes(topo.spec.get(id)?.lane)&&!topo.secondaryPackedIds?.has(id);
|
|
155
|
+
const attempt=()=>{evaluations++;const m=currentMetrics();if(better(m)){best=m;return true}return false};
|
|
156
|
+
for(let round=0;round<2&&evaluations<budget;round++){
|
|
157
|
+
let changed=false;
|
|
158
|
+
for(const lane of lanes){
|
|
159
|
+
const ids=[...positions.keys()].filter(id=>eligible(id)&&topo.spec.get(id).lane===lane)
|
|
160
|
+
.sort((a,b)=>positions.get(a).y-positions.get(b).y||a.localeCompare(b));
|
|
161
|
+
for(let i=1;i<ids.length&&evaluations<budget;i++){
|
|
162
|
+
const a=positions.get(ids[i]),b=positions.get(ids[i-1]),ay=a.y,by=b.y;
|
|
163
|
+
a.y=by;b.y=ay;if(attempt())changed=true;else{a.y=ay;b.y=by}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
const ids=[...positions.keys()].filter(eligible).sort((a,b)=>lanes.indexOf(topo.spec.get(a).lane)-lanes.indexOf(topo.spec.get(b).lane)||a.localeCompare(b));
|
|
167
|
+
for(const id of ids){
|
|
168
|
+
const p=positions.get(id),old=p.y,h=execweaveHeightOf(id);
|
|
169
|
+
const candidates=[...new Set([...positions].filter(([k])=>k!==id&&!topo.secondaryPackedIds?.has(k))
|
|
170
|
+
.flatMap(([k,v])=>[v.y-h-24,v.y+execweaveHeightOf(k)+24]))]
|
|
171
|
+
.sort((a,b)=>Math.abs(a-old)-Math.abs(b-old)||a-b);
|
|
172
|
+
for(const y of candidates){
|
|
173
|
+
if(evaluations>=budget)break;
|
|
174
|
+
const before=p.y;p.y=y;if(attempt())changed=true;else p.y=before;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
if(!changed)break;
|
|
178
|
+
}
|
|
179
|
+
syncGeometry();
|
|
180
|
+
topo.layoutQuality={pre:preLayout,dagre:postDagre,final:currentMetrics(),evaluations,budget,
|
|
181
|
+
budget_exhausted:evaluations>=budget,elapsed_ms:performance.now()-started};
|
|
182
|
+
if(layoutCache.size>=16)layoutCache.delete(layoutCache.keys().next().value);
|
|
183
|
+
layoutCache.set(inputKey,{ys:[...positions].map(([id,p])=>[id,p.y]),diagnostics:topo.layoutQuality});
|
|
184
|
+
return topo;
|
|
185
|
+
}finally{positions=previousPositions;execweaveTopology=previousTopology;geometryTopology=null}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function clearLabelFromNodes(label){
|
|
189
|
+
// Solve placement using the rendered text box, never estimated characters.
|
|
190
|
+
// At the existing route-label X, each overlapping node forbids one interval
|
|
191
|
+
// of text-baseline Y values. The nearest endpoint of their merged union is
|
|
192
|
+
// the minimum vertical displacement that keeps the whole label readable.
|
|
193
|
+
// This changes text placement only: topology, node positions and SVG routes
|
|
194
|
+
// remain exactly the ones selected by the layout/port pipeline.
|
|
195
|
+
const box=label.getBBox(),baseline=Number(label.getAttribute('y'));
|
|
196
|
+
if(!(box.width>0&&box.height>0&&Number.isFinite(baseline)))return;
|
|
197
|
+
const padding=2,offset=box.y-baseline,intervals=[];
|
|
198
|
+
for(const [id,p] of positions){
|
|
199
|
+
if(!nodeById.has(id))continue;
|
|
200
|
+
const w=execweaveWidthOf(id),h=execweaveHeightOf(id);
|
|
201
|
+
if(box.x+box.width<=p.x-padding||box.x>=p.x+w+padding)continue;
|
|
202
|
+
intervals.push([p.y-padding-box.height-offset,p.y+h+padding-offset]);
|
|
203
|
+
}
|
|
204
|
+
intervals.sort((a,b)=>a[0]-b[0]||a[1]-b[1]);
|
|
205
|
+
const merged=[];
|
|
206
|
+
for(const current of intervals){
|
|
207
|
+
const last=merged[merged.length-1];
|
|
208
|
+
if(last&¤t[0]<=last[1])last[1]=Math.max(last[1],current[1]);
|
|
209
|
+
else merged.push([...current]);
|
|
210
|
+
}
|
|
211
|
+
for(const [lo,hi] of merged){
|
|
212
|
+
if(baseline>lo&&baseline<hi){
|
|
213
|
+
label.setAttribute('y',baseline-lo<=hi-baseline?lo:hi);
|
|
214
|
+
break;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
if(typeof updateEdgeElement==='function'){
|
|
220
|
+
const updateBase=updateEdgeElement;
|
|
221
|
+
updateEdgeElement=function(edge){
|
|
222
|
+
updateBase(edge);const els=edgeElements.get(edgeId(edge));if(!els)return;
|
|
223
|
+
const r=route(edge);els.visible.dataset.geometryKind=r.geometryKind||r.kind;
|
|
224
|
+
els.hit.dataset.geometryKind=r.geometryKind||r.kind;
|
|
225
|
+
clearLabelFromNodes(els.label);
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
if(typeof execweaveRefreshIncidentEdges==='function')execweaveRefreshIncidentEdges=function(){paint()};
|
|
229
|
+
window.__execweaveLayout={projectionRepair:window.__execweaveProjectionRepair,
|
|
230
|
+
crossingCount:()=>currentMetrics().EDGE_CROSSINGS,metrics:currentMetrics,
|
|
231
|
+
routeFor:id=>{const edge=edgeById.get(id);return edge?execweaveRoute(edge):null},
|
|
232
|
+
topology:()=>execweaveTopology,syncGeometry,restorePrior:restore,paint,
|
|
233
|
+
diagnostics:()=>({live:execweaveTopology.liveDecross||null,layout:execweaveTopology.layoutQuality||null})};
|
|
234
|
+
})();
|
|
235
|
+
// The callsite is in the shared dashboard scope, not inside the installer IIFE.
|
|
236
|
+
function execweaveRestorePriorYUnlessWorse(priorY,topo){
|
|
237
|
+
return window.__execweaveLayout.restorePrior(priorY,topo);
|
|
238
|
+
}
|
|
239
|
+
""".strip()
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
_PRIOR_Y_RESTORE = (
|
|
243
|
+
"for(const [id,y] of priorY){const p=positions.get(id);"
|
|
244
|
+
"if(p&&Number.isFinite(y))p.y=y}"
|
|
245
|
+
)
|
|
246
|
+
_PRIOR_Y_GATED = (
|
|
247
|
+
"if(typeof execweaveRestorePriorYUnlessWorse==='function')"
|
|
248
|
+
"execweaveRestorePriorYUnlessWorse(priorY,execweaveTopology);"
|
|
249
|
+
"else " + _PRIOR_Y_RESTORE
|
|
250
|
+
)
|
|
251
|
+
_STARTUP_SEAM = "applyTheme(initialTheme());applyTransform();poll();"
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
def inject_projection_dashboard_repairs(html: str) -> str:
|
|
255
|
+
"""Install projection/decross repairs in the shared live + static Dashboard."""
|
|
256
|
+
if _PRIOR_Y_RESTORE not in html:
|
|
257
|
+
raise RuntimeError("Projection live Y-stability seam changed")
|
|
258
|
+
html = html.replace(_PRIOR_Y_RESTORE, _PRIOR_Y_GATED, 1)
|
|
259
|
+
if _STARTUP_SEAM not in html:
|
|
260
|
+
raise RuntimeError("Projection dashboard startup seam changed")
|
|
261
|
+
return html.replace(_STARTUP_SEAM, PROJECTION_DASHBOARD_SCRIPT + "\n" + _STARTUP_SEAM, 1)
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"""Archive receipts, manual offline verification, and final-sync status controls."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
from .viewer_archive_verifier import ARCHIVE_VERIFIER_JS
|
|
5
|
+
|
|
6
|
+
DELIVERY_STATUS_JS = r"""
|
|
7
|
+
(()=>{
|
|
8
|
+
'use strict';
|
|
9
|
+
if(window.__execweaveDeliveryStatus)return;
|
|
10
|
+
const make=(tag,text)=>{const n=document.createElement(tag);if(text!==undefined)n.textContent=String(text);return n};
|
|
11
|
+
const button=(text,fn)=>{const n=make('button',text);n.type='button';n.onclick=fn;return n};
|
|
12
|
+
const graphNow=()=>window.__execweaveCore?.getGraph?.()||window.__execweaveStaticGraph||{};
|
|
13
|
+
const scope=()=>{const g=graphNow();return {session_id:g.session_id||null,source_path:g.source_path||null}};
|
|
14
|
+
const key=()=>JSON.stringify(scope());
|
|
15
|
+
const count=v=>Number.isSafeInteger(v)&&v>=0?String(v):'unknown';
|
|
16
|
+
let activeKey=null,receipt=null,offline=null,controller=null,generation=0,host=null,picker=null,lastRender='',disclosure=null,heading=null,expanded=false;
|
|
17
|
+
function reconcile(){
|
|
18
|
+
const next=key();if(next===activeKey)return;
|
|
19
|
+
activeKey=next;generation++;controller?.abort();controller=null;receipt=null;offline=null;expanded=false;
|
|
20
|
+
if(disclosure)disclosure.open=false;
|
|
21
|
+
if(picker)picker.value='';
|
|
22
|
+
}
|
|
23
|
+
function matches(value){const s=scope();return typeof s.session_id==='string'&&value?.session_id===s.session_id&&(value.source_path||null)===s.source_path}
|
|
24
|
+
function card(axis,title,state,label,text){
|
|
25
|
+
const n=make('div');n.className='run-assessment-card';n.dataset.axis=axis;n.dataset.state=state;
|
|
26
|
+
n.append(make('h3',title),make('strong',label),make('p',text));host.append(n);return n;
|
|
27
|
+
}
|
|
28
|
+
const ERRORS={
|
|
29
|
+
missing_file:'A required export or declared content file is missing.',
|
|
30
|
+
hash_mismatch:'A selected file does not match its recorded SHA-256.',
|
|
31
|
+
size_mismatch:'A selected file has a different size from its recorded reference.',
|
|
32
|
+
run_mismatch:'The selected folder belongs to a different run or source.',
|
|
33
|
+
scope_unavailable:'This page has no usable run identity. Verification cannot be bound to it.',
|
|
34
|
+
verification_limit:'Verification reached its file, byte, JSON, or reference limit. No complete verdict is issued.',
|
|
35
|
+
invalid_reference:'An index has an invalid or unsafe content reference.',
|
|
36
|
+
conflicting_reference:'Indexes disagree about the same content file.',
|
|
37
|
+
duplicate_json_key:'A JSON document contains duplicate decoded keys.',
|
|
38
|
+
invalid_json:'An export index or receipt is not strict UTF-8 JSON.',
|
|
39
|
+
invalid_index:'An export index has an unsupported or malformed structure.',
|
|
40
|
+
invalid_receipt:'The receipt lacks valid primary-file fingerprints.',
|
|
41
|
+
unsupported_receipt:'This archive has no supported finalization receipt.',
|
|
42
|
+
invalid_folder:'Select a single exported run folder, not individual files.',
|
|
43
|
+
duplicate_file:'The folder selection contains duplicate archive paths.',
|
|
44
|
+
crypto_unavailable:'Native SHA-256 is unavailable in this browser context. Nothing is marked verified.',
|
|
45
|
+
changed_during_read:'A selected file changed while being read.',
|
|
46
|
+
invalid_lineage:'The redacted derivative lineage manifest is malformed or inconsistent.',
|
|
47
|
+
lineage_mismatch:'The redacted derivative files do not match their lineage manifest.',
|
|
48
|
+
cancelled:'Verification was cancelled. No complete verdict is issued.'
|
|
49
|
+
};
|
|
50
|
+
function redraw(){
|
|
51
|
+
reconcile();if(!host?.isConnected)return;
|
|
52
|
+
const status=window.__execweaveDashboard?.agentPanel?.getSynchronizationStatus?.();
|
|
53
|
+
const valid=status&&matches(status);
|
|
54
|
+
const state=valid?status.state:'unknown';
|
|
55
|
+
const archiveState=offline?.state||receipt?.state||'unavailable';
|
|
56
|
+
const brief={embedded:'embedded history',live:'history live',syncing:'history syncing',synced:'history response loaded',failed:'history sync failed',unknown:'history status unknown'};
|
|
57
|
+
const archiveBrief={verified_now:'selected files verified',checking:'checking files',not_verified:'files not verified',complete:'export check passed; not rechecked',incomplete:'export check failed',failed:'export failed',recording:'recording',exporting:'export pending',unavailable:'archive not verified'};
|
|
58
|
+
if(heading)heading.textContent='Delivery checks · '+(brief[state]||brief.unknown)+' · '+(archiveBrief[archiveState]||archiveBrief.unavailable);
|
|
59
|
+
if(disclosure)disclosure.dataset.state=state==='failed'||['incomplete','failed','not_verified'].includes(archiveState)?'incomplete':'not_verified';
|
|
60
|
+
const signature=JSON.stringify([activeKey,status,receipt,offline,!!controller]);
|
|
61
|
+
if(lastRender===signature&&host.childElementCount)return;lastRender=signature;host.replaceChildren();
|
|
62
|
+
const names={embedded:'Embedded history loaded',live:'Final synchronization not requested',syncing:'Final synchronization in progress',synced:'Final history response loaded',failed:'Final synchronization failed',unknown:'Synchronization status unavailable'};
|
|
63
|
+
const sync=card('synchronization','Conversation synchronization',Object.hasOwn(names,state)?state:'unknown',names[state]||names.unknown,
|
|
64
|
+
state==='embedded'?'Static content is loaded from this page. No live-server synchronization is implied.':
|
|
65
|
+
state==='synced'?(status.response_session_checked?'The response session matched this run. ':'The legacy response omitted its session identity. ')+
|
|
66
|
+
'This confirms history retrieval, not source completeness or task success.':
|
|
67
|
+
state==='failed'?'The last history response was not accepted. Existing history is retained; stopping polling is not synchronization.':
|
|
68
|
+
'This reports the existing history synchronizer; it does not start a second polling loop.');
|
|
69
|
+
if(state==='failed')sync.append(button('Retry final synchronization',()=>window.__execweaveDashboard?.agentPanel?.finishConversationPolling?.()));
|
|
70
|
+
let archive;
|
|
71
|
+
if(offline?.state==='verified_now'){
|
|
72
|
+
archive=card('archive','Selected archive verification','verified_now','Selected archive files verified',
|
|
73
|
+
`${offline.primary_file_count} primary files and ${offline.verified_file_count} unique content files (${offline.reference_count} references) verified using native SHA-256. `+
|
|
74
|
+
`Recorded export state: ${offline.recorded_state}. Checked: ${offline.checked_at}.`);
|
|
75
|
+
if(offline.derivation?.state==='verified_now')archive.append(make('p',
|
|
76
|
+
`Redacted derivative lineage verified for ${offline.derivation.mapping_count} source→derived mapping(s). `+
|
|
77
|
+
`Policy SHA-256: ${offline.derivation.policy_sha256}. The source archive itself was declared by fingerprint and was not rechecked from this selected derivative folder.`));
|
|
78
|
+
}else if(offline){
|
|
79
|
+
archive=card('archive','Selected archive verification',offline.state,
|
|
80
|
+
offline.state==='checking'?'Checking selected archive':'Archive not verified',
|
|
81
|
+
offline.state==='checking'?`${count(offline.checked_files)} file(s) checked. No complete verdict yet.`:
|
|
82
|
+
(ERRORS[offline.code]||'Verification failed; no complete verdict is issued.')+(offline.location?' Location: '+offline.location:''));
|
|
83
|
+
}else{
|
|
84
|
+
const r=receipt||{},state=r.state||'unavailable';
|
|
85
|
+
const labels={complete:'Recorded export check passed',incomplete:'Recorded export check failed',failed:'Export failed',recording:'Recording; archive not finalized',exporting:'Export verification pending',unavailable:'Archive not verified in this page'};
|
|
86
|
+
archive=card('archive','Archive verification',state,labels[state]||labels.unavailable,
|
|
87
|
+
state==='complete'?`${count(r.verified_file_count)} unique content files passed the recorded export check. Files have not been rechecked since then.`:
|
|
88
|
+
state==='incomplete'||state==='failed'?`Recorded content errors: ${count(r.error_count)}. Readable top-level files do not establish a complete archive.`:
|
|
89
|
+
'Select the exported run folder to check its primary files and declared content. No files are read automatically.');
|
|
90
|
+
if(r.reason==='inconsistent_finalization_report')archive.append(make('p','The finalization receipt is internally inconsistent; its success claim is not accepted.'));
|
|
91
|
+
for(const code of (Array.isArray(r.diagnostics)?r.diagnostics:[]).slice(0,20))archive.append(make('p',code));
|
|
92
|
+
}
|
|
93
|
+
archive.append(make('p','Scope: selected/declared graph and conversation content only. This is not proof of all raw events, source recall, task quality, or tamper-proof authenticity. A folder check does not attest that the current tab matches its viewer file.'));
|
|
94
|
+
archive.append(button('Verify exported run folder',()=>{ensurePicker();picker.click()}));
|
|
95
|
+
if(controller)archive.append(button('Cancel archive verification',()=>{generation++;controller.abort();controller=null;offline={state:'not_verified',code:'cancelled'};redraw()}));
|
|
96
|
+
}
|
|
97
|
+
function ensurePicker(){
|
|
98
|
+
if(picker)return;
|
|
99
|
+
picker=make('input');picker.type='file';picker.multiple=true;picker.setAttribute('webkitdirectory','');
|
|
100
|
+
picker.id='execweave-archive-folder';picker.setAttribute('aria-label','Exported run folder for verification');picker.hidden=true;
|
|
101
|
+
picker.onchange=()=>{const selected=Array.from(picker.files||[]);picker.value='';if(selected.length)verifySelected(selected)};
|
|
102
|
+
document.body.append(picker);
|
|
103
|
+
}
|
|
104
|
+
async function verifySelected(selected){
|
|
105
|
+
reconcile();const run=key(),token=++generation,expected=scope();controller?.abort();
|
|
106
|
+
const active=new AbortController();controller=active;offline={state:'checking',checked_files:0};redraw();
|
|
107
|
+
const timer=setTimeout(()=>active.abort(),120000);
|
|
108
|
+
try{
|
|
109
|
+
const verifier=window.__execweaveArchiveVerifier,files=verifier.filesFromSelection(selected);
|
|
110
|
+
const result=await verifier.verifyArchive(files,expected,{signal:active.signal,onProgress:p=>{
|
|
111
|
+
if(token===generation&&key()===run){offline={state:'checking',...p};redraw()}
|
|
112
|
+
}});
|
|
113
|
+
if(token===generation&&key()===run)offline=result;
|
|
114
|
+
}catch(error){
|
|
115
|
+
if(token===generation&&key()===run)offline={state:'not_verified',code:error.code||'read_failed',location:error.location||''};
|
|
116
|
+
}finally{
|
|
117
|
+
clearTimeout(timer);if(controller===active)controller=null;
|
|
118
|
+
if(token===generation&&key()===run)redraw();
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
function accept(packet){
|
|
122
|
+
reconcile();const candidate=packet?.finalization_assessment||packet?.graph?.finalization_assessment;
|
|
123
|
+
if(candidate){
|
|
124
|
+
const valid=candidate.schema_version==='0.1'&&candidate.scope==='recorded_finalization_result'&&matches(candidate)&&candidate.rechecked_now===false;
|
|
125
|
+
const completeOK=candidate.state!=='complete'||(Number.isSafeInteger(candidate.verified_file_count)&&candidate.verified_file_count>=0&&
|
|
126
|
+
candidate.verified_file_count===candidate.unique_file_count&&candidate.error_count===0&&candidate.reason==='recorded_export_verification');
|
|
127
|
+
receipt=valid&&completeOK?candidate:{state:'unavailable',reason:'inconsistent_finalization_report'};
|
|
128
|
+
}
|
|
129
|
+
redraw();
|
|
130
|
+
}
|
|
131
|
+
function mount(panel){
|
|
132
|
+
// Keep delivery disclosure separate from the assessment's existing details contract.
|
|
133
|
+
let next=panel.parentElement?.querySelector(':scope > #execweave-delivery-status');
|
|
134
|
+
if(!next){
|
|
135
|
+
next=make('div');next.id='execweave-delivery-status';
|
|
136
|
+
disclosure=make('details');disclosure.open=expanded;heading=make('summary');
|
|
137
|
+
heading.id='execweave-delivery-summary';disclosure.append(heading);
|
|
138
|
+
const body=make('div');body.className='execweave-delivery-body';disclosure.append(body);
|
|
139
|
+
const current=disclosure;current.ontoggle=()=>{if(disclosure===current)expanded=current.open};
|
|
140
|
+
next.append(disclosure);panel.after(next);
|
|
141
|
+
}else{disclosure=next.querySelector('details');heading=disclosure.querySelector('summary')}
|
|
142
|
+
const body=next.querySelector('.execweave-delivery-body');
|
|
143
|
+
if(host!==body)lastRender='';host=body;redraw();
|
|
144
|
+
}
|
|
145
|
+
window.addEventListener('execweave:conversation-sync',()=>{queueMicrotask(redraw)});
|
|
146
|
+
window.addEventListener('pagehide',()=>{generation++;controller?.abort();controller=null;receipt=null;offline=null;if(picker)picker.value=''});
|
|
147
|
+
window.__execweaveDeliveryStatus={mount,accept,verifySelected};
|
|
148
|
+
})();
|
|
149
|
+
""".strip()
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def delivery_scripts() -> str:
|
|
153
|
+
return ('<script id="execweave-archive-verifier-script">' + ARCHIVE_VERIFIER_JS
|
|
154
|
+
+ '</script><script id="execweave-delivery-status-script">' + DELIVERY_STATUS_JS
|
|
155
|
+
+ '</script>')
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
_STARTUP_SEAM = "applyTheme(initialTheme());applyTransform();poll();"
|
|
5
|
+
|
|
6
|
+
EDGE_DECROSS_SCRIPT = r"""
|
|
7
|
+
(function(){
|
|
8
|
+
if(typeof execweaveRoute!=='function'||typeof execweaveGeometry==='undefined')return;
|
|
9
|
+
const baseRoute=execweaveRoute;
|
|
10
|
+
const relation=edge=>String(edge?.relation||'').toUpperCase();
|
|
11
|
+
const nodeType=id=>String(typeof nodeById!=='undefined'?nodeById.get(id)?.type||'':'').toLowerCase();
|
|
12
|
+
const isNetworkEdge=edge=>relation(edge)==='CONNECTED_TO'||
|
|
13
|
+
nodeType(edge?.source)==='network_endpoint'||nodeType(edge?.target)==='network_endpoint';
|
|
14
|
+
const routePoints=edge=>{
|
|
15
|
+
const route=baseRoute(edge);
|
|
16
|
+
const points=route?.d?execweaveGeometry.polyline(route.d):null;
|
|
17
|
+
return{route,points};
|
|
18
|
+
};
|
|
19
|
+
const segments=points=>{
|
|
20
|
+
const result=[];
|
|
21
|
+
for(let i=1;i<(points?.length||0);i++)result.push({a:points[i-1],b:points[i]});
|
|
22
|
+
return result;
|
|
23
|
+
};
|
|
24
|
+
const crossesAny=(points,protectedSegments)=>{
|
|
25
|
+
for(let i=1;i<(points?.length||0);i++)for(const segment of protectedSegments)
|
|
26
|
+
if(execweaveGeometry.crosses(points[i-1],points[i],segment.a,segment.b))return true;
|
|
27
|
+
return false;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
execweaveRoute=function(edge){
|
|
31
|
+
const {route,points}=routePoints(edge);
|
|
32
|
+
if(!route||!points||points.length<2||isNetworkEdge(edge)||route.kind==='bundle'||route.kind==='lifecycle-return')return route;
|
|
33
|
+
if(typeof edgeById==='undefined'||typeof positions==='undefined'||!execweaveTopology)return route;
|
|
34
|
+
|
|
35
|
+
const protectedSegments=[];
|
|
36
|
+
for(const peer of edgeById.values()){
|
|
37
|
+
if(edgeId(peer)===edgeId(edge)||!isNetworkEdge(peer))continue;
|
|
38
|
+
const peerPoints=routePoints(peer).points;
|
|
39
|
+
if(peerPoints?.length>=2)protectedSegments.push(...segments(peerPoints));
|
|
40
|
+
}
|
|
41
|
+
if(!protectedSegments.length||!crossesAny(points,protectedSegments))return route;
|
|
42
|
+
|
|
43
|
+
const boxes=[...positions]
|
|
44
|
+
.filter(([id])=>id!==edge.source&&id!==edge.target&&nodeById.has(id))
|
|
45
|
+
.map(([id,p])=>({
|
|
46
|
+
id,x:p.x,y:p.y,
|
|
47
|
+
w:execweaveTopology.width?.get(id)||execweaveWidthOf(id),
|
|
48
|
+
h:execweaveTopology.height?.get(id)||execweaveHeightOf(id),
|
|
49
|
+
}));
|
|
50
|
+
const detour=execweaveGeometry.avoidCrossings(points,boxes,protectedSegments,8);
|
|
51
|
+
if(!detour||detour.crossingsAvoided<=0||detour.points.length<2)return route;
|
|
52
|
+
const d=detour.points.map((point,index)=>`${index?'L':'M'} ${point.x} ${point.y}`).join(' ');
|
|
53
|
+
const label=detour.points[Math.floor(detour.points.length/2)];
|
|
54
|
+
return{
|
|
55
|
+
...route,d,labelX:label.x,labelY:label.y-8,
|
|
56
|
+
geometryKind:'edge-decrossover',
|
|
57
|
+
edgeCrossingDetours:detour.detours,
|
|
58
|
+
protectedNetworkCrossingsAvoided:detour.crossingsAvoided,
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
if(typeof updateEdgeElement==='function'){
|
|
63
|
+
const updateBase=updateEdgeElement;
|
|
64
|
+
updateEdgeElement=function(edge){
|
|
65
|
+
// The existing projection wrapper already computes label placement and then clears
|
|
66
|
+
// it from rendered node boxes. Do not overwrite that cleared label position.
|
|
67
|
+
updateBase(edge);
|
|
68
|
+
const route=execweaveRoute(edge);
|
|
69
|
+
if(route?.geometryKind!=='edge-decrossover'||!route.d)return;
|
|
70
|
+
const els=edgeElements.get(edgeId(edge));if(!els)return;
|
|
71
|
+
// The base renderer normally sees the dynamically replaced execweaveRoute.
|
|
72
|
+
// Reapply only the path as a final authority guard; leave the label untouched.
|
|
73
|
+
els.visible.setAttribute('d',route.d);els.hit.setAttribute('d',route.d);
|
|
74
|
+
els.visible.dataset.geometryKind=route.geometryKind;
|
|
75
|
+
els.hit.dataset.geometryKind=route.geometryKind;
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const renderedMetrics=()=>{
|
|
80
|
+
if(typeof positions==='undefined'||typeof edgeById==='undefined'||typeof nodeById==='undefined')return null;
|
|
81
|
+
const nodes=[...positions]
|
|
82
|
+
.filter(([id])=>nodeById.has(id))
|
|
83
|
+
.map(([id,p])=>({
|
|
84
|
+
id,x:p.x,y:p.y,
|
|
85
|
+
w:execweaveTopology?.width?.get(id)||execweaveWidthOf(id),
|
|
86
|
+
h:execweaveTopology?.height?.get(id)||execweaveHeightOf(id),
|
|
87
|
+
}));
|
|
88
|
+
const edges=[...edgeById.values()]
|
|
89
|
+
.filter(edge=>positions.has(edge.source)&&positions.has(edge.target))
|
|
90
|
+
.map(edge=>({...edge,d:execweaveRoute(edge).d}));
|
|
91
|
+
return execweaveGeometry.measure(nodes,edges);
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
// The projection optimizer deliberately keeps its own pre-decrossover route family, but
|
|
95
|
+
// public metrics are a rendered-SVG diagnostic contract. Report the final paths
|
|
96
|
+
// users actually see so metric parity cannot drift after this local routing pass.
|
|
97
|
+
if(window.__execweaveLayout&&typeof window.__execweaveLayout.metrics==='function'){
|
|
98
|
+
const metricsBase=window.__execweaveLayout.metrics.bind(window.__execweaveLayout);
|
|
99
|
+
window.__execweaveLayout.metrics=()=>renderedMetrics()||metricsBase();
|
|
100
|
+
window.__execweaveLayout.crossingCount=()=>window.__execweaveLayout.metrics().EDGE_CROSSINGS;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
window.__execweaveEdgeDecross={
|
|
104
|
+
version:2,
|
|
105
|
+
routeFor:id=>{const edge=typeof edgeById!=='undefined'?edgeById.get(id):null;return edge?execweaveRoute(edge):null},
|
|
106
|
+
metrics:renderedMetrics,
|
|
107
|
+
};
|
|
108
|
+
})();
|
|
109
|
+
""".strip()
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def inject_edge_decross(html: str) -> str:
|
|
113
|
+
"""Prefer local route detours over moving nodes across network evidence edges."""
|
|
114
|
+
|
|
115
|
+
if html.count(_STARTUP_SEAM) != 1:
|
|
116
|
+
raise RuntimeError("edge-decrossover startup seam changed")
|
|
117
|
+
return html.replace(_STARTUP_SEAM, EDGE_DECROSS_SCRIPT + "\n" + _STARTUP_SEAM, 1)
|