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.
Files changed (234) hide show
  1. execweave/__init__.py +3 -0
  2. execweave/__main__.py +5 -0
  3. execweave/_conversation_records_core.py +902 -0
  4. execweave/_dashboard_shell_base.py +148 -0
  5. execweave/_http_proxy_base.py +565 -0
  6. execweave/_http_proxy_bounded.py +560 -0
  7. execweave/_http_proxy_stage.py +509 -0
  8. execweave/acceptance_output.py +19 -0
  9. execweave/agent_bootstrap.py +395 -0
  10. execweave/agent_topology.py +313 -0
  11. execweave/agent_trace.py +1162 -0
  12. execweave/agy_preview_sanitize.py +102 -0
  13. execweave/analysis.py +427 -0
  14. execweave/anthropic.py +228 -0
  15. execweave/anthropic_cli.py +171 -0
  16. execweave/anthropic_full_fidelity.py +385 -0
  17. execweave/antigravity_adapter.py +112 -0
  18. execweave/antigravity_adapter_base.py +479 -0
  19. execweave/antigravity_full_fidelity.py +656 -0
  20. execweave/antigravity_full_fidelity_base.py +172 -0
  21. execweave/antigravity_full_fidelity_collaboration_base.py +451 -0
  22. execweave/antigravity_hook_cli.py +209 -0
  23. execweave/antigravity_record.py +96 -0
  24. execweave/antigravity_subagent_linkage.py +449 -0
  25. execweave/antigravity_trace_capability.py +39 -0
  26. execweave/auto_specialized.py +547 -0
  27. execweave/backends.py +102 -0
  28. execweave/benchmark.py +80 -0
  29. execweave/claude_adapter.py +517 -0
  30. execweave/claude_child_transcript.py +314 -0
  31. execweave/claude_delegation.py +136 -0
  32. execweave/claude_full_fidelity.py +396 -0
  33. execweave/claude_hook_cli.py +209 -0
  34. execweave/claude_hook_contract.py +943 -0
  35. execweave/claude_model_observer.py +353 -0
  36. execweave/claude_record.py +106 -0
  37. execweave/cli.py +629 -0
  38. execweave/codex_adapter.py +455 -0
  39. execweave/codex_conversation.py +621 -0
  40. execweave/codex_full_fidelity.py +287 -0
  41. execweave/codex_hook_cli.py +301 -0
  42. execweave/codex_hook_entry.py +207 -0
  43. execweave/codex_hook_lifecycle.py +363 -0
  44. execweave/codex_message_diagnostics.py +322 -0
  45. execweave/codex_message_transport_diagnostics.py +399 -0
  46. execweave/codex_record.py +199 -0
  47. execweave/codex_rollout_structures.py +402 -0
  48. execweave/codex_rollout_trace.py +56 -0
  49. execweave/codex_rollout_trace_base.py +1509 -0
  50. execweave/collector.py +768 -0
  51. execweave/command.py +157 -0
  52. execweave/command_privacy.py +20 -0
  53. execweave/content_evidence.py +101 -0
  54. execweave/content_integrity.py +289 -0
  55. execweave/content_store.py +273 -0
  56. execweave/controlled_checks.py +561 -0
  57. execweave/conversation_archive.py +338 -0
  58. execweave/conversation_message_identity.py +264 -0
  59. execweave/conversation_preview.py +66 -0
  60. execweave/conversation_preview_antigravity.py +32 -0
  61. execweave/conversation_preview_claude.py +31 -0
  62. execweave/conversation_preview_codex.py +107 -0
  63. execweave/conversation_preview_common.py +180 -0
  64. execweave/conversation_preview_generic.py +188 -0
  65. execweave/conversation_preview_lines.py +133 -0
  66. execweave/conversation_preview_transcript.py +121 -0
  67. execweave/conversation_records.py +349 -0
  68. execweave/conversation_records_antigravity.py +370 -0
  69. execweave/conversation_records_codex.py +83 -0
  70. execweave/conversation_records_common.py +17 -0
  71. execweave/conversation_records_ollama.py +39 -0
  72. execweave/correlation.py +818 -0
  73. execweave/cursor_adapter.py +349 -0
  74. execweave/cursor_delegation.py +87 -0
  75. execweave/cursor_delegation_base.py +220 -0
  76. execweave/cursor_full_fidelity.py +489 -0
  77. execweave/cursor_hook_cli.py +195 -0
  78. execweave/cursor_hook_contract.py +439 -0
  79. execweave/cursor_lifecycle.py +159 -0
  80. execweave/cursor_record.py +96 -0
  81. execweave/dashboard_shell.py +283 -0
  82. execweave/delivery_status.py +94 -0
  83. execweave/entry.py +98 -0
  84. execweave/evidence_availability.py +113 -0
  85. execweave/evidence_grade.py +166 -0
  86. execweave/fidelity.py +304 -0
  87. execweave/filesystem.py +327 -0
  88. execweave/finalization.py +92 -0
  89. execweave/focus.py +118 -0
  90. execweave/framework_adapters/__init__.py +34 -0
  91. execweave/framework_adapters/autogen.py +398 -0
  92. execweave/framework_adapters/base.py +580 -0
  93. execweave/framework_adapters/camel.py +270 -0
  94. execweave/framework_adapters/camel_channel.py +71 -0
  95. execweave/framework_adapters/metagpt.py +315 -0
  96. execweave/framework_adapters/metagpt_ollama_compat.py +54 -0
  97. execweave/framework_adapters/metagpt_recording.py +342 -0
  98. execweave/framework_adapters/registry.py +90 -0
  99. execweave/graph.py +590 -0
  100. execweave/graph_ops.py +472 -0
  101. execweave/hook_command.py +32 -0
  102. execweave/hook_delivery.py +32 -0
  103. execweave/hook_input.py +16 -0
  104. execweave/http_proxy.py +187 -0
  105. execweave/http_proxy_cli.py +84 -0
  106. execweave/inference_gateway.py +476 -0
  107. execweave/inference_gateway_cli.py +211 -0
  108. execweave/inference_gateway_full_fidelity.py +613 -0
  109. execweave/inference_identity.py +76 -0
  110. execweave/inference_identity_cli.py +60 -0
  111. execweave/integrity.py +235 -0
  112. execweave/integrity_cli.py +55 -0
  113. execweave/investigation_index.py +445 -0
  114. execweave/litellm_callback.py +211 -0
  115. execweave/litellm_callback_cli.py +42 -0
  116. execweave/live.py +445 -0
  117. execweave/live_core.py +972 -0
  118. execweave/live_view.py +109 -0
  119. execweave/live_view_extra_style.py +11 -0
  120. execweave/live_view_markup.py +29 -0
  121. execweave/live_view_process_layout.py +650 -0
  122. execweave/live_view_readability.py +502 -0
  123. execweave/live_view_script_a.py +59 -0
  124. execweave/live_view_script_b.py +97 -0
  125. execweave/live_view_script_c.py +59 -0
  126. execweave/live_view_script_d.py +40 -0
  127. execweave/live_view_style.py +34 -0
  128. execweave/model_runtime.py +560 -0
  129. execweave/model_runtime_cli.py +265 -0
  130. execweave/model_runtime_full_fidelity.py +519 -0
  131. execweave/observation.py +53 -0
  132. execweave/observation_demo.py +69 -0
  133. execweave/openai_agents.py +267 -0
  134. execweave/openai_agents_sdk.py +453 -0
  135. execweave/openai_compatible.py +239 -0
  136. execweave/openai_compatible_cli.py +189 -0
  137. execweave/openai_compatible_full_fidelity.py +438 -0
  138. execweave/opencode_adapter.py +325 -0
  139. execweave/opencode_event_contract.py +734 -0
  140. execweave/opencode_full_fidelity.py +198 -0
  141. execweave/opencode_hook_cli.py +119 -0
  142. execweave/opencode_plugin_cli.py +150 -0
  143. execweave/opencode_record.py +96 -0
  144. execweave/opencode_task_linkage.py +225 -0
  145. execweave/overhead_benchmark.py +440 -0
  146. execweave/privacy.py +84 -0
  147. execweave/private_io.py +465 -0
  148. execweave/provider_capability.py +578 -0
  149. execweave/provider_lifecycle.py +282 -0
  150. execweave/provider_record.py +290 -0
  151. execweave/reader_identity.py +13 -0
  152. execweave/redacted_archive.py +906 -0
  153. execweave/risk.py +106 -0
  154. execweave/rule_pack.py +359 -0
  155. execweave/rule_pack_cli.py +57 -0
  156. execweave/run_assessment.py +200 -0
  157. execweave/runtime_endpoint_availability.py +44 -0
  158. execweave/scalability_benchmark.py +195 -0
  159. execweave/schema.py +62 -0
  160. execweave/scope.py +85 -0
  161. execweave/semantic.py +453 -0
  162. execweave/session_summary.py +159 -0
  163. execweave/sink.py +71 -0
  164. execweave/strace_backend.py +927 -0
  165. execweave/stream_assembly.py +363 -0
  166. execweave/task_artifacts.py +192 -0
  167. execweave/task_validation.py +317 -0
  168. execweave/theme.py +40 -0
  169. execweave/top.py +599 -0
  170. execweave/top_cli.py +150 -0
  171. execweave/validate.py +196 -0
  172. execweave/vendor/dagre.min.js +815 -0
  173. execweave/view_cli.py +49 -0
  174. execweave/viewer.py +474 -0
  175. execweave/viewer_agent_panel.py +630 -0
  176. execweave/viewer_agent_panel_antigravity.py +31 -0
  177. execweave/viewer_agent_panel_claude.py +9 -0
  178. execweave/viewer_agent_panel_codex.py +50 -0
  179. execweave/viewer_agent_panel_cursor.py +9 -0
  180. execweave/viewer_agent_panel_default.py +79 -0
  181. execweave/viewer_agent_panel_ollama.py +20 -0
  182. execweave/viewer_agent_panel_opencode.py +9 -0
  183. execweave/viewer_agent_panel_registry.py +20 -0
  184. execweave/viewer_archive_verifier.py +178 -0
  185. execweave/viewer_background_files.py +86 -0
  186. execweave/viewer_content_browser.py +307 -0
  187. execweave/viewer_content_health.py +208 -0
  188. execweave/viewer_content_inspector.py +309 -0
  189. execweave/viewer_controlled_checks.py +258 -0
  190. execweave/viewer_conversation_sync.py +115 -0
  191. execweave/viewer_dashboard_clean.py +405 -0
  192. execweave/viewer_dashboard_focus.py +127 -0
  193. execweave/viewer_dashboard_hardening.py +264 -0
  194. execweave/viewer_dashboard_hardening_v2.py +62 -0
  195. execweave/viewer_dashboard_projection.py +261 -0
  196. execweave/viewer_delivery_status.py +155 -0
  197. execweave/viewer_edge_decross.py +117 -0
  198. execweave/viewer_execution_flow.py +611 -0
  199. execweave/viewer_execution_flow_provider_normalization.py +107 -0
  200. execweave/viewer_execution_flow_safety.py +349 -0
  201. execweave/viewer_external_endpoints.py +307 -0
  202. execweave/viewer_flow_canvas.py +1140 -0
  203. execweave/viewer_flow_layout.py +922 -0
  204. execweave/viewer_fold_state.py +31 -0
  205. execweave/viewer_framework_flow.py +68 -0
  206. execweave/viewer_framework_model_output.py +133 -0
  207. execweave/viewer_gif.py +278 -0
  208. execweave/viewer_history_browser.py +225 -0
  209. execweave/viewer_investigation.py +268 -0
  210. execweave/viewer_layout_geometry.py +192 -0
  211. execweave/viewer_layout_v2.py +429 -0
  212. execweave/viewer_layout_v2_detached.py +25 -0
  213. execweave/viewer_limits.py +93 -0
  214. execweave/viewer_live_layout.py +61 -0
  215. execweave/viewer_message_handoffs.py +114 -0
  216. execweave/viewer_projection.py +488 -0
  217. execweave/viewer_projection_base.py +522 -0
  218. execweave/viewer_projection_bridges.py +214 -0
  219. execweave/viewer_recorded_sources.py +146 -0
  220. execweave/viewer_run_assessment.py +274 -0
  221. execweave/viewer_run_guide.py +175 -0
  222. execweave/viewer_runtime_evidence.py +258 -0
  223. execweave/viewer_semantic_projection.py +641 -0
  224. execweave/viewer_session_flow.py +491 -0
  225. execweave/viewer_structure_share.py +132 -0
  226. execweave/viewer_task_validation.py +241 -0
  227. execweave/viewer_tool_mirror_identity.py +75 -0
  228. execweave/viewer_workflow_mode.py +127 -0
  229. execweave/workflow.py +183 -0
  230. execweave-1.0.0.dist-info/METADATA +462 -0
  231. execweave-1.0.0.dist-info/RECORD +234 -0
  232. execweave-1.0.0.dist-info/WHEEL +4 -0
  233. execweave-1.0.0.dist-info/entry_points.txt +30 -0
  234. execweave-1.0.0.dist-info/licenses/LICENSE +16 -0
