geneseed 4.32.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 (245) hide show
  1. package/CHANGELOG.md +85 -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 +85 -18
  14. package/adapters/opencode/plugins/geneseed-guard.js +437 -76
  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 +5 -5
  26. package/docs/concepts/footprint.md +1 -1
  27. package/docs/concepts/foreman-mode.md +2 -2
  28. package/docs/concepts/hooks.md +22 -8
  29. package/docs/concepts/host-matrix.md +2 -2
  30. package/docs/concepts/hosts.md +1 -1
  31. package/docs/concepts/kits.md +3 -1
  32. package/docs/concepts/ownership.md +1 -1
  33. package/docs/concepts/rules.md +15 -2
  34. package/docs/concepts/shared-tier.md +73 -0
  35. package/docs/concepts/skills.md +2 -2
  36. package/docs/concepts/themes.md +1 -1
  37. package/docs/extending.md +13 -12
  38. package/docs/guides/install-claude-code.md +1 -1
  39. package/docs/guides/install-opencode.md +1 -1
  40. package/docs/guides/migrate.md +4 -2
  41. package/docs/guides/project-context.md +2 -2
  42. package/docs/guides/setup-footprint.md +1 -1
  43. package/docs/guides/uninstall.md +2 -1
  44. package/docs/guides/upgrade-to-5.md +116 -0
  45. package/docs/guides/upgrade.md +21 -9
  46. package/docs/guides/wiki.md +3 -3
  47. package/docs/reference/env-context.md +5 -3
  48. package/docs/reference/environment.md +1 -1
  49. package/docs/reference/glossary.md +2 -0
  50. package/docs/reference/opencode-plugins.md +3 -3
  51. package/docs/reference/plugin-activity.md +1 -1
  52. package/docs/reference/plugin-context.md +1 -0
  53. package/docs/reference/plugin-guard.md +14 -6
  54. package/docs/reference/plugin-learn.md +13 -6
  55. package/docs/reference/troubleshoot-hooks.md +3 -3
  56. package/docs/reference/troubleshoot-update.md +14 -0
  57. package/docs/token-footprint.md +4 -3
  58. package/docs/understand/a-day.md +2 -2
  59. package/docs/understand/design-choices-install.md +2 -1
  60. package/docs/understand/enforced-vs-asked.md +1 -1
  61. package/docs/understand/machine-bob.md +2 -0
  62. package/docs/understand/machine-claude.md +7 -5
  63. package/docs/understand/machine-opencode.md +7 -5
  64. package/docs/understand/on-your-machine.md +4 -0
  65. package/docs/understand/take-it-out.md +1 -1
  66. package/docs/web-ui.md +126 -68
  67. package/harness.config.json +1 -1
  68. package/js/README.md +10 -6
  69. package/js/build/args.mjs +10 -8
  70. package/js/build/bundle.mjs +11 -13
  71. package/js/build/driver.mjs +66 -65
  72. package/js/build/emit-claude.mjs +22 -16
  73. package/js/build/emit-common.mjs +4 -5
  74. package/js/build/emit-opencode.mjs +22 -22
  75. package/js/build/fold.mjs +515 -0
  76. package/js/build/generate.mjs +41 -52
  77. package/js/build/render.mjs +115 -29
  78. package/js/build/source.mjs +4 -1
  79. package/js/build/stubs.mjs +70 -9
  80. package/js/build/version.mjs +10 -10
  81. package/js/cli-table.json +23 -83
  82. package/js/hosts/activity.mjs +2 -2
  83. package/js/hosts/geneseed-dir.mjs +1 -1
  84. package/js/hosts/hooks-context.mjs +389 -99
  85. package/js/hosts/hooks-learn.mjs +38 -7
  86. package/js/hosts/hooks-prims.mjs +4 -2
  87. package/js/hosts/hooks.mjs +114 -39
  88. package/js/hosts/hosts.mjs +150 -51
  89. package/js/hosts/installs.mjs +55 -167
  90. package/js/hosts/link.mjs +3 -5
  91. package/js/hosts/mcp.mjs +1 -1
  92. package/js/hosts/memory-files.mjs +219 -17
  93. package/js/hosts/ownership-gate.mjs +1 -1
  94. package/js/hosts/settings.mjs +18 -13
  95. package/js/hosts/shim.mjs +4 -33
  96. package/js/hosts/store-watch.mjs +189 -0
  97. package/js/inspect/checks-authoring.mjs +3 -3
  98. package/js/inspect/checks-build.mjs +45 -18
  99. package/js/inspect/checks-counts.mjs +4 -4
  100. package/js/inspect/checks-repo.mjs +13 -14
  101. package/js/inspect/cost.mjs +24 -2
  102. package/js/inspect/diff.mjs +123 -123
  103. package/js/inspect/doctor.mjs +22 -27
  104. package/js/inspect/excludes.mjs +181 -62
  105. package/js/inspect/inventory.mjs +22 -27
  106. package/js/inspect/registry.mjs +106 -30
  107. package/js/inspect/scan.mjs +5 -5
  108. package/js/inspect/status.mjs +141 -119
  109. package/js/inspect/validate.mjs +22 -24
  110. package/js/lib/fs.mjs +47 -50
  111. package/js/lib/json.mjs +10 -17
  112. package/js/lib/machine-dir.mjs +73 -0
  113. package/js/lib/paths.mjs +22 -33
  114. package/js/lib/proc.mjs +1 -1
  115. package/js/lib/prompt.mjs +19 -27
  116. package/js/lib/text.mjs +8 -12
  117. package/js/lib/udiff.mjs +11 -15
  118. package/js/loop/catalog.mjs +2 -3
  119. package/js/maintain/memory.mjs +17 -17
  120. package/js/maintain/migrate.mjs +79 -89
  121. package/js/maintain/setup.mjs +43 -32
  122. package/js/maintain/uninstall.mjs +43 -61
  123. package/js/maintain/update.mjs +200 -93
  124. package/js/ui/anim.mjs +21 -35
  125. package/js/ui/cli.mjs +36 -58
  126. package/js/ui/menu.mjs +22 -45
  127. package/js/ui/tui.mjs +27 -67
  128. package/js/web/actions.mjs +34 -34
  129. package/js/web/api.mjs +130 -74
  130. package/js/web/catalog.mjs +175 -46
  131. package/js/web/docs.mjs +33 -12
  132. package/js/web/doctor-worker.mjs +14 -0
  133. package/js/web/handler.mjs +14 -5
  134. package/js/web/routes.mjs +17 -19
  135. package/js/web/state.mjs +78 -19
  136. package/js/web/update-check.mjs +25 -10
  137. package/js/web/user-files.mjs +50 -105
  138. package/package.json +7 -4
  139. package/registry.json +48 -55
  140. package/src/AGENT.md.tmpl +13 -14
  141. package/src/agents/_self-improvement.md +1 -1
  142. package/src/agents/_template.md +1 -1
  143. package/src/agents/advocate.md +1 -1
  144. package/src/agents/architect.md +1 -1
  145. package/src/agents/developer.md +1 -1
  146. package/src/agents/devops-engineer.md +1 -1
  147. package/src/agents/docker-expert.md +1 -1
  148. package/src/agents/docs.md +1 -1
  149. package/src/agents/empiricist.md +1 -1
  150. package/src/agents/explorer.md +1 -1
  151. package/src/agents/framer.md +1 -1
  152. package/src/agents/historian.md +1 -1
  153. package/src/agents/kubernetes-specialist.md +1 -1
  154. package/src/agents/memory-curator.md +2 -2
  155. package/src/agents/operator.md +1 -1
  156. package/src/agents/performance.md +1 -1
  157. package/src/agents/pragmatist.md +1 -1
  158. package/src/agents/react-engineer.md +1 -1
  159. package/src/agents/react-reviewer.md +1 -1
  160. package/src/agents/researcher.md +1 -1
  161. package/src/agents/reviewer.md +1 -1
  162. package/src/agents/security.md +1 -1
  163. package/src/agents/skeptic.md +1 -1
  164. package/src/agents/spring-boot-engineer.md +1 -1
  165. package/src/agents/spring-reviewer.md +1 -1
  166. package/src/agents/spring-security.md +1 -1
  167. package/src/agents/steward.md +1 -1
  168. package/src/agents/tester.md +1 -1
  169. package/src/agents/user-advocate.md +1 -1
  170. package/src/agents/visionary.md +1 -1
  171. package/src/memory/README.md +1 -1
  172. package/src/skills/_self-improvement.md +2 -2
  173. package/src/skills/daydream/SKILL.md +2 -2
  174. package/src/skills/daydream/instructions.md +1 -1
  175. package/src/skills/geneseed.md +1 -1
  176. package/src/skills/learn-mode.md +1 -2
  177. package/src/skills/profile.md +2 -2
  178. package/src/skills/rule/approve.md +69 -0
  179. package/src/skills/rule/consolidate.md +3 -3
  180. package/src/skills/rule.md +13 -5
  181. package/src/skills/skill-forge.md +1 -1
  182. package/src/skills/teach.md +29 -12
  183. package/src/skills/wiki.md +1 -1
  184. package/themes/_TEMPLATE.json +1 -2
  185. package/themes/biker.json +1 -2
  186. package/themes/commentator.json +1 -2
  187. package/themes/cyberpunk.json +1 -2
  188. package/themes/gamer.json +1 -2
  189. package/themes/imperial.json +1 -2
  190. package/themes/joker.json +1 -2
  191. package/themes/marvin.json +1 -2
  192. package/themes/mean.json +1 -2
  193. package/themes/military.json +1 -2
  194. package/themes/neutral.json +1 -2
  195. package/themes/pirate.json +1 -2
  196. package/themes/sports.json +1 -2
  197. package/themes/verstappen.json +1 -2
  198. package/themes/wizard.json +1 -2
  199. package/web/dist/assets/Activity-D8G4eClY.js +1 -0
  200. package/web/dist/assets/ActivityDetail-BtOBYk3M.js +1 -0
  201. package/web/dist/assets/AgentGlyph-k6o3gCM1.js +1 -0
  202. package/web/dist/assets/Bonsai-B_y20b3i.js +1 -0
  203. package/web/dist/assets/{CopyButton-C5Li6awl.js → CopyButton-CHQte7Ap.js} +1 -1
  204. package/web/dist/assets/Dashboard-B8uXeJZ_.js +2 -0
  205. package/web/dist/assets/Docs-Dgv_MWfT.js +5 -0
  206. package/web/dist/assets/GreenhouseView-CSzTMSl_.js +1 -0
  207. package/web/dist/assets/Installs-BDk9lqBI.js +3 -0
  208. package/web/dist/assets/JournalView-CvRk1-m5.js +1 -0
  209. package/web/dist/assets/Kits-CoITzxWM.js +1 -0
  210. package/web/dist/assets/Laws-Ctf5r9rE.js +3 -0
  211. package/web/dist/assets/Library-DNwHYVXt.js +3 -0
  212. package/web/dist/assets/{Loops-CzitjxGV.js → Loops-S85PMQ8m.js} +2 -2
  213. package/web/dist/assets/{Markdown-C4S4tTA7.js → Markdown-0ORz7tAc.js} +21 -21
  214. package/web/dist/assets/OperatorHudView-DuGz_sTk.js +1 -0
  215. package/web/dist/assets/Personal-afJNwvRS.js +2 -0
  216. package/web/dist/assets/{RailCats-D5weYPCS.js → RailCats-AW92uhsX.js} +1 -1
  217. package/web/dist/assets/Settings-CGDFz-6j.js +1 -0
  218. package/web/dist/assets/Tabs-1qLrnqmn.js +1 -0
  219. package/web/dist/assets/api-C46vAuqp.js +1 -0
  220. package/web/dist/assets/controls-D4wmg_pl.js +1 -0
  221. package/web/dist/assets/index-COTd4TRZ.js +3 -0
  222. package/web/dist/assets/index-CtorA7uK.css +1 -0
  223. package/web/dist/assets/motion-RlUl1osO.js +1 -0
  224. package/web/dist/assets/{sections-ChwaobfW.js → sections-CtFz7HFH.js} +1 -1
  225. package/web/dist/index.html +5 -5
  226. package/src/skills/quiz.md +0 -44
  227. package/web/dist/assets/Activity-Bjy64wHC.js +0 -1
  228. package/web/dist/assets/ActivityDetail-B0AaipP8.js +0 -1
  229. package/web/dist/assets/Bonsai-CJniRqaH.js +0 -1
  230. package/web/dist/assets/Dashboard-B-6DTmae.js +0 -2
  231. package/web/dist/assets/Docs-LRc30XL9.js +0 -5
  232. package/web/dist/assets/GreenhouseView-CcoYlaWo.js +0 -1
  233. package/web/dist/assets/Installs-dp1epTcE.js +0 -3
  234. package/web/dist/assets/JournalView-nFP4poCf.js +0 -1
  235. package/web/dist/assets/KitApply-DwyZUj57.js +0 -1
  236. package/web/dist/assets/Kits-C0IEdZXe.js +0 -1
  237. package/web/dist/assets/Laws-CkykmQWu.js +0 -3
  238. package/web/dist/assets/Library-Guh9HBZU.js +0 -2
  239. package/web/dist/assets/OperatorHudView-DLGNulIY.js +0 -1
  240. package/web/dist/assets/Personal-BMtberL8.js +0 -2
  241. package/web/dist/assets/Tabs-uYJqfuQt.js +0 -1
  242. package/web/dist/assets/api-BxjLd7Qd.js +0 -1
  243. package/web/dist/assets/index-DA7BiaE5.js +0 -3
  244. package/web/dist/assets/index-dbbDGFDq.css +0 -1
  245. package/web/dist/assets/motion-Bccx3zE8.js +0 -1
