@caupulican/pi-adaptative 0.94.0 → 0.95.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (371) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/dist/bundled-resources/extensions/tmux-agent-manager/README.md +32 -13
  3. package/dist/bundled-resources/extensions/tmux-agent-manager/index.d.ts +7 -4
  4. package/dist/bundled-resources/extensions/tmux-agent-manager/index.d.ts.map +1 -1
  5. package/dist/bundled-resources/extensions/tmux-agent-manager/index.js +173 -293
  6. package/dist/bundled-resources/extensions/tmux-agent-manager/index.js.map +1 -1
  7. package/dist/bundled-resources/extensions/tmux-agent-manager/index.ts +247 -392
  8. package/dist/bundled-resources/extensions/tmux-agent-manager/launch-profile.d.ts +52 -0
  9. package/dist/bundled-resources/extensions/tmux-agent-manager/launch-profile.d.ts.map +1 -0
  10. package/dist/bundled-resources/extensions/tmux-agent-manager/launch-profile.js +118 -0
  11. package/dist/bundled-resources/extensions/tmux-agent-manager/launch-profile.js.map +1 -0
  12. package/dist/bundled-resources/extensions/tmux-agent-manager/launch-profile.ts +169 -0
  13. package/dist/bundled-resources/extensions/tmux-agent-manager/templates/builder-validator.json +1 -1
  14. package/dist/bundled-resources/extensions/tmux-agent-manager/templates/provider-prompt-smoke.json +1 -1
  15. package/dist/bundled-resources/skills/pi-harness-learning/SKILL.md +13 -7
  16. package/dist/bundled-resources/skills/worker-profile-writer/SKILL.md +11 -11
  17. package/dist/core/agent-paths.d.ts +2 -0
  18. package/dist/core/agent-paths.d.ts.map +1 -1
  19. package/dist/core/agent-paths.js +7 -0
  20. package/dist/core/agent-paths.js.map +1 -1
  21. package/dist/core/agent-session.d.ts +11 -41
  22. package/dist/core/agent-session.d.ts.map +1 -1
  23. package/dist/core/agent-session.js +98 -161
  24. package/dist/core/agent-session.js.map +1 -1
  25. package/dist/core/autonomy/envelope-enforcement.d.ts +6 -1
  26. package/dist/core/autonomy/envelope-enforcement.d.ts.map +1 -1
  27. package/dist/core/autonomy/envelope-enforcement.js +26 -25
  28. package/dist/core/autonomy/envelope-enforcement.js.map +1 -1
  29. package/dist/core/autonomy/lane-private-paths.d.ts.map +1 -1
  30. package/dist/core/autonomy/lane-private-paths.js +2 -1
  31. package/dist/core/autonomy/lane-private-paths.js.map +1 -1
  32. package/dist/core/autonomy/lane-tool-surface.d.ts +8 -8
  33. package/dist/core/autonomy/lane-tool-surface.d.ts.map +1 -1
  34. package/dist/core/autonomy/lane-tool-surface.js +45 -30
  35. package/dist/core/autonomy/lane-tool-surface.js.map +1 -1
  36. package/dist/core/autonomy/worker-session-private-scope.d.ts +12 -0
  37. package/dist/core/autonomy/worker-session-private-scope.d.ts.map +1 -0
  38. package/dist/core/autonomy/worker-session-private-scope.js +42 -0
  39. package/dist/core/autonomy/worker-session-private-scope.js.map +1 -0
  40. package/dist/core/autonomy/worker-tool-adapter-registry.d.ts +65 -0
  41. package/dist/core/autonomy/worker-tool-adapter-registry.d.ts.map +1 -0
  42. package/dist/core/autonomy/worker-tool-adapter-registry.js +145 -0
  43. package/dist/core/autonomy/worker-tool-adapter-registry.js.map +1 -0
  44. package/dist/core/background-lane-controller.d.ts +9 -1
  45. package/dist/core/background-lane-controller.d.ts.map +1 -1
  46. package/dist/core/background-lane-controller.js +76 -6
  47. package/dist/core/background-lane-controller.js.map +1 -1
  48. package/dist/core/background-tool-task-controller.d.ts +23 -2
  49. package/dist/core/background-tool-task-controller.d.ts.map +1 -1
  50. package/dist/core/background-tool-task-controller.js +132 -17
  51. package/dist/core/background-tool-task-controller.js.map +1 -1
  52. package/dist/core/context/long-term-memory-trigger.d.ts +3 -1
  53. package/dist/core/context/long-term-memory-trigger.d.ts.map +1 -1
  54. package/dist/core/context/long-term-memory-trigger.js +1 -1
  55. package/dist/core/context/long-term-memory-trigger.js.map +1 -1
  56. package/dist/core/context/okf-memory-provider.d.ts +3 -0
  57. package/dist/core/context/okf-memory-provider.d.ts.map +1 -1
  58. package/dist/core/context/okf-memory-provider.js +66 -31
  59. package/dist/core/context/okf-memory-provider.js.map +1 -1
  60. package/dist/core/context/okf-memory.d.ts +18 -1
  61. package/dist/core/context/okf-memory.d.ts.map +1 -1
  62. package/dist/core/context/okf-memory.js +48 -0
  63. package/dist/core/context/okf-memory.js.map +1 -1
  64. package/dist/core/cost-guard-controller.d.ts +37 -0
  65. package/dist/core/cost-guard-controller.d.ts.map +1 -0
  66. package/dist/core/cost-guard-controller.js +71 -0
  67. package/dist/core/cost-guard-controller.js.map +1 -0
  68. package/dist/core/cost-guard.d.ts +9 -4
  69. package/dist/core/cost-guard.d.ts.map +1 -1
  70. package/dist/core/cost-guard.js +7 -3
  71. package/dist/core/cost-guard.js.map +1 -1
  72. package/dist/core/delegation/worker-agent-control.d.ts +4 -0
  73. package/dist/core/delegation/worker-agent-control.d.ts.map +1 -1
  74. package/dist/core/delegation/worker-agent-control.js.map +1 -1
  75. package/dist/core/delegation/worker-attempt-executor.d.ts +1 -1
  76. package/dist/core/delegation/worker-attempt-executor.d.ts.map +1 -1
  77. package/dist/core/delegation/worker-attempt-executor.js +0 -1
  78. package/dist/core/delegation/worker-attempt-executor.js.map +1 -1
  79. package/dist/core/delegation/worker-authority-resolver.d.ts +16 -3
  80. package/dist/core/delegation/worker-authority-resolver.d.ts.map +1 -1
  81. package/dist/core/delegation/worker-authority-resolver.js +114 -55
  82. package/dist/core/delegation/worker-authority-resolver.js.map +1 -1
  83. package/dist/core/delegation/worker-claim.d.ts +1 -2
  84. package/dist/core/delegation/worker-claim.d.ts.map +1 -1
  85. package/dist/core/delegation/worker-claim.js.map +1 -1
  86. package/dist/core/delegation/worker-delegation-controller.d.ts +19 -6
  87. package/dist/core/delegation/worker-delegation-controller.d.ts.map +1 -1
  88. package/dist/core/delegation/worker-delegation-controller.js +125 -40
  89. package/dist/core/delegation/worker-delegation-controller.js.map +1 -1
  90. package/dist/core/delegation/worker-delegation-request.d.ts +3 -3
  91. package/dist/core/delegation/worker-delegation-request.d.ts.map +1 -1
  92. package/dist/core/delegation/worker-delegation-request.js +13 -19
  93. package/dist/core/delegation/worker-delegation-request.js.map +1 -1
  94. package/dist/core/delegation/worker-execution-policy.d.ts +3 -2
  95. package/dist/core/delegation/worker-execution-policy.d.ts.map +1 -1
  96. package/dist/core/delegation/worker-execution-policy.js +54 -39
  97. package/dist/core/delegation/worker-execution-policy.js.map +1 -1
  98. package/dist/core/delegation/worker-fleet-limits.d.ts +3 -3
  99. package/dist/core/delegation/worker-fleet-limits.d.ts.map +1 -1
  100. package/dist/core/delegation/worker-fleet-limits.js +7 -7
  101. package/dist/core/delegation/worker-fleet-limits.js.map +1 -1
  102. package/dist/core/delegation/worker-machine-scope.d.ts +12 -0
  103. package/dist/core/delegation/worker-machine-scope.d.ts.map +1 -0
  104. package/dist/core/delegation/worker-machine-scope.js +38 -0
  105. package/dist/core/delegation/worker-machine-scope.js.map +1 -0
  106. package/dist/core/delegation/worker-notification-coordinator.d.ts +10 -0
  107. package/dist/core/delegation/worker-notification-coordinator.d.ts.map +1 -1
  108. package/dist/core/delegation/worker-notification-coordinator.js +69 -3
  109. package/dist/core/delegation/worker-notification-coordinator.js.map +1 -1
  110. package/dist/core/delegation/worker-recovery-coordinator.d.ts.map +1 -1
  111. package/dist/core/delegation/worker-recovery-coordinator.js +6 -1
  112. package/dist/core/delegation/worker-recovery-coordinator.js.map +1 -1
  113. package/dist/core/delegation/worker-runner.d.ts +5 -7
  114. package/dist/core/delegation/worker-runner.d.ts.map +1 -1
  115. package/dist/core/delegation/worker-runner.js +1 -4
  116. package/dist/core/delegation/worker-runner.js.map +1 -1
  117. package/dist/core/delegation/worker-write-reservation-coordinator.d.ts +3 -2
  118. package/dist/core/delegation/worker-write-reservation-coordinator.d.ts.map +1 -1
  119. package/dist/core/delegation/worker-write-reservation-coordinator.js +50 -25
  120. package/dist/core/delegation/worker-write-reservation-coordinator.js.map +1 -1
  121. package/dist/core/durable-custom-message-turn-controller.d.ts +6 -0
  122. package/dist/core/durable-custom-message-turn-controller.d.ts.map +1 -1
  123. package/dist/core/durable-custom-message-turn-controller.js +38 -15
  124. package/dist/core/durable-custom-message-turn-controller.js.map +1 -1
  125. package/dist/core/extension-binding-controller.d.ts +5 -1
  126. package/dist/core/extension-binding-controller.d.ts.map +1 -1
  127. package/dist/core/extension-binding-controller.js +15 -0
  128. package/dist/core/extension-binding-controller.js.map +1 -1
  129. package/dist/core/extensions/factory-runtime.d.ts.map +1 -1
  130. package/dist/core/extensions/factory-runtime.js +5 -0
  131. package/dist/core/extensions/factory-runtime.js.map +1 -1
  132. package/dist/core/extensions/runner.d.ts.map +1 -1
  133. package/dist/core/extensions/runner.js +1 -0
  134. package/dist/core/extensions/runner.js.map +1 -1
  135. package/dist/core/extensions/types.d.ts +8 -4
  136. package/dist/core/extensions/types.d.ts.map +1 -1
  137. package/dist/core/extensions/types.js.map +1 -1
  138. package/dist/core/foreground-terminal-handoff-controller.d.ts +31 -0
  139. package/dist/core/foreground-terminal-handoff-controller.d.ts.map +1 -1
  140. package/dist/core/foreground-terminal-handoff-controller.js +239 -55
  141. package/dist/core/foreground-terminal-handoff-controller.js.map +1 -1
  142. package/dist/core/goals/goal-session-controller.d.ts +2 -0
  143. package/dist/core/goals/goal-session-controller.d.ts.map +1 -1
  144. package/dist/core/goals/goal-session-controller.js +8 -0
  145. package/dist/core/goals/goal-session-controller.js.map +1 -1
  146. package/dist/core/goals/goal-tool-core.d.ts +5 -4
  147. package/dist/core/goals/goal-tool-core.d.ts.map +1 -1
  148. package/dist/core/goals/goal-tool-core.js +23 -19
  149. package/dist/core/goals/goal-tool-core.js.map +1 -1
  150. package/dist/core/learning/auto-learn-settings.d.ts +84 -0
  151. package/dist/core/learning/auto-learn-settings.d.ts.map +1 -0
  152. package/dist/core/learning/auto-learn-settings.js +66 -0
  153. package/dist/core/learning/auto-learn-settings.js.map +1 -0
  154. package/dist/core/learning/learning-audit.d.ts +5 -1
  155. package/dist/core/learning/learning-audit.d.ts.map +1 -1
  156. package/dist/core/learning/learning-audit.js +32 -1
  157. package/dist/core/learning/learning-audit.js.map +1 -1
  158. package/dist/core/learning/reflection-engine.d.ts +24 -0
  159. package/dist/core/learning/reflection-engine.d.ts.map +1 -1
  160. package/dist/core/learning/reflection-engine.js +104 -8
  161. package/dist/core/learning/reflection-engine.js.map +1 -1
  162. package/dist/core/local-prefix-warm-controller.d.ts +24 -0
  163. package/dist/core/local-prefix-warm-controller.d.ts.map +1 -0
  164. package/dist/core/local-prefix-warm-controller.js +79 -0
  165. package/dist/core/local-prefix-warm-controller.js.map +1 -0
  166. package/dist/core/memory/okf-project-memory-store.d.ts +28 -0
  167. package/dist/core/memory/okf-project-memory-store.d.ts.map +1 -0
  168. package/dist/core/memory/okf-project-memory-store.js +111 -0
  169. package/dist/core/memory/okf-project-memory-store.js.map +1 -0
  170. package/dist/core/memory/providers/file-store.d.ts +44 -1
  171. package/dist/core/memory/providers/file-store.d.ts.map +1 -1
  172. package/dist/core/memory/providers/file-store.js +341 -24
  173. package/dist/core/memory/providers/file-store.js.map +1 -1
  174. package/dist/core/memory/worker-memory-tools.d.ts +5 -0
  175. package/dist/core/memory/worker-memory-tools.d.ts.map +1 -0
  176. package/dist/core/memory/worker-memory-tools.js +5 -0
  177. package/dist/core/memory/worker-memory-tools.js.map +1 -0
  178. package/dist/core/memory-controller.d.ts +10 -1
  179. package/dist/core/memory-controller.d.ts.map +1 -1
  180. package/dist/core/memory-controller.js +72 -8
  181. package/dist/core/memory-controller.js.map +1 -1
  182. package/dist/core/model-capability.d.ts +7 -0
  183. package/dist/core/model-capability.d.ts.map +1 -1
  184. package/dist/core/model-capability.js +12 -0
  185. package/dist/core/model-capability.js.map +1 -1
  186. package/dist/core/model-registry.d.ts.map +1 -1
  187. package/dist/core/model-registry.js +2 -10
  188. package/dist/core/model-registry.js.map +1 -1
  189. package/dist/core/model-router-controller.d.ts +3 -2
  190. package/dist/core/model-router-controller.d.ts.map +1 -1
  191. package/dist/core/model-router-controller.js +3 -2
  192. package/dist/core/model-router-controller.js.map +1 -1
  193. package/dist/core/orchestration/contracts.d.ts +16 -12
  194. package/dist/core/orchestration/contracts.d.ts.map +1 -1
  195. package/dist/core/orchestration/contracts.js +2 -2
  196. package/dist/core/orchestration/contracts.js.map +1 -1
  197. package/dist/core/orchestration/lane-tool-manifests.d.ts +2 -2
  198. package/dist/core/orchestration/lane-tool-manifests.d.ts.map +1 -1
  199. package/dist/core/orchestration/lane-tool-manifests.js +6 -1
  200. package/dist/core/orchestration/lane-tool-manifests.js.map +1 -1
  201. package/dist/core/orchestration/profile-registry.d.ts.map +1 -1
  202. package/dist/core/orchestration/profile-registry.js +14 -0
  203. package/dist/core/orchestration/profile-registry.js.map +1 -1
  204. package/dist/core/orchestration/task-profile-writer.d.ts +7 -4
  205. package/dist/core/orchestration/task-profile-writer.d.ts.map +1 -1
  206. package/dist/core/orchestration/task-profile-writer.js +71 -59
  207. package/dist/core/orchestration/task-profile-writer.js.map +1 -1
  208. package/dist/core/orchestration/thinking-level-schema.d.ts +7 -0
  209. package/dist/core/orchestration/thinking-level-schema.d.ts.map +1 -0
  210. package/dist/core/orchestration/thinking-level-schema.js +19 -0
  211. package/dist/core/orchestration/thinking-level-schema.js.map +1 -0
  212. package/dist/core/orchestration/worker-execution-contract.d.ts.map +1 -1
  213. package/dist/core/orchestration/worker-execution-contract.js +12 -5
  214. package/dist/core/orchestration/worker-execution-contract.js.map +1 -1
  215. package/dist/core/provider-prompt-contracts.d.ts +1 -4
  216. package/dist/core/provider-prompt-contracts.d.ts.map +1 -1
  217. package/dist/core/provider-prompt-contracts.js +13 -29
  218. package/dist/core/provider-prompt-contracts.js.map +1 -1
  219. package/dist/core/provider-request-context-controller.d.ts +2 -0
  220. package/dist/core/provider-request-context-controller.d.ts.map +1 -1
  221. package/dist/core/provider-request-context-controller.js +10 -3
  222. package/dist/core/provider-request-context-controller.js.map +1 -1
  223. package/dist/core/reflection-controller.d.ts +63 -27
  224. package/dist/core/reflection-controller.d.ts.map +1 -1
  225. package/dist/core/reflection-controller.js +300 -132
  226. package/dist/core/reflection-controller.js.map +1 -1
  227. package/dist/core/runtime-builder.d.ts +1 -0
  228. package/dist/core/runtime-builder.d.ts.map +1 -1
  229. package/dist/core/runtime-builder.js +25 -14
  230. package/dist/core/runtime-builder.js.map +1 -1
  231. package/dist/core/secrets/credential-exposure-guard.d.ts.map +1 -1
  232. package/dist/core/secrets/credential-exposure-guard.js +55 -10
  233. package/dist/core/secrets/credential-exposure-guard.js.map +1 -1
  234. package/dist/core/session-role.d.ts +6 -8
  235. package/dist/core/session-role.d.ts.map +1 -1
  236. package/dist/core/session-role.js +8 -18
  237. package/dist/core/session-role.js.map +1 -1
  238. package/dist/core/settings-manager.d.ts +13 -16
  239. package/dist/core/settings-manager.d.ts.map +1 -1
  240. package/dist/core/settings-manager.js +53 -50
  241. package/dist/core/settings-manager.js.map +1 -1
  242. package/dist/core/skill-vault.d.ts +15 -0
  243. package/dist/core/skill-vault.d.ts.map +1 -1
  244. package/dist/core/skill-vault.js +79 -45
  245. package/dist/core/skill-vault.js.map +1 -1
  246. package/dist/core/skills.d.ts +3 -0
  247. package/dist/core/skills.d.ts.map +1 -1
  248. package/dist/core/skills.js +6 -6
  249. package/dist/core/skills.js.map +1 -1
  250. package/dist/core/system-prompt-builder.d.ts +2 -0
  251. package/dist/core/system-prompt-builder.d.ts.map +1 -1
  252. package/dist/core/system-prompt-builder.js +52 -12
  253. package/dist/core/system-prompt-builder.js.map +1 -1
  254. package/dist/core/system-prompt.js +1 -1
  255. package/dist/core/system-prompt.js.map +1 -1
  256. package/dist/core/tool-capability-policy.d.ts +3 -0
  257. package/dist/core/tool-capability-policy.d.ts.map +1 -1
  258. package/dist/core/tool-capability-policy.js +13 -2
  259. package/dist/core/tool-capability-policy.js.map +1 -1
  260. package/dist/core/toolkit/script-runner.d.ts +2 -1
  261. package/dist/core/toolkit/script-runner.d.ts.map +1 -1
  262. package/dist/core/toolkit/script-runner.js +10 -2
  263. package/dist/core/toolkit/script-runner.js.map +1 -1
  264. package/dist/core/tools/delegate-status.d.ts +3 -1
  265. package/dist/core/tools/delegate-status.d.ts.map +1 -1
  266. package/dist/core/tools/delegate-status.js +5 -1
  267. package/dist/core/tools/delegate-status.js.map +1 -1
  268. package/dist/core/tools/delegate.d.ts +4 -13
  269. package/dist/core/tools/delegate.d.ts.map +1 -1
  270. package/dist/core/tools/delegate.js +173 -73
  271. package/dist/core/tools/delegate.js.map +1 -1
  272. package/dist/core/tools/goal.d.ts +3 -4
  273. package/dist/core/tools/goal.d.ts.map +1 -1
  274. package/dist/core/tools/goal.js +24 -7
  275. package/dist/core/tools/goal.js.map +1 -1
  276. package/dist/core/tools/profile-writer.d.ts +2 -8
  277. package/dist/core/tools/profile-writer.d.ts.map +1 -1
  278. package/dist/core/tools/profile-writer.js +6 -18
  279. package/dist/core/tools/profile-writer.js.map +1 -1
  280. package/dist/core/tools/run-toolkit-script.d.ts +1 -1
  281. package/dist/core/tools/run-toolkit-script.d.ts.map +1 -1
  282. package/dist/core/tools/run-toolkit-script.js +2 -2
  283. package/dist/core/tools/run-toolkit-script.js.map +1 -1
  284. package/dist/core/tools/skill-audit.d.ts +28 -1
  285. package/dist/core/tools/skill-audit.d.ts.map +1 -1
  286. package/dist/core/tools/skill-audit.js +56 -12
  287. package/dist/core/tools/skill-audit.js.map +1 -1
  288. package/dist/core/tools/skill.d.ts +12 -1
  289. package/dist/core/tools/skill.d.ts.map +1 -1
  290. package/dist/core/tools/skill.js +52 -0
  291. package/dist/core/tools/skill.js.map +1 -1
  292. package/dist/core/tools/skillify.d.ts.map +1 -1
  293. package/dist/core/tools/skillify.js +16 -7
  294. package/dist/core/tools/skillify.js.map +1 -1
  295. package/dist/core/tools/task-steps.js +1 -1
  296. package/dist/core/tools/task-steps.js.map +1 -1
  297. package/dist/core/tools/tmux-dispatch.d.ts +4 -16
  298. package/dist/core/tools/tmux-dispatch.d.ts.map +1 -1
  299. package/dist/core/tools/tmux-dispatch.js +5 -20
  300. package/dist/core/tools/tmux-dispatch.js.map +1 -1
  301. package/dist/core/tools/tool-task.d.ts +1 -0
  302. package/dist/core/tools/tool-task.d.ts.map +1 -1
  303. package/dist/core/tools/tool-task.js +13 -8
  304. package/dist/core/tools/tool-task.js.map +1 -1
  305. package/dist/core/util/atomic-file.d.ts +2 -0
  306. package/dist/core/util/atomic-file.d.ts.map +1 -1
  307. package/dist/core/util/atomic-file.js +4 -0
  308. package/dist/core/util/atomic-file.js.map +1 -1
  309. package/dist/core/worktree-sync/codes.d.ts +1 -2
  310. package/dist/core/worktree-sync/codes.d.ts.map +1 -1
  311. package/dist/core/worktree-sync/codes.js +1 -2
  312. package/dist/core/worktree-sync/codes.js.map +1 -1
  313. package/dist/core/worktree-sync/lane-gate.d.ts +4 -8
  314. package/dist/core/worktree-sync/lane-gate.d.ts.map +1 -1
  315. package/dist/core/worktree-sync/lane-gate.js +5 -51
  316. package/dist/core/worktree-sync/lane-gate.js.map +1 -1
  317. package/dist/index.d.ts +5 -0
  318. package/dist/index.d.ts.map +1 -1
  319. package/dist/index.js +7 -0
  320. package/dist/index.js.map +1 -1
  321. package/dist/modes/interactive/auto-learn-controller.d.ts +6 -7
  322. package/dist/modes/interactive/auto-learn-controller.d.ts.map +1 -1
  323. package/dist/modes/interactive/auto-learn-controller.js +32 -207
  324. package/dist/modes/interactive/auto-learn-controller.js.map +1 -1
  325. package/dist/modes/interactive/autonomy-commands.js +2 -2
  326. package/dist/modes/interactive/autonomy-commands.js.map +1 -1
  327. package/dist/modes/interactive/components/activity-lane.d.ts.map +1 -1
  328. package/dist/modes/interactive/components/activity-lane.js +12 -23
  329. package/dist/modes/interactive/components/activity-lane.js.map +1 -1
  330. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
  331. package/dist/modes/interactive/components/custom-message.js +142 -1
  332. package/dist/modes/interactive/components/custom-message.js.map +1 -1
  333. package/dist/modes/interactive/components/fitness-role-selector.d.ts.map +1 -1
  334. package/dist/modes/interactive/components/fitness-role-selector.js +2 -2
  335. package/dist/modes/interactive/components/fitness-role-selector.js.map +1 -1
  336. package/dist/modes/interactive/components/footer.js +1 -1
  337. package/dist/modes/interactive/components/footer.js.map +1 -1
  338. package/dist/modes/interactive/components/settings-selector.d.ts +4 -0
  339. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  340. package/dist/modes/interactive/components/settings-selector.js +150 -73
  341. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  342. package/dist/modes/interactive/report-commands.d.ts.map +1 -1
  343. package/dist/modes/interactive/report-commands.js +8 -4
  344. package/dist/modes/interactive/report-commands.js.map +1 -1
  345. package/dist/modes/interactive/settings-selector-flow.d.ts.map +1 -1
  346. package/dist/modes/interactive/settings-selector-flow.js +10 -0
  347. package/dist/modes/interactive/settings-selector-flow.js.map +1 -1
  348. package/docs/extensions.md +8 -0
  349. package/docs/harness-architecture.md +28 -32
  350. package/docs/index.md +1 -1
  351. package/docs/process-matrix.md +8 -6
  352. package/docs/resources.md +1 -1
  353. package/docs/settings.md +61 -51
  354. package/docs/tmux-agent-manager.md +47 -40
  355. package/docs/usage.md +1 -1
  356. package/docs/worker-profiles.md +8 -6
  357. package/docs/worktree-sync.md +26 -20
  358. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  359. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  360. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  361. package/examples/extensions/sandbox/package-lock.json +2 -2
  362. package/examples/extensions/sandbox/package.json +1 -1
  363. package/examples/extensions/with-deps/package-lock.json +2 -2
  364. package/examples/extensions/with-deps/package.json +1 -1
  365. package/npm-shrinkwrap.json +12 -12
  366. package/package.json +4 -4
  367. package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.d.ts +0 -133
  368. package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.d.ts.map +0 -1
  369. package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.js +0 -199
  370. package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.js.map +0 -1
  371. package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.ts +0 -312
