create-walle 0.10.1 → 0.10.3

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 (681) hide show
  1. package/README.md +7 -1
  2. package/lib/owner-write-safety.js +135 -0
  3. package/lib/public-runtime.js +13 -5
  4. package/lib/release-schema.json +3 -2
  5. package/lib/runtime-closure-policy.json +11 -8
  6. package/package.json +1 -1
  7. package/template/bin/deps-doctor.js +1 -1
  8. package/template/bin/node-bin.sh +11 -0
  9. package/template/coding-task-manager/api-prompts.js +55 -29
  10. package/template/coding-task-manager/bin/claude-hook.js +62 -4
  11. package/template/coding-task-manager/bin/claude-table-parity.js +307 -0
  12. package/template/coding-task-manager/bin/conversation-storage-auto-migration-lib.js +16 -1
  13. package/template/coding-task-manager/bin/conversation-storage-generation-evidence.js +9 -2
  14. package/template/coding-task-manager/bin/conversation-storage-service-entry-lib.js +16 -1
  15. package/template/coding-task-manager/bin/conversation-storage-walle-owner.js +247 -0
  16. package/template/coding-task-manager/bin/ctm-machine-pair.js +160 -0
  17. package/template/coding-task-manager/bin/ctm-relay-client.js +35 -12
  18. package/template/coding-task-manager/bin/land.js +2069 -0
  19. package/template/coding-task-manager/bin/lead-wait-census.js +1348 -0
  20. package/template/coding-task-manager/bin/memory-census.js +4 -2
  21. package/template/coding-task-manager/bin/memory-sync-verify.js +151 -0
  22. package/template/coding-task-manager/bin/probe-refusal-scope.js +530 -0
  23. package/template/coding-task-manager/bin/repair-foreign-clone.js +564 -0
  24. package/template/coding-task-manager/bin/repair-resume-echo-titles.js +248 -0
  25. package/template/coding-task-manager/bin/write-lock-bench.js +111 -0
  26. package/template/coding-task-manager/db.js +860 -317
  27. package/template/coding-task-manager/git-utils.js +44 -0
  28. package/template/coding-task-manager/lib/acp/acp-client.js +383 -0
  29. package/template/coding-task-manager/lib/acp/dsh-context-truth.js +176 -0
  30. package/template/coding-task-manager/lib/acp/dsh-launch-model.js +302 -0
  31. package/template/coding-task-manager/lib/acp/dsh-mcp-servers.js +194 -0
  32. package/template/coding-task-manager/lib/acp/dsh-prompt-lane.js +616 -0
  33. package/template/coding-task-manager/lib/acp/dsh-route-patch.js +308 -0
  34. package/template/coding-task-manager/lib/acp/dsh-session-runtime.js +522 -0
  35. package/template/coding-task-manager/lib/acp/dsh-transcript.js +395 -0
  36. package/template/coding-task-manager/lib/acp/dsh-usage-log.js +162 -0
  37. package/template/coding-task-manager/lib/acp/ndjson-stdio-transport.js +225 -0
  38. package/template/coding-task-manager/lib/adopted-host-redial.js +47 -7
  39. package/template/coding-task-manager/lib/adopted-launch-environment.js +123 -0
  40. package/template/coding-task-manager/lib/agent-auto-update-runtime.js +0 -3
  41. package/template/coding-task-manager/lib/agent-auto-update.js +26 -10
  42. package/template/coding-task-manager/lib/agent-bundle/build.js +657 -0
  43. package/template/coding-task-manager/lib/agent-bundle/codex-install.js +558 -0
  44. package/template/coding-task-manager/lib/agent-bundle/drift.js +120 -0
  45. package/template/coding-task-manager/lib/agent-bundle/gc.js +522 -0
  46. package/template/coding-task-manager/lib/agent-bundle/inventory.js +346 -0
  47. package/template/coding-task-manager/lib/agent-bundle/push.js +717 -0
  48. package/template/coding-task-manager/lib/agent-bundle/skill-transfer.js +724 -0
  49. package/template/coding-task-manager/lib/agent-bundle/spawn.js +119 -0
  50. package/template/coding-task-manager/lib/agent-bundle/store.js +568 -0
  51. package/template/coding-task-manager/lib/agent-capabilities.js +142 -12
  52. package/template/coding-task-manager/lib/agent-cli-cache.js +30 -5
  53. package/template/coding-task-manager/lib/agent-definitions.js +19 -0
  54. package/template/coding-task-manager/lib/agent-hooks-codex-toml.js +28 -16
  55. package/template/coding-task-manager/lib/agent-hooks-codex-workspace.js +9 -1
  56. package/template/coding-task-manager/lib/agent-hooks-installer.js +23 -8
  57. package/template/coding-task-manager/lib/agent-hooks-prune.js +37 -11
  58. package/template/coding-task-manager/lib/agent-hooks-shim.js +105 -0
  59. package/template/coding-task-manager/lib/agent-presets.js +99 -1
  60. package/template/coding-task-manager/lib/agent-title-apply.js +88 -0
  61. package/template/coding-task-manager/lib/agent-title-backfill-read.js +92 -0
  62. package/template/coding-task-manager/lib/agent-upgrade-jobs.js +12 -1
  63. package/template/coding-task-manager/lib/agent-version-service.js +74 -11
  64. package/template/coding-task-manager/lib/all-sessions-query.js +6 -2
  65. package/template/coding-task-manager/lib/api/agent-bundles.js +436 -0
  66. package/template/coding-task-manager/lib/api/backup-retention.js +83 -0
  67. package/template/coding-task-manager/lib/api/conversation-sync-routes.js +124 -0
  68. package/template/coding-task-manager/lib/api/diagnostics.js +549 -69
  69. package/template/coding-task-manager/lib/api/fleet.js +118 -0
  70. package/template/coding-task-manager/lib/api/host-stats.js +98 -0
  71. package/template/coding-task-manager/lib/api/hub-bridge.js +243 -0
  72. package/template/coding-task-manager/lib/api/ingress.js +43 -12
  73. package/template/coding-task-manager/lib/api/landing.js +403 -0
  74. package/template/coding-task-manager/lib/api/machine-pairing.js +285 -0
  75. package/template/coding-task-manager/lib/api/machine-pool.js +307 -0
  76. package/template/coding-task-manager/lib/api/machines.js +1150 -0
  77. package/template/coding-task-manager/lib/api/memory-sync-routes.js +335 -0
  78. package/template/coding-task-manager/lib/api/misc-ops.js +25 -5
  79. package/template/coding-task-manager/lib/api/providers.js +53 -6
  80. package/template/coding-task-manager/lib/api/remote-sessions.js +1326 -0
  81. package/template/coding-task-manager/lib/api/resume-from-store.js +25 -0
  82. package/template/coding-task-manager/lib/api/session-attach.js +623 -0
  83. package/template/coding-task-manager/lib/api/session-messages.js +1384 -0
  84. package/template/coding-task-manager/lib/api/sessions.js +237 -59
  85. package/template/coding-task-manager/lib/api/setup-network.js +544 -16
  86. package/template/coding-task-manager/lib/api/setup-wizard-handlers.js +884 -0
  87. package/template/coding-task-manager/lib/api/setup.js +829 -10
  88. package/template/coding-task-manager/lib/api/transcript-history.js +17 -4
  89. package/template/coding-task-manager/lib/api/walle-bridge.js +9 -1
  90. package/template/coding-task-manager/lib/api/worktrees.js +38 -37
  91. package/template/coding-task-manager/lib/approval-drift.js +16 -1
  92. package/template/coding-task-manager/lib/approval-logical-frame.js +5 -1
  93. package/template/coding-task-manager/lib/approval-scope.js +68 -4
  94. package/template/coding-task-manager/lib/attachment-reconciler-wiring.js +5 -2
  95. package/template/coding-task-manager/lib/auth-context.js +32 -2
  96. package/template/coding-task-manager/lib/auth-rate-limit.js +64 -1
  97. package/template/coding-task-manager/lib/auth-rules.js +474 -62
  98. package/template/coding-task-manager/lib/background-stop.js +369 -0
  99. package/template/coding-task-manager/lib/best-of-attempts.js +4 -1
  100. package/template/coding-task-manager/lib/best-of-launch-plan.js +52 -0
  101. package/template/coding-task-manager/lib/box-keep-awake.js +89 -0
  102. package/template/coding-task-manager/lib/broadcast-reason-stats.js +152 -0
  103. package/template/coding-task-manager/lib/broadcast-serialize.js +7 -1
  104. package/template/coding-task-manager/lib/browser-session-broker.js +9 -1
  105. package/template/coding-task-manager/lib/browser-use-adapter.js +33 -2
  106. package/template/coding-task-manager/lib/build-info.js +4 -2
  107. package/template/coding-task-manager/lib/claude-markdown-ansi.js +27 -85
  108. package/template/coding-task-manager/lib/claude-model-truth.js +13 -2
  109. package/template/coding-task-manager/lib/claude-session-title.js +6 -30
  110. package/template/coding-task-manager/lib/claude-table-layout.js +322 -0
  111. package/template/coding-task-manager/lib/claude-transcript-terminal-renderer.js +17 -13
  112. package/template/coding-task-manager/lib/client-diag-handler.js +69 -2
  113. package/template/coding-task-manager/lib/codex-app-server-client.js +14 -16
  114. package/template/coding-task-manager/lib/codex-config-guard.js +33 -3
  115. package/template/coding-task-manager/lib/codex-configuration-history.js +55 -0
  116. package/template/coding-task-manager/lib/codex-harness-qualification.js +55 -20
  117. package/template/coding-task-manager/lib/codex-launch-health.js +29 -2
  118. package/template/coding-task-manager/lib/codex-link-preparation.js +9 -8
  119. package/template/coding-task-manager/lib/codex-paths.js +2 -1
  120. package/template/coding-task-manager/lib/codex-rollout-history.js +743 -0
  121. package/template/coding-task-manager/lib/coding-agent-models.js +48 -42
  122. package/template/coding-task-manager/lib/coding-cli-skill-installer.js +44 -14
  123. package/template/coding-task-manager/lib/coding-session-model-adapters.js +70 -4
  124. package/template/coding-task-manager/lib/coding-session-model-owner.js +1 -1
  125. package/template/coding-task-manager/lib/coding-session-model-projection.js +5 -0
  126. package/template/coding-task-manager/lib/coding-session-model-public.js +7 -1
  127. package/template/coding-task-manager/lib/coding-session-model-runtime.js +24 -6
  128. package/template/coding-task-manager/lib/coding-session-model-scan.js +31 -0
  129. package/template/coding-task-manager/lib/coding-session-model-state.js +17 -0
  130. package/template/coding-task-manager/lib/coding-session-model-sync-state.js +0 -1
  131. package/template/coding-task-manager/lib/conversation-freshness-diagnostics.js +280 -0
  132. package/template/coding-task-manager/lib/conversation-import/cursor-guard-owner.js +10 -0
  133. package/template/coding-task-manager/lib/conversation-item-clock.js +261 -0
  134. package/template/coding-task-manager/lib/conversation-source-registry.js +5 -0
  135. package/template/coding-task-manager/lib/conversation-store-v2.js +44 -0
  136. package/template/coding-task-manager/lib/conversation-sync.js +355 -0
  137. package/template/coding-task-manager/lib/create/resolve-launch-params.js +104 -13
  138. package/template/coding-task-manager/lib/create/worker-role-profile.js +4 -4
  139. package/template/coding-task-manager/lib/create-intent-lease.js +51 -0
  140. package/template/coding-task-manager/lib/ctm-boot-lifecycle.js +17 -1
  141. package/template/coding-task-manager/lib/ctm-session-context-api.js +97 -6
  142. package/template/coding-task-manager/lib/db-domain-tables.js +8 -0
  143. package/template/coding-task-manager/lib/db-domains.js +22 -2
  144. package/template/coding-task-manager/lib/db-owner-dispatch-probe.js +32 -0
  145. package/template/coding-task-manager/lib/db-owner-op-registry.js +7 -0
  146. package/template/coding-task-manager/lib/db-owner-request-counts.js +178 -0
  147. package/template/coding-task-manager/lib/db-owner-worker-client.js +68 -14
  148. package/template/coding-task-manager/lib/db-schema-source-files.js +6 -0
  149. package/template/coding-task-manager/lib/deferred-restore-attempt.js +6 -2
  150. package/template/coding-task-manager/lib/feature-manifest.js +5 -1
  151. package/template/coding-task-manager/lib/fleet-conversation-route.js +97 -0
  152. package/template/coding-task-manager/lib/fleet-fanout.js +78 -0
  153. package/template/coding-task-manager/lib/fleet-hub.js +762 -0
  154. package/template/coding-task-manager/lib/fleet-origin-follower.js +252 -0
  155. package/template/coding-task-manager/lib/fleet-resolver-effects.js +147 -0
  156. package/template/coding-task-manager/lib/fleet-resolver-tick.js +148 -0
  157. package/template/coding-task-manager/lib/fleet-resolver.js +454 -0
  158. package/template/coding-task-manager/lib/fleet-session-list-routes.js +114 -0
  159. package/template/coding-task-manager/lib/fleet-session-lists.js +672 -0
  160. package/template/coding-task-manager/lib/fleet-update.js +798 -0
  161. package/template/coding-task-manager/lib/fs-watcher-root-watch.js +141 -0
  162. package/template/coding-task-manager/lib/fs-watcher.js +61 -44
  163. package/template/coding-task-manager/lib/harness-history-transition.js +52 -11
  164. package/template/coding-task-manager/lib/headless-inflight-ops.js +203 -0
  165. package/template/coding-task-manager/lib/headless-missing-reply.js +42 -0
  166. package/template/coding-task-manager/lib/headless-term-service.js +139 -25
  167. package/template/coding-task-manager/lib/hermetic-agent-launch-guard.js +10 -0
  168. package/template/coding-task-manager/lib/history-transition-read-op.js +175 -8
  169. package/template/coding-task-manager/lib/host-control-dial.js +167 -0
  170. package/template/coding-task-manager/lib/host-cpu-categories.js +310 -0
  171. package/template/coding-task-manager/lib/host-fseventsd-sampler.js +399 -0
  172. package/template/coding-task-manager/lib/host-handoff-orchestrator.js +16 -2
  173. package/template/coding-task-manager/lib/host-handoff.js +50 -15
  174. package/template/coding-task-manager/lib/host-health-ledger.js +164 -12
  175. package/template/coding-task-manager/lib/host-self-truth-watchdog.js +4 -0
  176. package/template/coding-task-manager/lib/host-stats.js +475 -0
  177. package/template/coding-task-manager/lib/host-threadpool-evacuation.js +160 -0
  178. package/template/coding-task-manager/lib/host-threadpool-monitor.js +14 -1
  179. package/template/coding-task-manager/lib/hosted-input-dispatch.js +203 -0
  180. package/template/coding-task-manager/lib/hosted-sync-worker.js +141 -310
  181. package/template/coding-task-manager/lib/hub-bridge-access.js +798 -0
  182. package/template/coding-task-manager/lib/hub-bridge-box.js +409 -0
  183. package/template/coding-task-manager/lib/hub-bridge-mcp.js +380 -0
  184. package/template/coding-task-manager/lib/hub-bridge-mesh.js +313 -0
  185. package/template/coding-task-manager/lib/hub-bridge-ops.js +721 -0
  186. package/template/coding-task-manager/lib/hub-bridge.js +398 -0
  187. package/template/coding-task-manager/lib/idle-notify.js +491 -0
  188. package/template/coding-task-manager/lib/instance-id-ownership-manifest.js +12 -0
  189. package/template/coding-task-manager/lib/instance-manifest-runtime.js +3 -0
  190. package/template/coding-task-manager/lib/instance-manifest.js +18 -2
  191. package/template/coding-task-manager/lib/instance-sync-status.js +33 -8
  192. package/template/coding-task-manager/lib/landing/agent-rule.txt +1 -0
  193. package/template/coding-task-manager/lib/landing/batch-runner.js +366 -0
  194. package/template/coding-task-manager/lib/landing/config.js +536 -0
  195. package/template/coding-task-manager/lib/landing/ctm-view.js +256 -0
  196. package/template/coding-task-manager/lib/landing/gate.js +360 -0
  197. package/template/coding-task-manager/lib/landing/git.js +344 -0
  198. package/template/coding-task-manager/lib/landing/lease.js +247 -0
  199. package/template/coding-task-manager/lib/landing/merge-delta.js +380 -0
  200. package/template/coding-task-manager/lib/landing/proof.js +223 -0
  201. package/template/coding-task-manager/lib/landing/queue.js +998 -0
  202. package/template/coding-task-manager/lib/landing/radar.js +489 -0
  203. package/template/coding-task-manager/lib/landing/resolve-cli.js +424 -0
  204. package/template/coding-task-manager/lib/landing/state.js +263 -0
  205. package/template/coding-task-manager/lib/landing/stop.js +49 -0
  206. package/template/coding-task-manager/lib/landing/sync-cli.js +475 -0
  207. package/template/coding-task-manager/lib/landing/sync.js +456 -0
  208. package/template/coding-task-manager/lib/landing/train.js +885 -0
  209. package/template/coding-task-manager/lib/landing/window.js +57 -0
  210. package/template/coding-task-manager/lib/launch-environment.js +121 -0
  211. package/template/coding-task-manager/lib/launch-model-override.js +193 -8
  212. package/template/coding-task-manager/lib/launch-plan-pool.js +2 -1
  213. package/template/coding-task-manager/lib/launch-plan-warm-cache.js +6 -0
  214. package/template/coding-task-manager/lib/launch-plan-worker.js +59 -2
  215. package/template/coding-task-manager/lib/lead-model-observer.js +57 -1
  216. package/template/coding-task-manager/lib/lead-model-options.js +160 -3
  217. package/template/coding-task-manager/lib/lead-model-restore-reconciliation.js +106 -24
  218. package/template/coding-task-manager/lib/lead-model-switch-runtime.js +409 -72
  219. package/template/coding-task-manager/lib/lead-model-switch.js +115 -10
  220. package/template/coding-task-manager/lib/lead-model-transition-runtime.js +14 -2
  221. package/template/coding-task-manager/lib/lead-model-transition-store.js +85 -9
  222. package/template/coding-task-manager/lib/lead-route-preflight.js +179 -0
  223. package/template/coding-task-manager/lib/lead-switch-history-mode.js +110 -0
  224. package/template/coding-task-manager/lib/lead-wire-agent.js +7 -0
  225. package/template/coding-task-manager/lib/legacy-draft-cancellation-recovery.js +111 -0
  226. package/template/coding-task-manager/lib/lifecycle-wake-experiment.js +9 -2
  227. package/template/coding-task-manager/lib/live-defer-announce.js +45 -0
  228. package/template/coding-task-manager/lib/login-tripwire.js +1 -0
  229. package/template/coding-task-manager/lib/machine-pairing.js +238 -0
  230. package/template/coding-task-manager/lib/machine-pool.js +409 -0
  231. package/template/coding-task-manager/lib/machine-registry.js +1494 -0
  232. package/template/coding-task-manager/lib/machine-self.js +66 -0
  233. package/template/coding-task-manager/lib/macos-capabilities.js +32 -15
  234. package/template/coding-task-manager/lib/main-thread-lint-exemptions.json +485 -57
  235. package/template/coding-task-manager/lib/mainloop-observability.js +14 -9
  236. package/template/coding-task-manager/lib/media-draft-owner.js +16 -3
  237. package/template/coding-task-manager/lib/media-journal-control-reader.js +473 -0
  238. package/template/coding-task-manager/lib/media-journal.js +84 -27
  239. package/template/coding-task-manager/lib/media-store-options.js +43 -15
  240. package/template/coding-task-manager/lib/memory-join.js +337 -0
  241. package/template/coding-task-manager/lib/memory-sync-verify.js +393 -0
  242. package/template/coding-task-manager/lib/memory-sync.js +565 -0
  243. package/template/coding-task-manager/lib/migrations/v56-host-samples-and-machine-pool.js +76 -0
  244. package/template/coding-task-manager/lib/migrations/v57-delegate-pref-mirror-opencode.js +68 -0
  245. package/template/coding-task-manager/lib/migrations/v58-subagent-launch-native-subagents.js +42 -0
  246. package/template/coding-task-manager/lib/migrations/v59-coding-session-model-state-dsh.js +73 -0
  247. package/template/coding-task-manager/lib/migrations/v60-delegate-pref-mirror-dsh.js +78 -0
  248. package/template/coding-task-manager/lib/migrations/v61-conversation-item-clock.js +71 -0
  249. package/template/coding-task-manager/lib/mirror-feed-sanitize.js +12 -3
  250. package/template/coding-task-manager/lib/model-availability.js +727 -0
  251. package/template/coding-task-manager/lib/model-execution-recipe-metadata.js +4 -6
  252. package/template/coding-task-manager/lib/model-host-receipt.js +6 -3
  253. package/template/coding-task-manager/lib/model-id-rule.js +19 -0
  254. package/template/coding-task-manager/lib/model-proxy/anthropic-face.js +8 -0
  255. package/template/coding-task-manager/lib/model-proxy/auto-mode-review.js +110 -23
  256. package/template/coding-task-manager/lib/model-proxy/chat-response-translators.js +6 -0
  257. package/template/coding-task-manager/lib/model-proxy/generation-probe.js +60 -17
  258. package/template/coding-task-manager/lib/model-proxy/handoff.js +494 -0
  259. package/template/coding-task-manager/lib/model-proxy/historical-tool-declarations.js +37 -0
  260. package/template/coding-task-manager/lib/model-proxy/lead-request-validation.js +1 -0
  261. package/template/coding-task-manager/lib/model-proxy/lead-token-admin.js +130 -0
  262. package/template/coding-task-manager/lib/model-proxy/lead-worker-picks.js +25 -0
  263. package/template/coding-task-manager/lib/model-proxy/native-lead-listener.js +61 -7
  264. package/template/coding-task-manager/lib/model-proxy/proxy-cli.js +200 -0
  265. package/template/coding-task-manager/lib/model-proxy/proxy-instance-record.js +257 -0
  266. package/template/coding-task-manager/lib/model-proxy/refusal-scope.js +151 -0
  267. package/template/coding-task-manager/lib/model-proxy/request-budget-store.js +11 -2
  268. package/template/coding-task-manager/lib/model-proxy/stream-accounting.js +205 -0
  269. package/template/coding-task-manager/lib/model-proxy/tokens.js +147 -5
  270. package/template/coding-task-manager/lib/model-proxy/upstream-outcome.js +18 -0
  271. package/template/coding-task-manager/lib/native-agent-model-args.js +25 -22
  272. package/template/coding-task-manager/lib/native-history-control.js +7 -5
  273. package/template/coding-task-manager/lib/native-lead-settings-client.js +46 -5
  274. package/template/coding-task-manager/lib/native-lead-tls.js +18 -4
  275. package/template/coding-task-manager/lib/oauth-proxy-supervisor.js +776 -75
  276. package/template/coding-task-manager/lib/online-backup-worker-client.js +2 -0
  277. package/template/coding-task-manager/lib/opencode-cli.js +480 -0
  278. package/template/coding-task-manager/lib/opencode-launch-model.js +471 -0
  279. package/template/coding-task-manager/lib/opencode-v1-plugin/model-carrier.mjs +35 -0
  280. package/template/coding-task-manager/lib/opencode-v2-plugin/server.js +118 -0
  281. package/template/coding-task-manager/lib/owner-action-manifest-data.json +15 -1
  282. package/template/coding-task-manager/lib/painted-row-recorder.js +9 -1
  283. package/template/coding-task-manager/lib/park-composer-draft.js +54 -0
  284. package/template/coding-task-manager/lib/park-fresh-relaunch.js +41 -10
  285. package/template/coding-task-manager/lib/perf-phase-trace.js +72 -0
  286. package/template/coding-task-manager/lib/perf-summary.js +7 -0
  287. package/template/coding-task-manager/lib/perf-tracker.js +63 -2
  288. package/template/coding-task-manager/lib/project-config.js +7 -0
  289. package/template/coding-task-manager/lib/prompt-purge-v2.js +52 -1
  290. package/template/coding-task-manager/lib/prompt-submission-contract.js +21 -1
  291. package/template/coding-task-manager/lib/provider-login-broker.js +264 -24
  292. package/template/coding-task-manager/lib/provider-login-capture.js +153 -0
  293. package/template/coding-task-manager/lib/provider-login-tab.js +10 -2
  294. package/template/coding-task-manager/lib/queue-draft-status-overlay.js +36 -0
  295. package/template/coding-task-manager/lib/raw-codex-history-window.js +5 -3
  296. package/template/coding-task-manager/lib/read-pool-client.js +94 -4
  297. package/template/coding-task-manager/lib/read-pool-op-registry.js +10 -1
  298. package/template/coding-task-manager/lib/read-pool-worker-handle.js +29 -4
  299. package/template/coding-task-manager/lib/recent-catalog-query.js +41 -0
  300. package/template/coding-task-manager/lib/recent-session-catalog-response.js +76 -10
  301. package/template/coding-task-manager/lib/recovery-evidence.js +26 -11
  302. package/template/coding-task-manager/lib/relay-client.js +57 -3
  303. package/template/coding-task-manager/lib/relink-audit.js +34 -5
  304. package/template/coding-task-manager/lib/remote-command-context.js +12 -0
  305. package/template/coding-task-manager/lib/remote-command-runtime.js +13 -1
  306. package/template/coding-task-manager/lib/remote-machine-catalog.js +1357 -0
  307. package/template/coding-task-manager/lib/remote-machine-create.js +1233 -0
  308. package/template/coding-task-manager/lib/remote-machine-link.js +1426 -0
  309. package/template/coding-task-manager/lib/remote-machine-proxy.js +654 -0
  310. package/template/coding-task-manager/lib/remote-session-forward.js +364 -0
  311. package/template/coding-task-manager/lib/remote-submission-status.js +6 -0
  312. package/template/coding-task-manager/lib/remote-terminal-target.js +9 -2
  313. package/template/coding-task-manager/lib/restart-guard.js +18 -6
  314. package/template/coding-task-manager/lib/restart-outcome-truth.js +20 -3
  315. package/template/coding-task-manager/lib/restart-preflight.js +9 -2
  316. package/template/coding-task-manager/lib/restore-backoff-gate.js +10 -2
  317. package/template/coding-task-manager/lib/restore-prepare-retry.js +12 -5
  318. package/template/coding-task-manager/lib/restore-resume-batch.js +22 -1
  319. package/template/coding-task-manager/lib/restore-seed-modes.js +87 -0
  320. package/template/coding-task-manager/lib/restored-scrollback-hydration-runtime.js +22 -2
  321. package/template/coding-task-manager/lib/resume-admission.js +17 -3
  322. package/template/coding-task-manager/lib/resume-blocked-wire.js +62 -1
  323. package/template/coding-task-manager/lib/resume-cwd.js +13 -0
  324. package/template/coding-task-manager/lib/resume-from-store.js +12 -1
  325. package/template/coding-task-manager/lib/resume-origin-facts.js +38 -1
  326. package/template/coding-task-manager/lib/resume-preflight.js +21 -16
  327. package/template/coding-task-manager/lib/review-repo-admission.js +39 -6
  328. package/template/coding-task-manager/lib/review-repo-registry.js +74 -18
  329. package/template/coding-task-manager/lib/root-delivery-runtime.js +74 -17
  330. package/template/coding-task-manager/lib/root-delivery-selection.js +37 -1
  331. package/template/coding-task-manager/lib/root-prompt-admission.js +33 -2
  332. package/template/coding-task-manager/lib/root-prompt-flow.js +168 -34
  333. package/template/coding-task-manager/lib/runtime-contract.js +3 -1
  334. package/template/coding-task-manager/lib/schema-indexes.js +1 -0
  335. package/template/coding-task-manager/lib/scrollback-archive-store.js +7 -4
  336. package/template/coding-task-manager/lib/session-analysis-memory.js +2 -0
  337. package/template/coding-task-manager/lib/session-context-locator.js +742 -0
  338. package/template/coding-task-manager/lib/session-create/attachment.js +2 -2
  339. package/template/coding-task-manager/lib/session-create/codex-native-provider-gate.js +218 -0
  340. package/template/coding-task-manager/lib/session-create/codex-resume-exit-classify.js +52 -0
  341. package/template/coding-task-manager/lib/session-create/create-phases.js +118 -0
  342. package/template/coding-task-manager/lib/session-create/delegate-worker.js +179 -20
  343. package/template/coding-task-manager/lib/session-create/dsh-session.js +930 -0
  344. package/template/coding-task-manager/lib/session-create/identity.js +20 -1
  345. package/template/coding-task-manager/lib/session-create/lead-route-launch.js +186 -13
  346. package/template/coding-task-manager/lib/session-create/native-lead-lifetime.js +55 -3
  347. package/template/coding-task-manager/lib/session-create/opencode-lead-provider.js +50 -0
  348. package/template/coding-task-manager/lib/session-create/prepared.js +201 -9
  349. package/template/coding-task-manager/lib/session-create/provider-launch-context.js +77 -0
  350. package/template/coding-task-manager/lib/session-create/provider-process.js +193 -64
  351. package/template/coding-task-manager/lib/session-create/response.js +37 -19
  352. package/template/coding-task-manager/lib/session-create/structured-session.js +27 -0
  353. package/template/coding-task-manager/lib/session-create/subagent-pick-table.js +3 -1
  354. package/template/coding-task-manager/lib/session-create/subagent-pick.js +458 -9
  355. package/template/coding-task-manager/lib/session-create/transcript.js +14 -5
  356. package/template/coding-task-manager/lib/session-create/worker-budget-setup.js +21 -2
  357. package/template/coding-task-manager/lib/session-create/worker-continuation.js +50 -2
  358. package/template/coding-task-manager/lib/session-create/worker-launch-sandbox.js +39 -10
  359. package/template/coding-task-manager/lib/session-create/worker-notices.js +94 -5
  360. package/template/coding-task-manager/lib/session-create/worker-observability.js +101 -9
  361. package/template/coding-task-manager/lib/session-create/worker-stop.js +11 -3
  362. package/template/coding-task-manager/lib/session-create/worker-wait-watcher.js +315 -0
  363. package/template/coding-task-manager/lib/session-empty.js +13 -10
  364. package/template/coding-task-manager/lib/session-geometry-authority-handler.js +10 -1
  365. package/template/coding-task-manager/lib/session-host-manager.js +212 -206
  366. package/template/coding-task-manager/lib/session-jobs.js +20 -10
  367. package/template/coding-task-manager/lib/session-lifecycle.js +28 -4
  368. package/template/coding-task-manager/lib/session-model-action-preconditions.js +15 -2
  369. package/template/coding-task-manager/lib/session-model-intent-contract.js +11 -8
  370. package/template/coding-task-manager/lib/session-park.js +738 -0
  371. package/template/coding-task-manager/lib/session-path-grant.js +13 -4
  372. package/template/coding-task-manager/lib/session-resource-sampler.js +19 -9
  373. package/template/coding-task-manager/lib/session-standup.js +67 -4
  374. package/template/coding-task-manager/lib/session-status-ledger.js +147 -6
  375. package/template/coding-task-manager/lib/session-status-runtime.js +45 -1
  376. package/template/coding-task-manager/lib/session-title-mirror.js +25 -57
  377. package/template/coding-task-manager/lib/session-transcript-trash.js +8 -1
  378. package/template/coding-task-manager/lib/session-transport.js +17 -0
  379. package/template/coding-task-manager/lib/session-workspace-projection.js +54 -5
  380. package/template/coding-task-manager/lib/session-workspace-tracking-runtime.js +213 -1
  381. package/template/coding-task-manager/lib/skill-autocomplete-query.js +120 -3
  382. package/template/coding-task-manager/lib/skill-autocomplete.js +15 -1
  383. package/template/coding-task-manager/lib/sqlite-file-set.js +39 -0
  384. package/template/coding-task-manager/lib/standup-search-adapter.js +16 -2
  385. package/template/coding-task-manager/lib/startup-pointer-write.js +57 -0
  386. package/template/coding-task-manager/lib/state-sync/client-ledger.js +12 -0
  387. package/template/coding-task-manager/lib/state-sync/frame-emitter.js +319 -100
  388. package/template/coding-task-manager/lib/state-sync/painted-frame-field.js +11 -0
  389. package/template/coding-task-manager/lib/storage/coding-session-model-store.js +25 -23
  390. package/template/coding-task-manager/lib/storage/delegate-pref-mirror-store.js +32 -9
  391. package/template/coding-task-manager/lib/structured-session-boot-sweep.js +235 -0
  392. package/template/coding-task-manager/lib/submission-ack.js +90 -2
  393. package/template/coding-task-manager/lib/surviving-owner-bootstrap.js +7 -2
  394. package/template/coding-task-manager/lib/surviving-owner-recovery.js +2 -1
  395. package/template/coding-task-manager/lib/systemd-scope.js +115 -0
  396. package/template/coding-task-manager/lib/telemetry-receiver.js +39 -0
  397. package/template/coding-task-manager/lib/terminal-attach-geometry.js +985 -0
  398. package/template/coding-task-manager/lib/terminal-bootstrap.js +30 -0
  399. package/template/coding-task-manager/lib/terminal-draft-http-status.js +25 -0
  400. package/template/coding-task-manager/lib/terminal-draft-operation.js +357 -0
  401. package/template/coding-task-manager/lib/terminal-input-admission.js +17 -1
  402. package/template/coding-task-manager/lib/terminal-input-prepared.js +563 -0
  403. package/template/coding-task-manager/lib/transcript-archiver.js +229 -229
  404. package/template/coding-task-manager/lib/transcript-cache-temps.js +171 -0
  405. package/template/coding-task-manager/lib/transcript-frame-cache.js +20 -5
  406. package/template/coding-task-manager/lib/transcript-guard-job.js +55 -4
  407. package/template/coding-task-manager/lib/transcript-link.js +77 -0
  408. package/template/coding-task-manager/lib/transcript-manifest-store.js +8 -4
  409. package/template/coding-task-manager/lib/transcript-source.js +44 -7
  410. package/template/coding-task-manager/lib/transcript-store.js +49 -0
  411. package/template/coding-task-manager/lib/tunnel-lane-governor.js +6 -3
  412. package/template/coding-task-manager/lib/typing-interaction-trace.js +198 -3
  413. package/template/coding-task-manager/lib/typing-worker-stages.js +60 -0
  414. package/template/coding-task-manager/lib/usage-ledger/backfill.js +40 -5
  415. package/template/coding-task-manager/lib/usage-ledger/client.js +4 -1
  416. package/template/coding-task-manager/lib/usage-ledger/dsh-parse.js +152 -0
  417. package/template/coding-task-manager/lib/usage-ledger/dsh-read.js +73 -0
  418. package/template/coding-task-manager/lib/usage-ledger/ingest.js +34 -6
  419. package/template/coding-task-manager/lib/usage-ledger/live.js +35 -8
  420. package/template/coding-task-manager/lib/usage-ledger/read.js +29 -20
  421. package/template/coding-task-manager/lib/usage-ledger/schema.js +61 -1
  422. package/template/coding-task-manager/lib/usage-ledger/task-coordinator.js +4 -2
  423. package/template/coding-task-manager/lib/visible-revision-watchdog.js +8 -12
  424. package/template/coding-task-manager/lib/wake-skip-reasons.js +47 -0
  425. package/template/coding-task-manager/lib/walle/turn.js +1 -1
  426. package/template/coding-task-manager/lib/walle-history-serve.js +838 -0
  427. package/template/coding-task-manager/lib/walle-kill-authority.js +2 -2
  428. package/template/coding-task-manager/lib/walle-log-rotation.js +164 -1
  429. package/template/coding-task-manager/lib/walle-mcp-auto-config.js +56 -2
  430. package/template/coding-task-manager/lib/walle-row-history.js +495 -0
  431. package/template/coding-task-manager/lib/walle-supervisor.js +130 -27
  432. package/template/coding-task-manager/lib/watch-worker-client.js +203 -0
  433. package/template/coding-task-manager/lib/worker-failure-classify.js +13 -1
  434. package/template/coding-task-manager/lib/worker-terminal-output.js +5 -2
  435. package/template/coding-task-manager/lib/ws/hub-bridge.js +35 -0
  436. package/template/coding-task-manager/lib/ws/lifecycle.js +6 -11
  437. package/template/coding-task-manager/lib/ws/misc.js +1 -1
  438. package/template/coding-task-manager/lib/ws/state-sync.js +125 -6
  439. package/template/coding-task-manager/lib/ws/terminal-attach.js +123 -1
  440. package/template/coding-task-manager/lib/ws-router.js +68 -1
  441. package/template/coding-task-manager/lib/ws-send-admission.js +22 -4
  442. package/template/coding-task-manager/oauth-proxy.js +211 -170
  443. package/template/coding-task-manager/package-lock.json +34 -94
  444. package/template/coding-task-manager/package.json +7 -3
  445. package/template/coding-task-manager/protocol/message-table.json +10 -0
  446. package/template/coding-task-manager/protocol/messages.js +10 -0
  447. package/template/coding-task-manager/protocol/ws-schema.json +20 -0
  448. package/template/coding-task-manager/protocol/ws-schema.md +2 -0
  449. package/template/coding-task-manager/providers/codex-mcp-extract.js +121 -19
  450. package/template/coding-task-manager/providers/codex-mcp.js +14 -5
  451. package/template/coding-task-manager/public/css/app.css +449 -1
  452. package/template/coding-task-manager/public/css/reviews.css +4 -0
  453. package/template/coding-task-manager/public/css/walle-session.css +4 -0
  454. package/template/coding-task-manager/public/index.html +766 -465
  455. package/template/coding-task-manager/public/js/agent-command.js +86 -0
  456. package/template/coding-task-manager/public/js/app/backups-panel.js +111 -5
  457. package/template/coding-task-manager/public/js/app/coding-agent-upgrade.js +103 -4
  458. package/template/coding-task-manager/public/js/app/machines-page.js +2572 -0
  459. package/template/coding-task-manager/public/js/app/models-tab.js +658 -73
  460. package/template/coding-task-manager/public/js/app/restart-banner.js +53 -0
  461. package/template/coding-task-manager/public/js/app/worktrees-panel.js +191 -7
  462. package/template/coding-task-manager/public/js/background-work.js +203 -28
  463. package/template/coding-task-manager/public/js/coding-session-model-presentation.js +181 -13
  464. package/template/coding-task-manager/public/js/core/active-session-groups.js +179 -0
  465. package/template/coding-task-manager/public/js/core/pending-create.js +238 -0
  466. package/template/coding-task-manager/public/js/core/recent-machine-source.js +228 -0
  467. package/template/coding-task-manager/public/js/core/session-commands.js +847 -5
  468. package/template/coding-task-manager/public/js/core/session-selectors.js +5 -1
  469. package/template/coding-task-manager/public/js/dashboard-client-function-order.json +8 -0
  470. package/template/coding-task-manager/public/js/document-review-links.js +9 -1
  471. package/template/coding-task-manager/public/js/file-resolution-client.js +52 -1
  472. package/template/coding-task-manager/public/js/history-app-seam.js +48 -4
  473. package/template/coding-task-manager/public/js/history-painted-rows.js +17 -2
  474. package/template/coding-task-manager/public/js/history-reader-park.js +13 -1
  475. package/template/coding-task-manager/public/js/history-scroller.js +187 -9
  476. package/template/coding-task-manager/public/js/history-transcript-pages.js +5 -5
  477. package/template/coding-task-manager/public/js/machine-pool-shared.js +991 -0
  478. package/template/coding-task-manager/public/js/message-renderer.js +4 -3
  479. package/template/coding-task-manager/public/js/model-picker.js +3 -1
  480. package/template/coding-task-manager/public/js/native-subagent-review.js +15 -2
  481. package/template/coding-task-manager/public/js/new-session-agent-grid.js +346 -0
  482. package/template/coding-task-manager/public/js/pasted-content.js +236 -0
  483. package/template/coding-task-manager/public/js/pe-private-content-lifetime.js +39 -7
  484. package/template/coding-task-manager/public/js/private-model-lifetime.js +6 -2
  485. package/template/coding-task-manager/public/js/private-state-scope.js +31 -3
  486. package/template/coding-task-manager/public/js/prompt-submission-client.js +173 -8
  487. package/template/coding-task-manager/public/js/prompt-submission-tray.js +281 -0
  488. package/template/coding-task-manager/public/js/prompts.js +11 -10
  489. package/template/coding-task-manager/public/js/protocol.js +10 -0
  490. package/template/coding-task-manager/public/js/queue-panel-submission-reconcile.js +174 -1
  491. package/template/coding-task-manager/public/js/restart-banner-policy.js +29 -1
  492. package/template/coding-task-manager/public/js/reviews.js +7 -3
  493. package/template/coding-task-manager/public/js/root-draft-lifetime.js +139 -2
  494. package/template/coding-task-manager/public/js/root-queue-builder-lifetime.js +16 -0
  495. package/template/coding-task-manager/public/js/row-join.js +4 -2
  496. package/template/coding-task-manager/public/js/session-model-picker.js +447 -57
  497. package/template/coding-task-manager/public/js/session-search-utils.js +64 -21
  498. package/template/coding-task-manager/public/js/session-usage-view.js +2 -1
  499. package/template/coding-task-manager/public/js/session-workspace-tracking.js +51 -1
  500. package/template/coding-task-manager/public/js/state-sync-client.js +14 -1
  501. package/template/coding-task-manager/public/js/stream-view.js +6 -5
  502. package/template/coding-task-manager/public/js/terminal/conv-only-session.js +287 -0
  503. package/template/coding-task-manager/public/js/terminal/runtime-02.js +16 -7
  504. package/template/coding-task-manager/public/js/terminal/runtime-03.js +41 -0
  505. package/template/coding-task-manager/public/js/terminal/runtime-04.js +41 -4
  506. package/template/coding-task-manager/public/js/terminal/runtime-09.js +2 -0
  507. package/template/coding-task-manager/public/js/terminal/runtime-10.js +5 -5
  508. package/template/coding-task-manager/public/js/terminal/runtime-12.js +60 -3
  509. package/template/coding-task-manager/public/js/terminal/runtime-16.js +16 -12
  510. package/template/coding-task-manager/public/js/terminal/runtime-18.js +14 -0
  511. package/template/coding-task-manager/public/js/terminal/runtime-19.js +8 -4
  512. package/template/coding-task-manager/public/js/terminal/runtime-20.js +211 -74
  513. package/template/coding-task-manager/public/js/terminal/runtime-21.js +19 -6
  514. package/template/coding-task-manager/public/js/terminal/runtime-22.js +86 -0
  515. package/template/coding-task-manager/public/js/terminal-attachment-draft.js +67 -13
  516. package/template/coding-task-manager/public/js/terminal-history-viewport.js +1 -1
  517. package/template/coding-task-manager/public/js/terminal-image-orchestration.js +52 -6
  518. package/template/coding-task-manager/public/js/terminal-wheel.js +62 -5
  519. package/template/coding-task-manager/public/js/walle/chat-conversation.js +15 -7
  520. package/template/coding-task-manager/public/js/walle-session.js +30 -7
  521. package/template/coding-task-manager/public/js/walle.js +6 -0
  522. package/template/coding-task-manager/public/js/ws/live-dispatch.js +10 -0
  523. package/template/coding-task-manager/public/m/app.css +366 -8
  524. package/template/coding-task-manager/public/m/app.js +1006 -74
  525. package/template/coding-task-manager/public/m/index.html +55 -1
  526. package/template/coding-task-manager/public/m/machines.js +2147 -0
  527. package/template/coding-task-manager/public/m/pool-failover.js +391 -0
  528. package/template/coding-task-manager/public/m/private-api.js +31 -1
  529. package/template/coding-task-manager/public/m/private-queue-actions.js +26 -7
  530. package/template/coding-task-manager/public/m/sw.js +5 -0
  531. package/template/coding-task-manager/public/usage.html +1 -0
  532. package/template/coding-task-manager/queue-engine.js +13 -0
  533. package/template/coding-task-manager/scripts/dev-route-fixture/synthetic-route-upstream.js +104 -0
  534. package/template/coding-task-manager/scripts/dev-route-fixture.js +339 -0
  535. package/template/coding-task-manager/scripts/opencode-lead-route-probe.js +195 -0
  536. package/template/coding-task-manager/scripts/opencode-v2-contract-probe/fake-anthropic.js +168 -0
  537. package/template/coding-task-manager/scripts/opencode-v2-contract-probe/probe-plugin/server.js +95 -0
  538. package/template/coding-task-manager/scripts/opencode-v2-contract-probe.js +673 -0
  539. package/template/coding-task-manager/server/approvals.js +5 -6
  540. package/template/coding-task-manager/server/boot.js +136 -17
  541. package/template/coding-task-manager/server.js +2819 -11885
  542. package/template/coding-task-manager/session-integrity.js +71 -13
  543. package/template/coding-task-manager/workers/db-owner-worker.js +72 -9
  544. package/template/coding-task-manager/workers/online-backup-worker.js +1 -0
  545. package/template/coding-task-manager/workers/read-pool-model-collector.js +51 -3
  546. package/template/coding-task-manager/workers/read-pool-worker.js +93 -12
  547. package/template/coding-task-manager/workers/session-host-pool-process.js +24 -10
  548. package/template/coding-task-manager/workers/session-host-process.js +19 -8
  549. package/template/coding-task-manager/workers/transcript-archive-worker.js +1 -1
  550. package/template/coding-task-manager/workers/watch-worker.js +105 -0
  551. package/template/coding-task-manager/workers/worktree-worker.js +202 -33
  552. package/template/ctm-relay/lib/protocol.js +14 -1
  553. package/template/package-lock.json +2 -2
  554. package/template/package.json +1 -1
  555. package/template/scripts/conversation-storage-v2-migration.js +78 -11
  556. package/template/shared/backup-retention.js +82 -0
  557. package/template/shared/conversation-admission.js +2 -0
  558. package/template/shared/conversation-provenance.js +3 -7
  559. package/template/shared/conversation-storage-v2-contract.js +47 -6
  560. package/template/shared/fixtures/worker-status-payloads.json +392 -0
  561. package/template/shared/git-remote-key.js +83 -0
  562. package/template/shared/host-identity.js +98 -2
  563. package/template/shared/linked-worktree.js +51 -0
  564. package/template/shared/macos-fda-target.js +57 -0
  565. package/template/shared/orphan-parents.js +55 -0
  566. package/template/shared/owner-write-safety.js +135 -0
  567. package/template/shared/public-runtime.js +13 -5
  568. package/template/shared/release-schema.json +3 -2
  569. package/template/shared/report-citations.js +14 -0
  570. package/template/shared/sqlite-write-lock.js +361 -223
  571. package/template/shared/storage/contract.js +38 -3
  572. package/template/wall-e/adapters/imessage.js +12 -0
  573. package/template/wall-e/agent.js +92 -4
  574. package/template/wall-e/api-walle.js +26 -1
  575. package/template/wall-e/bin/brain-purge-legacy-ctm.js +3 -2
  576. package/template/wall-e/bin/train-gemma-e4b-tooluse.js +2 -2
  577. package/template/wall-e/bin/walle-mcp-stdio.js +14 -8
  578. package/template/wall-e/brain/brain-join.js +859 -0
  579. package/template/wall-e/brain/brain-sync-membership.js +20 -0
  580. package/template/wall-e/brain/brain-sync-store.js +131 -77
  581. package/template/wall-e/brain/brain-sync-v2-schema.js +203 -0
  582. package/template/wall-e/brain/brain-sync-v2.js +578 -0
  583. package/template/wall-e/brain/delegate-model-prefs-store.js +13 -4
  584. package/template/wall-e/brain/deterministic-id.js +51 -0
  585. package/template/wall-e/brain/helper-rules-schema.js +129 -0
  586. package/template/wall-e/brain/memories.js +2 -2
  587. package/template/wall-e/brain/migrations.js +91 -28
  588. package/template/wall-e/brain/model-deployment-facts.js +31 -1
  589. package/template/wall-e/brain/model-identity-migration.js +1 -1
  590. package/template/wall-e/brain/owner-call-whitelist.js +39 -7
  591. package/template/wall-e/brain/schema-ensures.js +22 -0
  592. package/template/wall-e/brain/schema.js +45 -85
  593. package/template/wall-e/brain.js +172 -36
  594. package/template/wall-e/chat.js +3 -3
  595. package/template/wall-e/coding/agent-shell-env.js +7 -2
  596. package/template/wall-e/coding/journal-dispatcher.js +51 -0
  597. package/template/wall-e/coding/prompt-bundle.js +66 -21
  598. package/template/wall-e/coding/session-journal.js +28 -40
  599. package/template/wall-e/coding-orchestrator.js +23 -26
  600. package/template/wall-e/config/main-loop-exemptions.json +2 -2
  601. package/template/wall-e/http/admin-api.js +37 -0
  602. package/template/wall-e/http/auth.js +18 -1
  603. package/template/wall-e/http/blog-views-api.js +318 -0
  604. package/template/wall-e/http/gws-api.js +4 -0
  605. package/template/wall-e/http/helper-rules-api.js +327 -0
  606. package/template/wall-e/http/model-admin.js +8 -1
  607. package/template/wall-e/http/model-delegate-pref-admin.js +3 -3
  608. package/template/wall-e/http/model-proxy-providers.js +177 -2
  609. package/template/wall-e/http/model-route-health.js +157 -0
  610. package/template/wall-e/http/sync-api.js +278 -464
  611. package/template/wall-e/http/telemetry-api.js +12 -0
  612. package/template/wall-e/jobs/job-runner.js +28 -1
  613. package/template/wall-e/lib/blog-view-policy.js +88 -0
  614. package/template/wall-e/lib/blog-view-store.js +169 -0
  615. package/template/wall-e/lib/brain-owner-op-priority.js +9 -1
  616. package/template/wall-e/lib/client-config-lock.js +2 -1
  617. package/template/wall-e/lib/coding-journal-writer-child-client.js +67 -18
  618. package/template/wall-e/lib/ctm-data-dir.js +26 -0
  619. package/template/wall-e/lib/derivation-home.js +147 -0
  620. package/template/wall-e/lib/error-kinds.js +10 -1
  621. package/template/wall-e/lib/feature-manifest.js +1 -1
  622. package/template/wall-e/lib/helper-rules/cell-state.js +123 -0
  623. package/template/wall-e/lib/helper-rules/evaluate.js +398 -0
  624. package/template/wall-e/lib/helper-rules/explore-rubric.md +12 -0
  625. package/template/wall-e/lib/helper-rules/grade.js +320 -0
  626. package/template/wall-e/lib/helper-rules/label.js +247 -0
  627. package/template/wall-e/lib/helper-rules/lead-call-hook.js +555 -0
  628. package/template/wall-e/lib/helper-rules/store.js +669 -0
  629. package/template/wall-e/lib/landing-mcp-tools.js +170 -0
  630. package/template/wall-e/lib/mcp-client-config.js +133 -14
  631. package/template/wall-e/lib/mcp-gateway-migrate.js +28 -64
  632. package/template/wall-e/lib/mcp-integration.js +63 -19
  633. package/template/wall-e/lib/parent-death.js +7 -1
  634. package/template/wall-e/lib/runtime-worker-pool.js +1 -0
  635. package/template/wall-e/lib/scheduler-worker-jobs.js +12 -4
  636. package/template/wall-e/lib/telemetry-db-schema.js +37 -0
  637. package/template/wall-e/lib/telemetry-process-client.js +76 -1
  638. package/template/wall-e/llm/default-fallback.js +4 -0
  639. package/template/wall-e/llm/delegate-lead-prefs.js +16 -1
  640. package/template/wall-e/llm/delegate-vendor-default.js +12 -5
  641. package/template/wall-e/llm/model-catalog.js +13 -4
  642. package/template/wall-e/llm/model-roles.js +7 -1
  643. package/template/wall-e/llm/native-delegate-selection.js +56 -8
  644. package/template/wall-e/llm/portkey-http.js +150 -0
  645. package/template/wall-e/llm/portkey-sync.js +15 -145
  646. package/template/wall-e/llm/worker-delegate-args.js +72 -7
  647. package/template/wall-e/llm/worker-mcp-routing.js +117 -7
  648. package/template/wall-e/llm/worker-route.js +43 -1
  649. package/template/wall-e/loops/brain-custom-writes.js +64 -0
  650. package/template/wall-e/loops/ingest.js +17 -1
  651. package/template/wall-e/loops/think.js +19 -4
  652. package/template/wall-e/mcp-contract.js +222 -6
  653. package/template/wall-e/mcp-protocol-contract.js +77 -2
  654. package/template/wall-e/mcp-server.js +141 -31
  655. package/template/wall-e/mcp-worker-schemas.js +25 -7
  656. package/template/wall-e/memory/ctm-context-client.js +110 -5
  657. package/template/wall-e/memory/ctm-session-context.js +9 -3
  658. package/template/wall-e/memory/hub-bridge-client.js +388 -0
  659. package/template/wall-e/memory/replica-origin.js +56 -0
  660. package/template/wall-e/memory/session-pool.js +135 -0
  661. package/template/wall-e/runtime/live-capabilities.js +8 -3
  662. package/template/wall-e/server.js +4 -2
  663. package/template/wall-e/shared/release-schema.json +3 -2
  664. package/template/wall-e/shared/sqlite-file-set.js +39 -0
  665. package/template/wall-e/shared/sqlite-write-lock.js +361 -223
  666. package/template/wall-e/shared/storage/contract.js +38 -3
  667. package/template/wall-e/skills/_templates/delegate-worker/VERSION +1 -1
  668. package/template/wall-e/skills/_templates/delegate-worker/released-sha256.json +13 -1
  669. package/template/wall-e/skills/_templates/delegate-worker/templates/claude/SKILL.md +11 -6
  670. package/template/wall-e/skills/_templates/delegate-worker/templates/codex/SKILL.md +13 -8
  671. package/template/wall-e/skills/_templates/fleet-sync/VERSION +1 -0
  672. package/template/wall-e/skills/_templates/fleet-sync/released-sha256.json +16 -0
  673. package/template/wall-e/skills/_templates/fleet-sync/templates/claude/SKILL.md +64 -0
  674. package/template/wall-e/skills/_templates/fleet-sync/templates/codex/SKILL.md +64 -0
  675. package/template/wall-e/tools/chrome-automation.js +6 -0
  676. package/template/wall-e/tools/local-tools.js +6 -4
  677. package/template/wall-e/training/setup-cuda-train-env.sh +2 -2
  678. package/template/wall-e/workers/brain-owner-worker.js +27 -4
  679. package/template/wall-e/workers/coding-journal-writer-child.js +8 -1
  680. package/template/wall-e/workers/mcp-gateway-process.js +5 -5
  681. package/template/wall-e/workers/telemetry-worker.js +8 -0
