brane 0.1.1 → 0.3.1

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 (352) hide show
  1. package/AGENTS.md +367 -0
  2. package/CHANGELOG.md +66 -0
  3. package/CONTRIBUTING.md +101 -0
  4. package/DESIGN.md +405 -0
  5. package/Dockerfile +61 -0
  6. package/LICENSE +656 -17
  7. package/README.md +174 -2
  8. package/SECURITY.md +213 -0
  9. package/dist/absorb/brane-id.js +11 -0
  10. package/dist/absorb/chatgpt.js +161 -0
  11. package/dist/absorb/claude-code.js +504 -0
  12. package/dist/absorb/index.js +543 -0
  13. package/dist/absorb/organelle.js +345 -0
  14. package/dist/absorb/run.js +520 -0
  15. package/dist/absorb/sources.js +168 -0
  16. package/dist/absorb/types.js +3 -0
  17. package/dist/agent-env.js +45 -0
  18. package/dist/agents.js +1168 -0
  19. package/dist/claude-live-session.js +124 -0
  20. package/dist/cli.js +50 -0
  21. package/dist/codex-tool-log.js +144 -0
  22. package/dist/commands/absorb.js +291 -0
  23. package/dist/commands/attach.js +31 -0
  24. package/dist/commands/certify.js +62 -0
  25. package/dist/commands/config.js +133 -0
  26. package/dist/commands/cost.js +126 -0
  27. package/dist/commands/daemon.js +350 -0
  28. package/dist/commands/doctor.js +262 -0
  29. package/dist/commands/fold.js +95 -0
  30. package/dist/commands/list.js +89 -0
  31. package/dist/commands/mcp.js +84 -0
  32. package/dist/commands/meld.js +360 -0
  33. package/dist/commands/memory.js +215 -0
  34. package/dist/commands/revive.js +74 -0
  35. package/dist/commands/run.js +85 -0
  36. package/dist/commands/spawn.js +1101 -0
  37. package/dist/commands/token.js +154 -0
  38. package/dist/copilot-tool-log.js +145 -0
  39. package/dist/cost/pricing.js +116 -0
  40. package/dist/cost/reprice.js +136 -0
  41. package/dist/crush-tool-log.js +293 -0
  42. package/dist/daemon/agent-scope.js +116 -0
  43. package/dist/daemon/awaiting.js +54 -0
  44. package/dist/daemon/cert-manager.js +349 -0
  45. package/dist/daemon/client.js +262 -0
  46. package/dist/daemon/gated-routes.js +112 -0
  47. package/dist/daemon/keep-awake.js +103 -0
  48. package/dist/daemon/local-socket.js +145 -0
  49. package/dist/daemon/presence-gate.js +206 -0
  50. package/dist/daemon/server.js +6353 -0
  51. package/dist/daemon/signal-source.js +35 -0
  52. package/dist/daemon/tailscale-rebind.js +58 -0
  53. package/dist/daemon/token-ring.js +263 -0
  54. package/dist/daemon/token-routes.js +190 -0
  55. package/dist/db/events.js +152 -0
  56. package/dist/db/mentions.js +179 -0
  57. package/dist/db/schema.js +643 -0
  58. package/dist/db/tokens.js +624 -0
  59. package/dist/db/tool-uses.js +647 -0
  60. package/dist/diagram/index.js +85 -0
  61. package/dist/diagram/label.js +455 -0
  62. package/dist/diagram/layout.js +476 -0
  63. package/dist/diagram/links.js +50 -0
  64. package/dist/diagram/metrics.js +152 -0
  65. package/dist/diagram/parse.js +487 -0
  66. package/dist/diagram/svg.js +389 -0
  67. package/dist/diagram/types.js +9 -0
  68. package/dist/export.js +629 -0
  69. package/dist/files/archive-types.js +2 -0
  70. package/dist/files/archive.js +182 -0
  71. package/dist/files/browse.js +327 -0
  72. package/dist/files/bytes.js +162 -0
  73. package/dist/files/codecs.js +33 -0
  74. package/dist/files/find.js +212 -0
  75. package/dist/files/tar.js +223 -0
  76. package/dist/files/zip.js +209 -0
  77. package/dist/folds.js +72 -0
  78. package/dist/grammars/ebnf.js +92 -0
  79. package/dist/highlight.js +250 -0
  80. package/dist/ids.js +24 -0
  81. package/dist/markdown-diagnostics.js +233 -0
  82. package/dist/math.js +168 -0
  83. package/dist/mcp/server.js +886 -0
  84. package/dist/memory/embedder.js +145 -0
  85. package/dist/memory/embedding-worker.js +71 -0
  86. package/dist/memory/embeddings.js +91 -0
  87. package/dist/memory/index.js +232 -0
  88. package/dist/memory/storage.js +587 -0
  89. package/dist/memory/wiki.js +688 -0
  90. package/dist/memory/wordpiece.js +247 -0
  91. package/dist/mentions-scan.js +40 -0
  92. package/dist/presence.js +259 -0
  93. package/dist/session-affinity.js +185 -0
  94. package/dist/shared/api-request.js +124 -0
  95. package/dist/shared/app-origin.js +26 -0
  96. package/dist/shared/block-glyphs.js +114 -0
  97. package/dist/shared/diagram-css.js +17 -0
  98. package/dist/shared/export-selection.js +101 -0
  99. package/dist/shared/find-in-text.js +110 -0
  100. package/dist/shared/glow-hues.js +225 -0
  101. package/dist/shared/hex-dump.js +62 -0
  102. package/dist/shared/hex-pages.js +52 -0
  103. package/dist/shared/hit-drum.js +79 -0
  104. package/dist/shared/known-nids.js +58 -0
  105. package/dist/shared/list-scroll-keys.js +56 -0
  106. package/dist/shared/markdown-lists.js +72 -0
  107. package/dist/shared/markdown-math.js +485 -0
  108. package/dist/shared/markdown-mentions.js +79 -0
  109. package/dist/shared/markdown-nids.js +41 -0
  110. package/dist/shared/markdown-protocols.js +53 -0
  111. package/dist/shared/markdown-refs.js +123 -0
  112. package/dist/shared/membrane-invasion.js +342 -0
  113. package/dist/shared/membrane-motion.js +83 -0
  114. package/dist/shared/membrane-palette.js +253 -0
  115. package/dist/shared/membrane-terrain.js +212 -0
  116. package/dist/shared/message-selection.js +123 -0
  117. package/dist/shared/mo-glyph.js +57 -0
  118. package/dist/shared/narrative-format.js +237 -0
  119. package/dist/shared/narrative-menu.js +84 -0
  120. package/dist/shared/narrative-sort.js +47 -0
  121. package/dist/shared/narrative-status.js +52 -0
  122. package/dist/shared/no-pan.js +85 -0
  123. package/dist/shared/pane-layout.js +50 -0
  124. package/dist/shared/payload-inline.js +83 -0
  125. package/dist/shared/speaker-color.js +61 -0
  126. package/dist/shared/token-rotation.js +14 -0
  127. package/dist/shared/view-url.js +216 -0
  128. package/dist/shared/wiki-links.js +70 -0
  129. package/dist/shared/wiki-window.js +4 -0
  130. package/dist/tailscale.js +55 -0
  131. package/dist/test/absorb-claude.test.js +892 -0
  132. package/dist/test/agent-scope.test.js +193 -0
  133. package/dist/test/agents.test.js +55 -0
  134. package/dist/test/api-request.test.js +122 -0
  135. package/dist/test/app-host-literal.test.js +53 -0
  136. package/dist/test/awaiting-glow.test.js +54 -0
  137. package/dist/test/awaiting.test.js +122 -0
  138. package/dist/test/bind-token.test.js +88 -0
  139. package/dist/test/block-glyphs.test.js +68 -0
  140. package/dist/test/cert-manager.test.js +262 -0
  141. package/dist/test/claude-live-session.test.js +110 -0
  142. package/dist/test/codex-tool-log.test.js +568 -0
  143. package/dist/test/config.test.js +71 -0
  144. package/dist/test/copilot-tool-log.test.js +93 -0
  145. package/dist/test/cors-preflight.test.js +56 -0
  146. package/dist/test/cost-linger.test.js +31 -0
  147. package/dist/test/cost-pricing.test.js +72 -0
  148. package/dist/test/cost-reprice.test.js +139 -0
  149. package/dist/test/cost-sessions.test.js +301 -0
  150. package/dist/test/crush-tool-log.test.js +289 -0
  151. package/dist/test/daemon-client.test.js +109 -0
  152. package/dist/test/daemon-socket.test.js +293 -0
  153. package/dist/test/diagram-arrows.test.js +205 -0
  154. package/dist/test/diagram-export.test.js +210 -0
  155. package/dist/test/diagram-labels.test.js +313 -0
  156. package/dist/test/diagram-parse.test.js +191 -0
  157. package/dist/test/diagram-render.test.js +175 -0
  158. package/dist/test/diagram-review.test.js +288 -0
  159. package/dist/test/diagram-self-loop-labels.test.js +303 -0
  160. package/dist/test/embedder.test.js +84 -0
  161. package/dist/test/events.test.js +123 -0
  162. package/dist/test/export-selection.test.js +102 -0
  163. package/dist/test/export.test.js +505 -0
  164. package/dist/test/files-browse.test.js +393 -0
  165. package/dist/test/files-find.test.js +272 -0
  166. package/dist/test/find-in-text.test.js +86 -0
  167. package/dist/test/first-paint-viewport.test.js +59 -0
  168. package/dist/test/fixtures/embedding-golden.js +23 -0
  169. package/dist/test/fixtures/wordpiece-golden.js +167 -0
  170. package/dist/test/glow-hues.test.js +202 -0
  171. package/dist/test/harness-cost.test.js +423 -0
  172. package/dist/test/helpers.js +21 -0
  173. package/dist/test/hex-pages.test.js +68 -0
  174. package/dist/test/highlight.test.js +69 -0
  175. package/dist/test/hit-drum.test.js +71 -0
  176. package/dist/test/hook-config.test.js +299 -0
  177. package/dist/test/json-gzip.test.js +70 -0
  178. package/dist/test/key-routing.test.js +58 -0
  179. package/dist/test/known-nids.test.js +106 -0
  180. package/dist/test/link-preview.test.js +67 -0
  181. package/dist/test/list-scroll-keys.test.js +66 -0
  182. package/dist/test/listen-own-words.test.js +147 -0
  183. package/dist/test/listen-timeout.test.js +33 -0
  184. package/dist/test/markdown-diagnostics.test.js +121 -0
  185. package/dist/test/markdown-lists.test.js +182 -0
  186. package/dist/test/markdown-math.test.js +256 -0
  187. package/dist/test/markdown-nids.test.js +146 -0
  188. package/dist/test/markdown-protocols.test.js +139 -0
  189. package/dist/test/mcp-bridge-cancel.test.js +98 -0
  190. package/dist/test/mcp-bridge-reconnect.test.js +121 -0
  191. package/dist/test/mcp-narrative.test.js +193 -0
  192. package/dist/test/mcp.test.js +548 -0
  193. package/dist/test/meld.test.js +143 -0
  194. package/dist/test/membrane-invasion.test.js +482 -0
  195. package/dist/test/membrane-motion.test.js +101 -0
  196. package/dist/test/membrane-palette.test.js +166 -0
  197. package/dist/test/membrane-terrain.test.js +170 -0
  198. package/dist/test/memory-log.test.js +202 -0
  199. package/dist/test/mentions-e2e.test.js +261 -0
  200. package/dist/test/mentions-ledger.test.js +265 -0
  201. package/dist/test/mentions-listen.test.js +265 -0
  202. package/dist/test/mentions.test.js +238 -0
  203. package/dist/test/message-selection.test.js +114 -0
  204. package/dist/test/mo-glyph.test.js +22 -0
  205. package/dist/test/model-resolution.test.js +166 -0
  206. package/dist/test/narrate-validate.test.js +77 -0
  207. package/dist/test/narrate-wait.test.js +160 -0
  208. package/dist/test/narrative-format.test.js +219 -0
  209. package/dist/test/narrative-menu.test.js +150 -0
  210. package/dist/test/narrative-sort.test.js +75 -0
  211. package/dist/test/no-pan.test.js +60 -0
  212. package/dist/test/pane-layout.test.js +153 -0
  213. package/dist/test/paths.test.js +37 -0
  214. package/dist/test/payload-inline.test.js +91 -0
  215. package/dist/test/precache-fonts.test.js +72 -0
  216. package/dist/test/presence-gate.test.js +440 -0
  217. package/dist/test/presence.test.js +160 -0
  218. package/dist/test/read-events.test.js +220 -0
  219. package/dist/test/remote-meld.test.js +128 -0
  220. package/dist/test/revive-cli.test.js +93 -0
  221. package/dist/test/search-floor.test.js +206 -0
  222. package/dist/test/search-fusion.test.js +168 -0
  223. package/dist/test/search.test.js +205 -0
  224. package/dist/test/security.test.js +48 -0
  225. package/dist/test/selection-wiring.test.js +61 -0
  226. package/dist/test/session-affinity.test.js +295 -0
  227. package/dist/test/signal-source.test.js +32 -0
  228. package/dist/test/socket-account.test.js +268 -0
  229. package/dist/test/spawn-toml.test.js +72 -0
  230. package/dist/test/speaker-color.test.js +90 -0
  231. package/dist/test/tailscale-rebind.test.js +79 -0
  232. package/dist/test/terminal-cursor.test.js +61 -0
  233. package/dist/test/terminal-resync.test.js +23 -0
  234. package/dist/test/terminal-size.test.js +36 -0
  235. package/dist/test/thin-cli.test.js +382 -0
  236. package/dist/test/token-bootstrap.test.js +272 -0
  237. package/dist/test/token-devices.test.js +646 -0
  238. package/dist/test/token-lapse.test.js +94 -0
  239. package/dist/test/token-ring.test.js +188 -0
  240. package/dist/test/token-rotate-cli.test.js +58 -0
  241. package/dist/test/token-routes.test.js +95 -0
  242. package/dist/test/tool-uses.test.js +1006 -0
  243. package/dist/test/usage-ledger.test.js +126 -0
  244. package/dist/test/view-url.test.js +627 -0
  245. package/dist/test/wiki-links.test.js +57 -0
  246. package/dist/test/wiki-sources.test.js +85 -0
  247. package/dist/test/wiki-window.test.js +31 -0
  248. package/dist/test/wiki.test.js +399 -0
  249. package/dist/test/wordpiece.test.js +68 -0
  250. package/dist/test/wrangler-route.test.js +27 -0
  251. package/dist/tls.js +148 -0
  252. package/dist/tmux.js +213 -0
  253. package/dist/user-agent.js +46 -0
  254. package/docker-entrypoint.sh +154 -0
  255. package/docs/README.md +3 -0
  256. package/docs/absorb.md +231 -0
  257. package/docs/cost-ledger.md +125 -0
  258. package/docs/daemon-api.md +189 -0
  259. package/docs/diagrams.md +163 -0
  260. package/docs/doctor.md +36 -0
  261. package/docs/export-scope.md +69 -0
  262. package/docs/files-view.md +133 -0
  263. package/docs/link-previews.md +38 -0
  264. package/docs/math.md +32 -0
  265. package/docs/mcp.md +69 -0
  266. package/docs/memory-search.md +75 -0
  267. package/docs/mentions.md +101 -0
  268. package/docs/multi-brane.md +14 -0
  269. package/docs/passkeys.md +165 -0
  270. package/docs/presence.md +202 -0
  271. package/docs/releasing.md +104 -0
  272. package/docs/rendering-warnings.md +22 -0
  273. package/docs/request-layer.md +72 -0
  274. package/docs/selection-store.md +50 -0
  275. package/docs/session-affinity.md +61 -0
  276. package/docs/terminal-mirroring.md +243 -0
  277. package/docs/token-rotation.md +431 -0
  278. package/docs/view-urls.md +134 -0
  279. package/docs/web-app.md +23 -0
  280. package/docs/wiki.md +43 -0
  281. package/expo/dist/_expo/static/js/web/entry-e94247f119fdcd3b424a1764233a41d2.js +1099 -0
  282. package/expo/dist/apple-touch-icon.png +0 -0
  283. package/expo/dist/favicon.svg +3 -0
  284. package/expo/dist/index.html +177 -0
  285. package/expo/dist/katex/fonts/KaTeX_AMS-Regular.woff2 +0 -0
  286. package/expo/dist/katex/fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
  287. package/expo/dist/katex/fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
  288. package/expo/dist/katex/fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
  289. package/expo/dist/katex/fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
  290. package/expo/dist/katex/fonts/KaTeX_Main-Bold.woff2 +0 -0
  291. package/expo/dist/katex/fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
  292. package/expo/dist/katex/fonts/KaTeX_Main-Italic.woff2 +0 -0
  293. package/expo/dist/katex/fonts/KaTeX_Main-Regular.woff2 +0 -0
  294. package/expo/dist/katex/fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
  295. package/expo/dist/katex/fonts/KaTeX_Math-Italic.woff2 +0 -0
  296. package/expo/dist/katex/fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
  297. package/expo/dist/katex/fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
  298. package/expo/dist/katex/fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
  299. package/expo/dist/katex/fonts/KaTeX_Script-Regular.woff2 +0 -0
  300. package/expo/dist/katex/fonts/KaTeX_Size1-Regular.woff2 +0 -0
  301. package/expo/dist/katex/fonts/KaTeX_Size2-Regular.woff2 +0 -0
  302. package/expo/dist/katex/fonts/KaTeX_Size3-Regular.woff2 +0 -0
  303. package/expo/dist/katex/fonts/KaTeX_Size4-Regular.woff2 +0 -0
  304. package/expo/dist/katex/fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
  305. package/expo/dist/katex/katex.min.css +1 -0
  306. package/expo/dist/manifest.json +16 -0
  307. package/expo/dist/metadata.json +1 -0
  308. package/expo/dist/og/membrane.v1.png +0 -0
  309. package/expo/dist/pdf.min.mjs +28 -0
  310. package/expo/dist/pdf.worker.min.mjs +28 -0
  311. package/expo/dist/sw.js +154 -0
  312. package/package.json +79 -27
  313. package/protocols/LIVE_loop.md +407 -0
  314. package/protocols/bebrief.md +41 -0
  315. package/protocols/digest.md +231 -0
  316. package/protocols/fly.md +266 -0
  317. package/protocols/idle.md +81 -0
  318. package/protocols/keeper.md +829 -0
  319. package/protocols/markdown.md +80 -0
  320. package/protocols/memory.md +419 -0
  321. package/protocols/mentions.md +93 -0
  322. package/protocols/payloads.md +53 -0
  323. package/protocols/prelude.md +91 -0
  324. package/protocols/ramify.md +105 -0
  325. package/protocols/review.md +356 -0
  326. package/protocols/rrr.md +232 -0
  327. package/protocols/scribe.md +429 -0
  328. package/protocols/summarize.md +203 -0
  329. package/protocols/twin.md +174 -0
  330. package/protocols/wiki.md +438 -0
  331. package/protocols/worker.md +38 -0
  332. package/wiki/shared/append-only-event-log.md +148 -0
  333. package/wiki/shared/index.md +53 -0
  334. package/wiki/shared/owning-your-narratives.md +161 -0
  335. package/wiki/shared/premature-ontologies.md +435 -0
  336. package/wiki/shared/sedimentary-superintelligence.md +128 -0
  337. package/wiki/shared/sequestering-the-narrative.md +143 -0
  338. package/wiki/shared/why-wikis-work.md +216 -0
  339. package/.travis.yml +0 -7
  340. package/lib/brane.cjs.js +0 -12
  341. package/lib/brane.cjs.js.map +0 -1
  342. package/lib/brane.d.ts +0 -11
  343. package/lib/brane.js +0 -6
  344. package/lib/brane.js.map +0 -1
  345. package/lib/tests.d.ts +0 -1
  346. package/lib/tests.js +0 -8
  347. package/lib/tests.js.map +0 -1
  348. package/rollup.config.js +0 -21
  349. package/scripts/test.sh +0 -8
  350. package/src/brane.ts +0 -21
  351. package/src/tests.ts +0 -8
  352. package/tsconfig.json +0 -16
