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
@@ -5,285 +5,38 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1">
6
6
  <title>counterparts — the owner's window</title>
7
7
  <link rel="icon" href="/favicon.svg" type="image/svg+xml">
8
- <style>
9
- /* ───────────────────────────────────────────────────────────────────────────
10
- The glow theme, and the only theme. Navy ground, neon cyan, JetBrains Mono
11
- where the machine has it, CRT scanlines over the top. Every colour is a
12
- variable so a second theme is a block, not a rewrite — but there is one look
13
- on purpose: this dashboard is the product's face.
14
- No web fonts, no CDN, no network of any kind on this page. It renders
15
- identically with the machine unplugged.
16
- ─────────────────────────────────────────────────────────────────────────── */
17
- :root{
18
- --bg:#0a0e14; --card:#0d1117; --hover:#111820; --deep:#060a10;
19
- --border:rgba(0,229,255,.12); --glow:rgba(0,229,255,.25);
20
- /* The three text steps, measured rather than eyeballed. WCAG ratios against
21
- the page ground (#0a0e14) and the card (#0d1117), which are the only two
22
- backgrounds any text sits on:
23
- --ink 11.8 : 1 — memory prose, table cells, node state
24
- --dim 6.4 : 1 / 6.2 : 1 — the narration lede, nav, legends, headers
25
- --faint 5.1 : 1 / 5.0 : 1 — the per-memory metadata row
26
- The old values were 3.35 and 1.86. The 1.86 was the line carrying what was
27
- remembered and when — the least legible text on the page was the one
28
- constitution line 16 is actually about. The hierarchy survives as a real
29
- three-step ramp; only the floor moved. */
30
- --ink:#c5cdd8; --dim:#8a95a3; --faint:#79848f;
31
- --cyan:#00e5ff; --purple:#b388ff; --amber:#ffd740; --teal:#00bfa5; --red:#ff5252;
32
- --radius:4px;
33
- --hovershadow:0 0 15px rgba(0,229,255,.15), inset 0 0 15px rgba(0,229,255,.02);
34
- }
35
- *{margin:0;padding:0;box-sizing:border-box}
36
- /* The UA's `[hidden]{display:none}` loses to any rule with an id or a class in
37
- it — `#flowcv{display:block}` kept the canvas on screen after `hidden` was
38
- set, and the flow list rendered below an invisible blank box. */
39
- [hidden]{display:none!important}
40
- html,body{background:var(--bg)}
41
- body{color:var(--ink);font-family:'JetBrains Mono','SF Mono',ui-monospace,Menlo,Consolas,monospace;
42
- font-size:13px;line-height:1.6;-webkit-font-smoothing:antialiased}
43
- body::after{content:'';position:fixed;inset:0;pointer-events:none;z-index:9999;
44
- background:repeating-linear-gradient(0deg,transparent,transparent 2px,rgba(0,0,0,.035) 2px,rgba(0,0,0,.035) 4px)}
45
- a{color:var(--cyan);text-decoration:none}
46
- .wrap{max-width:1500px;margin:0 auto;padding:20px 24px 70px}
47
-
48
- header{display:flex;align-items:center;gap:18px;margin-bottom:14px;flex-wrap:wrap}
49
- h1{font-size:22px;font-weight:300;letter-spacing:8px;text-transform:uppercase;color:var(--cyan);
50
- text-shadow:0 0 20px rgba(0,229,255,.35),0 0 40px rgba(0,229,255,.08);white-space:nowrap}
51
- nav{display:flex;gap:2px;flex-wrap:wrap}
52
- nav a{color:var(--dim);font-size:12px;padding:5px 12px;border-radius:8px;cursor:pointer}
53
- nav a:hover{color:var(--ink);background:var(--hover)}
54
- nav a.on{color:var(--cyan);background:var(--hover)}
55
- .hright{margin-left:auto;display:flex;gap:11px;align-items:center;flex-wrap:wrap}
56
- .badge{font-size:9px;padding:1px 8px;border-radius:9px;border:1px solid var(--glow);color:var(--dim);
57
- letter-spacing:.5px;white-space:nowrap}
58
- .badge.ok{color:var(--teal);border-color:rgba(0,191,165,.45)}
59
- .badge.dirpath{color:var(--dim);max-width:240px;overflow:hidden;text-overflow:ellipsis;cursor:help}
60
- .hright a{color:var(--dim);font-size:11px}
61
- .hright a:hover{color:var(--cyan)}
62
-
63
- h2{font-size:12px;text-transform:uppercase;letter-spacing:2.5px;color:var(--dim);margin:22px 0 10px;font-weight:400}
64
- h2 small{text-transform:none;letter-spacing:0;color:var(--faint)}
65
- h2:first-child{margin-top:0}
66
- .lede{color:var(--dim);font-size:12.5px;margin:0 0 16px;max-width:96ch;line-height:1.75}
67
- .lede b{color:var(--ink);font-weight:400}
68
-
69
- /* 124, not 132: the tenth tile (beliefs and entities) has to sit on the first
70
- row at 1440 rather than orphan itself under nine others. */
71
- .tiles{display:grid;grid-template-columns:repeat(auto-fit,minmax(124px,1fr));gap:10px;margin-bottom:6px}
72
- .tile{background:var(--card);border:1px solid var(--border);border-radius:var(--radius);padding:12px 14px;
73
- transition:border-color .3s,box-shadow .3s}
74
- .tile:hover,.card:hover{border-color:var(--glow);box-shadow:var(--hovershadow)}
75
- .tile .n{font-size:23px;font-weight:300;color:var(--cyan);text-shadow:0 0 15px rgba(0,229,255,.2);
76
- line-height:1.25;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
77
- .tile .l{font-size:9.5px;color:var(--dim);text-transform:uppercase;letter-spacing:1.2px;margin-top:2px}
78
- .tile .s{font-size:10px;color:var(--faint);margin-top:3px;line-height:1.45}
79
- .tile.purple .n{color:var(--purple);text-shadow:0 0 15px rgba(179,136,255,.2)}
80
- .tile.amber .n{color:var(--amber);text-shadow:0 0 15px rgba(255,215,64,.2)}
81
- .tile.teal .n{color:var(--teal);text-shadow:0 0 15px rgba(0,191,165,.2)}
82
- .tile.absent .n{color:var(--dim);font-size:15px;text-shadow:none;padding-top:6px;padding-bottom:2px}
83
-
84
- .cols{display:grid;grid-template-columns:1.05fr 1fr;gap:20px;align-items:start}
85
- .cols-wide{display:grid;grid-template-columns:1.35fr 1fr;gap:20px;align-items:start}
86
- /* A grid item defaults to `min-width:auto`, which means it refuses to shrink
87
- below its widest content — so `.tablewrap{overflow-x:auto}` never engaged and
88
- a seven-column table pushed the whole PAGE wider than the device. The page
89
- body must never scroll horizontally; this is the line that makes the
90
- per-panel scrollers do their job instead. */
91
- .cols>*,.cols-wide>*{min-width:0}
92
- /* THE PHONE HEADER. Measured at 390 before this existed: 150px of chrome in
93
- three rows, `nav a` 29.2px tall and `.hright a` the same, against the 44px
94
- minimum for something a thumb has to hit. The fix is not to shrink the header
95
- further — it is to stop the nav wrapping. Brand and chips take one row; the
96
- six sections become a single horizontal strip that scrolls on its own, with
97
- real 44px hits, which is both smaller overall and actually usable. */
98
- @media(max-width:720px){
99
- header{gap:8px 12px;margin-bottom:10px}
100
- h1{font-size:16px;letter-spacing:4px;order:1}
101
- .hright{order:2;margin-left:auto;gap:8px}
102
- nav{order:3;flex:1 0 100%;flex-wrap:nowrap;overflow-x:auto;gap:0;
103
- border-top:1px solid var(--glow);padding-top:2px;scrollbar-width:none}
104
- nav::-webkit-scrollbar{display:none}
105
- nav a{min-height:44px;display:inline-flex;align-items:center;padding:0 14px;
106
- font-size:13px;white-space:nowrap}
107
- .hright a{min-height:44px;display:inline-flex;align-items:center}
108
- .badge{font-size:10px;padding:4px 9px}
109
- .badge.dirpath{max-width:150px}
110
- /* The chips have to fit ONE line, or the header grows a row back. The
111
- observer badge is the long one, and `observer` alone is the whole claim —
112
- the sentence is still in its `title`. */
113
- .badge .wide{display:none}
114
- }
115
- @media(max-width:1080px){.cols,.cols-wide{grid-template-columns:1fr}}
116
-
117
- .card{background:var(--card);border:1px solid var(--border);border-radius:var(--radius);margin-bottom:8px;
118
- overflow:hidden;transition:border-color .3s,box-shadow .3s}
119
- .pad{padding:14px 16px}
120
- .empty{color:var(--dim);font-size:11.5px;padding:13px 15px;border:1px dashed var(--glow);
121
- border-radius:var(--radius);margin-bottom:8px;line-height:1.65}
122
- .empty b{color:var(--amber);font-weight:400}
123
-
124
- .bar{display:grid;grid-template-columns:92px 1fr auto;gap:11px;align-items:center;margin:8px 0;font-size:11.5px}
125
- .bar .track{display:block;height:9px;background:var(--deep);border-radius:5px;overflow:hidden;
126
- border:1px solid rgba(0,229,255,.06)}
127
- .bar .fill{display:block;height:100%;border-radius:5px;background:var(--cyan);box-shadow:0 0 9px rgba(0,229,255,.35)}
128
- .bar .n{text-align:right;color:var(--dim);font-variant-numeric:tabular-nums;white-space:nowrap;min-width:44px}
129
- .bar .lab{color:var(--ink)}
130
- .bar .lab.none{color:var(--dim)}
131
- .gloss{color:var(--faint);font-size:10.5px;margin:-2px 0 8px 103px}
132
- @media(max-width:520px){.bar{grid-template-columns:78px 1fr 40px}.gloss{margin-left:0}}
133
-
134
- .feed{max-height:440px;overflow-y:auto}
135
- .ev{display:grid;grid-template-columns:52px 1fr;gap:11px;padding:9px 14px;border-bottom:1px solid var(--border);
136
- font-size:11.5px;cursor:pointer;align-items:baseline}
137
- .ev:last-child{border-bottom:none}
138
- .ev:hover{background:var(--hover)}
139
- .ev .d{color:var(--faint);font-size:10px;white-space:nowrap}
140
- .ev .t{line-height:1.55;color:var(--ink)}
141
- .ev .k{display:block;color:var(--faint);font-size:9.5px;letter-spacing:.6px;margin-top:3px}
142
- .ev.amber .t{color:var(--amber)}
143
- .ev.notable .t{color:#dfe6ee}
144
- .ev.calm .t{color:var(--dim)}
145
- .ev.flash{animation:evflash 1.8s ease-out}
146
- @keyframes evflash{0%{background:rgba(0,229,255,.14)}100%{background:transparent}}
147
-
148
- .rows .r{padding:10px 15px;border-bottom:1px solid var(--border);font-size:11.5px;line-height:1.6}
149
- .rows .r:last-child{border-bottom:none}
150
- .rows .r.click{cursor:pointer}
151
- .rows .r.click:hover{background:var(--hover)}
152
- .rows .meta{color:var(--faint);font-size:10px;margin-top:4px;display:flex;gap:10px;flex-wrap:wrap}
153
- .rows .meta .k{color:var(--dim)}
154
- .withheld{color:var(--amber);font-style:italic}
155
-
156
- table{width:100%;border-collapse:collapse;font-size:11px}
157
- th{text-align:left;color:var(--dim);font-weight:400;text-transform:uppercase;letter-spacing:1.1px;
158
- font-size:9px;padding:9px 14px;border-bottom:1px solid var(--border);white-space:nowrap}
159
- td{padding:8px 14px;border-bottom:1px solid var(--border);vertical-align:top}
160
- tr:last-child td{border-bottom:none}
161
- tbody tr.click{cursor:pointer}
162
- tbody tr.click:hover{background:var(--hover)}
163
- td.num,th.num{text-align:right;font-variant-numeric:tabular-nums;white-space:nowrap}
164
- td.dimtd{color:var(--dim)}
165
- .tablewrap{overflow-x:auto}
166
- /* The durable-record table: English on top, the identifier under it. Two
167
- columns rather than three, so it survives a phone without a scroller. */
168
- td .lead{color:var(--ink);line-height:1.5}
169
- td .ident{color:var(--faint);font-size:9.5px;letter-spacing:.5px;margin-top:4px;
170
- display:flex;gap:8px;flex-wrap:wrap;align-items:baseline}
171
- td .ident .hostmark{color:var(--teal);text-transform:uppercase;letter-spacing:1px;font-size:8.5px}
172
- td .ident .notemark{color:var(--faint)}
173
-
174
- .chart{padding:12px 14px 6px;position:relative}
175
- .chart canvas{width:100%;display:block}
176
- .legend{display:flex;gap:14px;font-size:10px;color:var(--dim);padding:2px 15px 12px;flex-wrap:wrap}
177
- .legend .chip{display:inline-block;width:8px;height:8px;border-radius:4px;margin-right:5px;vertical-align:-1px}
178
-
179
- #tip{position:fixed;display:none;background:var(--deep);border:1px solid var(--glow);border-radius:6px;
180
- padding:8px 11px;font-size:11px;max-width:330px;pointer-events:none;z-index:120;color:var(--ink);
181
- line-height:1.55;box-shadow:0 6px 26px rgba(0,0,0,.6)}
182
- #tip .dimline{color:var(--dim);font-size:10px;margin-top:4px}
183
-
184
- .searchrow{display:flex;align-items:center;gap:12px;margin-bottom:12px;flex-wrap:wrap}
185
- #q{flex:1;min-width:220px;background:var(--card);border:1px solid var(--border);border-radius:var(--radius);
186
- color:inherit;font:inherit;font-size:12px;padding:10px 13px;outline:none}
187
- #q:focus{border-color:var(--cyan);box-shadow:0 0 12px rgba(0,229,255,.12)}
188
- #qn{color:var(--dim);font-size:11px;white-space:nowrap}
189
-
190
- .story{border:1px solid var(--border);border-radius:var(--radius);background:var(--card);
191
- padding:14px 16px;margin-bottom:10px}
192
- .story h3{font-size:12px;color:var(--cyan);font-weight:400;letter-spacing:1px;margin-bottom:2px}
193
- .story .about{color:var(--faint);font-size:10px;letter-spacing:.6px;text-transform:uppercase;margin-bottom:10px}
194
- .story .said{font-size:11.5px;margin:5px 0;line-height:1.65}
195
- .story .said .k{color:var(--dim);display:inline-block;min-width:88px;vertical-align:top}
196
- .story .said .stmt{display:inline-block;max-width:calc(100% - 96px)}
197
- .story .said .stmt.click{cursor:pointer}
198
- .story .said .stmt.click:hover{color:var(--cyan)}
199
- .beat .verdict.became{color:var(--amber);cursor:pointer}
200
- .beat .verdict.became:hover{text-decoration:underline}
201
- .beat{display:grid;grid-template-columns:52px 1fr 210px;gap:11px;align-items:start;
202
- padding:9px 0;border-top:1px solid var(--border);font-size:11px}
203
- .beat .day{color:var(--faint);font-size:10px}
204
- .beat .who{color:var(--ink);line-height:1.5}
205
- .beat .who em{color:var(--dim);font-style:normal;font-size:10px;display:block;margin-top:2px}
206
- .beat .track{height:7px;background:var(--deep);border-radius:4px;overflow:hidden;position:relative;
207
- border:1px solid rgba(0,229,255,.07)}
208
- .beat .fill{height:100%;background:var(--teal)}
209
- .beat.crossed .fill{background:var(--amber)}
210
- .beat .barline{position:absolute;top:-2px;bottom:-2px;width:1px;background:var(--red);opacity:.7}
211
- .beat .verdict{font-size:9.5px;color:var(--dim);margin-top:4px;letter-spacing:.4px;line-height:1.5;
212
- overflow-wrap:anywhere}
213
- .beat.crossed .verdict{color:var(--amber)}
214
- @media(max-width:640px){.beat{grid-template-columns:44px 1fr}.beat>div:last-child{grid-column:1/-1}}
215
-
216
- .lane{margin-bottom:12px}
217
- .lane h4{font-size:10px;text-transform:uppercase;letter-spacing:2px;color:var(--purple);
218
- font-weight:400;margin-bottom:6px}
219
- .lane .item{font-size:11.5px;line-height:1.7;padding:4px 0 4px 14px;border-left:1px solid var(--border);
220
- margin-bottom:2px;color:var(--ink)}
221
- .lane .item .date{color:var(--faint)}
222
- .wakehead{color:var(--dim);font-size:11px;margin-bottom:12px;line-height:1.65}
223
-
224
- #flowbox{padding:4px}
225
- #flowcv{width:100%;display:block;cursor:pointer}
226
- /* Below ~900px the diagram becomes a LIST of the same fourteen nodes. A canvas
227
- shrunk to a phone is text clipped mid-word inside overlapping boxes; the data
228
- behind it is a list of {label, sub, state} records, and a list is honest. */
229
- #flowlist{padding:4px 2px}
230
- .fnode{display:grid;grid-template-columns:1fr auto;gap:10px;align-items:baseline;
231
- padding:11px 13px;border:1px solid var(--border);border-radius:var(--radius);
232
- margin:6px 4px;cursor:pointer;background:var(--card)}
233
- .fnode:hover,.fnode.on{border-color:var(--glow);background:var(--hover)}
234
- .fnode .nm{font-size:11.5px;letter-spacing:1.4px}
235
- .fnode .sb{color:var(--dim);font-size:10px;display:block;margin-top:3px;letter-spacing:0}
236
- .fnode .st{font-size:10.5px;color:var(--ink);white-space:nowrap;text-align:right}
237
- .fnode.silent .st{color:var(--dim)}
238
- .fchain{color:var(--faint);font-size:9px;letter-spacing:1px;text-align:center;padding:1px 0}
239
- #flowdetail h3{color:var(--cyan);font-size:13px;font-weight:400;letter-spacing:1.5px;margin-bottom:6px}
240
- #flowdetail .brain{color:var(--purple);font-size:11px;line-height:1.65;margin:8px 0}
241
- #flowdetail .breaks{color:var(--amber);font-size:11px;line-height:1.65;margin:8px 0}
242
- #flowdetail .lab{color:var(--faint);font-size:9px;text-transform:uppercase;letter-spacing:1.4px;margin-top:12px}
243
- #flowdetail p{font-size:11.5px;margin:6px 0;line-height:1.7}
244
-
245
- .heat{overflow-x:auto}
246
- .heatgrid{border-collapse:collapse;font-size:9px}
247
- .heatgrid td{padding:0;border:none}
248
- .heatgrid .cell{width:15px;height:15px;border:1px solid var(--bg);border-radius:2px;background:var(--deep)}
249
- .heatgrid th{padding:2px 8px 2px 0;font-size:9px;text-transform:none;letter-spacing:0;border:none;
250
- color:var(--dim);text-align:right;white-space:nowrap}
251
- .heatgrid .dayhdr{color:var(--faint);font-size:8.5px;text-align:center;padding:0 0 4px;border:none}
252
-
253
- #overlay{position:fixed;inset:0;background:rgba(3,6,11,.8);display:none;z-index:200;
254
- backdrop-filter:blur(2px)}
255
- #overlay.show{display:flex;align-items:flex-start;justify-content:center;padding:5vh 16px}
256
- #modal{background:var(--card);border:1px solid var(--glow);border-radius:8px;max-width:900px;width:100%;
257
- max-height:88vh;overflow-y:auto;padding:20px 24px;box-shadow:0 0 60px rgba(0,229,255,.08)}
258
- #modal h3{font-size:14px;color:var(--cyan);font-weight:400;letter-spacing:1px;margin-bottom:4px;padding-right:26px}
259
- #modal .sub{color:var(--dim);font-size:10.5px;margin-bottom:16px;word-break:break-word;
260
- display:flex;gap:10px;align-items:baseline;flex-wrap:wrap}
261
- #modal .sub .path{color:var(--faint)}
262
- #modal .copy{background:none;border:1px solid var(--border);border-radius:3px;color:var(--dim);
263
- font:inherit;font-size:9px;letter-spacing:.6px;padding:1px 7px;cursor:pointer}
264
- #modal .copy:hover{color:var(--cyan);border-color:var(--glow)}
265
- #modal .x{float:right;cursor:pointer;color:var(--dim);font-size:18px;line-height:1;padding:0 4px}
266
- #modal .x:hover{color:var(--ink)}
267
- #modal .body{white-space:pre-wrap;font-size:12px;line-height:1.75;background:var(--deep);
268
- border:1px solid var(--border);border-radius:var(--radius);padding:13px 15px;margin-bottom:14px}
269
- #modal .kv{display:grid;grid-template-columns:132px 1fr;gap:5px 12px;font-size:11px;margin-bottom:14px}
270
- #modal .kv .k{color:var(--dim)}
271
- #modal .kv .v{color:var(--ink);word-break:break-word}
272
- #modal h4{font-size:9.5px;text-transform:uppercase;letter-spacing:1.6px;color:var(--faint);
273
- font-weight:400;margin:14px 0 6px}
274
- #modal .ref{font-size:11px;padding:6px 0;border-bottom:1px solid var(--border);cursor:pointer;line-height:1.55}
275
- #modal .ref:hover{color:var(--cyan)}
276
- #modal .ref .role{color:var(--dim);display:inline-block;min-width:118px}
277
- .foot{color:var(--faint);font-size:10.5px;line-height:1.7;margin-top:10px;max-width:96ch}
278
- .blind{font-size:11.5px;line-height:1.7;padding:10px 0;border-bottom:1px solid var(--border)}
279
- .blind:last-child{border-bottom:none}
280
- .blind .w{color:var(--amber)}
281
- .blind .y{color:var(--dim)}
282
- .tone-amber{color:var(--amber)}
283
- .tone-notable{color:var(--ink)}
284
- .tone-calm{color:var(--dim)}
285
- #err{display:none;margin-bottom:12px}
286
- </style>
8
+ <!-- The server fills this with a per-launch token; every management action
9
+ echoes it (web/actions.ts). Empty means this page cannot act. -->
10
+ <meta name="counterparts-action-token" content="">
11
+ <!--
12
+ The shell. Styles, scripts and the two font faces are served beside this file
13
+ (see README.md): no CDN, no network of any kind beyond this origin.
14
+ The <link> order IS the cascade order — it reproduces the one stylesheet this
15
+ page used to inline, so a rule's position still decides its ties.
16
+ -->
17
+ <link rel="preload" href="/shared/fonts/outfit-latin-wght.woff2" as="font" type="font/woff2" crossorigin>
18
+ <link rel="stylesheet" href="/shared/tokens.css">
19
+ <link rel="stylesheet" href="/shared/base.css">
20
+ <link rel="stylesheet" href="/shared/widgets/tiles.css">
21
+ <link rel="stylesheet" href="/shared/layout.css">
22
+ <link rel="stylesheet" href="/shared/widgets/card.css">
23
+ <link rel="stylesheet" href="/shared/widgets/bar.css">
24
+ <link rel="stylesheet" href="/shared/widgets/feed.css">
25
+ <link rel="stylesheet" href="/shared/widgets/rows.css">
26
+ <link rel="stylesheet" href="/shared/widgets/table.css">
27
+ <link rel="stylesheet" href="/shared/widgets/chart.css">
28
+ <link rel="stylesheet" href="/shared/tip.css">
29
+ <link rel="stylesheet" href="/shared/widgets/light.css">
30
+ <link rel="stylesheet" href="/pages/home/home.css">
31
+ <link rel="stylesheet" href="/pages/memories/memories.css">
32
+ <link rel="stylesheet" href="/pages/self/self.css">
33
+ <link rel="stylesheet" href="/pages/flow/flow.css">
34
+ <link rel="stylesheet" href="/pages/health/health.css">
35
+ <link rel="stylesheet" href="/shared/modal.css">
36
+ <link rel="stylesheet" href="/shared/widgets/confirm.css">
37
+ <link rel="stylesheet" href="/shared/utilities.css">
38
+ <link rel="stylesheet" href="/shared/type.css">
39
+ <script type="module" src="/app.js"></script>
287
40
  </head>
