geneseed 4.31.0 → 5.0.0

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 (272) hide show
  1. package/CHANGELOG.md +107 -0
  2. package/DESIGN.md +2 -2
  3. package/README.md +6 -5
  4. package/SHIPPED.md +4 -3
  5. package/adapters/bob/README.md +6 -5
  6. package/adapters/claude-code/README.md +4 -3
  7. package/adapters/claude-code/skills/geneseed/SKILL.md +1 -1
  8. package/adapters/openclaude/README.md +4 -3
  9. package/adapters/opencode/GLOBAL-HARNESS-SPEC.md +3 -1
  10. package/adapters/opencode/HOW-OPENCODE-LOADS.md +2 -1
  11. package/adapters/opencode/README.md +18 -18
  12. package/adapters/opencode/plugins/geneseed-activity.js +57 -1
  13. package/adapters/opencode/plugins/geneseed-context.js +220 -18
  14. package/adapters/opencode/plugins/geneseed-guard.js +578 -74
  15. package/adapters/opencode/plugins/geneseed-learn.js +97 -23
  16. package/bin/geneseed-cli.mjs +17 -25
  17. package/bin/geneseed-hook.mjs +23 -8
  18. package/docs/DESIGN.md +175 -0
  19. package/docs/PRD.md +111 -0
  20. package/docs/README.md +3 -2
  21. package/docs/architecture.md +145 -0
  22. package/docs/concepts/agents.md +1 -1
  23. package/docs/concepts/collaboration.md +1 -1
  24. package/docs/concepts/enforcement-table.md +1 -1
  25. package/docs/concepts/exclusions.md +6 -6
  26. package/docs/concepts/footprint.md +1 -1
  27. package/docs/concepts/foreman-mode.md +2 -2
  28. package/docs/concepts/hook-gates.md +1 -1
  29. package/docs/concepts/hooks.md +27 -11
  30. package/docs/concepts/host-matrix.md +3 -3
  31. package/docs/concepts/hosts.md +1 -1
  32. package/docs/concepts/kits.md +3 -1
  33. package/docs/concepts/loop-bricks.md +1 -1
  34. package/docs/concepts/loop-notes.md +4 -2
  35. package/docs/concepts/loop-templates.md +7 -4
  36. package/docs/concepts/loops.md +3 -0
  37. package/docs/concepts/ownership.md +2 -2
  38. package/docs/concepts/rules.md +15 -2
  39. package/docs/concepts/shared-tier.md +73 -0
  40. package/docs/concepts/skills.md +2 -2
  41. package/docs/concepts/themes.md +1 -1
  42. package/docs/extending.md +13 -12
  43. package/docs/guides/install-claude-code.md +1 -1
  44. package/docs/guides/install-opencode.md +1 -1
  45. package/docs/guides/migrate.md +4 -2
  46. package/docs/guides/project-context.md +2 -2
  47. package/docs/guides/run-a-loop.md +1 -1
  48. package/docs/guides/set-up-ownership.md +1 -1
  49. package/docs/guides/setup-footprint.md +1 -1
  50. package/docs/guides/uninstall.md +2 -1
  51. package/docs/guides/upgrade-to-5.md +116 -0
  52. package/docs/guides/upgrade.md +21 -9
  53. package/docs/guides/wiki.md +3 -3
  54. package/docs/reference/env-context.md +5 -3
  55. package/docs/reference/environment.md +1 -1
  56. package/docs/reference/glossary.md +2 -0
  57. package/docs/reference/loop-actions.md +1 -1
  58. package/docs/reference/opencode-plugins.md +3 -3
  59. package/docs/reference/plugin-activity.md +1 -1
  60. package/docs/reference/plugin-context.md +5 -0
  61. package/docs/reference/plugin-guard.md +14 -6
  62. package/docs/reference/plugin-learn.md +13 -6
  63. package/docs/reference/troubleshoot-hooks.md +3 -3
  64. package/docs/reference/troubleshoot-update.md +14 -0
  65. package/docs/token-footprint.md +4 -3
  66. package/docs/understand/a-day.md +2 -2
  67. package/docs/understand/design-choices-install.md +2 -1
  68. package/docs/understand/enforced-vs-asked.md +4 -3
  69. package/docs/understand/machine-bob.md +3 -1
  70. package/docs/understand/machine-claude.md +7 -5
  71. package/docs/understand/machine-opencode.md +7 -5
  72. package/docs/understand/on-your-machine.md +4 -0
  73. package/docs/understand/take-it-out.md +1 -1
  74. package/docs/web-ui.md +141 -73
  75. package/harness.config.json +1 -1
  76. package/js/README.md +10 -6
  77. package/js/build/args.mjs +10 -8
  78. package/js/build/bundle.mjs +11 -13
  79. package/js/build/driver.mjs +66 -65
  80. package/js/build/emit-claude.mjs +22 -16
  81. package/js/build/emit-common.mjs +4 -5
  82. package/js/build/emit-opencode.mjs +22 -22
  83. package/js/build/fold.mjs +515 -0
  84. package/js/build/generate.mjs +41 -52
  85. package/js/build/render.mjs +115 -29
  86. package/js/build/source.mjs +4 -1
  87. package/js/build/stubs.mjs +70 -9
  88. package/js/build/version.mjs +10 -10
  89. package/js/cli-table.json +23 -83
  90. package/js/hosts/activity.mjs +2 -2
  91. package/js/hosts/geneseed-dir.mjs +1 -1
  92. package/js/hosts/hooks-context.mjs +410 -99
  93. package/js/hosts/hooks-done.mjs +97 -31
  94. package/js/hosts/hooks-learn.mjs +38 -7
  95. package/js/hosts/hooks-prims.mjs +69 -2
  96. package/js/hosts/hooks.mjs +300 -64
  97. package/js/hosts/hosts.mjs +150 -51
  98. package/js/hosts/installs.mjs +55 -167
  99. package/js/hosts/link.mjs +3 -5
  100. package/js/hosts/mcp.mjs +1 -1
  101. package/js/hosts/memory-files.mjs +219 -17
  102. package/js/hosts/ownership-gate.mjs +1 -1
  103. package/js/hosts/settings.mjs +18 -13
  104. package/js/hosts/shim.mjs +4 -33
  105. package/js/hosts/store-watch.mjs +189 -0
  106. package/js/inspect/checks-authoring.mjs +3 -3
  107. package/js/inspect/checks-build.mjs +45 -18
  108. package/js/inspect/checks-counts.mjs +4 -4
  109. package/js/inspect/checks-repo.mjs +13 -14
  110. package/js/inspect/cost.mjs +24 -2
  111. package/js/inspect/diff.mjs +123 -123
  112. package/js/inspect/doctor.mjs +22 -27
  113. package/js/inspect/excludes.mjs +181 -62
  114. package/js/inspect/inventory.mjs +22 -27
  115. package/js/inspect/registry.mjs +106 -30
  116. package/js/inspect/scan.mjs +5 -5
  117. package/js/inspect/status.mjs +141 -119
  118. package/js/inspect/validate.mjs +22 -24
  119. package/js/lib/fs.mjs +47 -50
  120. package/js/lib/json.mjs +10 -17
  121. package/js/lib/machine-dir.mjs +73 -0
  122. package/js/lib/paths.mjs +22 -33
  123. package/js/lib/proc.mjs +1 -1
  124. package/js/lib/prompt.mjs +19 -27
  125. package/js/lib/text.mjs +8 -12
  126. package/js/lib/udiff.mjs +11 -15
  127. package/js/loop/catalog.mjs +2 -3
  128. package/js/loop/state.mjs +15 -5
  129. package/js/maintain/memory.mjs +17 -17
  130. package/js/maintain/migrate.mjs +79 -89
  131. package/js/maintain/setup.mjs +43 -32
  132. package/js/maintain/uninstall.mjs +43 -61
  133. package/js/maintain/update.mjs +200 -93
  134. package/js/ui/anim.mjs +21 -35
  135. package/js/ui/cli.mjs +36 -58
  136. package/js/ui/menu.mjs +22 -45
  137. package/js/ui/tui.mjs +27 -67
  138. package/js/web/actions.mjs +38 -38
  139. package/js/web/api.mjs +132 -76
  140. package/js/web/catalog.mjs +175 -46
  141. package/js/web/docs.mjs +33 -12
  142. package/js/web/doctor-worker.mjs +14 -0
  143. package/js/web/handler.mjs +14 -5
  144. package/js/web/routes.mjs +17 -19
  145. package/js/web/state.mjs +78 -19
  146. package/js/web/update-check.mjs +25 -10
  147. package/js/web/user-files.mjs +50 -105
  148. package/package.json +7 -4
  149. package/registry.json +48 -55
  150. package/src/AGENT.md.tmpl +13 -14
  151. package/src/agents/_self-improvement.md +1 -1
  152. package/src/agents/_template.md +4 -1
  153. package/src/agents/advocate.md +1 -1
  154. package/src/agents/architect.md +1 -1
  155. package/src/agents/developer.md +6 -3
  156. package/src/agents/devops-engineer.md +1 -1
  157. package/src/agents/docker-expert.md +1 -1
  158. package/src/agents/docs.md +1 -1
  159. package/src/agents/empiricist.md +1 -1
  160. package/src/agents/explorer.md +1 -1
  161. package/src/agents/framer.md +1 -1
  162. package/src/agents/historian.md +1 -1
  163. package/src/agents/kubernetes-specialist.md +1 -1
  164. package/src/agents/memory-curator.md +2 -2
  165. package/src/agents/operator.md +1 -1
  166. package/src/agents/performance.md +1 -1
  167. package/src/agents/pragmatist.md +1 -1
  168. package/src/agents/react-engineer.md +1 -1
  169. package/src/agents/react-reviewer.md +1 -1
  170. package/src/agents/researcher.md +1 -1
  171. package/src/agents/reviewer.md +1 -1
  172. package/src/agents/security.md +1 -1
  173. package/src/agents/skeptic.md +1 -1
  174. package/src/agents/spring-boot-engineer.md +1 -1
  175. package/src/agents/spring-reviewer.md +1 -1
  176. package/src/agents/spring-security.md +1 -1
  177. package/src/agents/steward.md +1 -1
  178. package/src/agents/tester.md +5 -2
  179. package/src/agents/user-advocate.md +1 -1
  180. package/src/agents/visionary.md +1 -1
  181. package/src/bricks/apply.md +3 -0
  182. package/src/bricks/test.md +6 -4
  183. package/src/loops/bugfix.json +11 -5
  184. package/src/loops/feature.json +7 -4
  185. package/src/memory/README.md +1 -1
  186. package/src/skills/_self-improvement.md +2 -2
  187. package/src/skills/daydream/SKILL.md +2 -2
  188. package/src/skills/daydream/instructions.md +1 -1
  189. package/src/skills/geneseed.md +1 -1
  190. package/src/skills/learn-mode.md +1 -2
  191. package/src/skills/loop.md +1 -0
  192. package/src/skills/profile.md +2 -2
  193. package/src/skills/rule/approve.md +69 -0
  194. package/src/skills/rule/consolidate.md +3 -3
  195. package/src/skills/rule.md +13 -5
  196. package/src/skills/ship.md +9 -1
  197. package/src/skills/skill-forge.md +1 -1
  198. package/src/skills/teach.md +29 -12
  199. package/src/skills/wiki.md +1 -1
  200. package/themes/_TEMPLATE.json +1 -2
  201. package/themes/biker.json +1 -2
  202. package/themes/commentator.json +1 -2
  203. package/themes/cyberpunk.json +1 -2
  204. package/themes/gamer.json +1 -2
  205. package/themes/imperial.json +1 -2
  206. package/themes/joker.json +1 -2
  207. package/themes/marvin.json +1 -2
  208. package/themes/mean.json +1 -2
  209. package/themes/military.json +1 -2
  210. package/themes/neutral.json +1 -2
  211. package/themes/pirate.json +1 -2
  212. package/themes/sports.json +1 -2
  213. package/themes/verstappen.json +1 -2
  214. package/themes/wizard.json +1 -2
  215. package/web/dist/assets/Activity-D8G4eClY.js +1 -0
  216. package/web/dist/assets/ActivityDetail-BtOBYk3M.js +1 -0
  217. package/web/dist/assets/AgentGlyph-k6o3gCM1.js +1 -0
  218. package/web/dist/assets/Bonsai-B_y20b3i.js +1 -0
  219. package/web/dist/assets/{CopyButton-IXnXzH4Y.js → CopyButton-CHQte7Ap.js} +1 -1
  220. package/web/dist/assets/Dashboard-B8uXeJZ_.js +2 -0
  221. package/web/dist/assets/{DataTable-BWbUx4bY.js → DataTable-b9zTShqJ.js} +1 -1
  222. package/web/dist/assets/Docs-Dgv_MWfT.js +5 -0
  223. package/web/dist/assets/{EmptyState-1sPNleqv.js → EmptyState-CY5Pm2xy.js} +1 -1
  224. package/web/dist/assets/FilterInput-qGKNSlxv.js +1 -0
  225. package/web/dist/assets/GreenhouseView-CSzTMSl_.js +1 -0
  226. package/web/dist/assets/Installs-BDk9lqBI.js +3 -0
  227. package/web/dist/assets/JournalView-CvRk1-m5.js +1 -0
  228. package/web/dist/assets/Kits-CoITzxWM.js +1 -0
  229. package/web/dist/assets/Laws-Ctf5r9rE.js +3 -0
  230. package/web/dist/assets/Library-DNwHYVXt.js +3 -0
  231. package/web/dist/assets/{Loops-C5u7fQOR.js → Loops-S85PMQ8m.js} +2 -2
  232. package/web/dist/assets/Markdown-0ORz7tAc.js +69 -0
  233. package/web/dist/assets/OperatorHudView-DuGz_sTk.js +1 -0
  234. package/web/dist/assets/Personal-afJNwvRS.js +2 -0
  235. package/web/dist/assets/RailCats-AW92uhsX.js +1 -0
  236. package/web/dist/assets/Settings-CGDFz-6j.js +1 -0
  237. package/web/dist/assets/Tabs-1qLrnqmn.js +1 -0
  238. package/web/dist/assets/api-C46vAuqp.js +1 -0
  239. package/web/dist/assets/controls-D4wmg_pl.js +1 -0
  240. package/web/dist/assets/index-COTd4TRZ.js +3 -0
  241. package/web/dist/assets/index-CtorA7uK.css +1 -0
  242. package/web/dist/assets/motion-RlUl1osO.js +1 -0
  243. package/web/dist/assets/react-C1iE8mnY.js +9 -0
  244. package/web/dist/assets/rolldown-runtime-XKyaHtl9.js +1 -0
  245. package/web/dist/assets/{sections-ChwaobfW.js → sections-CtFz7HFH.js} +1 -1
  246. package/web/dist/assets/{usePoll-bDFN-Hr6.js → usePoll-o8ul-Sog.js} +1 -1
  247. package/web/dist/index.html +7 -7
  248. package/src/skills/quiz.md +0 -44
  249. package/web/dist/assets/Activity-B7cFtS00.js +0 -1
  250. package/web/dist/assets/ActivityDetail-C-GbMmuW.js +0 -1
  251. package/web/dist/assets/Bonsai-_YyexVC5.js +0 -1
  252. package/web/dist/assets/Dashboard-sCfEjowQ.js +0 -2
  253. package/web/dist/assets/Docs-w3Y7M5Ts.js +0 -5
  254. package/web/dist/assets/FilterInput-CZREvrjX.js +0 -1
  255. package/web/dist/assets/GreenhouseView-BWWbMKmg.js +0 -1
  256. package/web/dist/assets/Installs-CnkdJ-VA.js +0 -3
  257. package/web/dist/assets/JournalView-C7bPD3fZ.js +0 -1
  258. package/web/dist/assets/KitApply-CQQbnThf.js +0 -1
  259. package/web/dist/assets/Kits-aj07N7mT.js +0 -1
  260. package/web/dist/assets/Laws-DZ38nl_H.js +0 -3
  261. package/web/dist/assets/Library-QCGXPV5h.js +0 -2
  262. package/web/dist/assets/Markdown-DpmmtW2Y.js +0 -65
  263. package/web/dist/assets/OperatorHudView-Blu1lqiZ.js +0 -1
  264. package/web/dist/assets/Personal-ox_MktWO.js +0 -2
  265. package/web/dist/assets/RailCats-BuJD4Jou.js +0 -1
  266. package/web/dist/assets/Tabs-CIPyMAX-.js +0 -1
  267. package/web/dist/assets/api-BxjLd7Qd.js +0 -1
  268. package/web/dist/assets/index-0GCxkY7m.css +0 -1
  269. package/web/dist/assets/index-CzDi9JpF.js +0 -3
  270. package/web/dist/assets/motion-CXaUMNkg.js +0 -1
  271. package/web/dist/assets/react-DlYQp10C.js +0 -9
  272. package/web/dist/assets/rolldown-runtime-hePW80VL.js +0 -1