@@ -1,19 +1,18 @@
1
1
  /**
2
- * `_install_registry.py` — the persistent list of folders a harness was deployed into.
2
+ * The persistent list of folders a harness was deployed into.
3
3
  *
4
- * MOVED OUT OF `bin/build-driver.mjs` IN P5f, for the third time the same arithmetic has decided
5
- * a module boundary in this port (P5c took the host resolvers, P5d the checkout paths). The
4
+ * IT LIVES HERE, NOT IN `bin/build-driver.mjs`. The
6
5
  * driver WRITES the registry, one row per per-repo emit; `harness rebuild-all` READS it to
7
6
  * find every install it must re-emit, and `bin/geneseed-cli.mjs` may not reach into a driver
8
7
  * for a reader. `js/build/generate.mjs` importing `main` from `bin/build-driver.mjs` is not a
9
8
  * precedent for it either: `harness build` IS the driver, and a registry reader is not.
10
9
  *
11
- * The move is licensed the same way the two before it were: `tests/golden.mjs` drives
12
- * `bin/build-driver.mjs` over 259 cells with `$XDG_CONFIG_HOME` redirected into the sandbox and
10
+ * `tests/golden.mjs` drives
11
+ * `bin/build-driver.mjs` over many cells with `$XDG_CONFIG_HOME` redirected into the sandbox and
13
12
  * compares `installs.json` byte-for-byte, so a changed path or a dropped prune fails cells
14
13
  * rather than passing quietly.
15
14
  */