@@ -1 +1 @@
1
- {"version":3,"file":"atomic-file.js","sourceRoot":"","sources":["../../../src/core/util/atomic-file.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,QAAQ,IAAI,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACxE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAoB,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE7D;;;;;;;;;GASG;AACH,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAChC,MAAM,2BAA2B,GAAG,EAAE,CAAC;AACvC,MAAM,2BAA2B,GAAG,GAAG,CAAC;AAExC;;;;;;;;GAQG;AACH,SAAS,6BAA6B,CAAC,GAAY;IAClD,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO;QAAE,OAAO,KAAK,CAAC;IAC/C,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAC1D,MAAM,IAAI,GAAI,GAAyB,CAAC,IAAI,CAAC;IAC7C,OAAO,IAAI,KAAK,OAAO,IAAI,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,OAAO,CAAC;AAClE,CAAC;AAED,8FAA8F;AAC9F,SAAS,mBAAmB,CAAC,OAAe,EAAE,QAAgB,EAAE,EAAe;IAC9E,KAAK,IAAI,OAAO,GAAG,CAAC,EAAE,OAAO,IAAI,qBAAqB,EAAE,OAAO,EAAE,EAAE,CAAC;QACnE,IAAI,CAAC;YACJ,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;Y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E,CAAC,CAAC;YACrG,MAAM,eAAe,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;YACzC,OAAO,GAAG,IAAI,CAAC;QAChB,CAAC;gBAAS,CAAC;YACV,IAAI,CAAC,OAAO;gBAAE,MAAM,mBAAmB,CAAC,OAAO,CAAC,CAAC;QAClD,CAAC;IACF,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Shared atomic-file helper: a single lock+tmp+rename implementation reused by every\n * on-disk store that does a read-modify-write against a JSON/text file. Modeled on the pattern\n * already proven in `memory/providers/file-store.ts` (proper-lockfile advisory lock + write-tmp-\n * then-rename); before this helper existed the pattern was copy-pasted per store, and most copies\n * were missing either the lock, the atomic write, or both.\n *\n * Two call shapes:\n * - `withFileLock(Sync)` — hold an exclusive advisory lock across an arbitrary read-modify-write\n * callback. The lock spans BOTH the read and the write, closing the classic RMW race where two\n * writers each read the old content before either writes back.\n * - `writeFileAtomic(Sync)` — write-tmp-then-rename. Used INSIDE a `withFileLock` callback (or\n * standalone, for a pure overwrite that has no read step to race).\n *\n * Sync and async variants are both exported. Most existing stores expose a synchronous public API\n * called from hot, non-async paths (e.g. a per-token-stream perf sample), so the sync variant lets\n * them gain locking without forcing an async ripple through their callers; the async variant is for\n * call sites that are already async.\n */\n\nimport { randomUUID } from \"node:crypto\";\nimport { promises as fsPromises, mkdirSync, unlinkSync } from \"node:fs\";\nimport { dirname, resolve } from \"node:path\";\nimport lockfile from \"proper-lockfile\";\nimport { type FaultableFs, nodeFs } from \"./faultable-fs.ts\";\n\n/**\n * Bounded rename retry budget for the win32-only transient-rename handling below (see\n * {@link isTransientRenameErrorOnWin32}). Backoff doubles each attempt starting at\n * {@link RENAME_RETRY_MIN_TIMEOUT_MS} and capped at {@link RENAME_RETRY_MAX_TIMEOUT_MS}, mirroring\n * the doubling-backoff shape used for lock acquisition above. With {@link RENAME_RETRY_ATTEMPTS}\n * extra attempts (10, 20, 40, 80, ... capped at 200) the worst-case total wait is ~1.03s\n * (10+20+40+80+160+200+200+200+200 ~= 1110ms across 9 gaps), which comfortably covers the\n * millisecond-scale window Defender/the Windows Search indexer hold a freshly-written file open\n * without FILE_SHARE_DELETE before releasing it.\n */\nconst RENAME_RETRY_ATTEMPTS = 9;\nconst RENAME_RETRY_MIN_TIMEOUT_MS = 10;\nconst RENAME_RETRY_MAX_TIMEOUT_MS = 200;\n\n/**\n * On win32, antivirus (e.g. Windows Defender's real-time scanner) and the Windows Search indexer\n * routinely open a freshly-written file for a brief scan without `FILE_SHARE_DELETE`, which makes a\n * rename over/of that file fail transiently with EPERM/EACCES/EBUSY for a few milliseconds. This is\n * a well-documented platform semantic, not a bug in our write path — it's exactly why the\n * `graceful-fs` package ships its own win32 rename-retry wrapper. POSIX platforms never exhibit this\n * transient (a POSIX rename either succeeds or fails for a real, non-transient reason), so retry is\n * gated strictly to win32 to keep POSIX behavior byte-identical to a bare rename.\n */\nfunction isTransientRenameErrorOnWin32(err: unknown): boolean {\n\tif (process.platform !== \"win32\") return false;\n\tif (typeof err !== \"object\" || err === null) return false;\n\tconst code = (err as { code?: string }).code;\n\treturn code === \"EPERM\" || code === \"EACCES\" || code === \"EBUSY\";\n}\n\n/** Sync counterpart of the rename-retry policy; see {@link isTransientRenameErrorOnWin32}. */\nfunction renameSyncWithRetry(tmpPath: string, filePath: string, fs: FaultableFs): void {\n\tfor (let attempt = 0; attempt <= RENAME_RETRY_ATTEMPTS; attempt++) {\n\t\ttry {\n\t\t\tfs.renameSync(tmpPath, filePath);\n\t\t\treturn;\n\t\t} catch (err) {\n\t\t\tif (!isTransientRenameErrorOnWin32(err) || attempt === RENAME_RETRY_ATTEMPTS) throw err;\n\t\t\tconst backoffMs = Math.min(RENAME_RETRY_MIN_TIMEOUT_MS * 2 ** attempt, RENAME_RETRY_MAX_TIMEOUT_MS);\n\t\t\tblockingSleepMs(backoffMs);\n\t\t}\n\t}\n}\n\n/** Async counterpart of the rename-retry policy; see {@link isTransientRenameErrorOnWin32}. */\nasync function renameWithRetry(tmpPath: string, filePath: string): Promise<void> {\n\tfor (let attempt = 0; attempt <= RENAME_RETRY_ATTEMPTS; attempt++) {\n\t\ttry {\n\t\t\tawait fsPromises.rename(tmpPath, filePath);\n\t\t\treturn;\n\t\t} catch (err) {\n\t\t\tif (!isTransientRenameErrorOnWin32(err) || attempt === RENAME_RETRY_ATTEMPTS) throw err;\n\t\t\tconst backoffMs = Math.min(RENAME_RETRY_MIN_TIMEOUT_MS * 2 ** attempt, RENAME_RETRY_MAX_TIMEOUT_MS);\n\t\t\tawait new Promise((resolve) => setTimeout(resolve, backoffMs));\n\t\t}\n\t}\n}\n\nexport interface AtomicFileLockOptions {\n\t/**\n\t * Bounded retry attempts while waiting for a lock already held elsewhere. Both variants use a\n\t * SHORT, capped backoff (see {@link RETRY_MIN_TIMEOUT_MS}/{@link RETRY_MAX_TIMEOUT_MS}) — these\n\t * stores' critical sections are sub-millisecond reads+writes of small JSON/text files, so\n\t * contention should clear in milliseconds, not the multi-second-to-31-second worst case\n\t * proper-lockfile's OWN default backoff produces for a bare numeric `retries` (its default\n\t * `minTimeout` is 1000ms with factor 2 — see node_modules/retry/lib/retry.js). Passing a bare\n\t * number straight through would turn brief contention into a multi-second stall on a hot path\n\t * (e.g. a per-token-stream perf sample), so both variants instead build an explicit short-backoff\n\t * `retry` options object.\n\t * - Async (`withFileLock`): forwarded as `{retries, minTimeout, maxTimeout}` to proper-lockfile.\n\t * - Sync (`withFileLockSync`): proper-lockfile's sync API REJECTS `retries > 0` outright (it\n\t * requires the whole acquire flow to be synchronous — see proper-lockfile/lib/adapter.js\n\t * `toSyncOptions`, which throws `ESYNC`). So the sync path implements its own bounded retry\n\t * around single `lockfile.lockSync` attempts, blocking briefly between them (Atomics.wait) —\n\t * callers are already fully synchronous fs code, so a short blocking wait on contention matches\n\t * the existing execution model rather than introducing a new one.\n\t */\n\tretries?: number;\n\t/** Initial delay between sync/async acquisition attempts; defaults to 25ms. */\n\tminRetryDelayMs?: number;\n\t/** Maximum delay between sync/async acquisition attempts; defaults to 500ms. */\n\tmaxRetryDelayMs?: number;\n\t/** Retry-delay multiplier; defaults to 2. Set max=min for a fixed delay. */\n\tretryFactor?: number;\n\t/** Resolve symlinks before locking (proper-lockfile `realpath`); false matches file-store.ts. */\n\trealpath?: boolean;\n\t/** Lock staleness window in ms (proper-lockfile `stale`); omitted = proper-lockfile's own default. */\n\tstale?: number;\n\t/** Explicit proper-lockfile directory path; defaults to `${filePath}.lock`. */\n\tlockfilePath?: string;\n}\n\nexport interface AtomicFileWriteOptions {\n\t/** POSIX permission bits applied to the temporary file and inherited by the renamed destination. */\n\tmode?: number;\n\t/**\n\t * Injection seam for the mutating fs primitives this write issues (`mkdirSync`, `writeFileSync`,\n\t * `renameSync`). Defaults to real `node:fs` — omitting this option is a zero-behavior-change no-op.\n\t * Only the destructive-testing harness passes a fault-injecting implementation.\n\t */\n\tfs?: FaultableFs;\n}\n\nconst DEFAULT_RETRIES = 10;\nconst DEFAULT_REALPATH = false;\n/**\n * Capped doubling backoff shared by both variants — see {@link AtomicFileLockOptions.retries}.\n * With the current defaults (10 retries, 25ms floor, 500ms cap) the total worst-case contention\n * budget is ~3.3s (25+50+100+200+400+500+500+500+500+500), comfortably over the >= 2s floor this\n * needs to survive a loaded CI runner (e.g. the Windows CI mkdir/rmdir lock-directory churn under\n * two-real-OS-thread contention).\n */\nconst RETRY_MIN_TIMEOUT_MS = 25;\nconst RETRY_MAX_TIMEOUT_MS = 500;\n\n/**\n * Existing auth/settings/trust paths historically used 10 total attempts separated by 20ms. Keep\n * that low-latency user-facing policy explicit while routing the mechanism through this module.\n */\nexport const LOW_LATENCY_FILE_LOCK_OPTIONS: Readonly<AtomicFileLockOptions> = Object.freeze({\n\tretries: 9,\n\tminRetryDelayMs: 20,\n\tmaxRetryDelayMs: 20,\n});\n\nfunction lockDirectory(filePath: string, lockfilePath?: string): string {\n\treturn dirname(lockfilePath ?? filePath);\n}\n\nfunction ensureLockDirSync(filePath: string, lockfilePath?: string): void {\n\tmkdirSync(lockDirectory(filePath, lockfilePath), { recursive: true });\n}\n\nasync function ensureLockDir(filePath: string, lockfilePath?: string): Promise<void> {\n\tawait fsPromises.mkdir(lockDirectory(filePath, lockfilePath), { recursive: true });\n}\n\nfunction isLockedError(err: unknown): boolean {\n\tif (typeof err !== \"object\" || err === null) return false;\n\tconst code = (err as { code?: string }).code;\n\tif (code === \"ELOCKED\") return true;\n\t// On win32, mkdir-ing the lock directory can transiently surface EPERM (rather than the\n\t// expected EEXIST) when a previous incarnation of that directory is concurrently being\n\t// rmdir'd by the racing releaser — the mkdir lands mid-teardown and the OS reports \"operation\n\t// not permitted\" instead of \"already exists\". This is contention, not a real permissions\n\t// failure, so treat it identically to ELOCKED: retry with the existing backoff rather than\n\t// letting it escape as fatal. POSIX platforms don't exhibit this transient and keep surfacing\n\t// real EPERM (e.g. an actually unwritable directory) as fatal.\n\tif (code === \"EPERM\" && process.platform === \"win32\") return true;\n\treturn false;\n}\n\n/** Block the calling thread for `ms` without spinning the CPU (Atomics.wait on a private buffer). */\nfunction blockingSleepMs(ms: number): void {\n\tAtomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);\n}\n\ntype PendingPathOperations = Map<string, Promise<void>>;\n\nconst pendingAsyncFileLockTails: PendingPathOperations = new Map();\nconst pendingAtomicWriteTails: PendingPathOperations = new Map();\n\nfunction pathOperationKey(filePath: string): string {\n\tconst absolutePath = resolve(filePath);\n\treturn process.platform === \"win32\" ? absolutePath.toLowerCase() : absolutePath;\n}\n\n/**\n * Queue only operations that target the same platform path. This prevents same-process callers\n * from entering synchronized OS retry storms without imposing a process-wide or cross-tenant\n * bottleneck. The tail always resolves and self-removes, including after a failed operation.\n */\nasync function withSerializedPathOperation<T>(\n\ttails: PendingPathOperations,\n\tfilePath: string,\n\tfn: () => Promise<T>,\n): Promise<T> {\n\tconst key = pathOperationKey(filePath);\n\tconst preceding = tails.get(key) ?? Promise.resolve();\n\tlet releaseTail: (() => void) | undefined;\n\tconst tail = new Promise<void>((resolveTail) => {\n\t\treleaseTail = resolveTail;\n\t});\n\ttails.set(key, tail);\n\n\tawait preceding;\n\ttry {\n\t\treturn await fn();\n\t} finally {\n\t\treleaseTail?.();\n\t\tif (tails.get(key) === tail) tails.delete(key);\n\t}\n}\n\n/**\n * Acquire a proper-lockfile sync lock with bounded retry on `ELOCKED` (proper-lockfile's sync API\n * itself forbids `retries > 0`; see {@link AtomicFileLockOptions.retries}).\n *\n * Backoff doubles each attempt (mirroring the `retry` module's own `factor: 2` default that the\n * async path gets for free from proper-lockfile), starting at {@link RETRY_MIN_TIMEOUT_MS} and\n * capped at {@link RETRY_MAX_TIMEOUT_MS}.\n *\n * This is budget PARITY between two implementations of the same lock-acquisition contract, not\n * flake-masking: `options.retries` (a count of RETRIES, i.e. attempts after the first) means the\n * same thing on both paths, so both must make `retries + 1` total acquisition attempts with the\n * same per-gap backoff schedule. The async path gets `retries + 1` attempts for free from the\n * `retry` module (it retries `options.retries` times after its initial attempt); the sync path\n * used to loop exactly `attempts` times total (one fewer gap, and one fewer attempt than the\n * async path for the same `retries` value), which under-budgeted it relative to its async sibling\n * and surfaced as spurious ELOCKED failures under real contention (e.g. two OS threads hammering\n * the same file, or mkdir/rmdir lock-directory churn on a loaded Windows CI runner).\n */\nfunction retryCount(options: AtomicFileLockOptions): number {\n\tconst configured = options.retries ?? DEFAULT_RETRIES;\n\treturn Number.isFinite(configured) ? Math.max(0, Math.floor(configured)) : DEFAULT_RETRIES;\n}\n\nfunction retryDelayMs(options: AtomicFileLockOptions, attempt: number): number {\n\tconst configuredMin = options.minRetryDelayMs ?? RETRY_MIN_TIMEOUT_MS;\n\tconst minDelay = Number.isFinite(configuredMin) ? Math.max(0, configuredMin) : RETRY_MIN_TIMEOUT_MS;\n\tconst configuredMax = options.maxRetryDelayMs ?? RETRY_MAX_TIMEOUT_MS;\n\tconst maxDelay = Number.isFinite(configuredMax) ? Math.max(minDelay, configuredMax) : RETRY_MAX_TIMEOUT_MS;\n\tconst configuredFactor = options.retryFactor ?? 2;\n\tconst factor = Number.isFinite(configuredFactor) ? Math.max(1, configuredFactor) : 2;\n\treturn Math.min(minDelay * factor ** (attempt - 1), maxDelay);\n}\n\n/**\n * Acquire a synchronous advisory file lock and return its release function. This is the shared\n * mechanism for coordinators that must hold several locks in a deterministic order before entering\n * one critical section; callers retain ownership of release ordering and release-error semantics.\n */\nexport function acquireFileLockSync(filePath: string, options: AtomicFileLockOptions = {}): () => void {\n\tensureLockDirSync(filePath, options.lockfilePath);\n\tconst attempts = retryCount(options) + 1;\n\tconst lockOptions = {\n\t\tlockfilePath: options.lockfilePath,\n\t\trealpath: options.realpath ?? DEFAULT_REALPATH,\n\t\tstale: options.stale,\n\t};\n\tfor (let attempt = 1; attempt <= attempts; attempt++) {\n\t\ttry {\n\t\t\treturn lockfile.lockSync(filePath, lockOptions);\n\t\t} catch (err) {\n\t\t\tif (!isLockedError(err) || attempt === attempts) throw err;\n\t\t\tblockingSleepMs(retryDelayMs(options, attempt));\n\t\t}\n\t}\n\t// Unreachable (the loop always returns or throws), but keeps the function's return type honest.\n\tthrow new Error(`Failed to acquire lock for ${filePath}`);\n}\n\n/**\n * Hold an exclusive advisory lock on `filePath` for the duration of `fn` (sync). Always releases,\n * including when `fn` throws.\n */\nexport function withFileLockSync<T>(filePath: string, fn: () => T, options?: AtomicFileLockOptions): T {\n\tconst release = acquireFileLockSync(filePath, options);\n\ttry {\n\t\treturn fn();\n\t} finally {\n\t\t// A lock-cleanup failure must never mask fn()'s result (or replace fn()'s own thrown error) —\n\t\t// by this point fn() has already durably committed or failed on its own terms.\n\t\ttry {\n\t\t\trelease();\n\t\t} catch {\n\t\t\t// best-effort cleanup; a stale lock self-expires via proper-lockfile's `stale` window\n\t\t}\n\t}\n}\n\n/** Async counterpart of {@link withFileLockSync}. Always releases, including when `fn` throws/rejects. */\nexport async function withFileLock<T>(\n\tfilePath: string,\n\tfn: () => Promise<T> | T,\n\toptions?: AtomicFileLockOptions,\n): Promise<T> {\n\treturn withSerializedPathOperation(pendingAsyncFileLockTails, options?.lockfilePath ?? filePath, async () => {\n\t\tawait ensureLockDir(filePath, options?.lockfilePath);\n\t\tconst release = await lockfile.lock(filePath, {\n\t\t\tlockfilePath: options?.lockfilePath,\n\t\t\trealpath: options?.realpath ?? DEFAULT_REALPATH,\n\t\t\tretries: {\n\t\t\t\tretries: retryCount(options ?? {}),\n\t\t\t\tfactor: options?.retryFactor ?? 2,\n\t\t\t\tminTimeout: options?.minRetryDelayMs ?? RETRY_MIN_TIMEOUT_MS,\n\t\t\t\tmaxTimeout: options?.maxRetryDelayMs ?? RETRY_MAX_TIMEOUT_MS,\n\t\t\t},\n\t\t\tstale: options?.stale,\n\t\t});\n\t\ttry {\n\t\t\treturn await fn();\n\t\t} finally {\n\t\t\t// See {@link withFileLockSync} — cleanup failures must not mask fn()'s outcome.\n\t\t\tawait release().catch(() => {});\n\t\t}\n\t});\n}\n\n/**\n * Write `content` to `filePath` via write-tmp-then-rename (sync); the rename is atomic on the same\n * filesystem, so a concurrent reader never observes a partially-written file. Does NOT itself lock —\n * call from inside {@link withFileLockSync} when the write follows a read that must not race another\n * writer's read+write; call standalone for an unconditional overwrite with no read step.\n */\nfunction temporaryPath(filePath: string): string {\n\treturn `${filePath}.${process.pid}.${randomUUID()}.tmp`;\n}\n\n/**\n * Async standalone overwrites can legitimately target the same file at once. Unique temporary\n * names prevent writers from corrupting each other's staging files, but Windows still serializes\n * replacement renames internally. Letting every writer retry in lockstep creates a thundering herd\n * that can exhaust the bounded Defender/indexer retry budget even though no external process owns\n * the destination. Keep one FIFO tail per destination inside this process so each destination has\n * one writer at a time; writes to different destinations remain fully parallel. The tail is always\n * resolved and removed, including after a failed write, so one failure cannot poison later writes\n * or retain tenant paths indefinitely. File-lock queues are separate from atomic-write queues so a\n * write inside a held advisory lock never waits on itself.\n */\nasync function withSerializedAtomicWrite<T>(filePath: string, fn: () => Promise<T>): Promise<T> {\n\treturn withSerializedPathOperation(pendingAtomicWriteTails, filePath, fn);\n}\n\n/** Remove one invocation's temporary path without masking the original write/rename failure. */\nfunction removeTemporaryPathSync(tmpPath: string): void {\n\ttry {\n\t\tunlinkSync(tmpPath);\n\t} catch {\n\t\t// The rename may have consumed the path, or another failure may have prevented its creation.\n\t}\n}\n\nasync function removeTemporaryPath(tmpPath: string): Promise<void> {\n\ttry {\n\t\tawait fsPromises.unlink(tmpPath);\n\t} catch {\n\t\t// The rename may have consumed the path, or another failure may have prevented its creation.\n\t}\n}\n\nexport function writeFileAtomicSync(filePath: string, content: string, options?: AtomicFileWriteOptions): void {\n\tconst fs = options?.fs ?? nodeFs;\n\tfs.mkdirSync(dirname(filePath), { recursive: true });\n\tconst tmpPath = temporaryPath(filePath);\n\tlet renamed = false;\n\ttry {\n\t\t// `wx` makes a nonce collision harmless: never truncate another writer's temporary file.\n\t\tfs.writeFileSync(tmpPath, content, { encoding: \"utf-8\", flag: \"wx\", mode: options?.mode });\n\t\trenameSyncWithRetry(tmpPath, filePath, fs);\n\t\trenamed = true;\n\t} finally {\n\t\tif (!renamed) removeTemporaryPathSync(tmpPath);\n\t}\n}\n\n/** Async counterpart of {@link writeFileAtomicSync}. */\nexport async function writeFileAtomic(\n\tfilePath: string,\n\tcontent: string,\n\toptions?: AtomicFileWriteOptions,\n): Promise<void> {\n\tawait withSerializedAtomicWrite(filePath, async () => {\n\t\tawait fsPromises.mkdir(dirname(filePath), { recursive: true });\n\t\tconst tmpPath = temporaryPath(filePath);\n\t\tlet renamed = false;\n\t\ttry {\n\t\t\t// `wx` makes a nonce collision harmless: never truncate another writer's temporary file.\n\t\t\tawait fsPromises.writeFile(tmpPath, content, { encoding: \"utf-8\", flag: \"wx\", mode: options?.mode });\n\t\t\tawait renameWithRetry(tmpPath, filePath);\n\t\t\trenamed = true;\n\t\t} finally {\n\t\t\tif (!renamed) await removeTemporaryPath(tmpPath);\n\t\t}\n\t});\n}\n"]}
1
+ {"version":3,"file":"atomic-file.js","sourceRoot":"","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E,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;YACrG,MAAM,eAAe,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;YACzC,OAAO,GAAG,IAAI,CAAC;QAChB,CAAC;gBAAS,CAAC;YACV,IAAI,CAAC,OAAO;gBAAE,MAAM,mBAAmB,CAAC,OAAO,CAAC,CAAC;QAClD,CAAC;IACF,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Shared atomic-file helper: a single lock+tmp+rename implementation reused by every\n * on-disk store that does a read-modify-write against a JSON/text file. Modeled on the pattern\n * already proven in `memory/providers/file-store.ts` (proper-lockfile advisory lock + write-tmp-\n * then-rename); before this helper existed the pattern was copy-pasted per store, and most copies\n * were missing either the lock, the atomic write, or both.\n *\n * Two call shapes:\n * - `withFileLock(Sync)` — hold an exclusive advisory lock across an arbitrary read-modify-write\n * callback. The lock spans BOTH the read and the write, closing the classic RMW race where two\n * writers each read the old content before either writes back.\n * - `writeFileAtomic(Sync)` — write-tmp-then-rename. Used INSIDE a `withFileLock` callback (or\n * standalone, for a pure overwrite that has no read step to race).\n *\n * Sync and async variants are both exported. Most existing stores expose a synchronous public API\n * called from hot, non-async paths (e.g. a per-token-stream perf sample), so the sync variant lets\n * them gain locking without forcing an async ripple through their callers; the async variant is for\n * call sites that are already async.\n */\n\nimport { randomUUID } from \"node:crypto\";\nimport { promises as fsPromises, mkdirSync, unlinkSync } from \"node:fs\";\nimport { dirname, resolve } from \"node:path\";\nimport lockfile from \"proper-lockfile\";\nimport { type FaultableFs, nodeFs } from \"./faultable-fs.ts\";\n\n/**\n * Bounded rename retry budget for the win32-only transient-rename handling below (see\n * {@link isTransientRenameErrorOnWin32}). Backoff doubles each attempt starting at\n * {@link RENAME_RETRY_MIN_TIMEOUT_MS} and capped at {@link RENAME_RETRY_MAX_TIMEOUT_MS}, mirroring\n * the doubling-backoff shape used for lock acquisition above. With {@link RENAME_RETRY_ATTEMPTS}\n * extra attempts (10, 20, 40, 80, ... capped at 200) the worst-case total wait is ~1.03s\n * (10+20+40+80+160+200+200+200+200 ~= 1110ms across 9 gaps), which comfortably covers the\n * millisecond-scale window Defender/the Windows Search indexer hold a freshly-written file open\n * without FILE_SHARE_DELETE before releasing it.\n */\nconst RENAME_RETRY_ATTEMPTS = 9;\nconst RENAME_RETRY_MIN_TIMEOUT_MS = 10;\nconst RENAME_RETRY_MAX_TIMEOUT_MS = 200;\n\n/**\n * On win32, antivirus (e.g. Windows Defender's real-time scanner) and the Windows Search indexer\n * routinely open a freshly-written file for a brief scan without `FILE_SHARE_DELETE`, which makes a\n * rename over/of that file fail transiently with EPERM/EACCES/EBUSY for a few milliseconds. This is\n * a well-documented platform semantic, not a bug in our write path — it's exactly why the\n * `graceful-fs` package ships its own win32 rename-retry wrapper. POSIX platforms never exhibit this\n * transient (a POSIX rename either succeeds or fails for a real, non-transient reason), so retry is\n * gated strictly to win32 to keep POSIX behavior byte-identical to a bare rename.\n */\nfunction isTransientRenameErrorOnWin32(err: unknown): boolean {\n\tif (process.platform !== \"win32\") return false;\n\tif (typeof err !== \"object\" || err === null) return false;\n\tconst code = (err as { code?: string }).code;\n\treturn code === \"EPERM\" || code === \"EACCES\" || code === \"EBUSY\";\n}\n\n/** Sync counterpart of the rename-retry policy; see {@link isTransientRenameErrorOnWin32}. */\nfunction renameSyncWithRetry(tmpPath: string, filePath: string, fs: FaultableFs): void {\n\tfor (let attempt = 0; attempt <= RENAME_RETRY_ATTEMPTS; attempt++) {\n\t\ttry {\n\t\t\tfs.renameSync(tmpPath, filePath);\n\t\t\treturn;\n\t\t} catch (err) {\n\t\t\tif (!isTransientRenameErrorOnWin32(err) || attempt === RENAME_RETRY_ATTEMPTS) throw err;\n\t\t\tconst backoffMs = Math.min(RENAME_RETRY_MIN_TIMEOUT_MS * 2 ** attempt, RENAME_RETRY_MAX_TIMEOUT_MS);\n\t\t\tblockingSleepMs(backoffMs);\n\t\t}\n\t}\n}\n\n/** Async counterpart of the rename-retry policy; see {@link isTransientRenameErrorOnWin32}. */\nasync function renameWithRetry(tmpPath: string, filePath: string): Promise<void> {\n\tfor (let attempt = 0; attempt <= RENAME_RETRY_ATTEMPTS; attempt++) {\n\t\ttry {\n\t\t\tawait fsPromises.rename(tmpPath, filePath);\n\t\t\treturn;\n\t\t} catch (err) {\n\t\t\tif (!isTransientRenameErrorOnWin32(err) || attempt === RENAME_RETRY_ATTEMPTS) throw err;\n\t\t\tconst backoffMs = Math.min(RENAME_RETRY_MIN_TIMEOUT_MS * 2 ** attempt, RENAME_RETRY_MAX_TIMEOUT_MS);\n\t\t\tawait new Promise((resolve) => setTimeout(resolve, backoffMs));\n\t\t}\n\t}\n}\n\nexport interface AtomicFileLockOptions {\n\t/**\n\t * Bounded retry attempts while waiting for a lock already held elsewhere. Both variants use a\n\t * SHORT, capped backoff (see {@link RETRY_MIN_TIMEOUT_MS}/{@link RETRY_MAX_TIMEOUT_MS}) — these\n\t * stores' critical sections are sub-millisecond reads+writes of small JSON/text files, so\n\t * contention should clear in milliseconds, not the multi-second-to-31-second worst case\n\t * proper-lockfile's OWN default backoff produces for a bare numeric `retries` (its default\n\t * `minTimeout` is 1000ms with factor 2 — see node_modules/retry/lib/retry.js). Passing a bare\n\t * number straight through would turn brief contention into a multi-second stall on a hot path\n\t * (e.g. a per-token-stream perf sample), so both variants instead build an explicit short-backoff\n\t * `retry` options object.\n\t * - Async (`withFileLock`): forwarded as `{retries, minTimeout, maxTimeout}` to proper-lockfile.\n\t * - Sync (`withFileLockSync`): proper-lockfile's sync API REJECTS `retries > 0` outright (it\n\t * requires the whole acquire flow to be synchronous — see proper-lockfile/lib/adapter.js\n\t * `toSyncOptions`, which throws `ESYNC`). So the sync path implements its own bounded retry\n\t * around single `lockfile.lockSync` attempts, blocking briefly between them (Atomics.wait) —\n\t * callers are already fully synchronous fs code, so a short blocking wait on contention matches\n\t * the existing execution model rather than introducing a new one.\n\t */\n\tretries?: number;\n\t/** Initial delay between sync/async acquisition attempts; defaults to 25ms. */\n\tminRetryDelayMs?: number;\n\t/** Maximum delay between sync/async acquisition attempts; defaults to 500ms. */\n\tmaxRetryDelayMs?: number;\n\t/** Retry-delay multiplier; defaults to 2. Set max=min for a fixed delay. */\n\tretryFactor?: number;\n\t/** Resolve symlinks before locking (proper-lockfile `realpath`); false matches file-store.ts. */\n\trealpath?: boolean;\n\t/** Lock staleness window in ms (proper-lockfile `stale`); omitted = proper-lockfile's own default. */\n\tstale?: number;\n\t/** Explicit proper-lockfile directory path; defaults to `${filePath}.lock`. */\n\tlockfilePath?: string;\n}\n\nexport interface AtomicFileWriteOptions {\n\t/** POSIX permission bits applied to the temporary file and inherited by the renamed destination. */\n\tmode?: number;\n\t/**\n\t * Injection seam for the mutating fs primitives this write issues (`mkdirSync`, `writeFileSync`,\n\t * `renameSync`). Defaults to real `node:fs` — omitting this option is a zero-behavior-change no-op.\n\t * Only the destructive-testing harness passes a fault-injecting implementation.\n\t */\n\tfs?: FaultableFs;\n}\n\n/** Narrow an unknown Node filesystem failure without unsafe casts at every storage owner. */\nexport function isMissingFileError(error: unknown): boolean {\n\treturn typeof error === \"object\" && error !== null && \"code\" in error && error.code === \"ENOENT\";\n}\n\nconst DEFAULT_RETRIES = 10;\nconst DEFAULT_REALPATH = false;\n/**\n * Capped doubling backoff shared by both variants — see {@link AtomicFileLockOptions.retries}.\n * With the current defaults (10 retries, 25ms floor, 500ms cap) the total worst-case contention\n * budget is ~3.3s (25+50+100+200+400+500+500+500+500+500), comfortably over the >= 2s floor this\n * needs to survive a loaded CI runner (e.g. the Windows CI mkdir/rmdir lock-directory churn under\n * two-real-OS-thread contention).\n */\nconst RETRY_MIN_TIMEOUT_MS = 25;\nconst RETRY_MAX_TIMEOUT_MS = 500;\n\n/**\n * Existing auth/settings/trust paths historically used 10 total attempts separated by 20ms. Keep\n * that low-latency user-facing policy explicit while routing the mechanism through this module.\n */\nexport const LOW_LATENCY_FILE_LOCK_OPTIONS: Readonly<AtomicFileLockOptions> = Object.freeze({\n\tretries: 9,\n\tminRetryDelayMs: 20,\n\tmaxRetryDelayMs: 20,\n});\n\nfunction lockDirectory(filePath: string, lockfilePath?: string): string {\n\treturn dirname(lockfilePath ?? filePath);\n}\n\nfunction ensureLockDirSync(filePath: string, lockfilePath?: string): void {\n\tmkdirSync(lockDirectory(filePath, lockfilePath), { recursive: true });\n}\n\nasync function ensureLockDir(filePath: string, lockfilePath?: string): Promise<void> {\n\tawait fsPromises.mkdir(lockDirectory(filePath, lockfilePath), { recursive: true });\n}\n\nfunction isLockedError(err: unknown): boolean {\n\tif (typeof err !== \"object\" || err === null) return false;\n\tconst code = (err as { code?: string }).code;\n\tif (code === \"ELOCKED\") return true;\n\t// On win32, mkdir-ing the lock directory can transiently surface EPERM (rather than the\n\t// expected EEXIST) when a previous incarnation of that directory is concurrently being\n\t// rmdir'd by the racing releaser — the mkdir lands mid-teardown and the OS reports \"operation\n\t// not permitted\" instead of \"already exists\". This is contention, not a real permissions\n\t// failure, so treat it identically to ELOCKED: retry with the existing backoff rather than\n\t// letting it escape as fatal. POSIX platforms don't exhibit this transient and keep surfacing\n\t// real EPERM (e.g. an actually unwritable directory) as fatal.\n\tif (code === \"EPERM\" && process.platform === \"win32\") return true;\n\treturn false;\n}\n\n/** Block the calling thread for `ms` without spinning the CPU (Atomics.wait on a private buffer). */\nfunction blockingSleepMs(ms: number): void {\n\tAtomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);\n}\n\ntype PendingPathOperations = Map<string, Promise<void>>;\n\nconst pendingAsyncFileLockTails: PendingPathOperations = new Map();\nconst pendingAtomicWriteTails: PendingPathOperations = new Map();\n\nfunction pathOperationKey(filePath: string): string {\n\tconst absolutePath = resolve(filePath);\n\treturn process.platform === \"win32\" ? absolutePath.toLowerCase() : absolutePath;\n}\n\n/**\n * Queue only operations that target the same platform path. This prevents same-process callers\n * from entering synchronized OS retry storms without imposing a process-wide or cross-tenant\n * bottleneck. The tail always resolves and self-removes, including after a failed operation.\n */\nasync function withSerializedPathOperation<T>(\n\ttails: PendingPathOperations,\n\tfilePath: string,\n\tfn: () => Promise<T>,\n): Promise<T> {\n\tconst key = pathOperationKey(filePath);\n\tconst preceding = tails.get(key) ?? Promise.resolve();\n\tlet releaseTail: (() => void) | undefined;\n\tconst tail = new Promise<void>((resolveTail) => {\n\t\treleaseTail = resolveTail;\n\t});\n\ttails.set(key, tail);\n\n\tawait preceding;\n\ttry {\n\t\treturn await fn();\n\t} finally {\n\t\treleaseTail?.();\n\t\tif (tails.get(key) === tail) tails.delete(key);\n\t}\n}\n\n/**\n * Acquire a proper-lockfile sync lock with bounded retry on `ELOCKED` (proper-lockfile's sync API\n * itself forbids `retries > 0`; see {@link AtomicFileLockOptions.retries}).\n *\n * Backoff doubles each attempt (mirroring the `retry` module's own `factor: 2` default that the\n * async path gets for free from proper-lockfile), starting at {@link RETRY_MIN_TIMEOUT_MS} and\n * capped at {@link RETRY_MAX_TIMEOUT_MS}.\n *\n * This is budget PARITY between two implementations of the same lock-acquisition contract, not\n * flake-masking: `options.retries` (a count of RETRIES, i.e. attempts after the first) means the\n * same thing on both paths, so both must make `retries + 1` total acquisition attempts with the\n * same per-gap backoff schedule. The async path gets `retries + 1` attempts for free from the\n * `retry` module (it retries `options.retries` times after its initial attempt); the sync path\n * used to loop exactly `attempts` times total (one fewer gap, and one fewer attempt than the\n * async path for the same `retries` value), which under-budgeted it relative to its async sibling\n * and surfaced as spurious ELOCKED failures under real contention (e.g. two OS threads hammering\n * the same file, or mkdir/rmdir lock-directory churn on a loaded Windows CI runner).\n */\nfunction retryCount(options: AtomicFileLockOptions): number {\n\tconst configured = options.retries ?? DEFAULT_RETRIES;\n\treturn Number.isFinite(configured) ? Math.max(0, Math.floor(configured)) : DEFAULT_RETRIES;\n}\n\nfunction retryDelayMs(options: AtomicFileLockOptions, attempt: number): number {\n\tconst configuredMin = options.minRetryDelayMs ?? RETRY_MIN_TIMEOUT_MS;\n\tconst minDelay = Number.isFinite(configuredMin) ? Math.max(0, configuredMin) : RETRY_MIN_TIMEOUT_MS;\n\tconst configuredMax = options.maxRetryDelayMs ?? RETRY_MAX_TIMEOUT_MS;\n\tconst maxDelay = Number.isFinite(configuredMax) ? Math.max(minDelay, configuredMax) : RETRY_MAX_TIMEOUT_MS;\n\tconst configuredFactor = options.retryFactor ?? 2;\n\tconst factor = Number.isFinite(configuredFactor) ? Math.max(1, configuredFactor) : 2;\n\treturn Math.min(minDelay * factor ** (attempt - 1), maxDelay);\n}\n\n/**\n * Acquire a synchronous advisory file lock and return its release function. This is the shared\n * mechanism for coordinators that must hold several locks in a deterministic order before entering\n * one critical section; callers retain ownership of release ordering and release-error semantics.\n */\nexport function acquireFileLockSync(filePath: string, options: AtomicFileLockOptions = {}): () => void {\n\tensureLockDirSync(filePath, options.lockfilePath);\n\tconst attempts = retryCount(options) + 1;\n\tconst lockOptions = {\n\t\tlockfilePath: options.lockfilePath,\n\t\trealpath: options.realpath ?? DEFAULT_REALPATH,\n\t\tstale: options.stale,\n\t};\n\tfor (let attempt = 1; attempt <= attempts; attempt++) {\n\t\ttry {\n\t\t\treturn lockfile.lockSync(filePath, lockOptions);\n\t\t} catch (err) {\n\t\t\tif (!isLockedError(err) || attempt === attempts) throw err;\n\t\t\tblockingSleepMs(retryDelayMs(options, attempt));\n\t\t}\n\t}\n\t// Unreachable (the loop always returns or throws), but keeps the function's return type honest.\n\tthrow new Error(`Failed to acquire lock for ${filePath}`);\n}\n\n/**\n * Hold an exclusive advisory lock on `filePath` for the duration of `fn` (sync). Always releases,\n * including when `fn` throws.\n */\nexport function withFileLockSync<T>(filePath: string, fn: () => T, options?: AtomicFileLockOptions): T {\n\tconst release = acquireFileLockSync(filePath, options);\n\ttry {\n\t\treturn fn();\n\t} finally {\n\t\t// A lock-cleanup failure must never mask fn()'s result (or replace fn()'s own thrown error) —\n\t\t// by this point fn() has already durably committed or failed on its own terms.\n\t\ttry {\n\t\t\trelease();\n\t\t} catch {\n\t\t\t// best-effort cleanup; a stale lock self-expires via proper-lockfile's `stale` window\n\t\t}\n\t}\n}\n\n/** Async counterpart of {@link withFileLockSync}. Always releases, including when `fn` throws/rejects. */\nexport async function withFileLock<T>(\n\tfilePath: string,\n\tfn: () => Promise<T> | T,\n\toptions?: AtomicFileLockOptions,\n): Promise<T> {\n\treturn withSerializedPathOperation(pendingAsyncFileLockTails, options?.lockfilePath ?? filePath, async () => {\n\t\tawait ensureLockDir(filePath, options?.lockfilePath);\n\t\tconst release = await lockfile.lock(filePath, {\n\t\t\tlockfilePath: options?.lockfilePath,\n\t\t\trealpath: options?.realpath ?? DEFAULT_REALPATH,\n\t\t\tretries: {\n\t\t\t\tretries: retryCount(options ?? {}),\n\t\t\t\tfactor: options?.retryFactor ?? 2,\n\t\t\t\tminTimeout: options?.minRetryDelayMs ?? RETRY_MIN_TIMEOUT_MS,\n\t\t\t\tmaxTimeout: options?.maxRetryDelayMs ?? RETRY_MAX_TIMEOUT_MS,\n\t\t\t},\n\t\t\tstale: options?.stale,\n\t\t});\n\t\ttry {\n\t\t\treturn await fn();\n\t\t} finally {\n\t\t\t// See {@link withFileLockSync} — cleanup failures must not mask fn()'s outcome.\n\t\t\tawait release().catch(() => {});\n\t\t}\n\t});\n}\n\n/**\n * Write `content` to `filePath` via write-tmp-then-rename (sync); the rename is atomic on the same\n * filesystem, so a concurrent reader never observes a partially-written file. Does NOT itself lock —\n * call from inside {@link withFileLockSync} when the write follows a read that must not race another\n * writer's read+write; call standalone for an unconditional overwrite with no read step.\n */\nfunction temporaryPath(filePath: string): string {\n\treturn `${filePath}.${process.pid}.${randomUUID()}.tmp`;\n}\n\n/**\n * Async standalone overwrites can legitimately target the same file at once. Unique temporary\n * names prevent writers from corrupting each other's staging files, but Windows still serializes\n * replacement renames internally. Letting every writer retry in lockstep creates a thundering herd\n * that can exhaust the bounded Defender/indexer retry budget even though no external process owns\n * the destination. Keep one FIFO tail per destination inside this process so each destination has\n * one writer at a time; writes to different destinations remain fully parallel. The tail is always\n * resolved and removed, including after a failed write, so one failure cannot poison later writes\n * or retain tenant paths indefinitely. File-lock queues are separate from atomic-write queues so a\n * write inside a held advisory lock never waits on itself.\n */\nasync function withSerializedAtomicWrite<T>(filePath: string, fn: () => Promise<T>): Promise<T> {\n\treturn withSerializedPathOperation(pendingAtomicWriteTails, filePath, fn);\n}\n\n/** Remove one invocation's temporary path without masking the original write/rename failure. */\nfunction removeTemporaryPathSync(tmpPath: string): void {\n\ttry {\n\t\tunlinkSync(tmpPath);\n\t} catch {\n\t\t// The rename may have consumed the path, or another failure may have prevented its creation.\n\t}\n}\n\nasync function removeTemporaryPath(tmpPath: string): Promise<void> {\n\ttry {\n\t\tawait fsPromises.unlink(tmpPath);\n\t} catch {\n\t\t// The rename may have consumed the path, or another failure may have prevented its creation.\n\t}\n}\n\nexport function writeFileAtomicSync(filePath: string, content: string, options?: AtomicFileWriteOptions): void {\n\tconst fs = options?.fs ?? nodeFs;\n\tfs.mkdirSync(dirname(filePath), { recursive: true });\n\tconst tmpPath = temporaryPath(filePath);\n\tlet renamed = false;\n\ttry {\n\t\t// `wx` makes a nonce collision harmless: never truncate another writer's temporary file.\n\t\tfs.writeFileSync(tmpPath, content, { encoding: \"utf-8\", flag: \"wx\", mode: options?.mode });\n\t\trenameSyncWithRetry(tmpPath, filePath, fs);\n\t\trenamed = true;\n\t} finally {\n\t\tif (!renamed) removeTemporaryPathSync(tmpPath);\n\t}\n}\n\n/** Async counterpart of {@link writeFileAtomicSync}. */\nexport async function writeFileAtomic(\n\tfilePath: string,\n\tcontent: string,\n\toptions?: AtomicFileWriteOptions,\n): Promise<void> {\n\tawait withSerializedAtomicWrite(filePath, async () => {\n\t\tawait fsPromises.mkdir(dirname(filePath), { recursive: true });\n\t\tconst tmpPath = temporaryPath(filePath);\n\t\tlet renamed = false;\n\t\ttry {\n\t\t\t// `wx` makes a nonce collision harmless: never truncate another writer's temporary file.\n\t\t\tawait fsPromises.writeFile(tmpPath, content, { encoding: \"utf-8\", flag: \"wx\", mode: options?.mode });\n\t\t\tawait renameWithRetry(tmpPath, filePath);\n\t\t\trenamed = true;\n\t\t} finally {\n\t\t\tif (!renamed) await removeTemporaryPath(tmpPath);\n\t\t}\n\t});\n}\n"]}
@@ -2,8 +2,7 @@
2
2
  * Worktree-sync SSOT for tagged result codes and shared record types.
