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,241 @@
|
|
|
1
|
+
"""Explicit local external-test-report review; never replaces task truth."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
TASK_REPORT_JS = r"""
|
|
5
|
+
(()=>{
|
|
6
|
+
'use strict';if(window.__execweaveTaskReports)return;
|
|
7
|
+
const LIMIT=2*1024*1024,MAX_FILE=8*1024*1024;
|
|
8
|
+
const make=(tag,text)=>{const n=document.createElement(tag);if(text!==undefined)n.textContent=String(text);return n};
|
|
9
|
+
const button=(text,fn)=>{const n=make('button',text);n.type='button';n.onclick=fn;return n};
|
|
10
|
+
const list=v=>Array.isArray(v)?v:[],obj=v=>v&&typeof v==='object'&&!Array.isArray(v);
|
|
11
|
+
const text=(v,max)=>typeof v==='string'&&v.trim().length>0&&Array.from(v).length<=max;
|
|
12
|
+
const graph=()=>window.__execweaveCore?.getGraph?.()||window.__execweaveStaticGraph||{};
|
|
13
|
+
const scope=()=>{const g=graph();return [g.session_id??null,g.run_id??null,g.source_path??null]};
|
|
14
|
+
const key=()=>JSON.stringify(scope());
|
|
15
|
+
let lastKey=key(),assessment=null,dialog=null,status,body,picker,invoker=null,generation=0;
|
|
16
|
+
const reports=new Map();let section=null;
|
|
17
|
+
function fail(message){throw new Error(message)}
|
|
18
|
+
function inspectXML(xml){
|
|
19
|
+
if(typeof xml!=='string'||new TextEncoder().encode(xml).length>LIMIT)fail('Report exceeds 2 MiB.');
|
|
20
|
+
if(/<!\s*(?:DOCTYPE|ENTITY)\b/i.test(xml)||xml.includes('\0'))fail('DTD/entities are not supported.');
|
|
21
|
+
const enc=/<\?xml[^>]*\bencoding\s*=\s*['"]([^'"]+)/i.exec(xml);
|
|
22
|
+
if(enc&&!['utf-8','utf8'].includes(enc[1].toLowerCase()))fail('Only UTF-8 reports are supported.');
|
|
23
|
+
const documentXML=new DOMParser().parseFromString(xml,'application/xml');
|
|
24
|
+
if(documentXML.querySelector('parsererror'))fail('Malformed XML report.');
|
|
25
|
+
const root=documentXML.documentElement;if(!['testsuite','testsuites'].includes(root.tagName))fail('Expected testsuite/testsuites.');
|
|
26
|
+
const empty=()=>({tests:0,passed:0,failures:0,errors:0,skipped:0});
|
|
27
|
+
const seen=new Set(),cases=[];let elements=0;
|
|
28
|
+
function visit(e,depth,parent){
|
|
29
|
+
if(++elements>50000||depth>32)fail('XML structure exceeds inspection budget.');
|
|
30
|
+
const tag=e.tagName,c=empty(),children=[...e.children];
|
|
31
|
+
if(e.namespaceURI||tag.includes(':'))fail('Namespaced XML is not supported.');
|
|
32
|
+
if(tag==='testcase'){
|
|
33
|
+
if(parent!=='testsuite'||!text(e.getAttribute('name'),4096))fail('Invalid testcase identity.');
|
|
34
|
+
const name=e.getAttribute('name'),cls=e.getAttribute('classname')||'',id=JSON.stringify([cls,name]);
|
|
35
|
+
if(Array.from(cls).length>4096||seen.has(id))fail('Duplicate or oversized testcase identity.');
|
|
36
|
+
seen.add(id);if(seen.size>10000)fail('Too many testcases.');
|
|
37
|
+
const outcomes=children.filter(x=>['failure','error','skipped'].includes(x.tagName));
|
|
38
|
+
if(outcomes.length>1)fail('Multiple testcase outcomes are ambiguous.');
|
|
39
|
+
for(const child of children){if(!['failure','error','skipped','system-out','system-err','properties'].includes(child.tagName))fail('Unsupported testcase child.');visit(child,depth+1,tag)}
|
|
40
|
+
if(![null,'run'].includes(e.getAttribute('status'))||e.hasAttribute('result'))fail('Unsupported testcase status/result attribute.');
|
|
41
|
+
const state={failure:'failures',error:'errors',skipped:'skipped'}[outcomes[0]?.tagName]||'passed';c.tests=1;c[state]=1;cases.push({name,classname:cls,outcome:state});
|
|
42
|
+
}else if(['testsuite','testsuites'].includes(tag)){
|
|
43
|
+
if(![null,'testsuite','testsuites'].includes(parent)||(tag==='testsuites'&&parent))fail('Unsupported suite nesting.');
|
|
44
|
+
const allowed=['testsuite','properties','system-out','system-err'];if(tag==='testsuite')allowed.push('testcase');
|
|
45
|
+
for(const child of children){if(!allowed.includes(child.tagName))fail('Unsupported suite child.');const sub=visit(child,depth+1,tag);for(const k of Object.keys(c))c[k]+=sub[k]}
|
|
46
|
+
for(const k of ['tests','failures','errors','skipped'])if(e.hasAttribute(k)){const v=e.getAttribute(k);if(!/^[0-9]{1,9}$/.test(v)||Number(v)!==c[k])fail('Suite counter disagrees with case records.')}
|
|
47
|
+
}else if(tag==='properties'){
|
|
48
|
+
if(!['testsuite','testsuites','testcase'].includes(parent))fail('Unsupported properties location.');
|
|
49
|
+
for(const child of children){if(child.tagName!=='property')fail('Unsupported property child.');visit(child,depth+1,tag)}
|
|
50
|
+
}else if(!['failure','error','skipped','system-out','system-err','property'].includes(tag)||children.length)fail('Unsupported XML element.');
|
|
51
|
+
return c;
|
|
52
|
+
}
|
|
53
|
+
const counts=visit(root,0,null),state=counts.failures||counts.errors?'checks_failed':!counts.passed?'no_executed_checks':counts.skipped?'partial':'checks_passed';
|
|
54
|
+
return {state,counts,cases,task_success_implied:false,authority_authenticated:false};
|
|
55
|
+
}
|
|
56
|
+
function currentAssessment(){
|
|
57
|
+
const g=graph();const a=assessment||g.run_assessment||window.__execweaveStaticRunAssessment;
|
|
58
|
+
return a?.schema_version==='0.1'&&a.scope==='published_graph_metadata'&&a.session_id===g.session_id&&
|
|
59
|
+
(a.run_id??null)===(g.run_id??null)&&(a.source_path??null)===(g.source_path??null)?a:null;
|
|
60
|
+
}
|
|
61
|
+
function targetMatches(r){
|
|
62
|
+
const a=currentAssessment(),g=graph();
|
|
63
|
+
if(!text(g.session_id,4096)||g.live_payload_compact||a?.inspection?.state!=='declared_graph')return false;
|
|
64
|
+
if(JSON.stringify([r?.scope?.session_id,r?.scope?.run_id??null,r?.scope?.source_path??null])!==key())return false;
|
|
65
|
+
const subjects=list(a?.task_validation?.external_report_subjects),match=subjects.filter(s=>s?.task_id===r?.subject?.task_id);
|
|
66
|
+
return match.length===1&&match[0].task_snapshot_sha256===r?.subject?.task_snapshot_sha256;
|
|
67
|
+
}
|
|
68
|
+
// Artifact names are lookup keys in an explicitly selected FileList, not paths
|
|
69
|
+
// the browser or server may fetch. The report never chooses a local directory.
|
|
70
|
+
const ARTIFACT_FORMAT='execweave.selected-artifact-versions.v1',ARTIFACT_FILE=8*1024*1024,ARTIFACT_TOTAL=64*1024*1024;
|
|
71
|
+
function artifactPath(v){
|
|
72
|
+
if(!text(v,512)||v.normalize('NFC')!==v||/[\\:*?"<>|\x00-\x1f\x7f]/.test(v)||
|
|
73
|
+
Array.from(v).some(c=>{const n=c.codePointAt(0);return n>=0xd800&&n<=0xdfff})||
|
|
74
|
+
v.split('/').some(p=>!p||p==='.'||p==='..'||/[ .]$/.test(p)||/^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])(?:\.|$)/i.test(p)))fail('Invalid artifact relative name.');
|
|
75
|
+
return v;
|
|
76
|
+
}
|
|
77
|
+
async function artifactManifest(value){
|
|
78
|
+
if(!obj(value)||value.format!==ARTIFACT_FORMAT||!Array.isArray(value.entries)||!value.entries.length||value.entries.length>100)fail('Unsupported artifact inventory.');
|
|
79
|
+
const seen=new Set(),entries=[];let total=0;
|
|
80
|
+
for(const item of value.entries){
|
|
81
|
+
if(!obj(item))fail('Invalid artifact entry.');const path=artifactPath(item.path),folded=path.toLowerCase();
|
|
82
|
+
if(seen.has(folded))fail('Duplicate or case-colliding artifact name.');seen.add(folded);
|
|
83
|
+
if(!Number.isSafeInteger(item.size_bytes)||item.size_bytes<0||item.size_bytes>ARTIFACT_FILE||(typeof item.sha256!=='string'||item.sha256.length!==64||!/^[a-f0-9]{64}$/.test(item.sha256)))fail('Invalid artifact size or digest.');
|
|
84
|
+
total+=item.size_bytes;if(total>ARTIFACT_TOTAL)fail('Artifact inventory exceeds 64 MiB.');
|
|
85
|
+
entries.push({path,size_bytes:item.size_bytes,sha256:item.sha256});
|
|
86
|
+
}
|
|
87
|
+
const encoded=new TextEncoder().encode(JSON.stringify(entries.map(e=>[e.path,e.size_bytes,e.sha256])));
|
|
88
|
+
const digest=await artifactDigest(encoded);
|
|
89
|
+
if(digest!==value.manifest_sha256)fail('Artifact manifest hash mismatch.');
|
|
90
|
+
return {format:ARTIFACT_FORMAT,entries,manifest_sha256:digest};
|
|
91
|
+
}
|
|
92
|
+
async function artifactDigest(bytes){
|
|
93
|
+
if(!globalThis.crypto?.subtle)fail('Native SHA-256 unavailable; artifact bytes not checked.');
|
|
94
|
+
return Array.from(new Uint8Array(await crypto.subtle.digest('SHA-256',bytes)),v=>v.toString(16).padStart(2,'0')).join('');
|
|
95
|
+
}
|
|
96
|
+
async function compareArtifacts(r,id,files){
|
|
97
|
+
const token=++generation,started=key();
|
|
98
|
+
const valid=()=>token===generation&&started===key()&&dialog?.open&&reports.get(id)===r&&targetMatches(r);
|
|
99
|
+
r.artifact_check={state:'checking',message:'Comparing only the explicitly associated files…',rows:[]};draw();
|
|
100
|
+
try{
|
|
101
|
+
if(!files.length||files.length>10000)fail('Select a nonempty folder with at most 10,000 files.');
|
|
102
|
+
const byPath=new Map(),folded=new Set();let root=null;
|
|
103
|
+
for(const file of files){
|
|
104
|
+
if(typeof file.webkitRelativePath!=='string'||!file.webkitRelativePath.includes('/'))fail('Directory-relative file identity is unavailable.');
|
|
105
|
+
const parts=file.webkitRelativePath.split('/'),folder=parts.shift();
|
|
106
|
+
if(!folder||(root!==null&&root!==folder))fail('Select exactly one folder.');root=folder;
|
|
107
|
+
const path=artifactPath(parts.join('/')),identity=path.toLowerCase();
|
|
108
|
+
if(folded.has(identity))fail('Duplicate or case-colliding selected path.');folded.add(identity);byPath.set(path,file);
|
|
109
|
+
}
|
|
110
|
+
const rows=[];let matched=0,bytesMatched=0;
|
|
111
|
+
for(const item of r.artifacts.entries){
|
|
112
|
+
if(!valid())return;
|
|
113
|
+
const file=byPath.get(item.path);let state;
|
|
114
|
+
if(!file)state='missing';
|
|
115
|
+
else if(file.size!==item.size_bytes)state='size_mismatch';
|
|
116
|
+
else{
|
|
117
|
+
const bytes=await file.arrayBuffer();if(!valid())return;
|
|
118
|
+
if(bytes.byteLength!==item.size_bytes||bytes.byteLength>ARTIFACT_FILE)fail('Selected artifact changed or exceeded its limit.');
|
|
119
|
+
const hash=await artifactDigest(bytes);if(!valid())return;
|
|
120
|
+
state=hash===item.sha256?'match':'hash_mismatch';
|
|
121
|
+
}
|
|
122
|
+
if(state==='match'){matched++;bytesMatched+=item.size_bytes}
|
|
123
|
+
rows.push({path:item.path,state});
|
|
124
|
+
}
|
|
125
|
+
if(!valid())return;
|
|
126
|
+
r.artifact_check={state:matched===rows.length?'match':'mismatch',rows,
|
|
127
|
+
message:`Last selected-file comparison: ${matched}/${rows.length} match; ${bytesMatched} matching bytes. ${files.length-rows.filter(x=>x.state!=='missing').length} other selected files were not read. This does not prove these files were tested.`};
|
|
128
|
+
draw();
|
|
129
|
+
}catch(e){if(valid()){r.artifact_check={state:'unavailable',message:'Artifact comparison not completed: '+e.message,rows:[]};draw()}}
|
|
130
|
+
}
|
|
131
|
+
function appendArtifacts(card,r,id){
|
|
132
|
+
const box=make('section');box.className='execweave-task-artifacts';
|
|
133
|
+
box.append(make('h4','Associated artifact versions'));
|
|
134
|
+
if(!r.artifacts){box.dataset.state='not_supplied';box.append(make('p','No artifact versions supplied. A task snapshot does not identify the files tested.'));card.append(box);return}
|
|
135
|
+
const result=r.artifact_check||{state:'not_checked',rows:[],message:'Artifact bytes have not been compared in this tab.'};box.dataset.state=result.state;
|
|
136
|
+
box.append(make('p','Operator-associated file versions, not proof of test execution on these files.'),make('p','Manifest SHA-256: '+r.artifacts.manifest_sha256));
|
|
137
|
+
const input=make('input');input.type='file';input.multiple=true;input.setAttribute('webkitdirectory','');input.className='execweave-task-artifact-folder';input.setAttribute('aria-label','Select folder to compare associated artifacts');
|
|
138
|
+
input.onchange=()=>{const files=Array.from(input.files||[]);void compareArtifacts(r,id,files)};
|
|
139
|
+
const message=make('p',result.message);message.className='artifact-comparison-status';message.setAttribute('role','status');box.append(input,message);
|
|
140
|
+
const details=make('details');details.append(make('summary',`${r.artifacts.entries.length} associated file version(s)`));
|
|
141
|
+
for(const entry of r.artifacts.entries)details.append(make('p',`${entry.path} · ${entry.size_bytes} bytes · ${entry.sha256}`));
|
|
142
|
+
box.append(details);for(const row of result.rows)box.append(make('p',row.path+' · '+row.state));
|
|
143
|
+
box.append(make('p','Only the listed files are compared. Extra files, permissions, dependencies and the entire delivered directory are not certified. Results are past comparisons and do not continuously monitor changes.'));
|
|
144
|
+
card.append(box);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
async function validate(r){
|
|
148
|
+
if(!obj(r)||!['execweave.external-task-report.v1','execweave.external-task-report.v2'].includes(r.format)||r.authority!=='operator_supplied_not_authenticated'||
|
|
149
|
+
!text(r.validator,256)||!text(r.criterion,2048)||!text(r.subject?.task_id,4096)||
|
|
150
|
+
!/^[a-f0-9]{64}$/.test(r.subject?.task_snapshot_sha256||'')||!targetMatches(r))fail('Unsupported report or task/run snapshot mismatch.');
|
|
151
|
+
const summary=inspectXML(r.report?.xml);
|
|
152
|
+
if(r.report?.media_type!=='application/xml; charset=utf-8'||!/^[a-f0-9]{64}$/.test(r.report.sha256||''))fail('Invalid report fingerprint.');
|
|
153
|
+
if(!globalThis.crypto?.subtle)fail('Native SHA-256 unavailable; no report accepted.');
|
|
154
|
+
const digest=Array.from(new Uint8Array(await crypto.subtle.digest('SHA-256',new TextEncoder().encode(r.report.xml))),b=>b.toString(16).padStart(2,'0')).join('');
|
|
155
|
+
if(digest!==r.report.sha256)fail('Report hash mismatch.');
|
|
156
|
+
if(r.format==='execweave.external-task-report.v1'&&r.artifacts!==undefined)fail('Artifact binding requires a v2 receipt.');
|
|
157
|
+
const artifacts=r.format==='execweave.external-task-report.v2'?await artifactManifest(r.artifacts):null;
|
|
158
|
+
// Claimed summaries are not evidence. Recount the original XML in this browser.
|
|
159
|
+
return {scope:{...r.scope},subject:{...r.subject},validator:r.validator,criterion:r.criterion,report_hash:digest,summary,artifacts};
|
|
160
|
+
}
|
|
161
|
+
function clear(){generation++;reports.clear();dialog?.close();body?.replaceChildren();if(picker)picker.value=''}
|
|
162
|
+
function reconcile(){
|
|
163
|
+
if(lastKey!==key()){clear();assessment=null;lastKey=key()}
|
|
164
|
+
for(const [id,r] of reports)if(!targetMatches(r))reports.delete(id);
|
|
165
|
+
}
|
|
166
|
+
function close(){generation++;for(const r of reports.values())if(r.artifact_check?.state==='checking')r.artifact_check={state:'cancelled',message:'Comparison cancelled; no complete version-match result.',rows:[]};dialog?.close();body?.replaceChildren();if(picker)picker.value='';(invoker?.isConnected?invoker:section?.querySelector('button'))?.focus()}
|
|
167
|
+
function draw(){
|
|
168
|
+
if(!dialog?.open)return;reconcile();body.replaceChildren();
|
|
169
|
+
for(const [id,r] of reports){
|
|
170
|
+
const card=make('article');card.className='execweave-task-report';card.dataset.state=r.summary.state;
|
|
171
|
+
const labels={checks_passed:'Report: checks passed',checks_failed:'Report: checks failed',partial:'Report: incomplete coverage',no_executed_checks:'Report: no executed passing checks'};
|
|
172
|
+
card.append(make('h3',labels[r.summary.state]),make('p','Task: '+r.subject.task_id),make('p','Operator-named verifier: '+r.validator),make('p','Operator-stated criterion: '+r.criterion));
|
|
173
|
+
const c=r.summary.counts;card.append(make('p',`${c.tests} case records: ${c.passed} passed, ${c.failures} failures, ${c.errors} errors, ${c.skipped} skipped.`),make('p','Report SHA-256: '+r.report_hash));
|
|
174
|
+
card.append(make('p','Report bytes verified and cases recounted. The report author, tested artifact version, execution and adequacy of these checks are not authenticated. This is not proof that the whole task succeeded.'));
|
|
175
|
+
appendArtifacts(card,r,id);
|
|
176
|
+
const details=make('details');details.append(make('summary','Case details (first 50)'));
|
|
177
|
+
for(const item of r.summary.cases.slice(0,50))details.append(make('p',[item.outcome,item.classname,item.name].join(' · ')));
|
|
178
|
+
if(r.summary.cases.length>50)details.append(make('p','Detail preview limited to 50; all supported cases were counted.'));
|
|
179
|
+
card.append(details);body.append(card);
|
|
180
|
+
}
|
|
181
|
+
if(!reports.size)body.append(make('p','No external report accepted for this exact run/task snapshot. Agent completion text and exit code 0 are not test evidence.'));
|
|
182
|
+
}
|
|
183
|
+
function ensure(){
|
|
184
|
+
if(dialog)return;dialog=make('dialog');dialog.id='execweave-task-reports-dialog';dialog.setAttribute('aria-labelledby','execweave-task-reports-title');
|
|
185
|
+
const header=make('header'),title=make('h2','External task check reports');title.id='execweave-task-reports-title';header.append(title,button('Close task reports',close));
|
|
186
|
+
const intro=make('p','Explicit operator import only. Create a receipt with python -m execweave.task_validation --help. Selecting it does not run commands, upload files, modify the original archive or authenticate an independent verifier. Report text stays in this tab and may contain sensitive test names.');
|
|
187
|
+
picker=make('input');picker.type='file';picker.accept='.json';picker.id='execweave-task-report-file';picker.setAttribute('aria-label','Select external task report receipt');
|
|
188
|
+
status=make('p');status.id='execweave-task-report-status';status.setAttribute('role','status');
|
|
189
|
+
body=make('div');body.id='execweave-task-report-results';
|
|
190
|
+
picker.onchange=async()=>{
|
|
191
|
+
reconcile();const file=picker.files?.[0],token=++generation,started=key();if(!file)return;
|
|
192
|
+
status.textContent='Checking report bytes, cases and task binding…';
|
|
193
|
+
try{
|
|
194
|
+
if(file.size>MAX_FILE)fail('Receipt exceeds 8 MiB.');
|
|
195
|
+
if(!window.__execweaveArchiveVerifier?.strictJSON)fail('Strict JSON reader unavailable.');
|
|
196
|
+
const bytes=await file.arrayBuffer();if(bytes.byteLength>MAX_FILE)fail('Receipt exceeds 8 MiB.');
|
|
197
|
+
const value=window.__execweaveArchiveVerifier.strictJSON(new TextDecoder('utf-8',{fatal:true}).decode(bytes));
|
|
198
|
+
const accepted=await validate(value);
|
|
199
|
+
if(token!==generation||started!==key()||!dialog.open)return;
|
|
200
|
+
if(!targetMatches(accepted))fail('Task changed during report verification.');
|
|
201
|
+
const id=JSON.stringify([accepted.subject,accepted.report_hash,accepted.validator,accepted.criterion,accepted.artifacts?.manifest_sha256??null]);
|
|
202
|
+
if(!reports.has(id)&&reports.size>=20)fail('20-report limit reached; clear imported reports first.');
|
|
203
|
+
reports.set(id,accepted);status.textContent='Report accepted as operator-supplied evidence; task success is not inferred.';draw();mount();
|
|
204
|
+
}catch(e){if(token===generation&&started===key()&&dialog.open)status.textContent='Report not accepted: '+e.message}
|
|
205
|
+
};
|
|
206
|
+
dialog.append(header,intro,picker,button('Clear imported reports',()=>{clear();mount();invoker?.focus()}),status,body);
|
|
207
|
+
dialog.addEventListener('keydown',e=>{if(e.key==='Escape')e.stopPropagation()});dialog.addEventListener('cancel',e=>{e.preventDefault();close()});document.body.append(dialog);
|
|
208
|
+
}
|
|
209
|
+
function open(){reconcile();ensure();invoker=document.activeElement;status.textContent='Reports are separate from native task completion claims.';dialog.showModal();draw()}
|
|
210
|
+
function mount(){
|
|
211
|
+
reconcile();const host=document.querySelector('#execweave-run-assessment [data-axis="task"]');if(!host)return;
|
|
212
|
+
if(!section?.isConnected||section.parentElement!==host){section?.remove();section=make('div');section.id='execweave-task-report-entry';section.append(button('Review external task reports',open),make('p'));host.append(section)}
|
|
213
|
+
section.querySelector('p').textContent=reports.size?`${reports.size} operator-supplied report(s) loaded; no automatic task-success verdict.`:'No authenticated independent task result is available.';
|
|
214
|
+
}
|
|
215
|
+
const prior=window.__execweaveDashboard||{};
|
|
216
|
+
function changed(packet){reconcile();const a=packet?.run_assessment||packet?.graph?.run_assessment;if(a)assessment=a;reconcile();mount();if(dialog?.open)draw()}
|
|
217
|
+
window.__execweaveDashboard={...prior,onPayload(...args){prior.onPayload?.(...args);changed(args[0])},onFinished(...args){prior.onFinished?.(...args);changed()}};
|
|
218
|
+
window.addEventListener('pagehide',()=>{clear();assessment=null});
|
|
219
|
+
window.__execweaveTaskReports={inspectXML,open,close};mount();
|
|
220
|
+
})();
|
|
221
|
+
""".strip()
|
|
222
|
+
|
|
223
|
+
TASK_REPORT_CSS = """
|
|
224
|
+
#execweave-task-report-entry button{font:inherit;padding:6px;cursor:pointer}
|
|
225
|
+
#execweave-task-reports-dialog{width:min(920px,92vw);max-height:88vh;box-sizing:border-box;background:var(--panel,#fff);color:var(--text,#111);border:1px solid var(--border,#888);border-radius:10px;padding:16px}
|
|
226
|
+
#execweave-task-reports-dialog::backdrop{background:rgba(0,0,0,.45)}
|
|
227
|
+
#execweave-task-reports-dialog header{display:flex;align-items:center;gap:10px}#execweave-task-reports-title{flex:1;font-size:20px}
|
|
228
|
+
#execweave-task-reports-dialog button,#execweave-task-reports-dialog input{font:inherit;padding:7px}
|
|
229
|
+
#execweave-task-reports-dialog p{font-size:14px;line-height:1.5;overflow-wrap:anywhere}
|
|
230
|
+
#execweave-task-report-results{overflow:auto;max-height:52vh}.execweave-task-report{border:1px solid var(--border,#888);padding:12px;margin-top:10px;border-radius:8px}
|
|
231
|
+
""".strip()
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
def inject_task_reports(html: str) -> str:
|
|
235
|
+
if 'id="execweave-task-reports-script"' in html:
|
|
236
|
+
return html
|
|
237
|
+
if "</body>" not in html:
|
|
238
|
+
raise RuntimeError("task reports require the shared Dashboard body")
|
|
239
|
+
return html.replace("</body>", "<style>" + TASK_REPORT_CSS
|
|
240
|
+
+ '</style><script id="execweave-task-reports-script">' + TASK_REPORT_JS
|
|
241
|
+
+ "</script></body>", 1)
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"""Exact invocation witnesses for an otherwise unlinked tool observation.
|
|
2
|
+
|
|
3
|
+
A mirrored provider observation is not a second invocation. It may corroborate a
|
|
4
|
+
proved call only through an explicit scoped native ID or conversation/step/tool
|
|
5
|
+
identity. An ambiguous or dangling ownership path is never overridden.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
TOOL_MIRROR_SCRIPT = r"""
|
|
9
|
+
function mirrorIdentity(node){
|
|
10
|
+
const identity=scope(node),a=node?.attributes||{};
|
|
11
|
+
if(!identity||!identity.provider)return null;
|
|
12
|
+
const values=keys=>sorted(keys.map(k=>text(a[k])).filter(Boolean));
|
|
13
|
+
const native=values(['tool_use_id','tool_call_id','call_id','provider_call_id','invocation_id']);
|
|
14
|
+
const rawSteps=values(['step_index','antigravity_step_index','stepIdx']);
|
|
15
|
+
if(native.length>1||rawSteps.some(v=>!/^\d+$/.test(v)))return null;
|
|
16
|
+
const steps=sorted(rawSteps.map(v=>String(Number(v))));
|
|
17
|
+
if(steps.length>1||steps.some(v=>!Number.isSafeInteger(Number(v))))return null;
|
|
18
|
+
const toolNames=values(['tool_name','native_name']).map(v=>v.toLowerCase());
|
|
19
|
+
if(new Set(toolNames).size>1)return null;
|
|
20
|
+
const tool=toolNames[0]||text(node?.name).toLowerCase();
|
|
21
|
+
return{identity,native:native[0]||'',step:steps[0]??null,tool};
|
|
22
|
+
}
|
|
23
|
+
function mirrorWitness(observation,anchor){
|
|
24
|
+
const a=mirrorIdentity(observation),b=mirrorIdentity(anchor);
|
|
25
|
+
if(!a||!b||a.identity.provider!==b.identity.provider)return null;
|
|
26
|
+
const identity=joinScope(a.identity,b.identity);if(!identity)return null;
|
|
27
|
+
if(!a.tool||a.tool!==b.tool)return null;
|
|
28
|
+
if(a.native&&b.native&&a.native!==b.native)return null;
|
|
29
|
+
if(a.step!==null&&b.step!==null&&a.step!==b.step)return null;
|
|
30
|
+
const commonScope=['conversation','session','run'].some(k=>a.identity[k]&&a.identity[k]===b.identity[k]);
|
|
31
|
+
if(a.native&&a.native===b.native&&commonScope){
|
|
32
|
+
return{kind:'scoped-native-invocation',identity,native:a.native,tool:a.tool};
|
|
33
|
+
}
|
|
34
|
+
if(a.identity.conversation&&a.identity.conversation===b.identity.conversation&&a.step!==null&&a.step===b.step){
|
|
35
|
+
return{kind:'provider-conversation-step-tool',identity,step:a.step,tool:a.tool};
|
|
36
|
+
}
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
function proveToolOccurrence(ids,presented,visible,byId,incoming,rawEdges,aliases){
|
|
40
|
+
const proofs=[],anchors=[],pending=[];
|
|
41
|
+
if(!ids.length)return null;
|
|
42
|
+
for(const id of [...ids].sort()){
|
|
43
|
+
const call=byId.get(id);if(!call)return null;
|
|
44
|
+
const leaves=rawEdges.filter(edge=>edge.source===id&&aliases.get(edge.target)===presented.target);
|
|
45
|
+
const candidates=leaves.length?leaves:[{source:id,target:presented.target}];
|
|
46
|
+
let unresolved=false;
|
|
47
|
+
for(const leaf of candidates){
|
|
48
|
+
const proof=supportFor(leaf,visible,byId,incoming,!leaves.length);
|
|
49
|
+
if(!proof.reason&&proof.sources.length===1&&proof.sources[0]===presented.source){proofs.push(proof);continue;}
|
|
50
|
+
if(call.type==='tool_call_observation'&&proof.reason==='unattributed_observation'&&!(incoming.get(id)||[]).length){
|
|
51
|
+
unresolved=true;break;
|
|
52
|
+
}
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
if(unresolved)pending.push(call);else anchors.push(call);
|
|
56
|
+
}
|
|
57
|
+
if(!proofs.length)return null;
|
|
58
|
+
for(const observation of pending){
|
|
59
|
+
const matches=anchors.map(anchor=>({anchor,witness:mirrorWitness(observation,anchor)})).filter(v=>v.witness);
|
|
60
|
+
if(!matches.length)return null;
|
|
61
|
+
const {anchor,witness}=matches[0];
|
|
62
|
+
const related=rawEdges.filter(e=>e.source===observation.id||e.target===observation.id);
|
|
63
|
+
let identity=witness.identity;
|
|
64
|
+
for(const e of related){identity=joinScope(identity,scope(e));if(!identity)return null;}
|
|
65
|
+
// A contradictory explicit tool target is not a harmless mirror detail.
|
|
66
|
+
if(related.some(e=>e.source===observation.id&&byId.get(e.target)?.type==='tool'&&aliases.get(e.target)!==presented.target))return null;
|
|
67
|
+
const proofIdentity=joinScope(identity,proofs.find(p=>p.nodes.includes(anchor.id))?.identity);
|
|
68
|
+
if(!proofIdentity)return null;
|
|
69
|
+
proofs.push({sources:[presented.source],edges:related,nodes:sorted([observation.id,anchor.id,
|
|
70
|
+
presented.target,...related.flatMap(e=>[e.source,e.target])]),missingSources:[],identity:proofIdentity,reason:'',
|
|
71
|
+
mirror:{observation_id:observation.id,proved_call_id:anchor.id,...witness,viewer_only:true,inferred:true,causal:false}});
|
|
72
|
+
}
|
|
73
|
+
return proofs;
|
|
74
|
+
}
|
|
75
|
+
""".strip()
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"""A reversible workflow-first projection over the existing display graph.
|
|
2
|
+
|
|
3
|
+
The raw graph, identity policy, layout solver and source evidence are unchanged.
|
|
4
|
+
Only visible membership is narrowed; no path is contracted into a new edge.
|
|
5
|
+
"""
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
WORKFLOW_JS = r"""
|
|
9
|
+
// Installed inside the core closure after the existing projection wrappers.
|
|
10
|
+
const workflowTypes=new Set(['agent','session','task','agent_task','subtask','message','artifact','model','tool']);
|
|
11
|
+
let workflowChoice='auto',workflowScope=null,workflowInventory=null;
|
|
12
|
+
const workflowBaseProjection=execweaveDashboardGraph;
|
|
13
|
+
const workflowToolbar=document.createElement('div');workflowToolbar.id='execweave-workflow-controls';
|
|
14
|
+
workflowToolbar.setAttribute('role','group');workflowToolbar.setAttribute('aria-label','Graph view');
|
|
15
|
+
const workflowSelect=document.createElement('select');workflowSelect.setAttribute('aria-label','Graph view');
|
|
16
|
+
for(const [value,label] of [['auto','Default (all evidence)'],['workflow','Workflow overview'],['all','All execution evidence']]){
|
|
17
|
+
const option=document.createElement('option');option.value=value;option.textContent=label;workflowSelect.append(option);
|
|
18
|
+
}
|
|
19
|
+
const workflowSummary=document.createElement('span');workflowSummary.id='execweave-workflow-summary';workflowSummary.setAttribute('role','status');
|
|
20
|
+
workflowToolbar.append(workflowSelect,workflowSummary);document.querySelector('#graph-panel .panel-bar')?.after(workflowToolbar);
|
|
21
|
+
function workflowFailed(node){
|
|
22
|
+
const a=node?.attributes||{};
|
|
23
|
+
return a.provider_reported_error===true||a.success===false||
|
|
24
|
+
['failed','error','interrupted','cancelled'].includes(a.status)||
|
|
25
|
+
(Number.isSafeInteger(a.return_code)&&a.return_code!==0)||
|
|
26
|
+
(typeof a.error==='string'&&a.error.length>0);
|
|
27
|
+
}
|
|
28
|
+
function workflowProject(data,display,choice,selected,selectedEdge){
|
|
29
|
+
const nodes=Array.isArray(display?.nodes)?display.nodes:[],edges=Array.isArray(display?.edges)?display.edges:[];
|
|
30
|
+
const seen=new Set();let ambiguous=false;
|
|
31
|
+
for(const node of nodes){if(!node||typeof node.id!=='string'||seen.has(node.id)){ambiguous=true;break}seen.add(node.id)}
|
|
32
|
+
const agentCount=nodes.filter(n=>n?.type==='agent').length;
|
|
33
|
+
// Keep the established display contract until workflow-first presentation
|
|
34
|
+
// can be enabled without hiding attribution gaps or runtime evidence.
|
|
35
|
+
// Workflow filtering remains an explicit, reversible reader choice.
|
|
36
|
+
const mode=choice==='auto'?'all':choice;
|
|
37
|
+
if(mode!=='workflow'||!agentCount||ambiguous||data?.live_payload_compact){
|
|
38
|
+
return {display,mode:'all',total:nodes.length,shown:nodes.length,hidden:0,ambiguous,agentCount};
|
|
39
|
+
}
|
|
40
|
+
const selectedEnds=new Set(edges.filter(e=>edgeId(e)===selectedEdge).flatMap(e=>[e.source,e.target]));
|
|
41
|
+
const snapshots=new Set((Array.isArray(data.edges)?data.edges:[])
|
|
42
|
+
.filter(e=>e?.relation==='OBSERVED_FILE_CONTENT_BEFORE_READ').map(e=>e.source));
|
|
43
|
+
const kept=nodes.filter(n=>workflowTypes.has(n.type)||n.attributes?.viewer_framework_messages||
|
|
44
|
+
n.attributes?.viewer_orchestration_action||n.attributes?.viewer_folded||snapshots.has(n.id)||workflowFailed(n)||n.id===selected||selectedEnds.has(n.id)||
|
|
45
|
+
(Array.isArray(n.attributes?.viewer_folded_members)&&n.attributes.viewer_folded_members.some(m=>workflowTypes.has(m?.type)||workflowFailed(m))));
|
|
46
|
+
const ids=new Set(kept.map(n=>n.id));
|
|
47
|
+
const shownEdges=edges.filter(e=>ids.has(e.source)&&ids.has(e.target));
|
|
48
|
+
return {display:{...display,nodes:kept,edges:shownEdges,node_count:kept.length,edge_count:shownEdges.length},
|
|
49
|
+
mode,agentCount,total:nodes.length,shown:kept.length,hidden:nodes.length-kept.length,ambiguous:false};
|
|
50
|
+
}
|
|
51
|
+
// Bundle rails in the filtered view follow actual visible rows, not stale
|
|
52
|
+
// full-graph preferred row numbers. Unchanged positions must keep the same rail.
|
|
53
|
+
function execweaveWorkflowRailOrder(id){
|
|
54
|
+
if(workflowInventory?.mode!=='workflow')return null;
|
|
55
|
+
const at=positions.get(id);if(!at)return null;
|
|
56
|
+
let order=0;
|
|
57
|
+
for(const [other,p] of positions)if(nodeById.has(other)&&Math.abs(p.x-at.x)<.5&&
|
|
58
|
+
(p.y<at.y||(p.y===at.y&&String(other).localeCompare(String(id))<0)))order++;
|
|
59
|
+
return order;
|
|
60
|
+
}
|
|
61
|
+
function workflowUpdate(){
|
|
62
|
+
workflowSelect.value=workflowChoice;workflowSelect.disabled=protectedMode;
|
|
63
|
+
const s=workflowInventory;
|
|
64
|
+
workflowSummary.textContent=protectedMode?'Large-graph protection is active. View switching cannot redraw a stale snapshot.':
|
|
65
|
+
!s?'Waiting for a published graph.':s.ambiguous?'Ambiguous display identities; the full evidence view is retained.':
|
|
66
|
+
`${s.mode==='workflow'?'Workflow':'All evidence'}: ${s.shown}/${s.total} displayable nodes. `+
|
|
67
|
+
(s.hidden?`${s.hidden} infrastructure/detail nodes are hidden, not deleted. Choose All execution evidence or Runtime evidence to inspect them.`:
|
|
68
|
+
'Existing file/folding limits still apply; raw evidence is unchanged.');
|
|
69
|
+
workflowToolbar.dataset.mode=s?.mode||'all';
|
|
70
|
+
}
|
|
71
|
+
execweaveDashboardGraph=function(data){
|
|
72
|
+
const key=JSON.stringify([data?.run_id??null,data?.session_id??null,data?.source_path??null]);
|
|
73
|
+
if(key!==workflowScope){workflowScope=key;workflowChoice='auto'}
|
|
74
|
+
const display=workflowBaseProjection(data);
|
|
75
|
+
workflowInventory=workflowProject(data,display,workflowChoice,selectedNodeId,selectedEdgeId);
|
|
76
|
+
workflowUpdate();return workflowInventory.display;
|
|
77
|
+
};
|
|
78
|
+
function workflowSetMode(mode){
|
|
79
|
+
if(!['auto','workflow','all'].includes(mode))return false;
|
|
80
|
+
if(protectedMode){workflowUpdate();return false}
|
|
81
|
+
workflowChoice=mode;
|
|
82
|
+
if(typeof execweaveFlowInvalidate==='function')execweaveFlowInvalidate();
|
|
83
|
+
setSnapshot(graph);restoreSelectionFocus();
|
|
84
|
+
// An explicit view change should settle the active Fit camera before the
|
|
85
|
+
// next interaction, not leave a delayed fit that appears to come from Arrange.
|
|
86
|
+
if(cameraMode==='fit'){clearTimeout(cameraTimer);cameraTimer=null;stopAnimation();fit(false)}
|
|
87
|
+
workflowUpdate();return true;
|
|
88
|
+
}
|
|
89
|
+
workflowSelect.addEventListener('change',()=>workflowSetMode(workflowSelect.value));
|
|
90
|
+
// A direct request for an exact hidden display node opens the full evidence
|
|
91
|
+
// view. No same-name, ancestry, or shared-resource identity substitution.
|
|
92
|
+
function workflowReveal(id){
|
|
93
|
+
if(typeof id!=='string'||protectedMode)return false;
|
|
94
|
+
if(nodeById.has(id))return true;
|
|
95
|
+
const matches=(workflowBaseProjection(graph).nodes||[]).filter(n=>n?.id===id);
|
|
96
|
+
if(matches.length!==1)return false;
|
|
97
|
+
return workflowSetMode('all')&&nodeById.has(id);
|
|
98
|
+
}
|
|
99
|
+
const workflowSelectNode=window.__execweaveCore.selectNode;
|
|
100
|
+
window.__execweaveCore.selectNode=(id,...args)=>{if(!nodeById.has(id))workflowReveal(id);return workflowSelectNode(id,...args)};
|
|
101
|
+
const workflowProtection=enterProtectiveMode;
|
|
102
|
+
enterProtectiveMode=function(data){workflowProtection(data);workflowUpdate()};
|
|
103
|
+
const workflowLeaveProtection=leaveProtectiveMode;
|
|
104
|
+
leaveProtectiveMode=function(){workflowLeaveProtection();workflowUpdate()};
|
|
105
|
+
window.__execweaveWorkflow={setMode:workflowSetMode,reveal:workflowReveal,project:workflowProject,
|
|
106
|
+
status:()=>workflowInventory?{mode:workflowInventory.mode,total:workflowInventory.total,shown:workflowInventory.shown,hidden:workflowInventory.hidden}:null};
|
|
107
|
+
""".strip()
|
|
108
|
+
|
|
109
|
+
WORKFLOW_CSS = """
|
|
110
|
+
#graph-panel{grid-template-rows:46px auto minmax(0,1fr)}
|
|
111
|
+
#execweave-explore-run,#execweave-runtime-launcher{font-size:12px;white-space:nowrap;line-height:1.4;padding:7px 9px;background:var(--panel2);color:var(--text);border:1px solid var(--border);border-radius:6px}
|
|
112
|
+
#execweave-health-dialog button,#execweave-health-dialog select,#execweave-share-dialog button{background:var(--panel2);color:var(--text);border:1px solid var(--border);border-radius:6px}
|
|
113
|
+
#execweave-health-dialog button:disabled,#execweave-share-dialog button:disabled{opacity:.5;cursor:not-allowed}
|
|
114
|
+
#execweave-workflow-controls button{font:inherit;font-size:12px;padding:6px 10px;cursor:pointer;background:var(--panel2);color:var(--text);border:1px solid var(--border);border-radius:6px}
|
|
115
|
+
#execweave-workflow-controls{display:flex;align-items:center;gap:10px;flex-wrap:wrap;padding:6px 12px;background:var(--panel);border-bottom:1px solid var(--border);flex-shrink:0}
|
|
116
|
+
#execweave-workflow-controls select{font:inherit;font-size:12px;background:var(--panel);color:var(--text);padding:5px;border:1px solid var(--border);border-radius:6px}
|
|
117
|
+
#execweave-workflow-summary{font-size:12px;line-height:1.4;flex:1;min-width:140px;color:var(--muted)}
|
|
118
|
+
""".strip()
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def inject_workflow_mode(html: str) -> str:
|
|
122
|
+
if 'id="execweave-workflow-style"' in html:
|
|
123
|
+
return html
|
|
124
|
+
startup = "applyTheme(initialTheme());applyTransform();poll();"
|
|
125
|
+
if html.count(startup) != 1 or "</head>" not in html:
|
|
126
|
+
raise RuntimeError("workflow startup seam changed")
|
|
127
|
+
return html.replace("</head>", '<style id="execweave-workflow-style">' + WORKFLOW_CSS + "</style></head>", 1).replace(startup, WORKFLOW_JS + "\n" + startup, 1)
|
execweave/workflow.py
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
from dataclasses import dataclass
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
from uuid import uuid4
|
|
7
|
+
|
|
8
|
+
from .backends import BackendName, create_collector, resolve_backend
|
|
9
|
+
from .fidelity import write_fidelity_report
|
|
10
|
+
from .graph import build_execution_graph, write_execution_graph
|
|
11
|
+
from .semantic import merge_semantic_sidecar
|
|
12
|
+
from .sink import JsonlSink
|
|
13
|
+
from .theme import ensure_viewer_theme
|
|
14
|
+
from .validate import validate_event_stream
|
|
15
|
+
from .viewer_projection import strip_internal_hook_execution_graph, write_graph_html
|
|
16
|
+
|
|
17
|
+
_SEMANTIC_ENV = "EXECWEAVE_SEMANTIC_SIDECAR"
|
|
18
|
+
_RUN_ID_ENV = "EXECWEAVE_RUN_ID"
|
|
19
|
+
_SESSION_ID_ENV = "EXECWEAVE_SESSION_ID"
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@dataclass(frozen=True)
|
|
23
|
+
class RecordResult:
|
|
24
|
+
session_id: str
|
|
25
|
+
backend: str
|
|
26
|
+
return_code: int
|
|
27
|
+
output_dir: Path
|
|
28
|
+
event_stream: Path
|
|
29
|
+
fidelity: Path
|
|
30
|
+
graph: Path
|
|
31
|
+
viewer: Path
|
|
32
|
+
event_count: int
|
|
33
|
+
node_count: int
|
|
34
|
+
edge_count: int
|
|
35
|
+
semantic_sidecar: Path | None = None
|
|
36
|
+
materialized_event_stream: Path | None = None
|
|
37
|
+
semantic_event_count: int = 0
|
|
38
|
+
|
|
39
|
+
def to_dict(self) -> dict[str, object]:
|
|
40
|
+
return {
|
|
41
|
+
"session_id": self.session_id,
|
|
42
|
+
"backend": self.backend,
|
|
43
|
+
"return_code": self.return_code,
|
|
44
|
+
"output_dir": str(self.output_dir),
|
|
45
|
+
"event_stream": str(self.event_stream),
|
|
46
|
+
"fidelity": str(self.fidelity),
|
|
47
|
+
"graph": str(self.graph),
|
|
48
|
+
"viewer": str(self.viewer),
|
|
49
|
+
"event_count": self.event_count,
|
|
50
|
+
"node_count": self.node_count,
|
|
51
|
+
"edge_count": self.edge_count,
|
|
52
|
+
"semantic_sidecar": (
|
|
53
|
+
str(self.semantic_sidecar) if self.semantic_sidecar is not None else None
|
|
54
|
+
),
|
|
55
|
+
"materialized_event_stream": (
|
|
56
|
+
str(self.materialized_event_stream)
|
|
57
|
+
if self.materialized_event_stream is not None
|
|
58
|
+
else str(self.event_stream)
|
|
59
|
+
),
|
|
60
|
+
"semantic_event_count": self.semantic_event_count,
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def _preflight_artifacts(paths: list[Path]) -> None:
|
|
65
|
+
conflicts = [path for path in paths if path.exists() and path.stat().st_size > 0]
|
|
66
|
+
if conflicts:
|
|
67
|
+
rendered = ", ".join(str(path) for path in conflicts)
|
|
68
|
+
raise FileExistsError(f"ExecWeave record artifacts already exist: {rendered}")
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def record_to_viewer(
|
|
72
|
+
command: list[str],
|
|
73
|
+
*,
|
|
74
|
+
watch_root: str | Path,
|
|
75
|
+
output_dir: str | Path | None = None,
|
|
76
|
+
backend: BackendName = "auto",
|
|
77
|
+
poll_interval: float = 0.10,
|
|
78
|
+
collect_filesystem: bool = True,
|
|
79
|
+
collect_network: bool = True,
|
|
80
|
+
keep_raw_trace: bool = False,
|
|
81
|
+
open_browser: bool = False,
|
|
82
|
+
integrate_semantic: bool = True,
|
|
83
|
+
) -> RecordResult:
|
|
84
|
+
"""Record one command and materialize a local graph/viewer after it exits."""
|
|
85
|
+
if not command:
|
|
86
|
+
raise ValueError("command must not be empty")
|
|
87
|
+
|
|
88
|
+
session_id = uuid4().hex
|
|
89
|
+
root = Path(watch_root).expanduser().resolve()
|
|
90
|
+
run_dir = (
|
|
91
|
+
Path(output_dir).expanduser().resolve()
|
|
92
|
+
if output_dir is not None
|
|
93
|
+
else root / ".execweave" / "runs" / session_id
|
|
94
|
+
)
|
|
95
|
+
run_dir.mkdir(parents=True, exist_ok=True)
|
|
96
|
+
|
|
97
|
+
event_path = run_dir / "events.jsonl"
|
|
98
|
+
fidelity_path = run_dir / "fidelity.json"
|
|
99
|
+
graph_path = run_dir / "graph.json"
|
|
100
|
+
viewer_path = run_dir / "viewer.html"
|
|
101
|
+
semantic_path = run_dir / "semantic.jsonl"
|
|
102
|
+
merged_event_path = run_dir / "events.semantic.jsonl"
|
|
103
|
+
artifacts = [event_path, fidelity_path, graph_path, viewer_path]
|
|
104
|
+
if integrate_semantic:
|
|
105
|
+
artifacts.extend([semantic_path, merged_event_path])
|
|
106
|
+
_preflight_artifacts(artifacts)
|
|
107
|
+
|
|
108
|
+
sink = JsonlSink(event_path)
|
|
109
|
+
resolved = resolve_backend(backend)
|
|
110
|
+
collector = create_collector(
|
|
111
|
+
backend=backend,
|
|
112
|
+
session_id=session_id,
|
|
113
|
+
sink=sink,
|
|
114
|
+
watch_root=root,
|
|
115
|
+
poll_interval=poll_interval,
|
|
116
|
+
collect_filesystem=collect_filesystem,
|
|
117
|
+
collect_network=collect_network,
|
|
118
|
+
keep_raw_trace=keep_raw_trace,
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
environment_updates = {
|
|
122
|
+
_RUN_ID_ENV: session_id,
|
|
123
|
+
_SESSION_ID_ENV: session_id,
|
|
124
|
+
}
|
|
125
|
+
if integrate_semantic:
|
|
126
|
+
environment_updates[_SEMANTIC_ENV] = str(semantic_path)
|
|
127
|
+
previous_environment = {
|
|
128
|
+
key: os.environ.get(key) for key in environment_updates
|
|
129
|
+
}
|
|
130
|
+
os.environ.update(environment_updates)
|
|
131
|
+
try:
|
|
132
|
+
return_code = collector.run(command)
|
|
133
|
+
finally:
|
|
134
|
+
for key, value in previous_environment.items():
|
|
135
|
+
if value is None:
|
|
136
|
+
os.environ.pop(key, None)
|
|
137
|
+
else:
|
|
138
|
+
os.environ[key] = value
|
|
139
|
+
|
|
140
|
+
validation = validate_event_stream(event_path)
|
|
141
|
+
if not validation.valid:
|
|
142
|
+
details = "; ".join(validation.errors)
|
|
143
|
+
raise RuntimeError(f"recorded event stream failed validation: {details}")
|
|
144
|
+
|
|
145
|
+
materialized_event_path = event_path
|
|
146
|
+
semantic_event_count = 0
|
|
147
|
+
if integrate_semantic and semantic_path.exists() and semantic_path.stat().st_size > 0:
|
|
148
|
+
semantic_merge = merge_semantic_sidecar(
|
|
149
|
+
event_path,
|
|
150
|
+
semantic_path,
|
|
151
|
+
merged_event_path,
|
|
152
|
+
)
|
|
153
|
+
materialized_event_path = merged_event_path
|
|
154
|
+
semantic_event_count = semantic_merge.semantic_event_count
|
|
155
|
+
|
|
156
|
+
execution_graph = strip_internal_hook_execution_graph(
|
|
157
|
+
build_execution_graph(materialized_event_path)
|
|
158
|
+
)
|
|
159
|
+
write_fidelity_report(execution_graph.fidelity, fidelity_path)
|
|
160
|
+
write_execution_graph(execution_graph, graph_path)
|
|
161
|
+
write_graph_html(execution_graph.to_dict(), viewer_path, open_browser=False)
|
|
162
|
+
ensure_viewer_theme(viewer_path)
|
|
163
|
+
if open_browser:
|
|
164
|
+
import webbrowser
|
|
165
|
+
|
|
166
|
+
webbrowser.open(viewer_path.resolve().as_uri())
|
|
167
|
+
|
|
168
|
+
return RecordResult(
|
|
169
|
+
session_id=session_id,
|
|
170
|
+
backend=resolved,
|
|
171
|
+
return_code=return_code,
|
|
172
|
+
output_dir=run_dir,
|
|
173
|
+
event_stream=event_path,
|
|
174
|
+
fidelity=fidelity_path,
|
|
175
|
+
graph=graph_path,
|
|
176
|
+
viewer=viewer_path,
|
|
177
|
+
event_count=execution_graph.event_count,
|
|
178
|
+
node_count=len(execution_graph.nodes),
|
|
179
|
+
edge_count=len(execution_graph.edges),
|
|
180
|
+
semantic_sidecar=semantic_path.resolve() if integrate_semantic else None,
|
|
181
|
+
materialized_event_stream=materialized_event_path.resolve(),
|
|
182
|
+
semantic_event_count=semantic_event_count,
|
|
183
|
+
)
|