opensquid 0.5.432 → 0.5.447

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 (440) hide show
  1. package/README.md +1 -0
  2. package/dist/functions/arm_scope.d.ts +27 -0
  3. package/dist/functions/arm_scope.d.ts.map +1 -0
  4. package/dist/functions/arm_scope.js +52 -0
  5. package/dist/functions/arm_scope.js.map +1 -0
  6. package/dist/functions/event.d.ts.map +1 -1
  7. package/dist/functions/event.js +18 -2
  8. package/dist/functions/event.js.map +1 -1
  9. package/dist/functions/index.d.ts +4 -0
  10. package/dist/functions/index.d.ts.map +1 -1
  11. package/dist/functions/index.js +4 -0
  12. package/dist/functions/index.js.map +1 -1
  13. package/dist/functions/inject_context.d.ts +18 -0
  14. package/dist/functions/inject_context.d.ts.map +1 -0
  15. package/dist/functions/inject_context.js +16 -0
  16. package/dist/functions/inject_context.js.map +1 -0
  17. package/dist/functions/procedure_pre_inject.d.ts +23 -0
  18. package/dist/functions/procedure_pre_inject.d.ts.map +1 -0
  19. package/dist/functions/procedure_pre_inject.js +49 -0
  20. package/dist/functions/procedure_pre_inject.js.map +1 -0
  21. package/dist/functions/registry.d.ts +6 -0
  22. package/dist/functions/registry.d.ts.map +1 -1
  23. package/dist/functions/registry.js.map +1 -1
  24. package/dist/functions/rubric_pre_inject.d.ts.map +1 -1
  25. package/dist/functions/rubric_pre_inject.js +2 -1
  26. package/dist/functions/rubric_pre_inject.js.map +1 -1
  27. package/dist/functions/set_request_type.d.ts +11 -0
  28. package/dist/functions/set_request_type.d.ts.map +1 -0
  29. package/dist/functions/set_request_type.js +34 -0
  30. package/dist/functions/set_request_type.js.map +1 -0
  31. package/dist/functions/shell_parse.d.ts +1 -0
  32. package/dist/functions/shell_parse.d.ts.map +1 -1
  33. package/dist/functions/shell_parse.js +22 -4
  34. package/dist/functions/shell_parse.js.map +1 -1
  35. package/dist/packs/loader.d.ts.map +1 -1
  36. package/dist/packs/loader.js +26 -0
  37. package/dist/packs/loader.js.map +1 -1
  38. package/dist/runtime/bootstrap.d.ts.map +1 -1
  39. package/dist/runtime/bootstrap.js +6 -0
  40. package/dist/runtime/bootstrap.js.map +1 -1
  41. package/dist/runtime/fsm_state.d.ts +6 -0
  42. package/dist/runtime/fsm_state.d.ts.map +1 -1
  43. package/dist/runtime/fsm_state.js +14 -0
  44. package/dist/runtime/fsm_state.js.map +1 -1
  45. package/dist/runtime/handoff/render.d.ts +5 -4
  46. package/dist/runtime/handoff/render.d.ts.map +1 -1
  47. package/dist/runtime/handoff/render.js +7 -7
  48. package/dist/runtime/handoff/render.js.map +1 -1
  49. package/dist/runtime/handoff/stranded_scoping.d.ts +21 -0
  50. package/dist/runtime/handoff/stranded_scoping.d.ts.map +1 -0
  51. package/dist/runtime/handoff/stranded_scoping.js +39 -0
  52. package/dist/runtime/handoff/stranded_scoping.js.map +1 -0
  53. package/dist/runtime/hooks/active_task_mirror.js +0 -0
  54. package/dist/runtime/hooks/apply_patch.js +0 -0
  55. package/dist/runtime/hooks/dispatch.d.ts.map +1 -1
  56. package/dist/runtime/hooks/dispatch.js +3 -0
  57. package/dist/runtime/hooks/dispatch.js.map +1 -1
  58. package/dist/runtime/hooks/hook_output.js +0 -0
  59. package/dist/runtime/hooks/memory_reconcile.js +0 -0
  60. package/dist/runtime/hooks/new_project_detect.js +0 -0
  61. package/dist/runtime/hooks/profession_resolver.js +0 -0
  62. package/dist/runtime/hooks/scope_intent.js +0 -0
  63. package/dist/runtime/hooks/session-start.js +17 -0
  64. package/dist/runtime/hooks/session-start.js.map +1 -1
  65. package/dist/runtime/hooks/session_id.js +0 -0
  66. package/dist/runtime/hooks/session_liveness.js +0 -0
  67. package/dist/runtime/hooks/stop_drive.js +0 -0
  68. package/dist/runtime/hooks/stop_stream.js +0 -0
  69. package/dist/runtime/hooks/subagent_guard.js +0 -0
  70. package/dist/runtime/hooks/transcript.js +0 -0
  71. package/dist/runtime/hooks/transcript_tasks.js +0 -0
  72. package/dist/runtime/hooks/user-prompt-submit.d.ts.map +1 -1
  73. package/dist/runtime/hooks/user-prompt-submit.js +22 -1
  74. package/dist/runtime/hooks/user-prompt-submit.js.map +1 -1
  75. package/dist/runtime/ralph/orchestrator.d.ts.map +1 -1
  76. package/dist/runtime/ralph/orchestrator.js +2 -1
  77. package/dist/runtime/ralph/orchestrator.js.map +1 -1
  78. package/dist/runtime/request_type.d.ts +33 -0
  79. package/dist/runtime/request_type.d.ts.map +1 -0
  80. package/dist/runtime/request_type.js +38 -0
  81. package/dist/runtime/request_type.js.map +1 -0
  82. package/dist/runtime/session_state.d.ts +11 -0
  83. package/dist/runtime/session_state.d.ts.map +1 -1
  84. package/dist/runtime/session_state.js +30 -0
  85. package/dist/runtime/session_state.js.map +1 -1
  86. package/dist/runtime/types.d.ts +5 -0
  87. package/dist/runtime/types.d.ts.map +1 -1
  88. package/dist/runtime/types.js +3 -0
  89. package/dist/runtime/types.js.map +1 -1
  90. package/dist/setup/cli/limits_state.d.ts.map +1 -1
  91. package/dist/setup/cli/limits_state.js +6 -40
  92. package/dist/setup/cli/limits_state.js.map +1 -1
  93. package/dist/setup/cli/pack_walk.d.ts +32 -0
  94. package/dist/setup/cli/pack_walk.d.ts.map +1 -0
  95. package/dist/setup/cli/pack_walk.js +76 -0
  96. package/dist/setup/cli/pack_walk.js.map +1 -0
  97. package/dist/setup/cli/permissions_state.d.ts.map +1 -1
  98. package/dist/setup/cli/permissions_state.js +6 -37
  99. package/dist/setup/cli/permissions_state.js.map +1 -1
  100. package/dist/setup/cli/triggers_state.d.ts.map +1 -1
  101. package/dist/setup/cli/triggers_state.js +3 -29
  102. package/dist/setup/cli/triggers_state.js.map +1 -1
  103. package/dist/workgraph/events.d.ts.map +1 -1
  104. package/dist/workgraph/events.js +10 -0
  105. package/dist/workgraph/events.js.map +1 -1
  106. package/dist/workgraph/store.d.ts.map +1 -1
  107. package/dist/workgraph/store.js +5 -0
  108. package/dist/workgraph/store.js.map +1 -1
  109. package/dist/workgraph/types.d.ts +2 -1
  110. package/dist/workgraph/types.d.ts.map +1 -1
  111. package/docs/ARCHITECTURE.md +268 -0
  112. package/docs/pack-runtime.md +26 -10
  113. package/package.json +5 -3
  114. package/packs/builtin/coding-flow/procedure.md +43 -0
  115. package/packs/builtin/coding-flow/skills/entry-and-handoffs/skill.yaml +49 -6
  116. package/packs/builtin/coding-flow/skills/pause-stop-guard/skill.yaml +11 -1
  117. package/packs/builtin/default-discipline/manifest.yaml +15 -6
  118. package/packs/builtin/pack-architect/skills/skill-yaml-author-walkthrough/skill.yaml +8 -0
  119. package/dist/anti-drift/evaluator.d.ts +0 -88
  120. package/dist/anti-drift/evaluator.d.ts.map +0 -1
  121. package/dist/anti-drift/evaluator.js +0 -417
  122. package/dist/anti-drift/evaluator.js.map +0 -1
  123. package/dist/anti-drift/evaluator.test.js +0 -78
  124. package/dist/anti-drift/rules.d.ts +0 -80
  125. package/dist/anti-drift/rules.d.ts.map +0 -1
  126. package/dist/anti-drift/rules.js +0 -368
  127. package/dist/anti-drift/rules.js.map +0 -1
  128. package/dist/anti-drift/rules.test.js +0 -213
  129. package/dist/anti-drift/state.d.ts +0 -107
  130. package/dist/anti-drift/state.d.ts.map +0 -1
  131. package/dist/anti-drift/state.js +0 -177
  132. package/dist/anti-drift/state.js.map +0 -1
  133. package/dist/anti-drift/state.test.js +0 -120
  134. package/dist/chat/adapters/discord.d.ts +0 -41
  135. package/dist/chat/adapters/discord.d.ts.map +0 -1
  136. package/dist/chat/adapters/discord.js +0 -176
  137. package/dist/chat/adapters/discord.js.map +0 -1
  138. package/dist/chat/adapters/discord.test.js +0 -25
  139. package/dist/chat/adapters/slack.d.ts +0 -43
  140. package/dist/chat/adapters/slack.d.ts.map +0 -1
  141. package/dist/chat/adapters/slack.js +0 -172
  142. package/dist/chat/adapters/slack.js.map +0 -1
  143. package/dist/chat/adapters/slack.test.js +0 -30
  144. package/dist/chat/adapters/telegram.d.ts +0 -148
  145. package/dist/chat/adapters/telegram.d.ts.map +0 -1
  146. package/dist/chat/adapters/telegram.js +0 -498
  147. package/dist/chat/adapters/telegram.js.map +0 -1
  148. package/dist/chat/adapters/telegram.test.js +0 -94
  149. package/dist/chat/config.d.ts +0 -98
  150. package/dist/chat/config.d.ts.map +0 -1
  151. package/dist/chat/config.js +0 -185
  152. package/dist/chat/config.js.map +0 -1
  153. package/dist/chat/daemon/active-project.d.ts +0 -17
  154. package/dist/chat/daemon/active-project.d.ts.map +0 -1
  155. package/dist/chat/daemon/active-project.js +0 -23
  156. package/dist/chat/daemon/active-project.js.map +0 -1
  157. package/dist/chat/daemon/autospawn.d.ts +0 -40
  158. package/dist/chat/daemon/autospawn.d.ts.map +0 -1
  159. package/dist/chat/daemon/autospawn.js +0 -129
  160. package/dist/chat/daemon/autospawn.js.map +0 -1
  161. package/dist/chat/daemon/autospawn.test.js +0 -112
  162. package/dist/chat/daemon/cli.d.ts +0 -18
  163. package/dist/chat/daemon/cli.d.ts.map +0 -1
  164. package/dist/chat/daemon/cli.js +0 -71
  165. package/dist/chat/daemon/cli.js.map +0 -1
  166. package/dist/chat/daemon/collisions.js +0 -384
  167. package/dist/chat/daemon/health-check.d.ts +0 -69
  168. package/dist/chat/daemon/health-check.d.ts.map +0 -1
  169. package/dist/chat/daemon/health-check.js +0 -112
  170. package/dist/chat/daemon/health-check.js.map +0 -1
  171. package/dist/chat/daemon/inbox-read.d.ts +0 -35
  172. package/dist/chat/daemon/inbox-read.d.ts.map +0 -1
  173. package/dist/chat/daemon/inbox-read.js +0 -75
  174. package/dist/chat/daemon/inbox-read.js.map +0 -1
  175. package/dist/chat/daemon/inbox-read.test.js +0 -97
  176. package/dist/chat/daemon/inbox.d.ts +0 -63
  177. package/dist/chat/daemon/inbox.d.ts.map +0 -1
  178. package/dist/chat/daemon/inbox.js +0 -56
  179. package/dist/chat/daemon/inbox.js.map +0 -1
  180. package/dist/chat/daemon/inbox.test.js +0 -110
  181. package/dist/chat/daemon/lifecycle.d.ts +0 -71
  182. package/dist/chat/daemon/lifecycle.d.ts.map +0 -1
  183. package/dist/chat/daemon/lifecycle.js +0 -221
  184. package/dist/chat/daemon/lifecycle.js.map +0 -1
  185. package/dist/chat/daemon/lifecycle.test.js +0 -163
  186. package/dist/chat/daemon/protocol.d.ts +0 -107
  187. package/dist/chat/daemon/protocol.d.ts.map +0 -1
  188. package/dist/chat/daemon/protocol.js +0 -54
  189. package/dist/chat/daemon/protocol.js.map +0 -1
  190. package/dist/chat/daemon/routing.d.ts +0 -140
  191. package/dist/chat/daemon/routing.d.ts.map +0 -1
  192. package/dist/chat/daemon/routing.js +0 -198
  193. package/dist/chat/daemon/routing.js.map +0 -1
  194. package/dist/chat/daemon/routing.test.js +0 -259
  195. package/dist/chat/daemon/rpc-client.d.ts +0 -45
  196. package/dist/chat/daemon/rpc-client.d.ts.map +0 -1
  197. package/dist/chat/daemon/rpc-client.js +0 -133
  198. package/dist/chat/daemon/rpc-client.js.map +0 -1
  199. package/dist/chat/daemon/rpc-server.d.ts +0 -39
  200. package/dist/chat/daemon/rpc-server.d.ts.map +0 -1
  201. package/dist/chat/daemon/rpc-server.js +0 -385
  202. package/dist/chat/daemon/rpc-server.js.map +0 -1
  203. package/dist/chat/daemon/rpc.test.js +0 -177
  204. package/dist/chat/daemon/subscribers.js +0 -257
  205. package/dist/chat/daemon/worker.d.ts +0 -27
  206. package/dist/chat/daemon/worker.d.ts.map +0 -1
  207. package/dist/chat/daemon/worker.js +0 -313
  208. package/dist/chat/daemon/worker.js.map +0 -1
  209. package/dist/chat/daemon/workspace-topic.js +0 -324
  210. package/dist/chat/env-token.d.ts +0 -60
  211. package/dist/chat/env-token.d.ts.map +0 -1
  212. package/dist/chat/env-token.js +0 -137
  213. package/dist/chat/env-token.js.map +0 -1
  214. package/dist/chat/env-token.test.js +0 -160
  215. package/dist/chat/factory.d.ts +0 -30
  216. package/dist/chat/factory.d.ts.map +0 -1
  217. package/dist/chat/factory.js +0 -50
  218. package/dist/chat/factory.js.map +0 -1
  219. package/dist/chat/factory.test.js +0 -55
  220. package/dist/chat/gateway.d.ts +0 -176
  221. package/dist/chat/gateway.d.ts.map +0 -1
  222. package/dist/chat/gateway.js +0 -146
  223. package/dist/chat/gateway.js.map +0 -1
  224. package/dist/chat/gateway.test.js +0 -192
  225. package/dist/claude-md.d.ts +0 -39
  226. package/dist/claude-md.d.ts.map +0 -1
  227. package/dist/claude-md.js +0 -113
  228. package/dist/claude-md.js.map +0 -1
  229. package/dist/claude-md.test.js +0 -91
  230. package/dist/codex/activate.d.ts +0 -66
  231. package/dist/codex/activate.d.ts.map +0 -1
  232. package/dist/codex/activate.js +0 -329
  233. package/dist/codex/activate.js.map +0 -1
  234. package/dist/codex/activate.test.js +0 -229
  235. package/dist/codex/bundled-default/bundled-default.test.js +0 -161
  236. package/dist/codex/cli-publish.test.js +0 -133
  237. package/dist/codex/cli.d.ts +0 -35
  238. package/dist/codex/cli.d.ts.map +0 -1
  239. package/dist/codex/cli.js +0 -554
  240. package/dist/codex/cli.js.map +0 -1
  241. package/dist/codex/cli.test.js +0 -277
  242. package/dist/codex/import-skill-md.d.ts +0 -53
  243. package/dist/codex/import-skill-md.d.ts.map +0 -1
  244. package/dist/codex/import-skill-md.js +0 -236
  245. package/dist/codex/import-skill-md.js.map +0 -1
  246. package/dist/codex/import-skill-md.test.js +0 -225
  247. package/dist/codex/loader.d.ts +0 -27
  248. package/dist/codex/loader.d.ts.map +0 -1
  249. package/dist/codex/loader.js +0 -86
  250. package/dist/codex/loader.js.map +0 -1
  251. package/dist/codex/loader.test.js +0 -75
  252. package/dist/codex/parse.d.ts +0 -28
  253. package/dist/codex/parse.d.ts.map +0 -1
  254. package/dist/codex/parse.js +0 -309
  255. package/dist/codex/parse.js.map +0 -1
  256. package/dist/codex/parse.test.js +0 -241
  257. package/dist/codex/store.d.ts +0 -87
  258. package/dist/codex/store.d.ts.map +0 -1
  259. package/dist/codex/store.js +0 -205
  260. package/dist/codex/store.js.map +0 -1
  261. package/dist/codex/store.test.js +0 -242
  262. package/dist/codex/types.d.ts +0 -398
  263. package/dist/codex/types.d.ts.map +0 -1
  264. package/dist/codex/types.js +0 -21
  265. package/dist/codex/types.js.map +0 -1
  266. package/dist/config.d.ts +0 -53
  267. package/dist/config.d.ts.map +0 -1
  268. package/dist/config.js +0 -202
  269. package/dist/config.js.map +0 -1
  270. package/dist/config.test.js +0 -117
  271. package/dist/engine/cli.d.ts +0 -14
  272. package/dist/engine/cli.d.ts.map +0 -1
  273. package/dist/engine/cli.js +0 -171
  274. package/dist/engine/cli.js.map +0 -1
  275. package/dist/engine/client.d.ts +0 -219
  276. package/dist/engine/client.d.ts.map +0 -1
  277. package/dist/engine/client.js +0 -312
  278. package/dist/engine/client.js.map +0 -1
  279. package/dist/engine/config.d.ts +0 -62
  280. package/dist/engine/config.d.ts.map +0 -1
  281. package/dist/engine/config.js +0 -223
  282. package/dist/engine/config.js.map +0 -1
  283. package/dist/engine/index.d.ts +0 -17
  284. package/dist/engine/index.d.ts.map +0 -1
  285. package/dist/engine/index.js +0 -16
  286. package/dist/engine/index.js.map +0 -1
  287. package/dist/engine/resolver.d.ts +0 -62
  288. package/dist/engine/resolver.d.ts.map +0 -1
  289. package/dist/engine/resolver.js +0 -103
  290. package/dist/engine/resolver.js.map +0 -1
  291. package/dist/engine/singleton.d.ts +0 -95
  292. package/dist/engine/singleton.d.ts.map +0 -1
  293. package/dist/engine/singleton.js +0 -325
  294. package/dist/engine/singleton.js.map +0 -1
  295. package/dist/engine/types.d.ts +0 -402
  296. package/dist/engine/types.d.ts.map +0 -1
  297. package/dist/engine/types.js +0 -22
  298. package/dist/engine/types.js.map +0 -1
  299. package/dist/engine-binary-resolver.js +0 -110
  300. package/dist/engine-binary-resolver.test.js +0 -61
  301. package/dist/engine-cli.js +0 -60
  302. package/dist/engine-client.js +0 -301
  303. package/dist/engine-client.test.js +0 -118
  304. package/dist/functions/chain_state.d.ts +0 -51
  305. package/dist/functions/chain_state.d.ts.map +0 -1
  306. package/dist/functions/chain_state.js +0 -59
  307. package/dist/functions/chain_state.js.map +0 -1
  308. package/dist/hooks/drift-catalog.d.ts +0 -68
  309. package/dist/hooks/drift-catalog.d.ts.map +0 -1
  310. package/dist/hooks/drift-catalog.js +0 -184
  311. package/dist/hooks/drift-catalog.js.map +0 -1
  312. package/dist/hooks/drift-catalog.test.js +0 -154
  313. package/dist/hooks/drift-patterns.d.ts +0 -110
  314. package/dist/hooks/drift-patterns.d.ts.map +0 -1
  315. package/dist/hooks/drift-patterns.js +0 -289
  316. package/dist/hooks/drift-patterns.js.map +0 -1
  317. package/dist/hooks/drift-patterns.test.js +0 -325
  318. package/dist/hooks/engine-vocab-gate.d.ts +0 -108
  319. package/dist/hooks/engine-vocab-gate.d.ts.map +0 -1
  320. package/dist/hooks/engine-vocab-gate.js +0 -225
  321. package/dist/hooks/engine-vocab-gate.js.map +0 -1
  322. package/dist/hooks/engine-vocab-gate.test.js +0 -170
  323. package/dist/hooks/heartbeat.d.ts +0 -107
  324. package/dist/hooks/heartbeat.d.ts.map +0 -1
  325. package/dist/hooks/heartbeat.js +0 -316
  326. package/dist/hooks/heartbeat.js.map +0 -1
  327. package/dist/hooks/heartbeat.test.js +0 -393
  328. package/dist/hooks/honesty-ledger-session-scope.test.js +0 -100
  329. package/dist/hooks/honesty-ledger.d.ts +0 -123
  330. package/dist/hooks/honesty-ledger.d.ts.map +0 -1
  331. package/dist/hooks/honesty-ledger.js +0 -226
  332. package/dist/hooks/honesty-ledger.js.map +0 -1
  333. package/dist/hooks/honesty-ledger.test.js +0 -466
  334. package/dist/hooks/inline-report-check.d.ts +0 -63
  335. package/dist/hooks/inline-report-check.d.ts.map +0 -1
  336. package/dist/hooks/inline-report-check.js +0 -88
  337. package/dist/hooks/inline-report-check.js.map +0 -1
  338. package/dist/hooks/inline-report-check.test.js +0 -96
  339. package/dist/hooks/pre-tool-use.d.ts +0 -62
  340. package/dist/hooks/pre-tool-use.d.ts.map +0 -1
  341. package/dist/hooks/pre-tool-use.js +0 -342
  342. package/dist/hooks/pre-tool-use.js.map +0 -1
  343. package/dist/hooks/pre-tool-use.test.js +0 -134
  344. package/dist/hooks/session-end.d.ts +0 -15
  345. package/dist/hooks/session-end.d.ts.map +0 -1
  346. package/dist/hooks/session-end.js +0 -60
  347. package/dist/hooks/session-end.js.map +0 -1
  348. package/dist/hooks/session-end.test.js +0 -52
  349. package/dist/hooks/stop.d.ts +0 -35
  350. package/dist/hooks/stop.d.ts.map +0 -1
  351. package/dist/hooks/stop.js +0 -136
  352. package/dist/hooks/stop.js.map +0 -1
  353. package/dist/hooks/transcript-active-task.test.js +0 -342
  354. package/dist/hooks/transcript.d.ts +0 -26
  355. package/dist/hooks/transcript.d.ts.map +0 -1
  356. package/dist/hooks/transcript.js +0 -266
  357. package/dist/hooks/transcript.js.map +0 -1
  358. package/dist/hooks/transcript.test.js +0 -103
  359. package/dist/hooks/user-prompt-submit.d.ts +0 -74
  360. package/dist/hooks/user-prompt-submit.d.ts.map +0 -1
  361. package/dist/hooks/user-prompt-submit.js +0 -256
  362. package/dist/hooks/user-prompt-submit.js.map +0 -1
  363. package/dist/hooks/user-prompt-submit.test.js +0 -118
  364. package/dist/hooks/versioning-gate.d.ts +0 -101
  365. package/dist/hooks/versioning-gate.d.ts.map +0 -1
  366. package/dist/hooks/versioning-gate.js +0 -245
  367. package/dist/hooks/versioning-gate.js.map +0 -1
  368. package/dist/hooks/versioning-gate.test.js +0 -368
  369. package/dist/hooks/workflow-gate.d.ts +0 -64
  370. package/dist/hooks/workflow-gate.d.ts.map +0 -1
  371. package/dist/hooks/workflow-gate.js +0 -152
  372. package/dist/hooks/workflow-gate.js.map +0 -1
  373. package/dist/hooks/workflow-gate.test.js +0 -197
  374. package/dist/hooks-cli.d.ts +0 -25
  375. package/dist/hooks-cli.d.ts.map +0 -1
  376. package/dist/hooks-cli.js +0 -286
  377. package/dist/hooks-cli.js.map +0 -1
  378. package/dist/hooks-cli.test.js +0 -148
  379. package/dist/origin.d.ts +0 -16
  380. package/dist/origin.d.ts.map +0 -1
  381. package/dist/origin.js +0 -92
  382. package/dist/origin.js.map +0 -1
  383. package/dist/packs/seed_lessons_ingest.d.ts +0 -30
  384. package/dist/packs/seed_lessons_ingest.d.ts.map +0 -1
  385. package/dist/packs/seed_lessons_ingest.js +0 -107
  386. package/dist/packs/seed_lessons_ingest.js.map +0 -1
  387. package/dist/project-cli.d.ts +0 -7
  388. package/dist/project-cli.d.ts.map +0 -1
  389. package/dist/project-cli.js +0 -145
  390. package/dist/project-cli.js.map +0 -1
  391. package/dist/project.d.ts +0 -127
  392. package/dist/project.d.ts.map +0 -1
  393. package/dist/project.js +0 -281
  394. package/dist/project.js.map +0 -1
  395. package/dist/project.test.js +0 -287
  396. package/dist/rag/backends/loop_engine.d.ts +0 -61
  397. package/dist/rag/backends/loop_engine.d.ts.map +0 -1
  398. package/dist/rag/backends/loop_engine.js +0 -160
  399. package/dist/rag/backends/loop_engine.js.map +0 -1
  400. package/dist/recall.d.ts +0 -82
  401. package/dist/recall.d.ts.map +0 -1
  402. package/dist/recall.js +0 -81
  403. package/dist/recall.js.map +0 -1
  404. package/dist/runtime/agent_bridge/autospawn.d.ts +0 -131
  405. package/dist/runtime/agent_bridge/autospawn.d.ts.map +0 -1
  406. package/dist/runtime/agent_bridge/autospawn.js +0 -251
  407. package/dist/runtime/agent_bridge/autospawn.js.map +0 -1
  408. package/dist/runtime/chain_state.d.ts +0 -124
  409. package/dist/runtime/chain_state.d.ts.map +0 -1
  410. package/dist/runtime/chain_state.js +0 -189
  411. package/dist/runtime/chain_state.js.map +0 -1
  412. package/dist/runtime/hooks/permission_decision.d.ts +0 -34
  413. package/dist/runtime/hooks/permission_decision.d.ts.map +0 -1
  414. package/dist/runtime/hooks/permission_decision.js +0 -39
  415. package/dist/runtime/hooks/permission_decision.js.map +0 -1
  416. package/dist/runtime/workflow_fsm.d.ts +0 -21
  417. package/dist/runtime/workflow_fsm.d.ts.map +0 -1
  418. package/dist/runtime/workflow_fsm.js +0 -25
  419. package/dist/runtime/workflow_fsm.js.map +0 -1
  420. package/dist/runtime/workflow_map.d.ts +0 -26
  421. package/dist/runtime/workflow_map.d.ts.map +0 -1
  422. package/dist/runtime/workflow_map.js +0 -38
  423. package/dist/runtime/workflow_map.js.map +0 -1
  424. package/dist/scope.d.ts +0 -48
  425. package/dist/scope.d.ts.map +0 -1
  426. package/dist/scope.js +0 -111
  427. package/dist/scope.js.map +0 -1
  428. package/dist/setup/cli/topic_create_step.d.ts +0 -84
  429. package/dist/setup/cli/topic_create_step.d.ts.map +0 -1
  430. package/dist/setup/cli/topic_create_step.js +0 -213
  431. package/dist/setup/cli/topic_create_step.js.map +0 -1
  432. package/dist/system-export.d.ts +0 -65
  433. package/dist/system-export.d.ts.map +0 -1
  434. package/dist/system-export.js +0 -194
  435. package/dist/system-export.js.map +0 -1
  436. package/dist/utterance/classifier.d.ts +0 -53
  437. package/dist/utterance/classifier.d.ts.map +0 -1
  438. package/dist/utterance/classifier.js +0 -184
  439. package/dist/utterance/classifier.js.map +0 -1
  440. package/dist/utterance/classifier.test.js +0 -147