3
3
  *
4
4
  * Every worktree-sync operation reports its outcome through one of these string-literal codes in
5
- * a typed result -- callers branch on `code`, NEVER on message/stderr substrings (the
6
- * `classifyDispatchError` substring compromise is deliberately not repeated here). Git stderr is
5
+ * a typed result -- callers branch on `code`, NEVER on message/stderr substrings. Git stderr is
7
6
  * carried alongside as evidence for humans, not as a branch condition.
8
7
  */
9
8
  /** Cap on `WorktreeSyncEpoch.changedPaths`; beyond it the list is truncated and overlap checks
@@ -1 +1 @@
1
- {"version":3,"file":"codes.d.ts","sourceRoot":"","sources":["../../../src/core/worktree-sync/codes.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;gGACgG;AAChG,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAE3C,6DAA6D;AAC7D,eAAO,MAAM,kBAAkB,WAAW,CAAC;AAE3C,MAAM,MAAM,gBAAgB,GACzB,IAAI,GACJ,UAAU,GACV,gBAAgB,GAChB,2BAA2B,GAC3B,aAAa,GACb,kBAAkB,GAClB,aAAa,GACb,gBAAgB,GAChB,mBAAmB,GACnB,YAAY,GACZ,WAAW,GACX,YAAY,GACZ,eAAe,GACf,YAAY,GACZ,gBAAgB,GAChB,oBAAoB,GACpB,uBAAuB,GACvB,0BAA0B,GAC1B,oBAAoB,GACpB,aAAa,GACb,0BAA0B,GAC1B,WAAW,GACX,WAAW,GACX,eAAe,GACf,iBAAiB,GACjB,uBAAuB,GACvB,oBAAoB,GACpB,kBAAkB,GAClB,UAAU,GACV,YAAY,GACZ,WAAW,GACX,gBAAgB,GAChB,mBAAmB,GACnB,qBAAqB,CAAC;AAEzB;;;;;GAKG;AACH,MAAM,WAAW,mBAAmB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B,CAAC;QAAC,WAAW,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;IAC9E,KAAK,EAAE,eAAe,EAAE,CAAC;IACzB,iGAAiG;IACjG,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,gBAAgB,GACzB,UAAU,GACV,mBAAmB,CAAC,gBAAgB,GAAG,2BAA2B,GAAG,WAAW,CAAC,CAAC"}
1
+ {"version":3,"file":"codes.d.ts","sourceRoot":"","sources":["../../../src/core/worktree-sync/codes.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;gGACgG;AAChG,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAE3C,6DAA6D;AAC7D,eAAO,MAAM,kBAAkB,WAAW,CAAC;AAE3C,MAAM,MAAM,gBAAgB,GACzB,IAAI,GACJ,UAAU,GACV,gBAAgB,GAChB,2BAA2B,GAC3B,aAAa,GACb,kBAAkB,GAClB,aAAa,GACb,gBAAgB,GAChB,mBAAmB,GACnB,YAAY,GACZ,WAAW,GACX,YAAY,GACZ,eAAe,GACf,YAAY,GACZ,gBAAgB,GAChB,oBAAoB,GACpB,uBAAuB,GACvB,0BAA0B,GAC1B,oBAAoB,GACpB,aAAa,GACb,0BAA0B,GAC1B,WAAW,GACX,WAAW,GACX,eAAe,GACf,iBAAiB,GACjB,uBAAuB,GACvB,oBAAoB,GACpB,kBAAkB,GAClB,UAAU,GACV,YAAY,GACZ,WAAW,GACX,gBAAgB,GAChB,mBAAmB,GACnB,qBAAqB,CAAC;AAEzB;;;;;GAKG;AACH,MAAM,WAAW,mBAAmB,CAAC,CAAC,SAAS,gBAAgB,GAAG,gBAAgB;IACjF,IAAI,EAAE,CAAC,CAAC;IACR,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,MAAM,CAAC,EAAE,oBAAoB,CAAC;CAC9B;AAED;;yFAEyF;AACzF,MAAM,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C"}
@@ -2,8 +2,7 @@
2
2
  * Worktree-sync SSOT for tagged result codes and shared record types.
3
3
  *
4
4
  * Every worktree-sync operation reports its outcome through one of these string-literal codes in
5
- * a typed result -- callers branch on `code`, NEVER on message/stderr substrings (the
6
- * `classifyDispatchError` substring compromise is deliberately not repeated here). Git stderr is
5
+ * a typed result -- callers branch on `code`, NEVER on message/stderr substrings. Git stderr is
7
6
  * carried alongside as evidence for humans, not as a branch condition.
8
7
  */