16
- import { existsSync, mkdirSync, readFileSync, realpathSync, renameSync } from 'node:fs';
15
+ import { existsSync, mkdirSync, readFileSync, realpathSync, renameSync, rmSync, statSync } from 'node:fs';
17
16
  import path from 'node:path';
18
17
  import os from 'node:os';
19
18
 
@@ -21,11 +20,11 @@ import { expanduser, resolvePath } from '../hosts/hosts.mjs';
21
20
  import { writeText, isFile, isDir } from '../lib/fs.mjs';
22
21
  import { parseJson, jsonDumpsIndent } from '../lib/json.mjs';
23
22
  import { toPlatformPath, within } from '../lib/paths.mjs';
23
+ import { machineDir } from '../lib/machine-dir.mjs';
24
24
 
25
25
  /** `_install_registry._path()` — `$XDG_CONFIG_HOME/geneseed/installs.json`. */
26
26
  function registryPath() {
27
- const base = process.env.XDG_CONFIG_HOME || path.join(os.homedir(), '.config');
28
- return path.join(base, 'geneseed', 'installs.json');
27
+ return path.join(machineDir(), 'installs.json');
29
28
  }
30
29
 
31
30
  /**
@@ -43,29 +42,97 @@ export function isScratchRoot(root, registryFile) {
43
42
  return within(resolvePath(root), tmp) && !within(resolvePath(registryFile), tmp);
44
43
  }
45
44
 
45
+ /**
46
+ * The rows, or `null` when the file exists and cannot be trusted. Only a missing file is an empty
47
+ * registry: read as `[]`, a refused read made the next save write one root over every install.
48
+ */
46
49
  function registryLoad() {
50
+ let file;
51
+ try { file = registryPath(); } catch { return null; } // no home dir: nothing to read or to save over
47
52
  try {
48
- const data = parseJson(readFileSync(registryPath(), 'utf8'));
49
- return Array.isArray(data) ? data.map(String) : [];
50
- } catch { return []; }
53
+ const data = parseJson(readFileSync(file, 'utf8'));
54
+ if (Array.isArray(data)) return data.map(String);
55
+ throw new Error('not a list');
56
+ } catch (e) {
57
+ if (e.code === 'ENOENT') return [];
58
+ process.stderr.write(`[geneseed] could not read the install registry ${file}: ${e.message}\n`);
59
+ return null;
60
+ }
61
+ }
62
+
63
+ /**
64
+ * The rename, waited out while Windows refuses it. A process holding the just-written target (real-time
65
+ * scanning, by every sign) fails the replace with EPERM: measured at about 1 rename in 500 under
66
+ * load, gone within moments. Writing in place instead would give up the atomicity: a reader could
67
+ * see a torn file, load `[]`, and save only its own root over every other install. Bounded at about
68
+ * 400 ms. Not gated on the platform: elsewhere these codes are rare and the bound is the same.
69
+ */
70
+ const RENAME_WAITS_MS = [10, 30, 90, 270];
71
+ const SHARING_ERRORS = new Set(['EPERM', 'EACCES', 'EBUSY']);
72
+ function renameOver(tmp, file) {
73
+ for (const wait of RENAME_WAITS_MS) {
74
+ try {
75
+ renameSync(tmp, file);
76
+ return;
77
+ } catch (e) {
78
+ if (!SHARING_ERRORS.has(e.code)) throw e;
79
+ pause(wait);
80
+ }
81
+ }
82
+ renameSync(tmp, file);
51
83
  }