@@ -0,0 +1,268 @@
1
+ # OpenSquid — Architecture (single source of truth)
2
+
3
+ Version: 0.5.441 · Last updated: 2026-06-14
4
+
5
+ This is the **one** map of the whole system: what each part is, **how the parts depend on each
6
+ other**, and **what gets brittle when you change something**. opensquid is not a bag of features —
7
+ it is one interconnected loop. Treat this doc as the reference point before any change: find the
8
+ subsystem you're touching, read its relationships, then read the [Change-impact map](#change-impact-map).
9
+
10
+ Deep-dives (this doc is the entry point; these are the details):
11
+ `docs/pack-runtime.md` (pack format + dispatch), `docs/pack-fsm-architecture.md` (FSM engine),
12
+ `docs/flows.md` (FLOW templates), `docs/state-formats.md` (on-disk shapes), `docs/lexicon.md`
13
+ (design principles), `docs/rubric/{scope,author}.md` (gate criteria).
14
+
15
+ ---
16
+
17
+ ## 1. The thesis — one loop, not six features
18
+
19
+ opensquid is a **behavior runtime**: an orchestrator that loads **packs** (the total definition of an
20
+ agent's behavior — FSMs + guards + the agent-facing procedure) and runs them over every agent action,
21
+ backed by durable **memory**, gated by **flows**, wired by **install/setup**, with **chat** as the
22
+ remote I/O. The parts complement each other:
23
+
24
+ ```
25
+ install/setup ──writes the config+state layout everything else reads──┐
26
+ │ │
27
+ ▼ ▼
28
+ ┌──────────────────┐ threads pack content ┌──────────────────┐ reads/writes
29
+ │ RUNTIME │◀──(procedure/models/fsm)──│ PACKS │ ~/.opensquid/
30
+ │ hooks→dispatch→ │ │ manifest+skills+ │ (the shared
31
+ │ evaluator→ │──runs rules/gates────────▶│ fsm+rubric+ │ substrate)
32
+ │ primitives │ │ procedure │ ▲
33
+ └───────┬──────────┘ └────────┬─────────┘ │
34
+ │ injects recall/rubric/procedure │ DEFINES │
35
+ │ runs the audits, writes FSM+phase state ▼ │
36
+ ▼ ┌──────────────────┐ │
37
+ ┌──────────────────┐ log_phase / recall / │ FLOWS │ │
38
+ │ MEMORY │◀──store_lesson──────────────│ coding-flow FSM, │───────┘
39
+ │ RAG + lessons + │ │ gates, git gate, │
40
+ │ work-graph │──recall feeds each turn────▶│ request-type │
41
+ └───────┬──────────┘ └──────────────────┘
42
+ │ umbrella/namespace key is SHARED with ▼
43
+ ┌──────────────────┐
44
+ │ CHAT │ remote I/O over the whole session (inbound→hooks, outbound←chat_send)
45
+ └──────────────────┘
46
+ ```
47
+
48
+ The five load-bearing connections (memorize these — they are where disconnection happens):
49
+
50
+ 1. **Packs DEFINE flows.** The `coding-flow` pack's `fsm.yaml` + skills ARE the lifecycle the Flows
51
+ subsystem enforces. Change the pack → you change the flow.
52
+ 2. **Flows WRITE memory.** `log_phase` writes the phase ledger; audits read the rubric docs; the
53
+ request-type record + FSM state are session memory the gates read.
54
+ 3. **Memory FEEDS packs/flows.** `recall` (+ `recall_pre_inject`) is what the agent knows each turn;
55
+ the request-type + FSM records drive the arm decision and the stop guards.
56
+ 4. **Runtime THREADS packs.** dispatch reads each pack's `procedure`/`models`/`fsm` and threads them
57
+ to primitives; the primitives run the gates and inject memory/rubric/procedure.
58
+ 5. **Install WIRES all of it.** setup writes the hooks (`~/.claude/settings.json`), the MCP servers
59
+ (`~/.claude.json`), and the `~/.opensquid/` layout. Chat + memory **share** the umbrella/namespace
60
+ key. If setup is wrong, nothing downstream fires.
61
+
62
+ ---
63
+
64
+ ## 2. A turn's data-flow (the spine)
65
+
66
+ ```
67
+ user prompt
68
+ └─▶ UserPromptSubmit hook (runtime)
69
+ ├─ resetTurnLedger → STATE (session ledger)
70
+ ├─ classifyRequestType → writeRequestType → MEMORY/STATE (request-type record) [FLOWS reads it]
71
+ ├─ recall_pre_inject ← MEMORY (top-K) → additionalContext
72
+ ├─ rubric_pre_inject / procedure_pre_inject← PACKS (coding-flow docs) → additionalContext
73
+ ├─ drainUmbrellaInbox ← CHAT (inbox) → additionalContext
74
+ └─ dispatchEvent
75
+ └─ walk PACKS → skills → rules → evaluator → primitives
76
+ ├─ enter-scoping reads request-type → advance_fsm (FLOWS: scoping) → STATE (FSM)
77
+ └─ directives (next_action) → additionalContext
78
+ agent acts (Write/Edit/Bash/git/...)
79
+ └─▶ PreToolUse hook → dispatch
80
+ ├─ a pre-research Write → guess-audit (spawn) → GUESS_FREE → advance_fsm → STATE (FSM)
81
+ ├─ a spec Write → spec-audit → SPEC_COMPLETE → advance_fsm
82
+ └─ git commit → execute-gate (in-session NUDGE) [git gate.ts = the HARD boundary]
83
+ └─▶ PostToolUse hook → phase-advance (after log_phase) → STATE (FSM) + MEMORY (phase ledger)
84
+ agent stops
85
+ └─▶ Stop hook → pause-stop-guard (reads request-type + FSM), maybeDriveInbound/streamOutput (CHAT)
86
+ session ends
87
+ └─▶ SessionEnd hook → reconcile memory, compression, auto-handoff, clearFsmState
88
+ ```
89
+
90
+ Every arrow crosses a subsystem boundary. That is the point: a change to any node ripples along its arrows.
91
+
92
+ ---
93
+
94
+ ## 3. Subsystems at a glance
95
+
96
+ | Subsystem | Owns | Key code | Deep-dive |
97
+ | ----------------- | ------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------- |
98
+ | **Install/Setup** | the npm package, the wizards, the `~/.opensquid/` + `~/.claude/` layout | `src/cli.ts`, `src/setup/`, `src/runtime/paths.ts`, `package.json` | §4.1 |
99
+ | **Runtime** | hooks → dispatch → evaluator → ~50 primitives; the event/verdict model | `src/runtime/hooks/`, `dispatch.ts`, `evaluator/`, `src/functions/`, `bootstrap.ts` | `pack-runtime.md` |
100
+ | **Packs** | pack format (manifest+skills+side-files), loader, the builtin pack set | `src/packs/`, `src/runtime/types.ts` (`Pack`), `packs/builtin/` | `pack-runtime.md` |
101
+ | **Flows/Gates** | the coding-flow FSM, guess/spec/phase gates, git-owned gate, request-type classifier | `packs/builtin/coding-flow/`, `src/runtime/fsm*.ts`, `src/functions/cached_audit.ts`, `src/setup/cli/gate.ts`, `src/runtime/request_type.ts` | `pack-fsm-architecture.md`, `flows.md` |
102
+ | **Memory** | RAG (libsql+fastembed), lessons + wedge gate, work-graph, compression/retention | `src/rag/`, `src/workgraph/`, `src/runtime/phase_ledger.ts`, `src/mcp/tools/` | `state-formats.md` |
103
+ | **Chat** | chat-daemon, umbrella routing, inbound watcher + drain, `chat_send` bridge | `src/channels/`, `src/runtime/chat/`, `src/mcp/chat-bridge-server.ts`, `src/chat_daemon/client.ts` | — |
104
+
105
+ ---
106
+
107
+ ## 4. Per-subsystem — owns / inputs / outputs / **touchpoints**
108
+
109
+ ### 4.1 Install / Setup / State-layout
110
+
111
+ - **Owns:** the npm `bin` set (the CLI + 6 hook bins + 2 MCP servers, `package.json:12-22`); the wizards
112
+ (`src/setup/wizard/{settings-writer,mcp-writer,codex-hooks-writer}.ts`, `src/setup/cli/chat_*`); the
113
+ canonical path layout (`src/runtime/paths.ts`, `OPENSQUID_HOME()`).
114
+ - **Writes (the config other subsystems consume):** `~/.claude/settings.json` (hook entries, marked
115
+ `@opensquid:true`), `~/.claude.json` (`opensquid` + `opensquid-chat` MCP servers), `~/.codex/hooks.json`
116
+ (codex parity), `~/.opensquid/{active.json, models.yaml, channels.json, config.json, .env, sessions/, store/, ...}`.
117
+ - **Touchpoints (downstream dependents):** Runtime hooks depend on `settings.json` being present+correct;
118
+ the MCP tools depend on `~/.claude.json`; Packs load from `active.json` + `~/.opensquid/packs/`; Chat
119
+ depends on `config.json` (tokens) + `channels.json` (routing); Memory keys on the umbrella from `channels.json`.
120
+ - **This is the root dependency.** If setup is broken, _every_ other subsystem silently no-ops.
121
+ - **Verify:** `opensquid doctor {hooks,codex-hooks,memory,git-hooks,update}`.
122
+
123
+ ### 4.2 Runtime (the spine)
124
+
125
+ - **Owns:** the 6 hook bins; `dispatchEvent` (walks packs→skills→rules, threads `packId/packModels/packFsm/packProcedure`
126
+ into the eval context, aggregates `contextInjections`+`directives`); the evaluator + `if:` interpreter;
127
+ the function registry (~50 primitives registered in `bootstrap.ts`); the Event (8 kinds) + Verdict (5 levels) model.
128
+ - **Inputs:** host hook payloads; the loaded packs; the session/FSM/memory state on disk.
129
+ - **Outputs:** `additionalContext` (injections+directives), `permissionDecision: deny` (block), FSM/state writes,
130
+ audit spawns, memory reads/writes.
131
+ - **Touchpoints:** threads PACK content → primitives; primitives read/write MEMORY + STATE; runs the FLOWS gates;
132
+ injects CHAT inbox; is installed BY setup. **Adding a primitive** = register in `bootstrap.ts` (+ thread via
133
+ `dispatch.ts` if it reads pack content, + register in test registries if pack rules call it — see [Change-impact](#change-impact-map)).
134
+
135
+ ### 4.3 Packs
136
+
137
+ - **Owns:** `manifest.yaml` (+ `skills/*/skill.yaml`) and the optional side-files `fsm.yaml`, `team.yaml`,
138
+ `models.yaml`, `drift_response.yaml`, `chat_agent.yaml`, `channels.yaml`, `notifications.yaml`, **`procedure.md`**;
139
+ the loader (`loadPack`); the runtime `Pack` object (`types.ts:351`); the 13 builtin packs.
140
+ - **Touchpoints:** the `coding-flow` pack DEFINES the FLOWS FSM+gates; `models.yaml` configures MEMORY's
141
+ embedder/LLM aliases; side-files are threaded by RUNTIME dispatch; packs are located by SETUP
142
+ (`active.json`); pack rules call MEMORY (`recall`/`store_lesson`) and inject the rubric/procedure.
143
+ - **A pack is the unit of behavior.** Editing a pack changes the agent's flow, gates, and injected guidance at once.
144
+
145
+ ### 4.4 Flows / Gates
146
+
147
+ - **Owns:** `coding-flow/fsm.yaml` (idle→SCOPE→AUTHOR→CODE, 9 states); the content gates — guess-audit
148
+ (SCOPE→`GUESS_FREE`), spec-audit (AUTHOR→`SPEC_COMPLETE`), phase-log (7 phases); the in-session skills
149
+ (entry-and-handoffs, scope-lifecycle, execute-gate, phase-advance/audit, pause-stop-guard, pause-prevention,
150
+ task-start); the **git-owned hard boundary** `gate.ts` (pre-commit/pre-push, binds to agents, humans pass);
151
+ the **request-type classifier** (research vs work, `request_type.ts`).
152
+ - **Touchpoints:** the FSM IS a PACK side-file; the gates run via RUNTIME primitives (`cached_audit` spawns
153
+ subagents); the audits read the rubric DOCS and write the FSM STATE; `log_phase` writes MEMORY (phase ledger);
154
+ `gate.ts` reads session STATE written by the hooks; the request-type record (written by the UPS hook) is read by
155
+ enter-scoping + the stop guards. **Two-layer design:** in-session gates = best-effort NUDGE; `gate.ts` = fail-closed.
156
+
157
+ ### 4.5 Memory
158
+
159
+ - **Owns:** the RAG store (`libsql-fastembed` default; per-file `store/lessons/<id>.md` = git-versionable truth;
160
+ lexical + claude-auto-memory backends); the Lesson type (durability, retired_at, tier/namespace); recall/memorize/forget;
161
+ the **wedge gate** (anti-self-grading lesson promotion); the **work-graph** (event-sourced op-log + libSQL projection,
162
+ claim/audience); compression + 30-day retention/demote.
163
+ - **Touchpoints:** recall is CALLED by pack rules + injected by RUNTIME (`recall_pre_inject`); the scope **namespace**
164
+ comes from the active umbrella (SHARED with CHAT); `models.yaml` (PACKS) picks the embedder; `log_phase` (FLOWS)
165
+ writes the ledger; memorize writes are scoped by the umbrella resolved from cwd/channels.json (SETUP/CHAT).
166
+ - **Scope is fail-closed:** null namespace → only `shared` memory; cross-project leakage is structurally prevented.
167
+
168
+ ### 4.6 Chat
169
+
170
+ - **Owns:** the long-lived `chat-daemon` (owns the bot tokens, a UDS socket, writes umbrella inbox JSONL);
171
+ umbrella routing (`channels.json`, pure FSM); the inbound watcher (real-time push) + Stop-hook drain (fallback);
172
+ outbound `chat_send` (the separate `opensquid-chat-bridge-mcp` server → daemon RPC); the live-session lease.
173
+ - **Touchpoints:** the daemon is configured BY setup (`config.json`/`channels.json`); inbound injects into the
174
+ RUNTIME hooks (UPS additionalContext / Stop drive); the **umbrella key is SHARED with MEMORY scoping** and the
175
+ lease; chat is the remote I/O over the WHOLE session. **Known fragility:** the inbound watcher can die silently
176
+ in long sessions → degrades to the turn-boundary drain (see [Stale/disconnect](#stale--disconnected)).
177
+
178
+ ---
179
+
180
+ ## 5. Relationship matrix — "if I change ROW, it affects COLUMN"
181
+
182
+ | ↓ change / → affects | Install | Runtime | Packs | Flows | Memory | Chat |
183
+ | -------------------- | ------------------------------------------------------- | ----------------------------------- | -------------------------------- | ------------------------------------ | ------------------------------------ | ------------------------------ |
184
+ | **Install/Setup** | — | hooks must re-register | pack discovery (`active.json`) | gate install | store/scope paths | daemon tokens+routing |
185
+ | **Runtime** | hook bin names ↔ `package.json` `bin` + settings-writer | — | dispatch threading of side-files | primitives the gates call | recall/state primitives | inbox drain + chat_send |
186
+ | **Packs** | — | new side-file ⇒ thread in dispatch | — | **coding-flow pack = the FSM+gates** | models.yaml ⇒ embedder; recall rules | chat_agent.yaml |
187
+ | **Flows** | gate.ts ↔ git hooks | audit primitives, classifier in UPS | the coding-flow pack content | — | log_phase ⇒ ledger; rubric docs | stop-guard reads request-type |
188
+ | **Memory** | store/db paths | recall/recall_pre_inject shape | recall hits feed pack rules | request-type/FSM records drive gates | — | umbrella namespace = scope key |
189
+ | **Chat** | channels.json/config.json | inbound event → hooks | chat_agent binding | — | umbrella key = memory namespace | — |
190
+
191
+ Read a row before you change that subsystem. Each non-empty cell is a place that can break.
192
+
193
+ ---
194
+
195
+ ## 6. Config & state layout (canonical)
196
+
197
+ The shared substrate. Detailed shapes in `docs/state-formats.md`; this is the index.
198
+
199
+ ```
200
+ ~/.claude/settings.json hooks: 6 opensquid-hook-* entries (@opensquid:true) ← WRITTEN BY setup; READ BY host→runtime
201
+ ~/.claude.json mcpServers: opensquid + opensquid-chat ← WRITTEN BY setup; READ BY host
202
+ ~/.codex/hooks.json 5 events (codex parity, absolute bin paths) ← WRITTEN BY setup
203
+ ~/.opensquid/
204
+ active.json opted-in packs (user scope) ← Packs
205
+ models.yaml model aliases (reasoning, fast_classifier, ...) ← Packs/Memory/LLM
206
+ channels.json umbrella routing (members→umbrella→telegram target) ← Chat + Memory(namespace)
207
+ config.json chat bot tokens (chmod 600) ← Chat
208
+ .env API tokens (chmod 600; canonical per SHL.1) ← Chat/SDK
209
+ rag.sqlite / store/lessons/ RAG store + per-file git-versionable truth ← Memory
210
+ workgraph.db / workgraph/ work-graph projection + per-op files ← Memory
211
+ lessons/<status>/ wedge-gate lessons (per-file source) ← Memory
212
+ phase_ledger/<taskId>/ durable 7-phase audit ledger ← Flows→Memory
213
+ sessions/<sid>/state/ fsm-coding-flow, request-type, *-audit-cache, ledgers ← Runtime/Flows
214
+ sessions/<sid>/active-task.json the active task signal ← Runtime/Flows/git-gate
215
+ umbrellas/<id>/inbox/*.jsonl + live-session.lease ← Chat
216
+ chat-daemon.{sock,pid,log} daemon endpoints ← Chat
217
+ <project>/.opensquid/active.json + .opensquid/attestations.jsonl ← Packs / git-gate
218
+ ```
219
+
220
+ ---
221
+
222
+ ## 7. Change-impact map
223
+
224
+ The "what gets brittle when you touch X" reference. **Before changing a left-column item, check the right column.**
225
+
226
+ | If you change… | …re-verify (these get brittle) |
227
+ | --------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
228
+ | **`coding-flow/fsm.yaml`** (states/transitions) | every skill that `advance_fsm`; the gates that read state (execute-gate, pause-stop-guard); `gate.ts` `commitAllowedNow` (keys on `phases_complete` + 7 phases); request-type idle-return + RTC.4 stranded-scoping; the FSM-active set in `rubric_pre_inject`/`procedure_pre_inject` |
229
+ | **session-state shape/key** (`sessions/<sid>/state/*`) | all `read_state` consumers across packs; the audits' cache keys; the classifier record; `gate.ts` (reads FSM+phases+active-task); the request-type consumers |
230
+ | **a pack side-file** (add/rename, e.g. `procedure.md`) | `loadPack` (load it), `types.ts` `Pack` (field), `dispatch.ts` (thread it into eval ctx), the consuming primitive, and **test registries** (`coding-flow.test.ts`/`default-discipline.test.ts` must register any primitive a shipped rule calls — or dispatch tests break) |
231
+ | **a new primitive** (`src/functions/*`) | register in `bootstrap.ts`; export in `src/functions/index.ts`; if it reads pack content, add the field to `FunctionContext` + thread in `dispatch.ts`; if a shipped pack rule calls it, register it in the dispatch test registries |
232
+ | **the rubric** (`docs/rubric/{scope,author}.md`) | BOTH the audit pass-criteria AND the agent-injected guidance change (single-source by design — that's the point; don't add a second copy) |
233
+ | **hook wiring** (`package.json` `bin` ↔ `settings-writer.ts` `OPENSQUID_BIN_FOR_EVENT`) | the whole pipeline: a renamed/missing bin = that event silently no-ops; re-run `opensquid setup wizard hooks` + `doctor hooks` |
234
+ | **the umbrella/namespace key** (`channels.json` routing or `scope.ts`) | Chat routing AND Memory scoping AND the live-session lease all key on it together — change one, reconcile all three |
235
+ | **the RAG backend / Lesson schema** (`src/rag/`) | `recall`/`recall_pre_inject`, all backends (libsql/lexical/auto-memory + the fallback wrapper), per-file source round-trip, `rebuildLibsqlIndex`, the wedge store |
236
+ | **the git gate** (`gate.ts`) | the gate-binding model (agents armed / humans pass); `isDocsOnly`; the attestation trail (pre-commit ↔ pre-push); the in-session execute-gate must stay consistent with it |
237
+ | **`command_invokes` / matchers** | the git-class guards in `default-discipline` (never-amend, no-force-push-main, npm-version); `command_boundary.skill.test` (regression guard) |
238
+ | **the version (minor/major bump)** | the final-audit-flow gate (planned, `wg-54eef8b4927c`) + `gate.ts` version-bump detection (FA.0 positional matcher shipped) |
239
+
240
+ **Process rule that falls out of this map:** never change a subsystem in isolation. A pack edit is a flow
241
+ edit; a state-shape edit is a gate edit; a key edit is a chat+memory edit. Walk the arrows.
242
+
243
+ ---
244
+
245
+ ## 8. Stale / disconnected (cleanup backlog, grounded)
246
+
247
+ Found during this mapping; each is a real disconnect to clean (drives the cleanup pass, tracked in the work-graph):
248
+
249
+ - **Pack discovery is not resilient** (`wg-a3e928b8255b`, **HIGH** — verified via CLI audit): one malformed pack in `~/.opensquid/packs/` crashes every pack-enumerating command (`schedule list`, `triggers list`, …) — `loadPack` throws on the first bad pack even when it isn't in `active.json`. Trigger here: a stale `sangmin-personal-rules.dpc6-backup/` dir. Discovery of the installed SET should fail-soft per-pack (skip+warn); an explicitly-loaded pack can still fail loud.
250
+ - **`dist/` ships dead code** (`wg-98a8d32127dd`, **HIGH** — ships to npm): `tsc` never cleans `dist/`, so `dist/anti-drift/*`, `dist/engine-client.js`, `dist/rag/backends/loop_engine.js`, and **56 `*.test.js`** (all with no live `src/`) accumulate and ship. Fix: `rm -rf dist` before build. (`npm/engine-*` = local cruft, not shipped.)
251
+ - **Install-flow holes** (`wg-5eedceaaa19f`): no `postinstall`/first-run nudge; `setup wizard mcp` `detectOpensquidRoot()` is dead code (defined, never called); the README happy-path assumes manual wizard steps; `daemon start/stop/restart` are stubs.
252
+ - **`~/.loop/.env` vs `~/.opensquid/.env`** — the chat wizard still references `~/.loop/.env` in places (SHL.1 made `~/.opensquid/.env` canonical); reconcile. The `~/.loop` tree is a rename remnant.
253
+ - **`dist/anti-drift/*`** — legacy 0.7.x monolith compiled output; superseded by `src/runtime/hooks/*` + dispatch; should not ship (and `dist/**/*.test.js` shouldn't ship either — packaging bloat).
254
+ - **Stale ADR paths** — `~/.opensquid/personas/` + `teams/` (ADR-0013) never built; `team.yaml` is the real mechanism (`wg-b400d5bc5ada` gap 2: docs/terminology).
255
+ - **Compression orchestrator** (`compression_orchestrator.ts`) — "TBD wiring"; consolidation not yet invoked at session boundary.
256
+ - **Chat watcher unsupervised** (`wg-83e8e91f39d2`) — dies silently in long sessions → silent fallback to turn-boundary drain; not auto-restarted.
257
+ - **channels.yaml / notifications.yaml** — pack side-files defined but not folded into the runtime Pack (await notification-router).
258
+ - **`memorize` synchronous confirm gate** (`wg-84d0d73b89c5`) — out of step with the decided records-everything + deferred-validation model (memory cluster, post-0.6.x).
259
+ - **Memory cluster (post-0.6.x, parked):** git-versioned memory (`wg-7f4df49787cb`), 30-day retention slices 2-3 (`wg-9e4f4eb2a40f`), stale-context durability/decay (`wg-4f91e0b5cb8c`).
260
+
261
+ ---
262
+
263
+ ## 9. How to use this doc
264
+
265
+ - **Before a change:** find the subsystem (§4), read its touchpoints, then the [Change-impact map](#change-impact-map). Walk the arrows.
266
+ - **Onboarding / "what does what":** §1–§3.
267
+ - **Finding stale/disconnected work:** §8 (kept in sync with the work-graph).
268
+ - **Exact shapes/APIs:** follow the deep-dive links — this doc is the map, not the territory; keep the details single-sourced in those docs, and keep _this_ doc the authoritative map of how they connect.
@@ -1,6 +1,6 @@
1
1
  # Pack runtime — authoritative reference
2
2
 
3
- Version: 0.5.293 · Last updated: 2026-06-03 · Spec: T-IDENTITY-FOUNDATION (IDF.1–IDF.5) + T-PACK-FSM-STANDARDIZATION (FSM engine, `fsm.yaml`, `guards:`, `read_fsm_state`/`advance_fsm`)
3
+ Version: 0.5.435 · Last updated: 2026-06-14 · Spec: T-IDENTITY-FOUNDATION (IDF.1–IDF.5) + T-PACK-FSM-STANDARDIZATION (FSM engine, `fsm.yaml`, `guards:`, `read_fsm_state`/`advance_fsm`) + T-per-pack-workflow-instructions (`procedure.md`, `procedure_pre_inject`)
4
4
 
5
5
  This document is the authoritative reference for the opensquid pack
6
6
  runtime: how a pack is identified on disk, what it can declare, how
@@ -43,6 +43,7 @@ packs/<name>/
43
43
  <skill-name>/
44
44
  skill.yaml # required — skill rules
45
45
  fsm.yaml # optional — pack-lifecycle FSM (auto-loaded by name; see 1.13)
46
+ procedure.md # optional — agent-facing operating procedure (auto-loaded by name; see 1.5)
46
47
  chat_agent.yaml # optional — chat-bridge agent identity
47
48
  models.yaml # optional — model aliases for LLM primitives
48
49
  channels.yaml # optional — chat channel registry
@@ -262,15 +263,16 @@ field naming a file in the same pack directory. The loader reads +
262
263
  validates each via its own Zod schema; failures throw with a
263
264
  path-bearing error so authors can fix the config.
264
265
 
265
- | Side file | Schema | Purpose |
266
- | --------------------- | ------------------------------------- | ------------------------------------------------------------------------------- |
267
- | `chat_agent.yaml` | `src/packs/schemas/chat_agent.ts` | Chat-bridge identity (display name + persona) |
268
- | `models.yaml` | `src/packs/schemas/models.ts` | Model aliases (e.g. `reasoning` → vendor model id) — keeps source model-neutral |
269
- | `channels.yaml` | `src/packs/schemas/channels.ts` | Chat channel registry (project-bridge mapping) |
270
- | `notifications.yaml` | `src/packs/schemas/notifications.ts` | Notification routing rules |
271
- | `drift_response.yaml` | `src/packs/schemas/drift_response.ts` | Per-rule drift policy + corrective_skills (see §4.3) |
272
- | `team.yaml` | `src/packs/schemas/team.ts` | Profession-pack marker (`role:` + `skills_catalog:`) |
273
- | `fsm.yaml` | `Fsm` in `src/runtime/fsm.ts` | Pack-lifecycle FSM (see §1.13). **Auto-loaded by filename — NO `*_ref`.** |
266
+ | Side file | Schema | Purpose |
267
+ | --------------------- | ------------------------------------- | ---------------------------------------------------------------------------------------- |
268
+ | `chat_agent.yaml` | `src/packs/schemas/chat_agent.ts` | Chat-bridge identity (display name + persona) |
269
+ | `models.yaml` | `src/packs/schemas/models.ts` | Model aliases (e.g. `reasoning` → vendor model id) — keeps source model-neutral |
270
+ | `channels.yaml` | `src/packs/schemas/channels.ts` | Chat channel registry (project-bridge mapping) |
271
+ | `notifications.yaml` | `src/packs/schemas/notifications.ts` | Notification routing rules |
272
+ | `drift_response.yaml` | `src/packs/schemas/drift_response.ts` | Per-rule drift policy + corrective_skills (see §4.3) |
273
+ | `team.yaml` | `src/packs/schemas/team.ts` | Profession-pack marker (`role:` + `skills_catalog:`) |
274
+ | `fsm.yaml` | `Fsm` in `src/runtime/fsm.ts` | Pack-lifecycle FSM (see §1.13). **Auto-loaded by filename — NO `*_ref`.** |
275
+ | `procedure.md` | _(raw markdown — no schema)_ | Agent-facing OPERATING PROCEDURE (the METHOD). **Auto-loaded by filename — NO `*_ref`.** |
274
276
 
275
277
  **`fsm.yaml` is the exception to the `*_ref:` rule.** It is read by
276
278
  fixed filename (`loader.ts:199` `loadOptionalFsm`), validated for totality
@@ -278,6 +280,20 @@ fixed filename (`loader.ts:199` `loadOptionalFsm`), validated for totality
278
280
  (`types.ts:415`). Absent file → `pack.fsm` is `undefined`; the FSM primitives
279
281
  then return `null` (no machine to walk).
280
282
 
283
+ **`procedure.md` is the other auto-loaded-by-filename side file** (wg-7f6225238a27). It is the
284
+ pack's **agent-facing operating procedure** — the positive _METHOD_ ("how to do this work so it
285
+ passes the gates first-try"), complementing the gates' quality _BAR_ (the rubric). It is raw markdown
286
+ (no schema), read whole by `loadOptionalProcedure` (`loader.ts`), size-capped at 64,000 chars
287
+ (over-cap → treated as absent, like an over-cap rubric — it is re-injected per prompt, so it shares
288
+ the rubric's context-budget cost profile), and folded onto the runtime `Pack` as `pack.procedure`
289
+ (threaded into `FunctionContext.packProcedure`). A pack delivers it by adding a rule that calls the
290
+ `procedure_pre_inject` primitive (unconditionally — the primitive self-gates): on `prompt_submit`,
291
+ when the pack is **engaged** (its FSM state ≠ `initial`, or the pack ships no FSM), the procedure is
292
+ injected into the agent's context. Absent file → nothing injects. Worked example:
293
+ `packs/builtin/coding-flow/procedure.md` + the `inject-procedure` rule in `entry-and-handoffs`.
294
+ Keep it METHOD, not CRITERIA — the gate criteria are single-sourced in the rubric; the procedure
295
+ references them, it does not restate them.
296
+
281
297
  ### 1.6 `scope:` (layering precedence)
282
298
 
283
299
  Schema: `src/packs/schemas/manifest.ts` (Scope enum). Distinct from
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opensquid",
3
- "version": "0.5.432",
3
+ "version": "0.5.447",
4
4
  "description": "Continuity layer for coding agents: durable memory, dependency-aware task state, workflow gates, and inspectable packs over MCP.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -24,6 +24,7 @@
24
24
  "dist",
25
25
  "schemas",
26
26
  "packs/builtin",
27
+ "docs/ARCHITECTURE.md",
27
28
  "docs/pack-runtime.md",
28
29
  "docs/skill-grammar-guide.md",
29
30
  "docs/load-budget.md",
@@ -34,7 +35,8 @@
34
35
  },
35
36
  "packageManager": "pnpm@10.33.2",
36
37
  "scripts": {
37
- "build": "tsc -p tsconfig.build.json",
38
+ "clean": "rm -rf dist",
39
+ "build": "tsc -p tsconfig.build.json && chmod +x dist/cli.js dist/runtime/hooks/*.js dist/mcp/server.js dist/mcp/chat-bridge-server.js",
38
40
  "typecheck": "tsc --noEmit",
39
41
  "test": "vitest run",
40
42
  "test:watch": "vitest",
@@ -46,7 +48,7 @@
46
48
  "prepare": "bash scripts/install-git-hooks.sh",
47
49
  "schemas": "tsx scripts/emit-schemas.ts && prettier --write 'schemas/*.json'",
48
50
  "sync-fixtures": "tsx scripts/sync-fixtures-from-live.ts",
49
- "prepublishOnly": "pnpm schemas && pnpm build"
51
+ "prepublishOnly": "pnpm clean && pnpm schemas && pnpm build"
50
52
  },
51
53
  "keywords": [
52
54
  "mcp",
@@ -0,0 +1,43 @@
1
+ # coding-flow — operating procedure (how to run a track so the gates pass first-try)
2
+
3
+ This is the **METHOD**. The SCOPE/AUTHOR **rubric** (injected alongside this) is the **BAR** — the
4
+ criteria the audit applies. Follow both: this tells you the steps; the rubric tells you the standard.
5
+
6
+ ## 0. Pick the flow by request type
7
+
8
+ - "look / find / check / why / investigate" → **RESEARCH**: full end-to-end reads + a synthesis step.
9
+ No freeform grep-and-guess; investigation is never process-exempt.
10
+ - "do X / build / fix / add" → the **3-stage flow** below (SCOPE → AUTHOR → CODE).
11
+
12
+ ## 1. SCOPE — gate: guess-audit → `GUESS_FREE`
13
+
14
+ - In **one** turn: `recall` + `Read` + `Grep` (**≥3 calls**), **then** write the pre-research **once**.
15
+ Never stub-then-edit across turns — the depth gate counts research per-turn, and each Edit to the
16
+ artifact re-fires the ~1–2 min audit (batch all edits into a single Write).
17
+ - Every claim is **derived from cited evidence** (`file:line`, a memory, or the user's words) **or**
18
+ flagged `- [ ] OPEN QUESTION:`. Weigh the alternatives; choose the **simplest correct** one
19
+ (Full-fix over a special-case patch). The artifact lives at `docs/research/T-*-pre-research-*.md`.
20
+
21
+ ## 2. AUTHOR — gate: spec-audit → `SPEC_COMPLETE`
22
+
23
+ - Write `docs/tasks/T-*.md` with all **11 fields** + **REAL code shapes** (actual code, not
24
+ pseudocode), one `### Task` block per slice.
25
+ - `TaskCreate` each block **only after** the spec-audit passes, with `metadata.taskId` +
26
+ `metadata.spec` = the spec's absolute path. A TaskCreate is not "authoring done"; the audit is.
27
+
28
+ ## 3. CODE — gate: phase-log → all 7 phases before commit
29
+
30
+ - Drive the 7 phases and `log_phase` each as it completes:
31
+ `pre_research → learn → code → test → audit → post_research → fix`.
32
+ - `pnpm` only — never `npm i` (it corrupts node_modules). Run the full local gate chain:
33
+ `pnpm typecheck && pnpm lint && pnpm test && pnpm format:check` — **`format:check` LAST** (the
34
+ CHANGELOG is authored in the audit phase, after the gate ran).
35
+ - Stage with explicit `git add <paths>` — **never `git add -A`** (it sweeps drive-by files into the
36
+ commit). Sole author: no `Co-Authored-By:` trailers.
37
+ - After push, verify CI with `gh run view <id> --json conclusion` (not a backgrounded `gh run watch`).
38
+
39
+ ## On a BLOCK
40
+
41
+ Do the block's **named step** (write the pre-research / pass the audit / `TaskCreate`). Never
42
+ narrate-and-stop, never `--no-verify` (a PreToolUse gate ignores it), never permission-fish. If the
43
+ named step errors, fix that and retry **inside** the flow.
@@ -24,10 +24,14 @@ rules:
24
24
  - '\bdesign\b'
25
25
  - '\bplan\b'
26
26
  as: intent
27
- - call: advance_fsm
27
+ # RTC (wg-649d80e78e64): the request-type veto now lives in the arm_scope CHOKEPOINT — the
28
+ # single owner shared by BOTH arm producers (this rule + rearm-on-depletion), so a research-
29
+ # classified prompt (understand-only / a question — "what's the plan here?" matches \bplan\b but
30
+ # is a question) can never arm scope and no producer can reintroduce the bypass. enter-scoping
31
+ # just supplies its keyword-intent condition; arm_scope reads request-type and vetoes research.
32
+ # (Supersedes the inline RTC.2 gate, wg-3d175ec06767.)
33
+ - call: arm_scope
28
34
  if: 'len(intent.matched) > 0'
29
- args:
30
- event: scope_start
31
35
  # FU.3: record the track-type so the AUTHOR gate can consult it. RESET to the
32
36
  # strict default (feature) on every scope entry FIRST — so a stale fix/doc/
33
37
  # trivial value from a prior track can never under-gate a later feature task —
@@ -95,9 +99,46 @@ rules:
95
99
  # ordering). rubric_pre_inject reads the coding-flow FSM and, when in an active SCOPE/AUTHOR phase, returns
96
100
  # an inject_context payload carrying the FULL rubric (scope + author — prompt_submit can't track mid-turn
97
101
  # phase advances, so one injection must cover the whole uninterrupted turn). Inject-only; never blocks.
102
+ # RTC.5 (wg-3d175ec06767): when the deterministic classifier was UNCERTAIN (confidence:low), a fast
103
+ # llm_classify decides research-vs-work and refines the persisted record (source:llm) — the "ACCURATE"
104
+ # half of the lock. Gated strictly on confidence==low (the clear-cut majority never pays the llm cost).
105
+ # Placed AFTER enter-scoping: the current turn's arm safely used the deterministic research-default
106
+ # (backed by the git commit/push gate for a missed work turn); the refinement sharpens the record for
107
+ # the downstream stop guards + measurement. UNCERTAIN/invalid llm output → record unchanged (stays safe).
108
+ - id: refine-request-type
109
+ process:
110
+ - call: read_state
111
+ args:
112
+ key: request-type
113
+ as: rt
114
+ - call: current_prompt
115
+ as: p
116
+ - call: llm_classify
117
+ if: 'rt.confidence == "low"'
118
+ args:
119
+ model: fast_classifier
120
+ prompt: |
121
+ Classify the user prompt as exactly one label:
122
+ - research: a question, investigation, or understand-only request (no code change follows)
123
+ - work: a request to build, change, or fix code
124
+ Prompt: {{p}}
125
+ allowed_labels: [research, work]
126
+ as: refined
127
+ - call: set_request_type
128
+ if: 'rt.confidence == "low" && (refined == "research" || refined == "work")'
129
+ args:
130
+ type: '{{refined}}'
98
131
  - id: inject-rubric
99
132
  process:
100
133
  - call: rubric_pre_inject
134
+ # wg-7f6225238a27 — deliver coding-flow's OPERATING PROCEDURE (the METHOD: how to run a track so
135
+ # the gates pass first-try) alongside the rubric (the BAR). Unconditional like inject-rubric;
136
+ # procedure_pre_inject self-gates on coding-flow's own FSM (engaged = state != idle), so the whole
137
+ # active lifecycle (SCOPE→AUTHOR→EXECUTE) is covered — gate-fighting happens in EXECUTE too. The
138
+ # content is packs/builtin/coding-flow/procedure.md, threaded via Pack.procedure → ctx.packProcedure.
139
+ - id: inject-procedure
140
+ process:
141
+ - call: procedure_pre_inject
101
142
  # GF.1 (F9) — the re-scope NUDGE, surfaced on prompt_submit (where directives are
102
143
  # delivered) for the `scoping` state. Fires after `enter-scoping` advanced idle→scoping
103
144
  # (or after task-start's task_unscoped reset, or GF.7's phases_complete re-arm landed
@@ -223,10 +264,12 @@ rules:
223
264
  as: st
224
265
  - call: open_task_count
225
266
  as: open
226
- - call: advance_fsm
267
+ # RTC (wg-649d80e78e64): the SECOND arm producer routes through the SAME arm_scope chokepoint,
268
+ # so a research/docs turn after a completed track can no longer spuriously re-arm scoping (the
269
+ # gate-fighting class). arm_scope owns the research veto; this rule supplies only the structural
270
+ # depletion condition.
271
+ - call: arm_scope
227
272
  if: 'st == "phases_complete" && open.count == 0'
228
- args:
229
- event: scope_start
230
273
  # Strict default for the re-armed track: a plain-language track can't be classified,
231
274
  # so gate it at the strictest profile (feature). Mirrors enter-scoping's reset.
232
275
  - call: write_state
@@ -48,8 +48,18 @@ rules:
48
48
  scope: current_turn
49
49
  filter_names: [AskUserQuestion]
50
50
  as: asked
51
+ # RTC.3 (wg-3d175ec06767): a research-classified turn (understand-only / a question) never
52
+ # armed the flow and owes no structured fork — its stop is legitimate on ANY harness. Reading
53
+ # the harness-NEUTRAL request-type record (not the Claude-only AskUserQuestion-ran signal) is
54
+ # the portable allow-signal that fixes cause-2 of the codex-pause-wedge (codex has no
55
+ # AskUserQuestion). Null-safe: absent record → rt.type undefined → `rt.type != "research"` true
56
+ # → preserves today's block (AskUserQuestion stays an additional allow-signal via asked.count).
57
+ - call: read_state
58
+ args:
59
+ key: request-type
60
+ as: rt
51
61
  - call: verdict
52
- if: '(st == "scoping" || st == "researching") && asked.count == 0'
62
+ if: '(st == "scoping" || st == "researching") && asked.count == 0 && rt.type != "research"'
53
63
  args:
54
64
  level: block
55
65
  message: >-
@@ -51,13 +51,19 @@ guards:
51
51
  Even on unpushed commits — make a follow-up commit instead.
52
52
  Override only if the user explicitly requested an amend in
53
53
  THIS turn.
54
+ # GMP.1 (wg-320845a92b65): structural — matches a real force-push to main/master (program +
55
+ # subcommand + a force flag + a main/master refspec TARGET), not the substring inside a
56
+ # grep/echo/prose mention. arg_any matches the push destination (src:dst → dst), so
57
+ # `main:develop` (push TO develop) does NOT false-block.
54
58
  - name: no-force-push-main
55
59
  on: tool_call
56
60
  detect:
57
- call: match_command
61
+ call: command_invokes
58
62
  args:
59
- pattern: '(?:^|[;&|\n(])\s*git\s+(?:-[cC]\s+\S+\s+)*push\b[^\n]*(--force|-f)\b[^\n]*\b(main|master)\b'
60
- target: tool_args.command
63
+ program: git
64
+ subcommand: push
65
+ flag_any: ['--force', '-f', '--force-with-lease']
66
+ arg_any: ['main', 'master']
61
67
  when: hit
62
68
  level: block
63
69
  message: >-
@@ -81,13 +87,16 @@ guards:
81
87
  engine types only — re-word using substrate vocabulary.
82
88
 
83
89
  # versioning patch-only (full_stop_and_redo per drift_response)
90
+ # GMP.1 (wg-320845a92b65): structural — a real `npm version minor|major` invocation, not a prose
91
+ # mention. arg_any matches the bump keyword positional after the `version` subcommand.
84
92
  - name: versioning-pre1-patch-only
85
93
  on: tool_call
86
94
  detect:
87
- call: match_command
95
+ call: command_invokes
88
96
  args:
89
- pattern: '(?:^|[;&|\n(])\s*npm\s+version\s+(minor|major)\b'
90
- target: tool_args.command
97
+ program: npm
98
+ subcommand: version
99
+ arg_any: ['minor', 'major']
91
100
  when: hit
92
101
  level: block
93
102
  message: >-
@@ -52,6 +52,14 @@ rules:
52
52
  (e.g. read_rubric → inject_context at prompt_submit). A gate
53
53
  teaches its bar; it does not only block. (Light block/warn
54
54
  gates teach via a remedy-naming message instead.)
55
+ [ ] PACK TEACHES ITS METHOD (wg-7f6225238a27): if the pack has a
56
+ multi-step workflow, ship a `procedure.md` at the pack root —
57
+ the agent-facing OPERATING PROCEDURE (the METHOD: how to do the
58
+ work so the gates pass first-try), the complement to the gate's
59
+ rubric (the BAR). Deliver it with an unconditional rule calling
60
+ `procedure_pre_inject` (it self-gates on the pack's FSM:
61
+ engaged = state != initial). Keep it METHOD not CRITERIA — it
62
+ references the rubric, never restates it. See pack-runtime.md §1.5.
55
63
  [ ] For directive verdict: next_action is skill XOR tool
56
64
  XOR profession (exactly one)
57
65
  [ ] No vendor model names anywhere (use model_alias)