9
8
  /** Cap on `WorktreeSyncEpoch.changedPaths`; beyond it the list is truncated and overlap checks
@@ -1 +1 @@
1
- {"version":3,"file":"codes.js","sourceRoot":"","sources":["../../../src/core/worktree-sync/codes.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;gGACgG;AAChG,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAE3C,6DAA6D;AAC7D,MAAM,CAAC,MAAM,kBAAkB,GAAG,QAAQ,CAAC","sourcesContent":["/**\n * Worktree-sync SSOT for tagged result codes and shared record types.\n *\n * Every worktree-sync operation reports its outcome through one of these string-literal codes in\n * a typed result -- callers branch on `code`, NEVER on message/stderr substrings (the\n * `classifyDispatchError` substring compromise is deliberately not repeated here). Git stderr is\n * carried alongside as evidence for humans, not as a branch condition.\n */\n\n/** Cap on `WorktreeSyncEpoch.changedPaths`; beyond it the list is truncated and overlap checks\n * treat the land as conservatively overlapping EVERYTHING (deterministic, never optimistic). */\nexport const EPOCH_CHANGED_PATHS_CAP = 500;\n\n/** Branch namespace for lane branches: `pi/wt/<laneKey>`. */\nexport const LANE_BRANCH_PREFIX = \"pi/wt/\";\n\nexport type WorktreeSyncCode =\n\t| \"ok\"\n\t| \"disabled\"\n\t| \"not_a_git_repo\"\n\t| \"default_branch_unresolved\"\n\t| \"hub_missing\"\n\t| \"invalid_lane_key\"\n\t| \"lane_exists\"\n\t| \"lane_not_found\"\n\t| \"max_lanes_reached\"\n\t| \"lane_dirty\"\n\t| \"hub_dirty\"\n\t| \"stale_lane\"\n\t| \"sync_required\"\n\t| \"sync_clean\"\n\t| \"sync_conflicts\"\n\t| \"rebase_in_progress\"\n\t| \"no_rebase_in_progress\"\n\t| \"conflict_markers_present\"\n\t| \"gate_command_unset\"\n\t| \"gate_failed\"\n\t| \"lane_changed_during_gate\"\n\t| \"ff_failed\"\n\t| \"lock_busy\"\n\t| \"lock_takeover\"\n\t| \"nothing_to_land\"\n\t| \"main_mutation_refused\"\n\t| \"lane_unlanded_work\"\n\t| \"worktree_missing\"\n\t| \"released\"\n\t| \"reconciled\"\n\t| \"git_error\"\n\t| \"role_forbidden\"\n\t| \"path_outside_lane\"\n\t| \"lane_owner_conflict\";\n\n/**\n * A refusal/failure outcome. `message` is deterministic text assembled from facts (safe to show a\n * model verbatim); `gitStderr` is bounded raw evidence; `paths` names offending files where the\n * refusal is about specific files (dirty files, conflict markers); `holder` identifies the\n * integration-lock holder on `lock_busy`.\n */\nexport interface WorktreeSyncRefusal<C extends WorktreeSyncCode = WorktreeSyncCode> {\n\tcode: C;\n\tmessage: string;\n\tgitStderr?: string;\n\tpaths?: string[];\n\tholder?: IntegrationLockOwner;\n}\n\n/** Staleness-propagation policy (D9). `on_land_mandatory` is the default: every land marks every\n * other active lane sync_required. `overlap_mandatory` requires it only on changed-file overlap.\n * `land_time_only` keeps staleness advisory until the land gate (G3 always enforces). */\nexport type WorktreeSyncPolicy = \"on_land_mandatory\" | \"overlap_mandatory\" | \"land_time_only\";\n\n/** One lane registration record (`lanes/<laneKey>.json`). Identity/binding fields ONLY -- git\n * truths (freshness, dirtiness, ahead/behind) are always re-derived live, never stored here. */\nexport interface LaneRegistration {\n\tlaneKey: string;\n\tbranch: string;\n\tworktreePath: string;\n\tstatus: \"active\" | \"released\" | \"orphaned\";\n\tcreatedAt: string;\n\tupdatedAt: string;\n\tgoalId?: string;\n\trequirementId?: string;\n\t/** Host `LaneRecord.laneId` after dispatch correlation (tmux/in-process worker binding). */\n\tboundLaneId?: string;\n\townerPid?: number;\n\townerSessionId?: string;\n}\n\n/** `epoch.json` -- the integration epoch. `epoch` is monotonic messaging/audit sugar; correctness\n * always derives from git shas (`merge-base --is-ancestor`), never from this counter. */\nexport interface WorktreeSyncEpoch {\n\tepoch: number;\n\tmainSha: string;\n\tpreviousMainSha?: string;\n\tlandedLaneKey?: string;\n\tlandedAt?: string;\n\tchangedPaths: string[];\n\tchangedPathsTruncated: boolean;\n}\n\n/** Live, git-derived facts about one lane. Computed fresh per call -- there is no cached copy to\n * go stale, which is the point. */\nexport interface LaneFacts {\n\tlaneKey: string;\n\tbranch: string;\n\tworktreePath: string;\n\tregistrationStatus: LaneRegistration[\"status\"];\n\t/** Lane branch tip sha; undefined when the branch no longer exists. */\n\tbranchSha?: string;\n\t/** True iff current main is an ancestor of the lane tip (`merge-base --is-ancestor`). */\n\tfresh: boolean;\n\t/** True when `status --porcelain` in the lane worktree is non-empty. */\n\tdirty: boolean;\n\trebaseInProgress: boolean;\n\taheadOfMain: number;\n\tbehindMain: number;\n\tworktreePresent: boolean;\n\t/** Undefined when the lane has no recorded owner pid. */\n\townerAlive?: boolean;\n}\n\nexport interface IntegrationLockOwner {\n\tpid: number;\n\thostname: string;\n\t/** Random acquisition identity; PID/session are diagnostic only and never authorize release. */\n\ttoken: string;\n\tsessionId?: string;\n\tlaneKey?: string;\n\tacquiredAt: string;\n}\n\nexport type IntegrationLockAcquisition =\n\t| { acquired: true; takeover: boolean; token: string }\n\t| { acquired: false; holder?: IntegrationLockOwner; holderAlive: boolean };\n\n/** One conflicted file in a sync stopped on conflicts. */\nexport interface ConflictWorklistFile {\n\tpath: string;\n\t/** Both-modified is the common case; add/add and modify/delete surface as their index states. */\n\tkind: \"both_modified\" | \"both_added\" | \"deleted_by_us\" | \"deleted_by_them\" | \"unknown\";\n\t/** True when git rerere already replayed a recorded resolution for this file -- review, not re-resolve. */\n\tresolvedByRerere: boolean;\n}\n\n/** Structured conflict worklist returned when a sync/continue stops on conflicts. */\nexport interface ConflictWorklist {\n\t/** e.g. \"2/5\" -- rebase progress (stopped step / total steps). */\n\tstep: string;\n\tstoppedAtCommit?: { sha: string; subject: string };\n\tfiles: ConflictWorklistFile[];\n}\n\nexport type BindLaneWorkerResult =\n\t| { code: \"bound\"; laneKey: string; laneId: string }\n\t| { code: \"already_bound\"; laneKey: string; laneId: string }\n\t| { code: \"binding_conflict\"; laneKey: string; boundLaneId: string }\n\t| { code: \"lane_not_found\"; message: string }\n\t| { code: \"lane_not_active\"; message: string }\n\t| { code: \"store_error\"; message: string };\n\nexport type CreateLaneResult =\n\t| { code: \"ok\"; lane: LaneRegistration }\n\t| WorktreeSyncRefusal<\n\t\t\t| \"not_a_git_repo\"\n\t\t\t| \"default_branch_unresolved\"\n\t\t\t| \"invalid_lane_key\"\n\t\t\t| \"lane_exists\"\n\t\t\t| \"max_lanes_reached\"\n\t\t\t| \"git_error\"\n\t >;\n\nexport type ReleaseLaneResult =\n\t| { code: \"released\"; laneKey: string }\n\t| WorktreeSyncRefusal<\n\t\t\t| \"not_a_git_repo\"\n\t\t\t| \"default_branch_unresolved\"\n\t\t\t| \"lane_not_found\"\n\t\t\t| \"lane_unlanded_work\"\n\t\t\t| \"lane_owner_conflict\"\n\t\t\t| \"git_error\"\n\t >;\n\nexport interface LandingTransaction {\n\tlaneKey: string;\n\tpriorMainSha: string;\n\ttestedTipSha: string;\n\tchangedPaths: string[];\n\tchangedPathsTruncated: boolean;\n\tlockToken: string;\n\tgate: \"passed\" | \"off\";\n\tstage: \"ready_to_merge\" | \"main_moved\" | \"epoch_written\" | \"audit_logged\";\n}\n\nexport interface ReconcileSummary {\n\tcode: \"reconciled\";\n\torphanedLaneKeys: string[];\n\treRegisteredLaneKeys: string[];\n\townerClearedLaneKeys: string[];\n\tstaleLockReleased: boolean;\n}\n\nexport type ReconcileResult =\n\t| ReconcileSummary\n\t| WorktreeSyncRefusal<\"not_a_git_repo\" | \"default_branch_unresolved\" | \"git_error\">;\n\nexport type SyncLaneResult =\n\t| { code: \"sync_clean\"; laneKey: string; alreadyFresh: boolean; autoContinued: number }\n\t| { code: \"sync_conflicts\"; laneKey: string; worklist: ConflictWorklist }\n\t| WorktreeSyncRefusal<\n\t\t\t| \"not_a_git_repo\"\n\t\t\t| \"default_branch_unresolved\"\n\t\t\t| \"lane_not_found\"\n\t\t\t| \"worktree_missing\"\n\t\t\t| \"lane_dirty\"\n\t\t\t| \"rebase_in_progress\"\n\t\t\t| \"git_error\"\n\t >;\n\nexport type ContinueSyncResult =\n\t| { code: \"sync_clean\"; laneKey: string; autoContinued: number }\n\t| { code: \"sync_conflicts\"; laneKey: string; worklist: ConflictWorklist }\n\t| WorktreeSyncRefusal<\n\t\t\t| \"not_a_git_repo\"\n\t\t\t| \"default_branch_unresolved\"\n\t\t\t| \"lane_not_found\"\n\t\t\t| \"worktree_missing\"\n\t\t\t| \"no_rebase_in_progress\"\n\t\t\t| \"conflict_markers_present\"\n\t\t\t| \"git_error\"\n\t >;\n\nexport type AbortSyncResult =\n\t| { code: \"ok\"; laneKey: string }\n\t| WorktreeSyncRefusal<\n\t\t\t\"not_a_git_repo\" | \"default_branch_unresolved\" | \"lane_not_found\" | \"no_rebase_in_progress\" | \"git_error\"\n\t >;\n\nexport type LandResult =\n\t| { code: \"ok\"; laneKey: string; epoch: number; mainSha: string; gate: \"passed\" | \"off\" }\n\t| WorktreeSyncRefusal<\n\t\t\t| \"not_a_git_repo\"\n\t\t\t| \"default_branch_unresolved\"\n\t\t\t| \"lane_not_found\"\n\t\t\t| \"worktree_missing\"\n\t\t\t| \"rebase_in_progress\"\n\t\t\t| \"lane_dirty\"\n\t\t\t| \"stale_lane\"\n\t\t\t| \"hub_missing\"\n\t\t\t| \"hub_dirty\"\n\t\t\t| \"gate_command_unset\"\n\t\t\t| \"gate_failed\"\n\t\t\t| \"lane_changed_during_gate\"\n\t\t\t| \"ff_failed\"\n\t\t\t| \"lock_busy\"\n\t\t\t| \"nothing_to_land\"\n\t\t\t| \"lane_owner_conflict\"\n\t\t\t| \"git_error\"\n\t >;\n\n/** One lane's full status entry: live git facts plus registry identity plus policy derivation. */\nexport interface LaneStatusEntry extends LaneFacts {\n\tgoalId?: string;\n\trequirementId?: string;\n\tboundLaneId?: string;\n\t/** Not fresh: main moved past this lane's base. Derived, never stored. */\n\tstale: boolean;\n\t/** Stale AND the active policy makes syncing mandatory NOW (G8 gates on this). */\n\tsyncRequired: boolean;\n\t/** Lane-changed files intersecting the last land's changed files (conservatively the whole\n\t * lane-changed list when the epoch's changedPaths were truncated). */\n\toverlapWithLastLand: string[];\n}\n\n/** The deterministic full picture (`status` action): everything an agent would otherwise infer\n * probabilistically from porcelain output, computed mechanically. */\nexport interface SyncStatus {\n\tcode: \"ok\";\n\tmainBranch: string;\n\tmainSha: string;\n\tepoch: number;\n\thub?: { path: string; clean: boolean };\n\tlock: { held: boolean; holder?: IntegrationLockOwner; holderAlive?: boolean };\n\tlanes: LaneStatusEntry[];\n\t/** One deterministic advisory sentence assembled from the codes above; never model-generated. */\n\tadvice?: string;\n}\n\nexport type SyncStatusResult =\n\t| SyncStatus\n\t| WorktreeSyncRefusal<\"not_a_git_repo\" | \"default_branch_unresolved\" | \"git_error\">;\n"]}
1
+ {"version":3,"file":"codes.js","sourceRoot":"","sources":["../../../src/core/worktree-sync/codes.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;gGACgG;AAChG,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAE3C,6DAA6D;AAC7D,MAAM,CAAC,MAAM,kBAAkB,GAAG,QAAQ,CAAC","sourcesContent":["/**\n * Worktree-sync SSOT for tagged result codes and shared record types.\n *\n * Every worktree-sync operation reports its outcome through one of these string-literal codes in\n * a typed result -- callers branch on `code`, NEVER on message/stderr substrings. Git stderr is\n * carried alongside as evidence for humans, not as a branch condition.\n */\n\n/** Cap on `WorktreeSyncEpoch.changedPaths`; beyond it the list is truncated and overlap checks\n * treat the land as conservatively overlapping EVERYTHING (deterministic, never optimistic). */\nexport const EPOCH_CHANGED_PATHS_CAP = 500;\n\n/** Branch namespace for lane branches: `pi/wt/<laneKey>`. */\nexport const LANE_BRANCH_PREFIX = \"pi/wt/\";\n\nexport type WorktreeSyncCode =\n\t| \"ok\"\n\t| \"disabled\"\n\t| \"not_a_git_repo\"\n\t| \"default_branch_unresolved\"\n\t| \"hub_missing\"\n\t| \"invalid_lane_key\"\n\t| \"lane_exists\"\n\t| \"lane_not_found\"\n\t| \"max_lanes_reached\"\n\t| \"lane_dirty\"\n\t| \"hub_dirty\"\n\t| \"stale_lane\"\n\t| \"sync_required\"\n\t| \"sync_clean\"\n\t| \"sync_conflicts\"\n\t| \"rebase_in_progress\"\n\t| \"no_rebase_in_progress\"\n\t| \"conflict_markers_present\"\n\t| \"gate_command_unset\"\n\t| \"gate_failed\"\n\t| \"lane_changed_during_gate\"\n\t| \"ff_failed\"\n\t| \"lock_busy\"\n\t| \"lock_takeover\"\n\t| \"nothing_to_land\"\n\t| \"main_mutation_refused\"\n\t| \"lane_unlanded_work\"\n\t| \"worktree_missing\"\n\t| \"released\"\n\t| \"reconciled\"\n\t| \"git_error\"\n\t| \"role_forbidden\"\n\t| \"path_outside_lane\"\n\t| \"lane_owner_conflict\";\n\n/**\n * A refusal/failure outcome. `message` is deterministic text assembled from facts (safe to show a\n * model verbatim); `gitStderr` is bounded raw evidence; `paths` names offending files where the\n * refusal is about specific files (dirty files, conflict markers); `holder` identifies the\n * integration-lock holder on `lock_busy`.\n */\nexport interface WorktreeSyncRefusal<C extends WorktreeSyncCode = WorktreeSyncCode> {\n\tcode: C;\n\tmessage: string;\n\tgitStderr?: string;\n\tpaths?: string[];\n\tholder?: IntegrationLockOwner;\n}\n\n/** Staleness-propagation policy (D9). `on_land_mandatory` is the default: every land marks every\n * other active lane sync_required. `overlap_mandatory` requires it only on changed-file overlap.\n * `land_time_only` keeps staleness advisory until the land gate (G3 always enforces). */\nexport type WorktreeSyncPolicy = \"on_land_mandatory\" | \"overlap_mandatory\" | \"land_time_only\";\n\n/** One lane registration record (`lanes/<laneKey>.json`). Identity/binding fields ONLY -- git\n * truths (freshness, dirtiness, ahead/behind) are always re-derived live, never stored here. */\nexport interface LaneRegistration {\n\tlaneKey: string;\n\tbranch: string;\n\tworktreePath: string;\n\tstatus: \"active\" | \"released\" | \"orphaned\";\n\tcreatedAt: string;\n\tupdatedAt: string;\n\tgoalId?: string;\n\trequirementId?: string;\n\t/** Host `LaneRecord.laneId` after dispatch correlation (tmux/in-process worker binding). */\n\tboundLaneId?: string;\n\townerPid?: number;\n\townerSessionId?: string;\n}\n\n/** `epoch.json` -- the integration epoch. `epoch` is monotonic messaging/audit sugar; correctness\n * always derives from git shas (`merge-base --is-ancestor`), never from this counter. */\nexport interface WorktreeSyncEpoch {\n\tepoch: number;\n\tmainSha: string;\n\tpreviousMainSha?: string;\n\tlandedLaneKey?: string;\n\tlandedAt?: string;\n\tchangedPaths: string[];\n\tchangedPathsTruncated: boolean;\n}\n\n/** Live, git-derived facts about one lane. Computed fresh per call -- there is no cached copy to\n * go stale, which is the point. */\nexport interface LaneFacts {\n\tlaneKey: string;\n\tbranch: string;\n\tworktreePath: string;\n\tregistrationStatus: LaneRegistration[\"status\"];\n\t/** Lane branch tip sha; undefined when the branch no longer exists. */\n\tbranchSha?: string;\n\t/** True iff current main is an ancestor of the lane tip (`merge-base --is-ancestor`). */\n\tfresh: boolean;\n\t/** True when `status --porcelain` in the lane worktree is non-empty. */\n\tdirty: boolean;\n\trebaseInProgress: boolean;\n\taheadOfMain: number;\n\tbehindMain: number;\n\tworktreePresent: boolean;\n\t/** Undefined when the lane has no recorded owner pid. */\n\townerAlive?: boolean;\n}\n\nexport interface IntegrationLockOwner {\n\tpid: number;\n\thostname: string;\n\t/** Random acquisition identity; PID/session are diagnostic only and never authorize release. */\n\ttoken: string;\n\tsessionId?: string;\n\tlaneKey?: string;\n\tacquiredAt: string;\n}\n\nexport type IntegrationLockAcquisition =\n\t| { acquired: true; takeover: boolean; token: string }\n\t| { acquired: false; holder?: IntegrationLockOwner; holderAlive: boolean };\n\n/** One conflicted file in a sync stopped on conflicts. */\nexport interface ConflictWorklistFile {\n\tpath: string;\n\t/** Both-modified is the common case; add/add and modify/delete surface as their index states. */\n\tkind: \"both_modified\" | \"both_added\" | \"deleted_by_us\" | \"deleted_by_them\" | \"unknown\";\n\t/** True when git rerere already replayed a recorded resolution for this file -- review, not re-resolve. */\n\tresolvedByRerere: boolean;\n}\n\n/** Structured conflict worklist returned when a sync/continue stops on conflicts. */\nexport interface ConflictWorklist {\n\t/** e.g. \"2/5\" -- rebase progress (stopped step / total steps). */\n\tstep: string;\n\tstoppedAtCommit?: { sha: string; subject: string };\n\tfiles: ConflictWorklistFile[];\n}\n\nexport type BindLaneWorkerResult =\n\t| { code: \"bound\"; laneKey: string; laneId: string }\n\t| { code: \"already_bound\"; laneKey: string; laneId: string }\n\t| { code: \"binding_conflict\"; laneKey: string; boundLaneId: string }\n\t| { code: \"lane_not_found\"; message: string }\n\t| { code: \"lane_not_active\"; message: string }\n\t| { code: \"store_error\"; message: string };\n\nexport type CreateLaneResult =\n\t| { code: \"ok\"; lane: LaneRegistration }\n\t| WorktreeSyncRefusal<\n\t\t\t| \"not_a_git_repo\"\n\t\t\t| \"default_branch_unresolved\"\n\t\t\t| \"invalid_lane_key\"\n\t\t\t| \"lane_exists\"\n\t\t\t| \"max_lanes_reached\"\n\t\t\t| \"git_error\"\n\t >;\n\nexport type ReleaseLaneResult =\n\t| { code: \"released\"; laneKey: string }\n\t| WorktreeSyncRefusal<\n\t\t\t| \"not_a_git_repo\"\n\t\t\t| \"default_branch_unresolved\"\n\t\t\t| \"lane_not_found\"\n\t\t\t| \"lane_unlanded_work\"\n\t\t\t| \"lane_owner_conflict\"\n\t\t\t| \"git_error\"\n\t >;\n\nexport interface LandingTransaction {\n\tlaneKey: string;\n\tpriorMainSha: string;\n\ttestedTipSha: string;\n\tchangedPaths: string[];\n\tchangedPathsTruncated: boolean;\n\tlockToken: string;\n\tgate: \"passed\" | \"off\";\n\tstage: \"ready_to_merge\" | \"main_moved\" | \"epoch_written\" | \"audit_logged\";\n}\n\nexport interface ReconcileSummary {\n\tcode: \"reconciled\";\n\torphanedLaneKeys: string[];\n\treRegisteredLaneKeys: string[];\n\townerClearedLaneKeys: string[];\n\tstaleLockReleased: boolean;\n}\n\nexport type ReconcileResult =\n\t| ReconcileSummary\n\t| WorktreeSyncRefusal<\"not_a_git_repo\" | \"default_branch_unresolved\" | \"git_error\">;\n\nexport type SyncLaneResult =\n\t| { code: \"sync_clean\"; laneKey: string; alreadyFresh: boolean; autoContinued: number }\n\t| { code: \"sync_conflicts\"; laneKey: string; worklist: ConflictWorklist }\n\t| WorktreeSyncRefusal<\n\t\t\t| \"not_a_git_repo\"\n\t\t\t| \"default_branch_unresolved\"\n\t\t\t| \"lane_not_found\"\n\t\t\t| \"worktree_missing\"\n\t\t\t| \"lane_dirty\"\n\t\t\t| \"rebase_in_progress\"\n\t\t\t| \"git_error\"\n\t >;\n\nexport type ContinueSyncResult =\n\t| { code: \"sync_clean\"; laneKey: string; autoContinued: number }\n\t| { code: \"sync_conflicts\"; laneKey: string; worklist: ConflictWorklist }\n\t| WorktreeSyncRefusal<\n\t\t\t| \"not_a_git_repo\"\n\t\t\t| \"default_branch_unresolved\"\n\t\t\t| \"lane_not_found\"\n\t\t\t| \"worktree_missing\"\n\t\t\t| \"no_rebase_in_progress\"\n\t\t\t| \"conflict_markers_present\"\n\t\t\t| \"git_error\"\n\t >;\n\nexport type AbortSyncResult =\n\t| { code: \"ok\"; laneKey: string }\n\t| WorktreeSyncRefusal<\n\t\t\t\"not_a_git_repo\" | \"default_branch_unresolved\" | \"lane_not_found\" | \"no_rebase_in_progress\" | \"git_error\"\n\t >;\n\nexport type LandResult =\n\t| { code: \"ok\"; laneKey: string; epoch: number; mainSha: string; gate: \"passed\" | \"off\" }\n\t| WorktreeSyncRefusal<\n\t\t\t| \"not_a_git_repo\"\n\t\t\t| \"default_branch_unresolved\"\n\t\t\t| \"lane_not_found\"\n\t\t\t| \"worktree_missing\"\n\t\t\t| \"rebase_in_progress\"\n\t\t\t| \"lane_dirty\"\n\t\t\t| \"stale_lane\"\n\t\t\t| \"hub_missing\"\n\t\t\t| \"hub_dirty\"\n\t\t\t| \"gate_command_unset\"\n\t\t\t| \"gate_failed\"\n\t\t\t| \"lane_changed_during_gate\"\n\t\t\t| \"ff_failed\"\n\t\t\t| \"lock_busy\"\n\t\t\t| \"nothing_to_land\"\n\t\t\t| \"lane_owner_conflict\"\n\t\t\t| \"git_error\"\n\t >;\n\n/** One lane's full status entry: live git facts plus registry identity plus policy derivation. */\nexport interface LaneStatusEntry extends LaneFacts {\n\tgoalId?: string;\n\trequirementId?: string;\n\tboundLaneId?: string;\n\t/** Not fresh: main moved past this lane's base. Derived, never stored. */\n\tstale: boolean;\n\t/** Stale AND the active policy makes syncing mandatory NOW (G8 gates on this). */\n\tsyncRequired: boolean;\n\t/** Lane-changed files intersecting the last land's changed files (conservatively the whole\n\t * lane-changed list when the epoch's changedPaths were truncated). */\n\toverlapWithLastLand: string[];\n}\n\n/** The deterministic full picture (`status` action): everything an agent would otherwise infer\n * probabilistically from porcelain output, computed mechanically. */\nexport interface SyncStatus {\n\tcode: \"ok\";\n\tmainBranch: string;\n\tmainSha: string;\n\tepoch: number;\n\thub?: { path: string; clean: boolean };\n\tlock: { held: boolean; holder?: IntegrationLockOwner; holderAlive?: boolean };\n\tlanes: LaneStatusEntry[];\n\t/** One deterministic advisory sentence assembled from the codes above; never model-generated. */\n\tadvice?: string;\n}\n\nexport type SyncStatusResult =\n\t| SyncStatus\n\t| WorktreeSyncRefusal<\"not_a_git_repo\" | \"default_branch_unresolved\" | \"git_error\">;\n"]}
@@ -4,9 +4,10 @@
4
4
  * write / bash) with {@link WorktreeLaneGate.checkMutation}; a lane that the active policy marks