52
84
 
85
+ /** A failed write must never break a deploy, and is never silent: stderr, since hooks speak on stdout. */
53
86
  export function registrySave(items) {
87
+ const file = registryPath();
88
+ const tmp = `${file}.tmp`;
54
89
  try {
55
- const file = registryPath();
56
90
  mkdirSync(path.dirname(file), { recursive: true });
57
- const tmp = `${file}.tmp`;
58
91
  // `jsonDumpsIndent` for the same reason as the manifest: these are absolute paths, and
59
92
  // a machine whose username carries an accent writes one here.
60
93
  writeText(tmp, `${jsonDumpsIndent(items)}\n`);
61
- renameSync(tmp, file);
62
- } catch { /* best-effort: a registry hiccup must never break a deploy */ }
94
+ renameOver(tmp, file);
95
+ } catch (e) {
96
+ try { rmSync(tmp, { force: true }); } catch { /* the report below is the one that matters */ }
97
+ process.stderr.write(`[geneseed] could not update the install registry ${file}: ${e.message}\n`);
98
+ }
63
99
  }
64
100
 
101
+ const pause = (ms) => Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
102
+ const LOCK_WAITS_MS = [10, 30, 90, 270, 500, 1000];
103
+ const LOCK_STALE_MS = 10_000;
104
+
65
105
  /**
66
- * `_install_registry.record` — idempotent, best-effort, and it must NEVER raise into a build.
106
+ * `fn` under a directory lock, or without it after about 2 s. An atomic rename stops a torn file,
107
+ * not a lost update: two records both load the list, and the later rename drops the other's root,
108
+ * which `rebuild-all` then never reaches. A crashed holder is outwaited by age. Past the bound
109
+ * `fn` runs anyway, reported, because a registry hiccup must never fail a build.
110
+ */
111
+ function withRegistryLock(fn) {
112
+ const lock = `${registryPath()}.lock`;
113
+ mkdirSync(path.dirname(lock), { recursive: true });
114
+ let held = false;
115
+ for (const wait of LOCK_WAITS_MS) {
116
+ try {
117
+ mkdirSync(lock);
118
+ held = true;
119
+ break;
120
+ } catch (e) {
121
+ if (e.code !== 'EEXIST' && !SHARING_ERRORS.has(e.code)) throw e;
122
+ try {
123
+ if (Date.now() - statSync(lock).mtimeMs > LOCK_STALE_MS) rmSync(lock, { recursive: true, force: true });
124
+ } catch { /* the holder just let go */ }
125
+ pause(wait);
126
+ }
127
+ }
128
+ if (!held) process.stderr.write(`[geneseed] the install registry stayed locked: ${lock}\n`);
129
+ try { return fn(); } finally { if (held) rmSync(lock, { recursive: true, force: true }); }
130
+ }
131
+
132
+ /**
133
+ * Idempotent, best-effort, and it must NEVER raise into a build.
67
134
  *
68
- * `realpathSync` rather than `path.resolve`, because Python's `Path.resolve()` returns the
135
+ * `realpathSync` rather than `path.resolve`, because it returns the
69
136
  * filesystem's own casing and follows links; `path.resolve` only makes a path absolute. The
70
137
  * registry is compared byte-for-byte by `tests/golden.mjs` (XDG is redirected into the
71
138
  * sandbox), so a differently-cased entry is a failing cell.
@@ -75,8 +142,11 @@ export function registryRecord(dir) {
75
142
  let root;
76
143
  try { root = realpathSync.native(dir); } catch { root = path.resolve(dir); }
77
144
  if (isScratchRoot(root, registryPath())) return;
78
- const cur = registryLoad();
79
- if (!cur.includes(root)) registrySave([...cur, root]);
145
+ if (registryLoad()?.includes(root)) return; // the usual case takes no lock
146
+ withRegistryLock(() => {
147
+ const cur = registryLoad();
148
+ if (cur && !cur.includes(root)) registrySave([...cur, root]);
149
+ });
80
150
  } catch { /* a registry hiccup must never fail a build */ }