288
41
  <body>
289
42
  <div class="wrap">
@@ -291,9 +44,8 @@ td .ident .notemark{color:var(--faint)}
291
44
  <h1>counterparts</h1>
292
45
  <nav id="nav"></nav>
293
46
  <div class="hright">
294
- <span class="badge ok" title="it strengthens nothing, deposits nothing, and writes no file of its own"><span class="wide">read-only · </span>observer</span>
47
+ <span class="badge ok" title="Looking never changes memory: opening a page, a memory or a record strengthens nothing and writes nothing. The actions you take here (a note, a removal, a backup) do change it, and ask you first when they cannot be undone.">looking changes nothing</span>
295
48
  <span class="badge dirpath" id="dir" title="the data directory this window is reading">…</span>
296
- <a href="/brain" title="the same machinery, mapped to a rough anatomy">brain</a>
297
49
  <span class="badge" id="clock" title="the store's own clock — lived days, the unit everything else here is measured in">…</span>
298
50
  <span class="badge" id="seen" hidden></span>
299
51
  </div>
@@ -301,1431 +53,16 @@ td .ident .notemark{color:var(--faint)}
301
53
 
302
54
  <div class="empty" id="err"></div>
303
55
 
304
- <!-- ── overview ────────────────────────────────────────────────────────── -->
305
- <section class="tab" id="tab-overview">
306
- <p class="lede" id="ov-opening"></p>
307
- <div class="tiles" id="ov-tiles"></div>
308
- <div class="cols" style="margin-top:22px">
309
- <div>
310
- <h2>Where every memory sits <small>— the consolidation gradient, computed now</small></h2>
311
- <div class="card pad" id="ov-bands"></div>
312
- <h2>Live activity <small style="color:var(--purple)">— in my own words · click any line for the record behind it</small></h2>
313
- <div class="card feed" id="ov-feed"></div>
314
- <p class="foot" id="ov-feednote"></p>
315
- <h2>Recent chapters <small>— the journal, in the first person; these do not decay</small></h2>
316
- <div class="card rows" id="ov-chapters"></div>
317
- </div>
318
- <div>
319
- <h2>Who I am <small>— the identity band</small></h2>
320
- <div class="card rows" id="ov-identity"></div>
321
- <h2>Permanent ink <small>— protected: no revision path reaches these</small></h2>
322
- <div class="card rows" id="ov-protected"></div>
323
- <h2>Beliefs under argument <small>— pressure against the bar it would take</small></h2>
324
- <div id="ov-contested"></div>
325
- </div>
326
- </div>
327
- </section>
328
-
329
- <!-- ── memories ────────────────────────────────────────────────────────── -->
330
- <section class="tab" id="tab-memories" hidden>
331
- <div class="searchrow">
332
- <input id="q" type="search" autocomplete="off" spellcheck="false"
333
- placeholder="search what I hold — click a result to open the memory">
334
- <span id="qn"></span>
335
- </div>
336
- <div class="card rows" id="qout" hidden></div>
337
- <div class="cols-wide">
338
- <div>
339
- <h2>The constellation <small id="con-sub"></small></h2>
340
- <div class="card chart"><canvas id="con" height="330"></canvas></div>
341
- <div class="legend" id="con-legend"></div>
342
- <h2>Strength, distributed <small>— how many memories sit at each depth</small></h2>
343
- <div class="card chart"><canvas id="hist" height="170"></canvas></div>
344
- </div>
345
- <div>
346
- <h2>Band composition</h2>
347
- <div class="card pad" id="mem-bands"></div>
348
- <h2>Kinds <small>— and the physics each one is moved by</small></h2>
349
- <div class="card tablewrap" id="kinds"></div>
350
- <p class="foot">
351
- <b style="color:var(--dim);font-weight:400">wSal / wRep</b> — how much salience and repetition each
352
- contribute to a memory's base strength. <b style="color:var(--dim);font-weight:400">κ</b> divides
353
- stability, so a higher number erodes faster. <b style="color:var(--dim);font-weight:400">ι</b> is
354
- revision inertia: the fraction of the memory's own strength a challenge must out-sum to land.
355
- </p>
356
- <!-- GRAPH HUBS lives here, under the kinds table, and not under the
357
- histogram in the left column: the left column was two charts and
358
- this list while the right was two short panels, so a reader at
359
- mid-scroll had roughly 850×750 of empty column beside the graph
360
- (design review, 2026-09-04, ranked #6). The list is the tallest
361
- thing that can move, so it is the one that moves. -->
362
- <h2>Graph hubs <small>— what the most is wired to, by summed edge weight</small></h2>
363
- <div class="card rows" id="hubs"></div>
364
- </div>
365
- </div>
366
- </section>
367
-
368
- <!-- ── mind ────────────────────────────────────────────────────────────── -->
369
- <section class="tab" id="tab-mind" hidden>
370
- <p class="lede" id="mind-opening"></p>
371
- <div class="cols">
372
- <div>
373
- <h2>Identity band <small>— what strength earned; physics can still move it</small></h2>
374
- <div class="card rows" id="mind-identity"></div>
375
- <h2>Protected <small>— permanent, including permanently wrong</small></h2>
376
- <div class="card rows" id="mind-protected"></div>
377
- <h2>Permanent but outside the band <small>— the rows most worth staring at</small></h2>
378
- <div class="card rows" id="mind-outside"></div>
379
- <h2>Identity-band rows I could not read just now</h2>
380
- <div class="card rows" id="mind-unreadable"></div>
381
- </div>
382
- <div>
383
- <h2>My page <small>— the prose the wake opens with; read-only here</small></h2>
384
- <div class="card pad" id="mind-page"></div>
385
- <h2>What the page used to say <small>— every earlier version, newest first</small></h2>
386
- <div class="card rows" id="mind-page-versions"></div>
387
- <h2>What I would say on waking <small>— the briefing, as it renders</small></h2>
388
- <div class="card pad" id="mind-wake"></div>
389
- <h2>Chapters <small>— the journal; these do not decay</small></h2>
390
- <div class="card rows" id="mind-chapters"></div>
391
- </div>
392
- </div>
393
- <h2>How I changed my mind <small>— every credited challenge, in the order it landed</small></h2>
394
- <div id="mind-stories"></div>
395
- </section>
396
-
397
- <!-- ── flow ────────────────────────────────────────────────────────────── -->
398
- <section class="tab" id="tab-flow" hidden>
399
- <p class="lede">
400
- The architecture, alive. <b>Only particles mean activity</b> — nothing here drifts for decoration, so a
401
- still diagram is a still machine. Click any part for what it does, its brain analogy, where that analogy
402
- deliberately breaks, and what it has actually been doing.
403
- </p>
404
- <div class="card" id="flowbox">
405
- <canvas id="flowcv" height="560"></canvas>
406
- <div id="flowlist" hidden></div>
407
- </div>
408
- <div class="cols">
409
- <div>
410
- <h2>What just happened <small>— the durable log, in plain english</small></h2>
411
- <div class="card feed" id="flow-feed"></div>
412
- </div>
413
- <div>
414
- <h2>Selected mechanism</h2>
415
- <div class="card pad" id="flowdetail">
416
- <p style="color:var(--dim)">Loading…</p>
417
- </div>
418
- </div>
419
- </div>
420
- </section>
421
-
422
- <!-- ── health ──────────────────────────────────────────────────────────── -->
423
- <section class="tab" id="tab-health" hidden>
424
- <div class="cols">
425
- <div>
426
- <h2>The last cycle <small>— which lived day each phase finished on</small></h2>
427
- <div class="card tablewrap" id="h-phases"></div>
428
- <h2>Band symmetry <small>— the ratchet tripwire, read by reason</small></h2>
429
- <div class="card tablewrap" id="h-symmetry"></div>
430
- <p class="foot">A counter nobody feeds is a tripwire that cannot trip. <b style="color:var(--dim);font-weight:400">never-asked</b>
431
- is reported as itself and never as health.</p>
432
- <h2>Ways out <small>— counted since birth; nothing disappears silently</small></h2>
433
- <div class="card tablewrap" id="h-exits"></div>
434
- <h2>The removal record</h2>
435
- <div class="card rows" id="h-removals"></div>
436
- </div>
437
- <div>
438
- <h2>What fired <small>— every mechanism by name, silent first</small></h2>
439
- <div class="card tablewrap" id="h-fired"></div>
440
- <p class="foot" id="h-fired-foot"></p>
441
- <h2>Everything I can record durably <small>— what each record means, and how often I have made one</small></h2>
442
- <div class="card tablewrap" id="h-records"></div>
443
- <p class="foot">What has actually happened is listed first; everything below the last count has
444
- never been recorded. A row marked <b style="color:var(--teal);font-weight:400">host</b> is one
445
- an adapter wrote — counts, bytes and reasons; never text.</p>
446
- </div>
447
- </div>
448
- <h2>Lived day × event <small>— the last three weeks of the log</small></h2>
449
- <div class="card pad heat" id="h-heat"></div>
450
- <h2>What I cannot see <small>— named, so an absence is a claim and not a gap</small></h2>
451
- <div class="card pad" id="h-blind"></div>
452
- </section>
56
+ <!-- One section per page; each page module (pages/<name>/index.js) writes
57
+ its own markup into its section at load. -->
58
+ <section class="tab" id="tab-home"></section>
59
+ <section class="tab" id="tab-memories" hidden></section>
60
+ <section class="tab" id="tab-self" hidden></section>
61
+ <section class="tab" id="tab-flow" hidden></section>
62
+ <section class="tab" id="tab-health" hidden></section>
453
63
  </div>
454
64
 
455
65
  <div id="tip"></div>
456
66
  <div id="overlay"><div id="modal"></div></div>
457
-
458
- <script>
459
- "use strict";
460
- /* ───────────────────────────────────────────────────────────────────────────
461
- One file, no dependencies, no network beyond this origin. Every panel is a
462
- pure function of one JSON view; nothing is cached between loads, because the
463
- whole point of render-time resolution is that a memory removed a minute ago
464
- stops resolving on the next request.
465
- ─────────────────────────────────────────────────────────────────────────── */
466
- const TABS = ["overview","memories","mind","flow","health"];
467
- const COL = { cyan:"#00e5ff", purple:"#b388ff", amber:"#ffd740", teal:"#00bfa5", red:"#ff5252", dim:"#5c6773" };
468
- const BANDCOL = { episodic:COL.dim, semantic:COL.cyan, identity:COL.purple };
469
-
470
- const $ = (id) => document.getElementById(id);
471
- const esc = (s) => String(s ?? "").replace(/[&<>"']/g, (c) => ({ "&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;" }[c]));
472
- const n2 = (x) => (typeof x === "number" && isFinite(x) ? x.toFixed(2) : "—");
473
- const n3 = (x) => (typeof x === "number" && isFinite(x) ? x.toFixed(3) : "—");
474
- const pct = (x) => Math.max(0, Math.min(100, (x || 0) * 100));
475
-
476
- /** Every fetch goes through here so one failure is a sentence, never a blank
477
- * page and never an unhandled rejection in the console. */
478
- async function api(path) {
479
- const res = await fetch(path, { headers: { accept: "application/json" } });
480
- const body = await res.json();
481
- if (!res.ok) throw new Error(body && body.error ? body.error : ("HTTP " + res.status));
482
- return body;
483
- }
484
- function fail(where, err) {
485
- const box = $("err");
486
- box.style.display = "block";
487
- box.innerHTML = "<b>" + esc(where) + " did not load.</b> " + esc(err && err.message ? err.message : String(err)) +
488
- " &nbsp;The rest of this page is unaffected — it is built one panel at a time on purpose.";
489
- }
490
-
491
- /** A withheld sentence is rendered as a withholding, not as empty space. */
492
- function said(text, confidential) {
493
- if (confidential) return '<span class="withheld">' + esc(text) + "</span>";
494
- return esc(text);
495
- }
496
- /**
497
- * A ROW'S LIVED DAYS, which is the metadata that actually varies.
498
- *
499
- * The identity list used to end every row with `learned 2026-09-04`, the same
500
- * date fifteen times, because that is the day the store was built — beside
501
- * `strength 1.00` fifteen times, which is what being in the identity band
502
- * means. Two of three visible fields said nothing. The lived days are the ones
503
- * the physics ran on: born spreads across the month, and last-used is what
504
- * "still load-bearing" looks like as a number. The calendar date is in the
505
- * memory's own card, where there is room to say what it means.
506
- */
507
- function livedSpan(el) {
508
- return "<span>born day " + el.bornDay + "</span><span>last used day " + el.lastUsedDay + "</span>";
509
- }
510
- function emptyBox(msg, extra) {
511
- return '<div class="empty"><b>' + esc(msg) + "</b>" + (extra ? " " + esc(extra) : "") + "</div>";
512
- }
513
- /** The two words, given their meaning back. */
514
- function absenceLine(marker, whatItWouldHold) {
515
- const why = marker === "(never run)"
516
- ? "I have never been asked, so there is nothing here to be wrong about."
517
- : "I have looked, and the answer is none.";
518
- return emptyBox(marker + " — " + whatItWouldHold + ".", why);
519
- }
520
-
521
- // ── tabs ───────────────────────────────────────────────────────────────────
522
- let currentTab = "overview";
523
- const loaded = {};
524
- function showTab(name, push) {
525
- if (!TABS.includes(name)) name = "overview";
526
- currentTab = name;
527
- for (const t of TABS) {
528
- $("tab-" + t).hidden = t !== name;
529
- const link = $("nav-" + t);
530
- if (link) link.classList.toggle("on", t === name);
531
- }
532
- if (push) history.replaceState(null, "", "#" + name);
533
- if (!loaded[name]) { loaded[name] = true; RENDER[name](); }
534
- else if (name === "memories") drawConstellation();
535
- else if (name === "flow") drawFlow();
536
- }
537
- $("nav").innerHTML = TABS.map((t) => '<a id="nav-' + t + '" href="#' + t + '">' + t + "</a>").join("");
538
- for (const t of TABS) $("nav-" + t).onclick = (e) => { e.preventDefault(); showTab(t, true); };
539
- addEventListener("hashchange", () => showTab(location.hash.slice(1), false));
540
-
541
- // ── modal ──────────────────────────────────────────────────────────────────
542
- const overlay = $("overlay");
543
- overlay.onclick = (e) => { if (e.target === overlay) closeModal(); };
544
- addEventListener("keydown", (e) => { if (e.key === "Escape") closeModal(); });
545
- function closeModal() { overlay.classList.remove("show"); }
546
- function openModal(html) { $("modal").innerHTML = '<span class="x" onclick="closeModal()">×</span>' + html; overlay.classList.add("show"); }
547
- window.closeModal = closeModal;
548
-
549
- // ── tooltip ────────────────────────────────────────────────────────────────
550
- const tip = $("tip");
551
- function showTip(x, y, html) {
552
- tip.innerHTML = html;
553
- tip.style.display = "block";
554
- const w = tip.offsetWidth, h = tip.offsetHeight;
555
- tip.style.left = Math.min(innerWidth - w - 10, Math.max(8, x + 14)) + "px";
556
- tip.style.top = Math.max(8, y - h - 12) + "px";
557
- }
558
- function hideTip() { tip.style.display = "none"; }
559
-
560
- // ── canvas helper: crisp on any display, laid out by CSS ───────────────────
561
- function fit(cv) {
562
- const dpr = Math.min(devicePixelRatio || 1, 2);
563
- const w = cv.clientWidth || 600;
564
- // The intended CSS height is stashed on FIRST call and read from there after,
565
- // because assigning `cv.height` rewrites the height ATTRIBUTE — reading it
566
- // back on the next draw doubled the canvas every time it was redrawn.
567
- if (!cv.dataset.h) cv.dataset.h = String(Number(cv.getAttribute("height")) || 260);
568
- const h = Number(cv.dataset.h);
569
- cv.width = Math.round(w * dpr);
570
- cv.height = Math.round(h * dpr);
571
- cv.style.height = h + "px";
572
- const ctx = cv.getContext("2d");
573
- ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
574
- ctx.clearRect(0, 0, w, h);
575
- ctx.font = '10px "JetBrains Mono", ui-monospace, monospace';
576
- return { ctx, w, h };
577
- }
578
-
579
- // ═══════════════════════════════════════════════════════════════════════════
580
- // overview
581
- // ═══════════════════════════════════════════════════════════════════════════
582
- let OVERVIEW = null;
583
- async function renderOverview() {
584
- let d;
585
- try { d = await api("/api/overview"); } catch (e) { return fail("The overview", e); }
586
- paintOverview(d, true);
587
- }
588
-
589
- /**
590
- * Draw the overview from a payload. Called once at boot with the feed, and
591
- * again from the poll WITHOUT it whenever the store moved.
592
- *
593
- * The feed is the one panel the poll owns: it prepends flashed rows as events
594
- * arrive, and a repaint from `/api/overview` underneath that would wipe them
595
- * mid-flash. So the refresh path passes `withFeed = false` — except while the
596
- * feed is still showing its absence line, where there is nothing to wipe and
597
- * everything to gain (a store's first event should not need a reload to
598
- * appear).
599
- */
600
- function paintOverview(d, withFeed) {
601
- OVERVIEW = d;
602
- $("ov-opening").textContent = d.opening;
603
-
604
- $("ov-tiles").innerHTML = d.tiles.map((t) =>
605
- '<div class="tile ' + esc(t.accent === "cyan" ? "" : t.accent) + (t.absent ? " absent" : "") + '">' +
606
- '<div class="n">' + esc(t.value) + "</div>" +
607
- '<div class="l">' + esc(t.label) + "</div>" +
608
- '<div class="s">' + esc(t.note) + "</div></div>"
609
- ).join("");
610
-
611
- $("ov-bands").innerHTML = d.bands.map((b) =>
612
- '<div class="bar"><span class="lab' + (b.absent ? " none" : "") + '">' + esc(b.label) + "</span>" +
613
- '<span class="track"><span class="fill" style="width:' + pct(b.fraction) + '%;background:' +
614
- BANDCOL[b.label] + ';box-shadow:0 0 9px ' + BANDCOL[b.label] + '55"></span></span>' +
615
- '<span class="n">' + (b.absent ? esc(b.absent) : b.count) + "</span></div>" +
616
- '<div class="gloss">' + esc(b.note) + "</div>"
617
- ).join("") + '<p class="foot">' + esc(d.bandNote) + "</p>";
618
-
619
- if (withFeed) {
620
- renderFeed($("ov-feed"), d.feed, d);
621
- $("ov-feednote").textContent =
622
- "Payloads are ids, counts and bytes — never a memory's words, and never a turn of yours. " +
623
- "The names above are resolved at the moment this page was drawn.";
624
- }
625
-
626
- $("ov-identity").innerHTML = d.identityAbsent
627
- ? absenceLine(d.identityAbsent, "nothing has become constitutive")
628
- : d.identity.map((el) =>
629
- '<div class="r click" onclick="openMemory(\'' + el.id + '\')">' + said(el.text, el.confidential) +
630
- '<div class="meta"><span class="k">' + esc(el.kind) + "</span>" +
631
- // NOT `strength 1.00`. Every element in this band is at 1.00 by
632
- // construction, so the field said one thing fifteen times down the
633
- // panel in the README's first image. The day it crossed is the fact
634
- // that varies — and where the store never recorded a crossing, this
635
- // says nothing rather than repeating a tautology or inventing a day.
636
- (el.promotedDay === null
637
- ? (el.strength < 1 ? "<span>strength " + n2(el.strength) + "</span>" : "")
638
- : "<span>promoted day " + el.promotedDay + "</span>") +
639
- livedSpan(el) + "</div></div>"
640
- ).join("");
641
-
642
- $("ov-protected").innerHTML = d.guardedAbsent
643
- ? absenceLine(d.guardedAbsent, "nothing is permanent ink")
644
- : d.guarded.map((el) =>
645
- '<div class="r click" onclick="openMemory(\'' + el.id + '\')">' + said(el.text, el.confidential) +
646
- '<div class="meta"><span class="k">' + esc(el.kind) + "</span>" + livedSpan(el) + "</div></div>"
647
- ).join("");
648
-
649
- $("ov-contested").innerHTML = d.contestedAbsent
650
- ? absenceLine(d.contestedAbsent, "nothing I hold has been argued with")
651
- : d.contested.map(contestedCard).join("");
652
-
653
- $("ov-chapters").innerHTML = d.chaptersAbsent
654
- ? absenceLine(d.chaptersAbsent, "no chapter has been written")
655
- : d.chapters.map((c) =>
656
- '<div class="r click" onclick="openMemory(\'' + c.id + '\')"><span style="color:var(--cyan)">' +
657
- esc(c.title) + "</span>" +
658
- '<div style="color:var(--dim);margin-top:4px">' + esc(c.opening) + "</div>" +
659
- '<div class="meta"><span>lived day ' + c.day + "</span><span>" + c.bytes + " bytes</span></div></div>"
660
- ).join("");
661
- }
662
-
663
- function contestedCard(c) {
664
- const over = c.fraction >= 1;
665
- return '<div class="card pad" style="margin-bottom:8px">' +
666
- '<div style="font-size:10px;letter-spacing:1px;text-transform:uppercase;color:var(--faint)">about ' +
667
- esc(c.about) + "</div>" +
668
- '<div style="font-size:11.5px;margin:6px 0 8px;line-height:1.6">' + esc(c.now) + "</div>" +
669
- '<div class="bar" style="margin:6px 0"><span class="lab" style="font-size:10px;color:var(--dim)">pressure</span>' +
670
- '<span class="track"><span class="fill" style="width:' + pct(Math.min(1, c.fraction)) +
671
- "%;background:" + (over ? COL.amber : COL.teal) + ";box-shadow:0 0 9px " + (over ? COL.amber : COL.teal) + '55"></span></span>' +
672
- '<span class="n">' + n2(c.pressure) + "</span></div>" +
673
- '<div class="foot" style="margin-top:2px">' +
674
- (c.revised
675
- ? '<span style="color:var(--amber)">REVISED</span> — it changed its mind after ' + c.challenges + " credited " + (c.challenges === 1 ? "challenge" : "challenges") + ". The successor starts clean."
676
- : "held so far — it would take " + n2(c.bar) + " to move it, and " + c.challenges + " " + (c.challenges === 1 ? "challenge has" : "challenges have") + " landed") +
677
- "</div></div>";
678
- }
679
-
680
- function renderFeed(el, events, ctx) {
681
- if (!events || events.length === 0) {
682
- el.innerHTML = absenceLine(ctx && ctx.feedAbsent ? ctx.feedAbsent : "(never run)", "nothing has reached my durable log");
683
- return;
684
- }
685
- el.innerHTML = events.map((e) =>
686
- '<div class="ev ' + e.tone + '" data-seq="' + e.seq + '" onclick="openEvent(' + e.seq + ')">' +
687
- '<span class="d">day ' + e.day + "</span>" +
688
- '<span class="t">' + esc(e.text) + '<span class="k">' + esc(e.name) +
689
- (e.node ? " · " + esc(e.node) : "") + "</span></span></div>"
690
- ).join("");
691
- }
692
-
693
- // ═══════════════════════════════════════════════════════════════════════════
694
- // memories
695
- // ═══════════════════════════════════════════════════════════════════════════
696
- let MEM = null;
697
- async function renderMemories() {
698
- let d;
699
- try { d = await api("/api/memories"); } catch (e) { return fail("The memories page", e); }
700
- MEM = d;
701
- $("con-sub").textContent = "— " + d.total + " of them: age across, strength up, salience as size";
702
- $("con-legend").innerHTML = ["episodic","semantic","identity"].map((b) =>
703
- '<span><span class="chip" style="background:' + BANDCOL[b] + '"></span>' + b + "</span>").join("") +
704
- '<span style="color:var(--faint)">band is computed for today, not the one it was born into</span>';
705
-
706
- $("mem-bands").innerHTML = d.bands.map((b) =>
707
- '<div class="bar"><span class="lab' + (b.absent ? " none" : "") + '">' + esc(b.label) + "</span>" +
708
- '<span class="track"><span class="fill" style="width:' + pct(b.fraction) + "%;background:" +
709
- BANDCOL[b.label] + ';box-shadow:0 0 9px ' + BANDCOL[b.label] + '55"></span></span>' +
710
- '<span class="n">' + (b.absent ? esc(b.absent) : b.count) + "</span></div>"
711
- ).join("");
712
-
713
- $("kinds").innerHTML =
714
- "<table><thead><tr><th>kind</th><th class='num'>held</th><th class='num'>mean</th>" +
715
- "<th class='num'>wSal</th><th class='num'>wRep</th><th class='num'>κ</th><th class='num'>ι</th></tr></thead><tbody>" +
716
- d.kinds.map((k) =>
717
- "<tr><td>" + esc(k.kind) + '<div class="meta" style="color:var(--faint);font-size:10px;margin-top:3px">' +
718
- esc(k.gloss) + "</div></td>" +
719
- '<td class="num' + (k.absent ? " dimtd" : "") + '">' + (k.absent ? esc(k.absent) : k.count) + "</td>" +
720
- '<td class="num dimtd">' + n2(k.meanStrength) + "</td>" +
721
- '<td class="num dimtd">' + n2(k.wSal) + '</td><td class="num dimtd">' + n2(k.wRep) + "</td>" +
722
- '<td class="num dimtd">' + n2(k.kappa) + '</td><td class="num dimtd">' + n2(k.iota) + "</td></tr>"
723
- ).join("") + "</tbody></table>";
724
-
725
- $("hubs").innerHTML = d.hubsAbsent
726
- ? absenceLine(d.hubsAbsent, "nothing has been wired to anything yet")
727
- : d.hubs.map((h) =>
728
- '<div class="r click" onclick="openMemory(\'' + h.id + '\')">' + said(h.text, h.confidential) +
729
- '<div class="meta"><span>summed weight ' + n2(h.weight) + "</span><span>" + h.degree + " edges</span></div></div>"
730
- ).join("");
731
-
732
- drawConstellation();
733
- drawHistogram();
734
- }
735
-
736
- let conPoints = [];
737
- function drawConstellation() {
738
- if (!MEM) return;
739
- const cv = $("con");
740
- const { ctx, w, h } = fit(cv);
741
- const padL = 34, padR = 12, padT = 12, padB = 26;
742
- const maxAge = Math.max(1, ...MEM.points.map((p) => p.ageDays));
743
- const X = (a) => padL + (a / maxAge) * (w - padL - padR);
744
- const Y = (s) => h - padB - Math.max(0, Math.min(1, s)) * (h - padT - padB);
745
-
746
- // grid
747
- ctx.strokeStyle = "rgba(0,229,255,.07)";
748
- ctx.fillStyle = "#39424d";
749
- ctx.lineWidth = 1;
750
- for (let i = 0; i <= 4; i++) {
751
- const y = Y(i / 4);
752
- ctx.beginPath(); ctx.moveTo(padL, y); ctx.lineTo(w - padR, y); ctx.stroke();
753
- ctx.fillText((i / 4).toFixed(2), 2, y + 3);
754
- }
755
- ctx.fillText("0", padL, h - 8);
756
- ctx.fillText(maxAge + " lived days old", w - padR - 118, h - 8);
757
-
758
- if (MEM.points.length === 0) {
759
- ctx.fillStyle = "#5c6773";
760
- ctx.fillText(String(MEM.pointsAbsent || "(never run)") + " — I hold no memory to plot.", padL + 8, h / 2);
761
- conPoints = [];
762
- return;
763
- }
764
-
765
- conPoints = [];
766
- for (const p of MEM.points) {
767
- const x = X(p.ageDays), y = Y(p.strength);
768
- const r = 2 + Math.max(0, Math.min(1, p.salience)) * 5;
769
- const col = BANDCOL[p.band] || COL.dim;
770
- ctx.beginPath();
771
- ctx.arc(x, y, r, 0, Math.PI * 2);
772
- ctx.fillStyle = col + (p.protected ? "ee" : "99");
773
- ctx.fill();
774
- if (p.protected || p.band === "identity") {
775
- ctx.strokeStyle = col; ctx.lineWidth = 1; ctx.stroke();
776
- }
777
- conPoints.push({ x, y, r: Math.max(r, 5), p });
778
- }
779
- }
780
-
781
- function hitTest(cv, ev, points) {
782
- const rect = cv.getBoundingClientRect();
783
- const x = ev.clientX - rect.left, y = ev.clientY - rect.top;
784
- let best = null, bestD = 1e9;
785
- for (const pt of points) {
786
- const d = (pt.x - x) ** 2 + (pt.y - y) ** 2;
787
- if (d < bestD && d <= pt.r * pt.r * 2.2) { best = pt; bestD = d; }
788
- }
789
- return best;
790
- }
791
- $("con").addEventListener("mousemove", (e) => {
792
- const hit = hitTest($("con"), e, conPoints);
793
- if (!hit) return hideTip();
794
- const p = hit.p;
795
- showTip(e.clientX, e.clientY,
796
- (p.confidential ? '<span class="withheld">' + esc(p.text) + "</span>" : esc(p.text)) +
797
- '<div class="dimline">' + esc(p.kind) + " · " + esc(p.band) + " · strength " + n2(p.strength) +
798
- " · salience " + n2(p.salience) + " · born day " + p.bornDay + " · used " + p.uses + "×</div>");
799
- });
800
- $("con").addEventListener("mouseleave", hideTip);
801
- $("con").addEventListener("click", (e) => {
802
- const hit = hitTest($("con"), e, conPoints);
803
- if (hit) openMemory(hit.p.id);
804
- });
805
-
806
- function drawHistogram() {
807
- const cv = $("hist");
808
- const { ctx, w, h } = fit(cv);
809
- const d = MEM.distribution;
810
- const peak = Math.max(1, ...d.map((b) => b.count));
811
- const padL = 30, padB = 20, padT = 10;
812
- const bw = (w - padL - 10) / d.length;
813
- ctx.fillStyle = "#39424d";
814
- ctx.fillText(String(peak), 2, padT + 8);
815
- ctx.fillText("0", 2, h - padB + 4);
816
- d.forEach((b, i) => {
817
- const bh = (b.count / peak) * (h - padT - padB);
818
- const x = padL + i * bw;
819
- const t = b.from;
820
- ctx.fillStyle = t < 0.25 ? COL.dim : t < 0.6 ? COL.cyan : t < 0.85 ? COL.teal : COL.purple;
821
- ctx.globalAlpha = 0.85;
822
- ctx.fillRect(x + 1, h - padB - bh, bw - 2, bh);
823
- ctx.globalAlpha = 1;
824
- });
825
- ctx.strokeStyle = "rgba(0,229,255,.12)";
826
- ctx.beginPath(); ctx.moveTo(padL, h - padB); ctx.lineTo(w - 8, h - padB); ctx.stroke();
827
- ctx.fillStyle = "#39424d";
828
- ctx.fillText("weakest", padL, h - 6);
829
- ctx.fillText("strongest", w - 68, h - 6);
830
- }
831
-
832
- // search
833
- let qtimer = null;
834
- $("q").addEventListener("input", () => {
835
- clearTimeout(qtimer);
836
- qtimer = setTimeout(runSearch, 180);
837
- });
838
- async function runSearch() {
839
- const q = $("q").value.trim();
840
- const out = $("qout");
841
- if (q.length === 0) { out.hidden = true; $("qn").textContent = ""; return; }
842
- let d;
843
- try { d = await api("/api/search?limit=25&q=" + encodeURIComponent(q)); }
844
- catch (e) { return fail("Search", e); }
845
- out.hidden = false;
846
- $("qn").textContent = d.hits.length + (d.hits.length === 1 ? " match" : " matches");
847
- out.innerHTML = d.absent
848
- ? absenceLine(d.absent, "nothing I hold matches those words")
849
- : d.hits.map((hit) =>
850
- '<div class="r click" onclick="openMemory(\'' + hit.id + '\')">' + said(hit.text, hit.confidential) +
851
- '<div class="meta"><span class="k">' + esc(hit.kind) + "</span><span>" + esc(hit.band) +
852
- "</span><span>strength " + n2(hit.strength) + "</span><span>score " + n2(hit.score) + "</span></div></div>"
853
- ).join("");
854
- }
855
-
856
- // ═══════════════════════════════════════════════════════════════════════════
857
- // mind
858
- // ═══════════════════════════════════════════════════════════════════════════
859
- async function renderMind() {
860
- let d;
861
- try { d = await api("/api/mind"); } catch (e) { return fail("The mind page", e); }
862
- $("mind-opening").textContent = d.opening;
863
-
864
- const elRow = (el) =>
865
- '<div class="r click" onclick="openMemory(\'' + el.id + '\')">' + said(el.text, el.confidential) +
866
- '<div class="meta"><span class="k">' + esc(el.kind) + "</span><span>" + esc(el.band) +
867
- "</span><span>strength " + n2(el.strength) + "</span><span>" + el.bytes + " bytes</span>" +
868
- livedSpan(el) + "</div></div>";
869
-
870
- $("mind-identity").innerHTML = d.identityAbsent
871
- ? absenceLine(d.identityAbsent, "nothing has become constitutive")
872
- : d.identity.map(elRow).join("");
873
- $("mind-protected").innerHTML = d.guardedAbsent
874
- ? absenceLine(d.guardedAbsent, "nothing is permanent ink")
875
- : d.guarded.map(elRow).join("");
876
- $("mind-outside").innerHTML = d.protectedOutsideIdentity.length === 0
877
- ? emptyBox("(none yet) — every permanent element also stands in the identity band.", "")
878
- : d.protectedOutsideIdentity.map((el) =>
879
- '<div class="r click" onclick="openMemory(\'' + el.id + '\')">' + esc(el.text) + "</div>").join("");
880
- $("mind-unreadable").innerHTML = d.unreadable.length === 0
881
- ? emptyBox("(none yet) — every element in the band read cleanly.", "")
882
- : d.unreadable.map((u) => '<div class="r">' + esc(u.label) + "</div>").join("");
883
-
884
- // The page, and what it used to say. Read-only: there is no write door here.
885
- $("mind-page").innerHTML = d.pageAbsent
886
- ? absenceLine(d.pageAbsent, "no page has been written — still forming")
887
- : '<div class="wakehead"><b style="color:var(--cyan);font-weight:400">' + d.page.bytes + " bytes</b>, version " +
888
- d.page.version + ", last revised " + esc(d.page.revisedOn || "an unrecorded date") +
889
- (d.page.by ? " by " + esc(d.page.by) : "") +
890
- (d.page.stale ? ' <span style="color:var(--amber)">— STALE</span>' : "") +
891
- (d.page.reason ? "<br><br>Last change: " + esc(d.page.reason) : "") + "</div>" +
892
- '<div class="lane"><div class="item" style="white-space:pre-wrap">' + esc(d.page.body) + "</div></div>";
893
- $("mind-page-versions").innerHTML = d.pageVersions.length === 0
894
- ? emptyBox("(none yet) — the page has been written once, or not at all.", "")
895
- : d.pageVersions.map((v) =>
896
- '<div class="r"><span style="color:var(--cyan)">version ' + v.seq + "</span>" +
897
- '<div class="meta"><span>lived day ' + v.day + "</span><span>" + esc(v.reason) + "</span></div>" +
898
- '<div style="color:var(--dim);margin-top:6px;white-space:pre-wrap">' +
899
- esc(v.body === null ? "(this version's prose could not be read)" : v.body) + "</div></div>"
900
- ).join("");
901
-
902
- const w = d.wake;
903
- $("mind-wake").innerHTML = !w.ok
904
- ? absenceLine(w.absent || "(never run)", "I have composed no briefing (" + w.reason + ")")
905
- : '<div class="wakehead"><b style="color:var(--cyan);font-weight:400">' + w.bytes + " bytes</b>, composed and waiting. " +
906
- "This is the text the next session opens with — rendered without a model, and read from the store just now." +
907
- (w.preface ? "<br><br>Delivery preface: " + esc(w.preface) : "") + "</div>" +
908
- w.lanes.map((lane) =>
909
- '<div class="lane"><h4>' + esc(lane.heading) + "</h4>" +
910
- lane.items.map((item) => {
911
- const m = /^(\S+\s·\s|by\s\S+\s·\s)/.exec(item);
912
- return '<div class="item">' + (m ? '<span class="date">' + esc(m[1]) + "</span>" + esc(item.slice(m[1].length)) : esc(item)) + "</div>";
913
- }).join("") + "</div>"
914
- ).join("");
915
-
916
- $("mind-chapters").innerHTML = d.chaptersAbsent
917
- ? absenceLine(d.chaptersAbsent, "no chapter has been written")
918
- : d.chapters.map((c) =>
919
- '<div class="r click" onclick="openMemory(\'' + c.id + '\')"><span style="color:var(--cyan)">' +
920
- esc(c.title) + "</span><div style=\"color:var(--dim);margin-top:4px\">" + esc(c.opening) + "</div>" +
921
- '<div class="meta"><span>lived day ' + c.day + "</span><span>" + c.bytes + " bytes</span></div></div>"
922
- ).join("");
923
-
924
- $("mind-stories").innerHTML = d.storiesAbsent
925
- ? absenceLine(d.storiesAbsent, "no belief of mine has taken a single credited challenge") +
926
- '<p class="foot">That is a real answer, not an empty panel: a store with no contested belief has never had one, and this line is how I say so.</p>'
927
- : d.stories.map(storyCard).join("");
928
- }
929
-
930
- function storyCard(s) {
931
- const beats = s.beatsAbsent
932
- ? '<div class="foot">' + esc(s.beatsAbsent) + "</div>"
933
- : s.beats.map((b) =>
934
- '<div class="beat' + (b.crossed ? " crossed" : "") + '">' +
935
- '<div class="day">day ' + b.day + "</div>" +
936
- '<div class="who">' + esc(b.challenger) + "<em>force " + n3(b.force) + "</em></div>" +
937
- "<div><div class='track'><span class='fill' style='display:block;width:" + pct(Math.min(1, b.fraction)) +
938
- "%'></span><span class='barline' style='left:" + pct(Math.min(1, 1 / Math.max(b.fraction || 1, 1))) + "%'></span></div>" +
939
- // The numbers first, then the clause they mean. "0.598 of 0.470"
940
- // beside the bare word REVISED read as a numerator larger than its
941
- // denominator with nothing saying that IS what clearing looks like.
942
- "<div class='verdict'>pressure " + n3(b.pressureAfter) + " against a bar of " + n3(b.bar) +
943
- " — " + esc(b.verdict) + "</div>" +
944
- (b.became
945
- ? "<div class='verdict became'" + (b.becameId ? " onclick=\"openMemory('" + b.becameId + "')\"" : "") +
946
- ">it became: " + esc(b.became) + "</div>"
947
- : "") +
948
- "</div>" +
949
- "</div>"
950
- ).join("");
951
- // The two ends are shown around the point they DIVERGE, so a revision that
952
- // kept most of its sentence still reads as a revision. The whole statement is
953
- // one hover (or one click) away.
954
- const said = (label, text, full, id, style) =>
955
- '<div class="said"><span class="k">' + label + "</span>" +
956
- '<span class="stmt' + (id ? " click" : "") + '" title="' + esc(full) + '"' +
957
- (id ? " onclick=\"openMemory('" + id + "')\"" : "") + (style ? ' style="' + style + '"' : "") + ">" +
958
- esc(text) + "</span></div>";
959
- return '<div class="story">' +
960
- '<div class="about">about ' + esc(s.about) + "</div>" +
961
- said("it began as", s.began, s.beganFull, s.id, "") +
962
- (s.revised
963
- ? said("it now says", s.now, s.nowFull, s.headId, "color:var(--amber)")
964
- : said("it now says", s.now + " — nothing has revised it", s.nowFull, s.headId, "")) +
965
- '<div class="said"><span class="k">pressure now</span>' +
966
- (s.pressure === 0
967
- ? '<span style="color:var(--dim)">(none yet) — ' + (s.revised ? "the revision reset it; the successor starts clean" : "it has decayed, or was never credited") + "</span>"
968
- : n3(s.pressure) + " against a bar of " + n3(s.bar)) + "</div>" +
969
- "<div style='margin-top:10px'>" + beats + "</div></div>";
970
- }
971
-
972
- // ═══════════════════════════════════════════════════════════════════════════
973
- // flow
974
- // ═══════════════════════════════════════════════════════════════════════════
975
- let FLOW = null, flowBoxes = [], selectedNode = null;
976
- const ACCENT = { cyan:COL.cyan, purple:COL.purple, amber:COL.amber, teal:COL.teal };
977
-
978
- async function renderFlow() {
979
- try { FLOW = await api("/api/flow"); } catch (e) { return fail("The flow page", e); }
980
- renderFeed($("flow-feed"), FLOW.feed, FLOW);
981
- lastSeq = FLOW.lastSeq;
982
- drawFlow();
983
- // Open on a node rather than on "click any node in the diagram." The
984
- // mechanism panel is the best writing on the page and an empty box is a
985
- // 900×90 hole in the middle of it; sleep is the one whose brain analogy most
986
- // people already half-know, so it is the one worth meeting first.
987
- if (selectedNode === null) await selectNode("sleep");
988
- }
989
-
990
- function nodeCentre(b) { return { x: b.x + b.w / 2, y: b.y + b.h / 2 }; }
991
-
992
- /** Under ~900px of container the diagram is a list. Above it, a canvas. */
993
- const FLOW_CANVAS_MIN = 900;
994
-
995
- function drawFlow() {
996
- if (!FLOW) return;
997
- const narrow = ($("flowbox").clientWidth || 0) < FLOW_CANVAS_MIN;
998
- $("flowcv").hidden = narrow;
999
- $("flowlist").hidden = !narrow;
1000
- if (narrow) return renderFlowList();
1001
- const cv = $("flowcv");
1002
- const { ctx, w, h } = fit(cv);
1003
- const M = 10;
1004
- const boxes = {};
1005
- flowBoxes = [];
1006
- for (const n of FLOW.nodes) {
1007
- 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 };
1008
- boxes[n.key] = b;
1009
- flowBoxes.push(b);
1010
- }
1011
-
1012
- // Edges first, dim and static — only particles mean activity.
1013
- //
1014
- // Each edge is a quadratic from centre to centre, but only the part OUTSIDE
1015
- // both boxes is drawn: a line that starts at a node's centre emerges from
1016
- // under its own box, and a label placed at the geometric midpoint lands on
1017
- // top of whatever box sits between the two. So the curve is sampled, clipped
1018
- // to the first and last points in open space, and the label is placed on the
1019
- // visible middle — or dropped when there is no room for it.
1020
- const SAMPLES = 64;
1021
- // Labels already placed this frame. An edge label that would land on another
1022
- // one is dropped rather than overprinted: `at session startootnotes · one
1023
- // loud` was two labels rendering as one string.
1024
- const placed = [];
1025
- 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;
1026
- // Kept for the frame: a particle rides the same clipped curve the edge was
1027
- // drawn along, rather than a second approximation of it.
1028
- edgePaths = {};
1029
-
1030
- for (const e of FLOW.edges) {
1031
- const a = boxes[e.from], z = boxes[e.to];
1032
- if (!a || !z) continue;
1033
- const p0 = nodeCentre(a), p1 = nodeCentre(z);
1034
- const bow = e.bow || 0;
1035
- const clamp = (v, lo, hi) => Math.max(lo, Math.min(hi, v));
1036
- const mx = clamp((p0.x + p1.x) / 2 + bow * (p1.y - p0.y), M + 6, w - M - 6);
1037
- const my = clamp((p0.y + p1.y) / 2 - bow * (p1.x - p0.x), M + 14, h - M - 6);
1038
- const at = (t) => ({
1039
- x: (1 - t) * (1 - t) * p0.x + 2 * (1 - t) * t * mx + t * t * p1.x,
1040
- y: (1 - t) * (1 - t) * p0.y + 2 * (1 - t) * t * my + t * t * p1.y,
1041
- });
1042
- const inside = (pt, b, pad) =>
1043
- pt.x >= b.x - pad && pt.x <= b.x + b.w + pad && pt.y >= b.y - pad && pt.y <= b.y + b.h + pad;
1044
-
1045
- let start = 0, end = 1;
1046
- for (let i = 0; i <= SAMPLES; i++) { if (!inside(at(i / SAMPLES), a, 3)) { start = i / SAMPLES; break; } }
1047
- for (let i = SAMPLES; i >= 0; i--) { if (!inside(at(i / SAMPLES), z, 3)) { end = i / SAMPLES; break; } }
1048
- if (end <= start) continue;
1049
- edgePaths[e.from + ">" + e.to] = { at, start, end };
1050
-
1051
- ctx.save();
1052
- ctx.strokeStyle = e.dotted ? "rgba(255,215,64,.24)" : "rgba(0,229,255,.18)";
1053
- ctx.lineWidth = 1;
1054
- if (e.dotted) ctx.setLineDash([3, 4]);
1055
- ctx.beginPath();
1056
- for (let i = 0; i <= SAMPLES; i++) {
1057
- const t = start + (end - start) * (i / SAMPLES);
1058
- const pt = at(t);
1059
- if (i === 0) ctx.moveTo(pt.x, pt.y); else ctx.lineTo(pt.x, pt.y);
1060
- }
1061
- ctx.stroke();
1062
- ctx.restore();
1063
-
1064
- // arrowhead, on the clipped end
1065
- const tip = at(end), back = at(Math.max(start, end - 0.05));
1066
- const ang = Math.atan2(tip.y - back.y, tip.x - back.x);
1067
- ctx.fillStyle = e.dotted ? "rgba(255,215,64,.5)" : "rgba(0,229,255,.42)";
1068
- ctx.beginPath();
1069
- ctx.moveTo(tip.x, tip.y);
1070
- ctx.lineTo(tip.x - Math.cos(ang - 0.42) * 8, tip.y - Math.sin(ang - 0.42) * 8);
1071
- ctx.lineTo(tip.x - Math.cos(ang + 0.42) * 8, tip.y - Math.sin(ang + 0.42) * 8);
1072
- ctx.closePath();
1073
- ctx.fill();
1074
-
1075
- if (e.label) {
1076
- ctx.font = '9px "JetBrains Mono", ui-monospace, monospace';
1077
- const tw = ctx.measureText(e.label).width;
1078
- // A label on top of a box says nothing and hides something. Try a few
1079
- // places along the visible curve before giving up on it entirely.
1080
- let at_ = null;
1081
- for (const f of [0.5, 0.42, 0.58, 0.34, 0.66]) {
1082
- const pt = at(start + (end - start) * f);
1083
- const box = { x: pt.x - tw / 2 - 4, y: pt.y - 13, w: tw + 8, h: 14 };
1084
- const clear =
1085
- !flowBoxes.some((b) => overlaps(box, { x: b.x, y: b.y, w: b.w, h: b.h })) &&
1086
- !placed.some((o) => overlaps(box, o));
1087
- if (clear && box.x > M && box.x + box.w < w - M) { at_ = pt; placed.push(box); break; }
1088
- }
1089
- if (at_) {
1090
- ctx.textAlign = "center";
1091
- ctx.fillStyle = "rgba(10,14,20,.92)";
1092
- ctx.fillRect(at_.x - tw / 2 - 4, at_.y - 13, tw + 8, 14);
1093
- ctx.fillStyle = "rgba(92,103,115,.95)";
1094
- ctx.fillText(e.label, at_.x, at_.y - 3);
1095
- ctx.textAlign = "left";
1096
- }
1097
- }
1098
- }
1099
-
1100
- // nodes
1101
- for (const b of flowBoxes) {
1102
- const n = b.n;
1103
- const col = ACCENT[n.accent] || COL.cyan;
1104
- const glow = flashes[n.key] || 0;
1105
- const on = selectedNode === n.key;
1106
- ctx.fillStyle = "#0d1117";
1107
- ctx.strokeStyle = on ? col : col + (n.silent ? "33" : "66");
1108
- ctx.lineWidth = on ? 1.6 : 1;
1109
- roundRect(ctx, b.x, b.y, b.w, b.h, 4);
1110
- ctx.fill();
1111
- if (glow > 0.02) {
1112
- ctx.save();
1113
- ctx.shadowColor = col;
1114
- ctx.shadowBlur = 34 * glow;
1115
- ctx.lineWidth = 1 + 1.4 * glow;
1116
- ctx.strokeStyle = col;
1117
- ctx.stroke();
1118
- ctx.stroke();
1119
- ctx.restore();
1120
- }
1121
- ctx.stroke();
1122
-
1123
- ctx.fillStyle = n.silent && !on ? col + "aa" : col;
1124
- ctx.font = '10px "JetBrains Mono", ui-monospace, monospace';
1125
- ctx.fillText(clip(ctx, n.label, b.w - 18), b.x + 9, b.y + 16);
1126
- ctx.fillStyle = "#5c6773";
1127
- ctx.font = '9px "JetBrains Mono", ui-monospace, monospace';
1128
- wrapText(ctx, n.sub, b.x + 9, b.y + 29, b.w - 16, 10, 2);
1129
- ctx.fillStyle = n.silent ? "#39424d" : "#c5cdd8";
1130
- ctx.font = '9.5px "JetBrains Mono", ui-monospace, monospace';
1131
- ctx.fillText(clip(ctx, n.state, b.w - 18), b.x + 9, b.y + b.h - 9);
1132
- }
1133
-
1134
- // PARTICLES RIDE ONLY ON REAL NEW EVENTS — and they have to be seen to mean
1135
- // anything. A 2.6px dot on a 1400px diagram was the entire payoff for "only
1136
- // particles mean activity"; this is a comet with a trail, travelling the edge
1137
- // into the node that recorded the event, ending in a flare on the box itself.
1138
- for (const p of particles) {
1139
- const path = edgePaths[p.key];
1140
- const target = boxes[p.node];
1141
- if (!target) continue;
1142
- const point = (t) => {
1143
- if (path) return path.at(path.start + (path.end - path.start) * Math.max(0, Math.min(1, t)));
1144
- // No edge into this node on the diagram: orbit its own box instead.
1145
- const c = nodeCentre(target);
1146
- const a = p.spin + t * 4.4;
1147
- return { x: c.x + Math.cos(a) * (target.w / 2 + 10), y: c.y + Math.sin(a) * (target.h / 2 + 10) };
1148
- };
1149
- ctx.save();
1150
- ctx.globalCompositeOperation = "lighter";
1151
- for (let i = TRAIL; i >= 0; i--) {
1152
- const t = p.t - i * 0.022;
1153
- if (t < 0) continue;
1154
- const q = point(t);
1155
- const fade = 1 - i / (TRAIL + 1);
1156
- ctx.beginPath();
1157
- ctx.arc(q.x, q.y, 1.2 + 3.4 * fade * fade, 0, Math.PI * 2);
1158
- ctx.fillStyle = p.col;
1159
- ctx.globalAlpha = 0.10 + 0.55 * fade * fade;
1160
- ctx.fill();
1161
- }
1162
- // The head, with a halo, so one event is unmistakable at a glance.
1163
- const head = point(p.t);
1164
- ctx.globalAlpha = 1;
1165
- ctx.shadowColor = p.col;
1166
- ctx.shadowBlur = 16;
1167
- ctx.beginPath();
1168
- ctx.arc(head.x, head.y, 4.2, 0, Math.PI * 2);
1169
- ctx.fillStyle = "#ffffff";
1170
- ctx.fill();
1171
- ctx.beginPath();
1172
- ctx.arc(head.x, head.y, 7.5, 0, Math.PI * 2);
1173
- ctx.fillStyle = p.col;
1174
- ctx.globalAlpha = 0.35;
1175
- ctx.fill();
1176
- ctx.restore();
1177
- }
1178
- }
1179
-
1180
- /**
1181
- * The same fourteen nodes, in pipeline order, as a list. Every node keeps its
1182
- * accent, its subtitle and its state line, and clicking one opens the same
1183
- * mechanism panel the diagram opens — so nothing is lost on a phone except the
1184
- * arrows, which are named in the chain markers between the rows.
1185
- */
1186
- function renderFlowList() {
1187
- const order = ["session","spans","sweep","remember","encode","store","physics","recall","associate","schemas","prospective","sleep","wake","self"];
1188
- const byKey = {};
1189
- for (const n of FLOW.nodes) byKey[n.key] = n;
1190
- $("flowlist").innerHTML = order.map((key, i) => {
1191
- const n = byKey[key];
1192
- if (!n) return "";
1193
- const col = ACCENT[n.accent] || COL.cyan;
1194
- return (i === 0 ? "" : '<div class="fchain">↓</div>') +
1195
- '<div class="fnode' + (n.silent ? " silent" : "") + (selectedNode === n.key ? " on" : "") +
1196
- '" onclick="selectNode(\'' + n.key + '\')">' +
1197
- '<span><span class="nm" style="color:' + col + '">' + esc(n.label) + "</span>" +
1198
- '<span class="sb">' + esc(n.sub) + "</span></span>" +
1199
- '<span class="st">' + esc(n.state) + "</span></div>";
1200
- }).join("");
1201
- }
1202
-
1203
- function roundRect(ctx, x, y, w, h, r) {
1204
- ctx.beginPath();
1205
- ctx.moveTo(x + r, y);
1206
- ctx.arcTo(x + w, y, x + w, y + h, r);
1207
- ctx.arcTo(x + w, y + h, x, y + h, r);
1208
- ctx.arcTo(x, y + h, x, y, r);
1209
- ctx.arcTo(x, y, x + w, y, r);
1210
- ctx.closePath();
1211
- }
1212
- /** Trim to fit AND SAY SO. A silent trim reads as the whole value — `SELF` was
1213
- * reporting "15 in the band · 2 pe" as if that were a sentence. */
1214
- function clip(ctx, text, maxw) {
1215
- const t = String(text);
1216
- if (ctx.measureText(t).width <= maxw) return t;
1217
- let cut = t;
1218
- while (cut.length > 1 && ctx.measureText(cut + "…").width > maxw) cut = cut.slice(0, -1);
1219
- return cut.trimEnd() + "…";
1220
- }
1221
- function wrapText(ctx, text, x, y, maxw, lh, maxLines) {
1222
- const words = String(text).split(" ");
1223
- let line = "", lines = 0;
1224
- for (const word of words) {
1225
- const test = line ? line + " " + word : word;
1226
- if (ctx.measureText(test).width > maxw && line) {
1227
- ctx.fillText(line, x, y + lines * lh);
1228
- lines += 1;
1229
- line = word;
1230
- if (lines >= maxLines) return;
1231
- } else line = test;
1232
- }
1233
- if (line && lines < maxLines) ctx.fillText(line, x, y + lines * lh);
1234
- }
1235
-
1236
- $("flowcv").addEventListener("click", (e) => {
1237
- const rect = e.currentTarget.getBoundingClientRect();
1238
- const x = e.clientX - rect.left, y = e.clientY - rect.top;
1239
- for (const b of flowBoxes) {
1240
- if (x >= b.x && x <= b.x + b.w && y >= b.y && y <= b.y + b.h) { selectNode(b.n.key); return; }
1241
- }
1242
- });
1243
-
1244
- async function selectNode(key) {
1245
- selectedNode = key;
1246
- drawFlow();
1247
- let d;
1248
- try { d = await api("/api/node?key=" + encodeURIComponent(key)); }
1249
- catch (e) { return fail("That node", e); }
1250
- $("flowdetail").innerHTML =
1251
- "<h3>" + esc(d.label) + "</h3>" +
1252
- "<p>" + esc(d.what) + "</p>" +
1253
- '<div class="lab">where the brain analogy holds</div>' +
1254
- '<div class="brain">' + esc(d.analog) + "</div>" +
1255
- '<div class="lab">where it deliberately breaks</div>' +
1256
- '<div class="breaks">' + esc(d.breaks) + "</div>" +
1257
- '<div class="lab">right now</div>' +
1258
- "<p style='color:var(--dim)'>" + esc(d.state) + "</p>" +
1259
- '<div class="lab">what it has been doing</div>' +
1260
- (d.noEventOfItsOwn
1261
- ? "<p style='color:var(--dim)'>" + esc(d.noEventOfItsOwn) + "</p>"
1262
- : d.unloggedPath
1263
- ? "<p style='color:var(--dim)'>" + esc(d.unloggedPath) + "</p>" +
1264
- (d.recent.length === 0 ? "" : d.recent.map(nodeEvent).join(""))
1265
- : d.recent.length === 0
1266
- ? "<p style='color:var(--dim)'>" + esc(d.recentAbsent || "(never run)") + " — nothing of this node's has reached the log.</p>"
1267
- : d.recent.map(nodeEvent).join(""));
1268
- }
1269
- function nodeEvent(ev) {
1270
- return "<p class='tone-" + ev.tone + "' style='font-size:11px'>" +
1271
- "<span style='color:var(--faint)'>day " + ev.day + " · </span>" + esc(ev.text) + "</p>";
1272
- }
1273
-
1274
- window.selectNode = selectNode;
1275
- /** How many comets are in flight. A harness that wants to photograph "only
1276
- * particles mean activity" has to know WHEN, and a fixed sleep either misses
1277
- * the animation or catches an empty frame. */
1278
- window.particleCount = () => particles.length;
1279
- /** One node's state line, for a harness that wants to prove the counters are
1280
- * live rather than take a screenshot's word for it. */
1281
- window.flowState = (key) => {
1282
- const node = FLOW && FLOW.nodes.find((n) => n.key === key);
1283
- return node ? node.state : "";
1284
- };
1285
- /** One overview tile's number, READ OFF THE PAGE rather than out of a variable,
1286
- * for the same reason: the flow diagram's counters were proved live while the
1287
- * tiles beside them were not, and a harness that asked the payload would have
1288
- * believed a page that never repainted. */
1289
- window.tileValue = (label) => {
1290
- for (const tile of document.querySelectorAll("#ov-tiles .tile")) {
1291
- const l = tile.querySelector(".l");
1292
- if (l && l.textContent === label) {
1293
- const n = tile.querySelector(".n");
1294
- return n ? n.textContent : "";
1295
- }
1296
- }
1297
- return "";
1298
- };
1299
-
1300
- // ═══════════════════════════════════════════════════════════════════════════
1301
- // health
1302
- // ═══════════════════════════════════════════════════════════════════════════
1303
- async function renderHealth() {
1304
- let d;
1305
- try { d = await api("/api/health"); } catch (e) { return fail("The health page", e); }
1306
-
1307
- $("h-phases").innerHTML =
1308
- "<table><thead><tr><th>phase</th><th>last finished</th><th class='num'>days ago</th></tr></thead><tbody>" +
1309
- d.phases.map((p) =>
1310
- "<tr><td>" + esc(p.phase) + "</td><td class='" + (p.absent ? "dimtd" : "") + "'>" +
1311
- (p.absent ? esc(p.absent) : "lived day " + p.day) + "</td>" +
1312
- "<td class='num dimtd'>" + (p.absent ? "—" : p.ago === 0 ? "today" : p.ago) + "</td></tr>"
1313
- ).join("") + "</tbody></table>";
1314
-
1315
- $("h-symmetry").innerHTML =
1316
- "<table><thead><tr><th>kind</th><th class='num'>up</th><th class='num'>down</th><th>verdict</th></tr></thead><tbody>" +
1317
- d.symmetry.map((s) =>
1318
- "<tr><td>" + esc(s.kind) + "</td><td class='num dimtd'>" + s.up + "</td><td class='num dimtd'>" + s.down + "</td>" +
1319
- "<td style='color:" + (s.ok ? "var(--teal)" : "var(--amber)") + "'>" + esc(s.reason) + "</td></tr>"
1320
- ).join("") + "</tbody></table>";
1321
-
1322
- $("h-exits").innerHTML =
1323
- "<table><thead><tr><th>reason</th><th class='num'>since birth</th><th>what it means</th></tr></thead><tbody>" +
1324
- d.exits.map((e) =>
1325
- "<tr><td>" + esc(e.reason) + "</td>" +
1326
- "<td class='num" + (e.absent ? " dimtd" : "") + "'>" + (e.absent ? esc(e.absent) : e.count) + "</td>" +
1327
- "<td class='dimtd'>" + esc(e.gloss) + "</td></tr>"
1328
- ).join("") + "</tbody></table>";
1329
-
1330
- $("h-removals").innerHTML = d.removalsAbsent
1331
- ? absenceLine(d.removalsAbsent, "the owner has erased nothing")
1332
- : d.removals.map((r) =>
1333
- '<div class="r">' + esc(r.label) + '<div class="meta"><span class="k">' + esc(r.stage) +
1334
- "</span><span>by " + esc(r.actor) + "</span><span>" + esc(r.reason || "no reason recorded") +
1335
- "</span></div></div>").join("");
1336
-
1337
- // ONE table where there were two, and the English leads. The dotted name is
1338
- // still on the page — it is what the owner greps the log for — but on the
1339
- // second line, in the type an identifier deserves.
1340
- $("h-records").innerHTML =
1341
- "<table><thead><tr><th>what it records</th><th class='num'>kept</th></tr></thead><tbody>" +
1342
- d.records.map((r) =>
1343
- "<tr><td><div class='lead'>" + esc(r.gloss) + "</div>" +
1344
- "<div class='ident'>" + esc(r.name) +
1345
- (r.adapter ? "<span class='hostmark'>host</span>" : "") +
1346
- (r.note ? "<span class='notemark'>" + esc(r.note) + "</span>" : "") + "</div></td>" +
1347
- "<td class='num" + (r.absent ? " dimtd" : "") + "'>" + (r.absent ? esc(r.absent) : r.count) + "</td></tr>"
1348
- ).join("") + "</tbody></table>";
1349
-
1350
- const hm = d.heatmap;
1351
- const peak = Math.max(1, ...hm.cells.map((c) => c.count));
1352
- const byName = {};
1353
- for (const c of hm.cells) { (byName[c.name] = byName[c.name] || {})[c.day] = c.count; }
1354
- $("h-heat").innerHTML =
1355
- "<table class='heatgrid'><thead><tr><th></th>" +
1356
- hm.days.map((day) => "<td class='dayhdr'>" + day + "</td>").join("") + "</tr></thead><tbody>" +
1357
- hm.names.map((name) =>
1358
- "<tr><th>" + esc(name) + "</th>" +
1359
- hm.days.map((day) => {
1360
- const c = (byName[name] || {})[day] || 0;
1361
- const a = c === 0 ? 0 : 0.18 + 0.82 * (c / peak);
1362
- return "<td><div class='cell' title='" + esc(name) + " · day " + day + " · " + c + "' style='background:rgba(0,229,255," + a.toFixed(3) + ")'></div></td>";
1363
- }).join("") + "</tr>"
1364
- ).join("") + "</tbody></table>" +
1365
- "<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>";
1366
-
1367
- $("h-blind").innerHTML = d.blind.map((b) =>
1368
- '<div class="blind"><span class="w">' + esc(b.what) + '</span> <span class="y">' + esc(b.why) + "</span></div>"
1369
- ).join("");
1370
-
1371
- await renderFired();
1372
- }
1373
-
1374
- // Constitution 11's last sentence, as one panel: what fired, what went quiet,
1375
- // and what nothing records at all. Its own fetch and its own table, so the
1376
- // health page above it is untouched.
1377
- async function renderFired() {
1378
- let d;
1379
- try { d = await api("/api/fired"); } catch (e) { return fail("The what-fired panel", e); }
1380
- const rows = [];
1381
- for (const { state, meaning } of d.vocabulary) {
1382
- const group = d.rows.filter((r) => r.state === state);
1383
- if (group.length === 0) continue;
1384
- rows.push("<tr><th colspan='3' class='dayhdr'>" + esc(state) + " (" + group.length + ") — " + esc(meaning) + "</th></tr>");
1385
- for (const r of group) {
1386
- rows.push(
1387
- "<tr><td><div class='lead'>" + esc(r.label) + "</div>" +
1388
- "<div class='ident'>" + esc(r.evidence) + "</div>" +
1389
- (r.note ? "<div class='ident'>" + esc(r.note) + "</div>" : "") + "</td>" +
1390
- "<td class='num" + (r.lastFired ? "" : " dimtd") + "'>" + esc(r.lastFired || "never") + "</td>" +
1391
- "<td class='num" + (r.firedInWindow ? "" : " dimtd") + "'>" + r.firedInWindow +
1392
- (r.refusedInWindow ? "<div class='ident'>refused " + r.refusedInWindow + (r.topRefusal ? " · " + esc(r.topRefusal) : "") + "</div>" : "") +
1393
- "</td></tr>",
1394
- );
1395
- }
1396
- }
1397
- $("h-fired").innerHTML =
1398
- "<table><thead><tr><th>what it does</th><th class='num'>last fired</th><th class='num'>7 days</th></tr></thead><tbody>" +
1399
- rows.join("") + "</tbody></table>";
1400
- $("h-fired-foot").textContent =
1401
- d.from + "→" + d.today + " (UTC), against " + d.previousFrom + "→" + d.previousTo + ". " +
1402
- (d.wentQuiet.length ? "Fired last week and not once this week: " + d.wentQuiet.join("; ") + ". "
1403
- : "Nothing that fired last week has fallen silent this week. ") +
1404
- (d.truncated ? "The event read hit its ceiling, so every count is a floor. " : "") +
1405
- "A row marked blind is one nothing durable records — its line says which row would fix it.";
1406
- }
1407
-
1408
- // ═══════════════════════════════════════════════════════════════════════════
1409
- // modals
1410
- // ═══════════════════════════════════════════════════════════════════════════
1411
- async function openMemory(id) {
1412
- let d;
1413
- try { d = await api("/api/memory?id=" + encodeURIComponent(id)); }
1414
- catch (e) { return fail("That memory", e); }
1415
- if (!d.found) {
1416
- return openModal("<h3>" + esc(id) + "</h3><div class='sub'>resolved just now</div>" +
1417
- emptyBox(d.absence || "[no longer at this address]",
1418
- "Ids are resolved at the moment a page is drawn, so a memory that has left the store stops resolving immediately."));
1419
- }
1420
- const kv = (k, v) => '<div class="k">' + esc(k) + '</div><div class="v">' + v + "</div>";
1421
- const s = d.salience;
1422
- openModal(
1423
- "<h3>" + (d.title ? esc(d.title) : d.confidential ? said(d.text, true) : esc(headline(d.text))) + "</h3>" +
1424
- "<div class='sub'><span>" + esc(d.id) + "</span>" +
1425
- (d.askedFor ? "<span>you asked for " + esc(d.askedFor) + ", which forwards here</span>" : "") +
1426
- "<span class='path'>rev " + esc(String(d.revision)) + " · " + esc(d.contentHash || "—") + "</span>" +
1427
- "<button class='copy' data-id=\"" + esc(d.id) + "\" onclick=\"copyId(this)\">copy id</button>" +
1428
- "</div>" +
1429
- "<div class='body'>" + (d.confidential ? '<span class="withheld">' + esc(d.text) + "</span>" : esc(d.text)) + "</div>" +
1430
- (d.journal
1431
- ? "<p style='color:var(--purple);font-size:11px;line-height:1.7;margin:-4px 0 14px'>" +
1432
- "This is a journal entry, not a memory. It is the account a memory was made from, it sits outside " +
1433
- "every sleep phase, and the physics below is recorded but never acted on — nothing here decays.</p>"
1434
- : "") +
1435
- '<div class="kv">' +
1436
- kv("kind", esc(d.kind)) +
1437
- kv("band", esc(d.band) + " <span style='color:var(--faint)'>(recorded " + esc(d.recordedBand) + ")</span>") +
1438
- kv("strength", n3(d.strength) + " <span style='color:var(--faint)'>· repetition " + n3(d.repetition) + "</span>") +
1439
- kv("salience", n3(s.combined) + " <span style='color:var(--faint)'>relevance " + n2(s.relevance) +
1440
- " · emotional " + n2(s.emotional) + " · predictive " + n2(s.predictive) +
1441
- (s.novelty === null ? " · <span style='color:var(--amber)'>novelty blind (no schema context existed)</span>" : " · novelty " + n2(s.novelty)) +
1442
- (s.claimed === null ? "" : " · claimed floor " + n2(s.claimed)) + "</span>") +
1443
- kv("lived", "born day " + d.bornDay + " · used " + d.uses + "× over " + d.reinforcedDays +
1444
- " separate days · last used day " + d.lastUsedDay) +
1445
- kv("recorded", esc(d.learnedOn) + (d.happenedOn ? " · happened " + esc(d.happenedOn) : "") +
1446
- "<span style='color:var(--faint)'> — the calendar day this entered the store; " +
1447
- "on a migrated or seeded store, the day of the import</span>") +
1448
- kv("standing", (d.consolidated ? "consolidated" : "not yet consolidated") + " · " +
1449
- (d.promoted ? "promoted into identity" : "not promoted") + " · " +
1450
- (d.protected ? "<span style='color:var(--amber)'>PROTECTED — no revision path reaches it</span>" : "revisable")) +
1451
- kv("pressure", d.pressure === 0
1452
- ? "<span style='color:var(--dim)'>(none yet) — nothing has argued with it</span>"
1453
- : n3(d.pressure) + (d.bar === null ? "" : " against a bar of " + n3(d.bar))) +
1454
- (d.archived ? kv("archived", "<span style='color:var(--amber)'>" + esc(d.archived) + "</span>") : "") +
1455
- "</div>" +
1456
- section("Wired together with", d.edges.map((e) =>
1457
- "<div class='ref' onclick=\"openMemory('" + e.id + "')\"><span class='role'>" + n2(e.weight) + "</span>" +
1458
- said(e.text, e.confidential) + "</div>").join(""),
1459
- "(none yet) — it fires with nothing.") +
1460
- section("What it points at, resolved just now", d.points.map((p) =>
1461
- "<div class='ref' onclick=\"openMemory('" + p.id + "')\"><span class='role'>" + esc(p.role) + "</span>" +
1462
- esc(p.text) + "</div>").join(""), "(none yet) — it points at nothing.") +
1463
- section("Version history", d.versions.map((v) =>
1464
- "<div class='ref'><span class='role'>v" + v.seq + " · " + esc(v.reason) + " · day " + v.day + "</span>" +
1465
- esc(v.became) + "</div>").join(""), "(none yet) — it has never been revised.") +
1466
- section("Looks ahead to", d.prospective.map((p) =>
1467
- "<div class='ref'><span class='role'>" + esc(p.date) + " (" + esc(p.precision) + ")</span>" +
1468
- esc(p.state) + ", fired " + p.fires + "×</div>").join(""), "(none yet) — it holds no intention.") +
1469
- (d.removal.length === 0 ? "" : section("Removal record", d.removal.map((r) =>
1470
- "<div class='ref'><span class='role'>" + esc(r.stage) + "</span>by " + esc(r.actor) +
1471
- " — " + esc(r.reason || "no reason recorded") + "</div>").join(""), ""))
1472
- );
1473
- }
1474
- /** Most memories carry no title: the first sentence is what they are called. */
1475
- function headline(text) {
1476
- const first = String(text).split(/(?<=[.!?])\s/)[0] || String(text);
1477
- return first.length > 96 ? first.slice(0, 95).trimEnd() + "…" : first;
1478
- }
1479
- function section(title, body, emptyMsg) {
1480
- if (!body && !emptyMsg) return "";
1481
- return "<h4>" + esc(title) + "</h4>" +
1482
- (body || "<div style='color:var(--dim);font-size:11px'>" + esc(emptyMsg) + "</div>");
1483
- }
1484
- window.openMemory = openMemory;
1485
-
1486
- /** The id, on demand — it is how the owner addresses this memory anywhere else
1487
- * (`counterparts recall`, the MCP tools, a note to themselves). Failure is
1488
- * silent and local: a clipboard a browser refuses is not worth a console
1489
- * error. */
1490
- function copyId(btn) {
1491
- const id = btn.dataset.id || "";
1492
- const done = () => { btn.textContent = "copied"; setTimeout(() => { btn.textContent = "copy id"; }, 1400); };
1493
- try {
1494
- if (navigator.clipboard && navigator.clipboard.writeText) {
1495
- navigator.clipboard.writeText(id).then(done, () => { btn.textContent = "select it above"; });
1496
- return;
1497
- }
1498
- } catch (e) { /* fall through */ }
1499
- btn.textContent = id;
1500
- }
1501
- window.copyId = copyId;
1502
-
1503
- async function openEvent(seq) {
1504
- let d;
1505
- try { d = await api("/api/event?seq=" + seq); } catch (e) { return fail("That event", e); }
1506
- const e = d.event;
1507
- openModal(
1508
- "<h3>" + esc(e.name) + "</h3>" +
1509
- "<div class='sub'>lived day " + e.day + " · " + new Date(e.at).toISOString().replace("T", " ").slice(0, 19) +
1510
- " · sequence " + e.seq + (e.node ? " · " + esc(e.node) : "") + "</div>" +
1511
- "<div class='body tone-" + e.tone + "'>" + esc(e.text) + "</div>" +
1512
- (e.subject ? "<h4>subject</h4><div class='ref'>" + esc(e.subject) + "</div>" : "") +
1513
- "<h4>the record itself</h4>" +
1514
- "<div class='kv'>" + e.detail.map((p) =>
1515
- '<div class="k">' + esc(p.key) + '</div><div class="v">' + esc(p.value) + "</div>").join("") + "</div>" +
1516
- "<p style='color:var(--faint);font-size:10.5px;line-height:1.7'>Every value above is an id, a count, a byte figure, " +
1517
- "a score or a closed-vocabulary reason. No memory's words and no turn of yours is ever written into this log — " +
1518
- "which is why the names on this page had to be resolved from the store as it stands right now.</p>"
1519
- );
1520
- }
1521
- window.openEvent = openEvent;
1522
-
1523
- // ═══════════════════════════════════════════════════════════════════════════
1524
- // the pulse: particles ride only on events that are actually new
1525
- // ═══════════════════════════════════════════════════════════════════════════
1526
- let lastSeq = 0;
1527
- /** The cheap shape of the store, so a poll can notice a deposit that left no
1528
- * trace in the event log. Null until the first `/api/meta` answers. */
1529
- let fingerprint = null;
1530
- const particles = [];
1531
- const flashes = {};
1532
- let animating = false;
1533
- /** Curves the last frame drew, so a particle rides the edge it belongs to. */
1534
- let edgePaths = {};
1535
- /** How many fading samples make the comet's tail. */
1536
- const TRAIL = 11;
1537
-
1538
- function animate() {
1539
- if (particles.length === 0 && Object.values(flashes).every((v) => v < 0.02)) { animating = false; return; }
1540
- for (let i = particles.length - 1; i >= 0; i--) {
1541
- const p = particles[i];
1542
- p.t += 0.014;
1543
- if (p.t < 0) continue;
1544
- // The tail has to finish arriving after the head does.
1545
- if (p.t > 1 + TRAIL * 0.022) particles.splice(i, 1);
1546
- }
1547
- for (const k of Object.keys(flashes)) flashes[k] *= 0.96;
1548
- if (currentTab === "flow") drawFlow();
1549
- requestAnimationFrame(animate);
1550
- }
1551
- function ignite(events) {
1552
- for (const e of events) {
1553
- if (!e.node) continue;
1554
- flashes[e.node] = 1;
1555
- // Ride an edge that ENDS at this node when the diagram has one — a signal
1556
- // arriving is the thing being drawn. Otherwise ride one leaving it, and
1557
- // otherwise orbit the box. A caller that KNOWS the path names it in `via`,
1558
- // because "the first edge ending here" is not always the right one: the
1559
- // first edge into ENCODE is the dotted crash-sweep fallback, so a deposit
1560
- // through the authored door would otherwise be drawn arriving from a crash.
1561
- const edge = e.via
1562
- ? null
1563
- : (FLOW && FLOW.edges.find((x) => x.to === e.node)) ||
1564
- (FLOW && FLOW.edges.find((x) => x.from === e.node));
1565
- particles.push({
1566
- node: e.node,
1567
- key: e.via || (edge ? edge.from + ">" + edge.to : ""),
1568
- // A negative start staggers a signal that crosses several nodes, so three
1569
- // particles read as one thing moving rather than three things blinking.
1570
- t: -(e.delay || 0),
1571
- spin: Math.random() * 6.28,
1572
- col: e.tone === "amber" ? COL.amber : e.tone === "notable" ? COL.cyan : COL.teal,
1573
- });
1574
- }
1575
- if (!animating) { animating = true; requestAnimationFrame(animate); }
1576
- }
1577
-
1578
- async function poll() {
1579
- let d;
1580
- try { d = await api("/api/activity?limit=40&sinceSeq=" + lastSeq); } catch (e) { return; }
1581
- // THE SECOND QUESTION, AND THE ONE THAT WAS MISSING.
1582
- //
1583
- // "Has anything happened" was asked of the event log alone, and the event log
1584
- // is not the whole truth: a deposit that writes no durable event never moves
1585
- // `lastSeq`, so the refetch never fired and a page left open on the flow tab
1586
- // said `143 came through` forever while the server already answered 144.
1587
- // `/api/meta` carries a row count for exactly this — one cheap request beside
1588
- // the one we were already making.
1589
- //
1590
- // The example was `counterparts note`, and it is no longer one: since
1591
- // `gate.deposit` (2026-09-05) the authored door writes a row like every other
1592
- // door, so a note moves the sequence and lands in the branch below. This stays
1593
- // as the belt — a store seeded around the door, and any future writer that
1594
- // leaves no row — because a freshness check that is only correct while one
1595
- // particular writer happens to log is not a freshness check.
1596
- let meta = null;
1597
- try { meta = await api("/api/meta"); } catch (e) { /* the next tick retries */ }
1598
- const deposited = meta !== null && fingerprint !== null &&
1599
- (meta.rows !== fingerprint.rows || meta.day !== fingerprint.day);
1600
- if (meta !== null) fingerprint = { rows: meta.rows, day: meta.day };
1601
-
1602
- if (d.lastSeq > lastSeq) {
1603
- lastSeq = d.lastSeq;
1604
- // A new event means the store moved, so everything the diagram counts moved
1605
- // with it: left open, the flow page silently reported yesterday's numbers
1606
- // beside today's feed. Refresh the node state — and the lived day, which is
1607
- // the one number in the header that is allowed to change.
1608
- refreshCounters(meta);
1609
- const fresh = d.events.slice().reverse();
1610
- ignite(fresh);
1611
- for (const el of [$("ov-feed"), $("flow-feed")]) {
1612
- if (!el || el.querySelector(".empty")) continue;
1613
- for (const e of fresh) {
1614
- const row = document.createElement("div");
1615
- row.className = "ev " + e.tone + " flash";
1616
- row.dataset.seq = e.seq;
1617
- row.onclick = () => openEvent(e.seq);
1618
- row.innerHTML = '<span class="d">day ' + e.day + '</span><span class="t">' + esc(e.text) +
1619
- '<span class="k">' + esc(e.name) + (e.node ? " · " + esc(e.node) : "") + "</span></span>";
1620
- el.insertBefore(row, el.firstChild);
1621
- }
1622
- while (el.children.length > 60) el.removeChild(el.lastChild);
1623
- }
1624
- // The wall clock gets its OWN chip, and only when something happened. It
1625
- // used to overwrite the lived-day chip on every four-second tick whether or
1626
- // not anything had — so the product's own clock survived four seconds and
1627
- // was then replaced by a host timestamp that means nothing to the store.
1628
- const seen = $("seen");
1629
- seen.hidden = false;
1630
- seen.textContent = "last event " + new Date().toTimeString().slice(0, 8);
1631
- } else if (deposited) {
1632
- // A deposit with no event of its own. There is nothing to put in the feed —
1633
- // the feed IS the durable log, and inventing a row there would be a lie
1634
- // about what was recorded — but the counters moved and the diagram can say
1635
- // so, along the path a deposit actually takes: the authored door, the gate,
1636
- // the store. Named edges, because the first edge into ENCODE is the crash
1637
- // fallback and an authored deposit did not crash.
1638
- //
1639
- // Since `gate.deposit` this is no longer the branch a note takes — a note
1640
- // logs, so it takes the one above and its animation is driven by the row's
1641
- // own `node`. This is now the arm for a store that gained rows some other
1642
- // way, which is the only thing it should ever have claimed to be.
1643
- refreshCounters(meta);
1644
- ignite([
1645
- { node: "remember", via: "session>remember", tone: "calm", delay: 0 },
1646
- { node: "encode", via: "remember>encode", tone: "calm", delay: 0.34 },
1647
- { node: "store", via: "encode>store", tone: "calm", delay: 0.68 },
1648
- ]);
1649
- // A different word, because it IS a different thing: something was stored,
1650
- // and nothing was recorded about the storing.
1651
- const seen = $("seen");
1652
- seen.hidden = false;
1653
- seen.textContent = "last deposit " + new Date().toTimeString().slice(0, 8);
1654
- }
1655
- }
1656
-
1657
- /**
1658
- * What a change to the store changes, re-read. The poll has already asked for
1659
- * `/api/meta`, so it hands it over rather than making the request twice.
1660
- *
1661
- * THE FLOW PAGE WAS NOT THE ONLY PAGE COUNTING. The first fix for the stale
1662
- * `143 came through` refreshed the flow diagram and stopped there, so the
1663
- * OVERVIEW — the page the dashboard opens on, the one in the README's first
1664
- * image — kept its boot-time tiles: `memories held`, `lived days`, the band
1665
- * bars, the identity panel, all frozen at whatever they were when the tab was
1666
- * opened, while the flow tab beside it moved. Same bug, one page over. Both
1667
- * pages are re-read here, from the one signal that catches a deposit with no
1668
- * durable event of its own.
1669
- */
1670
- async function refreshCounters(meta) {
1671
- try {
1672
- const m = meta ?? (await api("/api/meta"));
1673
- $("clock").textContent = "day " + m.day;
1674
- fingerprint = { rows: m.rows, day: m.day };
1675
- } catch (e) { /* the next poll retries */ }
1676
- if (loaded.overview) {
1677
- try {
1678
- const fresh = await api("/api/overview");
1679
- // The feed belongs to the poll (see `paintOverview`), unless it is still
1680
- // the absence line — in which case there is nothing of the poll's to lose.
1681
- const feedEl = $("ov-feed");
1682
- paintOverview(fresh, !!(feedEl && feedEl.querySelector(".empty")));
1683
- } catch (e) { /* the next poll retries */ }
1684
- }
1685
- if (!loaded.flow) return;
1686
- try {
1687
- const fresh = await api("/api/flow?limit=24");
1688
- if (FLOW) {
1689
- FLOW = { ...FLOW, nodes: fresh.nodes, lastSeq: fresh.lastSeq };
1690
- if (currentTab === "flow") drawFlow();
1691
- }
1692
- } catch (e) { /* the next poll retries */ }
1693
- }
1694
-
1695
- // ═══════════════════════════════════════════════════════════════════════════
1696
- const RENDER = { overview: renderOverview, memories: renderMemories, mind: renderMind, flow: renderFlow, health: renderHealth };
1697
-
1698
- let resizeTimer = null;
1699
- addEventListener("resize", () => {
1700
- clearTimeout(resizeTimer);
1701
- resizeTimer = setTimeout(() => {
1702
- if (currentTab === "memories" && MEM) { drawConstellation(); drawHistogram(); }
1703
- if (currentTab === "flow") drawFlow();
1704
- }, 120);
1705
- });
1706
-
1707
- (async function boot() {
1708
- try {
1709
- const meta = await api("/api/meta");
1710
- // The NAME of the store, not its address. A temp path in the header is in
1711
- // every screenshot this dashboard produces, and it says nothing about the
1712
- // store — the full path is one hover away for the moment it matters.
1713
- const name = meta.dir.replace(/\/+$/, "").split("/").pop() || meta.dir;
1714
- $("dir").textContent = name;
1715
- $("dir").title = "reading " + meta.dir;
1716
- $("clock").textContent = "day " + meta.day;
1717
- fingerprint = { rows: meta.rows, day: meta.day };
1718
- } catch (e) { fail("The header", e); }
1719
- showTab(location.hash.slice(1) || "overview", false);
1720
- // Every tab is built once, up front: a screenshot of any of them should never
1721
- // be waiting on a fetch, and the flow diagram needs its data before it can be
1722
- // drawn at all.
1723
- await Promise.all(TABS.filter((t) => !loaded[t]).map((t) => { loaded[t] = true; return RENDER[t](); }));
1724
- if (currentTab === "memories") { drawConstellation(); drawHistogram(); }
1725
- if (currentTab === "flow") drawFlow();
1726
- setInterval(poll, 4000);
1727
- document.documentElement.dataset.loaded = "1";
1728
- })();
1729
- </script>
1730
67
  </body>
1731
68
  </html>