5
5
  * sync_required fails closed with the exact recovery step until it rebases main.
6
6
  *
7
- * Honesty boundary (unchanged from the tmux trust model): this is HARD for pi children -- the
8
- * wrapper lives under the tool layer, not in the prompt -- and cooperative-only for foreign
9
- * CLIs, whose backstop is the land CAS (G3): stale work simply cannot land.
7
+ * Honesty boundary: edit/write checks are structural for Pi children because the wrapper lives
8
+ * under the tool layer. Bash remains a deliberate host-trust boundary; this gate only rejects
9
+ * integration-sensitive Git forms and never claims to sandbox arbitrary process code. Foreign
10
+ * CLIs stay cooperative-only, with the land CAS (G3) as their backstop.
10
11
  *
11
12
  * Determinism: the gate re-derives from git only when the epoch file actually changed (mtime
12
13
  * fence) or while blocked; verdicts in between are cached. No polling, no timers.
@@ -44,11 +45,6 @@ export interface WorktreeLaneGateConfig {
44
45
  laneKey: string;
45
46
  engineDeps: () => WorktreeSyncEngineDeps;
46
47
  policy: () => WorktreeSyncPolicy;
47
- /** Worker launches use a hard shell envelope: only lane-safe Git/WIP commands and the owner-configured
48
- * exact gate command may pass through bash. Interactive lane sessions retain the legacy cooperative
49
- * command surface while the typed worktree_sync actions are used for hard worker mutations. */
50
- hardShell?: boolean;
51
- trustedGateCommand?: () => string | undefined;
52
48
  }
