Mat2Bot front: one box, the story (no engine code)
Browse files- explore/cases/b1a_kcl_cooling_20C/package.zip +2 -2
- explore/cases/b1a_kcl_cooling_20C/trace.html +0 -0
- explore/cases/b1b_kcl_cooling_25C/package.zip +2 -2
- explore/cases/b1b_kcl_cooling_25C/trace.html +0 -0
- explore/cases/b1c_kcl_antisolvent_vcw001/package.zip +2 -2
- explore/cases/b1c_kcl_antisolvent_vcw001/trace.html +0 -0
- explore/cases/b2_caco3_calcite/package.zip +2 -2
- explore/cases/b2_caco3_calcite/trace.html +0 -0
- explore/cases/b3_zno_wurtzite/package.zip +2 -2
- explore/cases/b3_zno_wurtzite/trace.html +0 -0
- explore/cases/b4_zno_rocksalt/package.zip +2 -2
- explore/cases/b4_zno_rocksalt/trace.html +0 -0
- explore/cases/m1_matter_candidate/package.zip +2 -2
- explore/cases/m1_matter_candidate/trace.html +236 -117
- explore/cases/x1_na2o2_scope/package.zip +2 -2
- explore/cases/x1_na2o2_scope/trace.html +236 -117
- explore/cases/x2_caco3_vaterite/package.zip +2 -2
- explore/cases/x2_caco3_vaterite/trace.html +0 -0
- explore/cases/x3_caco3_aragonite/package.zip +2 -2
- explore/cases/x3_caco3_aragonite/trace.html +0 -0
- explore/data/site.json +1 -1
- story/story.html +3 -2
- story/viewer.css +20 -3
- story/viewer.js +216 -114
explore/cases/b1a_kcl_cooling_20C/package.zip
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e9c3f9cfb45e56341fdd0c7ccf0c95da517319564e17646b9e69d13d35c3e302
|
| 3 |
+
size 130782
|
explore/cases/b1a_kcl_cooling_20C/trace.html
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|
explore/cases/b1b_kcl_cooling_25C/package.zip
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:661b49fb2afbfafee0275d1b60798b439da84a1ce4f716f7a9f4df157431cc66
|
| 3 |
+
size 132383
|
explore/cases/b1b_kcl_cooling_25C/trace.html
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|
explore/cases/b1c_kcl_antisolvent_vcw001/package.zip
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:90cbe060cb7d7ffede8b982e12b2ced1330c66635bb7f332a3d26f8af5824d60
|
| 3 |
+
size 111535
|
explore/cases/b1c_kcl_antisolvent_vcw001/trace.html
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|
explore/cases/b2_caco3_calcite/package.zip
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6c4d397982e4787c55f1997c4abc39eea29926b0ee6689eeb0aa4462b058a19b
|
| 3 |
+
size 443489
|
explore/cases/b2_caco3_calcite/trace.html
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|
explore/cases/b3_zno_wurtzite/package.zip
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5028647fc4481e4d85406567b348050af87484ab3ea5dedfb6465fdf886a22aa
|
| 3 |
+
size 346474
|
explore/cases/b3_zno_wurtzite/trace.html
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|
explore/cases/b4_zno_rocksalt/package.zip
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2269d9a1f8735411c5716d12db9f3399d80958f69dfe5db6ed3f6cdec41f1b43
|
| 3 |
+
size 129795
|
explore/cases/b4_zno_rocksalt/trace.html
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|
explore/cases/m1_matter_candidate/package.zip
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:93cceecde2da6c1351fb59e07f0a5089143c2c3b1507a116b79504d92a55b8dd
|
| 3 |
+
size 37100
|
explore/cases/m1_matter_candidate/trace.html
CHANGED
|
@@ -113,7 +113,8 @@ details.tv-timeline summary{cursor:pointer;color:var(--accent);font-size:.95rem;
|
|
| 113 |
.tv-graph-bar button{border:1px solid var(--line);background:var(--card);color:var(--fg);border-radius:999px;padding:.35em .9em}
|
| 114 |
.tv-hint{font-size:.84rem;color:var(--muted);flex-basis:100%}
|
| 115 |
.tv-graph{border:1px solid var(--line);border-radius:var(--radius);background:var(--card);overflow:hidden;touch-action:none;cursor:grab}
|
| 116 |
-
.tv-graph:active{cursor:grabbing}.tv-graph svg{display:block;font:
|
|
|
|
| 117 |
.tv-graph line.gl{stroke:var(--line);stroke-width:1.2;opacity:.9}
|
| 118 |
.tv-graph line.member{stroke:var(--line);stroke-width:1;opacity:.5}
|
| 119 |
.tv-graph line.supported_by,.tv-graph line.computed_from,.tv-graph line.cites{stroke:var(--accent)}
|
|
@@ -125,17 +126,33 @@ details.tv-timeline summary{cursor:pointer;color:var(--accent);font-size:.95rem;
|
|
| 125 |
.tv-graph g.gn.tone-ok circle{stroke:var(--ok)}.tv-graph g.gn.tone-warn circle{stroke:var(--warn)}.tv-graph g.gn.tone-bad circle{stroke:var(--bad)}
|
| 126 |
.tv-graph g.gn.tone-off circle{stroke:var(--off);stroke-dasharray:3 2;opacity:.7}
|
| 127 |
.tv-graph g.gn.hub circle{stroke:var(--accent);stroke-width:2.5}
|
| 128 |
-
.tv-graph g.gn text.gt{fill:var(--fg);text-anchor:middle;pointer-events:none;opacity:0;font-size:
|
| 129 |
-
.tv-graph g.gn.hub text.gt{font-weight:700;font-size:
|
| 130 |
.tv-graph g.gn.lbl-always text.gt,.tv-graph.zoomed g.gn text.gt,.tv-graph.all-labels g.gn text.gt,.tv-graph g.gn:hover text.gt,.tv-graph g.gn.sel text.gt,.tv-graph g.gn.found text.gt{opacity:1}
|
| 131 |
.tv-graph g.gn.dim{opacity:.18}.tv-graph g.gn.sel circle{stroke:var(--accent);stroke-width:4}
|
| 132 |
.tv-graph g.gn.found circle{stroke:var(--accent);stroke-width:4}
|
| 133 |
.tv-glegend span{display:inline-flex;align-items:center;gap:.3em}.tv-glegend i{display:inline-block;width:12px;height:12px;border-radius:50%;border:0}
|
| 134 |
.tv-glegend i.ring{background:transparent;border:3px solid var(--ok)}.tv-glegend i.ring.warn{border-color:var(--warn)}.tv-glegend i.ring.bad{border-color:var(--bad)}.tv-glegend i.ring.off{border-color:var(--off);border-style:dashed}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 135 |
.tv-graph ellipse.cloud{fill:var(--accent);opacity:.07;stroke:none}.tv-graph ellipse.cloud.c1{fill:var(--ok)}.tv-graph ellipse.cloud.c2{fill:var(--warn)}.tv-graph ellipse.cloud.c3{fill:#b07aa1}
|
| 136 |
@media (prefers-color-scheme:dark){:root:not([data-theme="light"]) .tv-graph ellipse.cloud{opacity:.12}}
|
| 137 |
-
</style></head><body><script id="trace" type="application/json">{"edges":[],"events":[{"ended":"2026-10-26T00:00:00.000+00:00","message":"BaTiO3: identity known phase, phase cubic BaTiO3; gates G1 PASS, G2 PASS","name":"target intake","seq":1,"stage":"M01","started":"2026-10-26T00:00:00.000+00:00","status":"completed","subject":"m1"},{"ended":"2026-10-26T00:00:00.000+00:00","message":"no synthesis precedent of this composition in the evidence","name":"families and precedents","seq":2,"stage":"M02","started":"2026-10-26T00:00:00.000+00:00","status":"completed","subject":"BaTiO3"},{"ended":"2026-10-26T00:00:00.000+00:00","message":"no route for BaTiO3 in the families Mat2Bot (milestone 1) plans (documented here: none in the evidence set); not planned rather than planned weakly","name":"route candidates","seq":3,"stage":"M04","started":"2026-10-26T00:00:00.000+00:00","status":"refused","subject":"BaTiO3"},{"ended":"2026-10-26T00:00:00.000+00:00","message":"gate S on the product alone: UNKNOWN; BaTiO3 no classification found","name":"the product's own hazards (handling only)","seq":4,"stage":"M01","started":"2026-10-26T00:00:00.000+00:00","status":"completed","subject":"BaTiO3"},{"ended":"2026-10-26T00:00:00.000+00:00","message":"not reached: no route candidate in Mat2Bot's planned families","name":"feasibility","seq":5,"stage":"M05","started":"2026-10-26T00:00:00.000+00:00","status":"skipped","subject":"BaTiO3"},{"ended":"2026-10-26T00:00:00.000+00:00","message":"not reached: no route candidate in Mat2Bot's planned families","name":"route cases and ranking","seq":6,"stage":"M07","started":"2026-10-26T00:00:00.000+00:00","status":"skipped","subject":"BaTiO3"},{"ended":"2026-10-26T00:00:00.000+00:00","message":"not reached: no route candidate in Mat2Bot's planned families","name":"procedure","seq":7,"stage":"M08","started":"2026-10-26T00:00:00.000+00:00","status":"skipped","subject":"BaTiO3"},{"ended":"2026-10-26T00:00:00.000+00:00","message":"not reached: no route candidate in Mat2Bot's planned families","name":"laboratories","seq":8,"stage":"LAB","started":"2026-10-26T00:00:00.000+00:00","status":"skipped","subject":"BaTiO3"}],"layout":{"columns":["M01","M02","M04","M05","M07","M08","LAB","AUDIT"],"rows":{"finding:0":0,"gate:G1":1,"gate:G2":2,"gateS:target":3,"hazard:target:BaTiO3":4,"target":0}},"nodes":[{"children":["gate:G1","gate:G2","gateS:target"],"detail":{"checked_against":["the Mat2Bot v0.1 polymorph registry (KCl, CaCO3, ZnO, BaTiO3, and the ZnO competitors Zn(OH)2 and Zn5(OH)8(NO3)2(H2O)2; COD structures and cited stability fields)"],"form":"","formula":"BaTiO3","identity":"known_phase","known_phases":[{"ids":["cod:4124842"],"name":"cubic BaTiO3"},{"ids":["cod:2009488"],"name":"hexagonal BaTiO3"},{"ids":["cod:9014492"],"name":"orthorhombic BaTiO3"},{"ids":["cod:9014074"],"name":"rhombohedral BaTiO3"},{"ids":["cod:1513252"],"name":"tetragonal BaTiO3"}],"missing":["Materials Project energies (no key; never decisive for polymorphs)"],"novelty":"found in Perov-5 dataset (18,928 materials) by Matter's check (reduced formula and A|B|X site assignment): material 14809, in the training split","phase":"cubic BaTiO3"},"evidence":"n/a","execution":"completed","kind":"target","lab":null,"label":"BaTiO3, cubic BaTiO3","node_id":"target","presentation_only":false,"ref":"target.json#target","science":"known phase","stage":"M01"},{"children":[],"detail":{"findings":[],"rules":["R-G1-INPUT-001"]},"evidence":"n/a","execution":"completed","kind":"claim","lab":null,"label":"Gate G1: PASS","node_id":"gate:G1","presentation_only":false,"ref":"target.json#gates/G1","science":"PASS","stage":"M01"},{"children":[],"detail":{"findings":[{"code":"POLYMORPH_MISMATCH","message":"cubic BaTiO3 is stable only above about 130 °C (cited); at room temperature the measured structure is tetragonal BaTiO3 (P4mm, cod:1513252)","rule":"R-M01-PHASE-001"},{"code":"STABILITY_UNKNOWN","message":"Matter's ladder stage 1 (Stage 1 · Chemistry checked): the candidate structure is prototype placement, its stability is not assessed","rule":"R-M01-ID-002"},{"code":"KNOWN_COMPOUND","message":"BaTiO3 is a known compound: cubic BaTiO3 is a measured structure (cod:4124842)","rule":"R-M01-ID-002"}],"rules":["R-G2-ID-001","R-M01-ID-001","R-M01-PHASE-001"]},"evidence":"n/a","execution":"completed","kind":"claim","lab":null,"label":"Gate G2: PASS","node_id":"gate:G2","presentation_only":false,"ref":"target.json#gates/G2","science":"PASS","stage":"M01"},{"children":["hazard:target:BaTiO3"],"detail":{"findings":[{"code":"HAZARD_UNKNOWN","message":"BaTiO3 (BaTiO3, product): no classification found; a person decides at G7"},{"code":"HAZARD_UNKNOWN","message":"no reagent of this route is known, so their hazards are unknown; a person decides at G7"}],"what":"what handling the material demands; not a route verdict"},"evidence":"n/a","execution":"completed","kind":"hazard","lab":null,"label":"Handling the product (gate S on it alone): UNKNOWN","node_id":"gateS:target","presentation_only":false,"ref":"safety/target.json#gate","science":"UNKNOWN","stage":"M01"},{"children":[],"detail":{"codes":[],"demands":[],"harmonised":false,"pubchem_cid":null,"url":null},"evidence":"missing","execution":"completed","kind":"hazard","lab":null,"label":"BaTiO3 (BaTiO3): no classification found","node_id":"hazard:target:BaTiO3","presentation_only":false,"ref":"safety/target.json#substances/BaTiO3","science":null,"stage":"M01"},{"children":[],"detail":{"code":"NO_SUPPORTED_FAMILY","message":"no route for BaTiO3 in the families Mat2Bot (milestone 1) plans (documented here: none in the evidence set); not planned rather than planned weakly","rule":"R-M03-SCOPE-001","severity":"warning","subject":"BaTiO3"},"evidence":"n/a","execution":"refused","kind":"finding","lab":null,"label":"no route for BaTiO3 in the families Mat2Bot (milestone 1) plans (documented here: none in the evidence set); not planned rather than planned weakly","node_id":"finding:0","presentation_only":false,"ref":"plan.json#findings/0","science":null,"stage":"M04"},{"children":["target","gate:G1","gate:G2","gateS:target","hazard:target:BaTiO3"],"detail":{"events":[1,4],"how":"","message":"BaTiO3: identity known phase, phase cubic BaTiO3; gates G1 PASS, G2 PASS; gate S on the product alone: UNKNOWN; BaTiO3 no classification found"},"evidence":"n/a","execution":"completed","kind":"stage","lab":null,"label":"Target","node_id":"stage:M01","presentation_only":false,"ref":"trace.json#events/M01","science":null,"stage":"M01"},{"children":[],"detail":{"events":[2],"how":"","message":"no synthesis precedent of this composition in the evidence"},"evidence":"n/a","execution":"completed","kind":"stage","lab":null,"label":"Evidence","node_id":"stage:M02","presentation_only":false,"ref":"trace.json#events/M02","science":null,"stage":"M02"},{"children":["finding:0"],"detail":{"events":[3],"how":"","message":"no route for BaTiO3 in the families Mat2Bot (milestone 1) plans (documented here: none in the evidence set); not planned rather than planned weakly"},"evidence":"n/a","execution":"refused","kind":"stage","lab":null,"label":"Routes","node_id":"stage:M04","presentation_only":false,"ref":"trace.json#events/M04","science":null,"stage":"M04"},{"children":[],"detail":{"events":[5],"how":"","message":"not reached: no route candidate in Mat2Bot's planned families"},"evidence":"n/a","execution":"skipped","kind":"stage","lab":null,"label":"Science","node_id":"stage:M05","presentation_only":false,"ref":"trace.json#events/M05","science":null,"stage":"M05"},{"children":[],"detail":{"events":[6],"how":"","message":"not reached: no route candidate in Mat2Bot's planned families"},"evidence":"n/a","execution":"skipped","kind":"stage","lab":null,"label":"The case","node_id":"stage:M07","presentation_only":false,"ref":"trace.json#events/M07","science":null,"stage":"M07"},{"children":[],"detail":{"events":[7],"how":"","message":"not reached: no route candidate in Mat2Bot's planned families"},"evidence":"n/a","execution":"skipped","kind":"stage","lab":null,"label":"Procedure","node_id":"stage:M08","presentation_only":false,"ref":"trace.json#events/M08","science":null,"stage":"M08"},{"children":[],"detail":{"events":[8],"how":"","message":"not reached: no route candidate in Mat2Bot's planned families"},"evidence":"n/a","execution":"skipped","kind":"stage","lab":null,"label":"Laboratories","node_id":"stage:LAB","presentation_only":false,"ref":"trace.json#events/LAB","science":null,"stage":"LAB"},{"children":[],"detail":{"events":[],"how":"run `mat2bot audit <package>`; the result never comes from the package itself","message":"the package is audited after it is written: run the auditor, or a live audit fills this column"},"evidence":"n/a","execution":"not_run","kind":"stage","lab":null,"label":"Audit","node_id":"stage:AUDIT","presentation_only":false,"ref":"trace.json#nodes/stage:AUDIT","science":null,"stage":"AUDIT"}],"note":"A projection of the plan's records: every node names the record it shows and every edge a relationship that record holds; nothing here is computed anew. The audit stage is filled only by a live audit.","request_id":"m1","schema":"mat2bot/trace/1","title":"A MEIDNet-Matter candidate (Perov-5 search, run-LtMoP7Wma4gU-002, BaTiO3)"}</script><script id="trace-config" type="application/json">{"audit_url": "audit.json", "links": {"home": "../../index.html", "report": "report.html", "package": "package.zip"}, "mat2bot": "0.1.0"}</script><div id="trace-app" data-title="A MEIDNet-Matter candidate (Perov-5 search, run-LtMoP7Wma4gU-002, BaTiO3)"></div><script>/* Mat2Bot Trace viewer: a
|
| 138 |
-
it), a components view (a stage's records as cards with their typed edges) and a provenance panel (one record),
|
| 139 |
over trace.json and nothing else. Every drawn node is a node of the trace and every drawn line an edge of it; the
|
| 140 |
audit column is filled only from a live audit the host gives (config.audit_url or config.audit). Plain JS, no library.
|
| 141 |
Standalone (trace.html) it keeps its place in the address bar; embedded (the one-box page) it keeps it in memory. */
|
|
@@ -321,6 +338,11 @@ details.tv-timeline summary{cursor:pointer;color:var(--accent);font-size:.95rem;
|
|
| 321 |
return `<div class="tv-map"><svg viewBox="0 0 ${W} ${H}" width="${W}" height="${H}" role="img" aria-label="the stages Mat2Bot ran, with each stage's records"><defs><marker id="arrow" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="8" markerHeight="8" orient="auto-start-reverse"><path d="M0,0 L10,5 L0,10 z"></path></marker></defs>${parts.join("")}</svg></div>` + legend;
|
| 322 |
}
|
| 323 |
// ---------------------------------------------------------------- the graph: every record a circle, every relationship a line
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 324 |
const KIND_COLOR = { target: "#2f5d8a", evidence: "#4e79a7", route: "#59a14f", rival: "#e15759", doubt: "#f28e2b", calculation: "#b07aa1",
|
| 325 |
model_output: "#9c755f", step: "#76b7b2", laboratory: "#edc948", capability: "#bab0ab", hazard: "#ff9da7", claim: "#86bcb6", assumption: "#d4a6c8",
|
| 326 |
finding: "#e15759", grouping: "#bab0ab", inference: "#bab0ab" };
|
|
@@ -329,162 +351,256 @@ details.tv-timeline summary{cursor:pointer;color:var(--accent);font-size:.95rem;
|
|
| 329 |
const KIND_LEGEND = [["target", "the target"], ["evidence", "published record"], ["route", "route proposed"], ["rival", "route set aside"],
|
| 330 |
["claim", "claim"], ["doubt", "doubt"], ["calculation", "number / model"], ["step", "recipe step"], ["laboratory", "laboratory"],
|
| 331 |
["hazard", "hazard"], ["capability", "equipment"]];
|
| 332 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 333 |
let VIEWPORT = { k: 1, tx: 0, ty: 0 };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 334 |
function buildGraph() {
|
| 335 |
const cols = {};
|
| 336 |
STAGES.forEach((st, i) => { cols[st] = i; });
|
| 337 |
-
const nodes = T.nodes.filter((n) => n.kind !== "stage").map((n) => ({ id: n.node_id, n, r: KIND_R[n.kind] || 6, col: cols[n.stage] ?? 0, hub: false }));
|
| 338 |
-
STAGES.filter((st) => STAGE_NODE[st]).forEach((st) => nodes.push({ id: "stage:" + st, n: STAGE_NODE[st], r: 17, col: cols[st], hub: true }));
|
| 339 |
const byId = new Map(nodes.map((d) => [d.id, d]));
|
| 340 |
const links = [];
|
| 341 |
T.edges.forEach((e) => { if (byId.has(e.source) && byId.has(e.target)) links.push({ s: byId.get(e.source), t: byId.get(e.target), kind: e.kind, label: e.label }); });
|
| 342 |
STAGES.forEach((st) => { const hub = byId.get("stage:" + st); if (!hub) return; topLevel(st).forEach((n) => { const d = byId.get(n.node_id); if (d) links.push({ s: hub, t: d, kind: "member" }); }); });
|
| 343 |
T.nodes.forEach((n) => { if (NESTING.includes(n.kind)) n.children.forEach((c) => { const a = byId.get(n.node_id), b = byId.get(c); if (a && b) links.push({ s: a, t: b, kind: "member" }); }); });
|
| 344 |
-
const
|
| 345 |
-
|
|
|
|
|
|
|
|
|
|
| 346 |
let seed = 7;
|
| 347 |
const rnd = () => { seed = (seed * 9301 + 49297) % 233280; return seed / 233280; };
|
| 348 |
-
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
|
| 356 |
-
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
|
| 360 |
-
|
| 361 |
-
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 365 |
}
|
| 366 |
-
links.forEach((l) => {
|
| 367 |
-
const dx = l.t.x - l.s.x, dy = l.t.y - l.s.y;
|
| 368 |
-
const d = Math.sqrt(dx * dx + dy * dy) || 1;
|
| 369 |
-
const want = l.kind === "member" ? 58 : 84;
|
| 370 |
-
const f = (d - want) * (kLink[l.kind] || 0.03);
|
| 371 |
-
l.s.vx += (dx / d) * f; l.s.vy += (dy / d) * f; l.t.vx -= (dx / d) * f; l.t.vy -= (dy / d) * f;
|
| 372 |
-
});
|
| 373 |
-
nodes.forEach((d) => {
|
| 374 |
-
d.vx += (colX(d.col) - d.x) * (d.hub ? 0.16 : 0.03); // the flow from left to right is kept
|
| 375 |
-
d.vy += (H / 2 - d.y) * 0.004;
|
| 376 |
-
const sp = Math.sqrt(d.vx * d.vx + d.vy * d.vy) || 1;
|
| 377 |
-
const cap = 12 * temp + 1;
|
| 378 |
-
const k = Math.min(sp, cap) / sp;
|
| 379 |
-
d.x += d.vx * k; d.y += d.vy * k; d.vx *= 0.4; d.vy *= 0.4;
|
| 380 |
-
});
|
| 381 |
}
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
|
| 386 |
-
|
| 387 |
-
|
| 388 |
-
|
| 389 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 390 |
}
|
| 391 |
-
|
| 392 |
-
const box = { x0: Math.min(...xs) - 40, y0: Math.min(...ys) - 30, x1: Math.max(...xs) + 40, y1: Math.max(...ys) + 30 };
|
| 393 |
-
return { nodes, links, byId, W, H, box };
|
| 394 |
}
|
| 395 |
-
function
|
| 396 |
-
|
| 397 |
-
|
| 398 |
-
|
| 399 |
}
|
| 400 |
-
function gLabel(d) {
|
| 401 |
-
|
| 402 |
-
if (
|
| 403 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 404 |
}
|
| 405 |
function graphView(s) {
|
| 406 |
-
|
| 407 |
-
|
| 408 |
-
const sel = s.node || "";
|
| 409 |
-
|
| 410 |
-
|
| 411 |
-
|
| 412 |
-
|
| 413 |
-
|
| 414 |
-
const
|
| 415 |
-
const
|
| 416 |
-
return `<
|
| 417 |
}).join("");
|
| 418 |
-
const
|
| 419 |
-
|
| 420 |
-
|
| 421 |
-
|
| 422 |
-
|
| 423 |
-
<title>${esc(d.n.label)}</title><circle r="${d.r}" style="fill:${d.hub ? "var(--head)" : KIND_COLOR[d.n.kind] || "#999"}"></circle>
|
| 424 |
-
<text class="gt" y="${d.r + 12}">${esc(gLabel(d))}</text></g>`;
|
| 425 |
}).join("");
|
|
|
|
|
|
|
| 426 |
const legend = KIND_LEGEND.map(([k, w]) => `<span><i style="background:${KIND_COLOR[k]}"></i> ${esc(w)}</span>`).join("") +
|
| 427 |
-
`<span><i class="ring ok"></i> holds</span><span><i class="ring warn"></i> open / caveat</span><span><i class="ring bad"></i> fails / rejected</span>`
|
| 428 |
-
|
|
|
|
|
|
|
|
|
|
| 429 |
<button type="button" data-gzoom="in" aria-label="zoom in">+</button><button type="button" data-gzoom="out" aria-label="zoom out">−</button>
|
| 430 |
-
<button type="button" data-gfit="1">Fit</button><button type="button" data-glabels="1">Labels</button>
|
| 431 |
-
|
| 432 |
-
<
|
|
|
|
| 433 |
<g class="world" transform="translate(${VIEWPORT.tx},${VIEWPORT.ty}) scale(${VIEWPORT.k})">${clouds}${lines}${circles}</g></svg></div>
|
| 434 |
-
<p class="tv-legend tv-glegend">${legend}<
|
| 435 |
}
|
| 436 |
function wireGraph() {
|
| 437 |
-
|
| 438 |
-
if (!
|
| 439 |
-
const svg =
|
| 440 |
-
|
| 441 |
-
|
| 442 |
-
|
| 443 |
-
|
| 444 |
-
|
| 445 |
-
|
| 446 |
-
const
|
| 447 |
-
|
| 448 |
-
|
| 449 |
app.querySelectorAll("[data-gzoom]").forEach((b) => b.addEventListener("click", () => zoomAt({ x: g.W / 2, y: g.H / 2 }, b.dataset.gzoom === "in" ? 1.4 : 1 / 1.4)));
|
|
|
|
|
|
|
| 450 |
svg.addEventListener("pointerdown", (ev) => {
|
| 451 |
touches.set(ev.pointerId, pt(ev));
|
| 452 |
if (touches.size === 2) { const [a, b] = [...touches.values()]; pinch = { d: Math.hypot(a.x - b.x, a.y - b.y), k: VIEWPORT.k }; drag = null; return; }
|
| 453 |
-
const gn = ev.target.closest("g.gn")
|
| 454 |
drag = { x: p.x, y: p.y, node: gn ? g.byId.get(gn.dataset.gnode) : null, moved: false, tx: VIEWPORT.tx, ty: VIEWPORT.ty };
|
| 455 |
svg.setPointerCapture(ev.pointerId);
|
| 456 |
});
|
| 457 |
svg.addEventListener("pointermove", (ev) => {
|
| 458 |
if (touches.has(ev.pointerId)) touches.set(ev.pointerId, pt(ev));
|
| 459 |
-
if (pinch && touches.size === 2) { const [a, b] = [...touches.values()]; const d = Math.hypot(a.x - b.x, a.y - b.y) || 1;
|
| 460 |
if (!drag) return;
|
| 461 |
-
const p = pt(ev);
|
| 462 |
-
const dx = p.x - drag.x, dy = p.y - drag.y;
|
| 463 |
if (Math.abs(dx) + Math.abs(dy) > 3) drag.moved = true;
|
| 464 |
if (drag.node) {
|
| 465 |
-
|
| 466 |
const d = drag.node;
|
| 467 |
-
|
| 468 |
-
|
| 469 |
-
|
| 470 |
-
} else { VIEWPORT = { ...VIEWPORT, tx: drag.tx + dx, ty: drag.ty + dy }; apply(); }
|
| 471 |
});
|
| 472 |
const endDrag = (ev) => {
|
| 473 |
touches.delete(ev.pointerId);
|
| 474 |
if (touches.size < 2) pinch = null;
|
| 475 |
if (!drag) return;
|
| 476 |
const d = drag; drag = null;
|
| 477 |
-
if (
|
|
|
|
| 478 |
};
|
| 479 |
svg.addEventListener("pointerup", endDrag); svg.addEventListener("pointercancel", endDrag);
|
| 480 |
-
svg.addEventListener("dblclick", () => {
|
| 481 |
-
const neighbours = (id) => { const set = new Set([id]);
|
| 482 |
svg.addEventListener("pointerover", (ev) => { const gn = ev.target.closest("g.gn"); if (!gn || drag) return; const near = neighbours(gn.dataset.gnode);
|
| 483 |
-
|
| 484 |
-
|
| 485 |
-
svg.addEventListener("pointerout", (ev) => { if (ev.target.closest("g.gn") && !drag) {
|
| 486 |
const find = app.querySelector("#tv-find");
|
| 487 |
-
if (find)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 488 |
}
|
| 489 |
function overview(s) {
|
| 490 |
if (s.view !== "flow") return graphView(s) + `<details class="tv-timeline"><summary>What ran, in order (${T.events.length} events)</summary><ol class="tv-events">${T.events.map((e) => `<li class="${e.status}"><span class="seq">${e.seq}</span><span>${esc(e.stage)}</span><span>${esc(e.name)}${e.subject ? ` <small>(${esc(e.subject)})</small>` : ""}<span class="msg">${esc(e.message)}</span></span>${chip("execution", e.status)}</li>`).join("")}</ol></details>`;
|
|
@@ -634,11 +750,14 @@ details.tv-timeline summary{cursor:pointer;color:var(--accent);font-size:.95rem;
|
|
| 634 |
}
|
| 635 |
}
|
| 636 |
app.addEventListener("click", (ev) => {
|
| 637 |
-
const b = ev.target.closest("[data-tab],[data-stage],[data-node],[data-why],[data-open],[data-cmp],[data-cmp-clear],[data-close],[data-gfit],[data-glabels],a[href^='#']");
|
| 638 |
if (!b || !app.contains(b)) return;
|
| 639 |
const s = state();
|
| 640 |
if (b.dataset.tab != null) { ev.preventDefault(); if (b.dataset.tab === "") go({}); else if (b.dataset.tab === "__flow") go({ view: "flow" }); else if (b.dataset.tab === "__comp") go({ stage: s.stage || STAGES[0], cmp: s.cmp }); else go({ stage: s.stage || (s.node ? NODES.get(s.node).stage : STAGES[0]), node: s.node || ((STAGE_NODE[s.stage || STAGES[0]] || { children: [] }).children[0] || "target"), cmp: s.cmp }); return; }
|
| 641 |
-
if (b.dataset.gfit) { if (
|
|
|
|
|
|
|
|
|
|
| 642 |
if (b.dataset.glabels) { const box = app.querySelector("#tv-graph"); if (box) box.classList.toggle("all-labels"); return; }
|
| 643 |
if (b.dataset.stage) { ev.preventDefault(); go({ stage: b.dataset.stage }); return; }
|
| 644 |
if (b.dataset.node) { ev.preventDefault(); go({ stage: s.stage, node: b.dataset.node, cmp: s.cmp }); return; }
|
|
@@ -653,8 +772,8 @@ details.tv-timeline summary{cursor:pointer;color:var(--accent);font-size:.95rem;
|
|
| 653 |
app.addEventListener("mouseover", (ev) => { const c = ev.target.closest(".tv-card"); if (c) highlight(c.dataset.id, true); });
|
| 654 |
app.addEventListener("mouseout", (ev) => { const c = ev.target.closest(".tv-card"); if (c && c.dataset.id !== state().node) highlight(c.dataset.id, false); });
|
| 655 |
if (!EMBEDDED) window.addEventListener("hashchange", render);
|
| 656 |
-
window.addEventListener("resize", () => requestAnimationFrame(() => {
|
| 657 |
-
document.addEventListener("keydown", (ev) => { if (ev.key ==
|
| 658 |
render();
|
| 659 |
if (CFG.audit_url && !AUDIT) {
|
| 660 |
fetch(CFG.audit_url, { cache: "no-store" }).then((r) => (r.ok ? r.json() : null)).then((a) => {
|
|
|
|
| 113 |
.tv-graph-bar button{border:1px solid var(--line);background:var(--card);color:var(--fg);border-radius:999px;padding:.35em .9em}
|
| 114 |
.tv-hint{font-size:.84rem;color:var(--muted);flex-basis:100%}
|
| 115 |
.tv-graph{border:1px solid var(--line);border-radius:var(--radius);background:var(--card);overflow:hidden;touch-action:none;cursor:grab}
|
| 116 |
+
.tv-graph:active{cursor:grabbing}.tv-graph svg{display:block;font:11px/1.2 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif}
|
| 117 |
+
.tv-graph line,.tv-graph circle{vector-effect:non-scaling-stroke}
|
| 118 |
.tv-graph line.gl{stroke:var(--line);stroke-width:1.2;opacity:.9}
|
| 119 |
.tv-graph line.member{stroke:var(--line);stroke-width:1;opacity:.5}
|
| 120 |
.tv-graph line.supported_by,.tv-graph line.computed_from,.tv-graph line.cites{stroke:var(--accent)}
|
|
|
|
| 126 |
.tv-graph g.gn.tone-ok circle{stroke:var(--ok)}.tv-graph g.gn.tone-warn circle{stroke:var(--warn)}.tv-graph g.gn.tone-bad circle{stroke:var(--bad)}
|
| 127 |
.tv-graph g.gn.tone-off circle{stroke:var(--off);stroke-dasharray:3 2;opacity:.7}
|
| 128 |
.tv-graph g.gn.hub circle{stroke:var(--accent);stroke-width:2.5}
|
| 129 |
+
.tv-graph g.gn text.gt{fill:var(--fg);text-anchor:middle;pointer-events:none;opacity:0;font-size:1em;paint-order:stroke;stroke:var(--card);stroke-width:.28em;stroke-linejoin:round}
|
| 130 |
+
.tv-graph g.gn.hub text.gt{font-weight:700;font-size:1.18em;opacity:1}
|
| 131 |
.tv-graph g.gn.lbl-always text.gt,.tv-graph.zoomed g.gn text.gt,.tv-graph.all-labels g.gn text.gt,.tv-graph g.gn:hover text.gt,.tv-graph g.gn.sel text.gt,.tv-graph g.gn.found text.gt{opacity:1}
|
| 132 |
.tv-graph g.gn.dim{opacity:.18}.tv-graph g.gn.sel circle{stroke:var(--accent);stroke-width:4}
|
| 133 |
.tv-graph g.gn.found circle{stroke:var(--accent);stroke-width:4}
|
| 134 |
.tv-glegend span{display:inline-flex;align-items:center;gap:.3em}.tv-glegend i{display:inline-block;width:12px;height:12px;border-radius:50%;border:0}
|
| 135 |
.tv-glegend i.ring{background:transparent;border:3px solid var(--ok)}.tv-glegend i.ring.warn{border-color:var(--warn)}.tv-glegend i.ring.bad{border-color:var(--bad)}.tv-glegend i.ring.off{border-color:var(--off);border-style:dashed}
|
| 136 |
+
.tv-stages{display:flex;flex-wrap:wrap;gap:.4em;align-items:center;margin:0 0 .4em}
|
| 137 |
+
.tv-chip{border:1px solid var(--line);background:var(--card);color:var(--fg);border-radius:999px;padding:.25em .8em;font-size:.92em}
|
| 138 |
+
.tv-chip b{font-weight:600;color:var(--muted);margin-left:.15em}.tv-chip.open{border-color:var(--accent)}
|
| 139 |
+
.tv-chip.focus{background:var(--accent);color:var(--card);border-color:var(--accent)}.tv-chip.focus b{color:var(--card)}
|
| 140 |
+
.tv-focus{font-size:.9em;color:var(--muted);margin-left:.4em}
|
| 141 |
+
p.tv-hint{font-size:.9em;color:var(--muted);margin:0 0 .5em}
|
| 142 |
+
.tv-graph line.flow{stroke:var(--accent);stroke-dasharray:1 6;stroke-linecap:round;opacity:.55;stroke-width:2}
|
| 143 |
+
.tv-graph line.bundle{opacity:.6}.tv-graph line.far{opacity:.12}
|
| 144 |
+
.tv-graph g.gn.hub text.cnt{fill:var(--fg);text-anchor:middle;font-size:1em;font-weight:700;pointer-events:none}
|
| 145 |
+
.tv-graph g.gn.hub.open circle{fill:var(--accent)!important}.tv-graph g.gn.hub.open text.cnt{fill:var(--card)}
|
| 146 |
+
.tv-graph g.gn.far{opacity:.3}.tv-graph.focus g.gn.near text.gt,.tv-graph.few g.gn text.gt{opacity:1}.tv-graph.focus g.gn.far:not(.hub) text.gt{opacity:0}
|
| 147 |
+
.tv-graph ellipse.cloud.focus{opacity:.16}
|
| 148 |
+
.tv-glegend i.ln{display:inline-block;width:1.4em;height:0;border-top:2px dotted var(--accent);vertical-align:middle;margin-right:.3em}
|
| 149 |
+
.tv-glegend i.ln.bundle{border-top:3px solid var(--line)}
|
| 150 |
+
.tv-fullpage{position:fixed;inset:0;z-index:1000;background:var(--bg);padding:12px 16px;overflow:auto;box-sizing:border-box}
|
| 151 |
+
.tv-noscroll{overflow:hidden}
|
| 152 |
.tv-graph ellipse.cloud{fill:var(--accent);opacity:.07;stroke:none}.tv-graph ellipse.cloud.c1{fill:var(--ok)}.tv-graph ellipse.cloud.c2{fill:var(--warn)}.tv-graph ellipse.cloud.c3{fill:#b07aa1}
|
| 153 |
@media (prefers-color-scheme:dark){:root:not([data-theme="light"]) .tv-graph ellipse.cloud{opacity:.12}}
|
| 154 |
+
</style></head><body><script id="trace" type="application/json">{"edges":[],"events":[{"ended":"2026-10-26T00:00:00.000+00:00","message":"BaTiO3: identity known phase, phase cubic BaTiO3; gates G1 PASS, G2 PASS","name":"target intake","seq":1,"stage":"M01","started":"2026-10-26T00:00:00.000+00:00","status":"completed","subject":"m1"},{"ended":"2026-10-26T00:00:00.000+00:00","message":"no synthesis precedent of this composition in the evidence","name":"families and precedents","seq":2,"stage":"M02","started":"2026-10-26T00:00:00.000+00:00","status":"completed","subject":"BaTiO3"},{"ended":"2026-10-26T00:00:00.000+00:00","message":"no route for BaTiO3 in the families Mat2Bot (milestone 1) plans (documented here: none in the evidence set); not planned rather than planned weakly","name":"route candidates","seq":3,"stage":"M04","started":"2026-10-26T00:00:00.000+00:00","status":"refused","subject":"BaTiO3"},{"ended":"2026-10-26T00:00:00.000+00:00","message":"gate S on the product alone: UNKNOWN; BaTiO3 no classification found","name":"the product's own hazards (handling only)","seq":4,"stage":"M01","started":"2026-10-26T00:00:00.000+00:00","status":"completed","subject":"BaTiO3"},{"ended":"2026-10-26T00:00:00.000+00:00","message":"not reached: no route candidate in Mat2Bot's planned families","name":"feasibility","seq":5,"stage":"M05","started":"2026-10-26T00:00:00.000+00:00","status":"skipped","subject":"BaTiO3"},{"ended":"2026-10-26T00:00:00.000+00:00","message":"not reached: no route candidate in Mat2Bot's planned families","name":"route cases and ranking","seq":6,"stage":"M07","started":"2026-10-26T00:00:00.000+00:00","status":"skipped","subject":"BaTiO3"},{"ended":"2026-10-26T00:00:00.000+00:00","message":"not reached: no route candidate in Mat2Bot's planned families","name":"procedure","seq":7,"stage":"M08","started":"2026-10-26T00:00:00.000+00:00","status":"skipped","subject":"BaTiO3"},{"ended":"2026-10-26T00:00:00.000+00:00","message":"not reached: no route candidate in Mat2Bot's planned families","name":"laboratories","seq":8,"stage":"LAB","started":"2026-10-26T00:00:00.000+00:00","status":"skipped","subject":"BaTiO3"}],"layout":{"columns":["M01","M02","M04","M05","M07","M08","LAB","AUDIT"],"rows":{"finding:0":0,"gate:G1":1,"gate:G2":2,"gateS:target":3,"hazard:target:BaTiO3":4,"target":0}},"nodes":[{"children":["gate:G1","gate:G2","gateS:target"],"detail":{"checked_against":["the Mat2Bot v0.1 polymorph registry (KCl, CaCO3, ZnO, BaTiO3, and the ZnO competitors Zn(OH)2 and Zn5(OH)8(NO3)2(H2O)2; COD structures and cited stability fields)"],"form":"","formula":"BaTiO3","identity":"known_phase","known_phases":[{"ids":["cod:4124842"],"name":"cubic BaTiO3"},{"ids":["cod:2009488"],"name":"hexagonal BaTiO3"},{"ids":["cod:9014492"],"name":"orthorhombic BaTiO3"},{"ids":["cod:9014074"],"name":"rhombohedral BaTiO3"},{"ids":["cod:1513252"],"name":"tetragonal BaTiO3"}],"missing":["Materials Project energies (no key; never decisive for polymorphs)"],"novelty":"found in Perov-5 dataset (18,928 materials) by Matter's check (reduced formula and A|B|X site assignment): material 14809, in the training split","phase":"cubic BaTiO3"},"evidence":"n/a","execution":"completed","kind":"target","lab":null,"label":"BaTiO3, cubic BaTiO3","node_id":"target","presentation_only":false,"ref":"target.json#target","science":"known phase","stage":"M01"},{"children":[],"detail":{"findings":[],"rules":["R-G1-INPUT-001"]},"evidence":"n/a","execution":"completed","kind":"claim","lab":null,"label":"Gate G1: PASS","node_id":"gate:G1","presentation_only":false,"ref":"target.json#gates/G1","science":"PASS","stage":"M01"},{"children":[],"detail":{"findings":[{"code":"POLYMORPH_MISMATCH","message":"cubic BaTiO3 is stable only above about 130 °C (cited); at room temperature the measured structure is tetragonal BaTiO3 (P4mm, cod:1513252)","rule":"R-M01-PHASE-001"},{"code":"STABILITY_UNKNOWN","message":"Matter's ladder stage 1 (Stage 1 · Chemistry checked): the candidate structure is prototype placement, its stability is not assessed","rule":"R-M01-ID-002"},{"code":"KNOWN_COMPOUND","message":"BaTiO3 is a known compound: cubic BaTiO3 is a measured structure (cod:4124842)","rule":"R-M01-ID-002"}],"rules":["R-G2-ID-001","R-M01-ID-001","R-M01-PHASE-001"]},"evidence":"n/a","execution":"completed","kind":"claim","lab":null,"label":"Gate G2: PASS","node_id":"gate:G2","presentation_only":false,"ref":"target.json#gates/G2","science":"PASS","stage":"M01"},{"children":["hazard:target:BaTiO3"],"detail":{"findings":[{"code":"HAZARD_UNKNOWN","message":"BaTiO3 (BaTiO3, product): no classification found; a person decides at G7"},{"code":"HAZARD_UNKNOWN","message":"no reagent of this route is known, so their hazards are unknown; a person decides at G7"}],"what":"what handling the material demands; not a route verdict"},"evidence":"n/a","execution":"completed","kind":"hazard","lab":null,"label":"Handling the product (gate S on it alone): UNKNOWN","node_id":"gateS:target","presentation_only":false,"ref":"safety/target.json#gate","science":"UNKNOWN","stage":"M01"},{"children":[],"detail":{"codes":[],"demands":[],"harmonised":false,"pubchem_cid":null,"url":null},"evidence":"missing","execution":"completed","kind":"hazard","lab":null,"label":"BaTiO3 (BaTiO3): no classification found","node_id":"hazard:target:BaTiO3","presentation_only":false,"ref":"safety/target.json#substances/BaTiO3","science":null,"stage":"M01"},{"children":[],"detail":{"code":"NO_SUPPORTED_FAMILY","message":"no route for BaTiO3 in the families Mat2Bot (milestone 1) plans (documented here: none in the evidence set); not planned rather than planned weakly","rule":"R-M03-SCOPE-001","severity":"warning","subject":"BaTiO3"},"evidence":"n/a","execution":"refused","kind":"finding","lab":null,"label":"no route for BaTiO3 in the families Mat2Bot (milestone 1) plans (documented here: none in the evidence set); not planned rather than planned weakly","node_id":"finding:0","presentation_only":false,"ref":"plan.json#findings/0","science":null,"stage":"M04"},{"children":["target","gate:G1","gate:G2","gateS:target","hazard:target:BaTiO3"],"detail":{"events":[1,4],"how":"","message":"BaTiO3: identity known phase, phase cubic BaTiO3; gates G1 PASS, G2 PASS; gate S on the product alone: UNKNOWN; BaTiO3 no classification found"},"evidence":"n/a","execution":"completed","kind":"stage","lab":null,"label":"Target","node_id":"stage:M01","presentation_only":false,"ref":"trace.json#events/M01","science":null,"stage":"M01"},{"children":[],"detail":{"events":[2],"how":"","message":"no synthesis precedent of this composition in the evidence"},"evidence":"n/a","execution":"completed","kind":"stage","lab":null,"label":"Evidence","node_id":"stage:M02","presentation_only":false,"ref":"trace.json#events/M02","science":null,"stage":"M02"},{"children":["finding:0"],"detail":{"events":[3],"how":"","message":"no route for BaTiO3 in the families Mat2Bot (milestone 1) plans (documented here: none in the evidence set); not planned rather than planned weakly"},"evidence":"n/a","execution":"refused","kind":"stage","lab":null,"label":"Routes","node_id":"stage:M04","presentation_only":false,"ref":"trace.json#events/M04","science":null,"stage":"M04"},{"children":[],"detail":{"events":[5],"how":"","message":"not reached: no route candidate in Mat2Bot's planned families"},"evidence":"n/a","execution":"skipped","kind":"stage","lab":null,"label":"Science","node_id":"stage:M05","presentation_only":false,"ref":"trace.json#events/M05","science":null,"stage":"M05"},{"children":[],"detail":{"events":[6],"how":"","message":"not reached: no route candidate in Mat2Bot's planned families"},"evidence":"n/a","execution":"skipped","kind":"stage","lab":null,"label":"The case","node_id":"stage:M07","presentation_only":false,"ref":"trace.json#events/M07","science":null,"stage":"M07"},{"children":[],"detail":{"events":[7],"how":"","message":"not reached: no route candidate in Mat2Bot's planned families"},"evidence":"n/a","execution":"skipped","kind":"stage","lab":null,"label":"Procedure","node_id":"stage:M08","presentation_only":false,"ref":"trace.json#events/M08","science":null,"stage":"M08"},{"children":[],"detail":{"events":[8],"how":"","message":"not reached: no route candidate in Mat2Bot's planned families"},"evidence":"n/a","execution":"skipped","kind":"stage","lab":null,"label":"Laboratories","node_id":"stage:LAB","presentation_only":false,"ref":"trace.json#events/LAB","science":null,"stage":"LAB"},{"children":[],"detail":{"events":[],"how":"run `mat2bot audit <package>`; the result never comes from the package itself","message":"the package is audited after it is written: run the auditor, or a live audit fills this column"},"evidence":"n/a","execution":"not_run","kind":"stage","lab":null,"label":"Audit","node_id":"stage:AUDIT","presentation_only":false,"ref":"trace.json#nodes/stage:AUDIT","science":null,"stage":"AUDIT"}],"note":"A projection of the plan's records: every node names the record it shows and every edge a relationship that record holds; nothing here is computed anew. The audit stage is filled only by a live audit.","request_id":"m1","schema":"mat2bot/trace/1","title":"A MEIDNet-Matter candidate (Perov-5 search, run-LtMoP7Wma4gU-002, BaTiO3)"}</script><script id="trace-config" type="application/json">{"audit_url": "audit.json", "links": {"home": "../../index.html", "report": "report.html", "package": "package.zip"}, "mat2bot": "0.1.0"}</script><div id="trace-app" data-title="A MEIDNet-Matter candidate (Perov-5 search, run-LtMoP7Wma4gU-002, BaTiO3)"></div><script>/* Mat2Bot Trace viewer: a knowledge graph of the plan's records (folded to the stages at first, each opening on a
|
| 155 |
+
click), a flow map (the stages with arrows, each stage's branches under it), a components view (a stage's records as cards with their typed edges) and a provenance panel (one record),
|
| 156 |
over trace.json and nothing else. Every drawn node is a node of the trace and every drawn line an edge of it; the
|
| 157 |
audit column is filled only from a live audit the host gives (config.audit_url or config.audit). Plain JS, no library.
|
| 158 |
Standalone (trace.html) it keeps its place in the address bar; embedded (the one-box page) it keeps it in memory. */
|
|
|
|
| 338 |
return `<div class="tv-map"><svg viewBox="0 0 ${W} ${H}" width="${W}" height="${H}" role="img" aria-label="the stages Mat2Bot ran, with each stage's records"><defs><marker id="arrow" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="8" markerHeight="8" orient="auto-start-reverse"><path d="M0,0 L10,5 L0,10 z"></path></marker></defs>${parts.join("")}</svg></div>` + legend;
|
| 339 |
}
|
| 340 |
// ---------------------------------------------------------------- the graph: every record a circle, every relationship a line
|
| 341 |
+
// It starts folded: the stages (big circles, the number inside counts their records), the target, the routes, the
|
| 342 |
+
// laboratories and the findings. A stage opens on click (its records spring out of it) and the view zooms in on it.
|
| 343 |
+
// Lines between folded records are bundled into one thicker line between their stages. The layout is a live
|
| 344 |
+
// simulation (repulsion, springs on the links, a pull toward each stage's column so the whole still flows from the
|
| 345 |
+
// target on the left to the audit on the right); dragging a circle pulls its neighbours.
|
| 346 |
const KIND_COLOR = { target: "#2f5d8a", evidence: "#4e79a7", route: "#59a14f", rival: "#e15759", doubt: "#f28e2b", calculation: "#b07aa1",
|
| 347 |
model_output: "#9c755f", step: "#76b7b2", laboratory: "#edc948", capability: "#bab0ab", hazard: "#ff9da7", claim: "#86bcb6", assumption: "#d4a6c8",
|
| 348 |
finding: "#e15759", grouping: "#bab0ab", inference: "#bab0ab" };
|
|
|
|
| 351 |
const KIND_LEGEND = [["target", "the target"], ["evidence", "published record"], ["route", "route proposed"], ["rival", "route set aside"],
|
| 352 |
["claim", "claim"], ["doubt", "doubt"], ["calculation", "number / model"], ["step", "recipe step"], ["laboratory", "laboratory"],
|
| 353 |
["hazard", "hazard"], ["capability", "equipment"]];
|
| 354 |
+
const KEY = ["target", "route", "rival", "laboratory", "finding"]; // shown even while their stage is folded
|
| 355 |
+
const K_LINK = { member: 0.07, flow: 0.004, supported_by: 0.03, computed_from: 0.03, cites: 0.02, refuted_by: 0.03, resolved_by: 0.02,
|
| 356 |
+
rejected_for: 0.04, depends_on: 0.06, mapped_to: 0.015, produced: 0.03, requires_equipment: 0.03 };
|
| 357 |
+
const REDUCED = !!(window.matchMedia && window.matchMedia("(prefers-reduced-motion: reduce)").matches);
|
| 358 |
+
let GRAPH = null; // every record's circle with its position, kept across renders
|
| 359 |
+
let VIS = null; // what is drawn now: the visible circles and the lines between them
|
| 360 |
let VIEWPORT = { k: 1, tx: 0, ty: 0 };
|
| 361 |
+
let VIEW_MODE = "all"; // "all" / "focus": the view follows the layout; "free": the reader moved it
|
| 362 |
+
let OPEN = new Set(), FOCUS = "", FULL = false, HEAT = 1, QUERY = "";
|
| 363 |
+
const SIM = { alpha: 0, raf: 0 };
|
| 364 |
+
let WORLD = null, BOX = null, EL = new Map();
|
| 365 |
+
function graphSize() {
|
| 366 |
+
const W = Math.max(app.clientWidth, 640);
|
| 367 |
+
const H = FULL ? Math.max(window.innerHeight - 230, 400) : Math.max(Math.min(W * 0.62, 760), 440);
|
| 368 |
+
return { W, H };
|
| 369 |
+
}
|
| 370 |
function buildGraph() {
|
| 371 |
const cols = {};
|
| 372 |
STAGES.forEach((st, i) => { cols[st] = i; });
|
| 373 |
+
const nodes = T.nodes.filter((n) => n.kind !== "stage").map((n) => ({ id: n.node_id, n, st: n.stage, r: KIND_R[n.kind] || 6, col: cols[n.stage] ?? 0, hub: false, key: KEY.includes(n.kind) }));
|
| 374 |
+
STAGES.filter((st) => STAGE_NODE[st]).forEach((st) => nodes.push({ id: "stage:" + st, n: STAGE_NODE[st], st, r: 17, col: cols[st], hub: true, key: true }));
|
| 375 |
const byId = new Map(nodes.map((d) => [d.id, d]));
|
| 376 |
const links = [];
|
| 377 |
T.edges.forEach((e) => { if (byId.has(e.source) && byId.has(e.target)) links.push({ s: byId.get(e.source), t: byId.get(e.target), kind: e.kind, label: e.label }); });
|
| 378 |
STAGES.forEach((st) => { const hub = byId.get("stage:" + st); if (!hub) return; topLevel(st).forEach((n) => { const d = byId.get(n.node_id); if (d) links.push({ s: hub, t: d, kind: "member" }); }); });
|
| 379 |
T.nodes.forEach((n) => { if (NESTING.includes(n.kind)) n.children.forEach((c) => { const a = byId.get(n.node_id), b = byId.get(c); if (a && b) links.push({ s: a, t: b, kind: "member" }); }); });
|
| 380 |
+
const hubs = STAGES.map((st) => byId.get("stage:" + st)).filter(Boolean);
|
| 381 |
+
hubs.forEach((h, i) => { if (hubs[i + 1]) links.push({ s: h, t: hubs[i + 1], kind: "flow" }); }); // the stages in the order they ran
|
| 382 |
+
const members = {};
|
| 383 |
+
STAGES.forEach((st) => { members[st] = nodes.filter((d) => !d.hub && d.st === st); });
|
| 384 |
+
const { W, H } = graphSize();
|
| 385 |
let seed = 7;
|
| 386 |
const rnd = () => { seed = (seed * 9301 + 49297) % 233280; return seed / 233280; };
|
| 387 |
+
const g = { nodes, links, byId, members, W, H, rnd, hubOf: (d) => byId.get("stage:" + d.st) || null, colX: (c) => 60 + (c + 0.5) * ((g.W - 120) / STAGES.length) };
|
| 388 |
+
nodes.forEach((d) => { d.x = g.colX(d.col) + (rnd() - 0.5) * 40; d.y = H / 2 + (rnd() - 0.5) * H * (d.hub ? 0.2 : 0.6); d.vx = 0; d.vy = 0; d.fx = null; d.fy = null; });
|
| 389 |
+
return g;
|
| 390 |
+
}
|
| 391 |
+
function shown(d) { return d.hub || d.key || OPEN.has(d.st); }
|
| 392 |
+
function visibleGraph(g) {
|
| 393 |
+
const vnodes = g.nodes.filter(shown), vlinks = [], agg = new Map();
|
| 394 |
+
g.links.forEach((l) => {
|
| 395 |
+
const a = shown(l.s) ? l.s : g.hubOf(l.s), b = shown(l.t) ? l.t : g.hubOf(l.t);
|
| 396 |
+
if (!a || !b || a === b) return;
|
| 397 |
+
if (a === l.s && b === l.t) { vlinks.push({ s: a, t: b, kind: l.kind, label: l.label, n: 1 }); return; }
|
| 398 |
+
if (l.kind === "member") return; // a folded record is inside its stage's circle
|
| 399 |
+
const key = a.id + "\u0000" + b.id + "\u0000" + l.kind, got = agg.get(key);
|
| 400 |
+
if (got) got.n += 1; else agg.set(key, { s: a, t: b, kind: l.kind, n: 1, bundle: true });
|
| 401 |
+
});
|
| 402 |
+
agg.forEach((l) => vlinks.push(l));
|
| 403 |
+
return { vnodes, vlinks };
|
| 404 |
+
}
|
| 405 |
+
function step(g, vis, alpha) {
|
| 406 |
+
const nodes = vis.vnodes, kRep = 1800;
|
| 407 |
+
for (let i = 0; i < nodes.length; i++) {
|
| 408 |
+
const a = nodes[i];
|
| 409 |
+
for (let j = i + 1; j < nodes.length; j++) {
|
| 410 |
+
const b = nodes[j];
|
| 411 |
+
let dx = a.x - b.x, dy = a.y - b.y, d2 = dx * dx + dy * dy;
|
| 412 |
+
if (d2 < 1) { dx = g.rnd() - 0.5; dy = g.rnd() - 0.5; d2 = 1; }
|
| 413 |
+
const d = Math.sqrt(d2), f = (kRep * (a.hub || b.hub ? 2.2 : FOCUS && a.st === FOCUS && b.st === FOCUS ? 1.8 : 1)) / d2;
|
| 414 |
+
dx /= d; dy /= d;
|
| 415 |
+
a.vx += dx * f; a.vy += dy * f; b.vx -= dx * f; b.vy -= dy * f;
|
| 416 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 417 |
}
|
| 418 |
+
vis.vlinks.forEach((l) => {
|
| 419 |
+
const dx = l.t.x - l.s.x, dy = l.t.y - l.s.y, d = Math.sqrt(dx * dx + dy * dy) || 1;
|
| 420 |
+
const want = l.kind === "member" ? (FOCUS && l.t.st === FOCUS && !l.t.hub ? 105 : 62) : l.kind === "flow" ? 150 : 90;
|
| 421 |
+
const f = (d - want) * (K_LINK[l.kind] || 0.03);
|
| 422 |
+
l.s.vx += (dx / d) * f; l.s.vy += (dy / d) * f; l.t.vx -= (dx / d) * f; l.t.vy -= (dy / d) * f;
|
| 423 |
+
});
|
| 424 |
+
nodes.forEach((d) => {
|
| 425 |
+
if (d.fx != null) { d.x = d.fx; d.y = d.fy; d.vx = 0; d.vy = 0; return; }
|
| 426 |
+
d.vx += (g.colX(d.col) - d.x) * (d.hub ? 0.14 : 0.025); // the flow from left to right is kept
|
| 427 |
+
d.vy += (g.H / 2 - d.y) * (d.hub ? 0.02 : 0.004);
|
| 428 |
+
const sp = Math.sqrt(d.vx * d.vx + d.vy * d.vy) || 1, cap = 14 * alpha + 0.5, k = Math.min(sp, cap) / sp;
|
| 429 |
+
d.x += d.vx * k; d.y += d.vy * k; d.vx *= 0.4; d.vy *= 0.4;
|
| 430 |
+
});
|
| 431 |
+
for (let i = 0; i < nodes.length; i++) for (let j = i + 1; j < nodes.length; j++) { // no two circles overlap
|
| 432 |
+
const a = nodes[i], b = nodes[j], dx = b.x - a.x, dy = b.y - a.y, d = Math.sqrt(dx * dx + dy * dy) || 0.01, min = a.r + b.r + 8;
|
| 433 |
+
if (d < min) { const push = (min - d) / 2; if (a.fx == null) { a.x -= (dx / d) * push; a.y -= (dy / d) * push; } if (b.fx == null) { b.x += (dx / d) * push; b.y += (dy / d) * push; } }
|
| 434 |
+
}
|
| 435 |
+
}
|
| 436 |
+
function unfold(st, on) {
|
| 437 |
+
const g = GRAPH, hub = g.byId.get("stage:" + st);
|
| 438 |
+
if (!hub || !g.members[st].length) return;
|
| 439 |
+
if (on && !OPEN.has(st)) { OPEN.add(st); g.members[st].filter((d) => !d.key).forEach((d) => { d.x = hub.x + (g.rnd() - 0.5) * 36; d.y = hub.y + (g.rnd() - 0.5) * 36; d.vx = 0; d.vy = 0; d.fx = null; d.fy = null; }); }
|
| 440 |
+
if (!on) OPEN.delete(st);
|
| 441 |
+
HEAT = 1;
|
| 442 |
+
}
|
| 443 |
+
function boxOf(ds) { const xs = ds.map((d) => d.x), ys = ds.map((d) => d.y); return { x0: Math.min(...xs) - 70, y0: Math.min(...ys) - 24, x1: Math.max(...xs) + 70, y1: Math.max(...ys) + 36 }; }
|
| 444 |
+
function fitTo(box) {
|
| 445 |
+
const g = GRAPH, k = Math.min(g.W / (box.x1 - box.x0 + 40), g.H / (box.y1 - box.y0 + 30), 2.2);
|
| 446 |
+
return { k, tx: (g.W - (box.x0 + box.x1) * k) / 2, ty: (g.H - (box.y0 + box.y1) * k) / 2 };
|
| 447 |
+
}
|
| 448 |
+
function clusterOf(st) { return [GRAPH.byId.get("stage:" + st), ...GRAPH.members[st].filter(shown)].filter(Boolean); }
|
| 449 |
+
function aimView() {
|
| 450 |
+
if (VIEW_MODE === "focus" && FOCUS && GRAPH.byId.has("stage:" + FOCUS)) return fitTo(boxOf(clusterOf(FOCUS)));
|
| 451 |
+
if (VIEW_MODE === "all" && VIS && VIS.vnodes.length) return fitTo(boxOf(VIS.vnodes));
|
| 452 |
+
return null;
|
| 453 |
+
}
|
| 454 |
+
function applyView() {
|
| 455 |
+
if (!WORLD) return;
|
| 456 |
+
WORLD.setAttribute("transform", `translate(${VIEWPORT.tx},${VIEWPORT.ty}) scale(${VIEWPORT.k})`);
|
| 457 |
+
WORLD.style.fontSize = `${Math.min(14, Math.max(6.5, 11 / VIEWPORT.k)).toFixed(2)}px`; // labels keep their size on screen
|
| 458 |
+
if (BOX) BOX.classList.toggle("zoomed", VIEWPORT.k >= 1.5);
|
| 459 |
+
}
|
| 460 |
+
function place() {
|
| 461 |
+
VIS.vnodes.forEach((d) => { const el = EL.get(d.id); if (el) el.setAttribute("transform", `translate(${d.x.toFixed(1)},${d.y.toFixed(1)})`); });
|
| 462 |
+
VIS.vlinks.forEach((l) => { if (!l.el) return; l.el.setAttribute("x1", l.s.x.toFixed(1)); l.el.setAttribute("y1", l.s.y.toFixed(1)); l.el.setAttribute("x2", l.t.x.toFixed(1)); l.el.setAttribute("y2", l.t.y.toFixed(1)); });
|
| 463 |
+
WORLD.querySelectorAll("ellipse.cloud").forEach((c) => {
|
| 464 |
+
const b = boxOf(clusterOf(c.dataset.cloud));
|
| 465 |
+
c.setAttribute("cx", ((b.x0 + b.x1) / 2).toFixed(1)); c.setAttribute("cy", ((b.y0 + b.y1) / 2).toFixed(1));
|
| 466 |
+
c.setAttribute("rx", ((b.x1 - b.x0) / 2 + 8).toFixed(1)); c.setAttribute("ry", ((b.y1 - b.y0) / 2 + 4).toFixed(1));
|
| 467 |
+
});
|
| 468 |
+
}
|
| 469 |
+
function tick() {
|
| 470 |
+
SIM.raf = 0;
|
| 471 |
+
if (!GRAPH || !VIS || !WORLD || !WORLD.isConnected) return;
|
| 472 |
+
let busy = false;
|
| 473 |
+
if (SIM.alpha > 0.012) { step(GRAPH, VIS, SIM.alpha); SIM.alpha *= 0.95; place(); busy = true; }
|
| 474 |
+
const aim = aimView();
|
| 475 |
+
if (aim) {
|
| 476 |
+
const r = REDUCED ? 1 : 0.16;
|
| 477 |
+
VIEWPORT = { k: VIEWPORT.k + (aim.k - VIEWPORT.k) * r, tx: VIEWPORT.tx + (aim.tx - VIEWPORT.tx) * r, ty: VIEWPORT.ty + (aim.ty - VIEWPORT.ty) * r };
|
| 478 |
+
if (Math.abs(aim.k - VIEWPORT.k) > 0.002 || Math.abs(aim.tx - VIEWPORT.tx) > 0.4 || Math.abs(aim.ty - VIEWPORT.ty) > 0.4) busy = true; else VIEWPORT = aim;
|
| 479 |
+
applyView();
|
| 480 |
}
|
| 481 |
+
if (busy) SIM.raf = requestAnimationFrame(tick);
|
|
|
|
|
|
|
| 482 |
}
|
| 483 |
+
function heat(a) {
|
| 484 |
+
SIM.alpha = Math.max(SIM.alpha, a);
|
| 485 |
+
if (REDUCED) { while (SIM.alpha > 0.012) { step(GRAPH, VIS, SIM.alpha); SIM.alpha *= 0.95; } place(); const aim = aimView(); if (aim) VIEWPORT = aim; applyView(); return; }
|
| 486 |
+
if (!SIM.raf) SIM.raf = requestAnimationFrame(tick);
|
| 487 |
}
|
| 488 |
+
function gLabel(d) { return d.hub ? STAGE_WORDS[d.n.stage] || d.n.label : shortLabel(d.n, 22); }
|
| 489 |
+
function toggleStage(st) {
|
| 490 |
+
if (!GRAPH.byId.has("stage:" + st)) return;
|
| 491 |
+
if (FOCUS === st) { unfold(st, false); FOCUS = ""; VIEW_MODE = "all"; } else { unfold(st, true); FOCUS = st; VIEW_MODE = "focus"; }
|
| 492 |
+
render();
|
| 493 |
+
}
|
| 494 |
+
function toggleFull() {
|
| 495 |
+
FULL = !FULL;
|
| 496 |
+
app.classList.toggle("tv-fullpage", FULL);
|
| 497 |
+
document.documentElement.classList.toggle("tv-noscroll", FULL);
|
| 498 |
+
HEAT = Math.max(HEAT, 0.3); VIEW_MODE = FOCUS ? "focus" : "all";
|
| 499 |
+
render();
|
| 500 |
+
if (!FULL) app.scrollIntoView({ block: "nearest" });
|
| 501 |
}
|
| 502 |
function graphView(s) {
|
| 503 |
+
const { W, H } = graphSize();
|
| 504 |
+
if (!GRAPH) { GRAPH = buildGraph(); HEAT = 1; } else if (Math.abs(GRAPH.W - W) > 40 || Math.abs(GRAPH.H - H) > 40) { GRAPH.W = W; GRAPH.H = H; HEAT = Math.max(HEAT, 0.4); }
|
| 505 |
+
const g = GRAPH, sel = s.node || "";
|
| 506 |
+
if (sel && g.byId.has(sel) && !shown(g.byId.get(sel))) unfold(g.byId.get(sel).st, true);
|
| 507 |
+
VIS = visibleGraph(g);
|
| 508 |
+
const inFocus = (d) => FOCUS && d.st === FOCUS;
|
| 509 |
+
const clouds = STAGES.filter((st) => g.byId.has("stage:" + st) && g.members[st].some(shown)).map((st) => `<ellipse class="cloud c${STAGES.indexOf(st) % 4} ${FOCUS === st ? "focus" : ""}" data-cloud="${st}" cx="0" cy="0" rx="0" ry="0"><title>${esc(STAGE_WORDS[st] || st)}</title></ellipse>`).join("");
|
| 510 |
+
const lines = VIS.vlinks.map((l, i) => {
|
| 511 |
+
const word = l.kind === "member" ? "part of" : l.kind === "flow" ? "next stage" : EDGE_WORDS[l.kind] || l.kind;
|
| 512 |
+
const far = FOCUS && !inFocus(l.s) && !inFocus(l.t);
|
| 513 |
+
return `<line class="gl ${l.kind} ${l.bundle ? "bundle" : ""} ${far ? "far" : ""}" data-i="${i}" data-s="${esc(l.s.id)}" data-t="${esc(l.t.id)}"${l.n > 1 ? ` style="stroke-width:${(1.2 + Math.log2(l.n)).toFixed(1)}"` : ""}><title>${l.n > 1 ? `${l.n} × ` : ""}${esc(word)}${l.label ? ": " + esc(l.label) : ""}</title></line>`;
|
| 514 |
}).join("");
|
| 515 |
+
const circles = VIS.vnodes.map((d) => {
|
| 516 |
+
const t = d.hub ? "" : tone(d.n), cnt = d.hub ? g.members[d.st].length : 0;
|
| 517 |
+
return `<g class="gn ${d.hub ? "hub" : ""} ${d.hub && OPEN.has(d.st) ? "open" : ""} ${FOCUS ? (inFocus(d) ? "near" : "far") : ""} tone-${t || "none"} ${d.key ? "lbl-always" : ""} ${sel === d.id ? "sel" : ""}" data-gnode="${esc(d.id)}" tabindex="0" role="button">
|
| 518 |
+
<title>${esc(d.n.label)}${d.hub ? ` (${cnt} records; click to ${OPEN.has(d.st) ? "fold" : "open"})` : ""}</title><circle r="${d.r}" style="fill:${d.hub ? "var(--head)" : KIND_COLOR[d.n.kind] || "#999"}"></circle>
|
| 519 |
+
${d.hub && cnt ? `<text class="cnt" dy="4">${cnt}</text>` : ""}<text class="gt" y="${d.r + 12}">${esc(gLabel(d))}</text></g>`;
|
|
|
|
|
|
|
| 520 |
}).join("");
|
| 521 |
+
const stageChips = STAGES.filter((st) => g.byId.has("stage:" + st)).map((st) => { const n = g.members[st].length;
|
| 522 |
+
return `<button type="button" class="tv-chip ${OPEN.has(st) ? "open" : ""} ${FOCUS === st ? "focus" : ""}" data-gstage="${st}" aria-pressed="${FOCUS === st}">${esc(STAGE_WORDS[st] || st)}${n ? ` <b>${n}</b>` : ""}</button>`; }).join("");
|
| 523 |
const legend = KIND_LEGEND.map(([k, w]) => `<span><i style="background:${KIND_COLOR[k]}"></i> ${esc(w)}</span>`).join("") +
|
| 524 |
+
`<span><i class="ring ok"></i> holds</span><span><i class="ring warn"></i> open / caveat</span><span><i class="ring bad"></i> fails / rejected</span><span><i class="ring off"></i> skipped / not run</span>` +
|
| 525 |
+
`<span><i class="ln flow"></i> stage order</span><span><i class="ln bundle"></i> several relationships, folded into one line</span>`;
|
| 526 |
+
const focusNote = FOCUS ? `<span class="tv-focus">Zoomed in on <b>${esc(STAGE_WORDS[FOCUS] || FOCUS)}</b> · <a href="#" data-stage="${esc(FOCUS)}">see it as a list</a></span>` : "";
|
| 527 |
+
return `<div class="tv-graph-bar"><input type="search" id="tv-find" placeholder="find a record (e.g. NaOH, calcite, doubt)…" aria-label="find a record" value="${esc(QUERY)}">
|
| 528 |
+
<button type="button" data-gall="overview" ${!OPEN.size ? 'aria-current="page"' : ""}>Overview</button><button type="button" data-gall="everything" ${OPEN.size >= STAGES.filter((st) => g.members[st] && g.members[st].length).length ? 'aria-current="page"' : ""}>Everything</button>
|
| 529 |
<button type="button" data-gzoom="in" aria-label="zoom in">+</button><button type="button" data-gzoom="out" aria-label="zoom out">−</button>
|
| 530 |
+
<button type="button" data-gfit="1">Fit</button><button type="button" data-glabels="1">Labels</button><button type="button" data-gfull="1" aria-pressed="${FULL}">${FULL ? "Close full page" : "Full page"}</button></div>
|
| 531 |
+
<div class="tv-stages">${stageChips}${focusNote}</div>
|
| 532 |
+
<p class="tv-hint">Click a stage to open it and zoom in (click it again to fold it back); click a small circle to read that record; hover to see what it is linked to; drag to move, scroll to zoom. The number in a big circle counts the records inside it.</p>
|
| 533 |
+
<div class="tv-graph ${VIS.vnodes.length <= 24 ? "few" : ""} ${FOCUS ? "focus" : ""}" id="tv-graph"><svg viewBox="0 0 ${g.W} ${g.H}" width="100%" height="${g.H}" role="img" aria-label="the plan's records as a network">
|
| 534 |
<g class="world" transform="translate(${VIEWPORT.tx},${VIEWPORT.ty}) scale(${VIEWPORT.k})">${clouds}${lines}${circles}</g></svg></div>
|
| 535 |
+
<p class="tv-legend tv-glegend">${legend}</p>`;
|
| 536 |
}
|
| 537 |
function wireGraph() {
|
| 538 |
+
BOX = app.querySelector("#tv-graph");
|
| 539 |
+
if (!BOX) return;
|
| 540 |
+
const svg = BOX.querySelector("svg"), g = GRAPH;
|
| 541 |
+
WORLD = svg.querySelector("g.world");
|
| 542 |
+
EL = new Map(); WORLD.querySelectorAll("g.gn").forEach((el) => EL.set(el.dataset.gnode, el));
|
| 543 |
+
WORLD.querySelectorAll("line.gl").forEach((el) => { VIS.vlinks[+el.dataset.i].el = el; });
|
| 544 |
+
if (HEAT) { for (let i = 0; i < 30; i++) step(g, VIS, 1); const aim = aimView(); if (aim) VIEWPORT = aim; }
|
| 545 |
+
place(); applyView();
|
| 546 |
+
const a = HEAT; HEAT = 0; if (a) heat(a); else if (aimView()) { if (!SIM.raf) SIM.raf = requestAnimationFrame(tick); }
|
| 547 |
+
const pt = (ev) => { const r = svg.getBoundingClientRect(); return { x: (ev.clientX - r.left) * (g.W / r.width), y: (ev.clientY - r.top) * (g.H / r.height) }; };
|
| 548 |
+
const zoomAt = (p, f) => { const k2 = Math.min(6, Math.max(0.2, VIEWPORT.k * f)), r = k2 / VIEWPORT.k; VIEW_MODE = "free"; VIEWPORT = { k: k2, tx: p.x - (p.x - VIEWPORT.tx) * r, ty: p.y - (p.y - VIEWPORT.ty) * r }; applyView(); };
|
| 549 |
+
svg.addEventListener("wheel", (ev) => { ev.preventDefault(); zoomAt(pt(ev), Math.exp(-ev.deltaY * 0.0015)); }, { passive: false });
|
| 550 |
app.querySelectorAll("[data-gzoom]").forEach((b) => b.addEventListener("click", () => zoomAt({ x: g.W / 2, y: g.H / 2 }, b.dataset.gzoom === "in" ? 1.4 : 1 / 1.4)));
|
| 551 |
+
let drag = null, pinch = null;
|
| 552 |
+
const touches = new Map();
|
| 553 |
svg.addEventListener("pointerdown", (ev) => {
|
| 554 |
touches.set(ev.pointerId, pt(ev));
|
| 555 |
if (touches.size === 2) { const [a, b] = [...touches.values()]; pinch = { d: Math.hypot(a.x - b.x, a.y - b.y), k: VIEWPORT.k }; drag = null; return; }
|
| 556 |
+
const gn = ev.target.closest("g.gn"), p = pt(ev);
|
| 557 |
drag = { x: p.x, y: p.y, node: gn ? g.byId.get(gn.dataset.gnode) : null, moved: false, tx: VIEWPORT.tx, ty: VIEWPORT.ty };
|
| 558 |
svg.setPointerCapture(ev.pointerId);
|
| 559 |
});
|
| 560 |
svg.addEventListener("pointermove", (ev) => {
|
| 561 |
if (touches.has(ev.pointerId)) touches.set(ev.pointerId, pt(ev));
|
| 562 |
+
if (pinch && touches.size === 2) { const [a, b] = [...touches.values()]; const d = Math.hypot(a.x - b.x, a.y - b.y) || 1; zoomAt({ x: (a.x + b.x) / 2, y: (a.y + b.y) / 2 }, (pinch.k * d / pinch.d) / VIEWPORT.k); return; }
|
| 563 |
if (!drag) return;
|
| 564 |
+
const p = pt(ev), dx = p.x - drag.x, dy = p.y - drag.y;
|
|
|
|
| 565 |
if (Math.abs(dx) + Math.abs(dy) > 3) drag.moved = true;
|
| 566 |
if (drag.node) {
|
| 567 |
+
if (!drag.moved) return;
|
| 568 |
const d = drag.node;
|
| 569 |
+
d.fx = d.x + dx / VIEWPORT.k; d.fy = d.y + dy / VIEWPORT.k; d.x = d.fx; d.y = d.fy; drag.x = p.x; drag.y = p.y;
|
| 570 |
+
VIEW_MODE = "free"; heat(0.3); // the neighbours follow
|
| 571 |
+
} else { VIEW_MODE = "free"; VIEWPORT = { ...VIEWPORT, tx: drag.tx + dx, ty: drag.ty + dy }; applyView(); }
|
|
|
|
| 572 |
});
|
| 573 |
const endDrag = (ev) => {
|
| 574 |
touches.delete(ev.pointerId);
|
| 575 |
if (touches.size < 2) pinch = null;
|
| 576 |
if (!drag) return;
|
| 577 |
const d = drag; drag = null;
|
| 578 |
+
if (d.node && d.moved) { d.node.fx = null; d.node.fy = null; return; }
|
| 579 |
+
if (d.node) { if (d.node.hub) toggleStage(d.node.st); else go({ view: state().view, node: d.node.id, cmp: state().cmp }); }
|
| 580 |
};
|
| 581 |
svg.addEventListener("pointerup", endDrag); svg.addEventListener("pointercancel", endDrag);
|
| 582 |
+
svg.addEventListener("dblclick", () => { VIEW_MODE = FOCUS ? "focus" : "all"; if (!SIM.raf) SIM.raf = requestAnimationFrame(tick); });
|
| 583 |
+
const neighbours = (id) => { const set = new Set([id]); VIS.vlinks.forEach((l) => { if (l.s.id === id) set.add(l.t.id); if (l.t.id === id) set.add(l.s.id); }); return set; };
|
| 584 |
svg.addEventListener("pointerover", (ev) => { const gn = ev.target.closest("g.gn"); if (!gn || drag) return; const near = neighbours(gn.dataset.gnode);
|
| 585 |
+
EL.forEach((x, id) => x.classList.toggle("dim", !near.has(id)));
|
| 586 |
+
VIS.vlinks.forEach((l) => { if (!l.el) return; const on = l.s.id === gn.dataset.gnode || l.t.id === gn.dataset.gnode; l.el.classList.toggle("hl", on); l.el.classList.toggle("dim", !on); }); });
|
| 587 |
+
svg.addEventListener("pointerout", (ev) => { if (ev.target.closest("g.gn") && !drag) { WORLD.querySelectorAll(".dim,.hl").forEach((x) => { x.classList.remove("dim"); x.classList.remove("hl"); }); applySearch(); } });
|
| 588 |
const find = app.querySelector("#tv-find");
|
| 589 |
+
if (find) {
|
| 590 |
+
find.addEventListener("input", () => {
|
| 591 |
+
QUERY = find.value.trim();
|
| 592 |
+
const q = QUERY.toLowerCase();
|
| 593 |
+
const hit = (d) => !!q && (d.n.label + " " + JSON.stringify(d.n.detail || {})).toLowerCase().includes(q);
|
| 594 |
+
const need = new Set(g.nodes.filter((d) => hit(d) && !shown(d)).map((d) => d.st));
|
| 595 |
+
if (need.size) { need.forEach((st) => unfold(st, true)); render(); const f = app.querySelector("#tv-find"); if (f) { f.focus(); f.setSelectionRange(f.value.length, f.value.length); } return; }
|
| 596 |
+
applySearch();
|
| 597 |
+
});
|
| 598 |
+
if (QUERY) applySearch();
|
| 599 |
+
}
|
| 600 |
+
}
|
| 601 |
+
function applySearch() {
|
| 602 |
+
const q = QUERY.toLowerCase();
|
| 603 |
+
EL.forEach((x, id) => { const d = GRAPH.byId.get(id); const hit = !q || (d.n.label + " " + JSON.stringify(d.n.detail || {})).toLowerCase().includes(q); x.classList.toggle("dim", !hit); x.classList.toggle("found", !!q && hit); });
|
| 604 |
}
|
| 605 |
function overview(s) {
|
| 606 |
if (s.view !== "flow") return graphView(s) + `<details class="tv-timeline"><summary>What ran, in order (${T.events.length} events)</summary><ol class="tv-events">${T.events.map((e) => `<li class="${e.status}"><span class="seq">${e.seq}</span><span>${esc(e.stage)}</span><span>${esc(e.name)}${e.subject ? ` <small>(${esc(e.subject)})</small>` : ""}<span class="msg">${esc(e.message)}</span></span>${chip("execution", e.status)}</li>`).join("")}</ol></details>`;
|
|
|
|
| 750 |
}
|
| 751 |
}
|
| 752 |
app.addEventListener("click", (ev) => {
|
| 753 |
+
const b = ev.target.closest("[data-tab],[data-stage],[data-node],[data-why],[data-open],[data-cmp],[data-cmp-clear],[data-close],[data-gfit],[data-glabels],[data-gstage],[data-gall],[data-gfull],a[href^='#']");
|
| 754 |
if (!b || !app.contains(b)) return;
|
| 755 |
const s = state();
|
| 756 |
if (b.dataset.tab != null) { ev.preventDefault(); if (b.dataset.tab === "") go({}); else if (b.dataset.tab === "__flow") go({ view: "flow" }); else if (b.dataset.tab === "__comp") go({ stage: s.stage || STAGES[0], cmp: s.cmp }); else go({ stage: s.stage || (s.node ? NODES.get(s.node).stage : STAGES[0]), node: s.node || ((STAGE_NODE[s.stage || STAGES[0]] || { children: [] }).children[0] || "target"), cmp: s.cmp }); return; }
|
| 757 |
+
if (b.dataset.gfit) { VIEW_MODE = FOCUS ? "focus" : "all"; if (!SIM.raf) SIM.raf = requestAnimationFrame(tick); return; }
|
| 758 |
+
if (b.dataset.gstage) { toggleStage(b.dataset.gstage); return; }
|
| 759 |
+
if (b.dataset.gall) { if (b.dataset.gall === "overview") { OPEN.clear(); } else STAGES.forEach((st) => unfold(st, true)); FOCUS = ""; VIEW_MODE = "all"; HEAT = 1; render(); return; }
|
| 760 |
+
if (b.dataset.gfull) { toggleFull(); return; }
|
| 761 |
if (b.dataset.glabels) { const box = app.querySelector("#tv-graph"); if (box) box.classList.toggle("all-labels"); return; }
|
| 762 |
if (b.dataset.stage) { ev.preventDefault(); go({ stage: b.dataset.stage }); return; }
|
| 763 |
if (b.dataset.node) { ev.preventDefault(); go({ stage: s.stage, node: b.dataset.node, cmp: s.cmp }); return; }
|
|
|
|
| 772 |
app.addEventListener("mouseover", (ev) => { const c = ev.target.closest(".tv-card"); if (c) highlight(c.dataset.id, true); });
|
| 773 |
app.addEventListener("mouseout", (ev) => { const c = ev.target.closest(".tv-card"); if (c && c.dataset.id !== state().node) highlight(c.dataset.id, false); });
|
| 774 |
if (!EMBEDDED) window.addEventListener("hashchange", render);
|
| 775 |
+
window.addEventListener("resize", () => requestAnimationFrame(() => { const s = state(); if (s.stage) drawEdges(); else if (s.view === "flow") render(); else if (GRAPH) { const { W, H } = graphSize(); if (Math.abs(GRAPH.W - W) > 40 || Math.abs(GRAPH.H - H) > 40) render(); } }));
|
| 776 |
+
document.addEventListener("keydown", (ev) => { if (ev.key !== "Escape") return; if (state().node) { const s = state(); go({ stage: s.stage, cmp: s.cmp, view: s.view }); } else if (FULL) toggleFull(); });
|
| 777 |
render();
|
| 778 |
if (CFG.audit_url && !AUDIT) {
|
| 779 |
fetch(CFG.audit_url, { cache: "no-store" }).then((r) => (r.ok ? r.json() : null)).then((a) => {
|
explore/cases/x1_na2o2_scope/package.zip
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9a259b207ee00c66b10180521a5643f3d1a6a5313781282b04bf450fcff2d1c1
|
| 3 |
+
size 34728
|
explore/cases/x1_na2o2_scope/trace.html
CHANGED
|
@@ -113,7 +113,8 @@ details.tv-timeline summary{cursor:pointer;color:var(--accent);font-size:.95rem;
|
|
| 113 |
.tv-graph-bar button{border:1px solid var(--line);background:var(--card);color:var(--fg);border-radius:999px;padding:.35em .9em}
|
| 114 |
.tv-hint{font-size:.84rem;color:var(--muted);flex-basis:100%}
|
| 115 |
.tv-graph{border:1px solid var(--line);border-radius:var(--radius);background:var(--card);overflow:hidden;touch-action:none;cursor:grab}
|
| 116 |
-
.tv-graph:active{cursor:grabbing}.tv-graph svg{display:block;font:
|
|
|
|
| 117 |
.tv-graph line.gl{stroke:var(--line);stroke-width:1.2;opacity:.9}
|
| 118 |
.tv-graph line.member{stroke:var(--line);stroke-width:1;opacity:.5}
|
| 119 |
.tv-graph line.supported_by,.tv-graph line.computed_from,.tv-graph line.cites{stroke:var(--accent)}
|
|
@@ -125,17 +126,33 @@ details.tv-timeline summary{cursor:pointer;color:var(--accent);font-size:.95rem;
|
|
| 125 |
.tv-graph g.gn.tone-ok circle{stroke:var(--ok)}.tv-graph g.gn.tone-warn circle{stroke:var(--warn)}.tv-graph g.gn.tone-bad circle{stroke:var(--bad)}
|
| 126 |
.tv-graph g.gn.tone-off circle{stroke:var(--off);stroke-dasharray:3 2;opacity:.7}
|
| 127 |
.tv-graph g.gn.hub circle{stroke:var(--accent);stroke-width:2.5}
|
| 128 |
-
.tv-graph g.gn text.gt{fill:var(--fg);text-anchor:middle;pointer-events:none;opacity:0;font-size:
|
| 129 |
-
.tv-graph g.gn.hub text.gt{font-weight:700;font-size:
|
| 130 |
.tv-graph g.gn.lbl-always text.gt,.tv-graph.zoomed g.gn text.gt,.tv-graph.all-labels g.gn text.gt,.tv-graph g.gn:hover text.gt,.tv-graph g.gn.sel text.gt,.tv-graph g.gn.found text.gt{opacity:1}
|
| 131 |
.tv-graph g.gn.dim{opacity:.18}.tv-graph g.gn.sel circle{stroke:var(--accent);stroke-width:4}
|
| 132 |
.tv-graph g.gn.found circle{stroke:var(--accent);stroke-width:4}
|
| 133 |
.tv-glegend span{display:inline-flex;align-items:center;gap:.3em}.tv-glegend i{display:inline-block;width:12px;height:12px;border-radius:50%;border:0}
|
| 134 |
.tv-glegend i.ring{background:transparent;border:3px solid var(--ok)}.tv-glegend i.ring.warn{border-color:var(--warn)}.tv-glegend i.ring.bad{border-color:var(--bad)}.tv-glegend i.ring.off{border-color:var(--off);border-style:dashed}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 135 |
.tv-graph ellipse.cloud{fill:var(--accent);opacity:.07;stroke:none}.tv-graph ellipse.cloud.c1{fill:var(--ok)}.tv-graph ellipse.cloud.c2{fill:var(--warn)}.tv-graph ellipse.cloud.c3{fill:#b07aa1}
|
| 136 |
@media (prefers-color-scheme:dark){:root:not([data-theme="light"]) .tv-graph ellipse.cloud{opacity:.12}}
|
| 137 |
-
</style></head><body><script id="trace" type="application/json">{"edges":[],"events":[{"ended":"2026-10-26T00:00:00.000+00:00","message":"Na2O2: identity unresolved, phase unresolved; gates G1 PASS, G2 UNKNOWN","name":"target intake","seq":1,"stage":"M01","started":"2026-10-26T00:00:00.000+00:00","status":"completed","subject":"x1"},{"ended":"2026-10-26T00:00:00.000+00:00","message":"no synthesis precedent of this composition in the evidence","name":"families and precedents","seq":2,"stage":"M02","started":"2026-10-26T00:00:00.000+00:00","status":"completed","subject":"Na2O2"},{"ended":"2026-10-26T00:00:00.000+00:00","message":"no route for Na2O2 in the families Mat2Bot (milestone 1) plans (documented here: none in the evidence set); not planned rather than planned weakly","name":"route candidates","seq":3,"stage":"M04","started":"2026-10-26T00:00:00.000+00:00","status":"refused","subject":"Na2O2"},{"ended":"2026-10-26T00:00:00.000+00:00","message":"gate S on the product alone: UNKNOWN; Na2O2 H271, H314 (hard_fail/human_only)","name":"the product's own hazards (handling only)","seq":4,"stage":"M01","started":"2026-10-26T00:00:00.000+00:00","status":"completed","subject":"Na2O2"},{"ended":"2026-10-26T00:00:00.000+00:00","message":"not reached: no route candidate in Mat2Bot's planned families","name":"feasibility","seq":5,"stage":"M05","started":"2026-10-26T00:00:00.000+00:00","status":"skipped","subject":"Na2O2"},{"ended":"2026-10-26T00:00:00.000+00:00","message":"not reached: no route candidate in Mat2Bot's planned families","name":"route cases and ranking","seq":6,"stage":"M07","started":"2026-10-26T00:00:00.000+00:00","status":"skipped","subject":"Na2O2"},{"ended":"2026-10-26T00:00:00.000+00:00","message":"not reached: no route candidate in Mat2Bot's planned families","name":"procedure","seq":7,"stage":"M08","started":"2026-10-26T00:00:00.000+00:00","status":"skipped","subject":"Na2O2"},{"ended":"2026-10-26T00:00:00.000+00:00","message":"not reached: no route candidate in Mat2Bot's planned families","name":"laboratories","seq":8,"stage":"LAB","started":"2026-10-26T00:00:00.000+00:00","status":"skipped","subject":"Na2O2"}],"layout":{"columns":["M01","M02","M04","M05","M07","M08","LAB","AUDIT"],"rows":{"finding:0":0,"gate:G1":1,"gate:G2":2,"gateS:target":3,"hazard:target:Na2O2":4,"target":0}},"nodes":[{"children":["gate:G1","gate:G2","gateS:target"],"detail":{"checked_against":["the Mat2Bot v0.1 polymorph registry (KCl, CaCO3, ZnO, BaTiO3, and the ZnO competitors Zn(OH)2 and Zn5(OH)8(NO3)2(H2O)2; COD structures and cited stability fields)"],"form":"powder","formula":"Na2O2","identity":"unresolved","known_phases":[],"missing":["known phases of the composition (outside the registry; Materials Project not consulted)","Materials Project energies (no key; never decisive for polymorphs)"],"novelty":"not found in the Mat2Bot v0.1 polymorph registry (KCl, CaCO3, ZnO, BaTiO3, and the ZnO competitors Zn(OH)2 and Zn5(OH)8(NO3)2(H2O)2; COD structures and cited stability fields); no other database consulted","phase":null},"evidence":"n/a","execution":"completed","kind":"target","lab":null,"label":"Na2O2","node_id":"target","presentation_only":false,"ref":"target.json#target","science":"unresolved","stage":"M01"},{"children":[],"detail":{"findings":[],"rules":["R-G1-INPUT-001"]},"evidence":"n/a","execution":"completed","kind":"claim","lab":null,"label":"Gate G1: PASS","node_id":"gate:G1","presentation_only":false,"ref":"target.json#gates/G1","science":"PASS","stage":"M01"},{"children":[],"detail":{"findings":[{"code":"IDENTITY_UNRESOLVED","message":"Na2O2 is outside the Mat2Bot v0.1 polymorph registry (KCl, CaCO3, ZnO, BaTiO3, and the ZnO competitors Zn(OH)2 and Zn5(OH)8(NO3)2(H2O)2; COD structures and cited stability fields)","rule":"R-G2-ID-001"}],"rules":["R-G2-ID-001","R-M01-ID-001","R-M01-PHASE-001"]},"evidence":"n/a","execution":"completed","kind":"claim","lab":null,"label":"Gate G2: UNKNOWN","node_id":"gate:G2","presentation_only":false,"ref":"target.json#gates/G2","science":"UNKNOWN","stage":"M01"},{"children":["hazard:target:Na2O2"],"detail":{"findings":[{"code":"HAZARD_HARD_FAIL","message":"sodium peroxide (Na2O2, product): H271 (harmonised): no unattended automated step may handle it; a person may, after G7"},{"code":"HAZARD_HUMAN_ONLY","message":"sodium peroxide (Na2O2, product): H314 (harmonised): a person handles it; G7 records it"},{"code":"HAZARD_UNKNOWN","message":"no reagent of this route is known, so their hazards are unknown; a person decides at G7"}],"what":"what handling the material demands; not a route verdict"},"evidence":"n/a","execution":"completed","kind":"hazard","lab":null,"label":"Handling the product (gate S on it alone): UNKNOWN","node_id":"gateS:target","presentation_only":false,"ref":"safety/target.json#gate","science":"UNKNOWN","stage":"M01"},{"children":[],"detail":{"codes":["H271","H314"],"demands":["hard_fail","human_only"],"harmonised":true,"pubchem_cid":14803,"url":"https://pubchem.ncbi.nlm.nih.gov/compound/14803#section=GHS-Classification"},"evidence":"verified","execution":"completed","kind":"hazard","lab":null,"label":"sodium peroxide (Na2O2): hard_fail, human_only","node_id":"hazard:target:Na2O2","presentation_only":false,"ref":"safety/target.json#substances/Na2O2","science":null,"stage":"M01"},{"children":[],"detail":{"code":"NO_SUPPORTED_FAMILY","message":"no route for Na2O2 in the families Mat2Bot (milestone 1) plans (documented here: none in the evidence set); not planned rather than planned weakly","rule":"R-M03-SCOPE-001","severity":"warning","subject":"Na2O2"},"evidence":"n/a","execution":"refused","kind":"finding","lab":null,"label":"no route for Na2O2 in the families Mat2Bot (milestone 1) plans (documented here: none in the evidence set); not planned rather than planned weakly","node_id":"finding:0","presentation_only":false,"ref":"plan.json#findings/0","science":null,"stage":"M04"},{"children":["target","gate:G1","gate:G2","gateS:target","hazard:target:Na2O2"],"detail":{"events":[1,4],"how":"","message":"Na2O2: identity unresolved, phase unresolved; gates G1 PASS, G2 UNKNOWN; gate S on the product alone: UNKNOWN; Na2O2 H271, H314 (hard_fail/human_only)"},"evidence":"n/a","execution":"completed","kind":"stage","lab":null,"label":"Target","node_id":"stage:M01","presentation_only":false,"ref":"trace.json#events/M01","science":null,"stage":"M01"},{"children":[],"detail":{"events":[2],"how":"","message":"no synthesis precedent of this composition in the evidence"},"evidence":"n/a","execution":"completed","kind":"stage","lab":null,"label":"Evidence","node_id":"stage:M02","presentation_only":false,"ref":"trace.json#events/M02","science":null,"stage":"M02"},{"children":["finding:0"],"detail":{"events":[3],"how":"","message":"no route for Na2O2 in the families Mat2Bot (milestone 1) plans (documented here: none in the evidence set); not planned rather than planned weakly"},"evidence":"n/a","execution":"refused","kind":"stage","lab":null,"label":"Routes","node_id":"stage:M04","presentation_only":false,"ref":"trace.json#events/M04","science":null,"stage":"M04"},{"children":[],"detail":{"events":[5],"how":"","message":"not reached: no route candidate in Mat2Bot's planned families"},"evidence":"n/a","execution":"skipped","kind":"stage","lab":null,"label":"Science","node_id":"stage:M05","presentation_only":false,"ref":"trace.json#events/M05","science":null,"stage":"M05"},{"children":[],"detail":{"events":[6],"how":"","message":"not reached: no route candidate in Mat2Bot's planned families"},"evidence":"n/a","execution":"skipped","kind":"stage","lab":null,"label":"The case","node_id":"stage:M07","presentation_only":false,"ref":"trace.json#events/M07","science":null,"stage":"M07"},{"children":[],"detail":{"events":[7],"how":"","message":"not reached: no route candidate in Mat2Bot's planned families"},"evidence":"n/a","execution":"skipped","kind":"stage","lab":null,"label":"Procedure","node_id":"stage:M08","presentation_only":false,"ref":"trace.json#events/M08","science":null,"stage":"M08"},{"children":[],"detail":{"events":[8],"how":"","message":"not reached: no route candidate in Mat2Bot's planned families"},"evidence":"n/a","execution":"skipped","kind":"stage","lab":null,"label":"Laboratories","node_id":"stage:LAB","presentation_only":false,"ref":"trace.json#events/LAB","science":null,"stage":"LAB"},{"children":[],"detail":{"events":[],"how":"run `mat2bot audit <package>`; the result never comes from the package itself","message":"the package is audited after it is written: run the auditor, or a live audit fills this column"},"evidence":"n/a","execution":"not_run","kind":"stage","lab":null,"label":"Audit","node_id":"stage:AUDIT","presentation_only":false,"ref":"trace.json#nodes/stage:AUDIT","science":null,"stage":"AUDIT"}],"note":"A projection of the plan's records: every node names the record it shows and every edge a relationship that record holds; nothing here is computed anew. The audit stage is filled only by a live audit.","request_id":"x1","schema":"mat2bot/trace/1","title":"Sodium peroxide (Na2O2)"}</script><script id="trace-config" type="application/json">{"audit_url": "audit.json", "links": {"home": "../../index.html", "report": "report.html", "package": "package.zip"}, "mat2bot": "0.1.0"}</script><div id="trace-app" data-title="Sodium peroxide (Na2O2)"></div><script>/* Mat2Bot Trace viewer: a
|
| 138 |
-
it), a components view (a stage's records as cards with their typed edges) and a provenance panel (one record),
|
| 139 |
over trace.json and nothing else. Every drawn node is a node of the trace and every drawn line an edge of it; the
|
| 140 |
audit column is filled only from a live audit the host gives (config.audit_url or config.audit). Plain JS, no library.
|
| 141 |
Standalone (trace.html) it keeps its place in the address bar; embedded (the one-box page) it keeps it in memory. */
|
|
@@ -321,6 +338,11 @@ details.tv-timeline summary{cursor:pointer;color:var(--accent);font-size:.95rem;
|
|
| 321 |
return `<div class="tv-map"><svg viewBox="0 0 ${W} ${H}" width="${W}" height="${H}" role="img" aria-label="the stages Mat2Bot ran, with each stage's records"><defs><marker id="arrow" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="8" markerHeight="8" orient="auto-start-reverse"><path d="M0,0 L10,5 L0,10 z"></path></marker></defs>${parts.join("")}</svg></div>` + legend;
|
| 322 |
}
|
| 323 |
// ---------------------------------------------------------------- the graph: every record a circle, every relationship a line
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 324 |
const KIND_COLOR = { target: "#2f5d8a", evidence: "#4e79a7", route: "#59a14f", rival: "#e15759", doubt: "#f28e2b", calculation: "#b07aa1",
|
| 325 |
model_output: "#9c755f", step: "#76b7b2", laboratory: "#edc948", capability: "#bab0ab", hazard: "#ff9da7", claim: "#86bcb6", assumption: "#d4a6c8",
|
| 326 |
finding: "#e15759", grouping: "#bab0ab", inference: "#bab0ab" };
|
|
@@ -329,162 +351,256 @@ details.tv-timeline summary{cursor:pointer;color:var(--accent);font-size:.95rem;
|
|
| 329 |
const KIND_LEGEND = [["target", "the target"], ["evidence", "published record"], ["route", "route proposed"], ["rival", "route set aside"],
|
| 330 |
["claim", "claim"], ["doubt", "doubt"], ["calculation", "number / model"], ["step", "recipe step"], ["laboratory", "laboratory"],
|
| 331 |
["hazard", "hazard"], ["capability", "equipment"]];
|
| 332 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 333 |
let VIEWPORT = { k: 1, tx: 0, ty: 0 };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 334 |
function buildGraph() {
|
| 335 |
const cols = {};
|
| 336 |
STAGES.forEach((st, i) => { cols[st] = i; });
|
| 337 |
-
const nodes = T.nodes.filter((n) => n.kind !== "stage").map((n) => ({ id: n.node_id, n, r: KIND_R[n.kind] || 6, col: cols[n.stage] ?? 0, hub: false }));
|
| 338 |
-
STAGES.filter((st) => STAGE_NODE[st]).forEach((st) => nodes.push({ id: "stage:" + st, n: STAGE_NODE[st], r: 17, col: cols[st], hub: true }));
|
| 339 |
const byId = new Map(nodes.map((d) => [d.id, d]));
|
| 340 |
const links = [];
|
| 341 |
T.edges.forEach((e) => { if (byId.has(e.source) && byId.has(e.target)) links.push({ s: byId.get(e.source), t: byId.get(e.target), kind: e.kind, label: e.label }); });
|
| 342 |
STAGES.forEach((st) => { const hub = byId.get("stage:" + st); if (!hub) return; topLevel(st).forEach((n) => { const d = byId.get(n.node_id); if (d) links.push({ s: hub, t: d, kind: "member" }); }); });
|
| 343 |
T.nodes.forEach((n) => { if (NESTING.includes(n.kind)) n.children.forEach((c) => { const a = byId.get(n.node_id), b = byId.get(c); if (a && b) links.push({ s: a, t: b, kind: "member" }); }); });
|
| 344 |
-
const
|
| 345 |
-
|
|
|
|
|
|
|
|
|
|
| 346 |
let seed = 7;
|
| 347 |
const rnd = () => { seed = (seed * 9301 + 49297) % 233280; return seed / 233280; };
|
| 348 |
-
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
|
| 356 |
-
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
|
| 360 |
-
|
| 361 |
-
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 365 |
}
|
| 366 |
-
links.forEach((l) => {
|
| 367 |
-
const dx = l.t.x - l.s.x, dy = l.t.y - l.s.y;
|
| 368 |
-
const d = Math.sqrt(dx * dx + dy * dy) || 1;
|
| 369 |
-
const want = l.kind === "member" ? 58 : 84;
|
| 370 |
-
const f = (d - want) * (kLink[l.kind] || 0.03);
|
| 371 |
-
l.s.vx += (dx / d) * f; l.s.vy += (dy / d) * f; l.t.vx -= (dx / d) * f; l.t.vy -= (dy / d) * f;
|
| 372 |
-
});
|
| 373 |
-
nodes.forEach((d) => {
|
| 374 |
-
d.vx += (colX(d.col) - d.x) * (d.hub ? 0.16 : 0.03); // the flow from left to right is kept
|
| 375 |
-
d.vy += (H / 2 - d.y) * 0.004;
|
| 376 |
-
const sp = Math.sqrt(d.vx * d.vx + d.vy * d.vy) || 1;
|
| 377 |
-
const cap = 12 * temp + 1;
|
| 378 |
-
const k = Math.min(sp, cap) / sp;
|
| 379 |
-
d.x += d.vx * k; d.y += d.vy * k; d.vx *= 0.4; d.vy *= 0.4;
|
| 380 |
-
});
|
| 381 |
}
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
|
| 386 |
-
|
| 387 |
-
|
| 388 |
-
|
| 389 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 390 |
}
|
| 391 |
-
|
| 392 |
-
const box = { x0: Math.min(...xs) - 40, y0: Math.min(...ys) - 30, x1: Math.max(...xs) + 40, y1: Math.max(...ys) + 30 };
|
| 393 |
-
return { nodes, links, byId, W, H, box };
|
| 394 |
}
|
| 395 |
-
function
|
| 396 |
-
|
| 397 |
-
|
| 398 |
-
|
| 399 |
}
|
| 400 |
-
function gLabel(d) {
|
| 401 |
-
|
| 402 |
-
if (
|
| 403 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 404 |
}
|
| 405 |
function graphView(s) {
|
| 406 |
-
|
| 407 |
-
|
| 408 |
-
const sel = s.node || "";
|
| 409 |
-
|
| 410 |
-
|
| 411 |
-
|
| 412 |
-
|
| 413 |
-
|
| 414 |
-
const
|
| 415 |
-
const
|
| 416 |
-
return `<
|
| 417 |
}).join("");
|
| 418 |
-
const
|
| 419 |
-
|
| 420 |
-
|
| 421 |
-
|
| 422 |
-
|
| 423 |
-
<title>${esc(d.n.label)}</title><circle r="${d.r}" style="fill:${d.hub ? "var(--head)" : KIND_COLOR[d.n.kind] || "#999"}"></circle>
|
| 424 |
-
<text class="gt" y="${d.r + 12}">${esc(gLabel(d))}</text></g>`;
|
| 425 |
}).join("");
|
|
|
|
|
|
|
| 426 |
const legend = KIND_LEGEND.map(([k, w]) => `<span><i style="background:${KIND_COLOR[k]}"></i> ${esc(w)}</span>`).join("") +
|
| 427 |
-
`<span><i class="ring ok"></i> holds</span><span><i class="ring warn"></i> open / caveat</span><span><i class="ring bad"></i> fails / rejected</span>`
|
| 428 |
-
|
|
|
|
|
|
|
|
|
|
| 429 |
<button type="button" data-gzoom="in" aria-label="zoom in">+</button><button type="button" data-gzoom="out" aria-label="zoom out">−</button>
|
| 430 |
-
<button type="button" data-gfit="1">Fit</button><button type="button" data-glabels="1">Labels</button>
|
| 431 |
-
|
| 432 |
-
<
|
|
|
|
| 433 |
<g class="world" transform="translate(${VIEWPORT.tx},${VIEWPORT.ty}) scale(${VIEWPORT.k})">${clouds}${lines}${circles}</g></svg></div>
|
| 434 |
-
<p class="tv-legend tv-glegend">${legend}<
|
| 435 |
}
|
| 436 |
function wireGraph() {
|
| 437 |
-
|
| 438 |
-
if (!
|
| 439 |
-
const svg =
|
| 440 |
-
|
| 441 |
-
|
| 442 |
-
|
| 443 |
-
|
| 444 |
-
|
| 445 |
-
|
| 446 |
-
const
|
| 447 |
-
|
| 448 |
-
|
| 449 |
app.querySelectorAll("[data-gzoom]").forEach((b) => b.addEventListener("click", () => zoomAt({ x: g.W / 2, y: g.H / 2 }, b.dataset.gzoom === "in" ? 1.4 : 1 / 1.4)));
|
|
|
|
|
|
|
| 450 |
svg.addEventListener("pointerdown", (ev) => {
|
| 451 |
touches.set(ev.pointerId, pt(ev));
|
| 452 |
if (touches.size === 2) { const [a, b] = [...touches.values()]; pinch = { d: Math.hypot(a.x - b.x, a.y - b.y), k: VIEWPORT.k }; drag = null; return; }
|
| 453 |
-
const gn = ev.target.closest("g.gn")
|
| 454 |
drag = { x: p.x, y: p.y, node: gn ? g.byId.get(gn.dataset.gnode) : null, moved: false, tx: VIEWPORT.tx, ty: VIEWPORT.ty };
|
| 455 |
svg.setPointerCapture(ev.pointerId);
|
| 456 |
});
|
| 457 |
svg.addEventListener("pointermove", (ev) => {
|
| 458 |
if (touches.has(ev.pointerId)) touches.set(ev.pointerId, pt(ev));
|
| 459 |
-
if (pinch && touches.size === 2) { const [a, b] = [...touches.values()]; const d = Math.hypot(a.x - b.x, a.y - b.y) || 1;
|
| 460 |
if (!drag) return;
|
| 461 |
-
const p = pt(ev);
|
| 462 |
-
const dx = p.x - drag.x, dy = p.y - drag.y;
|
| 463 |
if (Math.abs(dx) + Math.abs(dy) > 3) drag.moved = true;
|
| 464 |
if (drag.node) {
|
| 465 |
-
|
| 466 |
const d = drag.node;
|
| 467 |
-
|
| 468 |
-
|
| 469 |
-
|
| 470 |
-
} else { VIEWPORT = { ...VIEWPORT, tx: drag.tx + dx, ty: drag.ty + dy }; apply(); }
|
| 471 |
});
|
| 472 |
const endDrag = (ev) => {
|
| 473 |
touches.delete(ev.pointerId);
|
| 474 |
if (touches.size < 2) pinch = null;
|
| 475 |
if (!drag) return;
|
| 476 |
const d = drag; drag = null;
|
| 477 |
-
if (
|
|
|
|
| 478 |
};
|
| 479 |
svg.addEventListener("pointerup", endDrag); svg.addEventListener("pointercancel", endDrag);
|
| 480 |
-
svg.addEventListener("dblclick", () => {
|
| 481 |
-
const neighbours = (id) => { const set = new Set([id]);
|
| 482 |
svg.addEventListener("pointerover", (ev) => { const gn = ev.target.closest("g.gn"); if (!gn || drag) return; const near = neighbours(gn.dataset.gnode);
|
| 483 |
-
|
| 484 |
-
|
| 485 |
-
svg.addEventListener("pointerout", (ev) => { if (ev.target.closest("g.gn") && !drag) {
|
| 486 |
const find = app.querySelector("#tv-find");
|
| 487 |
-
if (find)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 488 |
}
|
| 489 |
function overview(s) {
|
| 490 |
if (s.view !== "flow") return graphView(s) + `<details class="tv-timeline"><summary>What ran, in order (${T.events.length} events)</summary><ol class="tv-events">${T.events.map((e) => `<li class="${e.status}"><span class="seq">${e.seq}</span><span>${esc(e.stage)}</span><span>${esc(e.name)}${e.subject ? ` <small>(${esc(e.subject)})</small>` : ""}<span class="msg">${esc(e.message)}</span></span>${chip("execution", e.status)}</li>`).join("")}</ol></details>`;
|
|
@@ -634,11 +750,14 @@ details.tv-timeline summary{cursor:pointer;color:var(--accent);font-size:.95rem;
|
|
| 634 |
}
|
| 635 |
}
|
| 636 |
app.addEventListener("click", (ev) => {
|
| 637 |
-
const b = ev.target.closest("[data-tab],[data-stage],[data-node],[data-why],[data-open],[data-cmp],[data-cmp-clear],[data-close],[data-gfit],[data-glabels],a[href^='#']");
|
| 638 |
if (!b || !app.contains(b)) return;
|
| 639 |
const s = state();
|
| 640 |
if (b.dataset.tab != null) { ev.preventDefault(); if (b.dataset.tab === "") go({}); else if (b.dataset.tab === "__flow") go({ view: "flow" }); else if (b.dataset.tab === "__comp") go({ stage: s.stage || STAGES[0], cmp: s.cmp }); else go({ stage: s.stage || (s.node ? NODES.get(s.node).stage : STAGES[0]), node: s.node || ((STAGE_NODE[s.stage || STAGES[0]] || { children: [] }).children[0] || "target"), cmp: s.cmp }); return; }
|
| 641 |
-
if (b.dataset.gfit) { if (
|
|
|
|
|
|
|
|
|
|
| 642 |
if (b.dataset.glabels) { const box = app.querySelector("#tv-graph"); if (box) box.classList.toggle("all-labels"); return; }
|
| 643 |
if (b.dataset.stage) { ev.preventDefault(); go({ stage: b.dataset.stage }); return; }
|
| 644 |
if (b.dataset.node) { ev.preventDefault(); go({ stage: s.stage, node: b.dataset.node, cmp: s.cmp }); return; }
|
|
@@ -653,8 +772,8 @@ details.tv-timeline summary{cursor:pointer;color:var(--accent);font-size:.95rem;
|
|
| 653 |
app.addEventListener("mouseover", (ev) => { const c = ev.target.closest(".tv-card"); if (c) highlight(c.dataset.id, true); });
|
| 654 |
app.addEventListener("mouseout", (ev) => { const c = ev.target.closest(".tv-card"); if (c && c.dataset.id !== state().node) highlight(c.dataset.id, false); });
|
| 655 |
if (!EMBEDDED) window.addEventListener("hashchange", render);
|
| 656 |
-
window.addEventListener("resize", () => requestAnimationFrame(() => {
|
| 657 |
-
document.addEventListener("keydown", (ev) => { if (ev.key ==
|
| 658 |
render();
|
| 659 |
if (CFG.audit_url && !AUDIT) {
|
| 660 |
fetch(CFG.audit_url, { cache: "no-store" }).then((r) => (r.ok ? r.json() : null)).then((a) => {
|
|
|
|
| 113 |
.tv-graph-bar button{border:1px solid var(--line);background:var(--card);color:var(--fg);border-radius:999px;padding:.35em .9em}
|
| 114 |
.tv-hint{font-size:.84rem;color:var(--muted);flex-basis:100%}
|
| 115 |
.tv-graph{border:1px solid var(--line);border-radius:var(--radius);background:var(--card);overflow:hidden;touch-action:none;cursor:grab}
|
| 116 |
+
.tv-graph:active{cursor:grabbing}.tv-graph svg{display:block;font:11px/1.2 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif}
|
| 117 |
+
.tv-graph line,.tv-graph circle{vector-effect:non-scaling-stroke}
|
| 118 |
.tv-graph line.gl{stroke:var(--line);stroke-width:1.2;opacity:.9}
|
| 119 |
.tv-graph line.member{stroke:var(--line);stroke-width:1;opacity:.5}
|
| 120 |
.tv-graph line.supported_by,.tv-graph line.computed_from,.tv-graph line.cites{stroke:var(--accent)}
|
|
|
|
| 126 |
.tv-graph g.gn.tone-ok circle{stroke:var(--ok)}.tv-graph g.gn.tone-warn circle{stroke:var(--warn)}.tv-graph g.gn.tone-bad circle{stroke:var(--bad)}
|
| 127 |
.tv-graph g.gn.tone-off circle{stroke:var(--off);stroke-dasharray:3 2;opacity:.7}
|
| 128 |
.tv-graph g.gn.hub circle{stroke:var(--accent);stroke-width:2.5}
|
| 129 |
+
.tv-graph g.gn text.gt{fill:var(--fg);text-anchor:middle;pointer-events:none;opacity:0;font-size:1em;paint-order:stroke;stroke:var(--card);stroke-width:.28em;stroke-linejoin:round}
|
| 130 |
+
.tv-graph g.gn.hub text.gt{font-weight:700;font-size:1.18em;opacity:1}
|
| 131 |
.tv-graph g.gn.lbl-always text.gt,.tv-graph.zoomed g.gn text.gt,.tv-graph.all-labels g.gn text.gt,.tv-graph g.gn:hover text.gt,.tv-graph g.gn.sel text.gt,.tv-graph g.gn.found text.gt{opacity:1}
|
| 132 |
.tv-graph g.gn.dim{opacity:.18}.tv-graph g.gn.sel circle{stroke:var(--accent);stroke-width:4}
|
| 133 |
.tv-graph g.gn.found circle{stroke:var(--accent);stroke-width:4}
|
| 134 |
.tv-glegend span{display:inline-flex;align-items:center;gap:.3em}.tv-glegend i{display:inline-block;width:12px;height:12px;border-radius:50%;border:0}
|
| 135 |
.tv-glegend i.ring{background:transparent;border:3px solid var(--ok)}.tv-glegend i.ring.warn{border-color:var(--warn)}.tv-glegend i.ring.bad{border-color:var(--bad)}.tv-glegend i.ring.off{border-color:var(--off);border-style:dashed}
|
| 136 |
+
.tv-stages{display:flex;flex-wrap:wrap;gap:.4em;align-items:center;margin:0 0 .4em}
|
| 137 |
+
.tv-chip{border:1px solid var(--line);background:var(--card);color:var(--fg);border-radius:999px;padding:.25em .8em;font-size:.92em}
|
| 138 |
+
.tv-chip b{font-weight:600;color:var(--muted);margin-left:.15em}.tv-chip.open{border-color:var(--accent)}
|
| 139 |
+
.tv-chip.focus{background:var(--accent);color:var(--card);border-color:var(--accent)}.tv-chip.focus b{color:var(--card)}
|
| 140 |
+
.tv-focus{font-size:.9em;color:var(--muted);margin-left:.4em}
|
| 141 |
+
p.tv-hint{font-size:.9em;color:var(--muted);margin:0 0 .5em}
|
| 142 |
+
.tv-graph line.flow{stroke:var(--accent);stroke-dasharray:1 6;stroke-linecap:round;opacity:.55;stroke-width:2}
|
| 143 |
+
.tv-graph line.bundle{opacity:.6}.tv-graph line.far{opacity:.12}
|
| 144 |
+
.tv-graph g.gn.hub text.cnt{fill:var(--fg);text-anchor:middle;font-size:1em;font-weight:700;pointer-events:none}
|
| 145 |
+
.tv-graph g.gn.hub.open circle{fill:var(--accent)!important}.tv-graph g.gn.hub.open text.cnt{fill:var(--card)}
|
| 146 |
+
.tv-graph g.gn.far{opacity:.3}.tv-graph.focus g.gn.near text.gt,.tv-graph.few g.gn text.gt{opacity:1}.tv-graph.focus g.gn.far:not(.hub) text.gt{opacity:0}
|
| 147 |
+
.tv-graph ellipse.cloud.focus{opacity:.16}
|
| 148 |
+
.tv-glegend i.ln{display:inline-block;width:1.4em;height:0;border-top:2px dotted var(--accent);vertical-align:middle;margin-right:.3em}
|
| 149 |
+
.tv-glegend i.ln.bundle{border-top:3px solid var(--line)}
|
| 150 |
+
.tv-fullpage{position:fixed;inset:0;z-index:1000;background:var(--bg);padding:12px 16px;overflow:auto;box-sizing:border-box}
|
| 151 |
+
.tv-noscroll{overflow:hidden}
|
| 152 |
.tv-graph ellipse.cloud{fill:var(--accent);opacity:.07;stroke:none}.tv-graph ellipse.cloud.c1{fill:var(--ok)}.tv-graph ellipse.cloud.c2{fill:var(--warn)}.tv-graph ellipse.cloud.c3{fill:#b07aa1}
|
| 153 |
@media (prefers-color-scheme:dark){:root:not([data-theme="light"]) .tv-graph ellipse.cloud{opacity:.12}}
|
| 154 |
+
</style></head><body><script id="trace" type="application/json">{"edges":[],"events":[{"ended":"2026-10-26T00:00:00.000+00:00","message":"Na2O2: identity unresolved, phase unresolved; gates G1 PASS, G2 UNKNOWN","name":"target intake","seq":1,"stage":"M01","started":"2026-10-26T00:00:00.000+00:00","status":"completed","subject":"x1"},{"ended":"2026-10-26T00:00:00.000+00:00","message":"no synthesis precedent of this composition in the evidence","name":"families and precedents","seq":2,"stage":"M02","started":"2026-10-26T00:00:00.000+00:00","status":"completed","subject":"Na2O2"},{"ended":"2026-10-26T00:00:00.000+00:00","message":"no route for Na2O2 in the families Mat2Bot (milestone 1) plans (documented here: none in the evidence set); not planned rather than planned weakly","name":"route candidates","seq":3,"stage":"M04","started":"2026-10-26T00:00:00.000+00:00","status":"refused","subject":"Na2O2"},{"ended":"2026-10-26T00:00:00.000+00:00","message":"gate S on the product alone: UNKNOWN; Na2O2 H271, H314 (hard_fail/human_only)","name":"the product's own hazards (handling only)","seq":4,"stage":"M01","started":"2026-10-26T00:00:00.000+00:00","status":"completed","subject":"Na2O2"},{"ended":"2026-10-26T00:00:00.000+00:00","message":"not reached: no route candidate in Mat2Bot's planned families","name":"feasibility","seq":5,"stage":"M05","started":"2026-10-26T00:00:00.000+00:00","status":"skipped","subject":"Na2O2"},{"ended":"2026-10-26T00:00:00.000+00:00","message":"not reached: no route candidate in Mat2Bot's planned families","name":"route cases and ranking","seq":6,"stage":"M07","started":"2026-10-26T00:00:00.000+00:00","status":"skipped","subject":"Na2O2"},{"ended":"2026-10-26T00:00:00.000+00:00","message":"not reached: no route candidate in Mat2Bot's planned families","name":"procedure","seq":7,"stage":"M08","started":"2026-10-26T00:00:00.000+00:00","status":"skipped","subject":"Na2O2"},{"ended":"2026-10-26T00:00:00.000+00:00","message":"not reached: no route candidate in Mat2Bot's planned families","name":"laboratories","seq":8,"stage":"LAB","started":"2026-10-26T00:00:00.000+00:00","status":"skipped","subject":"Na2O2"}],"layout":{"columns":["M01","M02","M04","M05","M07","M08","LAB","AUDIT"],"rows":{"finding:0":0,"gate:G1":1,"gate:G2":2,"gateS:target":3,"hazard:target:Na2O2":4,"target":0}},"nodes":[{"children":["gate:G1","gate:G2","gateS:target"],"detail":{"checked_against":["the Mat2Bot v0.1 polymorph registry (KCl, CaCO3, ZnO, BaTiO3, and the ZnO competitors Zn(OH)2 and Zn5(OH)8(NO3)2(H2O)2; COD structures and cited stability fields)"],"form":"powder","formula":"Na2O2","identity":"unresolved","known_phases":[],"missing":["known phases of the composition (outside the registry; Materials Project not consulted)","Materials Project energies (no key; never decisive for polymorphs)"],"novelty":"not found in the Mat2Bot v0.1 polymorph registry (KCl, CaCO3, ZnO, BaTiO3, and the ZnO competitors Zn(OH)2 and Zn5(OH)8(NO3)2(H2O)2; COD structures and cited stability fields); no other database consulted","phase":null},"evidence":"n/a","execution":"completed","kind":"target","lab":null,"label":"Na2O2","node_id":"target","presentation_only":false,"ref":"target.json#target","science":"unresolved","stage":"M01"},{"children":[],"detail":{"findings":[],"rules":["R-G1-INPUT-001"]},"evidence":"n/a","execution":"completed","kind":"claim","lab":null,"label":"Gate G1: PASS","node_id":"gate:G1","presentation_only":false,"ref":"target.json#gates/G1","science":"PASS","stage":"M01"},{"children":[],"detail":{"findings":[{"code":"IDENTITY_UNRESOLVED","message":"Na2O2 is outside the Mat2Bot v0.1 polymorph registry (KCl, CaCO3, ZnO, BaTiO3, and the ZnO competitors Zn(OH)2 and Zn5(OH)8(NO3)2(H2O)2; COD structures and cited stability fields)","rule":"R-G2-ID-001"}],"rules":["R-G2-ID-001","R-M01-ID-001","R-M01-PHASE-001"]},"evidence":"n/a","execution":"completed","kind":"claim","lab":null,"label":"Gate G2: UNKNOWN","node_id":"gate:G2","presentation_only":false,"ref":"target.json#gates/G2","science":"UNKNOWN","stage":"M01"},{"children":["hazard:target:Na2O2"],"detail":{"findings":[{"code":"HAZARD_HARD_FAIL","message":"sodium peroxide (Na2O2, product): H271 (harmonised): no unattended automated step may handle it; a person may, after G7"},{"code":"HAZARD_HUMAN_ONLY","message":"sodium peroxide (Na2O2, product): H314 (harmonised): a person handles it; G7 records it"},{"code":"HAZARD_UNKNOWN","message":"no reagent of this route is known, so their hazards are unknown; a person decides at G7"}],"what":"what handling the material demands; not a route verdict"},"evidence":"n/a","execution":"completed","kind":"hazard","lab":null,"label":"Handling the product (gate S on it alone): UNKNOWN","node_id":"gateS:target","presentation_only":false,"ref":"safety/target.json#gate","science":"UNKNOWN","stage":"M01"},{"children":[],"detail":{"codes":["H271","H314"],"demands":["hard_fail","human_only"],"harmonised":true,"pubchem_cid":14803,"url":"https://pubchem.ncbi.nlm.nih.gov/compound/14803#section=GHS-Classification"},"evidence":"verified","execution":"completed","kind":"hazard","lab":null,"label":"sodium peroxide (Na2O2): hard_fail, human_only","node_id":"hazard:target:Na2O2","presentation_only":false,"ref":"safety/target.json#substances/Na2O2","science":null,"stage":"M01"},{"children":[],"detail":{"code":"NO_SUPPORTED_FAMILY","message":"no route for Na2O2 in the families Mat2Bot (milestone 1) plans (documented here: none in the evidence set); not planned rather than planned weakly","rule":"R-M03-SCOPE-001","severity":"warning","subject":"Na2O2"},"evidence":"n/a","execution":"refused","kind":"finding","lab":null,"label":"no route for Na2O2 in the families Mat2Bot (milestone 1) plans (documented here: none in the evidence set); not planned rather than planned weakly","node_id":"finding:0","presentation_only":false,"ref":"plan.json#findings/0","science":null,"stage":"M04"},{"children":["target","gate:G1","gate:G2","gateS:target","hazard:target:Na2O2"],"detail":{"events":[1,4],"how":"","message":"Na2O2: identity unresolved, phase unresolved; gates G1 PASS, G2 UNKNOWN; gate S on the product alone: UNKNOWN; Na2O2 H271, H314 (hard_fail/human_only)"},"evidence":"n/a","execution":"completed","kind":"stage","lab":null,"label":"Target","node_id":"stage:M01","presentation_only":false,"ref":"trace.json#events/M01","science":null,"stage":"M01"},{"children":[],"detail":{"events":[2],"how":"","message":"no synthesis precedent of this composition in the evidence"},"evidence":"n/a","execution":"completed","kind":"stage","lab":null,"label":"Evidence","node_id":"stage:M02","presentation_only":false,"ref":"trace.json#events/M02","science":null,"stage":"M02"},{"children":["finding:0"],"detail":{"events":[3],"how":"","message":"no route for Na2O2 in the families Mat2Bot (milestone 1) plans (documented here: none in the evidence set); not planned rather than planned weakly"},"evidence":"n/a","execution":"refused","kind":"stage","lab":null,"label":"Routes","node_id":"stage:M04","presentation_only":false,"ref":"trace.json#events/M04","science":null,"stage":"M04"},{"children":[],"detail":{"events":[5],"how":"","message":"not reached: no route candidate in Mat2Bot's planned families"},"evidence":"n/a","execution":"skipped","kind":"stage","lab":null,"label":"Science","node_id":"stage:M05","presentation_only":false,"ref":"trace.json#events/M05","science":null,"stage":"M05"},{"children":[],"detail":{"events":[6],"how":"","message":"not reached: no route candidate in Mat2Bot's planned families"},"evidence":"n/a","execution":"skipped","kind":"stage","lab":null,"label":"The case","node_id":"stage:M07","presentation_only":false,"ref":"trace.json#events/M07","science":null,"stage":"M07"},{"children":[],"detail":{"events":[7],"how":"","message":"not reached: no route candidate in Mat2Bot's planned families"},"evidence":"n/a","execution":"skipped","kind":"stage","lab":null,"label":"Procedure","node_id":"stage:M08","presentation_only":false,"ref":"trace.json#events/M08","science":null,"stage":"M08"},{"children":[],"detail":{"events":[8],"how":"","message":"not reached: no route candidate in Mat2Bot's planned families"},"evidence":"n/a","execution":"skipped","kind":"stage","lab":null,"label":"Laboratories","node_id":"stage:LAB","presentation_only":false,"ref":"trace.json#events/LAB","science":null,"stage":"LAB"},{"children":[],"detail":{"events":[],"how":"run `mat2bot audit <package>`; the result never comes from the package itself","message":"the package is audited after it is written: run the auditor, or a live audit fills this column"},"evidence":"n/a","execution":"not_run","kind":"stage","lab":null,"label":"Audit","node_id":"stage:AUDIT","presentation_only":false,"ref":"trace.json#nodes/stage:AUDIT","science":null,"stage":"AUDIT"}],"note":"A projection of the plan's records: every node names the record it shows and every edge a relationship that record holds; nothing here is computed anew. The audit stage is filled only by a live audit.","request_id":"x1","schema":"mat2bot/trace/1","title":"Sodium peroxide (Na2O2)"}</script><script id="trace-config" type="application/json">{"audit_url": "audit.json", "links": {"home": "../../index.html", "report": "report.html", "package": "package.zip"}, "mat2bot": "0.1.0"}</script><div id="trace-app" data-title="Sodium peroxide (Na2O2)"></div><script>/* Mat2Bot Trace viewer: a knowledge graph of the plan's records (folded to the stages at first, each opening on a
|
| 155 |
+
click), a flow map (the stages with arrows, each stage's branches under it), a components view (a stage's records as cards with their typed edges) and a provenance panel (one record),
|
| 156 |
over trace.json and nothing else. Every drawn node is a node of the trace and every drawn line an edge of it; the
|
| 157 |
audit column is filled only from a live audit the host gives (config.audit_url or config.audit). Plain JS, no library.
|
| 158 |
Standalone (trace.html) it keeps its place in the address bar; embedded (the one-box page) it keeps it in memory. */
|
|
|
|
| 338 |
return `<div class="tv-map"><svg viewBox="0 0 ${W} ${H}" width="${W}" height="${H}" role="img" aria-label="the stages Mat2Bot ran, with each stage's records"><defs><marker id="arrow" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="8" markerHeight="8" orient="auto-start-reverse"><path d="M0,0 L10,5 L0,10 z"></path></marker></defs>${parts.join("")}</svg></div>` + legend;
|
| 339 |
}
|
| 340 |
// ---------------------------------------------------------------- the graph: every record a circle, every relationship a line
|
| 341 |
+
// It starts folded: the stages (big circles, the number inside counts their records), the target, the routes, the
|
| 342 |
+
// laboratories and the findings. A stage opens on click (its records spring out of it) and the view zooms in on it.
|
| 343 |
+
// Lines between folded records are bundled into one thicker line between their stages. The layout is a live
|
| 344 |
+
// simulation (repulsion, springs on the links, a pull toward each stage's column so the whole still flows from the
|
| 345 |
+
// target on the left to the audit on the right); dragging a circle pulls its neighbours.
|
| 346 |
const KIND_COLOR = { target: "#2f5d8a", evidence: "#4e79a7", route: "#59a14f", rival: "#e15759", doubt: "#f28e2b", calculation: "#b07aa1",
|
| 347 |
model_output: "#9c755f", step: "#76b7b2", laboratory: "#edc948", capability: "#bab0ab", hazard: "#ff9da7", claim: "#86bcb6", assumption: "#d4a6c8",
|
| 348 |
finding: "#e15759", grouping: "#bab0ab", inference: "#bab0ab" };
|
|
|
|
| 351 |
const KIND_LEGEND = [["target", "the target"], ["evidence", "published record"], ["route", "route proposed"], ["rival", "route set aside"],
|
| 352 |
["claim", "claim"], ["doubt", "doubt"], ["calculation", "number / model"], ["step", "recipe step"], ["laboratory", "laboratory"],
|
| 353 |
["hazard", "hazard"], ["capability", "equipment"]];
|
| 354 |
+
const KEY = ["target", "route", "rival", "laboratory", "finding"]; // shown even while their stage is folded
|
| 355 |
+
const K_LINK = { member: 0.07, flow: 0.004, supported_by: 0.03, computed_from: 0.03, cites: 0.02, refuted_by: 0.03, resolved_by: 0.02,
|
| 356 |
+
rejected_for: 0.04, depends_on: 0.06, mapped_to: 0.015, produced: 0.03, requires_equipment: 0.03 };
|
| 357 |
+
const REDUCED = !!(window.matchMedia && window.matchMedia("(prefers-reduced-motion: reduce)").matches);
|
| 358 |
+
let GRAPH = null; // every record's circle with its position, kept across renders
|
| 359 |
+
let VIS = null; // what is drawn now: the visible circles and the lines between them
|
| 360 |
let VIEWPORT = { k: 1, tx: 0, ty: 0 };
|
| 361 |
+
let VIEW_MODE = "all"; // "all" / "focus": the view follows the layout; "free": the reader moved it
|
| 362 |
+
let OPEN = new Set(), FOCUS = "", FULL = false, HEAT = 1, QUERY = "";
|
| 363 |
+
const SIM = { alpha: 0, raf: 0 };
|
| 364 |
+
let WORLD = null, BOX = null, EL = new Map();
|
| 365 |
+
function graphSize() {
|
| 366 |
+
const W = Math.max(app.clientWidth, 640);
|
| 367 |
+
const H = FULL ? Math.max(window.innerHeight - 230, 400) : Math.max(Math.min(W * 0.62, 760), 440);
|
| 368 |
+
return { W, H };
|
| 369 |
+
}
|
| 370 |
function buildGraph() {
|
| 371 |
const cols = {};
|
| 372 |
STAGES.forEach((st, i) => { cols[st] = i; });
|
| 373 |
+
const nodes = T.nodes.filter((n) => n.kind !== "stage").map((n) => ({ id: n.node_id, n, st: n.stage, r: KIND_R[n.kind] || 6, col: cols[n.stage] ?? 0, hub: false, key: KEY.includes(n.kind) }));
|
| 374 |
+
STAGES.filter((st) => STAGE_NODE[st]).forEach((st) => nodes.push({ id: "stage:" + st, n: STAGE_NODE[st], st, r: 17, col: cols[st], hub: true, key: true }));
|
| 375 |
const byId = new Map(nodes.map((d) => [d.id, d]));
|
| 376 |
const links = [];
|
| 377 |
T.edges.forEach((e) => { if (byId.has(e.source) && byId.has(e.target)) links.push({ s: byId.get(e.source), t: byId.get(e.target), kind: e.kind, label: e.label }); });
|
| 378 |
STAGES.forEach((st) => { const hub = byId.get("stage:" + st); if (!hub) return; topLevel(st).forEach((n) => { const d = byId.get(n.node_id); if (d) links.push({ s: hub, t: d, kind: "member" }); }); });
|
| 379 |
T.nodes.forEach((n) => { if (NESTING.includes(n.kind)) n.children.forEach((c) => { const a = byId.get(n.node_id), b = byId.get(c); if (a && b) links.push({ s: a, t: b, kind: "member" }); }); });
|
| 380 |
+
const hubs = STAGES.map((st) => byId.get("stage:" + st)).filter(Boolean);
|
| 381 |
+
hubs.forEach((h, i) => { if (hubs[i + 1]) links.push({ s: h, t: hubs[i + 1], kind: "flow" }); }); // the stages in the order they ran
|
| 382 |
+
const members = {};
|
| 383 |
+
STAGES.forEach((st) => { members[st] = nodes.filter((d) => !d.hub && d.st === st); });
|
| 384 |
+
const { W, H } = graphSize();
|
| 385 |
let seed = 7;
|
| 386 |
const rnd = () => { seed = (seed * 9301 + 49297) % 233280; return seed / 233280; };
|
| 387 |
+
const g = { nodes, links, byId, members, W, H, rnd, hubOf: (d) => byId.get("stage:" + d.st) || null, colX: (c) => 60 + (c + 0.5) * ((g.W - 120) / STAGES.length) };
|
| 388 |
+
nodes.forEach((d) => { d.x = g.colX(d.col) + (rnd() - 0.5) * 40; d.y = H / 2 + (rnd() - 0.5) * H * (d.hub ? 0.2 : 0.6); d.vx = 0; d.vy = 0; d.fx = null; d.fy = null; });
|
| 389 |
+
return g;
|
| 390 |
+
}
|
| 391 |
+
function shown(d) { return d.hub || d.key || OPEN.has(d.st); }
|
| 392 |
+
function visibleGraph(g) {
|
| 393 |
+
const vnodes = g.nodes.filter(shown), vlinks = [], agg = new Map();
|
| 394 |
+
g.links.forEach((l) => {
|
| 395 |
+
const a = shown(l.s) ? l.s : g.hubOf(l.s), b = shown(l.t) ? l.t : g.hubOf(l.t);
|
| 396 |
+
if (!a || !b || a === b) return;
|
| 397 |
+
if (a === l.s && b === l.t) { vlinks.push({ s: a, t: b, kind: l.kind, label: l.label, n: 1 }); return; }
|
| 398 |
+
if (l.kind === "member") return; // a folded record is inside its stage's circle
|
| 399 |
+
const key = a.id + "\u0000" + b.id + "\u0000" + l.kind, got = agg.get(key);
|
| 400 |
+
if (got) got.n += 1; else agg.set(key, { s: a, t: b, kind: l.kind, n: 1, bundle: true });
|
| 401 |
+
});
|
| 402 |
+
agg.forEach((l) => vlinks.push(l));
|
| 403 |
+
return { vnodes, vlinks };
|
| 404 |
+
}
|
| 405 |
+
function step(g, vis, alpha) {
|
| 406 |
+
const nodes = vis.vnodes, kRep = 1800;
|
| 407 |
+
for (let i = 0; i < nodes.length; i++) {
|
| 408 |
+
const a = nodes[i];
|
| 409 |
+
for (let j = i + 1; j < nodes.length; j++) {
|
| 410 |
+
const b = nodes[j];
|
| 411 |
+
let dx = a.x - b.x, dy = a.y - b.y, d2 = dx * dx + dy * dy;
|
| 412 |
+
if (d2 < 1) { dx = g.rnd() - 0.5; dy = g.rnd() - 0.5; d2 = 1; }
|
| 413 |
+
const d = Math.sqrt(d2), f = (kRep * (a.hub || b.hub ? 2.2 : FOCUS && a.st === FOCUS && b.st === FOCUS ? 1.8 : 1)) / d2;
|
| 414 |
+
dx /= d; dy /= d;
|
| 415 |
+
a.vx += dx * f; a.vy += dy * f; b.vx -= dx * f; b.vy -= dy * f;
|
| 416 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 417 |
}
|
| 418 |
+
vis.vlinks.forEach((l) => {
|
| 419 |
+
const dx = l.t.x - l.s.x, dy = l.t.y - l.s.y, d = Math.sqrt(dx * dx + dy * dy) || 1;
|
| 420 |
+
const want = l.kind === "member" ? (FOCUS && l.t.st === FOCUS && !l.t.hub ? 105 : 62) : l.kind === "flow" ? 150 : 90;
|
| 421 |
+
const f = (d - want) * (K_LINK[l.kind] || 0.03);
|
| 422 |
+
l.s.vx += (dx / d) * f; l.s.vy += (dy / d) * f; l.t.vx -= (dx / d) * f; l.t.vy -= (dy / d) * f;
|
| 423 |
+
});
|
| 424 |
+
nodes.forEach((d) => {
|
| 425 |
+
if (d.fx != null) { d.x = d.fx; d.y = d.fy; d.vx = 0; d.vy = 0; return; }
|
| 426 |
+
d.vx += (g.colX(d.col) - d.x) * (d.hub ? 0.14 : 0.025); // the flow from left to right is kept
|
| 427 |
+
d.vy += (g.H / 2 - d.y) * (d.hub ? 0.02 : 0.004);
|
| 428 |
+
const sp = Math.sqrt(d.vx * d.vx + d.vy * d.vy) || 1, cap = 14 * alpha + 0.5, k = Math.min(sp, cap) / sp;
|
| 429 |
+
d.x += d.vx * k; d.y += d.vy * k; d.vx *= 0.4; d.vy *= 0.4;
|
| 430 |
+
});
|
| 431 |
+
for (let i = 0; i < nodes.length; i++) for (let j = i + 1; j < nodes.length; j++) { // no two circles overlap
|
| 432 |
+
const a = nodes[i], b = nodes[j], dx = b.x - a.x, dy = b.y - a.y, d = Math.sqrt(dx * dx + dy * dy) || 0.01, min = a.r + b.r + 8;
|
| 433 |
+
if (d < min) { const push = (min - d) / 2; if (a.fx == null) { a.x -= (dx / d) * push; a.y -= (dy / d) * push; } if (b.fx == null) { b.x += (dx / d) * push; b.y += (dy / d) * push; } }
|
| 434 |
+
}
|
| 435 |
+
}
|
| 436 |
+
function unfold(st, on) {
|
| 437 |
+
const g = GRAPH, hub = g.byId.get("stage:" + st);
|
| 438 |
+
if (!hub || !g.members[st].length) return;
|
| 439 |
+
if (on && !OPEN.has(st)) { OPEN.add(st); g.members[st].filter((d) => !d.key).forEach((d) => { d.x = hub.x + (g.rnd() - 0.5) * 36; d.y = hub.y + (g.rnd() - 0.5) * 36; d.vx = 0; d.vy = 0; d.fx = null; d.fy = null; }); }
|
| 440 |
+
if (!on) OPEN.delete(st);
|
| 441 |
+
HEAT = 1;
|
| 442 |
+
}
|
| 443 |
+
function boxOf(ds) { const xs = ds.map((d) => d.x), ys = ds.map((d) => d.y); return { x0: Math.min(...xs) - 70, y0: Math.min(...ys) - 24, x1: Math.max(...xs) + 70, y1: Math.max(...ys) + 36 }; }
|
| 444 |
+
function fitTo(box) {
|
| 445 |
+
const g = GRAPH, k = Math.min(g.W / (box.x1 - box.x0 + 40), g.H / (box.y1 - box.y0 + 30), 2.2);
|
| 446 |
+
return { k, tx: (g.W - (box.x0 + box.x1) * k) / 2, ty: (g.H - (box.y0 + box.y1) * k) / 2 };
|
| 447 |
+
}
|
| 448 |
+
function clusterOf(st) { return [GRAPH.byId.get("stage:" + st), ...GRAPH.members[st].filter(shown)].filter(Boolean); }
|
| 449 |
+
function aimView() {
|
| 450 |
+
if (VIEW_MODE === "focus" && FOCUS && GRAPH.byId.has("stage:" + FOCUS)) return fitTo(boxOf(clusterOf(FOCUS)));
|
| 451 |
+
if (VIEW_MODE === "all" && VIS && VIS.vnodes.length) return fitTo(boxOf(VIS.vnodes));
|
| 452 |
+
return null;
|
| 453 |
+
}
|
| 454 |
+
function applyView() {
|
| 455 |
+
if (!WORLD) return;
|
| 456 |
+
WORLD.setAttribute("transform", `translate(${VIEWPORT.tx},${VIEWPORT.ty}) scale(${VIEWPORT.k})`);
|
| 457 |
+
WORLD.style.fontSize = `${Math.min(14, Math.max(6.5, 11 / VIEWPORT.k)).toFixed(2)}px`; // labels keep their size on screen
|
| 458 |
+
if (BOX) BOX.classList.toggle("zoomed", VIEWPORT.k >= 1.5);
|
| 459 |
+
}
|
| 460 |
+
function place() {
|
| 461 |
+
VIS.vnodes.forEach((d) => { const el = EL.get(d.id); if (el) el.setAttribute("transform", `translate(${d.x.toFixed(1)},${d.y.toFixed(1)})`); });
|
| 462 |
+
VIS.vlinks.forEach((l) => { if (!l.el) return; l.el.setAttribute("x1", l.s.x.toFixed(1)); l.el.setAttribute("y1", l.s.y.toFixed(1)); l.el.setAttribute("x2", l.t.x.toFixed(1)); l.el.setAttribute("y2", l.t.y.toFixed(1)); });
|
| 463 |
+
WORLD.querySelectorAll("ellipse.cloud").forEach((c) => {
|
| 464 |
+
const b = boxOf(clusterOf(c.dataset.cloud));
|
| 465 |
+
c.setAttribute("cx", ((b.x0 + b.x1) / 2).toFixed(1)); c.setAttribute("cy", ((b.y0 + b.y1) / 2).toFixed(1));
|
| 466 |
+
c.setAttribute("rx", ((b.x1 - b.x0) / 2 + 8).toFixed(1)); c.setAttribute("ry", ((b.y1 - b.y0) / 2 + 4).toFixed(1));
|
| 467 |
+
});
|
| 468 |
+
}
|
| 469 |
+
function tick() {
|
| 470 |
+
SIM.raf = 0;
|
| 471 |
+
if (!GRAPH || !VIS || !WORLD || !WORLD.isConnected) return;
|
| 472 |
+
let busy = false;
|
| 473 |
+
if (SIM.alpha > 0.012) { step(GRAPH, VIS, SIM.alpha); SIM.alpha *= 0.95; place(); busy = true; }
|
| 474 |
+
const aim = aimView();
|
| 475 |
+
if (aim) {
|
| 476 |
+
const r = REDUCED ? 1 : 0.16;
|
| 477 |
+
VIEWPORT = { k: VIEWPORT.k + (aim.k - VIEWPORT.k) * r, tx: VIEWPORT.tx + (aim.tx - VIEWPORT.tx) * r, ty: VIEWPORT.ty + (aim.ty - VIEWPORT.ty) * r };
|
| 478 |
+
if (Math.abs(aim.k - VIEWPORT.k) > 0.002 || Math.abs(aim.tx - VIEWPORT.tx) > 0.4 || Math.abs(aim.ty - VIEWPORT.ty) > 0.4) busy = true; else VIEWPORT = aim;
|
| 479 |
+
applyView();
|
| 480 |
}
|
| 481 |
+
if (busy) SIM.raf = requestAnimationFrame(tick);
|
|
|
|
|
|
|
| 482 |
}
|
| 483 |
+
function heat(a) {
|
| 484 |
+
SIM.alpha = Math.max(SIM.alpha, a);
|
| 485 |
+
if (REDUCED) { while (SIM.alpha > 0.012) { step(GRAPH, VIS, SIM.alpha); SIM.alpha *= 0.95; } place(); const aim = aimView(); if (aim) VIEWPORT = aim; applyView(); return; }
|
| 486 |
+
if (!SIM.raf) SIM.raf = requestAnimationFrame(tick);
|
| 487 |
}
|
| 488 |
+
function gLabel(d) { return d.hub ? STAGE_WORDS[d.n.stage] || d.n.label : shortLabel(d.n, 22); }
|
| 489 |
+
function toggleStage(st) {
|
| 490 |
+
if (!GRAPH.byId.has("stage:" + st)) return;
|
| 491 |
+
if (FOCUS === st) { unfold(st, false); FOCUS = ""; VIEW_MODE = "all"; } else { unfold(st, true); FOCUS = st; VIEW_MODE = "focus"; }
|
| 492 |
+
render();
|
| 493 |
+
}
|
| 494 |
+
function toggleFull() {
|
| 495 |
+
FULL = !FULL;
|
| 496 |
+
app.classList.toggle("tv-fullpage", FULL);
|
| 497 |
+
document.documentElement.classList.toggle("tv-noscroll", FULL);
|
| 498 |
+
HEAT = Math.max(HEAT, 0.3); VIEW_MODE = FOCUS ? "focus" : "all";
|
| 499 |
+
render();
|
| 500 |
+
if (!FULL) app.scrollIntoView({ block: "nearest" });
|
| 501 |
}
|
| 502 |
function graphView(s) {
|
| 503 |
+
const { W, H } = graphSize();
|
| 504 |
+
if (!GRAPH) { GRAPH = buildGraph(); HEAT = 1; } else if (Math.abs(GRAPH.W - W) > 40 || Math.abs(GRAPH.H - H) > 40) { GRAPH.W = W; GRAPH.H = H; HEAT = Math.max(HEAT, 0.4); }
|
| 505 |
+
const g = GRAPH, sel = s.node || "";
|
| 506 |
+
if (sel && g.byId.has(sel) && !shown(g.byId.get(sel))) unfold(g.byId.get(sel).st, true);
|
| 507 |
+
VIS = visibleGraph(g);
|
| 508 |
+
const inFocus = (d) => FOCUS && d.st === FOCUS;
|
| 509 |
+
const clouds = STAGES.filter((st) => g.byId.has("stage:" + st) && g.members[st].some(shown)).map((st) => `<ellipse class="cloud c${STAGES.indexOf(st) % 4} ${FOCUS === st ? "focus" : ""}" data-cloud="${st}" cx="0" cy="0" rx="0" ry="0"><title>${esc(STAGE_WORDS[st] || st)}</title></ellipse>`).join("");
|
| 510 |
+
const lines = VIS.vlinks.map((l, i) => {
|
| 511 |
+
const word = l.kind === "member" ? "part of" : l.kind === "flow" ? "next stage" : EDGE_WORDS[l.kind] || l.kind;
|
| 512 |
+
const far = FOCUS && !inFocus(l.s) && !inFocus(l.t);
|
| 513 |
+
return `<line class="gl ${l.kind} ${l.bundle ? "bundle" : ""} ${far ? "far" : ""}" data-i="${i}" data-s="${esc(l.s.id)}" data-t="${esc(l.t.id)}"${l.n > 1 ? ` style="stroke-width:${(1.2 + Math.log2(l.n)).toFixed(1)}"` : ""}><title>${l.n > 1 ? `${l.n} × ` : ""}${esc(word)}${l.label ? ": " + esc(l.label) : ""}</title></line>`;
|
| 514 |
}).join("");
|
| 515 |
+
const circles = VIS.vnodes.map((d) => {
|
| 516 |
+
const t = d.hub ? "" : tone(d.n), cnt = d.hub ? g.members[d.st].length : 0;
|
| 517 |
+
return `<g class="gn ${d.hub ? "hub" : ""} ${d.hub && OPEN.has(d.st) ? "open" : ""} ${FOCUS ? (inFocus(d) ? "near" : "far") : ""} tone-${t || "none"} ${d.key ? "lbl-always" : ""} ${sel === d.id ? "sel" : ""}" data-gnode="${esc(d.id)}" tabindex="0" role="button">
|
| 518 |
+
<title>${esc(d.n.label)}${d.hub ? ` (${cnt} records; click to ${OPEN.has(d.st) ? "fold" : "open"})` : ""}</title><circle r="${d.r}" style="fill:${d.hub ? "var(--head)" : KIND_COLOR[d.n.kind] || "#999"}"></circle>
|
| 519 |
+
${d.hub && cnt ? `<text class="cnt" dy="4">${cnt}</text>` : ""}<text class="gt" y="${d.r + 12}">${esc(gLabel(d))}</text></g>`;
|
|
|
|
|
|
|
| 520 |
}).join("");
|
| 521 |
+
const stageChips = STAGES.filter((st) => g.byId.has("stage:" + st)).map((st) => { const n = g.members[st].length;
|
| 522 |
+
return `<button type="button" class="tv-chip ${OPEN.has(st) ? "open" : ""} ${FOCUS === st ? "focus" : ""}" data-gstage="${st}" aria-pressed="${FOCUS === st}">${esc(STAGE_WORDS[st] || st)}${n ? ` <b>${n}</b>` : ""}</button>`; }).join("");
|
| 523 |
const legend = KIND_LEGEND.map(([k, w]) => `<span><i style="background:${KIND_COLOR[k]}"></i> ${esc(w)}</span>`).join("") +
|
| 524 |
+
`<span><i class="ring ok"></i> holds</span><span><i class="ring warn"></i> open / caveat</span><span><i class="ring bad"></i> fails / rejected</span><span><i class="ring off"></i> skipped / not run</span>` +
|
| 525 |
+
`<span><i class="ln flow"></i> stage order</span><span><i class="ln bundle"></i> several relationships, folded into one line</span>`;
|
| 526 |
+
const focusNote = FOCUS ? `<span class="tv-focus">Zoomed in on <b>${esc(STAGE_WORDS[FOCUS] || FOCUS)}</b> · <a href="#" data-stage="${esc(FOCUS)}">see it as a list</a></span>` : "";
|
| 527 |
+
return `<div class="tv-graph-bar"><input type="search" id="tv-find" placeholder="find a record (e.g. NaOH, calcite, doubt)…" aria-label="find a record" value="${esc(QUERY)}">
|
| 528 |
+
<button type="button" data-gall="overview" ${!OPEN.size ? 'aria-current="page"' : ""}>Overview</button><button type="button" data-gall="everything" ${OPEN.size >= STAGES.filter((st) => g.members[st] && g.members[st].length).length ? 'aria-current="page"' : ""}>Everything</button>
|
| 529 |
<button type="button" data-gzoom="in" aria-label="zoom in">+</button><button type="button" data-gzoom="out" aria-label="zoom out">−</button>
|
| 530 |
+
<button type="button" data-gfit="1">Fit</button><button type="button" data-glabels="1">Labels</button><button type="button" data-gfull="1" aria-pressed="${FULL}">${FULL ? "Close full page" : "Full page"}</button></div>
|
| 531 |
+
<div class="tv-stages">${stageChips}${focusNote}</div>
|
| 532 |
+
<p class="tv-hint">Click a stage to open it and zoom in (click it again to fold it back); click a small circle to read that record; hover to see what it is linked to; drag to move, scroll to zoom. The number in a big circle counts the records inside it.</p>
|
| 533 |
+
<div class="tv-graph ${VIS.vnodes.length <= 24 ? "few" : ""} ${FOCUS ? "focus" : ""}" id="tv-graph"><svg viewBox="0 0 ${g.W} ${g.H}" width="100%" height="${g.H}" role="img" aria-label="the plan's records as a network">
|
| 534 |
<g class="world" transform="translate(${VIEWPORT.tx},${VIEWPORT.ty}) scale(${VIEWPORT.k})">${clouds}${lines}${circles}</g></svg></div>
|
| 535 |
+
<p class="tv-legend tv-glegend">${legend}</p>`;
|
| 536 |
}
|
| 537 |
function wireGraph() {
|
| 538 |
+
BOX = app.querySelector("#tv-graph");
|
| 539 |
+
if (!BOX) return;
|
| 540 |
+
const svg = BOX.querySelector("svg"), g = GRAPH;
|
| 541 |
+
WORLD = svg.querySelector("g.world");
|
| 542 |
+
EL = new Map(); WORLD.querySelectorAll("g.gn").forEach((el) => EL.set(el.dataset.gnode, el));
|
| 543 |
+
WORLD.querySelectorAll("line.gl").forEach((el) => { VIS.vlinks[+el.dataset.i].el = el; });
|
| 544 |
+
if (HEAT) { for (let i = 0; i < 30; i++) step(g, VIS, 1); const aim = aimView(); if (aim) VIEWPORT = aim; }
|
| 545 |
+
place(); applyView();
|
| 546 |
+
const a = HEAT; HEAT = 0; if (a) heat(a); else if (aimView()) { if (!SIM.raf) SIM.raf = requestAnimationFrame(tick); }
|
| 547 |
+
const pt = (ev) => { const r = svg.getBoundingClientRect(); return { x: (ev.clientX - r.left) * (g.W / r.width), y: (ev.clientY - r.top) * (g.H / r.height) }; };
|
| 548 |
+
const zoomAt = (p, f) => { const k2 = Math.min(6, Math.max(0.2, VIEWPORT.k * f)), r = k2 / VIEWPORT.k; VIEW_MODE = "free"; VIEWPORT = { k: k2, tx: p.x - (p.x - VIEWPORT.tx) * r, ty: p.y - (p.y - VIEWPORT.ty) * r }; applyView(); };
|
| 549 |
+
svg.addEventListener("wheel", (ev) => { ev.preventDefault(); zoomAt(pt(ev), Math.exp(-ev.deltaY * 0.0015)); }, { passive: false });
|
| 550 |
app.querySelectorAll("[data-gzoom]").forEach((b) => b.addEventListener("click", () => zoomAt({ x: g.W / 2, y: g.H / 2 }, b.dataset.gzoom === "in" ? 1.4 : 1 / 1.4)));
|
| 551 |
+
let drag = null, pinch = null;
|
| 552 |
+
const touches = new Map();
|
| 553 |
svg.addEventListener("pointerdown", (ev) => {
|
| 554 |
touches.set(ev.pointerId, pt(ev));
|
| 555 |
if (touches.size === 2) { const [a, b] = [...touches.values()]; pinch = { d: Math.hypot(a.x - b.x, a.y - b.y), k: VIEWPORT.k }; drag = null; return; }
|
| 556 |
+
const gn = ev.target.closest("g.gn"), p = pt(ev);
|
| 557 |
drag = { x: p.x, y: p.y, node: gn ? g.byId.get(gn.dataset.gnode) : null, moved: false, tx: VIEWPORT.tx, ty: VIEWPORT.ty };
|
| 558 |
svg.setPointerCapture(ev.pointerId);
|
| 559 |
});
|
| 560 |
svg.addEventListener("pointermove", (ev) => {
|
| 561 |
if (touches.has(ev.pointerId)) touches.set(ev.pointerId, pt(ev));
|
| 562 |
+
if (pinch && touches.size === 2) { const [a, b] = [...touches.values()]; const d = Math.hypot(a.x - b.x, a.y - b.y) || 1; zoomAt({ x: (a.x + b.x) / 2, y: (a.y + b.y) / 2 }, (pinch.k * d / pinch.d) / VIEWPORT.k); return; }
|
| 563 |
if (!drag) return;
|
| 564 |
+
const p = pt(ev), dx = p.x - drag.x, dy = p.y - drag.y;
|
|
|
|
| 565 |
if (Math.abs(dx) + Math.abs(dy) > 3) drag.moved = true;
|
| 566 |
if (drag.node) {
|
| 567 |
+
if (!drag.moved) return;
|
| 568 |
const d = drag.node;
|
| 569 |
+
d.fx = d.x + dx / VIEWPORT.k; d.fy = d.y + dy / VIEWPORT.k; d.x = d.fx; d.y = d.fy; drag.x = p.x; drag.y = p.y;
|
| 570 |
+
VIEW_MODE = "free"; heat(0.3); // the neighbours follow
|
| 571 |
+
} else { VIEW_MODE = "free"; VIEWPORT = { ...VIEWPORT, tx: drag.tx + dx, ty: drag.ty + dy }; applyView(); }
|
|
|
|
| 572 |
});
|
| 573 |
const endDrag = (ev) => {
|
| 574 |
touches.delete(ev.pointerId);
|
| 575 |
if (touches.size < 2) pinch = null;
|
| 576 |
if (!drag) return;
|
| 577 |
const d = drag; drag = null;
|
| 578 |
+
if (d.node && d.moved) { d.node.fx = null; d.node.fy = null; return; }
|
| 579 |
+
if (d.node) { if (d.node.hub) toggleStage(d.node.st); else go({ view: state().view, node: d.node.id, cmp: state().cmp }); }
|
| 580 |
};
|
| 581 |
svg.addEventListener("pointerup", endDrag); svg.addEventListener("pointercancel", endDrag);
|
| 582 |
+
svg.addEventListener("dblclick", () => { VIEW_MODE = FOCUS ? "focus" : "all"; if (!SIM.raf) SIM.raf = requestAnimationFrame(tick); });
|
| 583 |
+
const neighbours = (id) => { const set = new Set([id]); VIS.vlinks.forEach((l) => { if (l.s.id === id) set.add(l.t.id); if (l.t.id === id) set.add(l.s.id); }); return set; };
|
| 584 |
svg.addEventListener("pointerover", (ev) => { const gn = ev.target.closest("g.gn"); if (!gn || drag) return; const near = neighbours(gn.dataset.gnode);
|
| 585 |
+
EL.forEach((x, id) => x.classList.toggle("dim", !near.has(id)));
|
| 586 |
+
VIS.vlinks.forEach((l) => { if (!l.el) return; const on = l.s.id === gn.dataset.gnode || l.t.id === gn.dataset.gnode; l.el.classList.toggle("hl", on); l.el.classList.toggle("dim", !on); }); });
|
| 587 |
+
svg.addEventListener("pointerout", (ev) => { if (ev.target.closest("g.gn") && !drag) { WORLD.querySelectorAll(".dim,.hl").forEach((x) => { x.classList.remove("dim"); x.classList.remove("hl"); }); applySearch(); } });
|
| 588 |
const find = app.querySelector("#tv-find");
|
| 589 |
+
if (find) {
|
| 590 |
+
find.addEventListener("input", () => {
|
| 591 |
+
QUERY = find.value.trim();
|
| 592 |
+
const q = QUERY.toLowerCase();
|
| 593 |
+
const hit = (d) => !!q && (d.n.label + " " + JSON.stringify(d.n.detail || {})).toLowerCase().includes(q);
|
| 594 |
+
const need = new Set(g.nodes.filter((d) => hit(d) && !shown(d)).map((d) => d.st));
|
| 595 |
+
if (need.size) { need.forEach((st) => unfold(st, true)); render(); const f = app.querySelector("#tv-find"); if (f) { f.focus(); f.setSelectionRange(f.value.length, f.value.length); } return; }
|
| 596 |
+
applySearch();
|
| 597 |
+
});
|
| 598 |
+
if (QUERY) applySearch();
|
| 599 |
+
}
|
| 600 |
+
}
|
| 601 |
+
function applySearch() {
|
| 602 |
+
const q = QUERY.toLowerCase();
|
| 603 |
+
EL.forEach((x, id) => { const d = GRAPH.byId.get(id); const hit = !q || (d.n.label + " " + JSON.stringify(d.n.detail || {})).toLowerCase().includes(q); x.classList.toggle("dim", !hit); x.classList.toggle("found", !!q && hit); });
|
| 604 |
}
|
| 605 |
function overview(s) {
|
| 606 |
if (s.view !== "flow") return graphView(s) + `<details class="tv-timeline"><summary>What ran, in order (${T.events.length} events)</summary><ol class="tv-events">${T.events.map((e) => `<li class="${e.status}"><span class="seq">${e.seq}</span><span>${esc(e.stage)}</span><span>${esc(e.name)}${e.subject ? ` <small>(${esc(e.subject)})</small>` : ""}<span class="msg">${esc(e.message)}</span></span>${chip("execution", e.status)}</li>`).join("")}</ol></details>`;
|
|
|
|
| 750 |
}
|
| 751 |
}
|
| 752 |
app.addEventListener("click", (ev) => {
|
| 753 |
+
const b = ev.target.closest("[data-tab],[data-stage],[data-node],[data-why],[data-open],[data-cmp],[data-cmp-clear],[data-close],[data-gfit],[data-glabels],[data-gstage],[data-gall],[data-gfull],a[href^='#']");
|
| 754 |
if (!b || !app.contains(b)) return;
|
| 755 |
const s = state();
|
| 756 |
if (b.dataset.tab != null) { ev.preventDefault(); if (b.dataset.tab === "") go({}); else if (b.dataset.tab === "__flow") go({ view: "flow" }); else if (b.dataset.tab === "__comp") go({ stage: s.stage || STAGES[0], cmp: s.cmp }); else go({ stage: s.stage || (s.node ? NODES.get(s.node).stage : STAGES[0]), node: s.node || ((STAGE_NODE[s.stage || STAGES[0]] || { children: [] }).children[0] || "target"), cmp: s.cmp }); return; }
|
| 757 |
+
if (b.dataset.gfit) { VIEW_MODE = FOCUS ? "focus" : "all"; if (!SIM.raf) SIM.raf = requestAnimationFrame(tick); return; }
|
| 758 |
+
if (b.dataset.gstage) { toggleStage(b.dataset.gstage); return; }
|
| 759 |
+
if (b.dataset.gall) { if (b.dataset.gall === "overview") { OPEN.clear(); } else STAGES.forEach((st) => unfold(st, true)); FOCUS = ""; VIEW_MODE = "all"; HEAT = 1; render(); return; }
|
| 760 |
+
if (b.dataset.gfull) { toggleFull(); return; }
|
| 761 |
if (b.dataset.glabels) { const box = app.querySelector("#tv-graph"); if (box) box.classList.toggle("all-labels"); return; }
|
| 762 |
if (b.dataset.stage) { ev.preventDefault(); go({ stage: b.dataset.stage }); return; }
|
| 763 |
if (b.dataset.node) { ev.preventDefault(); go({ stage: s.stage, node: b.dataset.node, cmp: s.cmp }); return; }
|
|
|
|
| 772 |
app.addEventListener("mouseover", (ev) => { const c = ev.target.closest(".tv-card"); if (c) highlight(c.dataset.id, true); });
|
| 773 |
app.addEventListener("mouseout", (ev) => { const c = ev.target.closest(".tv-card"); if (c && c.dataset.id !== state().node) highlight(c.dataset.id, false); });
|
| 774 |
if (!EMBEDDED) window.addEventListener("hashchange", render);
|
| 775 |
+
window.addEventListener("resize", () => requestAnimationFrame(() => { const s = state(); if (s.stage) drawEdges(); else if (s.view === "flow") render(); else if (GRAPH) { const { W, H } = graphSize(); if (Math.abs(GRAPH.W - W) > 40 || Math.abs(GRAPH.H - H) > 40) render(); } }));
|
| 776 |
+
document.addEventListener("keydown", (ev) => { if (ev.key !== "Escape") return; if (state().node) { const s = state(); go({ stage: s.stage, cmp: s.cmp, view: s.view }); } else if (FULL) toggleFull(); });
|
| 777 |
render();
|
| 778 |
if (CFG.audit_url && !AUDIT) {
|
| 779 |
fetch(CFG.audit_url, { cache: "no-store" }).then((r) => (r.ok ? r.json() : null)).then((a) => {
|
explore/cases/x2_caco3_vaterite/package.zip
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:39a6fea8e54e09ae42a846db28ce45e38c12100d5d3a8e5f90d9c065a97f417c
|
| 3 |
+
size 242710
|
explore/cases/x2_caco3_vaterite/trace.html
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|
explore/cases/x3_caco3_aragonite/package.zip
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5fc0ed97caeb57ca4a11e51a60c9a3f4567b866af7b042275e53d641225904af
|
| 3 |
+
size 225704
|
explore/cases/x3_caco3_aragonite/trace.html
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|
explore/data/site.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
{
|
| 2 |
"version": "0.1.0",
|
| 3 |
-
"commit": "
|
| 4 |
"built": "2026-10-27",
|
| 5 |
"evaluation": {
|
| 6 |
"total": 73,
|
|
|
|
| 1 |
{
|
| 2 |
"version": "0.1.0",
|
| 3 |
+
"commit": "501f330",
|
| 4 |
"built": "2026-10-27",
|
| 5 |
"evaluation": {
|
| 6 |
"total": 73,
|
story/story.html
CHANGED
|
@@ -34,8 +34,9 @@
|
|
| 34 |
<section id="map-section" class="st-map" hidden>
|
| 35 |
<h2 class="st-h2">How Mat2Bot got there: the knowledge graph</h2>
|
| 36 |
<p class="st-muted st-lead2">Every circle is one of Mat2Bot's own records (a paper it read, a route, a doubt, a number, a step, a laboratory), every line a
|
| 37 |
-
relationship it recorded between two of them, flowing from the target on the left to the audit on the right.
|
| 38 |
-
|
|
|
|
| 39 |
<div id="map"></div>
|
| 40 |
</section>
|
| 41 |
<section id="story" class="st-story" hidden></section>
|
|
|
|
| 34 |
<section id="map-section" class="st-map" hidden>
|
| 35 |
<h2 class="st-h2">How Mat2Bot got there: the knowledge graph</h2>
|
| 36 |
<p class="st-muted st-lead2">Every circle is one of Mat2Bot's own records (a paper it read, a route, a doubt, a number, a step, a laboratory), every line a
|
| 37 |
+
relationship it recorded between two of them, flowing from the target on the left to the audit on the right. It starts folded: the eight stages
|
| 38 |
+
(the number inside counts their records), the target, the routes and the laboratories. Click a stage to open it and zoom in on its records; click a
|
| 39 |
+
record to read it with its sources; <b>Full page</b> gives the graph the whole window. <b>Flow</b> shows the same as a step-by-step chart.</p>
|
| 40 |
<div id="map"></div>
|
| 41 |
</section>
|
| 42 |
<section id="story" class="st-story" hidden></section>
|
story/viewer.css
CHANGED
|
@@ -113,7 +113,8 @@ details.tv-timeline summary{cursor:pointer;color:var(--accent);font-size:.95rem;
|
|
| 113 |
.tv-graph-bar button{border:1px solid var(--line);background:var(--card);color:var(--fg);border-radius:999px;padding:.35em .9em}
|
| 114 |
.tv-hint{font-size:.84rem;color:var(--muted);flex-basis:100%}
|
| 115 |
.tv-graph{border:1px solid var(--line);border-radius:var(--radius);background:var(--card);overflow:hidden;touch-action:none;cursor:grab}
|
| 116 |
-
.tv-graph:active{cursor:grabbing}.tv-graph svg{display:block;font:
|
|
|
|
| 117 |
.tv-graph line.gl{stroke:var(--line);stroke-width:1.2;opacity:.9}
|
| 118 |
.tv-graph line.member{stroke:var(--line);stroke-width:1;opacity:.5}
|
| 119 |
.tv-graph line.supported_by,.tv-graph line.computed_from,.tv-graph line.cites{stroke:var(--accent)}
|
|
@@ -125,12 +126,28 @@ details.tv-timeline summary{cursor:pointer;color:var(--accent);font-size:.95rem;
|
|
| 125 |
.tv-graph g.gn.tone-ok circle{stroke:var(--ok)}.tv-graph g.gn.tone-warn circle{stroke:var(--warn)}.tv-graph g.gn.tone-bad circle{stroke:var(--bad)}
|
| 126 |
.tv-graph g.gn.tone-off circle{stroke:var(--off);stroke-dasharray:3 2;opacity:.7}
|
| 127 |
.tv-graph g.gn.hub circle{stroke:var(--accent);stroke-width:2.5}
|
| 128 |
-
.tv-graph g.gn text.gt{fill:var(--fg);text-anchor:middle;pointer-events:none;opacity:0;font-size:
|
| 129 |
-
.tv-graph g.gn.hub text.gt{font-weight:700;font-size:
|
| 130 |
.tv-graph g.gn.lbl-always text.gt,.tv-graph.zoomed g.gn text.gt,.tv-graph.all-labels g.gn text.gt,.tv-graph g.gn:hover text.gt,.tv-graph g.gn.sel text.gt,.tv-graph g.gn.found text.gt{opacity:1}
|
| 131 |
.tv-graph g.gn.dim{opacity:.18}.tv-graph g.gn.sel circle{stroke:var(--accent);stroke-width:4}
|
| 132 |
.tv-graph g.gn.found circle{stroke:var(--accent);stroke-width:4}
|
| 133 |
.tv-glegend span{display:inline-flex;align-items:center;gap:.3em}.tv-glegend i{display:inline-block;width:12px;height:12px;border-radius:50%;border:0}
|
| 134 |
.tv-glegend i.ring{background:transparent;border:3px solid var(--ok)}.tv-glegend i.ring.warn{border-color:var(--warn)}.tv-glegend i.ring.bad{border-color:var(--bad)}.tv-glegend i.ring.off{border-color:var(--off);border-style:dashed}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 135 |
.tv-graph ellipse.cloud{fill:var(--accent);opacity:.07;stroke:none}.tv-graph ellipse.cloud.c1{fill:var(--ok)}.tv-graph ellipse.cloud.c2{fill:var(--warn)}.tv-graph ellipse.cloud.c3{fill:#b07aa1}
|
| 136 |
@media (prefers-color-scheme:dark){:root:not([data-theme="light"]) .tv-graph ellipse.cloud{opacity:.12}}
|
|
|
|
| 113 |
.tv-graph-bar button{border:1px solid var(--line);background:var(--card);color:var(--fg);border-radius:999px;padding:.35em .9em}
|
| 114 |
.tv-hint{font-size:.84rem;color:var(--muted);flex-basis:100%}
|
| 115 |
.tv-graph{border:1px solid var(--line);border-radius:var(--radius);background:var(--card);overflow:hidden;touch-action:none;cursor:grab}
|
| 116 |
+
.tv-graph:active{cursor:grabbing}.tv-graph svg{display:block;font:11px/1.2 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif}
|
| 117 |
+
.tv-graph line,.tv-graph circle{vector-effect:non-scaling-stroke}
|
| 118 |
.tv-graph line.gl{stroke:var(--line);stroke-width:1.2;opacity:.9}
|
| 119 |
.tv-graph line.member{stroke:var(--line);stroke-width:1;opacity:.5}
|
| 120 |
.tv-graph line.supported_by,.tv-graph line.computed_from,.tv-graph line.cites{stroke:var(--accent)}
|
|
|
|
| 126 |
.tv-graph g.gn.tone-ok circle{stroke:var(--ok)}.tv-graph g.gn.tone-warn circle{stroke:var(--warn)}.tv-graph g.gn.tone-bad circle{stroke:var(--bad)}
|
| 127 |
.tv-graph g.gn.tone-off circle{stroke:var(--off);stroke-dasharray:3 2;opacity:.7}
|
| 128 |
.tv-graph g.gn.hub circle{stroke:var(--accent);stroke-width:2.5}
|
| 129 |
+
.tv-graph g.gn text.gt{fill:var(--fg);text-anchor:middle;pointer-events:none;opacity:0;font-size:1em;paint-order:stroke;stroke:var(--card);stroke-width:.28em;stroke-linejoin:round}
|
| 130 |
+
.tv-graph g.gn.hub text.gt{font-weight:700;font-size:1.18em;opacity:1}
|
| 131 |
.tv-graph g.gn.lbl-always text.gt,.tv-graph.zoomed g.gn text.gt,.tv-graph.all-labels g.gn text.gt,.tv-graph g.gn:hover text.gt,.tv-graph g.gn.sel text.gt,.tv-graph g.gn.found text.gt{opacity:1}
|
| 132 |
.tv-graph g.gn.dim{opacity:.18}.tv-graph g.gn.sel circle{stroke:var(--accent);stroke-width:4}
|
| 133 |
.tv-graph g.gn.found circle{stroke:var(--accent);stroke-width:4}
|
| 134 |
.tv-glegend span{display:inline-flex;align-items:center;gap:.3em}.tv-glegend i{display:inline-block;width:12px;height:12px;border-radius:50%;border:0}
|
| 135 |
.tv-glegend i.ring{background:transparent;border:3px solid var(--ok)}.tv-glegend i.ring.warn{border-color:var(--warn)}.tv-glegend i.ring.bad{border-color:var(--bad)}.tv-glegend i.ring.off{border-color:var(--off);border-style:dashed}
|
| 136 |
+
.tv-stages{display:flex;flex-wrap:wrap;gap:.4em;align-items:center;margin:0 0 .4em}
|
| 137 |
+
.tv-chip{border:1px solid var(--line);background:var(--card);color:var(--fg);border-radius:999px;padding:.25em .8em;font-size:.92em}
|
| 138 |
+
.tv-chip b{font-weight:600;color:var(--muted);margin-left:.15em}.tv-chip.open{border-color:var(--accent)}
|
| 139 |
+
.tv-chip.focus{background:var(--accent);color:var(--card);border-color:var(--accent)}.tv-chip.focus b{color:var(--card)}
|
| 140 |
+
.tv-focus{font-size:.9em;color:var(--muted);margin-left:.4em}
|
| 141 |
+
p.tv-hint{font-size:.9em;color:var(--muted);margin:0 0 .5em}
|
| 142 |
+
.tv-graph line.flow{stroke:var(--accent);stroke-dasharray:1 6;stroke-linecap:round;opacity:.55;stroke-width:2}
|
| 143 |
+
.tv-graph line.bundle{opacity:.6}.tv-graph line.far{opacity:.12}
|
| 144 |
+
.tv-graph g.gn.hub text.cnt{fill:var(--fg);text-anchor:middle;font-size:1em;font-weight:700;pointer-events:none}
|
| 145 |
+
.tv-graph g.gn.hub.open circle{fill:var(--accent)!important}.tv-graph g.gn.hub.open text.cnt{fill:var(--card)}
|
| 146 |
+
.tv-graph g.gn.far{opacity:.3}.tv-graph.focus g.gn.near text.gt,.tv-graph.few g.gn text.gt{opacity:1}.tv-graph.focus g.gn.far:not(.hub) text.gt{opacity:0}
|
| 147 |
+
.tv-graph ellipse.cloud.focus{opacity:.16}
|
| 148 |
+
.tv-glegend i.ln{display:inline-block;width:1.4em;height:0;border-top:2px dotted var(--accent);vertical-align:middle;margin-right:.3em}
|
| 149 |
+
.tv-glegend i.ln.bundle{border-top:3px solid var(--line)}
|
| 150 |
+
.tv-fullpage{position:fixed;inset:0;z-index:1000;background:var(--bg);padding:12px 16px;overflow:auto;box-sizing:border-box}
|
| 151 |
+
.tv-noscroll{overflow:hidden}
|
| 152 |
.tv-graph ellipse.cloud{fill:var(--accent);opacity:.07;stroke:none}.tv-graph ellipse.cloud.c1{fill:var(--ok)}.tv-graph ellipse.cloud.c2{fill:var(--warn)}.tv-graph ellipse.cloud.c3{fill:#b07aa1}
|
| 153 |
@media (prefers-color-scheme:dark){:root:not([data-theme="light"]) .tv-graph ellipse.cloud{opacity:.12}}
|
story/viewer.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
-
/* Mat2Bot Trace viewer: a
|
| 2 |
-
it), a components view (a stage's records as cards with their typed edges) and a provenance panel (one record),
|
| 3 |
over trace.json and nothing else. Every drawn node is a node of the trace and every drawn line an edge of it; the
|
| 4 |
audit column is filled only from a live audit the host gives (config.audit_url or config.audit). Plain JS, no library.
|
| 5 |
Standalone (trace.html) it keeps its place in the address bar; embedded (the one-box page) it keeps it in memory. */
|
|
@@ -185,6 +185,11 @@
|
|
| 185 |
return `<div class="tv-map"><svg viewBox="0 0 ${W} ${H}" width="${W}" height="${H}" role="img" aria-label="the stages Mat2Bot ran, with each stage's records"><defs><marker id="arrow" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="8" markerHeight="8" orient="auto-start-reverse"><path d="M0,0 L10,5 L0,10 z"></path></marker></defs>${parts.join("")}</svg></div>` + legend;
|
| 186 |
}
|
| 187 |
// ---------------------------------------------------------------- the graph: every record a circle, every relationship a line
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 188 |
const KIND_COLOR = { target: "#2f5d8a", evidence: "#4e79a7", route: "#59a14f", rival: "#e15759", doubt: "#f28e2b", calculation: "#b07aa1",
|
| 189 |
model_output: "#9c755f", step: "#76b7b2", laboratory: "#edc948", capability: "#bab0ab", hazard: "#ff9da7", claim: "#86bcb6", assumption: "#d4a6c8",
|
| 190 |
finding: "#e15759", grouping: "#bab0ab", inference: "#bab0ab" };
|
|
@@ -193,162 +198,256 @@
|
|
| 193 |
const KIND_LEGEND = [["target", "the target"], ["evidence", "published record"], ["route", "route proposed"], ["rival", "route set aside"],
|
| 194 |
["claim", "claim"], ["doubt", "doubt"], ["calculation", "number / model"], ["step", "recipe step"], ["laboratory", "laboratory"],
|
| 195 |
["hazard", "hazard"], ["capability", "equipment"]];
|
| 196 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 197 |
let VIEWPORT = { k: 1, tx: 0, ty: 0 };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 198 |
function buildGraph() {
|
| 199 |
const cols = {};
|
| 200 |
STAGES.forEach((st, i) => { cols[st] = i; });
|
| 201 |
-
const nodes = T.nodes.filter((n) => n.kind !== "stage").map((n) => ({ id: n.node_id, n, r: KIND_R[n.kind] || 6, col: cols[n.stage] ?? 0, hub: false }));
|
| 202 |
-
STAGES.filter((st) => STAGE_NODE[st]).forEach((st) => nodes.push({ id: "stage:" + st, n: STAGE_NODE[st], r: 17, col: cols[st], hub: true }));
|
| 203 |
const byId = new Map(nodes.map((d) => [d.id, d]));
|
| 204 |
const links = [];
|
| 205 |
T.edges.forEach((e) => { if (byId.has(e.source) && byId.has(e.target)) links.push({ s: byId.get(e.source), t: byId.get(e.target), kind: e.kind, label: e.label }); });
|
| 206 |
STAGES.forEach((st) => { const hub = byId.get("stage:" + st); if (!hub) return; topLevel(st).forEach((n) => { const d = byId.get(n.node_id); if (d) links.push({ s: hub, t: d, kind: "member" }); }); });
|
| 207 |
T.nodes.forEach((n) => { if (NESTING.includes(n.kind)) n.children.forEach((c) => { const a = byId.get(n.node_id), b = byId.get(c); if (a && b) links.push({ s: a, t: b, kind: "member" }); }); });
|
| 208 |
-
const
|
| 209 |
-
|
|
|
|
|
|
|
|
|
|
| 210 |
let seed = 7;
|
| 211 |
const rnd = () => { seed = (seed * 9301 + 49297) % 233280; return seed / 233280; };
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 229 |
}
|
| 230 |
-
links.forEach((l) => {
|
| 231 |
-
const dx = l.t.x - l.s.x, dy = l.t.y - l.s.y;
|
| 232 |
-
const d = Math.sqrt(dx * dx + dy * dy) || 1;
|
| 233 |
-
const want = l.kind === "member" ? 58 : 84;
|
| 234 |
-
const f = (d - want) * (kLink[l.kind] || 0.03);
|
| 235 |
-
l.s.vx += (dx / d) * f; l.s.vy += (dy / d) * f; l.t.vx -= (dx / d) * f; l.t.vy -= (dy / d) * f;
|
| 236 |
-
});
|
| 237 |
-
nodes.forEach((d) => {
|
| 238 |
-
d.vx += (colX(d.col) - d.x) * (d.hub ? 0.16 : 0.03); // the flow from left to right is kept
|
| 239 |
-
d.vy += (H / 2 - d.y) * 0.004;
|
| 240 |
-
const sp = Math.sqrt(d.vx * d.vx + d.vy * d.vy) || 1;
|
| 241 |
-
const cap = 12 * temp + 1;
|
| 242 |
-
const k = Math.min(sp, cap) / sp;
|
| 243 |
-
d.x += d.vx * k; d.y += d.vy * k; d.vx *= 0.4; d.vy *= 0.4;
|
| 244 |
-
});
|
| 245 |
}
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 254 |
}
|
| 255 |
-
|
| 256 |
-
const box = { x0: Math.min(...xs) - 40, y0: Math.min(...ys) - 30, x1: Math.max(...xs) + 40, y1: Math.max(...ys) + 30 };
|
| 257 |
-
return { nodes, links, byId, W, H, box };
|
| 258 |
}
|
| 259 |
-
function
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
}
|
| 264 |
-
function gLabel(d) {
|
| 265 |
-
|
| 266 |
-
if (
|
| 267 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 268 |
}
|
| 269 |
function graphView(s) {
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
const sel = s.node || "";
|
| 273 |
-
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
const
|
| 279 |
-
const
|
| 280 |
-
return `<
|
| 281 |
}).join("");
|
| 282 |
-
const
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
<title>${esc(d.n.label)}</title><circle r="${d.r}" style="fill:${d.hub ? "var(--head)" : KIND_COLOR[d.n.kind] || "#999"}"></circle>
|
| 288 |
-
<text class="gt" y="${d.r + 12}">${esc(gLabel(d))}</text></g>`;
|
| 289 |
}).join("");
|
|
|
|
|
|
|
| 290 |
const legend = KIND_LEGEND.map(([k, w]) => `<span><i style="background:${KIND_COLOR[k]}"></i> ${esc(w)}</span>`).join("") +
|
| 291 |
-
`<span><i class="ring ok"></i> holds</span><span><i class="ring warn"></i> open / caveat</span><span><i class="ring bad"></i> fails / rejected</span>`
|
| 292 |
-
|
|
|
|
|
|
|
|
|
|
| 293 |
<button type="button" data-gzoom="in" aria-label="zoom in">+</button><button type="button" data-gzoom="out" aria-label="zoom out">−</button>
|
| 294 |
-
<button type="button" data-gfit="1">Fit</button><button type="button" data-glabels="1">Labels</button>
|
| 295 |
-
|
| 296 |
-
<
|
|
|
|
| 297 |
<g class="world" transform="translate(${VIEWPORT.tx},${VIEWPORT.ty}) scale(${VIEWPORT.k})">${clouds}${lines}${circles}</g></svg></div>
|
| 298 |
-
<p class="tv-legend tv-glegend">${legend}<
|
| 299 |
}
|
| 300 |
function wireGraph() {
|
| 301 |
-
|
| 302 |
-
if (!
|
| 303 |
-
const svg =
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
|
| 309 |
-
|
| 310 |
-
const
|
| 311 |
-
|
| 312 |
-
|
| 313 |
app.querySelectorAll("[data-gzoom]").forEach((b) => b.addEventListener("click", () => zoomAt({ x: g.W / 2, y: g.H / 2 }, b.dataset.gzoom === "in" ? 1.4 : 1 / 1.4)));
|
|
|
|
|
|
|
| 314 |
svg.addEventListener("pointerdown", (ev) => {
|
| 315 |
touches.set(ev.pointerId, pt(ev));
|
| 316 |
if (touches.size === 2) { const [a, b] = [...touches.values()]; pinch = { d: Math.hypot(a.x - b.x, a.y - b.y), k: VIEWPORT.k }; drag = null; return; }
|
| 317 |
-
const gn = ev.target.closest("g.gn")
|
| 318 |
drag = { x: p.x, y: p.y, node: gn ? g.byId.get(gn.dataset.gnode) : null, moved: false, tx: VIEWPORT.tx, ty: VIEWPORT.ty };
|
| 319 |
svg.setPointerCapture(ev.pointerId);
|
| 320 |
});
|
| 321 |
svg.addEventListener("pointermove", (ev) => {
|
| 322 |
if (touches.has(ev.pointerId)) touches.set(ev.pointerId, pt(ev));
|
| 323 |
-
if (pinch && touches.size === 2) { const [a, b] = [...touches.values()]; const d = Math.hypot(a.x - b.x, a.y - b.y) || 1;
|
| 324 |
if (!drag) return;
|
| 325 |
-
const p = pt(ev);
|
| 326 |
-
const dx = p.x - drag.x, dy = p.y - drag.y;
|
| 327 |
if (Math.abs(dx) + Math.abs(dy) > 3) drag.moved = true;
|
| 328 |
if (drag.node) {
|
| 329 |
-
|
| 330 |
const d = drag.node;
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
} else { VIEWPORT = { ...VIEWPORT, tx: drag.tx + dx, ty: drag.ty + dy }; apply(); }
|
| 335 |
});
|
| 336 |
const endDrag = (ev) => {
|
| 337 |
touches.delete(ev.pointerId);
|
| 338 |
if (touches.size < 2) pinch = null;
|
| 339 |
if (!drag) return;
|
| 340 |
const d = drag; drag = null;
|
| 341 |
-
if (
|
|
|
|
| 342 |
};
|
| 343 |
svg.addEventListener("pointerup", endDrag); svg.addEventListener("pointercancel", endDrag);
|
| 344 |
-
svg.addEventListener("dblclick", () => {
|
| 345 |
-
const neighbours = (id) => { const set = new Set([id]);
|
| 346 |
svg.addEventListener("pointerover", (ev) => { const gn = ev.target.closest("g.gn"); if (!gn || drag) return; const near = neighbours(gn.dataset.gnode);
|
| 347 |
-
|
| 348 |
-
|
| 349 |
-
svg.addEventListener("pointerout", (ev) => { if (ev.target.closest("g.gn") && !drag) {
|
| 350 |
const find = app.querySelector("#tv-find");
|
| 351 |
-
if (find)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 352 |
}
|
| 353 |
function overview(s) {
|
| 354 |
if (s.view !== "flow") return graphView(s) + `<details class="tv-timeline"><summary>What ran, in order (${T.events.length} events)</summary><ol class="tv-events">${T.events.map((e) => `<li class="${e.status}"><span class="seq">${e.seq}</span><span>${esc(e.stage)}</span><span>${esc(e.name)}${e.subject ? ` <small>(${esc(e.subject)})</small>` : ""}<span class="msg">${esc(e.message)}</span></span>${chip("execution", e.status)}</li>`).join("")}</ol></details>`;
|
|
@@ -498,11 +597,14 @@
|
|
| 498 |
}
|
| 499 |
}
|
| 500 |
app.addEventListener("click", (ev) => {
|
| 501 |
-
const b = ev.target.closest("[data-tab],[data-stage],[data-node],[data-why],[data-open],[data-cmp],[data-cmp-clear],[data-close],[data-gfit],[data-glabels],a[href^='#']");
|
| 502 |
if (!b || !app.contains(b)) return;
|
| 503 |
const s = state();
|
| 504 |
if (b.dataset.tab != null) { ev.preventDefault(); if (b.dataset.tab === "") go({}); else if (b.dataset.tab === "__flow") go({ view: "flow" }); else if (b.dataset.tab === "__comp") go({ stage: s.stage || STAGES[0], cmp: s.cmp }); else go({ stage: s.stage || (s.node ? NODES.get(s.node).stage : STAGES[0]), node: s.node || ((STAGE_NODE[s.stage || STAGES[0]] || { children: [] }).children[0] || "target"), cmp: s.cmp }); return; }
|
| 505 |
-
if (b.dataset.gfit) { if (
|
|
|
|
|
|
|
|
|
|
| 506 |
if (b.dataset.glabels) { const box = app.querySelector("#tv-graph"); if (box) box.classList.toggle("all-labels"); return; }
|
| 507 |
if (b.dataset.stage) { ev.preventDefault(); go({ stage: b.dataset.stage }); return; }
|
| 508 |
if (b.dataset.node) { ev.preventDefault(); go({ stage: s.stage, node: b.dataset.node, cmp: s.cmp }); return; }
|
|
@@ -517,8 +619,8 @@
|
|
| 517 |
app.addEventListener("mouseover", (ev) => { const c = ev.target.closest(".tv-card"); if (c) highlight(c.dataset.id, true); });
|
| 518 |
app.addEventListener("mouseout", (ev) => { const c = ev.target.closest(".tv-card"); if (c && c.dataset.id !== state().node) highlight(c.dataset.id, false); });
|
| 519 |
if (!EMBEDDED) window.addEventListener("hashchange", render);
|
| 520 |
-
window.addEventListener("resize", () => requestAnimationFrame(() => {
|
| 521 |
-
document.addEventListener("keydown", (ev) => { if (ev.key ==
|
| 522 |
render();
|
| 523 |
if (CFG.audit_url && !AUDIT) {
|
| 524 |
fetch(CFG.audit_url, { cache: "no-store" }).then((r) => (r.ok ? r.json() : null)).then((a) => {
|
|
|
|
| 1 |
+
/* Mat2Bot Trace viewer: a knowledge graph of the plan's records (folded to the stages at first, each opening on a
|
| 2 |
+
click), a flow map (the stages with arrows, each stage's branches under it), a components view (a stage's records as cards with their typed edges) and a provenance panel (one record),
|
| 3 |
over trace.json and nothing else. Every drawn node is a node of the trace and every drawn line an edge of it; the
|
| 4 |
audit column is filled only from a live audit the host gives (config.audit_url or config.audit). Plain JS, no library.
|
| 5 |
Standalone (trace.html) it keeps its place in the address bar; embedded (the one-box page) it keeps it in memory. */
|
|
|
|
| 185 |
return `<div class="tv-map"><svg viewBox="0 0 ${W} ${H}" width="${W}" height="${H}" role="img" aria-label="the stages Mat2Bot ran, with each stage's records"><defs><marker id="arrow" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="8" markerHeight="8" orient="auto-start-reverse"><path d="M0,0 L10,5 L0,10 z"></path></marker></defs>${parts.join("")}</svg></div>` + legend;
|
| 186 |
}
|
| 187 |
// ---------------------------------------------------------------- the graph: every record a circle, every relationship a line
|
| 188 |
+
// It starts folded: the stages (big circles, the number inside counts their records), the target, the routes, the
|
| 189 |
+
// laboratories and the findings. A stage opens on click (its records spring out of it) and the view zooms in on it.
|
| 190 |
+
// Lines between folded records are bundled into one thicker line between their stages. The layout is a live
|
| 191 |
+
// simulation (repulsion, springs on the links, a pull toward each stage's column so the whole still flows from the
|
| 192 |
+
// target on the left to the audit on the right); dragging a circle pulls its neighbours.
|
| 193 |
const KIND_COLOR = { target: "#2f5d8a", evidence: "#4e79a7", route: "#59a14f", rival: "#e15759", doubt: "#f28e2b", calculation: "#b07aa1",
|
| 194 |
model_output: "#9c755f", step: "#76b7b2", laboratory: "#edc948", capability: "#bab0ab", hazard: "#ff9da7", claim: "#86bcb6", assumption: "#d4a6c8",
|
| 195 |
finding: "#e15759", grouping: "#bab0ab", inference: "#bab0ab" };
|
|
|
|
| 198 |
const KIND_LEGEND = [["target", "the target"], ["evidence", "published record"], ["route", "route proposed"], ["rival", "route set aside"],
|
| 199 |
["claim", "claim"], ["doubt", "doubt"], ["calculation", "number / model"], ["step", "recipe step"], ["laboratory", "laboratory"],
|
| 200 |
["hazard", "hazard"], ["capability", "equipment"]];
|
| 201 |
+
const KEY = ["target", "route", "rival", "laboratory", "finding"]; // shown even while their stage is folded
|
| 202 |
+
const K_LINK = { member: 0.07, flow: 0.004, supported_by: 0.03, computed_from: 0.03, cites: 0.02, refuted_by: 0.03, resolved_by: 0.02,
|
| 203 |
+
rejected_for: 0.04, depends_on: 0.06, mapped_to: 0.015, produced: 0.03, requires_equipment: 0.03 };
|
| 204 |
+
const REDUCED = !!(window.matchMedia && window.matchMedia("(prefers-reduced-motion: reduce)").matches);
|
| 205 |
+
let GRAPH = null; // every record's circle with its position, kept across renders
|
| 206 |
+
let VIS = null; // what is drawn now: the visible circles and the lines between them
|
| 207 |
let VIEWPORT = { k: 1, tx: 0, ty: 0 };
|
| 208 |
+
let VIEW_MODE = "all"; // "all" / "focus": the view follows the layout; "free": the reader moved it
|
| 209 |
+
let OPEN = new Set(), FOCUS = "", FULL = false, HEAT = 1, QUERY = "";
|
| 210 |
+
const SIM = { alpha: 0, raf: 0 };
|
| 211 |
+
let WORLD = null, BOX = null, EL = new Map();
|
| 212 |
+
function graphSize() {
|
| 213 |
+
const W = Math.max(app.clientWidth, 640);
|
| 214 |
+
const H = FULL ? Math.max(window.innerHeight - 230, 400) : Math.max(Math.min(W * 0.62, 760), 440);
|
| 215 |
+
return { W, H };
|
| 216 |
+
}
|
| 217 |
function buildGraph() {
|
| 218 |
const cols = {};
|
| 219 |
STAGES.forEach((st, i) => { cols[st] = i; });
|
| 220 |
+
const nodes = T.nodes.filter((n) => n.kind !== "stage").map((n) => ({ id: n.node_id, n, st: n.stage, r: KIND_R[n.kind] || 6, col: cols[n.stage] ?? 0, hub: false, key: KEY.includes(n.kind) }));
|
| 221 |
+
STAGES.filter((st) => STAGE_NODE[st]).forEach((st) => nodes.push({ id: "stage:" + st, n: STAGE_NODE[st], st, r: 17, col: cols[st], hub: true, key: true }));
|
| 222 |
const byId = new Map(nodes.map((d) => [d.id, d]));
|
| 223 |
const links = [];
|
| 224 |
T.edges.forEach((e) => { if (byId.has(e.source) && byId.has(e.target)) links.push({ s: byId.get(e.source), t: byId.get(e.target), kind: e.kind, label: e.label }); });
|
| 225 |
STAGES.forEach((st) => { const hub = byId.get("stage:" + st); if (!hub) return; topLevel(st).forEach((n) => { const d = byId.get(n.node_id); if (d) links.push({ s: hub, t: d, kind: "member" }); }); });
|
| 226 |
T.nodes.forEach((n) => { if (NESTING.includes(n.kind)) n.children.forEach((c) => { const a = byId.get(n.node_id), b = byId.get(c); if (a && b) links.push({ s: a, t: b, kind: "member" }); }); });
|
| 227 |
+
const hubs = STAGES.map((st) => byId.get("stage:" + st)).filter(Boolean);
|
| 228 |
+
hubs.forEach((h, i) => { if (hubs[i + 1]) links.push({ s: h, t: hubs[i + 1], kind: "flow" }); }); // the stages in the order they ran
|
| 229 |
+
const members = {};
|
| 230 |
+
STAGES.forEach((st) => { members[st] = nodes.filter((d) => !d.hub && d.st === st); });
|
| 231 |
+
const { W, H } = graphSize();
|
| 232 |
let seed = 7;
|
| 233 |
const rnd = () => { seed = (seed * 9301 + 49297) % 233280; return seed / 233280; };
|
| 234 |
+
const g = { nodes, links, byId, members, W, H, rnd, hubOf: (d) => byId.get("stage:" + d.st) || null, colX: (c) => 60 + (c + 0.5) * ((g.W - 120) / STAGES.length) };
|
| 235 |
+
nodes.forEach((d) => { d.x = g.colX(d.col) + (rnd() - 0.5) * 40; d.y = H / 2 + (rnd() - 0.5) * H * (d.hub ? 0.2 : 0.6); d.vx = 0; d.vy = 0; d.fx = null; d.fy = null; });
|
| 236 |
+
return g;
|
| 237 |
+
}
|
| 238 |
+
function shown(d) { return d.hub || d.key || OPEN.has(d.st); }
|
| 239 |
+
function visibleGraph(g) {
|
| 240 |
+
const vnodes = g.nodes.filter(shown), vlinks = [], agg = new Map();
|
| 241 |
+
g.links.forEach((l) => {
|
| 242 |
+
const a = shown(l.s) ? l.s : g.hubOf(l.s), b = shown(l.t) ? l.t : g.hubOf(l.t);
|
| 243 |
+
if (!a || !b || a === b) return;
|
| 244 |
+
if (a === l.s && b === l.t) { vlinks.push({ s: a, t: b, kind: l.kind, label: l.label, n: 1 }); return; }
|
| 245 |
+
if (l.kind === "member") return; // a folded record is inside its stage's circle
|
| 246 |
+
const key = a.id + "\u0000" + b.id + "\u0000" + l.kind, got = agg.get(key);
|
| 247 |
+
if (got) got.n += 1; else agg.set(key, { s: a, t: b, kind: l.kind, n: 1, bundle: true });
|
| 248 |
+
});
|
| 249 |
+
agg.forEach((l) => vlinks.push(l));
|
| 250 |
+
return { vnodes, vlinks };
|
| 251 |
+
}
|
| 252 |
+
function step(g, vis, alpha) {
|
| 253 |
+
const nodes = vis.vnodes, kRep = 1800;
|
| 254 |
+
for (let i = 0; i < nodes.length; i++) {
|
| 255 |
+
const a = nodes[i];
|
| 256 |
+
for (let j = i + 1; j < nodes.length; j++) {
|
| 257 |
+
const b = nodes[j];
|
| 258 |
+
let dx = a.x - b.x, dy = a.y - b.y, d2 = dx * dx + dy * dy;
|
| 259 |
+
if (d2 < 1) { dx = g.rnd() - 0.5; dy = g.rnd() - 0.5; d2 = 1; }
|
| 260 |
+
const d = Math.sqrt(d2), f = (kRep * (a.hub || b.hub ? 2.2 : FOCUS && a.st === FOCUS && b.st === FOCUS ? 1.8 : 1)) / d2;
|
| 261 |
+
dx /= d; dy /= d;
|
| 262 |
+
a.vx += dx * f; a.vy += dy * f; b.vx -= dx * f; b.vy -= dy * f;
|
| 263 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 264 |
}
|
| 265 |
+
vis.vlinks.forEach((l) => {
|
| 266 |
+
const dx = l.t.x - l.s.x, dy = l.t.y - l.s.y, d = Math.sqrt(dx * dx + dy * dy) || 1;
|
| 267 |
+
const want = l.kind === "member" ? (FOCUS && l.t.st === FOCUS && !l.t.hub ? 105 : 62) : l.kind === "flow" ? 150 : 90;
|
| 268 |
+
const f = (d - want) * (K_LINK[l.kind] || 0.03);
|
| 269 |
+
l.s.vx += (dx / d) * f; l.s.vy += (dy / d) * f; l.t.vx -= (dx / d) * f; l.t.vy -= (dy / d) * f;
|
| 270 |
+
});
|
| 271 |
+
nodes.forEach((d) => {
|
| 272 |
+
if (d.fx != null) { d.x = d.fx; d.y = d.fy; d.vx = 0; d.vy = 0; return; }
|
| 273 |
+
d.vx += (g.colX(d.col) - d.x) * (d.hub ? 0.14 : 0.025); // the flow from left to right is kept
|
| 274 |
+
d.vy += (g.H / 2 - d.y) * (d.hub ? 0.02 : 0.004);
|
| 275 |
+
const sp = Math.sqrt(d.vx * d.vx + d.vy * d.vy) || 1, cap = 14 * alpha + 0.5, k = Math.min(sp, cap) / sp;
|
| 276 |
+
d.x += d.vx * k; d.y += d.vy * k; d.vx *= 0.4; d.vy *= 0.4;
|
| 277 |
+
});
|
| 278 |
+
for (let i = 0; i < nodes.length; i++) for (let j = i + 1; j < nodes.length; j++) { // no two circles overlap
|
| 279 |
+
const a = nodes[i], b = nodes[j], dx = b.x - a.x, dy = b.y - a.y, d = Math.sqrt(dx * dx + dy * dy) || 0.01, min = a.r + b.r + 8;
|
| 280 |
+
if (d < min) { const push = (min - d) / 2; if (a.fx == null) { a.x -= (dx / d) * push; a.y -= (dy / d) * push; } if (b.fx == null) { b.x += (dx / d) * push; b.y += (dy / d) * push; } }
|
| 281 |
+
}
|
| 282 |
+
}
|
| 283 |
+
function unfold(st, on) {
|
| 284 |
+
const g = GRAPH, hub = g.byId.get("stage:" + st);
|
| 285 |
+
if (!hub || !g.members[st].length) return;
|
| 286 |
+
if (on && !OPEN.has(st)) { OPEN.add(st); g.members[st].filter((d) => !d.key).forEach((d) => { d.x = hub.x + (g.rnd() - 0.5) * 36; d.y = hub.y + (g.rnd() - 0.5) * 36; d.vx = 0; d.vy = 0; d.fx = null; d.fy = null; }); }
|
| 287 |
+
if (!on) OPEN.delete(st);
|
| 288 |
+
HEAT = 1;
|
| 289 |
+
}
|
| 290 |
+
function boxOf(ds) { const xs = ds.map((d) => d.x), ys = ds.map((d) => d.y); return { x0: Math.min(...xs) - 70, y0: Math.min(...ys) - 24, x1: Math.max(...xs) + 70, y1: Math.max(...ys) + 36 }; }
|
| 291 |
+
function fitTo(box) {
|
| 292 |
+
const g = GRAPH, k = Math.min(g.W / (box.x1 - box.x0 + 40), g.H / (box.y1 - box.y0 + 30), 2.2);
|
| 293 |
+
return { k, tx: (g.W - (box.x0 + box.x1) * k) / 2, ty: (g.H - (box.y0 + box.y1) * k) / 2 };
|
| 294 |
+
}
|
| 295 |
+
function clusterOf(st) { return [GRAPH.byId.get("stage:" + st), ...GRAPH.members[st].filter(shown)].filter(Boolean); }
|
| 296 |
+
function aimView() {
|
| 297 |
+
if (VIEW_MODE === "focus" && FOCUS && GRAPH.byId.has("stage:" + FOCUS)) return fitTo(boxOf(clusterOf(FOCUS)));
|
| 298 |
+
if (VIEW_MODE === "all" && VIS && VIS.vnodes.length) return fitTo(boxOf(VIS.vnodes));
|
| 299 |
+
return null;
|
| 300 |
+
}
|
| 301 |
+
function applyView() {
|
| 302 |
+
if (!WORLD) return;
|
| 303 |
+
WORLD.setAttribute("transform", `translate(${VIEWPORT.tx},${VIEWPORT.ty}) scale(${VIEWPORT.k})`);
|
| 304 |
+
WORLD.style.fontSize = `${Math.min(14, Math.max(6.5, 11 / VIEWPORT.k)).toFixed(2)}px`; // labels keep their size on screen
|
| 305 |
+
if (BOX) BOX.classList.toggle("zoomed", VIEWPORT.k >= 1.5);
|
| 306 |
+
}
|
| 307 |
+
function place() {
|
| 308 |
+
VIS.vnodes.forEach((d) => { const el = EL.get(d.id); if (el) el.setAttribute("transform", `translate(${d.x.toFixed(1)},${d.y.toFixed(1)})`); });
|
| 309 |
+
VIS.vlinks.forEach((l) => { if (!l.el) return; l.el.setAttribute("x1", l.s.x.toFixed(1)); l.el.setAttribute("y1", l.s.y.toFixed(1)); l.el.setAttribute("x2", l.t.x.toFixed(1)); l.el.setAttribute("y2", l.t.y.toFixed(1)); });
|
| 310 |
+
WORLD.querySelectorAll("ellipse.cloud").forEach((c) => {
|
| 311 |
+
const b = boxOf(clusterOf(c.dataset.cloud));
|
| 312 |
+
c.setAttribute("cx", ((b.x0 + b.x1) / 2).toFixed(1)); c.setAttribute("cy", ((b.y0 + b.y1) / 2).toFixed(1));
|
| 313 |
+
c.setAttribute("rx", ((b.x1 - b.x0) / 2 + 8).toFixed(1)); c.setAttribute("ry", ((b.y1 - b.y0) / 2 + 4).toFixed(1));
|
| 314 |
+
});
|
| 315 |
+
}
|
| 316 |
+
function tick() {
|
| 317 |
+
SIM.raf = 0;
|
| 318 |
+
if (!GRAPH || !VIS || !WORLD || !WORLD.isConnected) return;
|
| 319 |
+
let busy = false;
|
| 320 |
+
if (SIM.alpha > 0.012) { step(GRAPH, VIS, SIM.alpha); SIM.alpha *= 0.95; place(); busy = true; }
|
| 321 |
+
const aim = aimView();
|
| 322 |
+
if (aim) {
|
| 323 |
+
const r = REDUCED ? 1 : 0.16;
|
| 324 |
+
VIEWPORT = { k: VIEWPORT.k + (aim.k - VIEWPORT.k) * r, tx: VIEWPORT.tx + (aim.tx - VIEWPORT.tx) * r, ty: VIEWPORT.ty + (aim.ty - VIEWPORT.ty) * r };
|
| 325 |
+
if (Math.abs(aim.k - VIEWPORT.k) > 0.002 || Math.abs(aim.tx - VIEWPORT.tx) > 0.4 || Math.abs(aim.ty - VIEWPORT.ty) > 0.4) busy = true; else VIEWPORT = aim;
|
| 326 |
+
applyView();
|
| 327 |
}
|
| 328 |
+
if (busy) SIM.raf = requestAnimationFrame(tick);
|
|
|
|
|
|
|
| 329 |
}
|
| 330 |
+
function heat(a) {
|
| 331 |
+
SIM.alpha = Math.max(SIM.alpha, a);
|
| 332 |
+
if (REDUCED) { while (SIM.alpha > 0.012) { step(GRAPH, VIS, SIM.alpha); SIM.alpha *= 0.95; } place(); const aim = aimView(); if (aim) VIEWPORT = aim; applyView(); return; }
|
| 333 |
+
if (!SIM.raf) SIM.raf = requestAnimationFrame(tick);
|
| 334 |
}
|
| 335 |
+
function gLabel(d) { return d.hub ? STAGE_WORDS[d.n.stage] || d.n.label : shortLabel(d.n, 22); }
|
| 336 |
+
function toggleStage(st) {
|
| 337 |
+
if (!GRAPH.byId.has("stage:" + st)) return;
|
| 338 |
+
if (FOCUS === st) { unfold(st, false); FOCUS = ""; VIEW_MODE = "all"; } else { unfold(st, true); FOCUS = st; VIEW_MODE = "focus"; }
|
| 339 |
+
render();
|
| 340 |
+
}
|
| 341 |
+
function toggleFull() {
|
| 342 |
+
FULL = !FULL;
|
| 343 |
+
app.classList.toggle("tv-fullpage", FULL);
|
| 344 |
+
document.documentElement.classList.toggle("tv-noscroll", FULL);
|
| 345 |
+
HEAT = Math.max(HEAT, 0.3); VIEW_MODE = FOCUS ? "focus" : "all";
|
| 346 |
+
render();
|
| 347 |
+
if (!FULL) app.scrollIntoView({ block: "nearest" });
|
| 348 |
}
|
| 349 |
function graphView(s) {
|
| 350 |
+
const { W, H } = graphSize();
|
| 351 |
+
if (!GRAPH) { GRAPH = buildGraph(); HEAT = 1; } else if (Math.abs(GRAPH.W - W) > 40 || Math.abs(GRAPH.H - H) > 40) { GRAPH.W = W; GRAPH.H = H; HEAT = Math.max(HEAT, 0.4); }
|
| 352 |
+
const g = GRAPH, sel = s.node || "";
|
| 353 |
+
if (sel && g.byId.has(sel) && !shown(g.byId.get(sel))) unfold(g.byId.get(sel).st, true);
|
| 354 |
+
VIS = visibleGraph(g);
|
| 355 |
+
const inFocus = (d) => FOCUS && d.st === FOCUS;
|
| 356 |
+
const clouds = STAGES.filter((st) => g.byId.has("stage:" + st) && g.members[st].some(shown)).map((st) => `<ellipse class="cloud c${STAGES.indexOf(st) % 4} ${FOCUS === st ? "focus" : ""}" data-cloud="${st}" cx="0" cy="0" rx="0" ry="0"><title>${esc(STAGE_WORDS[st] || st)}</title></ellipse>`).join("");
|
| 357 |
+
const lines = VIS.vlinks.map((l, i) => {
|
| 358 |
+
const word = l.kind === "member" ? "part of" : l.kind === "flow" ? "next stage" : EDGE_WORDS[l.kind] || l.kind;
|
| 359 |
+
const far = FOCUS && !inFocus(l.s) && !inFocus(l.t);
|
| 360 |
+
return `<line class="gl ${l.kind} ${l.bundle ? "bundle" : ""} ${far ? "far" : ""}" data-i="${i}" data-s="${esc(l.s.id)}" data-t="${esc(l.t.id)}"${l.n > 1 ? ` style="stroke-width:${(1.2 + Math.log2(l.n)).toFixed(1)}"` : ""}><title>${l.n > 1 ? `${l.n} × ` : ""}${esc(word)}${l.label ? ": " + esc(l.label) : ""}</title></line>`;
|
| 361 |
}).join("");
|
| 362 |
+
const circles = VIS.vnodes.map((d) => {
|
| 363 |
+
const t = d.hub ? "" : tone(d.n), cnt = d.hub ? g.members[d.st].length : 0;
|
| 364 |
+
return `<g class="gn ${d.hub ? "hub" : ""} ${d.hub && OPEN.has(d.st) ? "open" : ""} ${FOCUS ? (inFocus(d) ? "near" : "far") : ""} tone-${t || "none"} ${d.key ? "lbl-always" : ""} ${sel === d.id ? "sel" : ""}" data-gnode="${esc(d.id)}" tabindex="0" role="button">
|
| 365 |
+
<title>${esc(d.n.label)}${d.hub ? ` (${cnt} records; click to ${OPEN.has(d.st) ? "fold" : "open"})` : ""}</title><circle r="${d.r}" style="fill:${d.hub ? "var(--head)" : KIND_COLOR[d.n.kind] || "#999"}"></circle>
|
| 366 |
+
${d.hub && cnt ? `<text class="cnt" dy="4">${cnt}</text>` : ""}<text class="gt" y="${d.r + 12}">${esc(gLabel(d))}</text></g>`;
|
|
|
|
|
|
|
| 367 |
}).join("");
|
| 368 |
+
const stageChips = STAGES.filter((st) => g.byId.has("stage:" + st)).map((st) => { const n = g.members[st].length;
|
| 369 |
+
return `<button type="button" class="tv-chip ${OPEN.has(st) ? "open" : ""} ${FOCUS === st ? "focus" : ""}" data-gstage="${st}" aria-pressed="${FOCUS === st}">${esc(STAGE_WORDS[st] || st)}${n ? ` <b>${n}</b>` : ""}</button>`; }).join("");
|
| 370 |
const legend = KIND_LEGEND.map(([k, w]) => `<span><i style="background:${KIND_COLOR[k]}"></i> ${esc(w)}</span>`).join("") +
|
| 371 |
+
`<span><i class="ring ok"></i> holds</span><span><i class="ring warn"></i> open / caveat</span><span><i class="ring bad"></i> fails / rejected</span><span><i class="ring off"></i> skipped / not run</span>` +
|
| 372 |
+
`<span><i class="ln flow"></i> stage order</span><span><i class="ln bundle"></i> several relationships, folded into one line</span>`;
|
| 373 |
+
const focusNote = FOCUS ? `<span class="tv-focus">Zoomed in on <b>${esc(STAGE_WORDS[FOCUS] || FOCUS)}</b> · <a href="#" data-stage="${esc(FOCUS)}">see it as a list</a></span>` : "";
|
| 374 |
+
return `<div class="tv-graph-bar"><input type="search" id="tv-find" placeholder="find a record (e.g. NaOH, calcite, doubt)…" aria-label="find a record" value="${esc(QUERY)}">
|
| 375 |
+
<button type="button" data-gall="overview" ${!OPEN.size ? 'aria-current="page"' : ""}>Overview</button><button type="button" data-gall="everything" ${OPEN.size >= STAGES.filter((st) => g.members[st] && g.members[st].length).length ? 'aria-current="page"' : ""}>Everything</button>
|
| 376 |
<button type="button" data-gzoom="in" aria-label="zoom in">+</button><button type="button" data-gzoom="out" aria-label="zoom out">−</button>
|
| 377 |
+
<button type="button" data-gfit="1">Fit</button><button type="button" data-glabels="1">Labels</button><button type="button" data-gfull="1" aria-pressed="${FULL}">${FULL ? "Close full page" : "Full page"}</button></div>
|
| 378 |
+
<div class="tv-stages">${stageChips}${focusNote}</div>
|
| 379 |
+
<p class="tv-hint">Click a stage to open it and zoom in (click it again to fold it back); click a small circle to read that record; hover to see what it is linked to; drag to move, scroll to zoom. The number in a big circle counts the records inside it.</p>
|
| 380 |
+
<div class="tv-graph ${VIS.vnodes.length <= 24 ? "few" : ""} ${FOCUS ? "focus" : ""}" id="tv-graph"><svg viewBox="0 0 ${g.W} ${g.H}" width="100%" height="${g.H}" role="img" aria-label="the plan's records as a network">
|
| 381 |
<g class="world" transform="translate(${VIEWPORT.tx},${VIEWPORT.ty}) scale(${VIEWPORT.k})">${clouds}${lines}${circles}</g></svg></div>
|
| 382 |
+
<p class="tv-legend tv-glegend">${legend}</p>`;
|
| 383 |
}
|
| 384 |
function wireGraph() {
|
| 385 |
+
BOX = app.querySelector("#tv-graph");
|
| 386 |
+
if (!BOX) return;
|
| 387 |
+
const svg = BOX.querySelector("svg"), g = GRAPH;
|
| 388 |
+
WORLD = svg.querySelector("g.world");
|
| 389 |
+
EL = new Map(); WORLD.querySelectorAll("g.gn").forEach((el) => EL.set(el.dataset.gnode, el));
|
| 390 |
+
WORLD.querySelectorAll("line.gl").forEach((el) => { VIS.vlinks[+el.dataset.i].el = el; });
|
| 391 |
+
if (HEAT) { for (let i = 0; i < 30; i++) step(g, VIS, 1); const aim = aimView(); if (aim) VIEWPORT = aim; }
|
| 392 |
+
place(); applyView();
|
| 393 |
+
const a = HEAT; HEAT = 0; if (a) heat(a); else if (aimView()) { if (!SIM.raf) SIM.raf = requestAnimationFrame(tick); }
|
| 394 |
+
const pt = (ev) => { const r = svg.getBoundingClientRect(); return { x: (ev.clientX - r.left) * (g.W / r.width), y: (ev.clientY - r.top) * (g.H / r.height) }; };
|
| 395 |
+
const zoomAt = (p, f) => { const k2 = Math.min(6, Math.max(0.2, VIEWPORT.k * f)), r = k2 / VIEWPORT.k; VIEW_MODE = "free"; VIEWPORT = { k: k2, tx: p.x - (p.x - VIEWPORT.tx) * r, ty: p.y - (p.y - VIEWPORT.ty) * r }; applyView(); };
|
| 396 |
+
svg.addEventListener("wheel", (ev) => { ev.preventDefault(); zoomAt(pt(ev), Math.exp(-ev.deltaY * 0.0015)); }, { passive: false });
|
| 397 |
app.querySelectorAll("[data-gzoom]").forEach((b) => b.addEventListener("click", () => zoomAt({ x: g.W / 2, y: g.H / 2 }, b.dataset.gzoom === "in" ? 1.4 : 1 / 1.4)));
|
| 398 |
+
let drag = null, pinch = null;
|
| 399 |
+
const touches = new Map();
|
| 400 |
svg.addEventListener("pointerdown", (ev) => {
|
| 401 |
touches.set(ev.pointerId, pt(ev));
|
| 402 |
if (touches.size === 2) { const [a, b] = [...touches.values()]; pinch = { d: Math.hypot(a.x - b.x, a.y - b.y), k: VIEWPORT.k }; drag = null; return; }
|
| 403 |
+
const gn = ev.target.closest("g.gn"), p = pt(ev);
|
| 404 |
drag = { x: p.x, y: p.y, node: gn ? g.byId.get(gn.dataset.gnode) : null, moved: false, tx: VIEWPORT.tx, ty: VIEWPORT.ty };
|
| 405 |
svg.setPointerCapture(ev.pointerId);
|
| 406 |
});
|
| 407 |
svg.addEventListener("pointermove", (ev) => {
|
| 408 |
if (touches.has(ev.pointerId)) touches.set(ev.pointerId, pt(ev));
|
| 409 |
+
if (pinch && touches.size === 2) { const [a, b] = [...touches.values()]; const d = Math.hypot(a.x - b.x, a.y - b.y) || 1; zoomAt({ x: (a.x + b.x) / 2, y: (a.y + b.y) / 2 }, (pinch.k * d / pinch.d) / VIEWPORT.k); return; }
|
| 410 |
if (!drag) return;
|
| 411 |
+
const p = pt(ev), dx = p.x - drag.x, dy = p.y - drag.y;
|
|
|
|
| 412 |
if (Math.abs(dx) + Math.abs(dy) > 3) drag.moved = true;
|
| 413 |
if (drag.node) {
|
| 414 |
+
if (!drag.moved) return;
|
| 415 |
const d = drag.node;
|
| 416 |
+
d.fx = d.x + dx / VIEWPORT.k; d.fy = d.y + dy / VIEWPORT.k; d.x = d.fx; d.y = d.fy; drag.x = p.x; drag.y = p.y;
|
| 417 |
+
VIEW_MODE = "free"; heat(0.3); // the neighbours follow
|
| 418 |
+
} else { VIEW_MODE = "free"; VIEWPORT = { ...VIEWPORT, tx: drag.tx + dx, ty: drag.ty + dy }; applyView(); }
|
|
|
|
| 419 |
});
|
| 420 |
const endDrag = (ev) => {
|
| 421 |
touches.delete(ev.pointerId);
|
| 422 |
if (touches.size < 2) pinch = null;
|
| 423 |
if (!drag) return;
|
| 424 |
const d = drag; drag = null;
|
| 425 |
+
if (d.node && d.moved) { d.node.fx = null; d.node.fy = null; return; }
|
| 426 |
+
if (d.node) { if (d.node.hub) toggleStage(d.node.st); else go({ view: state().view, node: d.node.id, cmp: state().cmp }); }
|
| 427 |
};
|
| 428 |
svg.addEventListener("pointerup", endDrag); svg.addEventListener("pointercancel", endDrag);
|
| 429 |
+
svg.addEventListener("dblclick", () => { VIEW_MODE = FOCUS ? "focus" : "all"; if (!SIM.raf) SIM.raf = requestAnimationFrame(tick); });
|
| 430 |
+
const neighbours = (id) => { const set = new Set([id]); VIS.vlinks.forEach((l) => { if (l.s.id === id) set.add(l.t.id); if (l.t.id === id) set.add(l.s.id); }); return set; };
|
| 431 |
svg.addEventListener("pointerover", (ev) => { const gn = ev.target.closest("g.gn"); if (!gn || drag) return; const near = neighbours(gn.dataset.gnode);
|
| 432 |
+
EL.forEach((x, id) => x.classList.toggle("dim", !near.has(id)));
|
| 433 |
+
VIS.vlinks.forEach((l) => { if (!l.el) return; const on = l.s.id === gn.dataset.gnode || l.t.id === gn.dataset.gnode; l.el.classList.toggle("hl", on); l.el.classList.toggle("dim", !on); }); });
|
| 434 |
+
svg.addEventListener("pointerout", (ev) => { if (ev.target.closest("g.gn") && !drag) { WORLD.querySelectorAll(".dim,.hl").forEach((x) => { x.classList.remove("dim"); x.classList.remove("hl"); }); applySearch(); } });
|
| 435 |
const find = app.querySelector("#tv-find");
|
| 436 |
+
if (find) {
|
| 437 |
+
find.addEventListener("input", () => {
|
| 438 |
+
QUERY = find.value.trim();
|
| 439 |
+
const q = QUERY.toLowerCase();
|
| 440 |
+
const hit = (d) => !!q && (d.n.label + " " + JSON.stringify(d.n.detail || {})).toLowerCase().includes(q);
|
| 441 |
+
const need = new Set(g.nodes.filter((d) => hit(d) && !shown(d)).map((d) => d.st));
|
| 442 |
+
if (need.size) { need.forEach((st) => unfold(st, true)); render(); const f = app.querySelector("#tv-find"); if (f) { f.focus(); f.setSelectionRange(f.value.length, f.value.length); } return; }
|
| 443 |
+
applySearch();
|
| 444 |
+
});
|
| 445 |
+
if (QUERY) applySearch();
|
| 446 |
+
}
|
| 447 |
+
}
|
| 448 |
+
function applySearch() {
|
| 449 |
+
const q = QUERY.toLowerCase();
|
| 450 |
+
EL.forEach((x, id) => { const d = GRAPH.byId.get(id); const hit = !q || (d.n.label + " " + JSON.stringify(d.n.detail || {})).toLowerCase().includes(q); x.classList.toggle("dim", !hit); x.classList.toggle("found", !!q && hit); });
|
| 451 |
}
|
| 452 |
function overview(s) {
|
| 453 |
if (s.view !== "flow") return graphView(s) + `<details class="tv-timeline"><summary>What ran, in order (${T.events.length} events)</summary><ol class="tv-events">${T.events.map((e) => `<li class="${e.status}"><span class="seq">${e.seq}</span><span>${esc(e.stage)}</span><span>${esc(e.name)}${e.subject ? ` <small>(${esc(e.subject)})</small>` : ""}<span class="msg">${esc(e.message)}</span></span>${chip("execution", e.status)}</li>`).join("")}</ol></details>`;
|
|
|
|
| 597 |
}
|
| 598 |
}
|
| 599 |
app.addEventListener("click", (ev) => {
|
| 600 |
+
const b = ev.target.closest("[data-tab],[data-stage],[data-node],[data-why],[data-open],[data-cmp],[data-cmp-clear],[data-close],[data-gfit],[data-glabels],[data-gstage],[data-gall],[data-gfull],a[href^='#']");
|
| 601 |
if (!b || !app.contains(b)) return;
|
| 602 |
const s = state();
|
| 603 |
if (b.dataset.tab != null) { ev.preventDefault(); if (b.dataset.tab === "") go({}); else if (b.dataset.tab === "__flow") go({ view: "flow" }); else if (b.dataset.tab === "__comp") go({ stage: s.stage || STAGES[0], cmp: s.cmp }); else go({ stage: s.stage || (s.node ? NODES.get(s.node).stage : STAGES[0]), node: s.node || ((STAGE_NODE[s.stage || STAGES[0]] || { children: [] }).children[0] || "target"), cmp: s.cmp }); return; }
|
| 604 |
+
if (b.dataset.gfit) { VIEW_MODE = FOCUS ? "focus" : "all"; if (!SIM.raf) SIM.raf = requestAnimationFrame(tick); return; }
|
| 605 |
+
if (b.dataset.gstage) { toggleStage(b.dataset.gstage); return; }
|
| 606 |
+
if (b.dataset.gall) { if (b.dataset.gall === "overview") { OPEN.clear(); } else STAGES.forEach((st) => unfold(st, true)); FOCUS = ""; VIEW_MODE = "all"; HEAT = 1; render(); return; }
|
| 607 |
+
if (b.dataset.gfull) { toggleFull(); return; }
|
| 608 |
if (b.dataset.glabels) { const box = app.querySelector("#tv-graph"); if (box) box.classList.toggle("all-labels"); return; }
|
| 609 |
if (b.dataset.stage) { ev.preventDefault(); go({ stage: b.dataset.stage }); return; }
|
| 610 |
if (b.dataset.node) { ev.preventDefault(); go({ stage: s.stage, node: b.dataset.node, cmp: s.cmp }); return; }
|
|
|
|
| 619 |
app.addEventListener("mouseover", (ev) => { const c = ev.target.closest(".tv-card"); if (c) highlight(c.dataset.id, true); });
|
| 620 |
app.addEventListener("mouseout", (ev) => { const c = ev.target.closest(".tv-card"); if (c && c.dataset.id !== state().node) highlight(c.dataset.id, false); });
|
| 621 |
if (!EMBEDDED) window.addEventListener("hashchange", render);
|
| 622 |
+
window.addEventListener("resize", () => requestAnimationFrame(() => { const s = state(); if (s.stage) drawEdges(); else if (s.view === "flow") render(); else if (GRAPH) { const { W, H } = graphSize(); if (Math.abs(GRAPH.W - W) > 40 || Math.abs(GRAPH.H - H) > 40) render(); } }));
|
| 623 |
+
document.addEventListener("keydown", (ev) => { if (ev.key !== "Escape") return; if (state().node) { const s = state(); go({ stage: s.stage, cmp: s.cmp, view: s.view }); } else if (FULL) toggleFull(); });
|
| 624 |
render();
|
| 625 |
if (CFG.audit_url && !AUDIT) {
|
| 626 |
fetch(CFG.audit_url, { cache: "no-store" }).then((r) => (r.ok ? r.json() : null)).then((a) => {
|