@@ -37,7 +37,7 @@ import { emitGlobalInto } from '../build/driver.mjs';
37
37
  import {
38
38
  ROOT, discoverNames, knownRuleIds, loadKits, PACK_ORDER,
39
39
  } from '../build/source.mjs';
40
- import { diffCollect, drifted, withStdoutSwallowed } from '../inspect/diff.mjs';
40
+ import { diffCollect, drifted, renderMemo, withStdoutSwallowed } from '../inspect/diff.mjs';
41
41
  import { SESSION_FILES } from '../hosts/hooks-context.mjs';
42
42
  import { excludeAdd, excludeRemove } from '../inspect/excludes.mjs';
43
43
  import { installProfile, setupBuildArgs } from '../build/generate.mjs';
@@ -48,9 +48,9 @@ import {
48
48
  opencodeConfigDir, resolvePath,
49
49
  } from '../hosts/hosts.mjs';
50
50
  import {
51
- EMIT_HOST_SCOPE, doctrinesForBuild, excludedRulesOfDir, excludedSkillsOfDir, kitsOfDir,
51
+ EMIT_HOST_SCOPE, doctrinesForBuild, excludedRulesOfDir, excludedSkillsOfDir, kitsOfDir, sharedTierOfDir, renderedTier,
52
52
  footprintOfDir, gatesOfDir,
53
- installState, installTargets, legacyProcessCarrierOfDir, modeOfDir, postureOfDir, themeOfDir,
53
+ installState, installTargets, modeOfDir, postureOfDir, themeOfDir,
54
54
  trustOfDir,
55
55
  } from '../hosts/installs.mjs';