81
151
  }
82
152
 
@@ -85,24 +155,24 @@ export function registryRecord(dir) {
85
155
  *
86
156
  * The prune is a WRITE, and reproducing it matters: `installs.json` is compared byte-for-byte,
87
157
  * so a read that failed to drop a dead row would leave the two implementations holding
88
- * different registries. The snapshot is taken once on purpose (its own comment says why):
89
- * comparing `kept` against a SECOND read could clobber a root a concurrent `record()`
90
- * appended between the two.
158
+ * different registries. The snapshot is taken once on purpose: comparing `kept` against a SECOND
159
+ * read could clobber a root a concurrent `record()` appended between the two. So the write takes
160
+ * the lock and adds what that second read holds and the snapshot did not.
91
161
  */
92
162
  export function registryRoots() {
93
163
  const original = registryLoad();
164
+ if (!original) return [];
94
165
  const file = registryPath();
95
166
  const out = [];
96
167
  const kept = [];
97
168
  const seen = new Set();
98
169
  for (const s of original) {
99
- // `Path(s).expanduser()`, and `toPlatformPath` is the `str()` around it — which is where the
100
- // NORMALISATION happens. Python turns `C:/x/other` into `C:\x\other` before it is
101
- // compared, kept, returned and printed, so a registry entry spelled with forward slashes
102
- // (routine: every tool that writes one from Git Bash) makes Python rewrite the file and
103
- // print a backslash path while a raw `expanduser` prints the entry verbatim and leaves
104
- // installs.json alone. Invisible to every cell before P5h, because `rebuild-all`'s
105
- // registry cells seed native spellings; `uninstall`'s inventory prints the root.
170
+ // `toPlatformPath` around `expanduser` is where the NORMALISATION happens. `C:/x/other`
171
+ // becomes `C:\x\other` before it is compared, kept, returned and printed, so a registry
172
+ // entry spelled with forward slashes (routine: every tool that writes one from Git Bash)
173
+ // makes the file be rewritten and a backslash path printed, where a raw `expanduser`
174
+ // prints the entry verbatim and leaves installs.json alone. `rebuild-all`'s registry
175
+ // cells seed native spellings; `uninstall`'s inventory prints the root.
106
176
  // `expanduser` now REFUSES a `~user` entry (js/hosts/hosts.mjs's docblock) instead of passing
107
177
  // it through. This loop scans STORED registry rows, not a fresh CLI argument — a single
108
178
  // bad row (hand-edited, or written before this refusal existed) must not abort the scan
@@ -120,7 +190,13 @@ export function registryRoots() {
120
190
  }
121
191
  }
122
192
  if (kept.length !== original.length || kept.some((v, i) => v !== original[i])) {
123
- registrySave(kept);
193
+ try {
194
+ withRegistryLock(() => {
195
+ registrySave([...kept, ...(registryLoad() ?? []).filter((r) => !original.includes(r))]);
196
+ });
197
+ } catch (e) { // a lock that cannot be made must not fail the read; the next one prunes
198
+ process.stderr.write(`[geneseed] could not update the install registry ${file}: ${e.message}\n`);
199
+ }
124
200
  }
125
201
  return out;
126
202
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * `_harness_core`'s scanning primitives — what every doctor check reads the tree with.
2
+ * The scanning primitives — what every doctor check reads the tree with.
3
3
  *
4
4
  * Split out of `doctor.mjs` because all three check modules need them and none of the three
5
5
  * owns them. Nothing here decides anything: these walk, sort, strip and test, and the
@@ -23,10 +23,10 @@ import { mkdtempSync, readdirSync, rmSync } from 'node:fs';
23
23
  export { isDir, isFile, has };
24
24
 
25
25
  // --------------------------------------------------------------------------------------
26
- // _harness_core's scanning primitives
26
+ // scanning primitives
27
27
  // --------------------------------------------------------------------------------------
28
28
 
29
- /** `_harness_core.TOKEN_RE` / `LINK_RE` / `ABS_LINK_RE`. `g` where `findall` is used. */
29
+ /** `TOKEN_RE` / `LINK_RE` / `ABS_LINK_RE`. `g` where every match is collected. */
30
30
  // Must stay in step with `js/build/render.mjs`'s TOKEN_RE: a token the renderer substitutes but this
31
31
  // scan cannot see is an unresolved-token gate that silently stops gating. Digits are legal after
32
32
  // the first character for `DOC_<PACK>_<n>`; a leading digit is still not a token.
@@ -35,7 +35,7 @@ export const LINK_RE = /\]\((?!https?:\/\/|#)([^)]+)\)/g;
35
35
  export const ABS_LINK_RE = /^([A-Za-z]:[\\/]|\/|~)/;
36
36
  const COMMENT_RE = /<!--[\s\S]*?-->/g;
37
37
 
38
- /** `_harness_core.strip_code` — fenced blocks, then HTML comments, then inline code, in that order. */
38
+ /** Fenced blocks, then HTML comments, then inline code, in that order. */
39
39
  export function stripCode(text) {
40
40
  return text.replace(FENCE_RE, '').replace(COMMENT_RE, '').replace(INLINE_CODE_RE, '');
41
41
  }
@@ -79,7 +79,7 @@ export const sortedUnique = (xs) => [...new Set(xs)].sort((a, b) => (a < b ? -1
79
79
  /** `sorted(probs)` — SORTED, not deduped, which is what `_ran` fills a group with. */
80
80
  export const sortedProblems = (xs) => [...xs].sort((a, b) => (a < b ? -1 : a > b ? 1 : 0));
81
81
 
82
- /** `_harness_build._src_stems` — spec stems under `src/<folder>`, minus `_`-scaffolds. */
82
+ /** Spec stems under `src/<folder>`, minus `_`-scaffolds. */
83
83
  export function srcStems(folder) {
84
84
  const d = path.join(SRC, folder);
85
85
  if (!isDir(d)) return new Set();