counterparts 0.3.1 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (179) hide show
  1. package/CHANGELOG.md +49 -1
  2. package/docs/module-map.md +2 -0
  3. package/package.json +1 -1
  4. package/src/adapters/claude-code/NOTES.md +32 -0
  5. package/src/adapters/claude-code/bin/hook.ts +15 -2
  6. package/src/adapters/claude-code/bin/runner.ts +3 -1
  7. package/src/adapters/claude-code/config.ts +23 -0
  8. package/src/adapters/claude-code/doctor.ts +39 -20
  9. package/src/adapters/claude-code/hooks.ts +32 -12
  10. package/src/adapters/claude-code/index.ts +1 -0
  11. package/src/adapters/cli/commands.ts +178 -59
  12. package/src/adapters/cli/export.ts +27 -3
  13. package/src/adapters/cli/help.ts +22 -8
  14. package/src/adapters/cli/install.ts +3 -5
  15. package/src/adapters/cli/mechanisms.ts +295 -0
  16. package/src/adapters/cli/repair-dates.ts +3 -1
  17. package/src/adapters/dashboard/CONTRACT.md +13 -9
  18. package/src/adapters/dashboard/NOTES.md +3 -2
  19. package/src/adapters/dashboard/activity.ts +2 -1
  20. package/src/adapters/dashboard/bin/dashboard.ts +18 -3
  21. package/src/adapters/dashboard/upgrade.ts +23 -0
  22. package/src/adapters/dashboard/web/README.md +153 -0
  23. package/src/adapters/dashboard/web/actions.ts +631 -0
  24. package/src/adapters/dashboard/web/app.html +40 -1703
  25. package/src/adapters/dashboard/web/app.js +55 -0
  26. package/src/adapters/dashboard/web/mechanisms/association/index.js +15 -0
  27. package/src/adapters/dashboard/web/mechanisms/association/panel.js +17 -0
  28. package/src/adapters/dashboard/web/mechanisms/consolidation/index.js +15 -0
  29. package/src/adapters/dashboard/web/mechanisms/consolidation/panel.js +23 -0
  30. package/src/adapters/dashboard/web/mechanisms/decay/index.js +15 -0
  31. package/src/adapters/dashboard/web/mechanisms/decay/panel.js +45 -0
  32. package/src/adapters/dashboard/web/mechanisms/emotional/index.js +15 -0
  33. package/src/adapters/dashboard/web/mechanisms/episodic-semantic/index.js +15 -0
  34. package/src/adapters/dashboard/web/mechanisms/index.js +60 -0
  35. package/src/adapters/dashboard/web/mechanisms/interference/index.js +15 -0
  36. package/src/adapters/dashboard/web/mechanisms/picture.js +28 -0
  37. package/src/adapters/dashboard/web/mechanisms/prospective/index.js +15 -0
  38. package/src/adapters/dashboard/web/mechanisms/reconsolidation/index.js +15 -0
  39. package/src/adapters/dashboard/web/mechanisms/reconsolidation/panel.js +15 -0
  40. package/src/adapters/dashboard/web/mechanisms/regions.js +30 -0
  41. package/src/adapters/dashboard/web/mechanisms/retrieval/index.js +15 -0
  42. package/src/adapters/dashboard/web/mechanisms/retrieval/panel.js +20 -0
  43. package/src/adapters/dashboard/web/mechanisms/salience/index.js +15 -0
  44. package/src/adapters/dashboard/web/mechanisms/salience/panel.js +14 -0
  45. package/src/adapters/dashboard/web/mechanisms/schema/index.js +15 -0
  46. package/src/adapters/dashboard/web/narrate.ts +10 -10
  47. package/src/adapters/dashboard/web/pages/flow/flow.css +38 -0
  48. package/src/adapters/dashboard/web/pages/flow/index.js +117 -0
  49. package/src/adapters/dashboard/web/pages/flow/sections/blind.js +12 -0
  50. package/src/adapters/dashboard/web/pages/flow/sections/detail.js +45 -0
  51. package/src/adapters/dashboard/web/pages/flow/sections/diagram.js +291 -0
  52. package/src/adapters/dashboard/web/pages/flow/sections/feed.js +11 -0
  53. package/src/adapters/dashboard/web/pages/flow/sections/fired.js +41 -0
  54. package/src/adapters/dashboard/web/pages/flow/sections/heatmap.js +25 -0
  55. package/src/adapters/dashboard/web/pages/flow/sections/records.js +24 -0
  56. package/src/adapters/dashboard/web/pages/flow/sections/symmetry.js +17 -0
  57. package/src/adapters/dashboard/web/pages/flow/state.js +3 -0
  58. package/src/adapters/dashboard/web/pages/health/health.css +93 -0
  59. package/src/adapters/dashboard/web/pages/health/index.js +41 -0
  60. package/src/adapters/dashboard/web/pages/health/sections/archive.js +84 -0
  61. package/src/adapters/dashboard/web/pages/health/sections/checks.js +172 -0
  62. package/src/adapters/dashboard/web/pages/health/sections/cycle.js +37 -0
  63. package/src/adapters/dashboard/web/pages/health/sections/verify.js +54 -0
  64. package/src/adapters/dashboard/web/pages/home/brain.js +375 -0
  65. package/src/adapters/dashboard/web/pages/home/home.css +134 -0
  66. package/src/adapters/dashboard/web/pages/home/index.js +84 -0
  67. package/src/adapters/dashboard/web/pages/home/sections/explorer.js +206 -0
  68. package/src/adapters/dashboard/web/pages/home/sections/hero.js +22 -0
  69. package/src/adapters/dashboard/web/pages/home/sections/live-activity.js +25 -0
  70. package/src/adapters/dashboard/web/pages/home/sections/recent-chapters.js +13 -0
  71. package/src/adapters/dashboard/web/pages/home/sections/tiles.js +52 -0
  72. package/src/adapters/dashboard/web/pages/memories/index.js +75 -0
  73. package/src/adapters/dashboard/web/pages/memories/memories.css +143 -0
  74. package/src/adapters/dashboard/web/pages/memories/sections/constellation.js +178 -0
  75. package/src/adapters/dashboard/web/pages/memories/sections/kinds.js +42 -0
  76. package/src/adapters/dashboard/web/pages/memories/sections/list.js +114 -0
  77. package/src/adapters/dashboard/web/pages/memories/sections/search.js +102 -0
  78. package/src/adapters/dashboard/web/pages/memories/sections/tools.js +155 -0
  79. package/src/adapters/dashboard/web/pages/memories/state.js +22 -0
  80. package/src/adapters/dashboard/web/pages/self/diff.js +79 -0
  81. package/src/adapters/dashboard/web/pages/self/index.js +43 -0
  82. package/src/adapters/dashboard/web/pages/self/markdown.js +61 -0
  83. package/src/adapters/dashboard/web/pages/self/sections/journal.js +32 -0
  84. package/src/adapters/dashboard/web/pages/self/sections/page.js +149 -0
  85. package/src/adapters/dashboard/web/pages/self/sections/settling.js +150 -0
  86. package/src/adapters/dashboard/web/pages/self/sections/stories.js +47 -0
  87. package/src/adapters/dashboard/web/pages/self/sections/wake.js +74 -0
  88. package/src/adapters/dashboard/web/pages/self/self.css +182 -0
  89. package/src/adapters/dashboard/web/server.ts +305 -28
  90. package/src/adapters/dashboard/web/shared/absence.js +14 -0
  91. package/src/adapters/dashboard/web/shared/actions.js +48 -0
  92. package/src/adapters/dashboard/web/shared/api.js +17 -0
  93. package/src/adapters/dashboard/web/shared/base.css +34 -0
  94. package/src/adapters/dashboard/web/shared/canvas.js +68 -0
  95. package/src/adapters/dashboard/web/shared/colors.js +6 -0
  96. package/src/adapters/dashboard/web/shared/dom.js +4 -0
  97. package/src/adapters/dashboard/web/shared/event-modal.js +25 -0
  98. package/src/adapters/dashboard/web/shared/fonts/OFL-courier-prime.txt +93 -0
  99. package/src/adapters/dashboard/web/shared/fonts/OFL-outfit.txt +93 -0
  100. package/src/adapters/dashboard/web/shared/fonts/courier-prime-latin-400.woff2 +0 -0
  101. package/src/adapters/dashboard/web/shared/fonts/courier-prime-latin-700.woff2 +0 -0
  102. package/src/adapters/dashboard/web/shared/fonts/outfit-latin-wght.woff2 +0 -0
  103. package/src/adapters/dashboard/web/shared/format.js +31 -0
  104. package/src/adapters/dashboard/web/shared/layout.css +32 -0
  105. package/src/adapters/dashboard/web/shared/memory-modal.js +124 -0
  106. package/src/adapters/dashboard/web/shared/modal.css +24 -0
  107. package/src/adapters/dashboard/web/shared/modal.js +22 -0
  108. package/src/adapters/dashboard/web/shared/state.js +12 -0
  109. package/src/adapters/dashboard/web/shared/tip.css +4 -0
  110. package/src/adapters/dashboard/web/shared/tip.js +12 -0
  111. package/src/adapters/dashboard/web/shared/tokens.css +50 -0
  112. package/src/adapters/dashboard/web/shared/type.css +52 -0
  113. package/src/adapters/dashboard/web/shared/utilities.css +5 -0
  114. package/src/adapters/dashboard/web/shared/vendor/MIT-three.txt +21 -0
  115. package/src/adapters/dashboard/web/shared/vendor/three.module.min.js +6 -0
  116. package/src/adapters/dashboard/web/shared/widgets/bar.css +9 -0
  117. package/src/adapters/dashboard/web/shared/widgets/card.css +6 -0
  118. package/src/adapters/dashboard/web/shared/widgets/chapters.js +15 -0
  119. package/src/adapters/dashboard/web/shared/widgets/chart.css +4 -0
  120. package/src/adapters/dashboard/web/shared/widgets/confirm.css +31 -0
  121. package/src/adapters/dashboard/web/shared/widgets/confirm.js +52 -0
  122. package/src/adapters/dashboard/web/shared/widgets/feed.css +13 -0
  123. package/src/adapters/dashboard/web/shared/widgets/feed.js +41 -0
  124. package/src/adapters/dashboard/web/shared/widgets/light.css +4 -0
  125. package/src/adapters/dashboard/web/shared/widgets/light.js +15 -0
  126. package/src/adapters/dashboard/web/shared/widgets/rows.css +7 -0
  127. package/src/adapters/dashboard/web/shared/widgets/table.css +17 -0
  128. package/src/adapters/dashboard/web/shared/widgets/tiles.css +14 -0
  129. package/src/adapters/dashboard/web/shell/pages.js +15 -0
  130. package/src/adapters/dashboard/web/shell/pulse.js +86 -0
  131. package/src/adapters/dashboard/web/shell/tabs.js +49 -0
  132. package/src/adapters/dashboard/web/static.ts +76 -0
  133. package/src/adapters/dashboard/web/views/activity.ts +80 -0
  134. package/src/adapters/dashboard/web/views/archive-words.ts +57 -0
  135. package/src/adapters/dashboard/web/views/flow-view.ts +217 -0
  136. package/src/adapters/dashboard/web/views/health.ts +328 -0
  137. package/src/adapters/dashboard/web/views/mechanism-panel.ts +370 -0
  138. package/src/adapters/dashboard/web/views/mechanisms.ts +302 -0
  139. package/src/adapters/dashboard/web/views/memories.ts +342 -0
  140. package/src/adapters/dashboard/web/views/memory.ts +210 -0
  141. package/src/adapters/dashboard/web/views/meta.ts +64 -0
  142. package/src/adapters/dashboard/web/views/mind.ts +729 -0
  143. package/src/adapters/dashboard/web/views/overview.ts +282 -0
  144. package/src/adapters/dashboard/web/views/pulse.ts +19 -0
  145. package/src/adapters/dashboard/web/views/rows.ts +207 -0
  146. package/src/adapters/dashboard/web/views/search.ts +62 -0
  147. package/src/adapters/dashboard/web/views/shared.ts +161 -0
  148. package/src/adapters/dashboard/web/views.ts +34 -1724
  149. package/src/adapters/fired.ts +28 -17
  150. package/src/adapters/mcp/NOTES.md +43 -0
  151. package/src/adapters/mcp/bin/serve.ts +5 -1
  152. package/src/adapters/mcp/index.ts +3 -0
  153. package/src/adapters/mcp/server.ts +163 -6
  154. package/src/adapters/mcp/tools.ts +42 -0
  155. package/src/adapters/mcp/write-up.ts +1 -1
  156. package/src/core/counterpart.ts +30 -1
  157. package/src/core/feelings-wheel.ts +218 -0
  158. package/src/core/mint.ts +14 -2
  159. package/src/core/prospective/INTERFACE-GAPS.md +10 -0
  160. package/src/core/prospective/windows.ts +10 -48
  161. package/src/core/self/NOTES.md +17 -0
  162. package/src/core/self/calendar.ts +7 -78
  163. package/src/core/self/episodes.ts +7 -8
  164. package/src/core/self/index.ts +32 -11
  165. package/src/core/self/writer.ts +22 -22
  166. package/src/core/sleep/cycle.ts +8 -2
  167. package/src/core/store/CONTRACT.md +26 -7
  168. package/src/core/store/NOTES.md +142 -0
  169. package/src/core/store/errors.ts +15 -0
  170. package/src/core/store/feelings.ts +182 -0
  171. package/src/core/store/index.ts +297 -45
  172. package/src/core/store/operational.ts +133 -11
  173. package/src/core/store/owner-op-seam.ts +13 -3
  174. package/src/core/store/pre-migration.ts +3 -1
  175. package/src/core/store/prose.ts +8 -1
  176. package/src/core/store/render.ts +3 -0
  177. package/src/core/time.ts +374 -0
  178. package/src/core/types.ts +13 -0
  179. package/src/adapters/dashboard/web/brain.html +0 -463