@@ -0,0 +1,307 @@
1
+ """Bounded, verified, on-demand reading of the inspector's archived content.
2
+
3
+ This component consumes reference metadata already rendered by the shared panel.
4
+ It does not discover owners, parse tool output as routes, change graph evidence,
5
+ or read arbitrary workspace paths. Offline reading requires an explicit user
6
+ selection of an exported run folder; no content is embedded or silently fetched.
7
+ """
8
+ from __future__ import annotations
9
+
10
+ from .viewer_recorded_sources import inject_recorded_sources
11
+
12
+ CONTENT_BROWSER_CSS = r"""
13
+ .execweave-content-actions{display:flex;flex-wrap:wrap;gap:6px;padding:10px}
14
+ .execweave-content-actions button{font:inherit;cursor:pointer;padding:6px 10px}
15
+ #execweave-content-dialog{width:min(900px,90vw);max-height:85vh;box-sizing:border-box;border:1px solid var(--border,#888);border-radius:10px;background:var(--panel,#fff);color:var(--text,#111);padding:16px}
16
+ #execweave-content-dialog::backdrop{background:rgba(0,0,0,.4)}
17
+ #execweave-content-dialog header,.execweave-content-controls{display:flex;flex-wrap:wrap;align-items:center;gap:8px;margin-bottom:10px}
18
+ #execweave-content-title{flex:1;margin:0;font-size:18px}
19
+ #execweave-content-meta{overflow-wrap:anywhere;font-size:12px}
20
+ #execweave-content-status{white-space:pre-wrap;overflow-wrap:anywhere}
21
+ #execweave-content-text{white-space:pre-wrap;overflow-wrap:anywhere;overflow:auto;max-height:45vh;font:14px/1.5 ui-monospace,monospace;tab-size:4}
22
+ #execweave-content-dialog button,#execweave-content-dialog input{font:inherit;padding:6px}
23
+ """.strip()
24
+
25
+ CONTENT_BROWSER_JS = r"""
26
+ (()=>{
27
+ 'use strict';
28
+ if(window.__execweaveContentBrowser)return;
29
+ const LIMIT=8*1024*1024,PAGE=16384,TIMEOUT=15000;
30
+ const PATH=/^content\/sha256\/([0-9a-f]{64})\.(json|txt|bin)$/;
31
+ const inspector=document.getElementById('details');
32
+ if(!inspector)return;
33
+ let dialog=null,body,status,meta,title,folder,previous,next,search,find,copy;
34
+ let generation=0,controller=null,current=null,text=null,page=0,files=new Map(),runKey=null;
35
+ const processed=new WeakSet();
36
+ // This tab-local ledger contains identities and outcomes only, never body text.
37
+ // A new folder invalidates old file capabilities and their previous outcomes.
38
+ const READ_LIMIT=10000,readOutcomes=new Map();let readEvictions=0;
39
+ function resetReadOutcomes(){readOutcomes.clear();readEvictions=0}
40
+ function recordRead(ref,state,verifiedBytes=null){
41
+ if(!ref||!PATH.test(ref.path)||typeof ref.sha256!=='string')return;
42
+ const size=Number.isSafeInteger(ref.size_bytes)?ref.size_bytes:null;
43
+ const key=JSON.stringify([ref.path,ref.sha256,size]);readOutcomes.delete(key);
44
+ readOutcomes.set(key,{path:ref.path,sha256:ref.sha256,size_bytes:size,state,
45
+ hash_verified_bytes:Number.isSafeInteger(verifiedBytes)?verifiedBytes:null,
46
+ readable:state==='verified',source:(window.__execweaveStaticMode||location.protocol==='file:')?'selected_folder':'live_http'});
47
+ while(readOutcomes.size>READ_LIMIT){readOutcomes.delete(readOutcomes.keys().next().value);readEvictions++}
48
+ }
49
+ function getReadOutcomes(){
50
+ syncRun();return {schema_version:'1',scope:identity(),evicted:readEvictions,
51
+ records:[...readOutcomes.values()].map(r=>({...r}))};
52
+ }
53
+ function element(tag,id,value){const node=document.createElement(tag);if(id)node.id=id;if(value!==undefined)node.textContent=value;return node}
54
+ function button(label,action){const node=element('button',null,label);node.type='button';node.onclick=action;return node}
55
+ function graph(){return window.__execweaveCore?.getGraph?.()||window.__execweaveStaticGraph||{}}
56
+ function identity(){const g=graph();return JSON.stringify([g.run_id??null,g.session_id??null,g.source_path??null])}
57
+ function report(state,message){dialog.dataset.state=state;status.textContent=message}
58
+ function controls(enabled){for(const node of [previous,next,search,find,copy])node.disabled=!enabled}
59
+ function cancel(){if(controller&&current?.ref)recordRead(current.ref,'cancelled');generation++;controller?.abort();controller=null;text=null;current=null;page=0;if(body)body.textContent='';if(dialog){controls(false);dialog.close()}}
60
+ // A selected folder is an in-memory capability for one complete run scope.
61
+ // Reusing a session identifier must not authorize files from another execution.
62
+ function clearRun(){cancel();files=new Map();resetReadOutcomes();if(folder)folder.value=''}
63
+ function syncRun(){
64
+ const key=identity();
65
+ if(runKey!==null&&key!==runKey){clearRun();runKey=key;return false}
66
+ runKey=key;return true;
67
+ }
68
+ function reference(value){
69
+ if(!value||typeof value!=='object'||Array.isArray(value))throw new Error('invalid_reference');
70
+ const match=typeof value.path==='string'?PATH.exec(value.path):null;
71
+ if(!match||match[0]!==value.path||value.sha256!==match[1])throw new Error('invalid_reference');
72
+ const nodes=Array.isArray(graph().nodes)?graph().nodes:[];
73
+ const matches=nodes.filter(node=>node&&(
74
+ (value.id&&node.id===value.id)||
75
+ (node.type==='observed_content'&&node.attributes?.path===value.path)
76
+ ));
77
+ // A caller cannot overwrite contradictory graph evidence. Check every known
78
+ // byte declaration, including repeated IDs, before opening any file/request.
79
+ // Different content kinds may legitimately refer to the same stored bytes.
80
+ for(const node of matches){
81
+ const a=node.attributes;
82
+ if(node.type!=='observed_content'||a?.path!==value.path||a?.sha256!==value.sha256)
83
+ throw new Error('conflicting_reference');
84
+ }
85
+ const sizes=new Set();
86
+ for(const declaration of [value,...matches.map(node=>node.attributes)]){
87
+ const size=declaration.size_bytes;
88
+ if(size===undefined)continue;
89
+ if(!Number.isSafeInteger(size)||size<0)throw new Error('invalid_reference');
90
+ sizes.add(size);
91
+ }
92
+ if(sizes.size>1)throw new Error('conflicting_reference');
93
+ const source=matches.find(node=>value.id&&node.id===value.id)||matches[0];
94
+ const result={...source?.attributes,...value};
95
+ if(sizes.size)result.size_bytes=sizes.values().next().value;
96
+ return result;
97
+ }
98
+ function ensureDialog(){
99
+ if(dialog)return;
100
+ dialog=element('dialog','execweave-content-dialog');dialog.setAttribute('aria-labelledby','execweave-content-title');
101
+ const head=element('header');title=element('h2','execweave-content-title','Recorded content');
102
+ head.append(title,button('Close',cancel));
103
+ meta=element('p','execweave-content-meta');status=element('p','execweave-content-status');status.setAttribute('role','status');
104
+ const actions=element('div');actions.className='execweave-content-controls';
105
+ const load=button('Load / retry',()=>loadCurrent());load.id='execweave-content-load';
106
+ folder=element('input','execweave-content-folder');folder.type='file';folder.multiple=true;folder.setAttribute('webkitdirectory','');folder.setAttribute('aria-label','Choose exported run folder');
107
+ folder.onchange=()=>{
108
+ if(!syncRun()||!current){folder.value='';return}
109
+ generation++;controller?.abort();text=null;body.textContent='';controls(false);files=new Map();resetReadOutcomes();
110
+ if(folder.files.length>50000){report('folder_limit','Too many files. Choose one exported run folder.');return}
111
+ for(const file of folder.files){
112
+ const relative=String(file.webkitRelativePath||'');
113
+ const slash=relative.indexOf('/');
114
+ const path=slash<0?'':relative.slice(slash+1);
115
+ const match=PATH.exec(path);
116
+ if(match&&match[0]===path)files.set(path,file);
117
+ }
118
+ folder.value='';
119
+ if(!files.size){report('folder_missing','No content/sha256 files found. Choose the exported run folder, not its parent or the content folder.');return}
120
+ loadCurrent();
121
+ };
122
+ const folderLabel=element('label',null,'Offline: choose exported run folder ');folderLabel.append(folder);
123
+ actions.append(load,folderLabel);
124
+ const paging=element('div');paging.className='execweave-content-controls';
125
+ previous=button('Previous page',()=>{page=Math.max(0,page-1);showPage()});
126
+ next=button('Next page',()=>{page++;showPage()});
127
+ search=element('input','execweave-content-search');search.type='search';search.placeholder='Find in full loaded content';search.setAttribute('aria-label','Find in full loaded content');
128
+ find=button('Find',()=>{
129
+ if(text===null)return;
130
+ const index=text.indexOf(search.value);
131
+ if(index<0){report('verified','SHA-256 verified. Search text not found.');return}
132
+ page=Math.floor(index/PAGE);showPage();
133
+ });
134
+ search.onkeydown=event=>{if(event.key==='Enter'){event.preventDefault();find.click()}};
135
+ copy=button('Copy full content',async()=>{
136
+ if(text===null)return;
137
+ const token=generation;
138
+ try{await navigator.clipboard.writeText(text);if(token===generation)report('verified','SHA-256 verified. Full content copied.')}
139
+ catch(_){if(token===generation)report('verified','SHA-256 verified. Clipboard unavailable; select text in the preview.')}
140
+ });
141
+ paging.append(previous,next,search,find,copy);
142
+ body=element('pre','execweave-content-text');
143
+ dialog.append(head,meta,status,actions,paging,body);
144
+ // Escape belongs to the topmost content dialog, not the canvas or its
145
+ // underlying investigation. Keep native dialog cancellation and focus return.
146
+ dialog.addEventListener('keydown',event=>{if(event.key==='Escape')event.stopPropagation()});
147
+ dialog.addEventListener('cancel',event=>{event.preventDefault();cancel()});
148
+ document.body.append(dialog);controls(false);
149
+ }
150
+ function showPage(){
151
+ if(text===null)return;
152
+ const total=Math.max(1,Math.ceil(text.length/PAGE));page=Math.min(Math.max(0,page),total-1);
153
+ let start=page*PAGE,end=Math.min(text.length,start+PAGE);
154
+ // Keep a supplementary Unicode character intact across page boundaries.
155
+ if(start>0&&/[\uDC00-\uDFFF]/.test(text[start]))start--;
156
+ if(end<text.length&&/[\uD800-\uDBFF]/.test(text[end-1]))end--;
157
+ body.textContent=text.slice(start,end);body.scrollTop=0;
158
+ controls(true);previous.disabled=page===0;next.disabled=page===total-1;
159
+ report('verified',`SHA-256 verified. Page ${page+1}/${total}; full captured file loaded.${text.length===0?' Captured content is empty.':''}`);
160
+ }
161
+ const ERRORS={
162
+ run_changed:'The active run changed during content retrieval. Reopen the desired reference in the current run.',
163
+ invalid_reference:'Invalid content reference. Only run-local content/sha256 paths matching their recorded hash are allowed.',
164
+ conflicting_reference:'Conflicting recorded content identity, path, hash or size declarations. Content was not loaded; resolve the conflicting evidence rather than selecting one declaration.',
165
+ too_large:'Content exceeds the 8 MiB in-browser read limit. No truncated body is being presented as complete; the archived content is unchanged.',
166
+ folder_required:'Offline content is not embedded. Choose the exported run folder to read and verify its captured files.',
167
+ missing_blob:'Recorded content file is missing from this run or selected folder. This is not evidence that the provider never exposed it.',
168
+ unauthorized:'Content access was rejected. Reopen this run with its authorized Dashboard URL, then retry.',
169
+ hash_mismatch:'SHA-256 mismatch. The bytes do not match the recorded reference; content is not displayed.',
170
+ size_mismatch:'Content size does not match the recorded reference; content is not displayed.',
171
+ crypto_unavailable:'SHA-256 verification is unavailable in this browser context. Content is not displayed as verified.',
172
+ binary_content:'The hash matches, but this content is not UTF-8 text. Binary preview is not supported.',
173
+ incomplete_response:'The content server returned a partial response; full-content verification was not performed.',
174
+ stream_unavailable:'Bounded streaming is unavailable in this browser. Content was not loaded.',
175
+ request_failed:'Content could not be loaded. Check the run server and retry; no provider-visibility conclusion is implied.'
176
+ };
177
+ async function bytesFromResponse(response,signal){
178
+ const length=response.headers.get('content-length');
179
+ if(length!==null&&Number(length)>LIMIT)throw new Error('too_large');
180
+ if(!response.body?.getReader)throw new Error('stream_unavailable');
181
+ const reader=response.body.getReader(),chunks=[];let size=0,complete=false;
182
+ try{
183
+ while(true){
184
+ if(signal.aborted)throw new DOMException('Aborted','AbortError');
185
+ const {done,value}=await reader.read();if(done){complete=true;break}
186
+ size+=value.byteLength;if(size>LIMIT)throw new Error('too_large');chunks.push(value);
187
+ }
188
+ }finally{if(!complete)await reader.cancel().catch(()=>{});reader.releaseLock()}
189
+ const bytes=new Uint8Array(size);let offset=0;for(const chunk of chunks){bytes.set(chunk,offset);offset+=chunk.byteLength}return bytes;
190
+ }
191
+ async function loadCurrent(){
192
+ if(!syncRun()||!current)return;
193
+ const value=current.ref,token=++generation,startedRun=identity();
194
+ controller?.abort();controller=new AbortController();const active=controller;
195
+ const timer=setTimeout(()=>active.abort(),TIMEOUT);
196
+ text=null;page=0;body.textContent='';controls(false);report('loading','Loading recorded content; verification pending.');
197
+ let checkedRef=null,verifiedBytes=null;
198
+ try{
199
+ const ref=reference(value);checkedRef=ref;recordRead(ref,'reading');if(ref.size_bytes>LIMIT)throw new Error('too_large');
200
+ let bytes;
201
+ if(window.__execweaveStaticMode||location.protocol==='file:'){
202
+ if(!files.size)throw new Error('folder_required');
203
+ const file=files.get(ref.path);if(!file)throw new Error('missing_blob');
204
+ if(file.size>LIMIT)throw new Error('too_large');
205
+ bytes=new Uint8Array(await file.arrayBuffer());
206
+ }else{
207
+ const headers={};if(window.__execweaveToken)headers['X-ExecWeave-Token']=window.__execweaveToken;
208
+ const response=await fetch('/'+ref.path,{headers,signal:active.signal,cache:'no-store',credentials:'same-origin',redirect:'error'});
209
+ if(response.status===401||response.status===403)throw new Error('unauthorized');
210
+ if(response.status===404)throw new Error('missing_blob');
211
+ if(response.status===206)throw new Error('incomplete_response');
212
+ if(!response.ok)throw new Error('request_failed');
213
+ bytes=await bytesFromResponse(response,active.signal);
214
+ }
215
+ if(token!==generation)return;
216
+ if(identity()!==startedRun)throw new Error('run_changed');
217
+ if(active.signal.aborted)throw new DOMException('Aborted','AbortError');
218
+ if(ref.size_bytes!==undefined&&bytes.byteLength!==ref.size_bytes)throw new Error('size_mismatch');
219
+ if(!globalThis.crypto?.subtle)throw new Error('crypto_unavailable');
220
+ const digest=await crypto.subtle.digest('SHA-256',bytes);
221
+ if(token!==generation)return;
222
+ if(identity()!==startedRun)throw new Error('run_changed');
223
+ if(active.signal.aborted)throw new DOMException('Aborted','AbortError');
224
+ const actual=Array.from(new Uint8Array(digest),value=>value.toString(16).padStart(2,'0')).join('');
225
+ if(actual!==ref.sha256)throw new Error('hash_mismatch');
226
+ verifiedBytes=bytes.byteLength;
227
+ let decoded;try{decoded=new TextDecoder('utf-8',{fatal:true,ignoreBOM:true}).decode(bytes)}catch(_){throw new Error('binary_content')}
228
+ if(decoded.includes('\u0000'))throw new Error('binary_content');
229
+ text=decoded;recordRead(ref,'verified',verifiedBytes);showPage();
230
+ }catch(error){
231
+ if(token!==generation)return;
232
+ text=null;body.textContent='';controls(false);
233
+ const state=error?.name==='AbortError'?'cancelled':(ERRORS[error?.message]?error.message:'request_failed');
234
+ if(identity()===startedRun)recordRead(checkedRef||value,state,verifiedBytes);
235
+ report(state,state==='cancelled'?'Content read cancelled or timed out. Retry when ready.':ERRORS[state]);
236
+ }finally{clearTimeout(timer);if(controller===active)controller=null}
237
+ }
238
+ function open(value,context){
239
+ syncRun();
240
+ ensureDialog();if(controller&&current?.ref)recordRead(current.ref,'cancelled');generation++;controller?.abort();text=null;body.textContent='';controls(false);current=null;
241
+ title.textContent='Recorded content';meta.textContent=String(context||'');search.value='';
242
+ if(!dialog.open)dialog.showModal();
243
+ try{
244
+ const ref=reference(value);current={ref};
245
+ meta.textContent=[context,ref.content_kind,ref.path,ref.representation,
246
+ ref.complete_from_source===true?'Complete value supplied by source (not proof of hidden provider stages).':
247
+ ref.complete_from_source===false?'Source capture marked partial.':'Source completeness unknown.'
248
+ ].filter(Boolean).join('\n');
249
+ loadCurrent();
250
+ }catch(error){const state=error?.message==='conflicting_reference'?'conflicting_reference':'invalid_reference';report(state,ERRORS[state])}
251
+ }
252
+ function attach(parent,refs,context){
253
+ if(!Array.isArray(refs)||!refs.length)return;
254
+ const actions=element('div');actions.className='execweave-content-actions';
255
+ const seen=new Set();
256
+ for(const ref of refs){
257
+ const key=JSON.stringify([ref?.path,ref?.sha256,ref?.relation]);if(seen.has(key))continue;seen.add(key);
258
+ const relation=String(ref?.relation||ref?.content_kind||'content');
259
+ const label=relation==='HAS_TOOL_INPUT'?'Read input':relation==='HAS_TOOL_OUTPUT'?'Read output':'Read '+relation;
260
+ actions.append(button(label,()=>open(ref,context)));
261
+ }
262
+ parent.append(actions);
263
+ }
264
+ function refresh(){
265
+ syncRun();
266
+ // Only parse metadata containers emitted by the existing inspector. Never parse
267
+ // arbitrary message bodies or tool results to discover paths or owners.
268
+ for(const occurrence of inspector.querySelectorAll('.execweave-tool-occurrence')){
269
+ const pre=occurrence.querySelector(':scope > pre');if(!pre||processed.has(pre))continue;
270
+ processed.add(pre);
271
+ try{const item=JSON.parse(pre.textContent);attach(occurrence,item.content_references,occurrence.querySelector(':scope > summary')?.textContent)}catch(_){}
272
+ }
273
+ for(const occurrence of inspector.querySelectorAll('.execweave-inference-occurrence')){
274
+ for(const card of occurrence.querySelectorAll(':scope > .execweave-agent-card')){
275
+ if(card.querySelector('.execweave-agent-label')?.textContent!=='Content references')continue;
276
+ const pre=card.querySelector('pre');if(!pre||processed.has(pre))continue;processed.add(pre);
277
+ try{attach(card,JSON.parse(pre.textContent),occurrence.querySelector(':scope > summary')?.textContent)}catch(_){}
278
+ }
279
+ }
280
+ }
281
+ let scheduled=false;
282
+ new MutationObserver(()=>{if(scheduled)return;scheduled=true;queueMicrotask(()=>{scheduled=false;refresh()})}).observe(inspector,{childList:true,subtree:true});
283
+ const previousDashboard=window.__execweaveDashboard||{};
284
+ window.__execweaveDashboard={...previousDashboard,
285
+ onPayload(...args){const result=previousDashboard.onPayload?.apply(this,args);syncRun();return result},
286
+ onFinished(...args){const result=previousDashboard.onFinished?.apply(this,args);syncRun();return result}
287
+ };
288
+ window.addEventListener('pagehide',()=>{clearRun();runKey=null});
289
+ window.__execweaveContentBrowser={refresh,close:cancel,attach,getReadOutcomes};refresh();
290
+ })();
291
+ """.strip()
292
+
293
+
294
+ def inject_content_browser(html: str) -> str:
295
+ """Install one additive component without replacing existing renderer code."""
296
+ if 'id="execweave-content-browser"' in html:
297
+ return inject_recorded_sources(html)
298
+ if "</body>" not in html:
299
+ raise RuntimeError("content browser requires a dashboard body")
300
+ component = (
301
+ '<style id="execweave-content-browser-style">'
302
+ + CONTENT_BROWSER_CSS
303
+ + '</style><script id="execweave-content-browser">'
304
+ + CONTENT_BROWSER_JS
305
+ + "</script>\n"
306
+ )
307
+ return inject_recorded_sources(html.replace("</body>", component + "</body>", 1))
@@ -0,0 +1,208 @@
1
+ """Versioned, inspectable content-reference coverage, not provider recall."""
2
+ from __future__ import annotations
3
+
4
+ CONTENT_HEALTH_JS = r"""
5
+ (()=>{
6
+ 'use strict';
7
+ if(window.__execweaveContentHealth)return;
8
+ const list=x=>Array.isArray(x)?x:[],make=(tag,text)=>{const e=document.createElement(tag);if(text!==undefined)e.textContent=String(text);return e};
9
+ const button=(text,fn)=>{const b=make('button',text);b.type='button';b.onclick=fn;return b};
10
+ const raw=()=>window.__execweaveCore?.getGraph?.()||window.__execweaveStaticGraph||{};
11
+ const scope=()=>JSON.stringify([raw().run_id??null,raw().session_id??null,raw().source_path??null]);
12
+ const validRef=r=>{const m=typeof r?.path==='string'?/^content\/sha256\/([0-9a-f]{64})\.(json|txt|bin)$/.exec(r.path):null;return !!m&&m[0]===r.path&&m[1]===r.sha256&&Number.isSafeInteger(r.size_bytes)&&r.size_bytes>=0};
13
+ const labels={registered:'Reference registered; bytes not checked',source_partial:'Source marked incomplete',configured_omission:'Explicit metadata-only capture',not_recorded:'Body not recorded; cause unknown',phase_unobserved:'Phase not observed',invalid:'Invalid or conflicting reference',outside_inventory:'Not in graph inventory',mixed:'Mixed or incomplete references',bounded:'Inspection limit reached'};
14
+ function summarize(index){
15
+ const report={denominator_version:'indexed-record-phase-v1',partial:true,groups:[],rows:[],invalid_rows:0};
16
+ if(index?.schema_version!=='0.1'||index.scope!=='recorded_event_investigation'||!['messages','calls','artifacts'].every(k=>Array.isArray(index[k])))return report;
17
+ const inspection=index.inspection||{};
18
+ report.partial=inspection.state!=='scanned_selected_streams'||inspection.graph_inventory_partial===true||inspection.limit_reached===true;
19
+ const definitions=[['model-request','Model request','calls','model','request'],['model-response','Model response','calls','model','response'],
20
+ ['tool-request','Tool arguments','calls','tool','request'],['tool-response','Tool result','calls','tool','response'],
21
+ ['message-sent','Sent message body','messages',null,'sent'],['message-received','Received message body','messages',null,'received'],
22
+ ['artifact','Historical file snapshot','artifacts',null,null]];
23
+ for(const [id,title,tab,kind,phase] of definitions){
24
+ const counts=Object.fromEntries(Object.keys(labels).map(k=>[k,0])),rows=list(index[tab]);
25
+ const group={id,title,total:0,counts,unknown_source_completeness:0};
26
+ const seen=new Map();for(const r of rows.slice(0,10000)){const key=r?.key||r?.id;seen.set(key,(seen.get(key)||0)+1)}
27
+ for(const row of rows.slice(0,10000)){
28
+ if(!row||typeof row!=='object'||Array.isArray(row)||(kind&&row.kind!==kind))continue;
29
+ const key=row.key||row.id;
30
+ if(typeof key!=='string'||!key||seen.get(key)!==1){report.partial=true;report.invalid_rows++;continue}
31
+ const all=tab==='artifacts'?list(row.snapshots):list(row.references).filter(r=>r?.phase===phase);
32
+ const refs=all.slice(0,100),hasPhase=tab==='artifacts'?row.snapshot_count>0:list(row.phases).includes(phase);
33
+ let state;
34
+ if(all.length>100||(tab==='artifacts'&&row.snapshot_count>all.length)||row.reference_count>list(row.references).length)state='bounded';
35
+ else if(!hasPhase&&!refs.length)state='phase_unobserved';
36
+ else if(refs.some(r=>r?.state==='invalid_reference'||(r?.state==='registered_not_read'&&!validRef(r.reference))))state='invalid';
37
+ else if(refs.some(r=>r?.state==='not_in_graph_inventory'))state='outside_inventory';
38
+ else if(refs.length&&refs.every(r=>r?.state==='registered_not_read'&&r.reference&&typeof r.reference.path==='string')){
39
+ state=refs.some(r=>r.reference.complete_from_source===false)?'source_partial':'registered';
40
+ if(refs.some(r=>r.reference.complete_from_source!==true&&r.reference.complete_from_source!==false))group.unknown_source_completeness++;
41
+ }else if(!refs.length||refs.every(r=>r?.state==='not_recorded')){
42
+ const observations=list(row.observations).filter(o=>o?.phase===phase);
43
+ state=observations.length&&observations.every(o=>o.capture_mode==='metadata_only')?'configured_omission':'not_recorded';
44
+ }else state='mixed';
45
+ if(state==='bounded')report.partial=true;
46
+ group.total++;group.counts[state]++;report.rows.push({group:id,tab,key,state,label:row.source_name||row.name||row.native_id||key});
47
+ }
48
+ if(rows.length>10000)report.partial=true;
49
+ report.groups.push(group);
50
+ }
51
+ return report;
52
+ }
53
+ function verifiedReads(index,ledger){
54
+ const result={denominator_version:'unique-indexed-files-v1',files:0,declared_bytes:0,
55
+ hash_verified_files:0,hash_verified_bytes:0,readable_files:0,readable_bytes:0,
56
+ failed_reads:0,unverified_files:0,conflicting_files:0,partial:false};
57
+ if(document.getElementById('protective')?.hidden===false)return {...result,partial:true};
58
+ const refs=new Map(),bad=new Set();let inspected=0;
59
+ if(index?.schema_version!=='0.1'||index.scope!=='recorded_event_investigation'||
60
+ !['calls','messages','artifacts'].every(k=>Array.isArray(index[k])))return {...result,partial:true};
61
+ const budget=100000;
62
+ outer:for(const tab of ['calls','messages','artifacts'])for(const row of index[tab]){
63
+ if(++inspected>budget){result.partial=true;break outer}
64
+ for(const item of list(tab==='artifacts'?row?.snapshots:row?.references)){
65
+ if(++inspected>budget){result.partial=true;break outer}
66
+ const r=item?.reference;if(!r)continue;
67
+ if(!validRef(r)||item.state!=='registered_not_read'){
68
+ if(typeof r.path==='string')bad.add(r.path);result.partial=true;continue;
69
+ }
70
+ const old=refs.get(r.path);
71
+ if(old&&(old.sha256!==r.sha256||old.size_bytes!==r.size_bytes))bad.add(r.path);
72
+ else refs.set(r.path,r);
73
+ }
74
+ }
75
+ for(const path of bad)refs.delete(path);result.conflicting_files=bad.size;
76
+ const reads=new Map(),duplicate=new Set();
77
+ if(ledger?.schema_version==='1'&&ledger.scope===scope()&&Array.isArray(ledger.records)){
78
+ for(const r of ledger.records.slice(0,10000)){
79
+ if(!r||typeof r.path!=='string')continue;
80
+ if(reads.has(r.path))duplicate.add(r.path);else reads.set(r.path,r);
81
+ }
82
+ if(ledger.evicted||ledger.records.length>10000)result.partial=true;
83
+ }
84
+ // Recheck current graph declarations once, not once per file. A previously
85
+ // verified path cannot override a changed size/hash or conflicting identity.
86
+ const declared=new Map();
87
+ for(const node of list(raw().nodes).slice(0,100000)){
88
+ const a=node?.attributes;
89
+ if(node?.type!=='observed_content'||typeof a?.path!=='string')continue;
90
+ const old=declared.get(a.path);
91
+ if(old===false)continue;
92
+ if(!validRef(a)||(old&&(old.sha256!==a.sha256||old.size_bytes!==a.size_bytes)))declared.set(a.path,false);
93
+ else declared.set(a.path,a);
94
+ }
95
+ if(list(raw().nodes).length>100000)result.partial=true;
96
+ for(const r of refs.values()){
97
+ result.files++;result.declared_bytes+=r.size_bytes;
98
+ const observed=reads.get(r.path),g=declared.get(r.path);
99
+ const bound=observed&&!duplicate.has(r.path)&&observed.sha256===r.sha256&&observed.size_bytes===r.size_bytes&&
100
+ g&&g.sha256===r.sha256&&g.size_bytes===r.size_bytes;
101
+ const verified=bound&&['verified','binary_content'].includes(observed.state)&&observed.hash_verified_bytes===r.size_bytes;
102
+ if(verified){result.hash_verified_files++;result.hash_verified_bytes+=r.size_bytes;
103
+ if(observed.state==='verified'&&observed.readable===true){result.readable_files++;result.readable_bytes+=r.size_bytes}
104
+ }else result.unverified_files++;
105
+ if(bound&&['missing_blob','hash_mismatch','size_mismatch','unauthorized','request_failed','incomplete_response','conflicting_reference','invalid_reference'].includes(observed.state))result.failed_reads++;
106
+ }
107
+ if(!Number.isSafeInteger(result.declared_bytes)){result.declared_bytes=null;result.partial=true}
108
+ const inspection=index.inspection||{};
109
+ result.partial=result.partial||bad.size>0||inspection.state!=='scanned_selected_streams'||
110
+ inspection.graph_inventory_partial===true||inspection.limit_reached===true;
111
+ return result;
112
+ }
113
+ let pinnedReads=null;
114
+ let dialog=null,body,summary,filter,refreshButton,invoker=null,currentScope=scope(),pinned=null,page=0,generation=0;
115
+ function close(){generation++;if(refreshButton)refreshButton.disabled=false;dialog?.close();body?.replaceChildren();pinned=null;pinnedReads=null;page=0;invoker?.focus()}
116
+ function checkScope(){if(scope()===currentScope)return true;currentScope=scope();close();return false}
117
+ function ensure(){
118
+ if(dialog)return;
119
+ dialog=make('dialog');dialog.id='execweave-health-dialog';dialog.setAttribute('aria-labelledby','execweave-health-title');
120
+ const head=make('header'),title=make('h2','Content health');title.id='execweave-health-title';head.append(title,button('Close content health',close));
121
+ const boundary=make('p','Counts describe indexed records and phases, not total provider activity or readable-byte recall. A registered reference has not been read or hash-verified. Source-incomplete, configured omission, missing phase and unknown cause are separate states.');
122
+ summary=make('p');summary.id='execweave-health-summary';summary.setAttribute('role','status');
123
+ filter=make('select');filter.setAttribute('aria-label','Content health category');
124
+ const all=make('option','All categories');all.value='all';filter.append(all);filter.onchange=()=>{page=0;draw()};
125
+ refreshButton=button('Refresh content health',async()=>{
126
+ if(!checkScope()||refreshButton.disabled)return;const request=++generation;refreshButton.disabled=true;
127
+ try{
128
+ if(!window.__execweaveStaticMode){
129
+ const refreshed=await window.__execweaveDashboard?.agentPanel?.refresh?.({includeInvestigation:true});
130
+ // The shared reader reports HTTP, scope and terminal failures as false,
131
+ // not rejected promises. Only its explicit success can replace this view.
132
+ if(refreshed!==true)throw new Error('Index refresh did not complete');
133
+ }
134
+ }
135
+ catch{if(request===generation)summary.textContent='Index refresh failed. The current snapshot is retained.';return}
136
+ finally{if(request===generation)refreshButton.disabled=false}
137
+ if(request!==generation||!checkScope()||!dialog.open)return;capture();draw();
138
+ });
139
+ const controls=make('div');controls.className='health-controls';controls.append(filter,refreshButton,
140
+ button('Previous health records',()=>{page=Math.max(0,page-1);draw()}),button('Next health records',()=>{page++;draw()}));
141
+ body=make('div');body.id='execweave-health-body';dialog.append(head,boundary,summary,controls,body);
142
+ dialog.addEventListener('keydown',e=>{if(e.key==='Escape')e.stopPropagation()});dialog.addEventListener('cancel',e=>{e.preventDefault();close()});document.body.append(dialog);
143
+ }
144
+ function capture(){
145
+ const index=window.__execweaveInvestigation?.getIndex?.();
146
+ pinned=summarize(index);pinnedReads=verifiedReads(index,window.__execweaveContentBrowser?.getReadOutcomes?.());page=0;
147
+ const chosen=filter.value;while(filter.options.length>1)filter.remove(1);
148
+ for(const g of pinned.groups){const option=make('option',g.title);option.value=g.id;filter.append(option)}
149
+ filter.value=[...filter.options].some(o=>o.value===chosen)?chosen:'all';
150
+ }
151
+ function draw(){
152
+ if(!pinned||!dialog.open||!checkScope())return;
153
+ body.replaceChildren();
154
+ summary.textContent=`Denominator: ${pinned.denominator_version}. `+(pinned.partial?'Partial or unavailable index; counts are lower bounds. ':'Selected recorded streams inspected. ')+
155
+ 'The snapshot stays pinned until Refresh content health. '+(pinned.invalid_rows?`${pinned.invalid_rows} invalid or duplicate record-phase rows withheld. `:'');
156
+ if(!pinned.groups.length){body.append(make('p','No versioned investigation index is available. Refresh to request it. Missing inventory is not zero activity.'));return}
157
+ const reads=pinnedReads,readSummary=make('section');readSummary.id='execweave-health-verified-reads';
158
+ readSummary.append(make('h3','Verified reads in this tab'),
159
+ make('p',`${reads.hash_verified_files}/${reads.files} indexed files hash-verified; ${reads.readable_files} readable as UTF-8. `+
160
+ `${reads.hash_verified_bytes} verified bytes / ${reads.declared_bytes===null?'unknown':reads.declared_bytes} declared bytes; ${reads.readable_bytes} readable verified bytes. `+
161
+ `${reads.failed_reads} latest read failures; ${reads.unverified_files} files without a matching verified result.`),
162
+ make('p','Denominator: '+reads.denominator_version+'. Duplicate references share one byte count, not one invocation. '+
163
+ 'Results describe the latest reads in this tab and selected folder, not continuous file integrity, provider recall, task success or an archive certificate. '+
164
+ 'Opening another folder or execution resets these results; reloading the page does not retain them. '+
165
+ (reads.partial?'Inventory or retained outcomes are partial. ':'')+`${reads.conflicting_files} conflicting file declaration(s) withheld.`));
166
+ body.append(readSummary);
167
+ const table=make('table');table.id='execweave-health-table';const header=make('tr');
168
+ for(const label of ['Category','Indexed records','Reference registered','Source incomplete','Explicit metadata-only','Other gaps / unknown'])header.append(make('th',label));table.append(header);
169
+ for(const g of pinned.groups){const tr=make('tr');tr.dataset.category=g.id;const c=g.counts;
170
+ for(const value of [g.title,g.total,c.registered,c.source_partial,c.configured_omission,g.total-c.registered-c.source_partial-c.configured_omission])tr.append(make('td',value));table.append(tr)}
171
+ body.append(table,make('p','Registered record-phase entries with unknown source completeness: '+pinned.groups.reduce((n,g)=>n+g.unknown_source_completeness,0)+'. Registration does not certify source completeness.'));
172
+ const rows=pinned.rows.filter(r=>filter.value==='all'||r.group===filter.value),pages=Math.max(1,Math.ceil(rows.length/25));page=Math.min(page,pages-1);
173
+ body.append(make('p',`${rows.length} indexed record-phase rows; page ${page+1}/${pages}. Rows across categories are not unique invocation counts.`));
174
+ for(const row of rows.slice(page*25,(page+1)*25)){
175
+ const card=make('article');card.className='execweave-health-row';card.dataset.state=row.state;
176
+ card.append(make('strong',row.label),make('p',row.group+' · '+labels[row.state]),button('Inspect indexed record',()=>{
177
+ const tab=row.tab,key=row.key;
178
+ if(window.__execweaveInvestigation?.openRecord?.(tab,key))close();
179
+ else summary.textContent='The indexed record changed or is no longer uniquely available. Refresh before inspecting it.';
180
+ }));body.append(card);
181
+ }
182
+ }
183
+ function open(){checkScope();ensure();invoker=document.activeElement;capture();dialog.showModal();draw()}
184
+ const launch=button('Content health',open);launch.id='execweave-content-health-launcher';
185
+ const host=document.getElementById('execweave-workflow-controls');if(host)host.append(launch);else{const anchor=document.getElementById('theme-toggle');anchor?.parentElement?.insertBefore(launch,anchor)};
186
+ const prior=window.__execweaveDashboard||{};window.__execweaveDashboard={...prior,onPayload(...args){prior.onPayload?.(...args);checkScope()},onFinished(...args){prior.onFinished?.(...args);checkScope()}};
187
+ window.addEventListener('pagehide',close);window.__execweaveContentHealth={summarize,verifiedReads,open,close};
188
+ })();
189
+ """.strip()
190
+
191
+ CONTENT_HEALTH_CSS = """
192
+ #execweave-health-dialog{width:min(1120px,94vw);max-height:90vh;border:1px solid var(--border);border-radius:12px;padding:18px;background:var(--panel);color:var(--text)}
193
+ #execweave-health-dialog::backdrop{background:rgba(0,0,0,.45)}
194
+ #execweave-health-dialog header,.health-controls{display:flex;align-items:center;gap:8px;flex-wrap:wrap}#execweave-health-title{flex:1;font-size:20px}
195
+ #execweave-health-dialog button,#execweave-health-dialog select{font:inherit;padding:7px}#execweave-health-dialog p{font-size:13px;line-height:1.5;overflow-wrap:anywhere}
196
+ #execweave-health-body{overflow:auto;max-height:58vh}#execweave-health-table{border-collapse:collapse;font-size:13px;width:100%;margin:12px 0}
197
+ #execweave-health-table th,#execweave-health-table td{padding:8px;text-align:left;border:1px solid var(--border)}
198
+ .execweave-health-row{padding:9px;margin:8px 0;border:1px solid var(--border);border-radius:8px;overflow-wrap:anywhere}
199
+ #execweave-content-health-launcher{font:inherit;padding:6px 10px;cursor:pointer}
200
+ """.strip()
201
+
202
+
203
+ def inject_content_health(html: str) -> str:
204
+ if 'id="execweave-content-health-script"' in html:
205
+ return html
206
+ if "</body>" not in html:
207
+ raise RuntimeError("content health requires a dashboard body")
208
+ return html.replace("</body>", "<style>" + CONTENT_HEALTH_CSS + '</style><script id="execweave-content-health-script">' + CONTENT_HEALTH_JS + "</script></body>", 1)