@@ -17,6 +17,11 @@
17
17
  // module-state rate-limit bookkeeping (renamed from handleWalleApi._rlMap/
18
18
  // _rlTimer, moved verbatim).
19
19
  const { jsonResponse, readBody } = require('./api-utils');
20
+ // WP-1 (blog-view-counts, docs/blog-view-counts-2026-10-22.html §5 D-4): the
21
+ // public blog-view counter is a sibling of the telemetry routes — same module
22
+ // boundary, same injected deps, same dispatch chain — and is claimed FIRST so
23
+ // its exact path can never fall through to a telemetry handler.
24
+ const { handleBlogViewsApi } = require('./blog-views-api');
20
25
 
21
26
  function handleTelemetryApi(req, res, url, deps) {
22
27
  const {
@@ -47,6 +52,13 @@ function handleTelemetryApi(req, res, url, deps) {
47
52
  const m = req.method;
48
53
  const params = url.searchParams;
49
54
 
55
+ // --- Blog view counts (public, unauthenticated, exact path only) ---
56
+ // Before the telemetry routes: the handler claims only
57
+ // /api/wall-e/telemetry/blog-views and returns false for everything else, so the
58
+ // existing dispatch order and behavior below are untouched.
59
+ const blogViewsHandled = handleBlogViewsApi(req, res, url, { getTelemetryDb, errorSink });
60
+ if (blogViewsHandled !== false) return blogViewsHandled;
61
+
50
62
  // --- Telemetry endpoints (server mode only) ---
51
63
 
52
64
  // POST /api/wall-e/telemetry/ingest — receive anonymous telemetry from users
@@ -48,6 +48,7 @@
48
48
  // `../brain/job-store` here.
49
49
 
50
50
  const { writeRunArtifact, pruneRunArtifacts, classifySkillError } = require('../lib/run-artifacts');
51
+ const { resolvePlacement } = require('../lib/derivation-home');
51
52
 
52
53
  // The per-run execution budget constants and the prompt builder live in the
53
54
  // require-free leaf `jobs/job-defaults.js` (moved there verbatim by fix round 2);
@@ -65,6 +66,13 @@ const {
65
66
  // §4: default concurrency is 1 — run jobs one at a time per tick, no flag.
66
67
  const DEFAULT_JOB_CONCURRENCY = 1;
67
68
 
69
+ // D-5/S-16 (shared-memory WP-2): job kinds whose INPUT is replicated brain rows, so the
70
+ // derived rows they mint (skill-executor's timestamped `source_id`, a prompt job's model
71
+ // output) would multiply across N replicas. Only the derivation home selects them;
72
+ // `builtin` jobs (e.g. `slack.inbound`) act on data this machine has and always run.
73
+ const DERIVED_JOB_ACTION_KINDS = new Set(['skill', 'prompt']);
74
+ const NOT_DERIVATION_HOME = 'not_derivation_home';
75
+
68
76
  // §6.1 retention: keep the newest 200 runs per job.
69
77
  const DEFAULT_RUN_KEEP = 200;
70
78
 
@@ -337,9 +345,13 @@ async function runJob(job, { trigger = 'schedule', now = Date.now, executors, ac
337
345
  *
338
346
  * @returns {Promise<{ran: number, skipped: number, considered: number, decisions: Array}>}
339
347
  */
340
- async function runDueJobs({ now = Date.now, executors, brain, deps } = {}) {
348
+ async function runDueJobs({ now = Date.now, executors, brain, deps, placement } = {}) {
341
349
  const io = resolveAccess(brain);
342
350
  const at = typeof now === 'function' ? now() : now;
351
+ // D-5/S-16 (WP-2): the `jobs` table is host-local and stays untouched; the placement gate
352
+ // lives HERE, at the selection point, so a non-home node simply never selects a derived job.
353
+ // `placement` is the test seam; production resolves it from CTM (cached 60 s).
354
+ const resolvedPlacement = placement || await resolvePlacement();
343
355
 
344
356
  const jobs = await io.read('listJobs', [{ includeDisabled: true }]);
345
357
  const decisions = [];
@@ -350,6 +362,19 @@ async function runDueJobs({ now = Date.now, executors, brain, deps } = {}) {
350
362
  for (const job of jobs || []) {
351
363
  if (ran >= DEFAULT_JOB_CONCURRENCY) break;
352
364
  considered += 1;
365
+ // WP-2: a derived job on a non-home node is skipped with its own reason, reported in the
366
+ // same `decisions` array every other skip uses (no row is disabled, no run is recorded).
367
+ if (!resolvedPlacement.home && DERIVED_JOB_ACTION_KINDS.has(job.action_kind)) {
368
+ skipped += 1;
369
+ decisions.push({
370
+ job_id: job.id,
371
+ name: job.name,
372
+ decision: 'skip',
373
+ reason: NOT_DERIVATION_HOME,
374
+ details: { action_kind: job.action_kind, placement: resolvedPlacement.reason },
375
+ });
376
+ continue;
377
+ }
353
378
  // WP-5a (D-12): the connection record is the authority — a job that declares
354
379
  // a requirement is judged by its kind's row, and a job that declares none is
355
380
  // 'ok'. Only reconnect_required/disabled gate dispatch (§4/D-6).
@@ -527,4 +552,6 @@ module.exports = {
527
552
  MIN_TASK_EXECUTION_TIMEOUT_MS,
528
553
  DEFAULT_JOB_CONCURRENCY,
529
554
  DEFAULT_RUN_KEEP,
555
+ DERIVED_JOB_ACTION_KINDS,
556
+ NOT_DERIVATION_HOME,
530
557
  };
@@ -0,0 +1,88 @@
1
+ 'use strict';
2
+
3
+ // WP-1 (docs/blog-view-counts-2026-10-22.html §5/§6): the ONE place the blog
4
+ // view counter's public surface is described — route, article allowlist, policy
5
+ // ceilings, accepted browser origins and the approximate bot filter. Pure data
6
+ // and pure predicates: no env read, no database handle, no module state, no
7
+ // side effects at require time.
8
+ //
9
+ // Counting semantics are deliberately approximate (design §11): one visible
10
+ // article opening per 30-minute per-tab token, no unique-person claim, no
11
+ // historical backfill.
12
+
13
+ // The EXACT public path. It lives under the /api/wall-e/telemetry/ prefix on
14
+ // purpose (design §5 D-4, lead review correction): api-walle.js already routes
15
+ // that prefix to lib/telemetry-process-client.js in the daemon role, so the
16
+ // counter runs in the isolated telemetry process — no SQLite on the foreground
17
+ // daemon — without touching the frozen dispatcher.
18
+ const BLOG_VIEWS_PATH = '/api/wall-e/telemetry/blog-views';
19
+
20
+ // The three published static articles. A slug outside this frozen list is never
21
+ // a valid counter key, so an arbitrary/hostile value can never reach a query.
22
+ const BLOG_POSTS = Object.freeze(['delegation-economics', 'delegation-guide', 'paste-the-link']);
23
+
24
+ // Repeat-visit suppression window: a per-tab random token counts once per 30 min.
25
+ const BLOG_VIEW_WINDOW_MS = 1800000;
26
+
27
+ // Product policy ceilings (conservative, not measured traffic — design §11).
28
+ const BLOG_VIEW_MAX_RECEIPTS = 100000;
29
+ const BLOG_VIEW_MAX_BODY_BYTES = 1024;
30
+
31
+ // Bounded receipt pruning: a POST removes at most this many expired receipts.
32
+ const BLOG_VIEW_PRUNE_BATCH = 1000;
33
+
34
+ // The only browser origins whose POST may increment a counter (and the only ones
35
+ // reflected back in CORS). Both the apex and the www host serve the site.
36
+ const BLOG_VIEW_ORIGINS = Object.freeze(['https://walle.sh', 'https://www.walle.sh']);
37
+
38
+ // User-Agent input is truncated before matching; the pattern is an approximate
39
+ // filter (design D-4), never proof that a visitor is human.
40
+ const BLOG_VIEW_USER_AGENT_MAX = 1024;
41
+ const BLOG_VIEW_BOT_PATTERN = /bot|crawler|spider|headless|curl|wget|python|preview|facebookexternalhit|meta-externalagent|bytespider|gptbot|claudebot/i;
42
+
43
+ // Canonical lowercase 8-4-4-4-12 UUID text (the shape crypto.randomUUID emits).
44
+ const BLOG_VIEW_TOKEN_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
45
+
46
+ function isBlogViewsPath(pathname) {
47
+ return pathname === BLOG_VIEWS_PATH;
48
+ }
49
+
50
+ // Returns the request's origin only when it is EXACTLY one of the two published
51
+ // site origins; every other present origin is null (the caller turns that into a
52
+ // refusal — the private API's localhost-only set is never widened).
53
+ function getBlogViewOrigin(origin) {
54
+ if (typeof origin !== 'string') return null;
55
+ return BLOG_VIEW_ORIGINS.includes(origin) ? origin : null;
56
+ }
57
+
58
+ function isBlogPostSlug(slug) {
59
+ return typeof slug === 'string' && BLOG_POSTS.includes(slug);
60
+ }
61
+
62
+ function isBlogViewToken(token) {
63
+ return typeof token === 'string' && BLOG_VIEW_TOKEN_PATTERN.test(token);
64
+ }
65
+
66
+ // Truncated, case-insensitive, deliberately approximate reconnaissance filter.
67
+ function isKnownBotUserAgent(userAgent) {
68
+ if (typeof userAgent !== 'string' || userAgent === '') return false;
69
+ return BLOG_VIEW_BOT_PATTERN.test(userAgent.slice(0, BLOG_VIEW_USER_AGENT_MAX));
70
+ }
71
+
72
+ module.exports = {
73
+ BLOG_POSTS,
74
+ BLOG_VIEWS_PATH,
75
+ BLOG_VIEW_BOT_PATTERN,
76
+ BLOG_VIEW_MAX_BODY_BYTES,
77
+ BLOG_VIEW_MAX_RECEIPTS,
78
+ BLOG_VIEW_ORIGINS,
79
+ BLOG_VIEW_PRUNE_BATCH,
80
+ BLOG_VIEW_TOKEN_PATTERN,
81
+ BLOG_VIEW_USER_AGENT_MAX,
82
+ BLOG_VIEW_WINDOW_MS,
83
+ getBlogViewOrigin,
84
+ isBlogPostSlug,
85
+ isBlogViewsPath,
86
+ isBlogViewToken,
87
+ isKnownBotUserAgent,
88
+ };
@@ -0,0 +1,169 @@
1
+ 'use strict';
2
+
3
+ // WP-1 (docs/blog-view-counts-2026-10-22.html §5 D-2, §6): durable per-article
4
+ // view counters on the EXISTING telemetry.db. Two additive tables — a running
5
+ // total per article and a bounded set of short-lived per-tab receipts — updated
6
+ // in one IMMEDIATE transaction, so a replay is a no-op and a concurrent writer
7
+ // can never double-count.
8
+ //
9
+ // The handle is ALWAYS injected: nothing here opens a database, calls initDb(),
10
+ // schedules a job or reads the environment. This module contains NO DDL: the two
11
+ // tables are declared and created by lib/telemetry-db-schema.js (the
12
+ // walle-telemetry migration owner), whose baseline and additive migration 2 both
13
+ // call its own createBlogViewTables(). Only queries live here, and the module
14
+ // requires nothing but the pure policy module — no cycle back through the schema.
15
+ //
16
+ // Privacy (design D-5): a receipt stores the slug, the opaque random per-tab
17
+ // token and its expiry — nothing else. No IP address, User-Agent, referrer,
18
+ // account or derived fingerprint is ever written; the raw token is a
19
+ // deduplication key, not a credential, and expires in 30 minutes.
20
+ //
21
+ // Counting semantics are approximate (design §11): a 30-minute per-tab
22
+ // suppression window, not unique people.
23
+
24
+ const {
25
+ BLOG_VIEW_MAX_RECEIPTS,
26
+ BLOG_VIEW_PRUNE_BATCH,
27
+ BLOG_VIEW_WINDOW_MS,
28
+ BLOG_POSTS,
29
+ isBlogPostSlug,
30
+ isBlogViewToken,
31
+ } = require('./blog-view-policy');
32
+
33
+ // Typed store errors: the API layer maps them to status codes without ever
34
+ // having to parse a message.
35
+ const BLOG_VIEW_INVALID_SLUG = 'blog_view_invalid_slug';
36
+ const BLOG_VIEW_INVALID_TOKEN = 'blog_view_invalid_token';
37
+ const BLOG_VIEW_INVALID_STATE = 'blog_view_invalid_state';
38
+ const BLOG_VIEW_CAPACITY = 'blog_view_capacity';
39
+ const BLOG_VIEW_OVERFLOW = 'blog_view_overflow';
40
+
41
+ function blogViewError(code, message) {
42
+ const error = new Error(message);
43
+ error.code = code;
44
+ return error;
45
+ }
46
+
47
+ // Current totals for every published article, as {slug: views}. A known article
48
+ // with no row yet is authoritatively 0; an unsafe or negative stored value is
49
+ // refused rather than rendered.
50
+ function getBlogViewCounts(db) {
51
+ const placeholders = BLOG_POSTS.map(() => '?').join(', ');
52
+ const rows = db.prepare(
53
+ `SELECT slug, views FROM blog_view_counts WHERE slug IN (${placeholders})`
54
+ ).all(...BLOG_POSTS);
55
+ const counts = {};
56
+ for (const slug of BLOG_POSTS) counts[slug] = 0;
57
+ for (const row of rows) {
58
+ // Prototype-safe: only the frozen allowlist's own keys are ever assigned to,
59
+ // so a hostile stored slug can never write through to Object.prototype.
60
+ if (!Object.prototype.hasOwnProperty.call(counts, row.slug)) continue;
61
+ if (!Number.isSafeInteger(row.views) || row.views < 0) {
62
+ throw blogViewError(BLOG_VIEW_INVALID_STATE, 'stored blog view count is not a safe non-negative integer');
63
+ }
64
+ counts[row.slug] = row.views;
65
+ }
66
+ return counts;
67
+ }
68
+
69
+ // Records one view for `slug` from the per-tab `token` at `nowMs`, returning
70
+ // {slug, views, counted}. `counted` is false when this exact token already has
71
+ // an unexpired receipt (a refresh or a duplicate submission) — the stored total
72
+ // is then returned unchanged, even when the receipt table is at its cap.
73
+ //
74
+ // Throws a typed error for an unknown slug, a non-canonical token, a full
75
+ // receipt table or a total at the safe-integer ceiling; the caller maps those to
76
+ // a refusal and never acknowledges an uncounted view.
77
+ function recordBlogView(db, slug, token, nowMs = Date.now()) {
78
+ // Validate the ONLY two things that can reach SQL, before any statement runs:
79
+ // a frozen-allowlist slug and canonical UUID text. No arbitrary key ever
80
+ // becomes a query parameter.
81
+ if (!isBlogPostSlug(slug)) {
82
+ throw blogViewError(BLOG_VIEW_INVALID_SLUG, 'unknown blog post slug');
83
+ }
84
+ // Canonical text only, and nothing below folds case: isBlogViewToken() accepts
85
+ // ONLY the lowercase 8-4-4-4-12 spelling, so an uppercased uuid is refused as a
86
+ // malformed token rather than silently normalized into somebody else's receipt
87
+ // key.
88
+ if (!isBlogViewToken(token)) {
89
+ throw blogViewError(BLOG_VIEW_INVALID_TOKEN, 'token is not a canonical uuid');
90
+ }
91
+ const now = Number.isSafeInteger(nowMs) ? nowMs : Date.now();
92
+
93
+ const record = db.transaction(() => {
94
+ // 1. Bounded, indexed prune of expired receipts (at most
95
+ // BLOG_VIEW_PRUNE_BATCH rows): the table stays bounded with no job.
96
+ db.prepare(
97
+ `DELETE FROM blog_view_receipts WHERE rowid IN (
98
+ SELECT rowid FROM blog_view_receipts
99
+ WHERE expires_at_ms <= ?
100
+ ORDER BY expires_at_ms
101
+ LIMIT ?
102
+ )`
103
+ ).run(now, BLOG_VIEW_PRUNE_BATCH);
104
+
105
+ // 2. An EXACT unexpired receipt is a duplicate: the stored total is returned
106
+ // unchanged, even when the table is at its cap.
107
+ const existing = db.prepare(
108
+ 'SELECT expires_at_ms FROM blog_view_receipts WHERE slug = ? AND token = ?'
109
+ ).get(slug, token);
110
+ if (existing && existing.expires_at_ms > now) {
111
+ const current = db.prepare('SELECT views FROM blog_view_counts WHERE slug = ?').get(slug);
112
+ const views = current ? current.views : 0;
113
+ if (!Number.isSafeInteger(views) || views < 0) {
114
+ throw blogViewError(BLOG_VIEW_INVALID_STATE, 'stored blog view count is not a safe non-negative integer');
115
+ }
116
+ return { slug, views, counted: false };
117
+ }
118
+ // An expired receipt for this exact token is removed before its replacement
119
+ // is inserted, so the primary key never collides and no stale expiry is
120
+ // reused. (Step 1 usually removed it already; this is the exact case.)
121
+ if (existing) {
122
+ db.prepare('DELETE FROM blog_view_receipts WHERE slug = ? AND token = ?').run(slug, token);
123
+ }
124
+
125
+ // 3. Capacity is a policy bound, not memory: a full table refuses the view
126
+ // (the transaction rolls back, so the cap stays full) instead of
127
+ // acknowledging an uncounted one.
128
+ const receiptCount = db.prepare('SELECT count(*) AS n FROM blog_view_receipts').get().n;
129
+ if (receiptCount >= BLOG_VIEW_MAX_RECEIPTS) {
130
+ throw blogViewError(BLOG_VIEW_CAPACITY, 'blog view receipt capacity reached');
131
+ }
132
+
133
+ // 4. Never wrap: a total at the safe-integer ceiling refuses the view.
134
+ const currentRow = db.prepare('SELECT views FROM blog_view_counts WHERE slug = ?').get(slug);
135
+ const currentViews = currentRow ? currentRow.views : 0;
136
+ if (!Number.isSafeInteger(currentViews) || currentViews < 0) {
137
+ throw blogViewError(BLOG_VIEW_INVALID_STATE, 'stored blog view count is not a safe non-negative integer');
138
+ }
139
+ if (currentViews >= Number.MAX_SAFE_INTEGER) {
140
+ throw blogViewError(BLOG_VIEW_OVERFLOW, 'blog view count reached the safe integer ceiling');
141
+ }
142
+
143
+ db.prepare(
144
+ `INSERT INTO blog_view_receipts (slug, token, expires_at_ms) VALUES (?, ?, ?)
145
+ ON CONFLICT(slug, token) DO UPDATE SET expires_at_ms = excluded.expires_at_ms`
146
+ ).run(slug, token, now + BLOG_VIEW_WINDOW_MS);
147
+ db.prepare(
148
+ `INSERT INTO blog_view_counts (slug, views) VALUES (?, 1)
149
+ ON CONFLICT(slug) DO UPDATE SET views = views + 1`
150
+ ).run(slug);
151
+
152
+ const committed = db.prepare('SELECT views FROM blog_view_counts WHERE slug = ?').get(slug);
153
+ return { slug, views: committed ? committed.views : 0, counted: true };
154
+ });
155
+
156
+ // IMMEDIATE: take the write lock at BEGIN, so two competing writers serialize
157
+ // instead of one failing late with SQLITE_BUSY after a stale read.
158
+ return record.immediate();
159
+ }
160
+
161
+ module.exports = {
162
+ BLOG_VIEW_CAPACITY,
163
+ BLOG_VIEW_INVALID_SLUG,
164
+ BLOG_VIEW_INVALID_STATE,
165
+ BLOG_VIEW_INVALID_TOKEN,
166
+ BLOG_VIEW_OVERFLOW,
167
+ getBlogViewCounts,
168
+ recordBlogView,
169
+ };
@@ -13,7 +13,15 @@ const OWNER_METHOD_PRIORITY = Object.freeze({
13
13
  // background — scheduled, resumable
14
14
  markTurnLedgerOutboxDelivered: 'background',
15
15
  recordTurnLedgerOutboxFailure: 'background',
16
- backfillEntityLinkBatch: 'background', backfillClassifyBatch: 'background',
16
+ backfillEntityLinkBatch: 'background', backfillClassifyBatch: 'background', brainSyncClockSeed: 'background',
17
+ // WP-1 §6.4: the v2 feed/apply pair and the hub bookkeeping — peer-driven, no user waits on
18
+ // them locally (the hub's own tick owns the latency budget), so they share the seed walk's
19
+ // class rather than competing with an interactive turn.
20
+ brainSyncV2Vector: 'background', brainSyncV2Changes: 'background', brainSyncV2Apply: 'background',
21
+ brainSyncV2MemberVector: 'background', brainSyncV2PruneTombstones: 'background', brainSyncV2Digest: 'background',
22
+ // WP-4 §6.7: the join trio + the import job's step — peer/job-driven, no local user waits on them.
23
+ brainSyncV2JoinSnapshot: 'background', brainSyncV2JoinImport: 'background',
24
+ brainSyncV2JoinStatus: 'background', brainSyncV2JoinStep: 'background',
17
25
  backfillStripNoiseBatch: 'background', backfillInsertMemoryIndexBatch: 'background',
18
26
  backfillMarkEmbedFailed: 'background', embeddingsUpsertBatch: 'background',
19
27
  commitThinkExtraction: 'background', ingestInsertMemoryBatch: 'background',
@@ -43,6 +43,7 @@ const os = require('os');
43
43
  const path = require('path');
44
44
 
45
45
  const { ClientConfigError, isClientConfigError } = require('./mcp-client-config');
46
+ const { isWritableOnlyByOwner } = require('../../shared/owner-write-safety');
46
47
 
47
48
  const POLL_MS = 100; // admission cadence, never a performance budget
48
49
  const DEFAULT_TIMEOUT_MS = 10000; // admission deadline only
@@ -145,7 +146,7 @@ function _modeBits(stat) {
145
146
  }
146
147
 
147
148
  function _isGroupOrOtherWritable(stat) {
148
- return (_exactInteger(stat.mode) & 0o022n) !== 0n;
149
+ return !isWritableOnlyByOwner(stat);
149
150
  }
150
151
 
151
152
  function _hasStickyBit(stat) {
@@ -20,7 +20,6 @@ const SAFE_ENV_KEYS = [
20
20
  'WALL_E_SQLITE_STORAGE_POLICY',
21
21
  'WALL_E_SQLITE_BUSY_TIMEOUT_MS',
22
22
  'WALL_E_SQLITE_WRITE_LOCK_TIMEOUT_MS',
23
- 'WALL_E_SQLITE_WRITE_LOCK_STALE_MS',
24
23
  'WALL_E_BRAIN_BOOT_LOCK_WAIT_MS',
25
24
  'WALL_E_SQLITE_SYNCHRONOUS',
26
25
  'WALL_E_SQLITE_WAL_AUTOCHECKPOINT_PAGES',
@@ -82,16 +81,48 @@ function writeJournalEntryInChild(entry, options = {}) {
82
81
  serialization: 'json',
83
82
  });
84
83
  } catch (error) {
84
+ // C7: a fork that threw synchronously returned no child, so this call owns
85
+ // nothing to watch and nothing to terminate — reject with the original value.
85
86
  return Promise.reject(error);
86
87
  }
87
88
 
88
89
  return new Promise((resolve, reject) => {
90
+ // C7: the application result (one reply envelope) and the native lifecycle
91
+ // (exit/close) are two separate facts about the same child. Only the child's
92
+ // own 'close' finalizes this operation — a reply envelope or 'exit' alone
93
+ // leaves the operation pending, because the child may still be running (or
94
+ // may still die badly) after either one.
95
+ let replied = false;
96
+ let replyResult = null;
97
+ let failed = false; // explicit Boolean: a falsy thrown value is still a failure
98
+ let failure = null;
99
+ let nativeExited = false; // 'exit' seen: the process is gone, its stdio is not necessarily closed
100
+ let nativeClosed = false; // 'close' seen: the only fact that finalizes this operation
101
+ let terminationRequested = false;
89
102
  let settled = false;
103
+
104
+ const recordFailure = (error) => {
105
+ // The FIRST failure wins, verbatim (identity and value): later errors, the
106
+ // deadline and a nonzero native close must never replace it.
107
+ if (failed) return;
108
+ failed = true;
109
+ failure = error;
110
+ };
111
+ const requestTermination = () => {
112
+ if (terminationRequested) return;
113
+ // Marked BEFORE kill: an 'error' emitted by the kill call itself must not
114
+ // re-enter here and signal the same child twice.
115
+ terminationRequested = true;
116
+ if (nativeExited || nativeClosed) return; // never signal after the native exit/close was observed
117
+ try { child.kill('SIGKILL'); }
118
+ catch { /* expected: the child may already be gone; a throwing kill neither relinquishes ownership nor proves closure — the operation still joins the child's actual close below */ }
119
+ };
90
120
  const cleanup = () => {
91
121
  clearTimeout(timer);
92
122
  child.off('message', onMessage);
93
123
  child.off('error', onError);
94
124
  child.off('exit', onExit);
125
+ child.off('close', onClose);
95
126
  };
96
127
  const settle = (fn, value) => {
97
128
  if (settled) return false;
@@ -101,39 +132,57 @@ function writeJournalEntryInChild(entry, options = {}) {
101
132
  return true;
102
133
  };
103
134
  const onMessage = (message) => {
104
- if (!message || message.type !== 'coding-journal-result') return;
105
- if (message.ok) settle(resolve, message.result || null);
106
- else {
107
- const error = new Error(String(message.error || 'One-shot journal writer failed').slice(0, 500));
108
- if (message.code) error.code = String(message.code).slice(0, 100);
109
- settle(reject, error);
110
- }
135
+ if (!message || message.type !== 'coding-journal-result') return; // unrelated envelope
136
+ if (replied) return; // first valid result wins; duplicate and late envelopes are ignored
137
+ replied = true;
138
+ if (message.ok) { replyResult = message.result || null; return; }
139
+ const error = new Error(String(message.error || 'One-shot journal writer failed').slice(0, 500));
140
+ if (message.code) error.code = String(message.code).slice(0, 100);
141
+ recordFailure(error);
142
+ };
143
+ const onError = (error) => {
144
+ // A process/IPC error is a failure but not a closure: the operation keeps
145
+ // waiting for the child's own close, and this first failure is preserved.
146
+ recordFailure(error);
147
+ requestTermination();
111
148
  };
112
- const onError = (error) => settle(reject, error);
113
- const onExit = (code, signal) => {
149
+ // 'exit' only records that the process is gone; the verdict reads the close
150
+ // event's own (code, signal), so exit and close can never be conflated.
151
+ const onExit = () => { nativeExited = true; };
152
+ const onClose = (code, signal) => {
153
+ nativeClosed = true;
154
+ // A falsy thrown value must not be laundered into a success: the boolean,
155
+ // not the value, says whether a failure happened.
156
+ if (failed) { settle(reject, failure); return; }
114
157
  const suffix = signal ? `signal ${signal}` : `code ${code}`;
115
- settle(reject, new Error(`One-shot journal writer exited before replying (${suffix})`));
158
+ if (!replied) { settle(reject, new Error(`One-shot journal writer exited before replying (${suffix})`)); return; }
159
+ if (code === 0 && signal === null) { settle(resolve, replyResult); return; }
160
+ // Replied, then died badly: the reply alone is not proof the write survived.
161
+ const error = new Error(`One-shot journal writer exited after replying (${suffix})`);
162
+ error.code = 'WALL_E_JOURNAL_WRITER_EXIT';
163
+ settle(reject, error);
116
164
  };
117
165
  const timer = setTimeout(() => {
118
166
  const error = new Error(`One-shot journal writer timed out after ${timeoutMs}ms`);
119
167
  error.code = 'WALL_E_JOURNAL_WRITER_TIMEOUT';
120
- if (!settle(reject, error)) return;
121
- try { child.kill('SIGKILL'); } catch {}
168
+ recordFailure(error); // only the first failure is kept; the deadline joins the close
169
+ requestTermination();
122
170
  }, timeoutMs);
123
171
 
124
172
  child.on('message', onMessage);
125
- child.once('error', onError);
126
- child.once('exit', onExit);
173
+ child.on('error', onError);
174
+ child.on('exit', onExit);
175
+ child.on('close', onClose);
127
176
  try {
128
177
  child.send({
129
178
  type: 'persist-coding-journal',
130
179
  dbPath: path.resolve(dbPath),
131
180
  entry: JSON.parse(entryJson),
132
181
  });
182
+ // A false return is IPC backpressure, never a failure or a cancellation.
133
183
  } catch (error) {
134
- if (settle(reject, error)) {
135
- try { child.kill('SIGKILL'); } catch {}
136
- }
184
+ recordFailure(error);
185
+ requestTermination();
137
186
  }
138
187
  });
139
188
  }
@@ -0,0 +1,26 @@
1
+ 'use strict';
2
+
3
+ // R-6/R-7 (§5, D-4) — "CTM's data dir", computed the way CTM computes it for itself
4
+ // (coding-task-manager/lib/data-dir.js:17-21) but from a GIVEN env object.
5
+ //
6
+ // Call it in the Wall-E DAEMON (the process that serves POST /api/walle/sync/v2/join/import),
7
+ // NEVER in the brain-owner worker: the owner's env is a deliberate whitelist
8
+ // (lib/brain-owner-env.js) that sets WALL_E_DATA_DIR to the brain's own directory and drops
9
+ // CTM_DATA_DIR (I-5), so resolving the inbox root there names the wrong directory — which is
10
+ // exactly the Spark fault (every join import refused JOIN_PATH_INVALID while CTM wrote its
11
+ // snapshots to the CTM inbox). The daemon resolves the root and passes it down as `dataDir`
12
+ // (http/sync-api.js _handleV2JoinImport → brain/brain-join.js isInsideJoinInbox).
13
+
14
+ const os = require('node:os');
15
+ const path = require('node:path');
16
+
17
+ // CTM_DATA_DIR, then WALL_E_DATA_DIR (wall-e's own override, honoured by CTM's resolver too so a
18
+ // single value works for both processes), then <HOME>/.walle/data. An empty — or
19
+ // whitespace-only — value counts as unset, matching CTM's truthiness test on the raw value.
20
+ function resolveCtmDataDir(env = process.env) {
21
+ const override = String(env.CTM_DATA_DIR || env.WALL_E_DATA_DIR || '').trim();
22
+ if (override) return path.resolve(override);
23
+ return path.resolve(env.HOME || os.homedir(), '.walle', 'data');
24
+ }
25
+
26
+ module.exports = { resolveCtmDataDir };