@@ -0,0 +1,38 @@
1
+ #flowbox{padding:4px}
2
+ #flowcv{width:100%;display:block;cursor:pointer}
3
+ /* Below ~900px the diagram becomes a LIST of the same fourteen nodes. A canvas
4
+ shrunk to a phone is text clipped mid-word inside overlapping boxes; the data
5
+ behind it is a list of {label, sub, state} records, and a list is honest. */
6
+ #flowlist{padding:4px 2px}
7
+ .fnode{display:grid;grid-template-columns:1fr auto;gap:10px;align-items:baseline;
8
+ padding:11px 13px;border:1px solid var(--border);border-radius:var(--radius);
9
+ margin:6px 4px;cursor:pointer;background:var(--card)}
10
+ .fnode:hover,.fnode.on{border-color:var(--glow);background:var(--hover)}
11
+ .fnode .nm{font-size:11.5px;letter-spacing:1.4px}
12
+ .fnode .sb{color:var(--dim);font-size:10px;display:block;margin-top:3px;letter-spacing:0}
13
+ .fnode .st{font-size:10.5px;color:var(--ink);white-space:nowrap;text-align:right}
14
+ .fnode.silent .st{color:var(--dim)}
15
+ .fchain{color:var(--faint);font-size:9px;letter-spacing:1px;text-align:center;padding:1px 0}
16
+ #flowdetail h3{color:var(--cyan);font-size:13px;font-weight:400;letter-spacing:1.5px;margin-bottom:6px}
17
+ #flowdetail .brain{color:var(--purple);font-size:11px;line-height:1.65;margin:8px 0}
18
+ #flowdetail .breaks{color:var(--amber);font-size:11px;line-height:1.65;margin:8px 0}
19
+ #flowdetail .lab{color:var(--faint);font-size:9px;text-transform:uppercase;letter-spacing:1.4px;margin-top:12px}
20
+ #flowdetail p{font-size:11.5px;margin:6px 0;line-height:1.7}
21
+
22
+ /* ── Under the hood (moved from the health tab, 2026-09-25): the developer
23
+ panels — band symmetry, what fired, every durable record, the heatmap, the
24
+ blind spots. ── */
25
+ #underhood{margin-top:34px;padding-top:18px;border-top:1px solid var(--border)}
26
+ #underhood>.lede{margin-bottom:14px}
27
+ .heat{overflow-x:auto}
28
+ .heatgrid{border-collapse:collapse;font-size:9px}
29
+ .heatgrid td{padding:0;border:none}
30
+ .heatgrid .cell{width:15px;height:15px;border:1px solid var(--bg);border-radius:2px;background:var(--deep)}
31
+ .heatgrid th{padding:2px 8px 2px 0;font-size:9px;text-transform:none;letter-spacing:0;border:none;
32
+ color:var(--dim);text-align:right;white-space:nowrap}
33
+ .heatgrid .dayhdr{color:var(--faint);font-size:8.5px;text-align:center;padding:0 0 4px;border:none}
34
+ .blind{font-size:11.5px;line-height:1.7;padding:10px 0;border-bottom:1px solid var(--border)}
35
+ .blind:last-child{border-bottom:none}
36
+ .blind .w{color:var(--amber)}
37
+ .blind .y{color:var(--dim)}
38
+ #underhood>h2{font-size:18px}
@@ -0,0 +1,117 @@
1
+ /* The flow tab: the architecture, alive — and, below it, "Under the hood":
2
+ the developer panels that used to sit on the health tab. One fetch
3
+ (`/api/flow`) for the diagram and its feed; `/api/node` per selected
4
+ mechanism; `/api/health` and `/api/fired` for the panels underneath. */
5
+ import { api, fail } from "../../shared/api.js";
6
+ import { live, tabs } from "../../shared/state.js";
7
+ import { flow } from "./state.js";
8
+ import * as detail from "./sections/detail.js";
9
+ import * as diagram from "./sections/diagram.js";
10
+ import * as feed from "./sections/feed.js";
11
+ import * as blind from "./sections/blind.js";
12
+ import * as fired from "./sections/fired.js";
13
+ import * as heatmap from "./sections/heatmap.js";
14
+ import * as records from "./sections/records.js";
15
+ import * as symmetry from "./sections/symmetry.js";
16
+
17
+ const markup = `
18
+ <p class="lede">
19
+ The architecture, alive. <b>Only particles mean activity</b> — nothing here drifts for decoration, so a
20
+ still diagram is a still machine. Click any part for what it does, its brain analogy, where that analogy
21
+ deliberately breaks, and what it has actually been doing.
22
+ </p>${diagram.markup}
23
+ <div class="cols">
24
+ <div>${feed.markup}
25
+ </div>
26
+ <div>${detail.markup}
27
+ </div>
28
+ </div>
29
+ <div id="underhood">
30
+ <h2>Under the hood <small>— the raw readings behind the diagram, for whoever is building it</small></h2>
31
+ <div class="cols">
32
+ <div>${symmetry.markup}${records.markup}
33
+ </div>
34
+ <div>${fired.markup}
35
+ </div>
36
+ </div>${heatmap.markup}${blind.markup}
37
+ </div>
38
+ `;
39
+
40
+ /** The panels under the diagram: `/api/health`'s developer half, then the
41
+ * what-fired panel's own `/api/fired`. Each failure is its own sentence. */
42
+ async function renderUnderHood() {
43
+ let d;
44
+ try { d = await api("/api/health"); } catch (e) { return fail("The under-the-hood panels", e); }
45
+ symmetry.paint(d);
46
+ records.paint(d);
47
+ heatmap.paint(d);
48
+ blind.paint(d);
49
+ await fired.render();
50
+ }
51
+
52
+ async function render() {
53
+ try { flow.data = await api("/api/flow"); } catch (e) { return fail("The flow page", e); }
54
+ feed.paint(flow.data);
55
+ live.lastSeq = flow.data.lastSeq;
56
+ diagram.drawFlow();
57
+ // Open on a node rather than on "click any node in the diagram." The
58
+ // mechanism panel is the best writing on the page and an empty box is a
59
+ // 900×90 hole in the middle of it; sleep is the one whose brain analogy most
60
+ // people already half-know, so it is the one worth meeting first.
61
+ if (flow.selected === null) await detail.selectNode("sleep");
62
+ await renderUnderHood();
63
+ }
64
+
65
+ /** The store moved: every count on the diagram moved with it. Left open, the
66
+ * flow page used to report yesterday's numbers beside today's feed. */
67
+ async function refresh() {
68
+ const fresh = await api("/api/flow?limit=24");
69
+ if (flow.data) {
70
+ flow.data = { ...flow.data, nodes: fresh.nodes, lastSeq: fresh.lastSeq };
71
+ if (tabs.current === "flow") diagram.drawFlow();
72
+ }
73
+ }
74
+
75
+ /** One node's state line, for a harness that wants to prove the counters are
76
+ * live rather than take a screenshot's word for it. (`tools/visual-loop`.) */
77
+ window.flowState = (key) => {
78
+ const node = flow.data && flow.data.nodes.find((n) => n.key === key);
79
+ return node ? node.state : "";
80
+ };
81
+
82
+ export default {
83
+ name: "flow",
84
+ mount(section) {
85
+ section.innerHTML = markup;
86
+ diagram.mount(detail.selectNode);
87
+ feed.mount();
88
+ },
89
+ render,
90
+ refresh,
91
+ show: diagram.drawFlow,
92
+ resize: diagram.drawFlow,
93
+ redraw: diagram.drawFlow,
94
+ /** New durable events: particles ride the edges into the nodes that logged
95
+ * them. */
96
+ onEvents(fresh) { diagram.ignite(fresh); },
97
+ /**
98
+ * A deposit with no event of its own. There is nothing to put in the feed —
99
+ * the feed IS the durable log, and inventing a row there would be a lie
100
+ * about what was recorded — but the counters moved and the diagram can say
101
+ * so, along the path a deposit actually takes: the authored door, the gate,
102
+ * the store. Named edges, because the first edge into ENCODE is the crash
103
+ * fallback and an authored deposit did not crash.
104
+ *
105
+ * Since `gate.deposit` this is no longer the branch a note takes — a note
106
+ * logs, so it takes the events branch and its animation is driven by the
107
+ * row's own `node`. This is now the arm for a store that gained rows some
108
+ * other way, which is the only thing it should ever have claimed to be.
109
+ */
110
+ onDeposit() {
111
+ diagram.ignite([
112
+ { node: "remember", via: "session>remember", tone: "calm", delay: 0 },
113
+ { node: "encode", via: "remember>encode", tone: "calm", delay: 0.34 },
114
+ { node: "store", via: "encode>store", tone: "calm", delay: 0.68 },
115
+ ]);
116
+ },
117
+ };
@@ -0,0 +1,12 @@
1
+ /* What I cannot see — named, so an absence is a claim and not a gap. */
2
+ import { $, esc } from "../../../shared/dom.js";
3
+
4
+ export const markup = `
5
+ <h2>What I cannot see <small>— named, so an absence is a claim and not a gap</small></h2>
6
+ <div class="card pad" id="h-blind"></div>`;
7
+
8
+ export function paint(d) {
9
+ $("h-blind").innerHTML = d.blind.map((b) =>
10
+ '<div class="blind"><span class="w">' + esc(b.what) + '</span> <span class="y">' + esc(b.why) + "</span></div>"
11
+ ).join("");
12
+ }
@@ -0,0 +1,45 @@
1
+ /* Selected mechanism — what a node does, its brain analogy, where that analogy
2
+ deliberately breaks, and what it has actually been doing. */
3
+ import { api, fail } from "../../../shared/api.js";
4
+ import { $, esc } from "../../../shared/dom.js";
5
+ import { flow } from "../state.js";
6
+ import { drawFlow } from "./diagram.js";
7
+
8
+ export const markup = `
9
+ <h2>Selected mechanism</h2>
10
+ <div class="card pad" id="flowdetail">
11
+ <p style="color:var(--dim)">Loading…</p>
12
+ </div>`;
13
+
14
+ export async function selectNode(key) {
15
+ flow.selected = key;
16
+ drawFlow();
17
+ let d;
18
+ try { d = await api("/api/node?key=" + encodeURIComponent(key)); }
19
+ catch (e) { return fail("That node", e); }
20
+ $("flowdetail").innerHTML =
21
+ "<h3>" + esc(d.label) + "</h3>" +
22
+ "<p>" + esc(d.what) + "</p>" +
23
+ '<div class="lab">where the brain analogy holds</div>' +
24
+ '<div class="brain">' + esc(d.analog) + "</div>" +
25
+ '<div class="lab">where it deliberately breaks</div>' +
26
+ '<div class="breaks">' + esc(d.breaks) + "</div>" +
27
+ '<div class="lab">right now</div>' +
28
+ "<p style='color:var(--dim)'>" + esc(d.state) + "</p>" +
29
+ '<div class="lab">what it has been doing</div>' +
30
+ (d.noEventOfItsOwn
31
+ ? "<p style='color:var(--dim)'>" + esc(d.noEventOfItsOwn) + "</p>"
32
+ : d.unloggedPath
33
+ ? "<p style='color:var(--dim)'>" + esc(d.unloggedPath) + "</p>" +
34
+ (d.recent.length === 0 ? "" : d.recent.map(nodeEvent).join(""))
35
+ : d.recent.length === 0
36
+ ? "<p style='color:var(--dim)'>" + esc(d.recentAbsent || "(never run)") + " — nothing of this node's has reached the log.</p>"
37
+ : d.recent.map(nodeEvent).join(""));
38
+ }
39
+ function nodeEvent(ev) {
40
+ return "<p class='tone-" + ev.tone + "' style='font-size:11px'>" +
41
+ "<span style='color:var(--faint)'>day " + ev.day + " · </span>" + esc(ev.text) + "</p>";
42
+ }
43
+
44
+ // The phone list's rows select through an inline `onclick` string.
45
+ window.selectNode = selectNode;
@@ -0,0 +1,291 @@
1
+ /* The architecture diagram: fourteen nodes on a canvas (a list below ~900px),
2
+ static edges, and particles that ride ONLY on real new events. */
3
+ import { FACE, clip, fit, roundRect, wrapText } from "../../../shared/canvas.js";
4
+ import { ACCENT, COL } from "../../../shared/colors.js";
5
+ import { $, esc } from "../../../shared/dom.js";
6
+ import { tabs } from "../../../shared/state.js";
7
+ import { flow } from "../state.js";
8
+
9
+ export const markup = `
10
+ <div class="card" id="flowbox">
11
+ <canvas id="flowcv" height="560"></canvas>
12
+ <div id="flowlist" hidden></div>
13
+ </div>`;
14
+
15
+ let flowBoxes = [];
16
+ /** Curves the last frame drew, so a particle rides the edge it belongs to. */
17
+ let edgePaths = {};
18
+ const particles = [];
19
+ const flashes = {};
20
+ let animating = false;
21
+ /** How many fading samples make the comet's tail. */
22
+ const TRAIL = 11;
23
+
24
+ /** A click on a box selects its node; `onSelect` is the detail panel's. */
25
+ export function mount(onSelect) {
26
+ $("flowcv").addEventListener("click", (e) => {
27
+ const rect = e.currentTarget.getBoundingClientRect();
28
+ const x = e.clientX - rect.left, y = e.clientY - rect.top;
29
+ for (const b of flowBoxes) {
30
+ if (x >= b.x && x <= b.x + b.w && y >= b.y && y <= b.y + b.h) { onSelect(b.n.key); return; }
31
+ }
32
+ });
33
+ }
34
+
35
+ function nodeCentre(b) { return { x: b.x + b.w / 2, y: b.y + b.h / 2 }; }
36
+
37
+ /** Under ~900px of container the diagram is a list. Above it, a canvas. */
38
+ const FLOW_CANVAS_MIN = 900;
39
+
40
+ export function drawFlow() {
41
+ if (!flow.data) return;
42
+ const narrow = ($("flowbox").clientWidth || 0) < FLOW_CANVAS_MIN;
43
+ $("flowcv").hidden = narrow;
44
+ $("flowlist").hidden = !narrow;
45
+ if (narrow) return renderFlowList();
46
+ const cv = $("flowcv");
47
+ const { ctx, w, h } = fit(cv);
48
+ const M = 10;
49
+ const boxes = {};
50
+ flowBoxes = [];
51
+ for (const n of flow.data.nodes) {
52
+ const b = { x: M + n.x * (w - 2 * M), y: M + n.y * (h - 2 * M), w: n.w * (w - 2 * M), h: n.h * (h - 2 * M), n };
53
+ boxes[n.key] = b;
54
+ flowBoxes.push(b);
55
+ }
56
+
57
+ // Edges first, dim and static — only particles mean activity.
58
+ //
59
+ // Each edge is a quadratic from centre to centre, but only the part OUTSIDE
60
+ // both boxes is drawn: a line that starts at a node's centre emerges from
61
+ // under its own box, and a label placed at the geometric midpoint lands on
62
+ // top of whatever box sits between the two. So the curve is sampled, clipped
63
+ // to the first and last points in open space, and the label is placed on the
64
+ // visible middle — or dropped when there is no room for it.
65
+ const SAMPLES = 64;
66
+ // Labels already placed this frame. An edge label that would land on another
67
+ // one is dropped rather than overprinted: `at session startootnotes · one
68
+ // loud` was two labels rendering as one string.
69
+ const placed = [];
70
+ const overlaps = (r, o) => r.x < o.x + o.w + 4 && r.x + r.w > o.x - 4 && r.y < o.y + o.h + 3 && r.y + r.h > o.y - 3;
71
+ // Kept for the frame: a particle rides the same clipped curve the edge was
72
+ // drawn along, rather than a second approximation of it.
73
+ edgePaths = {};
74
+
75
+ for (const e of flow.data.edges) {
76
+ const a = boxes[e.from], z = boxes[e.to];
77
+ if (!a || !z) continue;
78
+ const p0 = nodeCentre(a), p1 = nodeCentre(z);
79
+ const bow = e.bow || 0;
80
+ const clamp = (v, lo, hi) => Math.max(lo, Math.min(hi, v));
81
+ const mx = clamp((p0.x + p1.x) / 2 + bow * (p1.y - p0.y), M + 6, w - M - 6);
82
+ const my = clamp((p0.y + p1.y) / 2 - bow * (p1.x - p0.x), M + 14, h - M - 6);
83
+ const at = (t) => ({
84
+ x: (1 - t) * (1 - t) * p0.x + 2 * (1 - t) * t * mx + t * t * p1.x,
85
+ y: (1 - t) * (1 - t) * p0.y + 2 * (1 - t) * t * my + t * t * p1.y,
86
+ });
87
+ const inside = (pt, b, pad) =>
88
+ pt.x >= b.x - pad && pt.x <= b.x + b.w + pad && pt.y >= b.y - pad && pt.y <= b.y + b.h + pad;
89
+
90
+ let start = 0, end = 1;
91
+ for (let i = 0; i <= SAMPLES; i++) { if (!inside(at(i / SAMPLES), a, 3)) { start = i / SAMPLES; break; } }
92
+ for (let i = SAMPLES; i >= 0; i--) { if (!inside(at(i / SAMPLES), z, 3)) { end = i / SAMPLES; break; } }
93
+ if (end <= start) continue;
94
+ edgePaths[e.from + ">" + e.to] = { at, start, end };
95
+
96
+ ctx.save();
97
+ ctx.strokeStyle = e.dotted ? "rgba(255,215,64,.24)" : "rgba(0,229,255,.18)";
98
+ ctx.lineWidth = 1;
99
+ if (e.dotted) ctx.setLineDash([3, 4]);
100
+ ctx.beginPath();
101
+ for (let i = 0; i <= SAMPLES; i++) {
102
+ const t = start + (end - start) * (i / SAMPLES);
103
+ const pt = at(t);
104
+ if (i === 0) ctx.moveTo(pt.x, pt.y); else ctx.lineTo(pt.x, pt.y);
105
+ }
106
+ ctx.stroke();
107
+ ctx.restore();
108
+
109
+ // arrowhead, on the clipped end
110
+ const tip = at(end), back = at(Math.max(start, end - 0.05));
111
+ const ang = Math.atan2(tip.y - back.y, tip.x - back.x);
112
+ ctx.fillStyle = e.dotted ? "rgba(255,215,64,.5)" : "rgba(0,229,255,.42)";
113
+ ctx.beginPath();
114
+ ctx.moveTo(tip.x, tip.y);
115
+ ctx.lineTo(tip.x - Math.cos(ang - 0.42) * 8, tip.y - Math.sin(ang - 0.42) * 8);
116
+ ctx.lineTo(tip.x - Math.cos(ang + 0.42) * 8, tip.y - Math.sin(ang + 0.42) * 8);
117
+ ctx.closePath();
118
+ ctx.fill();
119
+
120
+ if (e.label) {
121
+ ctx.font = "10.5px " + FACE;
122
+ const tw = ctx.measureText(e.label).width;
123
+ // A label on top of a box says nothing and hides something. Try a few
124
+ // places along the visible curve before giving up on it entirely.
125
+ let at_ = null;
126
+ for (const f of [0.5, 0.42, 0.58, 0.34, 0.66]) {
127
+ const pt = at(start + (end - start) * f);
128
+ const box = { x: pt.x - tw / 2 - 4, y: pt.y - 13, w: tw + 8, h: 14 };
129
+ const clear =
130
+ !flowBoxes.some((b) => overlaps(box, { x: b.x, y: b.y, w: b.w, h: b.h })) &&
131
+ !placed.some((o) => overlaps(box, o));
132
+ if (clear && box.x > M && box.x + box.w < w - M) { at_ = pt; placed.push(box); break; }
133
+ }
134
+ if (at_) {
135
+ ctx.textAlign = "center";
136
+ ctx.fillStyle = "rgba(10,14,20,.92)";
137
+ ctx.fillRect(at_.x - tw / 2 - 4, at_.y - 13, tw + 8, 14);
138
+ ctx.fillStyle = "rgba(92,103,115,.95)";
139
+ ctx.fillText(e.label, at_.x, at_.y - 3);
140
+ ctx.textAlign = "left";
141
+ }
142
+ }
143
+ }
144
+
145
+ // nodes
146
+ for (const b of flowBoxes) {
147
+ const n = b.n;
148
+ const col = ACCENT[n.accent] || COL.cyan;
149
+ const glow = flashes[n.key] || 0;
150
+ const on = flow.selected === n.key;
151
+ ctx.fillStyle = "#0d1117";
152
+ ctx.strokeStyle = on ? col : col + (n.silent ? "33" : "66");
153
+ ctx.lineWidth = on ? 1.6 : 1;
154
+ roundRect(ctx, b.x, b.y, b.w, b.h, 4);
155
+ ctx.fill();
156
+ if (glow > 0.02) {
157
+ ctx.save();
158
+ ctx.shadowColor = col;
159
+ ctx.shadowBlur = 34 * glow;
160
+ ctx.lineWidth = 1 + 1.4 * glow;
161
+ ctx.strokeStyle = col;
162
+ ctx.stroke();
163
+ ctx.stroke();
164
+ ctx.restore();
165
+ }
166
+ ctx.stroke();
167
+
168
+ ctx.fillStyle = n.silent && !on ? col + "aa" : col;
169
+ ctx.font = "11.5px " + FACE;
170
+ ctx.fillText(clip(ctx, n.label, b.w - 18), b.x + 9, b.y + 16);
171
+ ctx.fillStyle = "#5c6773";
172
+ ctx.font = "10.5px " + FACE;
173
+ wrapText(ctx, n.sub, b.x + 9, b.y + 29, b.w - 16, 10, 2);
174
+ ctx.fillStyle = n.silent ? "#39424d" : "#c5cdd8";
175
+ ctx.font = "11px " + FACE;
176
+ ctx.fillText(clip(ctx, n.state, b.w - 18), b.x + 9, b.y + b.h - 9);
177
+ }
178
+
179
+ // PARTICLES RIDE ONLY ON REAL NEW EVENTS — and they have to be seen to mean
180
+ // anything. A 2.6px dot on a 1400px diagram was the entire payoff for "only
181
+ // particles mean activity"; this is a comet with a trail, travelling the edge
182
+ // into the node that recorded the event, ending in a flare on the box itself.
183
+ for (const p of particles) {
184
+ const path = edgePaths[p.key];
185
+ const target = boxes[p.node];
186
+ if (!target) continue;
187
+ const point = (t) => {
188
+ if (path) return path.at(path.start + (path.end - path.start) * Math.max(0, Math.min(1, t)));
189
+ // No edge into this node on the diagram: orbit its own box instead.
190
+ const c = nodeCentre(target);
191
+ const a = p.spin + t * 4.4;
192
+ return { x: c.x + Math.cos(a) * (target.w / 2 + 10), y: c.y + Math.sin(a) * (target.h / 2 + 10) };
193
+ };
194
+ ctx.save();
195
+ ctx.globalCompositeOperation = "lighter";
196
+ for (let i = TRAIL; i >= 0; i--) {
197
+ const t = p.t - i * 0.022;
198
+ if (t < 0) continue;
199
+ const q = point(t);
200
+ const fade = 1 - i / (TRAIL + 1);
201
+ ctx.beginPath();
202
+ ctx.arc(q.x, q.y, 1.2 + 3.4 * fade * fade, 0, Math.PI * 2);
203
+ ctx.fillStyle = p.col;
204
+ ctx.globalAlpha = 0.10 + 0.55 * fade * fade;
205
+ ctx.fill();
206
+ }
207
+ // The head, with a halo, so one event is unmistakable at a glance.
208
+ const head = point(p.t);
209
+ ctx.globalAlpha = 1;
210
+ ctx.shadowColor = p.col;
211
+ ctx.shadowBlur = 16;
212
+ ctx.beginPath();
213
+ ctx.arc(head.x, head.y, 4.2, 0, Math.PI * 2);
214
+ ctx.fillStyle = "#ffffff";
215
+ ctx.fill();
216
+ ctx.beginPath();
217
+ ctx.arc(head.x, head.y, 7.5, 0, Math.PI * 2);
218
+ ctx.fillStyle = p.col;
219
+ ctx.globalAlpha = 0.35;
220
+ ctx.fill();
221
+ ctx.restore();
222
+ }
223
+ }
224
+
225
+ /**
226
+ * The same fourteen nodes, in pipeline order, as a list. Every node keeps its
227
+ * accent, its subtitle and its state line, and clicking one opens the same
228
+ * mechanism panel the diagram opens — so nothing is lost on a phone except the
229
+ * arrows, which are named in the chain markers between the rows.
230
+ */
231
+ function renderFlowList() {
232
+ const order = ["session","spans","sweep","remember","encode","store","physics","recall","associate","schemas","prospective","sleep","wake","self"];
233
+ const byKey = {};
234
+ for (const n of flow.data.nodes) byKey[n.key] = n;
235
+ $("flowlist").innerHTML = order.map((key, i) => {
236
+ const n = byKey[key];
237
+ if (!n) return "";
238
+ const col = ACCENT[n.accent] || COL.cyan;
239
+ return (i === 0 ? "" : '<div class="fchain">↓</div>') +
240
+ '<div class="fnode' + (n.silent ? " silent" : "") + (flow.selected === n.key ? " on" : "") +
241
+ '" onclick="selectNode(\'' + n.key + '\')">' +
242
+ '<span><span class="nm" style="color:' + col + '">' + esc(n.label) + "</span>" +
243
+ '<span class="sb">' + esc(n.sub) + "</span></span>" +
244
+ '<span class="st">' + esc(n.state) + "</span></div>";
245
+ }).join("");
246
+ }
247
+
248
+ function animate() {
249
+ if (particles.length === 0 && Object.values(flashes).every((v) => v < 0.02)) { animating = false; return; }
250
+ for (let i = particles.length - 1; i >= 0; i--) {
251
+ const p = particles[i];
252
+ p.t += 0.014;
253
+ if (p.t < 0) continue;
254
+ // The tail has to finish arriving after the head does.
255
+ if (p.t > 1 + TRAIL * 0.022) particles.splice(i, 1);
256
+ }
257
+ for (const k of Object.keys(flashes)) flashes[k] *= 0.96;
258
+ if (tabs.current === "flow") drawFlow();
259
+ requestAnimationFrame(animate);
260
+ }
261
+ export function ignite(events) {
262
+ for (const e of events) {
263
+ if (!e.node) continue;
264
+ flashes[e.node] = 1;
265
+ // Ride an edge that ENDS at this node when the diagram has one — a signal
266
+ // arriving is the thing being drawn. Otherwise ride one leaving it, and
267
+ // otherwise orbit the box. A caller that KNOWS the path names it in `via`,
268
+ // because "the first edge ending here" is not always the right one: the
269
+ // first edge into ENCODE is the dotted crash-sweep fallback, so a deposit
270
+ // through the authored door would otherwise be drawn arriving from a crash.
271
+ const edge = e.via
272
+ ? null
273
+ : (flow.data && flow.data.edges.find((x) => x.to === e.node)) ||
274
+ (flow.data && flow.data.edges.find((x) => x.from === e.node));
275
+ particles.push({
276
+ node: e.node,
277
+ key: e.via || (edge ? edge.from + ">" + edge.to : ""),
278
+ // A negative start staggers a signal that crosses several nodes, so three
279
+ // particles read as one thing moving rather than three things blinking.
280
+ t: -(e.delay || 0),
281
+ spin: Math.random() * 6.28,
282
+ col: e.tone === "amber" ? COL.amber : e.tone === "notable" ? COL.cyan : COL.teal,
283
+ });
284
+ }
285
+ if (!animating) { animating = true; requestAnimationFrame(animate); }
286
+ }
287
+
288
+ /** How many comets are in flight. A harness that wants to photograph "only
289
+ * particles mean activity" has to know WHEN, and a fixed sleep either misses
290
+ * the animation or catches an empty frame. */
291
+ window.particleCount = () => particles.length;
@@ -0,0 +1,11 @@
1
+ /* What just happened — the durable log, in plain english. A live feed. */
2
+ import { $ } from "../../../shared/dom.js";
3
+ import { registerLiveFeed, renderFeed } from "../../../shared/widgets/feed.js";
4
+
5
+ export const markup = `
6
+ <h2>What just happened <small>— the durable log, in plain english</small></h2>
7
+ <div class="card feed" id="flow-feed"></div>`;
8
+
9
+ export function mount() { registerLiveFeed("flow-feed"); }
10
+
11
+ export function paint(d) { renderFeed($("flow-feed"), d.feed, d); }
@@ -0,0 +1,41 @@
1
+ /* What fired — every mechanism by name, silent first. Constitution 11's last
2
+ sentence as one panel: what fired, what went quiet, and what nothing records
3
+ at all. Its own fetch (`/api/fired`) and its own table. */
4
+ import { api, fail } from "../../../shared/api.js";
5
+ import { $, esc } from "../../../shared/dom.js";
6
+
7
+ export const markup = `
8
+ <h2>What fired <small>— every mechanism by name, silent first</small></h2>
9
+ <div class="card tablewrap" id="h-fired"></div>
10
+ <p class="foot" id="h-fired-foot"></p>`;
11
+
12
+ export async function render() {
13
+ let d;
14
+ try { d = await api("/api/fired"); } catch (e) { return fail("The what-fired panel", e); }
15
+ const rows = [];
16
+ for (const { state, meaning } of d.vocabulary) {
17
+ const group = d.rows.filter((r) => r.state === state);
18
+ if (group.length === 0) continue;
19
+ rows.push("<tr><th colspan='3' class='dayhdr'>" + esc(state) + " (" + group.length + ") — " + esc(meaning) + "</th></tr>");
20
+ for (const r of group) {
21
+ rows.push(
22
+ "<tr><td><div class='lead'>" + esc(r.label) + "</div>" +
23
+ "<div class='ident'>" + esc(r.evidence) + "</div>" +
24
+ (r.note ? "<div class='ident'>" + esc(r.note) + "</div>" : "") + "</td>" +
25
+ "<td class='num" + (r.lastFired ? "" : " dimtd") + "'>" + esc(r.lastFired || "never") + "</td>" +
26
+ "<td class='num" + (r.firedInWindow ? "" : " dimtd") + "'>" + r.firedInWindow +
27
+ (r.refusedInWindow ? "<div class='ident'>refused " + r.refusedInWindow + (r.topRefusal ? " · " + esc(r.topRefusal) : "") + "</div>" : "") +
28
+ "</td></tr>",
29
+ );
30
+ }
31
+ }
32
+ $("h-fired").innerHTML =
33
+ "<table><thead><tr><th>what it does</th><th class='num'>last fired</th><th class='num'>7 days</th></tr></thead><tbody>" +
34
+ rows.join("") + "</tbody></table>";
35
+ $("h-fired-foot").textContent =
36
+ d.from + "→" + d.today + " (UTC), against " + d.previousFrom + "→" + d.previousTo + ". " +
37
+ (d.wentQuiet.length ? "Fired last week and not once this week: " + d.wentQuiet.join("; ") + ". "
38
+ : "Nothing that fired last week has fallen silent this week. ") +
39
+ (d.truncated ? "The event read hit its ceiling, so every count is a floor. " : "") +
40
+ "A row marked blind is one nothing durable records — its line says which row would fix it.";
41
+ }
@@ -0,0 +1,25 @@
1
+ /* Lived day × event — the last three weeks of the log. */
2
+ import { $, esc } from "../../../shared/dom.js";
3
+
4
+ export const markup = `
5
+ <h2>Lived day × event <small>— the last three weeks of the log</small></h2>
6
+ <div class="card pad heat" id="h-heat"></div>`;
7
+
8
+ export function paint(d) {
9
+ const hm = d.heatmap;
10
+ const peak = Math.max(1, ...hm.cells.map((c) => c.count));
11
+ const byName = {};
12
+ for (const c of hm.cells) { (byName[c.name] = byName[c.name] || {})[c.day] = c.count; }
13
+ $("h-heat").innerHTML =
14
+ "<table class='heatgrid'><thead><tr><th></th>" +
15
+ hm.days.map((day) => "<td class='dayhdr'>" + day + "</td>").join("") + "</tr></thead><tbody>" +
16
+ hm.names.map((name) =>
17
+ "<tr><th>" + esc(name) + "</th>" +
18
+ hm.days.map((day) => {
19
+ const c = (byName[name] || {})[day] || 0;
20
+ const a = c === 0 ? 0 : 0.18 + 0.82 * (c / peak);
21
+ return "<td><div class='cell' title='" + esc(name) + " · day " + day + " · " + c + "' style='background:rgba(0,229,255," + a.toFixed(3) + ")'></div></td>";
22
+ }).join("") + "</tr>"
23
+ ).join("") + "</tbody></table>" +
24
+ "<p class='foot'>An empty row is a mechanism that recorded nothing in this window — which is a fact about the log, not a gap in the table.</p>";
25
+ }
@@ -0,0 +1,24 @@
1
+ /* Everything I can record durably — what each record means, and how often. */
2
+ import { $, esc } from "../../../shared/dom.js";
3
+
4
+ export const markup = `
5
+ <h2>Everything I can record durably <small>— what each record means, and how often I have made one</small></h2>
6
+ <div class="card tablewrap" id="h-records"></div>
7
+ <p class="foot">What has actually happened is listed first; everything below the last count has
8
+ never been recorded. A row marked <b style="color:var(--teal);font-weight:400">host</b> is one
9
+ an adapter wrote — counts, bytes and reasons; never text.</p>`;
10
+
11
+ export function paint(d) {
12
+ // ONE table where there were two, and the English leads. The dotted name is
13
+ // still on the page — it is what the owner greps the log for — but on the
14
+ // second line, in the type an identifier deserves.
15
+ $("h-records").innerHTML =
16
+ "<table><thead><tr><th>what it records</th><th class='num'>kept</th></tr></thead><tbody>" +
17
+ d.records.map((r) =>
18
+ "<tr><td><div class='lead'>" + esc(r.gloss) + "</div>" +
19
+ "<div class='ident'>" + esc(r.name) +
20
+ (r.adapter ? "<span class='hostmark'>host</span>" : "") +
21
+ (r.note ? "<span class='notemark'>" + esc(r.note) + "</span>" : "") + "</div></td>" +
22
+ "<td class='num" + (r.absent ? " dimtd" : "") + "'>" + (r.absent ? esc(r.absent) : r.count) + "</td></tr>"
23
+ ).join("") + "</tbody></table>";
24
+ }
@@ -0,0 +1,17 @@
1
+ /* Band symmetry — the ratchet tripwire, read by reason. */
2
+ import { $, esc } from "../../../shared/dom.js";
3
+
4
+ export const markup = `
5
+ <h2>Band symmetry <small>— the ratchet tripwire, read by reason</small></h2>
6
+ <div class="card tablewrap" id="h-symmetry"></div>
7
+ <p class="foot">A counter nobody feeds is a tripwire that cannot trip. <b style="color:var(--dim);font-weight:400">never-asked</b>
8
+ is reported as itself and never as health.</p>`;
9
+
10
+ export function paint(d) {
11
+ $("h-symmetry").innerHTML =
12
+ "<table><thead><tr><th>kind</th><th class='num'>up</th><th class='num'>down</th><th>verdict</th></tr></thead><tbody>" +
13
+ d.symmetry.map((s) =>
14
+ "<tr><td>" + esc(s.kind) + "</td><td class='num dimtd'>" + s.up + "</td><td class='num dimtd'>" + s.down + "</td>" +
15
+ "<td style='color:" + (s.ok ? "var(--teal)" : "var(--amber)") + "'>" + esc(s.reason) + "</td></tr>"
16
+ ).join("") + "</tbody></table>";
17
+ }
@@ -0,0 +1,3 @@
1
+ /* The flow tab's own state: the last `/api/flow` payload and the node whose
2
+ mechanism panel is open. */
3
+ export const flow = { data: null, selected: null };