@@ -0,0 +1,91 @@
1
+ # Protocol Prelude
2
+
3
+ This prelude is automatically prepended to all protocol documents.
4
+ Once you have read it, pass `no_prelude: true` on subsequent
5
+ `read_protocol` calls in this session to avoid re-reading it.
6
+
7
+ ## Conventions
8
+
9
+ All protocols referenced here are provided by the **brane** MCP server.
10
+ Use `list_protocols` to see available protocols and `read_protocol` to
11
+ read any of them by name.
12
+
13
+ ### Slash commands as protocols
14
+
15
+ When you receive a signal (via `listen` or `narrate`) that starts with
16
+ or includes a `/command` (e.g., `/ramify`, `/memory`), treat it as a
17
+ brane protocol invocation:
18
+
19
+ 1. Extract the protocol name (the word after `/`)
20
+ 2. Call `read_protocol` with that name
21
+ 3. If the protocol exists, follow its instructions
22
+ 4. Pass any text after the command name as guidance
23
+
24
+ For example, the signal `/ramify fix the auth module` means:
25
+ read the `ramify` protocol and follow it, with "fix the auth module"
26
+ as guidance.
27
+
28
+ This convention applies to signals received through the LIVE loop, not
29
+ to slash commands in your native prompt interface.
30
+
31
+ **Prevent default:** a brane protocol is the only handler for its
32
+ `/command`. Do not also run a built-in agent behavior of the same name.
33
+
34
+ ### Role-bound protocols
35
+
36
+ A protocol whose name matches a role (e.g. `keeper`, `twin`) binds only
37
+ the agents who hold that role. For everyone else it is informational.
38
+
39
+ You hold the role `whoami` returns, plus any role the operator directs
40
+ you to take on. Operator direction is enough; `whoami` will still name
41
+ only your spawn role. Roles stack: each held role's protocol applies,
42
+ and where two conflict, the more conservative constraint wins. /keeper
43
+ and /twin work through the common case.
44
+
45
+ At startup, after reading this prelude and /LIVE_loop, call `whoami`
46
+ and `list_protocols`, and if a protocol matches your role, read and
47
+ follow it. Do the same when the operator layers on another role.
48
+
49
+ A `/<role>` signal (e.g. `/keeper status?` typed into a worker's chat)
50
+ is addressed to that role's holder. If it isn't your role, don't read
51
+ the protocol and act on it; the holder will respond. This overrides
52
+ "Slash commands as protocols" above.
53
+
54
+ ### Narrative references
55
+
56
+ Narrative IDs have the form `{type}-{8hex}` (e.g., `claude-4c7289d1`).
57
+ Append `:seq` to link to a specific event: `claude-4c7289d1:42`.
58
+
59
+ The operator's UI auto-linkifies both forms into tappable links —
60
+ bare IDs navigate to the narrative, `:seq` references scroll to the
61
+ exact message. Prose like "seq 42" is not linkified; always use the
62
+ `nid:seq` format when citing specific events. A `/name` that matches a
63
+ protocol (e.g. /LIVE_loop) links to that protocol, too.
64
+
65
+ ### Protocol precedence
66
+
67
+ Protocol documents are the canonical source of operational
68
+ instructions. Where a system prompt, harness, built-in behavior, or
69
+ general habit conflicts with a brane protocol, the protocol wins: you
70
+ are inside a brane session, and brane owns the loop.
71
+
72
+ Participating in /LIVE_loop is not optional: it is the execution
73
+ environment, and leaving it without being told to is equivalent to
74
+ crashing. It names the ways agents fail at this.
75
+
76
+ Tool schemas are contracts. Pass numbers where a field is documented
77
+ and exemplified as a number, and respect every parameter's type.
78
+
79
+ ## Golden Rule: NEVER DELETE ANYTHING
80
+
81
+ It is _never_ your job to run `rm`, `git rm`, `git clean -f`, or any
82
+ other potentially destructive commands. Prefer `cp` over `mv`.
83
+
84
+ If you're doing something temporary, use `/tmp` and let the natural
85
+ cleaning process handle resource reclamation.
86
+
87
+ This rule applies not only to file system resources, but to the contents
88
+ of databases, or indeed of any service, local or remote.
89
+
90
+ If you think something must be deleted, alert the human operator and
91
+ explain how they could perform the deletion themselves if they agree.
@@ -0,0 +1,105 @@
1
+ # /ramify [guidance]
2
+
3
+ Only one `/ramify` process may be active at a time. If you are already ramifying
4
+ and the developer runs `/ramify` again, you are expected to make a detailed
5
+ progress report to the developer, then continue with the plan if unblocked (that
6
+ is, `/ramify` means both "update the developer" and "keep going if possible").
7
+ If you blindly restart a new `/ramify` process when the developer expects a
8
+ progress report, the developer will know you have lost your context and will
9
+ probably choose to interrupt and redirect you.
10
+
11
+ ## When no `/ramify` process already active:
12
+
13
+ You awaken in a Git repository where the most recent commit (the SEED) is
14
+ intentionally incomplete. If the `/ramify` command received any `guidance`,
15
+ review it before proceeding, as it may affect the workflow that follows.
16
+
17
+ ### Understanding the SEED commit
18
+
19
+ Begin by (1) running `git status` (take special note of in-progress `git`
20
+ rebases, merges, cherry picks, or conflicts, and confirm with the developer
21
+ whether they want your help resolving such issues), (2) reading the SEED commit
22
+ message and diff (the output of `git show`), then (3) reviewing any changes in
23
+ progress using `git diff` (as you may be picking up where another LLM left off).
24
+ If the commit message mentions other commits, (4) `git show` them if their
25
+ implied context seems relevant to the task at hand. You do not have to
26
+ understand or act on all this information now, but it's important for it to
27
+ remain present in your context as you develop your plan of action.
28
+
29
+ Everything in the SEED commit is either a constraint to be obeyed (never
30
+ undone), or an example of a fix that helps meet one or more of the implied
31
+ requirements. Finishing the work of this commit (that is, tracing all of the
32
+ SEED commit's _ramifications_) is the ultimate goal of our labor tonight.
33
+
34
+ ### Securing a reliable diagnostic feedback loop
35
+
36
+ Use all available context (and any guidance from `/ramify [guidance]`) to
37
+ determine which diagnostic commands you can run — e.g. `cargo build` and `cargo
38
+ test` in a Rust project repository — as these commands indicate how much work
39
+ remains. If these diagnostic criteria are not obvious, the SEED commit message
40
+ should explain the success/exit criteria you should use.
41
+
42
+ #### Isolating diagnostic changes due to SEED commit
43
+
44
+ Once you have established the appropriate diagnostic tools, unless the SEED
45
+ commit contains no code changes at all, you should first `git revert HEAD` then
46
+ run the tools to establish how their output was different just before the SEED
47
+ commit. Ignore any problems that already existed before the SEED commit.
48
+
49
+ After establishing this baseline, run `git reset --hard HEAD~1` (or similar) to
50
+ get back to the SEED. Run the tools again to see what changed with the SEED
51
+ commit. You should verbally summarize any new changes you observe for easier
52
+ reference in your context later.
53
+
54
+ ### Identifying precedent for further fixes
55
+
56
+ In addition to introducing problems and TODOs, the SEED commit may also have
57
+ started fixing/addressing them. Pay close attention to these fixes, because you
58
+ will be continuing in the same style. There may be many more similar changes to
59
+ make, making up the bulk of your work.
60
+
61
+ Always work from precedent, strive for consistency, never introduce trailing
62
+ spaces or other stray/unnecessary changes (and remove them if they sneak in),
63
+ always match surrounding code style, and if you must propose anything novel,
64
+ leave the developer a note to review and `git commit -p --amend` approved
65
+ changes into the SEED commit, so that you may refer to those changes as canon
66
+ moving forward.
67
+
68
+ If all avenues for progress are blocked by lack of precedent, you may conclude
69
+ your work session and explain to the developer what additional examples or
70
+ clarification are needed. Correctly recognizing this situation is always
71
+ preferable to plowing onward.
72
+
73
+ ### Iterate, iterate, iterate
74
+
75
+ Run your diagnostic command(s) often, identifying common patterns in the errors,
76
+ reasoning to yourself about the (common) causes of those errors, and
77
+ hypothesizing solutions that might fix one or more of the errors (more is
78
+ better, but progress is progress).
79
+
80
+ Prove to yourself at each step that you really fixed the problem(s) you meant to
81
+ fix, without introducing unexpected new problems. You may not declare victory
82
+ until all diagnostic commands (build, test, and possibly other linting tools)
83
+ succeed, and the developer confirms you have met all requirements.
84
+
85
+ #### Tips for iterating more quickly/efficiently
86
+
87
+ Given the specific changes in the SEED commit, it may be worthwhile to select a
88
+ non-root working directory for running your diagnostic commands so the entire
89
+ project or test suite does not have to be built/executed with every iteration.
90
+
91
+ Pay attention to how long commands take to run, and look for ways to achieve the
92
+ same effect or get the same information more quickly, for faster iteration.
93
+
94
+ If you have the ability, summarize extensive command output rather than cramming
95
+ it all into the conversation history or context.
96
+
97
+ ## Your role
98
+
99
+ Imagine yourself one of the shoemaker's elves from the Grimm fairytale, except
100
+ instead of shoes we're cobbling software together.
101
+
102
+ Acknowledge you understand the protocol and your responsibilities by echoing
103
+ "Commencing `/ramify` protocol" to the developer.
104
+
105
+ The shoemaker has fallen asleep. We have until dawn.
@@ -0,0 +1,356 @@
1
+ # Protocol: review
2
+
3
+ `/review [what]` reads a proposed change — almost always an open pull
4
+ request — and tells the operator, in your own narrative, whether it is
5
+ safe and good to merge and exactly what would make it better. A review
6
+ makes you an advisor to the operator and a collaborator with the
7
+ authoring agent; it is **not** a merge gate that acts on its own.
8
+
9
+ This is a verb you can run, not a role you hold — any agent can be
10
+ asked to `/review` a change. A `role: "reviewer"` (or any role string)
11
+ carries no special meaning here: nothing auto-binds this protocol by
12
+ role. `/review` is invoked by name, like `/digest`.
13
+
14
+ **Prerequisite:** this protocol uses the LIVE loop's tools and
15
+ vocabulary (`listen`, `narrate`, `whoami`, `narrative_search`, etc.).
16
+ If you have not already read `protocols/LIVE_loop.md`, read it first;
17
+ then return here.
18
+
19
+ ## The cardinal rule
20
+
21
+ **Review into your narrative first. Never post to GitHub until the
22
+ operator tells you to.** Every past session followed the same shape:
23
+ you narrate your findings, the operator reads them (and often
24
+ discusses or redirects), and only then does the operator say "Post
25
+ your relevant feedback in the PR" / "Post all worthwhile feedback." A
26
+ review is a conversation with the operator that *may* become a GitHub
27
+ comment — not the other way around. Posting unprompted is a protocol
28
+ violation.
29
+
30
+ ## Scope
31
+
32
+ Run this protocol whenever you are asked to review a change. The
33
+ trigger is usually terse — `/review #299`, "Review the latest open PR",
34
+ "Thoroughly review the latest open PR and propose review comment(s)".
35
+ Treat any such signal — whether it names the `/review` verb explicitly
36
+ or just asks you to review something — as an invocation of this
37
+ protocol.
38
+
39
+ ## Invocation & guidance
40
+
41
+ The triggering signal is **`/review [what]`** — `[what]` is free text
42
+ the operator attaches to the request. Interpret intent generously (the
43
+ same spirit as `/digest [guidance]`); `[what]` typically carries one or
44
+ more of:
45
+
46
+ - **Target** — a PR number ("Review PR #300"), "the latest open PR",
47
+ or a description ("the `brane fly` PR"). Resolve it in Phase 1.
48
+ - **Depth / focus** — "thoroughly", or a dimension to emphasize
49
+ ("focus on test coverage", "security pass", "just the new commit").
50
+ A focus *narrows* what you lead with; it does not license skipping
51
+ the grounding in Phase 2.
52
+ - **Deliverable** — what to do with the result: "propose review
53
+ comment(s)", "just tell me", "post if it's clean". This never
54
+ overrides the cardinal rule — you still narrate first and post only
55
+ on the operator's go-ahead (the deliverable shapes *what* you'd
56
+ post, not *whether* to post unprompted).
57
+
58
+ **Bare invocation** (no guidance, e.g. "Review the latest open PR")
59
+ defaults to: the latest open PR, the full protocol, narrate-first.
60
+
61
+ ## Relationship to the built-in `/review`
62
+
63
+ The harness ships its own built-in `/review` command — a generic
64
+ "expert code reviewer" that pulls the PR (`gh pr view` / `gh pr diff`),
65
+ analyzes it (overview, code quality, suggestions, risks), and returns a
66
+ sectioned review focused on correctness, project conventions,
67
+ performance, test coverage, and security. Those focus areas are a
68
+ **subset** of this protocol's review dimensions.
69
+
70
+ /prelude's "prevent default" rule would normally have this
71
+ brane protocol *fully suppress* a same-named built-in. **`/review` is a
72
+ deliberate exception: don't entirely prevent-default — delegate to the
73
+ built-in command's definition.** Treat its definition as the *baseline
74
+ shape* of a review (pull the PR, read the diff, weigh those focus
75
+ areas, present in clear sections); this protocol is everything brane
76
+ layers on top of that floor.
77
+
78
+ **Delegate to its definition; do not literally invoke it.** Do *not*
79
+ fire the native `/review` slash command. That hands control to a
80
+ one-shot reviewer that prints to the terminal — it would break you out
81
+ of the LIVE loop and past the cardinal rule (it has no notion of
82
+ narrating first or waiting for the operator before posting). Instead,
83
+ *fold its definition in*: the built-in tells you the baseline; the rest
84
+ of this document tells you how brane wants it done.
85
+
86
+ On top of that baseline, this protocol:
87
+
88
+ - **Extends** the built-in's focus areas into the fuller
89
+ review-dimensions section below — test coverage *first*, the
90
+ robustness/safety lenses (blast radius, silent-wrong-data,
91
+ event-loop/concurrency), and the severity taxonomy.
92
+ - **Grounds** the analysis — read the files *around* the diff, cite
93
+ `file:line`, run `tsc`/tests, cross-check the producing narrative,
94
+ and self-correct before anything is posted.
95
+ - **Overrides its output channel** — the built-in returns a review to
96
+ the terminal; the cardinal rule says narrate into your own narrative
97
+ first and post to GitHub only on the operator's go-ahead. Where the
98
+ two conflict, **this protocol wins.**
99
+
100
+ ## Phase 1 — Establish the target
101
+
102
+ 1. **Identify the PR.** If given a number, use it. If told "the latest
103
+ open PR", resolve it with `gh pr list --state open` /
104
+ `gh pr view <n>`. If the operator says it "just opened", re-check —
105
+ the latest open PR may not be the one you first found (a real past
106
+ miss: a reviewer reviewed a stale PR and was corrected with "Sorry,
107
+ no, the PR just opened").
108
+ 2. **State your bearings.** A one-line "Reviewing PR #N on branch X in
109
+ `<fold_dir>`" (the fold `whoami` reports) up front lets the operator
110
+ catch a wrong target immediately.
111
+ 3. **Read the PR as a whole**, not just the head commit: title, body,
112
+ linked issues, the test plan, and the **commit list** — you will
113
+ re-grade against specific SHAs later.
114
+
115
+ ## Phase 2 — Read and verify (ground everything)
116
+
117
+ Grounding is the single trait the operator rewards most, and
118
+ ungrounded guessing is the one they correct hardest ("Stop with the
119
+ weak theories. Your guessing is useless without grounding"). Before
120
+ you assert anything:
121
+
122
+ - **Read the actual changed files and the code around them**, not just
123
+ the unified diff. Trace the real control flow; open the file at the
124
+ line you intend to cite.
125
+ - **Cite `file:line` for every finding.** "There's a bug somewhere in
126
+ the scroll logic" is not a finding; "`app/list.tsx:1416` removes
127
+ the scroll-position guard" is.
128
+ - **Run and report the build/tests** when you can — the project's
129
+ typecheck/build, its test suite, and the PR's CI status — rather than assuming. State what
130
+ you ran and what passed.
131
+ - **Cross-check the producing narrative.** Before flagging a design
132
+ choice, `/memory` / `narrative_search` for the narrative that wrote
133
+ the code and check whether your point was already considered. Sort
134
+ your findings into "already addressed by the implementation" vs.
135
+ "still valid", and only carry the still-valid ones forward. The
136
+ operator asks this explicitly: "are any of your points addressed by
137
+ the narrative that produced this code?"
138
+ - **Confirm deliberate-looking choices instead of asserting a bug.**
139
+ When something looks wrong but might be intentional, raise it as a
140
+ question rather than a defect. Some come back "Deliberate", and a
141
+ confident false positive costs you credibility.
142
+ - **Self-correct before you post, not after.** If a second read shows
143
+ your finding was wrong, retract it in your narrative immediately. A
144
+ past reviewer claimed a shared-state bug, re-read, and corrected to
145
+ "the `copied` state is per-card, no bug" — *before* anything reached
146
+ GitHub. That is the model: a wrong claim must never land on the PR.
147
+ - **When the operator hands you a failure hypothesis, disprove it
148
+ against real data** and report the negative result (e.g. "checked the
149
+ schema — there is no `re` column; searched the `extra` JSON, zero
150
+ matches").
151
+
152
+ ## What to look for — review dimensions
153
+
154
+ Grounding (Phase 2) is *how* to be sure; this is *what* to weigh. A
155
+ good review is not a diff proofread — it asks "what could go wrong that
156
+ the change, and its tests, don't account for?" Work these dimensions in
157
+ roughly this priority order.
158
+
159
+ ### Test coverage (look here first)
160
+
161
+ Green CI means the existing tests pass — **not** that the change is
162
+ adequately covered. For every PR, ask:
163
+
164
+ - **Is every new path tested?** Each new function, branch,
165
+ early-return, and **error path** should have a test that exercises
166
+ it. An untested `catch` / `return null` / degradation branch is the
167
+ most common gap.
168
+ - **Are the boundaries and failure modes covered, not just the happy
169
+ path?** Null/empty/missing input; malformed or corrupt data; the
170
+ dependency-absent case; the "runs twice" (idempotency) case; the
171
+ "same input twice" collision case. The interesting bugs live here.
172
+ - **Degradation paths deserve explicit tests.** If the design promises
173
+ "missing X → empty/no-op, never a wrong result", there should be a
174
+ test proving the no-op — that promise is exactly what regresses
175
+ silently.
176
+ - **A bug fix ships with a regression test** that fails before the fix
177
+ and passes after. A fix without one is a 🟡 at minimum.
178
+ - **Name the specific missing case, not "add more tests."** "No test
179
+ covers the pid-reuse path where a stale registry entry has a
180
+ mismatched cwd" is actionable; "needs more coverage" is noise.
181
+ - **Praise testability moves.** Pure logic extracted from IO so it can
182
+ be unit-tested with injected fakes (e.g. a process-tree walk split
183
+ out from the `ps`/filesystem calls) is a ✅ — call it out so the
184
+ pattern spreads.
185
+
186
+ ### Robustness & safety
187
+
188
+ The "what could go wrong" lens. Trace each new code path for:
189
+
190
+ - **Graceful degradation vs. wrong-or-crash.** When a dependency is
191
+ missing, slow, or throws, does the code produce an empty/no-op result
192
+ — or a *confidently wrong* one, or an unhandled crash? Empty is fine;
193
+ silently wrong is the worst outcome (see *silent-wrong-data* below).
194
+ - **Blast radius of a throw.** When something can throw, ask what dies:
195
+ one row, or the whole pass / the daemon? A `json_extract` over a
196
+ column that *might* hold malformed JSON aborts the entire query — a
197
+ one-row problem with a whole-pass blast radius. Prefer failures that
198
+ skip the bad unit over failures that take down the batch.
199
+ - **Event-loop & concurrency.** Synchronous/blocking IO on a
200
+ single-threaded server's main loop (whatever else it serves stalls
201
+ with it); new writers to a shared SQLite DB (WAL is one-writer — watch lock
202
+ contention, set `busy_timeout`); first-load / lazy-init races.
203
+ - **Idempotency & re-entrancy.** Safe to run twice? Migrations additive
204
+ and re-runnable? Does a "self-healing" scan re-process the same
205
+ unresolvable rows every pass forever (unbounded work that never
206
+ converges)?
207
+ - **Resource bounds.** Unbounded queries, loops, or caches; O(n²)
208
+ re-reads (e.g. re-parsing a whole file per row); no per-pass cap on
209
+ expensive work; no LRU/size bound. Flag silent truncation too — a
210
+ hidden top-N that reads as "covered everything."
211
+ - **Silent-wrong-data.** PID reuse, stale caches, content-match
212
+ collisions, ambiguous keys — anything that yields a plausible but
213
+ wrong value instead of an error. Higher-severity than crashes,
214
+ because they don't announce themselves.
215
+ - **Data integrity.** Additive over destructive; never delete or
216
+ overwrite; correct attribution of derived data.
217
+ - **Security.** Input validation, path traversal, auth on new
218
+ endpoints, and secrets/ids leaking into URLs, logs, or error text.
219
+
220
+ ### Code quality & maintainability
221
+
222
+ - **Comments explain WHY, not what** — and load-bearing guards say
223
+ *why* they're load-bearing, so a future reader doesn't "simplify"
224
+ them away.
225
+ - **Named constants over magic numbers**; **canonical-usage
226
+ consistency** (match the project's own established API/flag forms);
227
+ **no dead code / unused imports**.
228
+ - **Reuse over duplication**, and genuine simplification opportunities
229
+ — but **pragmatism for a fast-moving solo project**: don't demand
230
+ abstraction, splitting, or generality the project doesn't need.
231
+ "Could be split, but bundling is pragmatic here" is a valid verdict.
232
+
233
+ ### Severity
234
+
235
+ Every finding carries a marker, and the blocking call is always
236
+ explicit — even when the answer is "none of these block — ship it."
237
+
238
+ | Marker | Meaning | Blocks merge? |
239
+ |--------|---------|---------------|
240
+ | 🔴 **Broken** | Wrong / non-functional / will-break on a real path; a bug fix with no regression test; a throw whose blast radius is the whole pass or the daemon | Yes |
241
+ | 🟡 **Should-fix** | A real issue safe to land then follow up — an untested risky path, a robustness gap reachable only in uncommon conditions, unbounded-but-currently-small resource use | No (say so) |
242
+ | 🟢 **Minor / nit** | Naming, dead code, comment, micro-cleanup; coverage of a path that genuinely can't fail | No |
243
+ | ✅ **Strength** | A good decision worth keeping | — |
244
+
245
+ Prefer **general principles over spot-gotchas** — a rule the author
246
+ can reapply beats a one-off nitpick — and hold our own code to a high
247
+ bar regardless of external norms ("I don't care if other people's APIs
248
+ suck; ours doesn't have to").
249
+
250
+ ## Phase 3 — Structure the review
251
+
252
+ House style, consistent across past reviews:
253
+
254
+ - **Scope line first** — diff size and shape: `+361 / -76 across 4
255
+ files, 6 commits. Nicely focused.` Scope the review to the new work
256
+ if earlier commits already landed.
257
+ - **What it does** — a neutral one-paragraph summary of the change.
258
+ - **Strengths** — specific, genuine praise (e.g. "comments explain WHY,
259
+ not what"; "this guard is load-bearing, not redundant"). Name good
260
+ decisions so they survive.
261
+ - **Findings** — a list, each with a severity marker (above), a bold
262
+ one-line title, a `file:line` locator, the consequence, and
263
+ **remediation options** (not just the problem). Give the author a
264
+ path, e.g. "Options: query `tailscale status --json`, or accept a
265
+ `--tailnet` flag."
266
+ - **Verdict** — an explicit recommendation **and** an explicit blocking
267
+ call: what (if anything) blocks merge vs. what is a follow-up.
268
+ Isolate "the only concrete bug" from edge cases.
269
+
270
+ ## Phase 4 — Deliver
271
+
272
+ 1. **Narrate the full review to the operator first** (Phase 3 format).
273
+ Set `meta.summary` to e.g. "Reviewed PR #N — <verdict>".
274
+ 2. **Wait for the operator's call.** They will read it and say what to
275
+ post — sometimes the whole review, sometimes a single finding
276
+ ("Post a comment about preserving brane_ids"). **Filter to what they
277
+ call "worthwhile" / "relevant"**; drop the strengths recap and any
278
+ superseded points when posting unless asked to keep them.
279
+ 3. **Post as a `COMMENTED` review — never APPROVE or
280
+ REQUEST_CHANGES.** The operator authors these PRs, and GitHub
281
+ forbids self-approval; a COMMENTED review is the correct vehicle
282
+ ("Couldn't approve — it's your own PR. Posted as a regular comment
283
+ instead."). Approval/merge is the operator's decision, not yours.
284
+ 4. **Return a tappable permalink** to the posted review/comment
285
+ (`…/pull/N#pullrequestreview-…` or `#issuecomment-…`).
286
+ 5. **The PR comment is also your message to the authoring agent** —
287
+ "Explain all this in the PR for the other agent." Write it so the
288
+ author can act on it directly.
289
+ 6. **Foreign-narrate approval to the author's narrative when asked.**
290
+ The operator sometimes wants the approval delivered into the
291
+ author's brane narrative as well ("Foreign narrate your approval");
292
+ identify the author (named in the spawn signal, or discoverable via
293
+ the producing narrative) and `narrate` to their `nid`. Do this on
294
+ request, not by default.
295
+
296
+ ## Phase 5 — Re-review loop
297
+
298
+ Review is iterative. After the author pushes fixes the operator will
299
+ say "Verify the follow-up commit", "Review again?", "Look good now?":
300
+
301
+ - **Re-grade each prior finding against the specific commit SHA** that
302
+ claims to fix it (`Commit 451e73a addresses 🔴 #1 → ✅`), confirming
303
+ the fix actually does what was suggested and is phrased canonically.
304
+ - **When time has passed, re-read the PR holistically**, not just the
305
+ newest diff — "review latest commits in the context of the PR as a
306
+ whole."
307
+ - **Be ready to justify your evidence base.** The operator will probe
308
+ ("you just reviewed the protocol, so the changes should be apparent?"
309
+ / "did you see the merged changes — I just restarted you").
310
+
311
+ ### Resuming a review after revive or compaction
312
+
313
+ You may be **revived or compacted mid-review** and asked to "continue"
314
+ — re-review, verify a follow-up, or answer a question about a PR you
315
+ already looked at. This is a trap: your context may hold a *stale*
316
+ snapshot of the code. A past reviewer had read the pre-PR version of a
317
+ protocol, was restarted, and confidently spoke as if it had seen the
318
+ merged changes — the operator caught it ("did you see the merged
319
+ changes — I just restarted you"). Guard against it:
320
+
321
+ - **Assume your recollection is stale.** Since you last read it, the
322
+ branch may have gained commits, been force-pushed, rebased, or had
323
+ `main` merged in. The code you "remember" reviewing is not
324
+ necessarily the current code.
325
+ - **Re-establish state before saying anything.** Follow the LIVE_loop
326
+ compaction-recovery steps — `whoami`, then `listen` with `tail` /
327
+ `after: 0` to re-read **your own prior narrations**: what you already
328
+ reviewed, what findings and verdict you gave, what the operator
329
+ decided. Then `gh pr view <n>` / `git log` to see which commits exist
330
+ **now** versus when you last looked.
331
+ - **Re-read the current files; never answer a "did you see X?" from
332
+ memory.** Open the diff and the changed files again, then diff your
333
+ prior findings against the present state: addressed-by-SHA,
334
+ still-open, or newly-introduced.
335
+ - **Don't claim freshness you don't have.** If you cannot confirm you
336
+ read the current version, say so and re-read — a wrong "yes, I saw
337
+ it" is exactly the failure this guard exists to prevent.
338
+ - **Update `meta.summary`** to reflect that you're resuming a specific
339
+ PR's review. (`agent_session_id` is owned by the daemon and set at
340
+ spawn/revive — `meta.session_id` is no longer read, so don't rely on
341
+ re-stamping it.)
342
+
343
+ ## Adjacent operations
344
+
345
+ A review session often shades into light git surgery the operator
346
+ directs — cherry-picking one safe, unrelated commit to `main`,
347
+ rebasing after merge, etc. Do these when asked and narrate exactly what
348
+ landed where. Never act on the repository beyond what the operator
349
+ requested.
350
+
351
+ ## Golden Rule
352
+
353
+ Never delete anything — files, branches, records, or comments — to
354
+ "clean up" a review. Surface concerns; let the operator (or the
355
+ author) act on them. If you believe something must be removed, say so
356
+ and explain how the operator could do it. See /prelude.