56
56
  import {
@@ -65,6 +65,7 @@ import { memoryDelete } from '../maintain/memory.mjs';
65
65
  import { installDeactivate, installReactivate, installUninstall } from '../maintain/uninstall.mjs';
66
66
  import { emitChoices, themeChoices, viewCfg } from './api.mjs';
67
67
  import { actionCommands } from './jobs.mjs';
68
+ import { emitOf } from '../inspect/status.mjs';
68
69
  import { webState } from './state.mjs';
69
70
  import { NotFound, deployed, memoryDir } from './catalog.mjs';
70
71
 
@@ -136,7 +137,7 @@ function bodyExcludeRules(body) {
136
137
  }
137
138
 
138
139
  /**
139
- * A request body's `kits` — REPLACES the install's kits (the Kits tab sends the whole set it
140
+ * A request body's `kits` — REPLACES the install's kits (the Kits page sends the whole set it
140
141
  * wants): `[]`/`'none'` give `[]`, an omitted key gives `null` (keep the install's own), and an
141
142
  * unknown name gives `null` too, which `apiInstallCmd` refuses for a body that HAS the key.
142
143
  */
@@ -145,10 +146,19 @@ function bodyKits(body) {
145
146
  }
146
147
 
147
148
  /**
148
- * The gate switches across the trust boundary (`deletionGate`, `secretsGate`, `doneGate`), each
149
- * on its own: only a real JSON boolean counts. Anything else — a string `"false"`, a number,
150
- * absence — falls back to the install's own answer for THAT gate, so a malformed or partial body
151
- * can never disarm (or re-arm) a gate it did not name.
149
+ * A request body's `sharedTier` — the project install's switch for reading the machine tier. Only
150
+ * a real JSON boolean counts, as a gate's does: anything else keeps the install's own answer.
151
+ */
152
+ function bodySharedTier(body, root, host) {
153
+ const said = bget(body, 'sharedTier');
154
+ return typeof said === 'boolean' ? said : sharedTierOfDir(root, host);
155
+ }
156
+
157
+ /**
158
+ * The gate switches across the trust boundary (`deletionGate`, `secretsGate`, `doneGate`,
159
+ * `ownershipGate`), each on its own: only a real JSON boolean counts. Anything else — a string
160
+ * `"false"`, a number, absence — falls back to the install's own answer for THAT gate, so a
161
+ * malformed or partial body can never disarm (or re-arm) a gate it did not name.
152
162
  */
153
163
  function bodyGates(body, root, host) {
154
164
  const own = gatesOfDir(root, host);
@@ -221,8 +231,10 @@ export function targetView(base, [host, scope, root]) {
221
231
  if (v === undefined) {
222
232
  const target = viewCfg(host, scope, root);
223
233
  v = webState(null, target);
224
- v.selectView(target, root);
234
+ v.selectView(target, root, emitOf(host, scope));
225
235
  v.pinned = true;
236
+ // The daemon's one memo: a render is keyed on what it read, not on who asked for it.
237
+ v.renderMemo = (base.renderMemo ??= renderMemo());
226
238
  v.refresh = base.refresh;
227
239
  v.daemonStale = () => base.daemonStale?.();
228
240
  v.jobBusy = () => base.jobBusy?.();
@@ -234,7 +246,7 @@ export function targetView(base, [host, scope, root]) {
234
246
  // ---- OS-native folder picker ---------------------------------------------------------------
235
247
 
236
248
  /**
237
- * ms before an open dialog is abandoned. The Python original's 300 s, kept as a named
249
+ * ms before an open dialog is abandoned. 300 s, kept as a named
238
250
  * constant rather than a literal in the spawn call. `GENESEED_PICK_TIMEOUT_MS` is a TEST HOOK
239
251
  * ONLY — it overrides the constant so the timeout path can be proven in seconds instead of
240
252
  * five minutes (nobody is at the dialog to cancel it in an automated run); the 300 s default
@@ -256,8 +268,7 @@ const PICK_SCRIPT_WIN = 'Add-Type -AssemblyName System.Windows.Forms; '
256
268
  + 'if ($d.ShowDialog() -eq [System.Windows.Forms.DialogResult]::OK) '
257
269
  + '{ Write-Output $d.SelectedPath }';
258
270
 
259
- // Ported VERBATIM from the deleted Python (`git show 8860c72:rituals/_web_actions.py`,
260
- // `api_pick_folder`) — same prompt text, same AppleScript shape. `choose folder` is a
271
+ // The prompt text and the AppleScript shape are fixed. `choose folder` is a
261
272
  // StandardAdditions command that runs in-process inside `osascript`, so it needs no
262
273
  // automation-consent prompt the way scripting another app would.
263
274
  const PICK_SCRIPT_MAC = 'set f to POSIX path of (choose folder with prompt '
@@ -560,7 +571,8 @@ export function globalEmitHostFor(emit) {
560
571
  * user's after the first build. Derived from `SESSION_FILES`, the one list of them.
561
572
  */
562
573
  const SEED_FILES = new Set(SESSION_FILES.filter((r) => !r.includes('/')));
563
- const SEED_DIRS = new Set(SESSION_FILES.filter((r) => r.includes('/')).map((r) => r.split('/')[0]));
574
+ // `anamnesis` is the memory store's older name: no longer a session file, still the user's.
575
+ const SEED_DIRS = new Set(['anamnesis', ...SESSION_FILES.filter((r) => r.includes('/')).map((r) => r.split('/')[0])]);
564
576
  const isSeedOnce = (rel) => SEED_FILES.has(rel) || SEED_DIRS.has(rel.split('/')[0]);
565
577
 
566
578
  /**
@@ -626,12 +638,15 @@ export function apiRestore(state, files) {
626
638
  // behind it — prompt and boundary disagreeing by a WRITE, the write-side twin of the
627
639
  // read-side hole `diffCollect` had (and the reason the panel offered the file at all).
628
640
  doctrines: doctrinesForBuild(target),
641
+ // Its own tier root, or a restored file names a tier this install does not read.
642
+ sharedRoot: renderedTier(target, globalEmitHostFor(state.emit)).root,
629
643
  // The excluded rules for the same boundary reason: without them a restored AGENT.md
630
644
  // re-states a rule whose hook gate the install deliberately left unwired.
631
645
  excludeRules: excludedRulesOfDir(target),
632
646
  excludeSkills: excludedSkillsOfDir(target),
633
647
  // The kits: a restored AGENT.md keeps its Kits block and `Active kits:` line.
634
648
  kits: kitsOfDir(target),
649
+ sharedTier: sharedTierOfDir(target),
635
650
  // The gate switches: a restored AGENT.md must keep the install's `<gate>: off` lines.
636
651
  ...gatesOfDir(target),
637
652
  }));
@@ -709,20 +724,11 @@ export function apiInstallCmd(state, body) {
709
724
  if (installState(root, host, scope) === 'disabled') {
710
725
  return { error: 'install is disabled — reactivate it before (re)building' };
711
726
  }
712
- // A LEGACY CARRIER IS REFUSED, NEVER REBUILT — same guard as `rebuild-all`/`migrate` (see
713
- // `legacyProcessCarrierOfDir`'s docblock): `doctrinesForBuild`/`excludedRulesOfDir` below
714
- // read a pre-comms carrier exactly as written, and this endpoint's `{cmd}` is EXECUTED by
715
- // `startJob` (`js/web/handler.mjs`'s `install` action) — building that argv here would write
716
- // the same permanent loss a console click away.
717
- if (legacyProcessCarrierOfDir(root, host)) {
718
- return { error: `${host}:${scope} (${root}) predates the comms pack (its carrier names `
719
- + "'process 8') — run `geneseed setup` for it before rebuilding from the console" };
720
- }
721
727
  const emit = EMIT_FOR.get(`${host} ${scope}`);
722
728
  if (emit === undefined) return { error: `no install mode for ${host}:${scope}` };
723
729
  // Every read-back below is narrowed to `host`'s OWN carrier (host-compat B1) — see the
724
730
  // comment at `installProfile` in `js/build/generate.mjs`.
725
- // The theme default is THIS install's own, not the viewed one's: the Kits tab acts on any row.
731
+ // The theme default is THIS install's own, not the viewed one's: the Kits page acts on any row.
726
732
  // An ABSENT row has no footprint of its own (`footprintOfDir` answers its no-marker `full`),
727
733
  // so a new install takes the CLI's default, lean — see `apiDeployCmd` below.
728
734
  const { theme, footprint: fp, posture: pos, mode, trust } = bodyAxes(body, {
@@ -755,10 +761,15 @@ export function apiInstallCmd(state, body) {
755
761
  + [...loadKits().keys()].join(', ') };
756
762
  }
757
763
  } catch (e) { return { error: String(e?.message ?? e) }; }
764
+ // D11: the shared tier is a project install's option; a global install owns it.
765
+ const sharedTier = scope === 'global' ? false : bodySharedTier(body, root, host);
766
+ if (scope === 'global' && bget(body, 'sharedTier') === true) {
767
+ return { error: 'the shared tier is a project option — a global install already owns it' };
768
+ }
758
769
  const out = scope === 'global' ? null : String(root);
759
770
  const argv = setupBuildArgs(theme || 'neutral', emit, out, out, fp, pos, mode, doctrines,
760
771
  PACK_ORDER, excludeRules, trust, excludedSkillsOfDir(root, host), gates,
761
- kits ?? kitsOfDir(root, host));
772
+ kits ?? kitsOfDir(root, host), sharedTier);
762
773
  return { cmd: [process.execPath, path.join(ROOT, 'bin', 'build-driver.mjs'), ...argv] };
763
774
  }
764
775
 
@@ -772,7 +783,7 @@ export function apiInstallCmd(state, body) {
772
783
  * built from the REGISTRY's host/scope/root, never from body strings, and it is what `rebuildAll`
773
784
  * replays (`installProfile`), so a console rebuild of one row equals the CLI's of all of them.
774
785
  *
775
- * ALL OR NOTHING: one unknown, inactive or legacy entry (or a malformed body) is `{ error }` and no
786
+ * ALL OR NOTHING: one unknown or inactive entry (or a malformed body) is `{ error }` and no
776
787
  * job starts. `detectedInstall`'s `NotFound` would answer 404; a refusal here means the world
777
788
  * changed under the client, so the dispatcher answers 409, as for `install`. The shape is checked
778
789
  * before the registry is read, so a bad body never costs a detect.
@@ -791,11 +802,6 @@ export function rebuildCmds(body) {
791
802
  const hit = active.findLast(([host, , root]) => JSON.stringify([host, String(root)]) === key);
792
803
  if (hit === undefined) return { error: `not an active install: ${key}` };
793
804
  const [host, scope, root] = hit;
794
- // Asked BEFORE `installProfile`, as `rebuildAll` does: a legacy carrier must never be rebuilt.
795
- if (legacyProcessCarrierOfDir(root, host)) {
796
- return { error: `${host}:${scope} (${root}) predates the comms pack (its carrier names `
797
- + "'process 8') — run `geneseed setup` for it before rebuilding from the console" };
798
- }
799
805
  steps.push(...actionCommands('build', { buildArgv: installProfile(host, scope, root).argv }));
800
806
  }
801
807
  return { cmds: steps };
@@ -877,13 +883,6 @@ export function apiDeployCmd(state, body) {
877
883
  if (cfgdirs.has(root)) {
878
884
  return { error: "that's a host global config dir — use its existing row to build a global install" };
879
885
  }
880
- // Same guard as `apiInstallCmd` above: a landing folder that already holds a pre-comms
881
- // install must not be rebuilt through `doctrinesForBuild`/`excludedRulesOfDir` below. A
882
- // fresh, never-built folder has no carrier at all, so this is a no-op for the common case.
883
- if (legacyProcessCarrierOfDir(root, host)) {
884
- return { error: `${root} predates the comms pack (its carrier names 'process 8') — `
885
- + 'run `geneseed setup` for it before deploying over it' };
886
- }
887
886
  // A fresh deploy is LEAN, at the default register, mode and trust: the same default as the
888
887
  // CLI's `--footprint`, which the user chose (2026-10-24) over the console's old `full` — a
889
888
  // console install and a CLI install of the same folder must not differ in always-on text for
@@ -902,6 +901,7 @@ export function apiDeployCmd(state, body) {
902
901
  const gates = bodyGates(body, root, host);
903
902
  // project-scope emit name == host name (opencode / claude / bob / openclaude)
904
903
  const argv = setupBuildArgs(theme || 'neutral', host, root, root, fp, pos, mode, doctrines,
905
- PACK_ORDER, excludeRules, trust, excludedSkillsOfDir(root, host), gates, kitsOfDir(root, host));
904
+ PACK_ORDER, excludeRules, trust, excludedSkillsOfDir(root, host), gates, kitsOfDir(root, host),
905
+ bodySharedTier(body, root, host));
906
906
  return { cmd: [process.execPath, path.join(ROOT, 'bin', 'build-driver.mjs'), ...argv] };
907
907
  }
package/js/web/api.mjs CHANGED
@@ -8,7 +8,7 @@
8
8
  * bind paths to these functions are `routes.mjs`. This file imports none of its route siblings,
9
9
  * which is what keeps the old `api ↔ actions` and `api ↔ activity` cycles from coming back.
10
10
  */
11
- import { existsSync, readdirSync, statSync } from 'node:fs';
11
+ import { existsSync, mkdirSync, readdirSync, statSync } from 'node:fs';
12
12
  import path from 'node:path';
13
13
 
14
14
  import { CONFIG, CREDIT_RE, ROOT, SRC, THEMES, discoverNames, loadKits, makeCfg, upstreamOf } from '../build/source.mjs';
@@ -18,11 +18,13 @@ import { alwaysOnCost } from '../inspect/cost.mjs';
18
18
  import { installProfile } from '../build/generate.mjs';
19
19
  import { diffCollect, renderMemo } from '../inspect/diff.mjs';
20
20
  import { excludesSnapshot } from '../inspect/excludes.mjs';
21
- import { VERSION_MARKER } from '../hosts/hosts.mjs';
21
+ import { sessionStartSize } from '../hosts/hooks-context.mjs';
22
+ import { CLAUDE_STYLE, VERSION_MARKER } from '../hosts/hosts.mjs';
23
+ import { factCount } from '../hosts/memory-files.mjs';
22
24
  import { autostartPaths } from '../hosts/shim.mjs';
23
25
  import {
24
- footprintOfDir, gatesOfDir, installState, installTargets, legacyProcessCarrierOfDir, modeOfDir,
25
- trustOfDir,
26
+ footprintOfDir, gatesOfDir, installState, installTargets, modeOfDir,
27
+ trustOfDir, sharedTierOfDir,
26
28
  postureOfDir, readJsonMaybe, readMaybe, themeOfDir,
27
29
  } from '../hosts/installs.mjs';
28
30
  import { PRESETS } from '../loop/score.mjs';
@@ -30,10 +32,11 @@ import { loadCatalog, catalogProblems } from '../loop/catalog.mjs';
30
32
  import { activeLoops } from '../loop/registry.mjs';
31
33
  import { EMIT_OPTIONS, themeOptions } from '../maintain/setup.mjs';
32
34
  import { accentFor, keptKitFiles, statusData } from '../inspect/status.mjs';
33
- import { isFile } from '../lib/fs.mjs';
35
+ import { isFile, writeTextAtomic } from '../lib/fs.mjs';
36
+ import { sharedPaths } from '../lib/machine-dir.mjs';
34
37
  import { comparePaths } from '../lib/paths.mjs';
35
38
  import {
36
- configItems, deployed, dget, memoryItems, notebookItems, wikiItems,
39
+ configItems, deployed, dget, fleetCounts, memoryDir, memoryItems, notebookItems, orSkip, tierOf, wikiItems,
37
40
  } from './catalog.mjs';
38
41
  import { defaultView, samePath, stampMinute, viewCfg } from './state.mjs';
39
42
  import { MANUAL_UPDATE, gitBehind, installKind, updateStatus } from './update-check.mjs';
@@ -89,15 +92,21 @@ const DOCTOR_COOLDOWN_MS = 3_000;
89
92
  * A fresh ask within `DOCTOR_COOLDOWN_MS` of the last one THIS PATH ran reuses that run, so a
90
93
  * page looping on `?fresh=1` cannot pin the event loop. `_doctorFreshAt` is written here only: a
91
94
  * verdict planted any other way still re-runs. No single-flight promise — `runDoctor` is
92
- * synchronous, so two fresh runs cannot overlap (revisit if it ever goes async).
95
+ * synchronous, so two fresh runs cannot overlap; only the warm-up is not (`warmDoctor`).
96
+ *
97
+ * This page needs the groups, so during the warm-up it answers with a promise of the verdict
98
+ * rather than a pending one: the request waits, the event loop does not.
93
99
  */
94
100
  export function apiDoctor(state, fresh = false) {
95
101
  if (fresh && Date.now() - (state._doctorFreshAt ?? 0) >= DOCTOR_COOLDOWN_MS) {
96
102
  state.runDoctor();
97
103
  state._doctorFreshAt = Date.now();
98
104
  }
99
- const { ok, problems, checked_at } = state.doctor;
100
- return { ...state._doctorRun, ok, problems, checked_at };
105
+ const answer = () => {
106
+ const { ok, problems, checked_at } = state.doctor;
107
+ return { ...state._doctorRun, ok, problems, checked_at };
108
+ };
109
+ return state._doctorJob === null ? answer() : state._doctorJob.then(answer);
101
110
  }
102
111
 
103
112
  /**
@@ -109,7 +118,7 @@ export function apiDoctor(state, fresh = false) {
109
118
  */
110
119
  export function apiDiff(state) {
111
120
  const { target, theme, files } = diffCollect({
112
- target: state.target, theme: state.theme, emit: state.emit });
121
+ target: state.target, theme: state.theme, emit: state.emit, memo: memoOf(state) });
113
122
  return { deployed: deployed(state), diffable: files !== null, target, theme,
114
123
  files: files || [] };
115
124
  }
@@ -153,19 +162,6 @@ const driftCounts = (files) => ({
153
162
  stale: files.filter((f) => f.status === 'stale').length,
154
163
  });
155
164
 
156
- /**
157
- * How many memory facts an install's data dir holds: the `.md` files of `<dir>/memory` (where
158
- * `memoryItems` reads them), minus its index and README (the console's furniture), any case.
159
- * No folder is no facts (0); a folder that cannot be listed is null, so a row says "not read"
160
- * rather than "no facts".
161
- */
162
- export function memoryFactCount(dir) {
163
- try {
164
- return readdirSync(path.join(dir, 'memory'))
165
- .filter((f) => /\.md$/i.test(f) && !/^(memory|readme)\.md$/i.test(f)).length;
166
- } catch (e) { return e?.code === 'ENOENT' ? 0 : null; }
167
- }
168
-
169
165
  /**
170
166
  * The fields every install row opens with, in this order. Theme is narrowed to this row's own
171
167
  * host (host-compat B1): a shared repo otherwise answers every row with whichever host's
@@ -175,8 +171,39 @@ const installRowBase = (host, scope, root, state) => ({
175
171
  id: `${host}:${scope}:${root}`, host, scope, path: root, state,
176
172
  theme: themeOfDir(root, host),
177
173
  footprint: footprintOfDir(root),
174
+ // Reads the machine's shared tier: its rules, profile and memory are the same on every row that
175
+ // says so. The one field the console asks; `sharedTier` is only a project install's switch.
176
+ shared: tierOf({ target: viewCfg(host, scope, root) }) !== null,
178
177
  });
179
178
 
179
+ /** Move the daemon's own state to the default install `def`. A pinned view keeps the one it named. */
180
+ function followDefault(state, def) {
181
+ if (def && state?.selectView && !state.pinned && !samePath(def[0], state.target)) state.selectView(...def);
182
+ }
183
+
184
+ /**
185
+ * `POST /api/default-install`: `{host, path}` makes that install the default. Anything else is
186
+ * refused (the 409 arm) and the stored pick stays: there is no clearing body, because
187
+ * `readJsonBody` turns a malformed request into `{}`, and that must not erase a choice. The
188
+ * pair is the VALUE here, so this route is no `VIEW_POSTS` row. It stores the detected root, not
189
+ * the request's spelling of it. The daemon state moves here and not by `refresh`, which would
190
+ * drop every install's cached doctor for a pick that changes none of them.
191
+ */
192
+ export function apiDefaultInstallSet(state, body) {
193
+ const { host, path: root } = body;
194
+ const hit = typeof root === 'string' && root
195
+ ? [...activeInstalls(installTargets())].find(([h, , r]) => h === host && samePath(r, root))
196
+ : undefined;
197
+ if (hit === undefined) return { ok: false, error: 'not an active install (host, path)' };
198
+ const file = sharedPaths().defaultInstall;
199
+ // The folder normally exists already, through the install registry. Created here, it does not
200
+ // read as a tier: `tierOf` tests for the tier's memory store or a tier file, not the folder.
201
+ mkdirSync(path.dirname(file), { recursive: true });
202
+ writeTextAtomic(file, `${JSON.stringify({ host, path: String(hit[2]) }, null, 2)}\n`);
203
+ followDefault(state, defaultView());
204
+ return { ok: true };
205
+ }
206
+
180
207
  /**
181
208
  * The row `id` carries the ROOT, not only `host:scope`: two project installs of one host (two
182
209
  * repos on Bob, say) are both `bob:project`, and the console keys its selection, its React rows
@@ -190,13 +217,15 @@ export function apiInstalls(state) {
190
217
  const def = defaultView(targets);
191
218
  // The row marked `default` must be the install an unnamed request reads, so the daemon state
192
219
  // follows the marker here, where the console reads it, rather than only on a full refresh.
193
- if (def && state?.selectView && !state.pinned && !samePath(def[0], state.target)) state.selectView(...def);
220
+ followDefault(state, def);
194
221
  for (const [host, scope, root] of targets) {
195
222
  out.push({
196
223
  ...installRowBase(host, scope, root, installState(root, host, scope)),
197
224
  posture: postureOfDir(root, host),
198
225
  mode: modeOfDir(root, host),
199
226
  trust: trustOfDir(root, host),
227
+ // A project install's switch for reading the machine tier (a global install owns it).
228
+ sharedTier: scope === 'global' ? false : sharedTierOfDir(root, host),
200
229
  // The install a request naming none reads (`defaultView`): the console's pickers start on it.
201
230
  default: !!def && samePath(viewCfg(host, scope, root), def[0]),
202
231
  });
@@ -206,6 +235,10 @@ export function apiInstalls(state) {
206
235
  }
207
236
 
208
237
 
238
+ // How long a poll may serve `apiFleet`'s memo: a rule or profile write and a session's memory write
239
+ // call no `refresh`, so this is how late they show.
240
+ const FLEET_READS_MS = 30_000;
241
+
209
242
  /**
210
243
  * EVERY INSTALLED HARNESS ON THE MACHINE, EACH JUDGED ON ITS OWN — the Overview's fleet table.
211
244
  *
@@ -222,7 +255,23 @@ export function apiInstalls(state) {
222
255
  * a fixed walk finds, which describes the wrong install as soon as two hosts are deployed.
223
256
  * Every unknown stays `null` — `verdict: 'unknown'`, `drift: null` — never a reassuring zero.
224
257
  */
225
- export function apiFleet(state) {
258
+ export function apiFleet(state, { now = Date.now() } = {}) {
259
+ // Both reads render the session files, and an eager wiki walks a whole vault each time, so a poll
260
+ // serves them from a memo. `refresh` clears it; `FLEET_READS_MS` bounds what no `refresh` reports.
261
+ // `st` is in the key: an install switched off stops being measured at once.
262
+ const reads = (host, scope, st, root, dir) => {
263
+ const memo = (state._fleetReads ??= new Map());
264
+ const key = JSON.stringify([host, scope, st, String(root)]);
265
+ const hit = memo.get(key);
266
+ if (hit && now - hit.at < FLEET_READS_MS) return hit;
267
+ let sessionStart = null;
268
+ if (st === 'active' && scope === 'global' && CLAUDE_STYLE.includes(host)) {
269
+ try { sessionStart = sessionStartSize(dir, host); } catch { /* not measured, this round */ }
270
+ }
271
+ const fresh = { at: now, sessionStart, cost: alwaysOnCost({ host, root, dir, footprint: footprintOfDir(root) }) };
272
+ memo.set(key, fresh);
273
+ return fresh;
274
+ };
226
275
  const sourceFp = sourceFingerprint(makeCfg());
227
276
  const installs = [];
228
277
  for (const [host, scope, root] of installTargets()) {
@@ -239,6 +288,8 @@ export function apiFleet(state) {
239
288
  }
240
289
  let built = null;
241
290
  try { built = Math.floor(statSync(path.join(dir, VERSION_MARKER)).mtimeMs / 1000); } catch { /* never built */ }
291
+ const { cost, sessionStart } = reads(host, scope, st, root, dir);
292
+ const tier = tierOf({ target: dir });
242
293
  installs.push({
243
294
  ...installRowBase(host, scope, root, st),
244
295
  installed_fp: fp,
@@ -251,11 +302,14 @@ export function apiFleet(state) {
251
302
  // Each install's own settings, on its row: the Overview has no viewed install to read them off.
252
303
  posture: postureOfDir(root, host),
253
304
  mode: modeOfDir(root, host),
254
- // Its memory facts: one directory listing (`memoryFactCount`), no file read.
255
- facts: memoryFactCount(dir),
305
+ // Its memory facts: directory listings (`factCount`), no file read.
306
+ facts: factCount(memoryDir({ target: dir }, tier)),
256
307
  // What this install injects every session, by part (characters); null when its carrier
257
308
  // is missing, so the console says "not measured" rather than drawing an empty bar.
258
- cost: alwaysOnCost({ host, root, dir, footprint: footprintOfDir(root) }),
309
+ cost,
310
+ // Its session-start hook against the budget. Global hook hosts only: the console has no
311
+ // repo to add, a project install's size is that repo's, and OpenCode has no stdout cap.
312
+ session_start: sessionStart,
259
313
  });
260
314
  }
261
315
  // `version` is the source's release label, the "Behind 4.19.0" a behind row names; the same
@@ -264,7 +318,7 @@ export function apiFleet(state) {
264
318
  }
265
319
 
266
320
  /**
267
- * What the Server tab says about the process answering it — built FIELD BY FIELD, never from the
321
+ * What Settings' Server panel says about the process answering it — built FIELD BY FIELD, never from the
268
322
  * daemon record, which holds the write token: a GET is readable by anything that passes the Host
269
323
  * check, and the token is the only guard on a POST. `started` is the process's own start (the
270
324
  * server is the process), in epoch seconds. `autostart` is whether the hand-written login
@@ -307,10 +361,10 @@ function kitCredits(m, rules) {
307
361
  }
308
362
 
309
363
  /**
310
- * EVERY INSTALL'S KITS — the Kits tab. Its own route, like `apiFleet`: it re-reads each carrier
364
+ * EVERY INSTALL'S KITS — the Kits page. Its own route, like `apiFleet`: it re-reads each carrier
311
365
  * and the kit manifests, which the sidebar's `/api/installs` refetch must not pay for.
312
366
  *
313
- * `kits` per row is `installProfile(...).kits`, the reader `rebuild-all` uses, so the tab shows
367
+ * `kits` per row is `installProfile(...).kits`, the reader `rebuild-all` uses, so the page shows
314
368
  * what a rebuild would keep. A malformed manifest answers 200 with `error` and EMPTY lists, never
315
369
  * rows without kits (which would read as "no kit on") and never a 500. `editable:false` carries
316
370
  * the two refusals `apiInstallCmd` makes, so the page can say why before the click.
@@ -332,9 +386,7 @@ export function apiKits() {
332
386
  if (st === 'absent') continue;
333
387
  try {
334
388
  const p = installProfile(host, scope, root);
335
- const reason = st === 'disabled' ? 'install is disabled — reactivate it first'
336
- : legacyProcessCarrierOfDir(root, host) ? 'predates the comms pack — run geneseed setup for it first'
337
- : null;
389
+ const reason = st === 'disabled' ? 'install is disabled — reactivate it first' : null;
338
390
  installs.push({ ...installRowBase(host, scope, root, st), kits: p.kits,
339
391
  keptKitFiles: keptKitFiles(host, scope, root, p.kits), editable: reason === null, reason });
340
392
  } catch (e) {
@@ -345,9 +397,37 @@ export function apiKits() {
345
397
  return { kits, installs };
346
398
  }
347
399
 
348
- /** The dashboard aggregate. */
349
- export function apiOverview(state) {
350
- const inv = state.inventory;
400
+ /**
401
+ * Every count the console prints, over `fleet`: `fleetCounts`, plus the rail's Loops badge. That one
402
+ * is templates only (a brick is a part, the template is what a person runs), from the catalogue
403
+ * `/api/loops` reads, and the union across installs, where its page lists the picked install's.
404
+ */
405
+ export function machineCounts(state, fleet) {
406
+ const templates = (v) => [...loadCatalog({ projectRoot: v.state.root }).templates.keys()];
407
+ return { ...fleetCounts(state, fleet),
408
+ loops: new Set(fleet.flatMap((v) => orSkip(v, () => templates(v)))).size };
409
+ }
410
+
411
+ // How long `machineCounts` may serve a read: the overview is asked every 1.5 s while the doctor
412
+ // warms. A mutation drops it (`refreshOwn`); this bounds what a session writes behind the console.
413
+ const COUNTS_MS = 5_000;
414
+
415
+ /** `machineCounts` over `fleet()`, memoised on the daemon's state `base`. */
416
+ export function memoCounts(base, fleet, now = Date.now()) {
417
+ const hit = base._counts;
418
+ if (hit && now - hit.at < COUNTS_MS) return hit.counts;
419
+ const counts = machineCounts(base, fleet());
420
+ base._counts = { at: now, counts };
421
+ return counts;
422
+ }
423
+
424
+ /**
425
+ * The dashboard aggregate. One install's facts, but its `counts` are the machine's (`memoCounts`):
426
+ * every install, deduped, the same answer whichever install asks. They default to `state` alone.
427
+ * A pinned view runs no doctor: its one reader wants its `install`, and a cold run blocks the request
428
+ * for seconds. It serves the verdict it holds, or null.
429
+ */
430
+ export function apiOverview(state, counts = machineCounts(state, [{ install: null, state }])) {
351
431
  let diff = null;
352
432
  if (deployed(state)) {
353
433
  const { files } = diffCollect({
@@ -373,8 +453,8 @@ export function apiOverview(state) {
373
453
  for (const [host, scope, root] of installTargets()) {
374
454
  try {
375
455
  if (samePath(viewCfg(host, scope, root), state.target)) {
376
- // `deletionGate`/`secretsGate`/`doneGate`: the gate switches, for the Constitution
377
- // page's toggles on rows IV, I and III.
456
+ // `deletionGate`/`secretsGate`/`doneGate`/`ownershipGate`: the gate switches, for the
457
+ // Constitution page's toggles on rows IV, I, III and inside the Credo's Ownership row.
378
458
  install = { host, scope, path: root, footprint: footprintOfDir(root),
379
459
  ...gatesOfDir(root, host) };
380
460
  break;
@@ -400,37 +480,8 @@ export function apiOverview(state) {
400
480
  // `serve` installs the comparison; a state built without a server has none and is false.
401
481
  daemon_stale: Boolean(state.daemonStale?.()),
402
482
  server: serverFacts(),
403
- counts: {
404
- agents: inv.agents.length,
405
- skills: inv.skills.length,
406
- // ⚠ `laws` STAYS THE INVARIANT COUNT. The rail badge reads it, `docCounts` mirrors it as
407
- // `{N_LAWS}`, and the doctor's frozen `proseMirrorProblems` compares README and
408
- // SHIPPED.md prose against the same number. Widening it to "the whole constitution"
409
- // would silently move all four at once.
410
- laws: inv.laws.length,
411
- ontology: (inv.ontology ?? []).length,
412
- // The tier's own summary, kept out of the section counts because it is not a section:
413
- // `active`/`total` is the fraction the dashboard shows, `rules` counts only the packs
414
- // this install built in — what it is bound by, not what its bundle carries.
415
- doctrines: {
416
- active: (inv.doctrines ?? []).filter((p) => p.active).length,
417
- total: (inv.doctrines ?? []).length,
418
- // Counted RULE BY RULE, not pack by pack: with the per-rule axis an active pack can
419
- // carry an inactive rule, so `p.rules.length` over active packs over-counts by
420
- // exactly what the user switched off — the one number on the dashboard that claims
421
- // to say how many rules bind this install.
422
- rules: (inv.doctrines ?? [])
423
- .reduce((n, p) => n + p.rules.filter((r) => r.active !== false).length, 0),
424
- },
425
- memory: memoryItems(state).length,
426
- notebook: notebookItems(state).length,
427
- wiki: wikiItems(state).length,
428
- config: configItems(state).length,
429
- // The rail's Loops badge: templates only, from the same catalogue `/api/loops` reads —
430
- // a brick is a part, the template is what a person runs.
431
- loops: loadCatalog({ projectRoot: state.root }).templates.size,
432
- },
433
- doctor: state.doctor,
483
+ counts,
484
+ doctor: state.pinned ? state._doctor : state.doctor,
434
485
  diff,
435
486
  build_time: buildTime,
436
487
  build_epoch: buildEpoch,
@@ -464,7 +515,7 @@ const RECENT_LIMIT = 8;
464
515
  /**
465
516
  * THE NEWEST FILE-BACKED ENTRIES ACROSS THE HARNESS — the "freshly grown" card's whole payload.
466
517
  *
467
- * The first GET added after the Python→Node port froze its reference surface. It exists
518
+ * It exists
468
519
  * because NOTHING else in this API carries a per-entry date: every
469
520
  * catalog row is `{name, title, desc, source}` and the only two timestamps on the whole surface are
470
521
  * `overview.build_time` and `doctor.checked_at`. A client cannot stat a path, so "what changed
@@ -561,17 +612,22 @@ export function apiLoopsActive() {
561
612
  *
562
613
  * `install` picks the Update route (`git`, `npm-global`, `other`); `git` is kept beside it for a
563
614
  * console bundle older than the field. `behind` is a clone's own "up to date": commits upstream
564
- * holds that it does not, null when unknown — a clone can always pull, since `main` moves between
565
- * releases and a work proxy can leave the release check unanswered. `command` is what to run by
566
- * hand when the console cannot update this copy itself.
615
+ * holds that it does not, null when unknown — a clone can always try to pull, since `main` moves
616
+ * between releases and a work proxy can leave the release check unanswered — and false when the
617
+ * update job would refuse: local changes, no upstream, a detached HEAD, a diverged branch.
618
+ * `checking` covers both asks, so a slow fetch reads as "checking…", not as a settled unknown.
619
+ * `command` is what to run by hand when the console cannot update this copy itself.
567
620
  */
568
621
  export function apiUpdate(state) {
569
622
  const install = installKind();
623
+ const status = updateStatus(state, releaseLabel());
624
+ const behind = install === 'git' ? gitBehind(state, { busy: Boolean(state.jobBusy?.()) }) : null;
570
625
  return {
571
- ...updateStatus(state, releaseLabel()),
626
+ ...status,
627
+ checking: status.checking || Boolean(state._behind?.inflight),
572
628
  install,
573
629
  git: install === 'git',
574
- behind: install === 'git' ? gitBehind(state, { busy: Boolean(state.jobBusy?.()) }) : null,
630
+ behind,
575
631
  command: install === 'other' ? MANUAL_UPDATE : null,
576
632
  };
577
633
  }