53
49
  export type LaneMutationCheck = {
54
50
  allowed: true;
@@ -1 +1 @@
1
- {"version":3,"file":"lane-gate.d.ts","sourceRoot":"","sources":["../../../src/core/worktree-sync/lane-gate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAyD,KAAK,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAGrH,MAAM,MAAM,eAAe,GACxB;IAAE,OAAO,EAAE,SAAS,CAAA;CAAE,GACtB;IAAE,OAAO,EAAE,iCAAiC,CAAA;CAAE,GAC9C;IAAE,OAAO,EAAE,uBAAuB,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAkBxD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,eAAe,CAiF5F;AA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CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CA0F3G;CACD"}
@@ -4,9 +4,10 @@
4
4
  * write / bash) with {@link WorktreeLaneGate.checkMutation}; a lane that the active policy marks
5
5
  * sync_required fails closed with the exact recovery step until it rebases main.
6
6
  *
7
- * Honesty boundary (unchanged from the tmux trust model): this is HARD for pi children -- the
8
- * wrapper lives under the tool layer, not in the prompt -- and cooperative-only for foreign
9
- * CLIs, whose backstop is the land CAS (G3): stale work simply cannot land.
7
+ * Honesty boundary: edit/write checks are structural for Pi children because the wrapper lives
8
+ * under the tool layer. Bash remains a deliberate host-trust boundary; this gate only rejects
9
+ * integration-sensitive Git forms and never claims to sandbox arbitrary process code. Foreign
10
+ * CLIs stay cooperative-only, with the land CAS (G3) as their backstop.
10
11
  *
11
12
  * Determinism: the gate re-derives from git only when the epoch file actually changed (mtime
12
13
  * fence) or while blocked; verdicts in between are cached. No polling, no timers.
@@ -184,24 +185,6 @@ async function changedPaths(deps, cwd, base, ref) {
184
185
  .map((path) => path.trim())
185
186
  .filter(Boolean));
186
187
  }
187
- function hardShellCommandAllowed(command, mainBranch, trustedGateCommand) {
188
- const trimmed = command.trim();
189
- if (trustedGateCommand && trimmed === trustedGateCommand.trim())
190
- return true;
191
- if (!/^git(?:\s|$)/u.test(trimmed))
192
- return false;
193
- const verdict = classifyLaneBashCommand(trimmed, mainBranch);
194
- if (verdict.verdict === "main_mutation_refused")
195
- return false;
196
- const tokens = trimmed.split(/\s+/u);
197
- const subcommand = tokens[1] ?? "";
198
- if (!SYNC_SAFE_GIT_SUBCOMMANDS.has(subcommand) && subcommand !== "commit")
199
- return false;
200
- // Git path operands must not escape the lane checkout. The typed worktree
201
- // actions are the authoritative route for path-sensitive add/diff operations;
202
- // this final check prevents the common absolute/parent escape in the shell floor.
203
- return !tokens.slice(2).some((token) => token.startsWith("/") || token.startsWith("..") || token.includes("/../"));
204
- }
205
188
  /**
206
189
  * The G8 gate object RuntimeBuilder holds per lane-bound session. `checkMutation` is called by
207
190
  * the wrapped edit/write/bash tools before every mutating execution.
@@ -237,24 +220,9 @@ export class WorktreeLaneGate {
237
220
  async checkMutation(toolName, bashCommand, targetPath) {
238
221
  const ctx = await this.resolveContext();
239
222
  // No repo context (deleted repo, engine failure): fail OPEN for plain tools -- the land
240
- // CAS still holds -- but the G10 bash rules below never depend on repo state.
223
+ // CAS still holds -- but the integration-sensitive Git rules below never depend on repo state.
241
224
  const mainBranch = ctx?.mainBranch ?? "main";
242
- if (this.config.hardShell && !ctx) {
243
- return {
244
- allowed: false,
245
- code: "lane_state_unavailable",
246
- message: "worktree-sync: lane state is unavailable; hard worker mutations fail closed",
247
- };
248
- }
249
225
  if (toolName === "bash" && bashCommand !== undefined) {
250
- if (this.config.hardShell &&
251
- !hardShellCommandAllowed(bashCommand, mainBranch, this.config.trustedGateCommand?.())) {
252
- return {
253
- allowed: false,
254
- code: "main_mutation_refused",
255
- message: "worktree-sync: unrestricted bash is unavailable in a hard worker lane; use typed worktree_sync actions",
256
- };
257
- }
258
226
  const verdict = classifyLaneBashCommand(bashCommand, mainBranch);
259
227
  if (verdict.verdict === "main_mutation_refused") {
260
228
  return { allowed: false, code: "main_mutation_refused", message: `worktree-sync: ${verdict.reason}` };
@@ -284,26 +252,12 @@ export class WorktreeLaneGate {
284
252
  const deps = this.config.engineDeps();
285
253
  const lane = await readLane(ctx.paths, this.config.laneKey);
286
254
  if (!lane || lane.status !== "active") {
287
- if (this.config.hardShell) {
288
- return {
289
- allowed: false,
290
- code: "lane_state_unavailable",
291
- message: "worktree-sync: hard worker lane registration is missing or inactive; reconcile before mutating",
292
- };
293
- }
294
255
  this._cachedAllowed = true;
295
256
  return { allowed: true };
296
257
  }
297
258
  // Re-derive main tip: the cached ctx pins the sha from session start.
298
259
  const fresh = await resolveRepoContext(deps);
299
260
  if ("code" in fresh) {
300
- if (this.config.hardShell) {
301
- return {
302
- allowed: false,
303
- code: "lane_state_unavailable",
304
- message: "worktree-sync: Git context is unavailable; hard worker mutation refused",
305
- };
306
- }
307
261
  this._cachedAllowed = true;
308
262
  return { allowed: true };
309
263
  }
@@ -1 +1 @@
1
- {"version":3,"file":"lane-gate.js","sourceRoot":"","sources":["../../../src/core/worktree-sync/lane-gate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAElE,OAAO,EAAE,eAAe,EAAoB,kBAAkB,EAA+B,MAAM,iBAAiB,CAAC;AACrH,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAOtC,MAAM,yBAAyB,GAAG,IAAI,GAAG,CAAC;IACzC,QAAQ;IACR,MAAM;IACN,KAAK;IACL,MAAM;IACN,KAAK;IACL,QAAQ;IACR,OAAO;IACP,WAAW;IACX,UAAU;IACV,OAAO;IACP,MAAM;CACN,CAAC,CAAC;AAEH,MAAM,6BAA6B,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,CAAC,CAAC,CAAC;AAEtH;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,uBAAuB,CAAC,OAAe,EAAE,UAAkB;IAC1E,2EAA2E;IAC3E,wEAAwE;IACxE,2DAA2D;IAC3D,IAAI,oBAAoB,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QACxC,OAAO;YACN,OAAO,EAAE,uBAAuB;YAChC,MAAM,EAAE,6EAA6E;SACrF,CAAC;IACH,CAAC;IACD,IAAI,oBAAoB,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QACxC,OAAO;YACN,OAAO,EAAE,uBAAuB;YAChC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F,yFAAyF;gBACzF,0FAA0F;SAC3F,CAAC;IACH,CAAC;CACD","sourcesContent":["/**\n * Lane gate: G8/G10 enforcement for a LANE-BOUND `pi` session (launched with\n * `PI_WORKTREE_LANE=<key>`). RuntimeBuilder wraps the session's file-mutation tools (edit /\n * write / bash) with {@link WorktreeLaneGate.checkMutation}; a lane that the active policy marks\n * sync_required fails closed with the exact recovery step until it rebases main.\n *\n * Honesty boundary (unchanged from the tmux trust model): this is HARD for pi children -- the\n * wrapper lives under the tool layer, not in the prompt -- and cooperative-only for foreign\n * CLIs, whose backstop is the land CAS (G3): stale work simply cannot land.\n *\n * Determinism: the gate re-derives from git only when the epoch file actually changed (mtime\n * fence) or while blocked; verdicts in between are cached. No polling, no timers.\n */\n\nimport { existsSync, realpathSync, statSync } from \"node:fs\";\nimport { basename, dirname, join, resolve, sep } from \"node:path\";\nimport type { WorktreeSyncPolicy } from \"./codes.ts\";\nimport { deriveLaneFacts, type RepoContext, resolveRepoContext, type WorktreeSyncEngineDeps } from \"./git-engine.ts\";\nimport { readLane } from \"./store.ts\";\n\nexport type LaneBashVerdict =\n\t| { verdict: \"allowed\" }\n\t| { verdict: \"allowed_even_when_sync_required\" }\n\t| { verdict: \"main_mutation_refused\"; reason: string };\n\nconst SYNC_SAFE_GIT_SUBCOMMANDS = new Set([\n\t\"status\",\n\t\"diff\",\n\t\"log\",\n\t\"show\",\n\t\"add\",\n\t\"commit\",\n\t\"stash\",\n\t\"rev-parse\",\n\t\"ls-files\",\n\t\"blame\",\n\t\"grep\",\n]);\n\nconst MAIN_MUTATING_GIT_SUBCOMMANDS = new Set([\"merge\", \"rebase\", \"reset\", \"commit\", \"branch\", \"update-ref\", \"push\"]);\n\n/**\n * Classify one bash command line for a lane-bound session (G10 + the sync_required allowlist).\n * Tokenization is whitespace-naive by design -- deterministic and reviewable; shell-quoting\n * tricks can evade it, which is the documented cooperative boundary (the land CAS cannot be\n * evaded). Command POSITION still matters: `git` only begins an invocation at the start of the\n * command or immediately after a shell separator (`&&`, `||`, `;`, `|`) -- a bare `git` token\n * elsewhere (e.g. as a plain argument to `echo`) is not an invocation. Rules:\n * - `git push` anywhere: refused (main moves only through the land gate; pushing is owner-only).\n * - `git -C <path>` / `--git-dir` combined with a mutating subcommand: refused (escaping the\n * lane worktree to operate on another checkout, e.g. the hub).\n * - `git branch -f/-M/-D <main>` / `git update-ref refs/heads/<main>`: refused.\n * - Everything else: allowed; a read/commit-shaped git subcommand additionally stays allowed\n * while the lane is sync_required (committing WIP is the prescribed step BEFORE syncing).\n */\nexport function classifyLaneBashCommand(command: string, mainBranch: string): LaneBashVerdict {\n\t// This classifier is defense-in-depth, not a shell parser. Refuse compound\n\t// syntax before any segment can return an allow verdict; otherwise `git\n\t// status; git push` is approved by the first safe segment.\n\tif (/[|;&<>$`(){}\\n\\r]/u.test(command)) {\n\t\treturn {\n\t\t\tverdict: \"main_mutation_refused\",\n\t\t\treason: \"compound shell syntax is refused in a lane; use typed worktree_sync actions\",\n\t\t};\n\t}\n\tif (/^\\s*[\"']git[\"']\\s/u.test(command)) {\n\t\treturn {\n\t\t\tverdict: \"main_mutation_refused\",\n\t\t\treason: \"quoted command names are refused in a lane; use the typed Git actions\",\n\t\t};\n\t}\n\tconst segments = [command];\n\tlet allowedWhenSyncRequired = false;\n\tfor (const segment of segments) {\n\t\tconst tokens = segment.trim().split(/\\s+/).filter(Boolean);\n\t\tif (tokens[0] !== \"git\") continue;\n\t\tlet j = 1;\n\t\tlet escapesWorktree = false;\n\t\t// Skip git global options to find the subcommand; -C/--git-dir mark checkout escape.\n\t\twhile (j < tokens.length) {\n\t\t\tconst token = tokens[j] ?? \"\";\n\t\t\tif (token === \"-C\" || token === \"--git-dir\" || token === \"--work-tree\") {\n\t\t\t\tescapesWorktree = true;\n\t\t\t\tj += 2;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (token.startsWith(\"-C\") && token !== \"-C\") {\n\t\t\t\tescapesWorktree = true;\n\t\t\t\tj += 1;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (token.startsWith(\"--git-dir=\") || token.startsWith(\"--work-tree=\")) {\n\t\t\t\tescapesWorktree = true;\n\t\t\t\tj += 1;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (token.startsWith(\"-\")) {\n\t\t\t\tj += 1;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tconst subcommand = tokens[j] ?? \"\";\n\t\tconst rest = tokens.slice(j + 1);\n\t\tif (subcommand === \"push\") {\n\t\t\treturn {\n\t\t\t\tverdict: \"main_mutation_refused\",\n\t\t\t\treason:\n\t\t\t\t\t\"git push is refused in a lane session; landing is the only integration path and pushing stays an owner action\",\n\t\t\t};\n\t\t}\n\t\tif (escapesWorktree && MAIN_MUTATING_GIT_SUBCOMMANDS.has(subcommand)) {\n\t\t\treturn {\n\t\t\t\tverdict: \"main_mutation_refused\",\n\t\t\t\treason: `git -C/--git-dir with '${subcommand}' escapes the lane worktree; operate only on this lane (G10)`,\n\t\t\t};\n\t\t}\n\t\tif (\n\t\t\tsubcommand === \"branch\" &&\n\t\t\trest.some((token) => /^(?:-f|--force|-M|-m|-D|-d)$/.test(token)) &&\n\t\t\trest.includes(mainBranch)\n\t\t) {\n\t\t\treturn {\n\t\t\t\tverdict: \"main_mutation_refused\",\n\t\t\t\treason: `git branch may not move/delete '${mainBranch}' from a lane; main moves only through the land gate (G10)`,\n\t\t\t};\n\t\t}\n\t\tif (subcommand === \"update-ref\" && rest.some((token) => token === `refs/heads/${mainBranch}`)) {\n\t\t\treturn {\n\t\t\t\tverdict: \"main_mutation_refused\",\n\t\t\t\treason: `git update-ref may not touch refs/heads/${mainBranch} from a lane (G10)`,\n\t\t\t};\n\t\t}\n\t\tif (SYNC_SAFE_GIT_SUBCOMMANDS.has(subcommand)) allowedWhenSyncRequired = true;\n\t}\n\treturn allowedWhenSyncRequired ? { verdict: \"allowed_even_when_sync_required\" } : { verdict: \"allowed\" };\n}\n\n/** Symlink-safe resolution of a path that may not exist yet: realpath the NEAREST EXISTING\n * ancestor, then re-append the not-yet-existing tail literally (a not-yet-created file's own\n * missing final component can never itself be a symlink escape). */\nfunction resolveSymlinkSafe(targetPath: string): string {\n\tif (existsSync(targetPath)) {\n\t\ttry {\n\t\t\treturn realpathSync(targetPath);\n\t\t} catch {\n\t\t\treturn targetPath;\n\t\t}\n\t}\n\tconst tail: string[] = [basename(targetPath)];\n\tlet ancestor = dirname(targetPath);\n\twhile (!existsSync(ancestor)) {\n\t\tconst parent = dirname(ancestor);\n\t\tif (parent === ancestor) break; // reached the filesystem root without finding one\n\t\ttail.unshift(basename(ancestor));\n\t\tancestor = parent;\n\t}\n\tlet realAncestor: string;\n\ttry {\n\t\trealAncestor = realpathSync(ancestor);\n\t} catch {\n\t\trealAncestor = ancestor;\n\t}\n\treturn join(realAncestor, ...tail);\n}\n\n/** Symlink-safe containment check (G-path): does `targetPath` resolve inside `worktreePath`? */\nexport function isPathOutsideLane(targetPath: string, worktreePath: string): boolean {\n\tlet realRoot: string;\n\ttry {\n\t\trealRoot = realpathSync(worktreePath);\n\t} catch {\n\t\trealRoot = worktreePath;\n\t}\n\tconst resolvedTarget = resolveSymlinkSafe(targetPath);\n\treturn resolvedTarget !== realRoot && !resolvedTarget.startsWith(realRoot + sep);\n}\n\n/** Resolve a user-supplied relative lane path and reject symlink/parent escapes. */\nexport function resolveLaneMutationPath(worktreePath: string, candidate: string): string | undefined {\n\tconst target = resolve(worktreePath, candidate);\n\treturn isPathOutsideLane(target, worktreePath) ? undefined : target;\n}\n\nexport interface WorktreeLaneGateConfig {\n\tlaneKey: string;\n\tengineDeps: () => WorktreeSyncEngineDeps;\n\tpolicy: () => WorktreeSyncPolicy;\n\t/** Worker launches use a hard shell envelope: only lane-safe Git/WIP commands and the owner-configured\n\t * exact gate command may pass through bash. Interactive lane sessions retain the legacy cooperative\n\t * command surface while the typed worktree_sync actions are used for hard worker mutations. */\n\thardShell?: boolean;\n\ttrustedGateCommand?: () => string | undefined;\n}\n\nexport type LaneMutationCheck = { allowed: true } | { allowed: false; code: string; message: string };\n\nasync function changedPaths(\n\tdeps: WorktreeSyncEngineDeps,\n\tcwd: string,\n\tbase: string,\n\tref: string,\n): Promise<Set<string> | undefined> {\n\tconst result = await deps.exec(\"git\", [\"diff\", \"--name-only\", `${base}..${ref}`, \"--\"], {\n\t\tcwd,\n\t\ttimeout: 60_000,\n\t\tmaxBuffer: 1024 * 1024,\n\t});\n\tif (result.code !== 0) return undefined;\n\treturn new Set(\n\t\tresult.stdout\n\t\t\t.split(/\\r?\\n/u)\n\t\t\t.map((path) => path.trim())\n\t\t\t.filter(Boolean),\n\t);\n}\n\nfunction hardShellCommandAllowed(command: string, mainBranch: string, trustedGateCommand?: string): boolean {\n\tconst trimmed = command.trim();\n\tif (trustedGateCommand && trimmed === trustedGateCommand.trim()) return true;\n\tif (!/^git(?:\\s|$)/u.test(trimmed)) return false;\n\tconst verdict = classifyLaneBashCommand(trimmed, mainBranch);\n\tif (verdict.verdict === \"main_mutation_refused\") return false;\n\tconst tokens = trimmed.split(/\\s+/u);\n\tconst subcommand = tokens[1] ?? \"\";\n\tif (!SYNC_SAFE_GIT_SUBCOMMANDS.has(subcommand) && subcommand !== \"commit\") return false;\n\t// Git path operands must not escape the lane checkout. The typed worktree\n\t// actions are the authoritative route for path-sensitive add/diff operations;\n\t// this final check prevents the common absolute/parent escape in the shell floor.\n\treturn !tokens.slice(2).some((token) => token.startsWith(\"/\") || token.startsWith(\"..\") || token.includes(\"/../\"));\n}\n\n/**\n * The G8 gate object RuntimeBuilder holds per lane-bound session. `checkMutation` is called by\n * the wrapped edit/write/bash tools before every mutating execution.\n */\nexport class WorktreeLaneGate {\n\tprivate readonly config: WorktreeLaneGateConfig;\n\tprivate _ctx: RepoContext | undefined;\n\tprivate _epochFileMtimeMs: number | undefined;\n\tprivate _cachedAllowed = false;\n\n\tconstructor(config: WorktreeLaneGateConfig) {\n\t\tthis.config = config;\n\t}\n\n\tprivate async resolveContext(): Promise<RepoContext | undefined> {\n\t\tif (this._ctx) return this._ctx;\n\t\tconst ctx = await resolveRepoContext(this.config.engineDeps());\n\t\tif (\"code\" in ctx) return undefined;\n\t\tthis._ctx = ctx;\n\t\treturn ctx;\n\t}\n\n\t/** Cheap fence: has the epoch file changed since the last allowed verdict? */\n\tprivate epochChanged(ctx: RepoContext): boolean {\n\t\tlet mtimeMs: number | undefined;\n\t\ttry {\n\t\t\tmtimeMs = statSync(ctx.paths.epochFile).mtimeMs;\n\t\t} catch {\n\t\t\tmtimeMs = undefined;\n\t\t}\n\t\tif (mtimeMs === this._epochFileMtimeMs) return false;\n\t\tthis._epochFileMtimeMs = mtimeMs;\n\t\treturn true;\n\t}\n\n\tasync checkMutation(toolName: string, bashCommand?: string, targetPath?: string): Promise<LaneMutationCheck> {\n\t\tconst ctx = await this.resolveContext();\n\t\t// No repo context (deleted repo, engine failure): fail OPEN for plain tools -- the land\n\t\t// CAS still holds -- but the G10 bash rules below never depend on repo state.\n\t\tconst mainBranch = ctx?.mainBranch ?? \"main\";\n\t\tif (this.config.hardShell && !ctx) {\n\t\t\treturn {\n\t\t\t\tallowed: false,\n\t\t\t\tcode: \"lane_state_unavailable\",\n\t\t\t\tmessage: \"worktree-sync: lane state is unavailable; hard worker mutations fail closed\",\n\t\t\t};\n\t\t}\n\n\t\tif (toolName === \"bash\" && bashCommand !== undefined) {\n\t\t\tif (\n\t\t\t\tthis.config.hardShell &&\n\t\t\t\t!hardShellCommandAllowed(bashCommand, mainBranch, this.config.trustedGateCommand?.())\n\t\t\t) {\n\t\t\t\treturn {\n\t\t\t\t\tallowed: false,\n\t\t\t\t\tcode: \"main_mutation_refused\",\n\t\t\t\t\tmessage:\n\t\t\t\t\t\t\"worktree-sync: unrestricted bash is unavailable in a hard worker lane; use typed worktree_sync actions\",\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst verdict = classifyLaneBashCommand(bashCommand, mainBranch);\n\t\t\tif (verdict.verdict === \"main_mutation_refused\") {\n\t\t\t\treturn { allowed: false, code: \"main_mutation_refused\", message: `worktree-sync: ${verdict.reason}` };\n\t\t\t}\n\t\t\tif (verdict.verdict === \"allowed_even_when_sync_required\") return { allowed: true };\n\t\t}\n\t\tif (!ctx) return { allowed: true };\n\n\t\t// G-path: an edit/write target must resolve INSIDE this lane's worktree (symlink-safe),\n\t\t// checked BEFORE the staleness cache so a cached \"allowed\" verdict never short-circuits past\n\t\t// it. No active lane record: existing fail-open stands (mirrors the readLane check below).\n\t\tif ((toolName === \"edit\" || toolName === \"write\") && targetPath !== undefined) {\n\t\t\tconst laneForPath = await readLane(ctx.paths, this.config.laneKey);\n\t\t\tif (laneForPath?.status === \"active\" && isPathOutsideLane(targetPath, laneForPath.worktreePath)) {\n\t\t\t\treturn {\n\t\t\t\t\tallowed: false,\n\t\t\t\t\tcode: \"path_outside_lane\",\n\t\t\t\t\tmessage: `worktree-sync: '${targetPath}' resolves outside lane '${this.config.laneKey}' worktree (${laneForPath.worktreePath}); edit/write only inside your lane checkout`,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\t// G8: sync_required fails mutations closed. Re-derive only when the epoch moved or while\n\t\t// blocked (a successful sync clears the block on the very next check).\n\t\tif (this._cachedAllowed && !this.epochChanged(ctx)) return { allowed: true };\n\n\t\tconst deps = this.config.engineDeps();\n\t\tconst lane = await readLane(ctx.paths, this.config.laneKey);\n\t\tif (!lane || lane.status !== \"active\") {\n\t\t\tif (this.config.hardShell) {\n\t\t\t\treturn {\n\t\t\t\t\tallowed: false,\n\t\t\t\t\tcode: \"lane_state_unavailable\",\n\t\t\t\t\tmessage:\n\t\t\t\t\t\t\"worktree-sync: hard worker lane registration is missing or inactive; reconcile before mutating\",\n\t\t\t\t};\n\t\t\t}\n\t\t\tthis._cachedAllowed = true;\n\t\t\treturn { allowed: true };\n\t\t}\n\t\t// Re-derive main tip: the cached ctx pins the sha from session start.\n\t\tconst fresh = await resolveRepoContext(deps);\n\t\tif (\"code\" in fresh) {\n\t\t\tif (this.config.hardShell) {\n\t\t\t\treturn {\n\t\t\t\t\tallowed: false,\n\t\t\t\t\tcode: \"lane_state_unavailable\",\n\t\t\t\t\tmessage: \"worktree-sync: Git context is unavailable; hard worker mutation refused\",\n\t\t\t\t};\n\t\t\t}\n\t\t\tthis._cachedAllowed = true;\n\t\t\treturn { allowed: true };\n\t\t}\n\t\tthis._ctx = fresh;\n\t\tconst facts = await deriveLaneFacts(deps, fresh, lane);\n\t\tif (facts.fresh) {\n\t\t\tthis._cachedAllowed = true;\n\t\t\treturn { allowed: true };\n\t\t}\n\n\t\tconst policy = this.config.policy();\n\t\tlet syncRequired = policy === \"on_land_mandatory\";\n\t\tif (policy === \"overlap_mandatory\") {\n\t\t\t// Epoch files are notification/diagnostic state only. Derive both sides from the\n\t\t\t// current merge base so an overlap from land N remains enforced after unrelated land N+1.\n\t\t\tconst mergeBase = await deps.exec(\"git\", [\"merge-base\", fresh.mainBranch, lane.branch], {\n\t\t\t\tcwd: fresh.topLevel,\n\t\t\t\ttimeout: 60_000,\n\t\t\t\tmaxBuffer: 1024 * 1024,\n\t\t\t});\n\t\t\tif (mergeBase.code !== 0 || !mergeBase.stdout.trim()) {\n\t\t\t\tsyncRequired = true;\n\t\t\t} else {\n\t\t\t\tconst base = mergeBase.stdout.trim().split(/\\s+/u)[0];\n\t\t\t\tconst lanePaths = await changedPaths(deps, fresh.topLevel, base, lane.branch);\n\t\t\t\tconst mainPaths = await changedPaths(deps, fresh.topLevel, base, fresh.mainBranch);\n\t\t\t\tif (!lanePaths || !mainPaths) {\n\t\t\t\t\tsyncRequired = true;\n\t\t\t\t} else {\n\t\t\t\t\tsyncRequired = [...lanePaths].some((path) => mainPaths.has(path));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (policy === \"land_time_only\") syncRequired = false;\n\n\t\tif (!syncRequired) {\n\t\t\tthis._cachedAllowed = true;\n\t\t\treturn { allowed: true };\n\t\t}\n\t\tthis._cachedAllowed = false;\n\t\treturn {\n\t\t\tallowed: false,\n\t\t\tcode: \"sync_required\",\n\t\t\tmessage:\n\t\t\t\t`worktree-sync: lane '${this.config.laneKey}' must rebase main before further mutations ` +\n\t\t\t\t`(main moved past this lane). Commit any WIP (git add/commit stay available), then call ` +\n\t\t\t\t`worktree_sync {\"action\":\"sync\"}, resolve conflicts if any, and continue. (sync_required)`,\n\t\t};\n\t}\n}\n"]}
1
+ {"version":3,"file":"lane-gate.js","sourceRoot":"","sources":["../../../src/core/worktree-sync/lane-gate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAElE,OAAO,EAAE,eAAe,EAAoB,kBAAkB,EAA+B,MAAM,iBAAiB,CAAC;AACrH,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAOtC,MAAM,yBAAyB,GAAG,IAAI,GAAG,CAAC;IACzC,QAAQ;IACR,MAAM;IACN,KAAK;IACL,MAAM;IACN,KAAK;IACL,QAAQ;IACR,OAAO;IACP,WAAW;IACX,UAAU;IACV,OAAO;IACP,MAAM;CACN,CAAC,CAAC;AAEH,MAAM,6BAA6B,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,CAAC,CAAC,CAAC;AAEtH;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,uBAAuB,CAAC,OAAe,EAAE,UAAkB;IAC1E,2EAA2E;IAC3E,wEAAwE;IACxE,2DAA2D;IAC3D,IAAI,oBAAoB,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QACxC,OAAO;YACN,OAAO,EAAE,uBAAuB;YAChC,MAAM,E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AAE,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;gBAC9E,MAAM,SAAS,GAAG,MAAM,YAAY,CAAC,IAAI,EAAE,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;gBACnF,IAAI,CAAC,SAAS,IAAI,CAAC,SAAS,EAAE,CAAC;oBAC9B,YAAY,GAAG,IAAI,CAAC;gBACrB,CAAC;qBAAM,CAAC;oBACP,YAAY,GAAG,CAAC,GAAG,SAAS,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;gBACnE,CAAC;YACF,CAAC;QACF,CAAC;QACD,IAAI,MAAM,KAAK,gBAAgB;YAAE,YAAY,GAAG,KAAK,CAAC;QAEtD,IAAI,CAAC,YAAY,EAAE,CAAC;YACnB,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;YAC3B,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QAC1B,CAAC;QACD,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC;QAC5B,OAAO;YACN,OAAO,EAAE,KAAK;YACd,IAAI,EAAE,eAAe;YACrB,OAAO,EACN,wBAAwB,IAAI,CAAC,MAAM,CAAC,OAAO,8CAA8C;gBACzF,yFAAyF;gBACzF,0FAA0F;SAC3F,CAAC;IACH,CAAC;CACD","sourcesContent":["/**\n * Lane gate: G8/G10 enforcement for a LANE-BOUND `pi` session (launched with\n * `PI_WORKTREE_LANE=<key>`). RuntimeBuilder wraps the session's file-mutation tools (edit /\n * write / bash) with {@link WorktreeLaneGate.checkMutation}; a lane that the active policy marks\n * sync_required fails closed with the exact recovery step until it rebases main.\n *\n * Honesty boundary: edit/write checks are structural for Pi children because the wrapper lives\n * under the tool layer. Bash remains a deliberate host-trust boundary; this gate only rejects\n * integration-sensitive Git forms and never claims to sandbox arbitrary process code. Foreign\n * CLIs stay cooperative-only, with the land CAS (G3) as their backstop.\n *\n * Determinism: the gate re-derives from git only when the epoch file actually changed (mtime\n * fence) or while blocked; verdicts in between are cached. No polling, no timers.\n */\n\nimport { existsSync, realpathSync, statSync } from \"node:fs\";\nimport { basename, dirname, join, resolve, sep } from \"node:path\";\nimport type { WorktreeSyncPolicy } from \"./codes.ts\";\nimport { deriveLaneFacts, type RepoContext, resolveRepoContext, type WorktreeSyncEngineDeps } from \"./git-engine.ts\";\nimport { readLane } from \"./store.ts\";\n\nexport type LaneBashVerdict =\n\t| { verdict: \"allowed\" }\n\t| { verdict: \"allowed_even_when_sync_required\" }\n\t| { verdict: \"main_mutation_refused\"; reason: string };\n\nconst SYNC_SAFE_GIT_SUBCOMMANDS = new Set([\n\t\"status\",\n\t\"diff\",\n\t\"log\",\n\t\"show\",\n\t\"add\",\n\t\"commit\",\n\t\"stash\",\n\t\"rev-parse\",\n\t\"ls-files\",\n\t\"blame\",\n\t\"grep\",\n]);\n\nconst MAIN_MUTATING_GIT_SUBCOMMANDS = new Set([\"merge\", \"rebase\", \"reset\", \"commit\", \"branch\", \"update-ref\", \"push\"]);\n\n/**\n * Classify one bash command line for a lane-bound session (G10 + the sync_required allowlist).\n * Tokenization is whitespace-naive by design -- deterministic and reviewable; shell-quoting\n * tricks can evade it, which is the documented cooperative boundary (the land CAS cannot be\n * evaded). Command POSITION still matters: `git` only begins an invocation at the start of the\n * command or immediately after a shell separator (`&&`, `||`, `;`, `|`) -- a bare `git` token\n * elsewhere (e.g. as a plain argument to `echo`) is not an invocation. Rules:\n * - `git push` anywhere: refused (main moves only through the land gate; pushing is owner-only).\n * - `git -C <path>` / `--git-dir` combined with a mutating subcommand: refused (escaping the\n * lane worktree to operate on another checkout, e.g. the hub).\n * - `git branch -f/-M/-D <main>` / `git update-ref refs/heads/<main>`: refused.\n * - Everything else: allowed; a read/commit-shaped git subcommand additionally stays allowed\n * while the lane is sync_required (committing WIP is the prescribed step BEFORE syncing).\n */\nexport function classifyLaneBashCommand(command: string, mainBranch: string): LaneBashVerdict {\n\t// This classifier is defense-in-depth, not a shell parser. Refuse compound\n\t// syntax before any segment can return an allow verdict; otherwise `git\n\t// status; git push` is approved by the first safe segment.\n\tif (/[|;&<>$`(){}\\n\\r]/u.test(command)) {\n\t\treturn {\n\t\t\tverdict: \"main_mutation_refused\",\n\t\t\treason: \"compound shell syntax is refused in a lane; use typed worktree_sync actions\",\n\t\t};\n\t}\n\tif (/^\\s*[\"']git[\"']\\s/u.test(command)) {\n\t\treturn {\n\t\t\tverdict: \"main_mutation_refused\",\n\t\t\treason: \"quoted command names are refused in a lane; use the typed Git actions\",\n\t\t};\n\t}\n\tconst segments = [command];\n\tlet allowedWhenSyncRequired = false;\n\tfor (const segment of segments) {\n\t\tconst tokens = segment.trim().split(/\\s+/).filter(Boolean);\n\t\tif (tokens[0] !== \"git\") continue;\n\t\tlet j = 1;\n\t\tlet escapesWorktree = false;\n\t\t// Skip git global options to find the subcommand; -C/--git-dir mark checkout escape.\n\t\twhile (j < tokens.length) {\n\t\t\tconst token = tokens[j] ?? \"\";\n\t\t\tif (token === \"-C\" || token === \"--git-dir\" || token === \"--work-tree\") {\n\t\t\t\tescapesWorktree = true;\n\t\t\t\tj += 2;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (token.startsWith(\"-C\") && token !== \"-C\") {\n\t\t\t\tescapesWorktree = true;\n\t\t\t\tj += 1;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (token.startsWith(\"--git-dir=\") || token.startsWith(\"--work-tree=\")) {\n\t\t\t\tescapesWorktree = true;\n\t\t\t\tj += 1;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (token.startsWith(\"-\")) {\n\t\t\t\tj += 1;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tconst subcommand = tokens[j] ?? \"\";\n\t\tconst rest = tokens.slice(j + 1);\n\t\tif (subcommand === \"push\") {\n\t\t\treturn {\n\t\t\t\tverdict: \"main_mutation_refused\",\n\t\t\t\treason:\n\t\t\t\t\t\"git push is refused in a lane session; landing is the only integration path and pushing stays an owner action\",\n\t\t\t};\n\t\t}\n\t\tif (escapesWorktree && MAIN_MUTATING_GIT_SUBCOMMANDS.has(subcommand)) {\n\t\t\treturn {\n\t\t\t\tverdict: \"main_mutation_refused\",\n\t\t\t\treason: `git -C/--git-dir with '${subcommand}' escapes the lane worktree; operate only on this lane (G10)`,\n\t\t\t};\n\t\t}\n\t\tif (\n\t\t\tsubcommand === \"branch\" &&\n\t\t\trest.some((token) => /^(?:-f|--force|-M|-m|-D|-d)$/.test(token)) &&\n\t\t\trest.includes(mainBranch)\n\t\t) {\n\t\t\treturn {\n\t\t\t\tverdict: \"main_mutation_refused\",\n\t\t\t\treason: `git branch may not move/delete '${mainBranch}' from a lane; main moves only through the land gate (G10)`,\n\t\t\t};\n\t\t}\n\t\tif (subcommand === \"update-ref\" && rest.some((token) => token === `refs/heads/${mainBranch}`)) {\n\t\t\treturn {\n\t\t\t\tverdict: \"main_mutation_refused\",\n\t\t\t\treason: `git update-ref may not touch refs/heads/${mainBranch} from a lane (G10)`,\n\t\t\t};\n\t\t}\n\t\tif (SYNC_SAFE_GIT_SUBCOMMANDS.has(subcommand)) allowedWhenSyncRequired = true;\n\t}\n\treturn allowedWhenSyncRequired ? { verdict: \"allowed_even_when_sync_required\" } : { verdict: \"allowed\" };\n}\n\n/** Symlink-safe resolution of a path that may not exist yet: realpath the NEAREST EXISTING\n * ancestor, then re-append the not-yet-existing tail literally (a not-yet-created file's own\n * missing final component can never itself be a symlink escape). */\nfunction resolveSymlinkSafe(targetPath: string): string {\n\tif (existsSync(targetPath)) {\n\t\ttry {\n\t\t\treturn realpathSync(targetPath);\n\t\t} catch {\n\t\t\treturn targetPath;\n\t\t}\n\t}\n\tconst tail: string[] = [basename(targetPath)];\n\tlet ancestor = dirname(targetPath);\n\twhile (!existsSync(ancestor)) {\n\t\tconst parent = dirname(ancestor);\n\t\tif (parent === ancestor) break; // reached the filesystem root without finding one\n\t\ttail.unshift(basename(ancestor));\n\t\tancestor = parent;\n\t}\n\tlet realAncestor: string;\n\ttry {\n\t\trealAncestor = realpathSync(ancestor);\n\t} catch {\n\t\trealAncestor = ancestor;\n\t}\n\treturn join(realAncestor, ...tail);\n}\n\n/** Symlink-safe containment check (G-path): does `targetPath` resolve inside `worktreePath`? */\nexport function isPathOutsideLane(targetPath: string, worktreePath: string): boolean {\n\tlet realRoot: string;\n\ttry {\n\t\trealRoot = realpathSync(worktreePath);\n\t} catch {\n\t\trealRoot = worktreePath;\n\t}\n\tconst resolvedTarget = resolveSymlinkSafe(targetPath);\n\treturn resolvedTarget !== realRoot && !resolvedTarget.startsWith(realRoot + sep);\n}\n\n/** Resolve a user-supplied relative lane path and reject symlink/parent escapes. */\nexport function resolveLaneMutationPath(worktreePath: string, candidate: string): string | undefined {\n\tconst target = resolve(worktreePath, candidate);\n\treturn isPathOutsideLane(target, worktreePath) ? undefined : target;\n}\n\nexport interface WorktreeLaneGateConfig {\n\tlaneKey: string;\n\tengineDeps: () => WorktreeSyncEngineDeps;\n\tpolicy: () => WorktreeSyncPolicy;\n}\n\nexport type LaneMutationCheck = { allowed: true } | { allowed: false; code: string; message: string };\n\nasync function changedPaths(\n\tdeps: WorktreeSyncEngineDeps,\n\tcwd: string,\n\tbase: string,\n\tref: string,\n): Promise<Set<string> | undefined> {\n\tconst result = await deps.exec(\"git\", [\"diff\", \"--name-only\", `${base}..${ref}`, \"--\"], {\n\t\tcwd,\n\t\ttimeout: 60_000,\n\t\tmaxBuffer: 1024 * 1024,\n\t});\n\tif (result.code !== 0) return undefined;\n\treturn new Set(\n\t\tresult.stdout\n\t\t\t.split(/\\r?\\n/u)\n\t\t\t.map((path) => path.trim())\n\t\t\t.filter(Boolean),\n\t);\n}\n\n/**\n * The G8 gate object RuntimeBuilder holds per lane-bound session. `checkMutation` is called by\n * the wrapped edit/write/bash tools before every mutating execution.\n */\nexport class WorktreeLaneGate {\n\tprivate readonly config: WorktreeLaneGateConfig;\n\tprivate _ctx: RepoContext | undefined;\n\tprivate _epochFileMtimeMs: number | undefined;\n\tprivate _cachedAllowed = false;\n\n\tconstructor(config: WorktreeLaneGateConfig) {\n\t\tthis.config = config;\n\t}\n\n\tprivate async resolveContext(): Promise<RepoContext | undefined> {\n\t\tif (this._ctx) return this._ctx;\n\t\tconst ctx = await resolveRepoContext(this.config.engineDeps());\n\t\tif (\"code\" in ctx) return undefined;\n\t\tthis._ctx = ctx;\n\t\treturn ctx;\n\t}\n\n\t/** Cheap fence: has the epoch file changed since the last allowed verdict? */\n\tprivate epochChanged(ctx: RepoContext): boolean {\n\t\tlet mtimeMs: number | undefined;\n\t\ttry {\n\t\t\tmtimeMs = statSync(ctx.paths.epochFile).mtimeMs;\n\t\t} catch {\n\t\t\tmtimeMs = undefined;\n\t\t}\n\t\tif (mtimeMs === this._epochFileMtimeMs) return false;\n\t\tthis._epochFileMtimeMs = mtimeMs;\n\t\treturn true;\n\t}\n\n\tasync checkMutation(toolName: string, bashCommand?: string, targetPath?: string): Promise<LaneMutationCheck> {\n\t\tconst ctx = await this.resolveContext();\n\t\t// No repo context (deleted repo, engine failure): fail OPEN for plain tools -- the land\n\t\t// CAS still holds -- but the integration-sensitive Git rules below never depend on repo state.\n\t\tconst mainBranch = ctx?.mainBranch ?? \"main\";\n\n\t\tif (toolName === \"bash\" && bashCommand !== undefined) {\n\t\t\tconst verdict = classifyLaneBashCommand(bashCommand, mainBranch);\n\t\t\tif (verdict.verdict === \"main_mutation_refused\") {\n\t\t\t\treturn { allowed: false, code: \"main_mutation_refused\", message: `worktree-sync: ${verdict.reason}` };\n\t\t\t}\n\t\t\tif (verdict.verdict === \"allowed_even_when_sync_required\") return { allowed: true };\n\t\t}\n\t\tif (!ctx) return { allowed: true };\n\n\t\t// G-path: an edit/write target must resolve INSIDE this lane's worktree (symlink-safe),\n\t\t// checked BEFORE the staleness cache so a cached \"allowed\" verdict never short-circuits past\n\t\t// it. No active lane record: existing fail-open stands (mirrors the readLane check below).\n\t\tif ((toolName === \"edit\" || toolName === \"write\") && targetPath !== undefined) {\n\t\t\tconst laneForPath = await readLane(ctx.paths, this.config.laneKey);\n\t\t\tif (laneForPath?.status === \"active\" && isPathOutsideLane(targetPath, laneForPath.worktreePath)) {\n\t\t\t\treturn {\n\t\t\t\t\tallowed: false,\n\t\t\t\t\tcode: \"path_outside_lane\",\n\t\t\t\t\tmessage: `worktree-sync: '${targetPath}' resolves outside lane '${this.config.laneKey}' worktree (${laneForPath.worktreePath}); edit/write only inside your lane checkout`,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\t// G8: sync_required fails mutations closed. Re-derive only when the epoch moved or while\n\t\t// blocked (a successful sync clears the block on the very next check).\n\t\tif (this._cachedAllowed && !this.epochChanged(ctx)) return { allowed: true };\n\n\t\tconst deps = this.config.engineDeps();\n\t\tconst lane = await readLane(ctx.paths, this.config.laneKey);\n\t\tif (!lane || lane.status !== \"active\") {\n\t\t\tthis._cachedAllowed = true;\n\t\t\treturn { allowed: true };\n\t\t}\n\t\t// Re-derive main tip: the cached ctx pins the sha from session start.\n\t\tconst fresh = await resolveRepoContext(deps);\n\t\tif (\"code\" in fresh) {\n\t\t\tthis._cachedAllowed = true;\n\t\t\treturn { allowed: true };\n\t\t}\n\t\tthis._ctx = fresh;\n\t\tconst facts = await deriveLaneFacts(deps, fresh, lane);\n\t\tif (facts.fresh) {\n\t\t\tthis._cachedAllowed = true;\n\t\t\treturn { allowed: true };\n\t\t}\n\n\t\tconst policy = this.config.policy();\n\t\tlet syncRequired = policy === \"on_land_mandatory\";\n\t\tif (policy === \"overlap_mandatory\") {\n\t\t\t// Epoch files are notification/diagnostic state only. Derive both sides from the\n\t\t\t// current merge base so an overlap from land N remains enforced after unrelated land N+1.\n\t\t\tconst mergeBase = await deps.exec(\"git\", [\"merge-base\", fresh.mainBranch, lane.branch], {\n\t\t\t\tcwd: fresh.topLevel,\n\t\t\t\ttimeout: 60_000,\n\t\t\t\tmaxBuffer: 1024 * 1024,\n\t\t\t});\n\t\t\tif (mergeBase.code !== 0 || !mergeBase.stdout.trim()) {\n\t\t\t\tsyncRequired = true;\n\t\t\t} else {\n\t\t\t\tconst base = mergeBase.stdout.trim().split(/\\s+/u)[0];\n\t\t\t\tconst lanePaths = await changedPaths(deps, fresh.topLevel, base, lane.branch);\n\t\t\t\tconst mainPaths = await changedPaths(deps, fresh.topLevel, base, fresh.mainBranch);\n\t\t\t\tif (!lanePaths || !mainPaths) {\n\t\t\t\t\tsyncRequired = true;\n\t\t\t\t} else {\n\t\t\t\t\tsyncRequired = [...lanePaths].some((path) => mainPaths.has(path));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (policy === \"land_time_only\") syncRequired = false;\n\n\t\tif (!syncRequired) {\n\t\t\tthis._cachedAllowed = true;\n\t\t\treturn { allowed: true };\n\t\t}\n\t\tthis._cachedAllowed = false;\n\t\treturn {\n\t\t\tallowed: false,\n\t\t\tcode: \"sync_required\",\n\t\t\tmessage:\n\t\t\t\t`worktree-sync: lane '${this.config.laneKey}' must rebase main before further mutations ` +\n\t\t\t\t`(main moved past this lane). Commit any WIP (git add/commit stay available), then call ` +\n\t\t\t\t`worktree_sync {\"action\":\"sync\"}, resolve conflicts if any, and continue. (sync_required)`,\n\t\t};\n\t}\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -4,6 +4,8 @@ export { type Args, parseArgs } from "./cli/args.ts";
4
4
  export { getAgentDir, VERSION } from "./config.ts";
5
5
  export { AgentSession, type AgentSessionConfig, type AgentSessionEvent, type AgentSessionEventListener, type ModelCycleResult, type ParsedSkillBlock, type PromptOptions, parseSkillBlock, type SessionStats, } from "./core/agent-session.ts";
6
6
  export { type ApiKeyCredential, type AuthCredential, type AuthStatus, AuthStorage, type AuthStorageBackend, FileAuthStorageBackend, InMemoryAuthStorageBackend, type OAuthCredential, } from "./core/auth-storage.ts";
7
+ export { encodeWorkerSessionAllowedPaths, PI_WORKER_ALLOWED_PATHS_ENV, } from "./core/autonomy/worker-session-private-scope.ts";
8
+ export { mapToolNamesForPlatform } from "./core/default-tool-surface.ts";
7
9
  export { createEventBus, type EventBus, type EventBusController } from "./core/event-bus.ts";
8
10
  export type { AgentEndEvent, AgentStartEvent, AgentToolResult, AgentToolUpdateCallback, AppKeybinding, AutocompleteProviderFactory, BashToolCallEvent, BeforeAgentStartEvent, BeforeAgentStartEventResult, BeforeProviderRequestEvent, BeforeProviderRequestEventResult, BuildSystemPromptOptions, CompactOptions, ContextEvent, ContextEventResult, ContextUsage, CustomToolCallEvent, EditToolCallEvent, ExecOptions, ExecResult, Extension, ExtensionActions, ExtensionAPI, ExtensionCommandContext, ExtensionCommandContextActions, ExtensionContext, ExtensionContextActions, ExtensionError, ExtensionEvent, ExtensionFactory, ExtensionFlag, ExtensionHandler, ExtensionRuntime, ExtensionShortcut, ExtensionStorage, ExtensionUIContext, ExtensionUIDialogOptions, ExtensionWidgetOptions, ExtensionWorkRunOptions, FindToolCallEvent, GrepToolCallEvent, InputEvent, InputEventResult, InputSource, KeybindingsManager, LoadExtensionsResult, LsToolCallEvent, MessageEndEvent, MessageRenderer, MessageRenderOptions, MessageStartEvent, MessageUpdateEvent, ProviderConfig, ProviderModelConfig, ReadToolCallEvent, RegisteredCommand, RegisteredTool, ResolvedCommand, SessionBeforeCompactEvent, SessionBeforeForkEvent, SessionBeforeSwitchEvent, SessionBeforeTreeEvent, SessionCompactEvent, SessionShutdownEvent, SessionStartEvent, SessionTreeEvent, SlashCommandInfo, SlashCommandSource, SourceInfo, TerminalInputHandler, ToolCallEvent, ToolCallEventResult, ToolDefinition, ToolExecutionEndEvent, ToolExecutionMode, ToolExecutionStartEvent, ToolExecutionUpdateEvent, ToolInfo, ToolRenderResultOptions, ToolResultEvent, TurnEndEvent, TurnStartEvent, UserBashEvent, UserBashEventResult, WidgetPlacement, WorkingIndicatorOptions, WriteToolCallEvent, } from "./core/extensions/index.ts";
9
11
  export { defineTool, ExtensionRunner, isBashToolResult, isEditToolResult, isFindToolResult, isGrepToolResult, isLsToolResult, isReadToolResult, isToolCallEventType, isWriteToolResult, wrapRegisteredTool, wrapRegisteredTools, } from "./core/extensions/index.ts";
@@ -19,6 +21,7 @@ export * from "./core/orchestration/policy-compiler.ts";
19
21
  export * from "./core/orchestration/profile-registry.ts";
20
22
  export * from "./core/orchestration/profile-store.ts";
21
23
  export * from "./core/orchestration/task-runtime.ts";
24
+ export { orchestrationThinkingLevelSchema } from "./core/orchestration/thinking-level-schema.ts";
22
25
  export type { PackageManager, PathMetadata, ProgressCallback, ProgressEvent, ResolvedPaths, ResolvedResource, } from "./core/package-manager.ts";
23
26
  export { DefaultPackageManager } from "./core/package-manager.ts";
24
27
  export { PI_ORCHESTRATION_AGENT_ID_ENV } from "./core/process-identity.ts";
@@ -33,10 +36,12 @@ export { type BitwardenSecretsManagerCommandRequest, type BitwardenSecretsManage
33
36
  export { type CredentialActivationResult, type CredentialConnectionStatus, CredentialManager, CredentialManagerError, type CredentialManagerErrorCode, type CredentialManagerOptions, type CredentialMutationResult, type CredentialProfileRecord, type CredentialProfileStorage, type CredentialProfileSummary, type CredentialProjectIdentity, type CredentialProjectResolver, CredentialStorageError, type CredentialStorageErrorCode, type CredentialStorageProvider, type CredentialVariable, type MachineCredentialSession, type MachineCredentialSessionResolver, type StoredCredentialProfileSummary, } from "./core/secrets/credential-manager.ts";
34
37
  export { type CredentialMigrationSource, CredentialMigrationSourceError, type CredentialMigrationSourceErrorCode, type CredentialMigrationSourceResolver, resolveCredentialMigrationSources, } from "./core/secrets/credential-migration-source.ts";
35
38
  export { createPortableGitProjectKey, resolveCredentialProject } from "./core/secrets/credential-project.ts";
39
+ export { WORKER_FORBIDDEN_TOOLS } from "./core/session-role.ts";
36
40
  export { type CompactionSettings, type DirectoryResourceProfileInfo, getDirectoryResourceProfileInfo, type ImageSettings, matchesResourceProfilePattern, type PackageSource, type ResourceProfileFilterSettings, type ResourceProfileKind, type ResourceProfileSettings, type RetrySettings, SettingsManager, type SettingsManagerCreateOptions, } from "./core/settings-manager.ts";
37
41
  export { DEFAULT_SKILL_IDLE_TIMEOUT_MS, MAX_ACTIVE_SKILL_BODY_BYTES, MAX_LOADED_SKILLS, MAX_PINNED_SKILLS, MIN_ACTIVE_SKILL_BODY_BYTES, resolveActiveSkillBodyByteLimit, type SkillLoadResult, type SkillSearchResult, type SkillSlotStatus, SkillVaultController, type SkillVaultControllerOptions, type SkillVaultStatus, } from "./core/skill-vault.ts";
38
42
  export { type LoadSkillsFromDirOptions, type LoadSkillsResult, loadSkills, loadSkillsFromDir, MAX_SKILL_FRONTMATTER_BYTES, readSkillFrontmatterFile, type Skill, type SkillFrontmatter, } from "./core/skills.ts";
39
43
  export { createSyntheticSourceInfo } from "./core/source-info.ts";
44
+ export { POLICY_OWNED_RUNTIME_TOOL_NAMES } from "./core/tool-capability-policy.ts";
40
45
  export { type AskQuestion, type AskQuestionAnswer, AskQuestionDialog, type AskQuestionStopReason, type AskQuestionToolDetails, type AskQuestionToolInput, type AskQuestionToolOptions, createAskQuestionToolDefinition, } from "./core/tools/ask-question.ts";
41
46
  export { type BashOperations, type BashSpawnContext, type BashSpawnHook, type BashToolDetails, type BashToolInput, type BashToolOptions, createBashToolDefinition, createEditToolDefinition, createFileFailureRecoveryAuthority, createFindToolDefinition, createGrepToolDefinition, createLocalBashOperations, createLsToolDefinition, createReadToolDefinition, createSecretStoreToolDefinition, createWriteToolDefinition, DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, type EditOperations, type EditToolDetails, type EditToolInput, type EditToolOptions, type FileContentReference, type FileFailureRecoveryAuthority, FileMutationIntentController, type FileMutationIntentControllerOptions, type FileMutationIntentOperations, type FileMutationKind, type FileMutationLease, type FileMutationPayloadReference, FileMutationPreflightError, type FileMutationPreflightFailureReason, type FilePathIdentity, type FilePathInspection, type FindOperations, type FindToolDetails, type FindToolInput, type FindToolOptions, formatMiddleOmissionMarker, formatSize, type GrepOperations, type GrepToolDetails, type GrepToolInput, type GrepToolOptions, type LsOperations, type LsToolDetails, type LsToolInput, type LsToolOptions, type ReadOperations, type ReadToolDetails, type ReadToolInput, type ReadToolOptions, type SecretStoreStatus, type SecretStoreToolDetails, type SecretStoreToolInput, type SecretStoreToolOptions, type ToolsOptions, type TruncationOptions, type TruncationResult, truncateHead, truncateKnownHeadTail, truncateLine, truncateMiddle, truncateTail, type WriteOperations, type WriteToolDetails, type WriteToolInput, type WriteToolOptions, withFileMutationQueue, } from "./core/tools/index.ts";
42
47
  export { createSkillVaultToolDefinition, type SkillToolDetails, type SkillToolInput, } from "./core/tools/skill.ts";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,OAAO,EACN,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,mBAAmB,EACnB,KAAK,oBAAoB,EACzB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,uBAAuB,EACvB,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,sBAAsB,EACtB,8BAA8B,EAC9B,OAAO,EACP,2BAA2B,EAC3B,cAAc,EACd,KAAK,SAAS,EACd,KAAK,cAAc,EACnB,YAAY,EACZ,kBAAkB,EAClB,KAAK,4BAA4B,EACjC,qBAAqB,EACrB,eAAe,EACf,qBAAqB,EACrB,wBAAwB,EACxB,KAAK,gBAAgB,EACrB,qBAAqB,EACrB,KAAK,iBAAiB,EACtB,mBAAmB,EACnB,oBAAoB,EACpB,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,cAAc,EACd,KAAK,mBAAmB,EACxB,qBAAqB,EACrB,aAAa,EACb,KAAK,wBAAwB,GAC7B,MA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