@ttsc/unplugin 0.31.0 → 0.31.2

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 (291) hide show
  1. package/lib/core/bridge/projectRecordMoved.js +1 -1
  2. package/lib/core/bridge/projectRecordMoved.js.map +1 -1
  3. package/lib/core/bridge/projectRecordMoved.mjs +1 -1
  4. package/lib/core/bridge/projectRecordMoved.mjs.map +1 -1
  5. package/lib/core/bun/bun.d.cts +3 -2
  6. package/lib/core/bun/bun.d.mts +3 -2
  7. package/lib/core/bun/bun.d.ts +3 -2
  8. package/lib/core/bun/bun.js +8 -4
  9. package/lib/core/bun/bun.js.map +1 -1
  10. package/lib/core/bun/bun.mjs +8 -4
  11. package/lib/core/bun/bun.mjs.map +1 -1
  12. package/lib/core/observer/createInputObserver.js +7 -6
  13. package/lib/core/observer/createInputObserver.js.map +1 -1
  14. package/lib/core/observer/createInputObserver.mjs +7 -6
  15. package/lib/core/observer/createInputObserver.mjs.map +1 -1
  16. package/lib/core/observer/openIsolatedRecursiveWatch.d.cts +11 -12
  17. package/lib/core/observer/openIsolatedRecursiveWatch.d.mts +11 -12
  18. package/lib/core/observer/openIsolatedRecursiveWatch.d.ts +11 -12
  19. package/lib/core/observer/openIsolatedRecursiveWatch.js +11 -12
  20. package/lib/core/observer/openIsolatedRecursiveWatch.js.map +1 -1
  21. package/lib/core/observer/openIsolatedRecursiveWatch.mjs +11 -12
  22. package/lib/core/observer/openIsolatedRecursiveWatch.mjs.map +1 -1
  23. package/lib/core/transform/cache/TtscCachedProjectTransform.d.cts +12 -3
  24. package/lib/core/transform/cache/TtscCachedProjectTransform.d.mts +12 -3
  25. package/lib/core/transform/cache/TtscCachedProjectTransform.d.ts +12 -3
  26. package/lib/core/transform/cache/selectCachedGenerationAction.d.cts +2 -0
  27. package/lib/core/transform/cache/selectCachedGenerationAction.d.mts +2 -0
  28. package/lib/core/transform/cache/selectCachedGenerationAction.d.ts +2 -0
  29. package/lib/core/transform/cache/selectCachedGenerationAction.js +1 -1
  30. package/lib/core/transform/cache/selectCachedGenerationAction.js.map +1 -1
  31. package/lib/core/transform/cache/selectCachedGenerationAction.mjs +1 -1
  32. package/lib/core/transform/cache/selectCachedGenerationAction.mjs.map +1 -1
  33. package/lib/core/transform/deliverCachedTransform.d.cts +36 -0
  34. package/lib/core/transform/deliverCachedTransform.d.mts +36 -0
  35. package/lib/core/transform/deliverCachedTransform.d.ts +36 -0
  36. package/lib/core/transform/deliverCachedTransform.js +73 -0
  37. package/lib/core/transform/deliverCachedTransform.js.map +1 -0
  38. package/lib/core/transform/deliverCachedTransform.mjs +71 -0
  39. package/lib/core/transform/deliverCachedTransform.mjs.map +1 -0
  40. package/lib/core/transform/envelope/selectDeclaredProjectInputKeys.d.cts +2 -2
  41. package/lib/core/transform/envelope/selectDeclaredProjectInputKeys.d.mts +2 -2
  42. package/lib/core/transform/envelope/selectDeclaredProjectInputKeys.d.ts +2 -2
  43. package/lib/core/transform/envelope/selectDeclaredProjectInputKeys.js +6 -2
  44. package/lib/core/transform/envelope/selectDeclaredProjectInputKeys.js.map +1 -1
  45. package/lib/core/transform/envelope/selectDeclaredProjectInputKeys.mjs +6 -2
  46. package/lib/core/transform/envelope/selectDeclaredProjectInputKeys.mjs.map +1 -1
  47. package/lib/core/transform/envelope/selectExternalInputPaths.d.cts +3 -5
  48. package/lib/core/transform/envelope/selectExternalInputPaths.d.mts +3 -5
  49. package/lib/core/transform/envelope/selectExternalInputPaths.d.ts +3 -5
  50. package/lib/core/transform/envelope/selectExternalInputPaths.js +8 -7
  51. package/lib/core/transform/envelope/selectExternalInputPaths.js.map +1 -1
  52. package/lib/core/transform/envelope/selectExternalInputPaths.mjs +8 -7
  53. package/lib/core/transform/envelope/selectExternalInputPaths.mjs.map +1 -1
  54. package/lib/core/transform/filesystem/TtscTransformFilesystemOperations.d.cts +15 -12
  55. package/lib/core/transform/filesystem/TtscTransformFilesystemOperations.d.mts +15 -12
  56. package/lib/core/transform/filesystem/TtscTransformFilesystemOperations.d.ts +15 -12
  57. package/lib/core/transform/generation/captureFailedGenerationInputStates.js +1 -1
  58. package/lib/core/transform/generation/captureFailedGenerationInputStates.js.map +1 -1
  59. package/lib/core/transform/generation/captureFailedGenerationInputStates.mjs +1 -1
  60. package/lib/core/transform/generation/captureFailedGenerationInputStates.mjs.map +1 -1
  61. package/lib/core/transform/generation/captureTransformGeneration.js +1 -1
  62. package/lib/core/transform/generation/captureTransformGeneration.js.map +1 -1
  63. package/lib/core/transform/generation/captureTransformGeneration.mjs +1 -1
  64. package/lib/core/transform/generation/captureTransformGeneration.mjs.map +1 -1
  65. package/lib/core/transform/generation/failedGenerationEnvironmentChanged.js +2 -2
  66. package/lib/core/transform/generation/failedGenerationEnvironmentChanged.js.map +1 -1
  67. package/lib/core/transform/generation/failedGenerationEnvironmentChanged.mjs +2 -2
  68. package/lib/core/transform/generation/failedGenerationEnvironmentChanged.mjs.map +1 -1
  69. package/lib/core/transform/generation/selectTransformAttemptDisposition.d.cts +3 -1
  70. package/lib/core/transform/generation/selectTransformAttemptDisposition.d.mts +3 -1
  71. package/lib/core/transform/generation/selectTransformAttemptDisposition.d.ts +3 -1
  72. package/lib/core/transform/generation/selectTransformAttemptDisposition.js +3 -1
  73. package/lib/core/transform/generation/selectTransformAttemptDisposition.js.map +1 -1
  74. package/lib/core/transform/generation/selectTransformAttemptDisposition.mjs +3 -1
  75. package/lib/core/transform/generation/selectTransformAttemptDisposition.mjs.map +1 -1
  76. package/lib/core/transform/generation/transformProject.d.cts +9 -7
  77. package/lib/core/transform/generation/transformProject.d.mts +9 -7
  78. package/lib/core/transform/generation/transformProject.d.ts +9 -7
  79. package/lib/core/transform/generation/transformProject.js +14 -9
  80. package/lib/core/transform/generation/transformProject.js.map +1 -1
  81. package/lib/core/transform/generation/transformProject.mjs +14 -9
  82. package/lib/core/transform/generation/transformProject.mjs.map +1 -1
  83. package/lib/core/transform/inputs/pluginSourceFilesDigest.d.cts +9 -3
  84. package/lib/core/transform/inputs/pluginSourceFilesDigest.d.mts +9 -3
  85. package/lib/core/transform/inputs/pluginSourceFilesDigest.d.ts +9 -3
  86. package/lib/core/transform/inputs/pluginSourceFilesDigest.js +10 -4
  87. package/lib/core/transform/inputs/pluginSourceFilesDigest.js.map +1 -1
  88. package/lib/core/transform/inputs/pluginSourceFilesDigest.mjs +11 -5
  89. package/lib/core/transform/inputs/pluginSourceFilesDigest.mjs.map +1 -1
  90. package/lib/core/transform/inputs/pluginSourceHolds.d.cts +4 -2
  91. package/lib/core/transform/inputs/pluginSourceHolds.d.mts +4 -2
  92. package/lib/core/transform/inputs/pluginSourceHolds.d.ts +4 -2
  93. package/lib/core/transform/inputs/pluginSourceHolds.js +9 -4
  94. package/lib/core/transform/inputs/pluginSourceHolds.js.map +1 -1
  95. package/lib/core/transform/inputs/pluginSourceHolds.mjs +9 -4
  96. package/lib/core/transform/inputs/pluginSourceHolds.mjs.map +1 -1
  97. package/lib/core/transform/inputs/pluginSourceState.d.cts +3 -1
  98. package/lib/core/transform/inputs/pluginSourceState.d.mts +3 -1
  99. package/lib/core/transform/inputs/pluginSourceState.d.ts +3 -1
  100. package/lib/core/transform/inputs/pluginSourceState.js +8 -3
  101. package/lib/core/transform/inputs/pluginSourceState.js.map +1 -1
  102. package/lib/core/transform/inputs/pluginSourceState.mjs +8 -3
  103. package/lib/core/transform/inputs/pluginSourceState.mjs.map +1 -1
  104. package/lib/core/transform/inputs/preparePluginBuildEnvironments.d.cts +18 -5
  105. package/lib/core/transform/inputs/preparePluginBuildEnvironments.d.mts +18 -5
  106. package/lib/core/transform/inputs/preparePluginBuildEnvironments.d.ts +18 -5
  107. package/lib/core/transform/inputs/preparePluginBuildEnvironments.js +53 -12
  108. package/lib/core/transform/inputs/preparePluginBuildEnvironments.js.map +1 -1
  109. package/lib/core/transform/inputs/preparePluginBuildEnvironments.mjs +53 -12
  110. package/lib/core/transform/inputs/preparePluginBuildEnvironments.mjs.map +1 -1
  111. package/lib/core/transform/tracker/broker/WatchBroker.d.cts +14 -4
  112. package/lib/core/transform/tracker/broker/WatchBroker.d.mts +14 -4
  113. package/lib/core/transform/tracker/broker/WatchBroker.d.ts +14 -4
  114. package/lib/core/transform/tracker/broker/WatchBrokerTransport.d.cts +63 -0
  115. package/lib/core/transform/tracker/broker/WatchBrokerTransport.d.mts +63 -0
  116. package/lib/core/transform/tracker/broker/WatchBrokerTransport.d.ts +63 -0
  117. package/lib/core/transform/tracker/broker/WatchBrokerTransport.js +89 -0
  118. package/lib/core/transform/tracker/broker/WatchBrokerTransport.js.map +1 -0
  119. package/lib/core/transform/tracker/broker/WatchBrokerTransport.mjs +89 -0
  120. package/lib/core/transform/tracker/broker/WatchBrokerTransport.mjs.map +1 -0
  121. package/lib/core/transform/tracker/broker/drainWatchBroker.d.cts +8 -8
  122. package/lib/core/transform/tracker/broker/drainWatchBroker.d.mts +8 -8
  123. package/lib/core/transform/tracker/broker/drainWatchBroker.d.ts +8 -8
  124. package/lib/core/transform/tracker/broker/drainWatchBroker.js +12 -13
  125. package/lib/core/transform/tracker/broker/drainWatchBroker.js.map +1 -1
  126. package/lib/core/transform/tracker/broker/drainWatchBroker.mjs +12 -13
  127. package/lib/core/transform/tracker/broker/drainWatchBroker.mjs.map +1 -1
  128. package/lib/core/transform/tracker/broker/getWatchBroker.d.cts +18 -15
  129. package/lib/core/transform/tracker/broker/getWatchBroker.d.mts +18 -15
  130. package/lib/core/transform/tracker/broker/getWatchBroker.d.ts +18 -15
  131. package/lib/core/transform/tracker/broker/getWatchBroker.js +87 -17
  132. package/lib/core/transform/tracker/broker/getWatchBroker.js.map +1 -1
  133. package/lib/core/transform/tracker/broker/getWatchBroker.mjs +87 -17
  134. package/lib/core/transform/tracker/broker/getWatchBroker.mjs.map +1 -1
  135. package/lib/core/transform/tracker/broker/openBrokeredWatch.d.cts +5 -5
  136. package/lib/core/transform/tracker/broker/openBrokeredWatch.d.mts +5 -5
  137. package/lib/core/transform/tracker/broker/openBrokeredWatch.d.ts +5 -5
  138. package/lib/core/transform/tracker/broker/openBrokeredWatch.js +11 -14
  139. package/lib/core/transform/tracker/broker/openBrokeredWatch.js.map +1 -1
  140. package/lib/core/transform/tracker/broker/openBrokeredWatch.mjs +11 -14
  141. package/lib/core/transform/tracker/broker/openBrokeredWatch.mjs.map +1 -1
  142. package/lib/core/transform/tracker/broker/usesWatchBroker.d.cts +7 -7
  143. package/lib/core/transform/tracker/broker/usesWatchBroker.d.mts +7 -7
  144. package/lib/core/transform/tracker/broker/usesWatchBroker.d.ts +7 -7
  145. package/lib/core/transform/tracker/broker/usesWatchBroker.js +7 -7
  146. package/lib/core/transform/tracker/broker/usesWatchBroker.mjs +7 -7
  147. package/lib/core/transform/tracker/broker/watchBrokerSource.d.cts +9 -10
  148. package/lib/core/transform/tracker/broker/watchBrokerSource.d.mts +9 -10
  149. package/lib/core/transform/tracker/broker/watchBrokerSource.d.ts +9 -10
  150. package/lib/core/transform/tracker/broker/watchBrokerSource.js +10 -11
  151. package/lib/core/transform/tracker/broker/watchBrokerSource.js.map +1 -1
  152. package/lib/core/transform/tracker/broker/watchBrokerSource.mjs +10 -11
  153. package/lib/core/transform/tracker/broker/watchBrokerSource.mjs.map +1 -1
  154. package/lib/core/transform/transformTtsc.d.cts +7 -4
  155. package/lib/core/transform/transformTtsc.d.mts +7 -4
  156. package/lib/core/transform/transformTtsc.d.ts +7 -4
  157. package/lib/core/transform/transformTtsc.js +38 -93
  158. package/lib/core/transform/transformTtsc.js.map +1 -1
  159. package/lib/core/transform/transformTtsc.mjs +38 -93
  160. package/lib/core/transform/transformTtsc.mjs.map +1 -1
  161. package/lib/core/transform/validation/TtscGenerationProof.d.cts +105 -0
  162. package/lib/core/transform/validation/TtscGenerationProof.d.mts +105 -0
  163. package/lib/core/transform/validation/TtscGenerationProof.d.ts +105 -0
  164. package/lib/core/transform/validation/TtscGenerationProof.js +149 -0
  165. package/lib/core/transform/validation/TtscGenerationProof.js.map +1 -0
  166. package/lib/core/transform/validation/TtscGenerationProof.mjs +149 -0
  167. package/lib/core/transform/validation/TtscGenerationProof.mjs.map +1 -0
  168. package/lib/core/transform/validation/captureUniversalHostInputValidation.js +2 -2
  169. package/lib/core/transform/validation/captureUniversalHostInputValidation.js.map +1 -1
  170. package/lib/core/transform/validation/captureUniversalHostInputValidation.mjs +2 -2
  171. package/lib/core/transform/validation/captureUniversalHostInputValidation.mjs.map +1 -1
  172. package/lib/core/transform/validation/matchesCachedSource.d.cts +18 -15
  173. package/lib/core/transform/validation/matchesCachedSource.d.mts +18 -15
  174. package/lib/core/transform/validation/matchesCachedSource.d.ts +18 -15
  175. package/lib/core/transform/validation/matchesCachedSource.js +28 -22
  176. package/lib/core/transform/validation/matchesCachedSource.js.map +1 -1
  177. package/lib/core/transform/validation/matchesCachedSource.mjs +28 -22
  178. package/lib/core/transform/validation/matchesCachedSource.mjs.map +1 -1
  179. package/lib/core/transform/validation/matchesCompleteInputSnapshot.d.cts +3 -2
  180. package/lib/core/transform/validation/matchesCompleteInputSnapshot.d.mts +3 -2
  181. package/lib/core/transform/validation/matchesCompleteInputSnapshot.d.ts +3 -2
  182. package/lib/core/transform/validation/matchesCompleteInputSnapshot.js +4 -4
  183. package/lib/core/transform/validation/matchesCompleteInputSnapshot.js.map +1 -1
  184. package/lib/core/transform/validation/matchesCompleteInputSnapshot.mjs +4 -4
  185. package/lib/core/transform/validation/matchesCompleteInputSnapshot.mjs.map +1 -1
  186. package/lib/core/transform/validation/matchesNarrowPersistentInputs.d.cts +2 -1
  187. package/lib/core/transform/validation/matchesNarrowPersistentInputs.d.mts +2 -1
  188. package/lib/core/transform/validation/matchesNarrowPersistentInputs.d.ts +2 -1
  189. package/lib/core/transform/validation/matchesNarrowPersistentInputs.js +2 -2
  190. package/lib/core/transform/validation/matchesNarrowPersistentInputs.js.map +1 -1
  191. package/lib/core/transform/validation/matchesNarrowPersistentInputs.mjs +2 -2
  192. package/lib/core/transform/validation/matchesNarrowPersistentInputs.mjs.map +1 -1
  193. package/lib/core/transform/validation/matchesUniversalHostInputTrees.d.cts +3 -2
  194. package/lib/core/transform/validation/matchesUniversalHostInputTrees.d.mts +3 -2
  195. package/lib/core/transform/validation/matchesUniversalHostInputTrees.d.ts +3 -2
  196. package/lib/core/transform/validation/matchesUniversalHostInputTrees.js +7 -5
  197. package/lib/core/transform/validation/matchesUniversalHostInputTrees.js.map +1 -1
  198. package/lib/core/transform/validation/matchesUniversalHostInputTrees.mjs +7 -5
  199. package/lib/core/transform/validation/matchesUniversalHostInputTrees.mjs.map +1 -1
  200. package/lib/core/transform/validation/matchesUniversalHostInputs.d.cts +3 -2
  201. package/lib/core/transform/validation/matchesUniversalHostInputs.d.mts +3 -2
  202. package/lib/core/transform/validation/matchesUniversalHostInputs.d.ts +3 -2
  203. package/lib/core/transform/validation/matchesUniversalHostInputs.js +5 -5
  204. package/lib/core/transform/validation/matchesUniversalHostInputs.js.map +1 -1
  205. package/lib/core/transform/validation/matchesUniversalHostInputs.mjs +5 -5
  206. package/lib/core/transform/validation/matchesUniversalHostInputs.mjs.map +1 -1
  207. package/lib/core/transform/validation/nativeInputPredicatesHold.d.cts +5 -4
  208. package/lib/core/transform/validation/nativeInputPredicatesHold.d.mts +5 -4
  209. package/lib/core/transform/validation/nativeInputPredicatesHold.d.ts +5 -4
  210. package/lib/core/transform/validation/nativeInputPredicatesHold.js +31 -12
  211. package/lib/core/transform/validation/nativeInputPredicatesHold.js.map +1 -1
  212. package/lib/core/transform/validation/nativeInputPredicatesHold.mjs +31 -12
  213. package/lib/core/transform/validation/nativeInputPredicatesHold.mjs.map +1 -1
  214. package/lib/core/transform/validation/notificationsProveProgramUnchanged.d.cts +2 -1
  215. package/lib/core/transform/validation/notificationsProveProgramUnchanged.d.mts +2 -1
  216. package/lib/core/transform/validation/notificationsProveProgramUnchanged.d.ts +2 -1
  217. package/lib/core/transform/validation/notificationsProveProgramUnchanged.js +2 -2
  218. package/lib/core/transform/validation/notificationsProveProgramUnchanged.js.map +1 -1
  219. package/lib/core/transform/validation/notificationsProveProgramUnchanged.mjs +2 -2
  220. package/lib/core/transform/validation/notificationsProveProgramUnchanged.mjs.map +1 -1
  221. package/lib/core/transform/watch/captureWatchInputBaseline.d.cts +4 -0
  222. package/lib/core/transform/watch/captureWatchInputBaseline.d.mts +4 -0
  223. package/lib/core/transform/watch/captureWatchInputBaseline.d.ts +4 -0
  224. package/lib/core/transform/watch/captureWatchInputBaseline.js +3 -0
  225. package/lib/core/transform/watch/captureWatchInputBaseline.js.map +1 -1
  226. package/lib/core/transform/watch/captureWatchInputBaseline.mjs +3 -0
  227. package/lib/core/transform/watch/captureWatchInputBaseline.mjs.map +1 -1
  228. package/lib/core/transform/watch/captureWatchInputBaselines.d.cts +2 -0
  229. package/lib/core/transform/watch/captureWatchInputBaselines.d.mts +2 -0
  230. package/lib/core/transform/watch/captureWatchInputBaselines.d.ts +2 -0
  231. package/lib/core/transform/watch/captureWatchInputBaselines.js +3 -1
  232. package/lib/core/transform/watch/captureWatchInputBaselines.js.map +1 -1
  233. package/lib/core/transform/watch/captureWatchInputBaselines.mjs +3 -1
  234. package/lib/core/transform/watch/captureWatchInputBaselines.mjs.map +1 -1
  235. package/lib/core/transform/watch/notifyWatchInputs.js +3 -0
  236. package/lib/core/transform/watch/notifyWatchInputs.js.map +1 -1
  237. package/lib/core/transform/watch/notifyWatchInputs.mjs +3 -0
  238. package/lib/core/transform/watch/notifyWatchInputs.mjs.map +1 -1
  239. package/lib/core/transform/watch/watchInputEvidenceMatchesDisk.d.cts +5 -2
  240. package/lib/core/transform/watch/watchInputEvidenceMatchesDisk.d.mts +5 -2
  241. package/lib/core/transform/watch/watchInputEvidenceMatchesDisk.d.ts +5 -2
  242. package/lib/core/transform/watch/watchInputEvidenceMatchesDisk.js +6 -3
  243. package/lib/core/transform/watch/watchInputEvidenceMatchesDisk.js.map +1 -1
  244. package/lib/core/transform/watch/watchInputEvidenceMatchesDisk.mjs +6 -3
  245. package/lib/core/transform/watch/watchInputEvidenceMatchesDisk.mjs.map +1 -1
  246. package/lib/core/turbopack/turbopack.js +2 -1
  247. package/lib/core/turbopack/turbopack.js.map +1 -1
  248. package/lib/core/turbopack/turbopack.mjs +2 -1
  249. package/lib/core/turbopack/turbopack.mjs.map +1 -1
  250. package/package.json +3 -3
  251. package/src/core/bridge/projectRecordMoved.ts +3 -1
  252. package/src/core/bun/bun.ts +8 -4
  253. package/src/core/observer/createInputObserver.ts +8 -5
  254. package/src/core/observer/openIsolatedRecursiveWatch.ts +11 -12
  255. package/src/core/transform/cache/TtscCachedProjectTransform.ts +13 -3
  256. package/src/core/transform/cache/selectCachedGenerationAction.ts +9 -1
  257. package/src/core/transform/deliverCachedTransform.ts +97 -0
  258. package/src/core/transform/envelope/selectDeclaredProjectInputKeys.ts +5 -2
  259. package/src/core/transform/envelope/selectExternalInputPaths.ts +7 -7
  260. package/src/core/transform/filesystem/TtscTransformFilesystemOperations.ts +15 -12
  261. package/src/core/transform/generation/captureFailedGenerationInputStates.ts +1 -0
  262. package/src/core/transform/generation/captureTransformGeneration.ts +6 -1
  263. package/src/core/transform/generation/failedGenerationEnvironmentChanged.ts +12 -2
  264. package/src/core/transform/generation/selectTransformAttemptDisposition.ts +3 -1
  265. package/src/core/transform/generation/transformProject.ts +13 -9
  266. package/src/core/transform/inputs/pluginSourceFilesDigest.ts +11 -4
  267. package/src/core/transform/inputs/pluginSourceHolds.ts +13 -3
  268. package/src/core/transform/inputs/pluginSourceState.ts +8 -2
  269. package/src/core/transform/inputs/preparePluginBuildEnvironments.ts +64 -11
  270. package/src/core/transform/tracker/broker/WatchBroker.ts +15 -4
  271. package/src/core/transform/tracker/broker/WatchBrokerTransport.ts +82 -0
  272. package/src/core/transform/tracker/broker/drainWatchBroker.ts +12 -13
  273. package/src/core/transform/tracker/broker/getWatchBroker.ts +89 -18
  274. package/src/core/transform/tracker/broker/openBrokeredWatch.ts +11 -14
  275. package/src/core/transform/tracker/broker/usesWatchBroker.ts +7 -7
  276. package/src/core/transform/tracker/broker/watchBrokerSource.ts +10 -11
  277. package/src/core/transform/transformTtsc.ts +38 -92
  278. package/src/core/transform/validation/TtscGenerationProof.ts +201 -0
  279. package/src/core/transform/validation/captureUniversalHostInputValidation.ts +2 -1
  280. package/src/core/transform/validation/matchesCachedSource.ts +27 -21
  281. package/src/core/transform/validation/matchesCompleteInputSnapshot.ts +5 -3
  282. package/src/core/transform/validation/matchesNarrowPersistentInputs.ts +3 -1
  283. package/src/core/transform/validation/matchesUniversalHostInputTrees.ts +8 -3
  284. package/src/core/transform/validation/matchesUniversalHostInputs.ts +6 -4
  285. package/src/core/transform/validation/nativeInputPredicatesHold.ts +36 -14
  286. package/src/core/transform/validation/notificationsProveProgramUnchanged.ts +3 -1
  287. package/src/core/transform/watch/captureWatchInputBaseline.ts +4 -0
  288. package/src/core/transform/watch/captureWatchInputBaselines.ts +7 -1
  289. package/src/core/transform/watch/notifyWatchInputs.ts +3 -0
  290. package/src/core/transform/watch/watchInputEvidenceMatchesDisk.ts +12 -2
  291. package/src/core/turbopack/turbopack.ts +2 -1
@@ -64,18 +64,20 @@ import { selectTransformAttemptDisposition } from "./selectTransformAttemptDispo
64
64
  * (samchon/ttsc#1545).
65
65
  *
66
66
  * A local success whose only lost premise is explicitly unavailable host
67
- * observation may qualify for its initiating delivery. The delivery coordinator
68
- * additionally requires an explicitly nonwatching host with cache-withdrawal
69
- * capability. It remains incomplete and cannot authorize resident, shared or
70
- * persistent caching. Actual changes, conflicts and unexplained missing proof
71
- * retain the stabilization gate.
67
+ * observation may qualify for local delivery. TtscGenerationProof additionally
68
+ * requires an explicitly nonwatching host and actual cache withdrawal for every
69
+ * delivery. It alone can share recorded first-module baselines inside the same
70
+ * explicit pass. This incomplete result cannot authorize ordinary resident
71
+ * reuse, a persistent project record or shared publication; repeated modules
72
+ * and later passes recapture. Actual changes, conflicts and unexplained missing
73
+ * proof retain the stabilization gate.
72
74
  *
73
75
  * Enabled private tracing records each computed disposition before its state is
74
76
  * applied. It does not supply proof when capture throws or tracing fails.
75
77
  *
76
- * @evidence contracts/common.md#principled-implementation Each capture establishes config coherence and reusable success proof or a current diagnostic verdict; a local stable success with only explicit unavailable host observations instead transfers one fresh delivery without reuse authority, while mixed mutation, missing or conflicting proof retains retry admission.
78
+ * @evidence contracts/common.md#principled-implementation Each capture establishes config coherence and reusable success proof or a current diagnostic verdict; a local stable success with only explicit unavailable host observations instead transfers an incomplete local result whose bounded first deliveries require the common nonwatching pass owner, while mixed mutation, missing or conflicting proof retains retry admission.
77
79
  * @evidence contracts/common.md#clear-and-simple-design The pure attempt policy selects acceptance and retry budgets; this loop owns mutable learned facts and resource handoff, capture owns proof construction, and the shared error builder owns terminal rendering and final disposal.
78
- * @evidence contracts/common.md#prohibited-implementation-shortcuts Retrying follows learned dependencies/case policy or refuted publication payload rather than an endless workaround chain; only lossless producer-authorized observation unavailability can permit a local fresh answer, and it never becomes a reusable success or excuses actual mutation.
80
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Retrying follows learned dependencies/case policy or refuted publication payload rather than an endless workaround chain; only lossless producer-authorized observation unavailability can permit a local fresh answer, and it never becomes complete or persistent/shared success proof or excuses actual mutation.
79
81
  * @evidence contracts/common.md#meaningful-documentation Native paragraphs explain movement versus absolute budgets, failed-compile diagnostics and learned facts; separated props state delivery, tracking and inherited witness meaning.
80
82
  * @evidence contracts/portability.md#os-neutral-implementation Each capture delegates native filesystem and compiler behavior to injected host boundaries; reported compiler case policy is carried between attempts rather than guessed from OS names.
81
83
  * @evidence contracts/performance.md#efficient-algorithms At most four captures bound retry count, not each capture's project/config/input bytes, native walks, compiler/plugin work, observer setup or session waiting time. Each rejected attempt copies the cumulative witnessed Set and scans its external dependencies into that copy; the next capture receives a separate array of its names; supplied spellings contribute hashing/text cost. Terminal rendering visits retained attempts/witnesses, and disposal delegates observer/probe cleanup rather than making those effects constant work. Enabled tracing serializes disposition scalars and path text through the existing bounded append sink; disabled tracing skips that payload construction.
@@ -200,10 +202,12 @@ export async function transformProject(props: {
200
202
  },
201
203
  });
202
204
  if (disposition.freshDeliveryOnly) {
203
- // Neither incomplete diagnostic observations nor a permitted local fresh
204
- // success authorizes this generation's reuse beyond its current delivery.
205
+ // Missing observations never authorize persistent or shared reuse. A
206
+ // coherent fresh-only local success may separately earn bounded first
207
+ // deliveries through the common nonwatching pass owner (#1713).
205
208
  cached.freshDeliveryOnly = true;
206
209
  }
210
+ if (disposition.kind === "fresh-only") cached.passDeliveryOnly = true;
207
211
  if (disposition.kind === "accepted" || disposition.kind === "fresh-only") {
208
212
  return cached;
209
213
  }
@@ -1,7 +1,7 @@
1
1
  import path from "node:path";
2
2
  import {
3
- pluginSourceDigest,
4
3
  pluginSourceFilesSignature,
4
+ provenPluginSourceDigest,
5
5
  } from "ttsc/plugin-source";
6
6
 
7
7
  import { DEFAULT_FILESYSTEM_OPERATIONS } from "../filesystem/DEFAULT_FILESYSTEM_OPERATIONS";
@@ -24,9 +24,15 @@ import { inputMetadataEvidence } from "./inputMetadataEvidence";
24
24
  * historical-directory eviction or owner partition and can grow with distinct
25
25
  * directory spellings.
26
26
  *
27
- * @param directory The source directory.
27
+ * @param directory The source directory. WARNING (samchon/ttsc#1725): the map
28
+ * below ends with the process, and every bundler worker or restart is a new
29
+ * one, so each first proof read every plugin source byte again (0.35 s for
30
+ * typia's Go module). A caller that names its project takes a miss's digest
31
+ * from that project's plugin cache records, which the load that reported the
32
+ * state wrote.
28
33
  * @param filesystem The operations whose clock reference the caller refreshed
29
34
  * (`refreshFilesystemClockReference`), which decides separability.
35
+ * @param projectRoot Project whose plugin cache root holds the records.
30
36
  * @throws When a listed file cannot be read, as `pluginSourceDigest` does.
31
37
  * @evidence contracts/common.md#principled-implementation The build's exact file selector signs names and metadata around a fresh byte digest; matching separable signatures permit reuse only under the same native source-tree and refreshed-clock premises.
32
38
  * @evidence contracts/common.md#clear-and-simple-design This coordinator owns the directory digest entry while ttsc owns selection and byte hashing and inputMetadataEvidence owns stamp interpretation.
@@ -34,12 +40,13 @@ import { inputMetadataEvidence } from "./inputMetadataEvidence";
34
40
  * @evidence contracts/common.md#meaningful-documentation Native paragraphs explain population invalidation, before/after proof, fresh clock ordering, native-view assumptions and unbounded retained entries, with separated tags following documentation guidance.
35
41
  * @evidence contracts/portability.md#os-neutral-implementation OS-neutral native source paths use Node resolution and ttsc's native selector; injected metadata must observe those paths. A different filesystem view or path dialect is not supported by the native enumeration/read calls here.
36
42
  * @evidence contracts/performance.md#efficient-algorithms Reuse still enumerates and stats F files; a miss performs two metadata walks and one O(B) byte digest. Selection sorts its population, and temporary storage follows the file list and largest file buffer.
37
- * @evidence contracts/performance.md#reuse-equivalent-work All calls share DIGESTS by resolved directory spelling; current separable metadata must match the signature recorded around the producer read. The key does not partition filesystem owners, so sharing assumes one native source view.
43
+ * @evidence contracts/performance.md#reuse-equivalent-work All calls share DIGESTS by resolved directory spelling; current separable metadata must match the signature recorded around the producer read. The key does not partition filesystem owners, so sharing assumes one native source view. A miss of a caller naming its project takes the digest the load recorded in that project's plugin cache, across processes.
38
44
  * @evidence contracts/performance.md#bound-retention-and-release-resources DIGESTS is module-owned and retains one digest/signature per encountered key until failed stabilization deletes that key or the process ends; no historical-directory bound or explicit teardown currently exists.
39
45
  */
40
46
  export function pluginSourceFilesDigest(
41
47
  directory: string,
42
48
  filesystem: TtscTransformFilesystemOperations = DEFAULT_FILESYSTEM_OPERATIONS,
49
+ projectRoot?: string,
43
50
  ): string {
44
51
  const key = path.resolve(directory);
45
52
  /**
@@ -56,7 +63,7 @@ export function pluginSourceFilesDigest(
56
63
  ) {
57
64
  return known.digest;
58
65
  }
59
- const digest = pluginSourceDigest(key);
66
+ const digest = provenPluginSourceDigest(key, projectRoot);
60
67
  const after = pluginSourceFilesSignature(key, evidence);
61
68
  if (
62
69
  before !== undefined &&
@@ -26,13 +26,15 @@ import { pluginSourceFilesDigest } from "./pluginSourceFilesDigest";
26
26
  * @param state The state the envelope, a record, or a capture recorded.
27
27
  * @param filesystem The operations whose clock reference the caller refreshed.
28
28
  * @param prepared Optional already-qualified native environment authority.
29
+ * @param projectRoot Project whose plugin cache records prove the sources and
30
+ * the SDK in a new process (samchon/ttsc#1725).
29
31
  * @evidence contracts/common.md#principled-implementation Source-state equality uses ttsc's build-key composition. Synchronous clients retain mismatch-triggered environment refresh; async clients supply current native authority and own fresh preparation separately. Unavailable source or prepared environment rejects proof.
30
32
  * @evidence contracts/common.md#clear-and-simple-design This adapter supplies a proven source digest to the shared state comparator, keeping environment composition and refresh in ttsc's owner.
31
33
  * @evidence contracts/common.md#prohibited-implementation-shortcuts The fresh environment comparison corrects an actual stale environment witness; unreadable source is not hidden by expected state exceptions or perpetual compensating retries.
32
34
  * @evidence contracts/common.md#meaningful-documentation Native paragraphs explain source versus environment proof, failure semantics and refreshed-clock parameters, followed by separated tags under documentation guidance.
33
35
  * @evidence contracts/portability.md#os-neutral-implementation OS-neutral source/environment comparison uses the build's native boundaries. Injected metadata must describe that same native source tree; arbitrary foreign-filesystem views are not established by this adapter.
34
36
  * @evidence contracts/performance.md#efficient-algorithms One proven source digest serves either the supplied-environment comparison or both synchronous environment comparisons; file work is delegated to the digest owner.
35
- * @evidence contracts/performance.md#reuse-equivalent-work Metadata-proven source digests and current native environment witnesses qualify reuse; async preparation and synchronous mismatch refresh remain distinct owning paths.
37
+ * @evidence contracts/performance.md#reuse-equivalent-work Metadata-proven source digests and current native environment witnesses qualify reuse; async preparation and synchronous mismatch refresh remain distinct owning paths. A named project lets the source and SDK readings come from its plugin cache records across processes.
36
38
  * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources This comparison acquires no retained source cache or native handle; digest storage and process-environment retention have separate owners.
37
39
  */
38
40
  export function pluginSourceHolds(
@@ -40,9 +42,14 @@ export function pluginSourceHolds(
40
42
  state: string,
41
43
  filesystem: TtscTransformFilesystemOperations = DEFAULT_FILESYSTEM_OPERATIONS,
42
44
  prepared?: { environment: string | undefined },
45
+ projectRoot?: string,
43
46
  ): boolean {
44
47
  try {
45
- const sourceDigest = pluginSourceFilesDigest(directory, filesystem);
48
+ const sourceDigest = pluginSourceFilesDigest(
49
+ directory,
50
+ filesystem,
51
+ projectRoot,
52
+ );
46
53
  if (prepared !== undefined)
47
54
  return (
48
55
  prepared.environment !== undefined &&
@@ -51,7 +58,10 @@ export function pluginSourceHolds(
51
58
  sourceDigest,
52
59
  }) === state
53
60
  );
54
- return pluginSourceStateHolds(directory, state, { sourceDigest });
61
+ return pluginSourceStateHolds(directory, state, {
62
+ projectRoot,
63
+ sourceDigest,
64
+ });
55
65
  } catch {
56
66
  return false;
57
67
  }
@@ -21,6 +21,8 @@ import * as pluginSource from "ttsc/plugin-source";
21
21
  *
22
22
  * @param directory The source directory, as the envelope names it.
23
23
  * @param prepared Optional current environment prepared by the async owner.
24
+ * @param projectRoot Project whose plugin cache records prove the sources and
25
+ * the SDK in a new process (samchon/ttsc#1725).
24
26
  * @evidence contracts/common.md#principled-implementation The shared pluginSourceState composition combines source digest and build environment exactly as binary keys do, and an observation error preserves null rather than a plausible state.
25
27
  * @evidence contracts/common.md#clear-and-simple-design Capture delegates state composition to ttsc while proof callers use pluginSourceHolds for mismatch refresh; the two roles are explicit without duplicate key logic.
26
28
  * @evidence contracts/common.md#prohibited-implementation-shortcuts Missing observations cannot become hardcoded state or equal a recorded valid state through an exception branch.
@@ -33,13 +35,17 @@ import * as pluginSource from "ttsc/plugin-source";
33
35
  export function pluginSourceState(
34
36
  directory: string,
35
37
  prepared?: { environment: string | undefined },
38
+ projectRoot?: string,
36
39
  ): string | null {
37
40
  try {
38
41
  if (prepared !== undefined)
39
42
  return prepared.environment === undefined
40
43
  ? null
41
- : pluginSource.pluginSourceState(directory, prepared);
42
- return pluginSource.pluginSourceState(directory);
44
+ : pluginSource.pluginSourceState(directory, {
45
+ environment: prepared.environment,
46
+ projectRoot,
47
+ });
48
+ return pluginSource.pluginSourceState(directory, { projectRoot });
43
49
  } catch {
44
50
  return null;
45
51
  }
@@ -12,23 +12,36 @@ import { pluginSourceHolds } from "./pluginSourceHolds";
12
12
  const asyncResults = new WeakSet<object>();
13
13
 
14
14
  /**
15
- * Prepare actual plugin toolchain authority before synchronous input proofs.
15
+ * Qualify actual plugin toolchain authority before synchronous input proofs.
16
16
  * Cold Go/environment/SDK work stays off the host thread. A mismatch requests
17
17
  * one fresh native environment reading; observation failure remains unavailable
18
18
  * and the following admission or replay validator retains its failure policy. A
19
19
  * resident generation can reuse its exact proven source state while healthy
20
20
  * notifications and the still-qualified environment witness both hold. Native
21
- * environment preparation remains mandatory; source events cannot prove it.
21
+ * environment authority remains mandatory; source events cannot prove it.
22
+ *
23
+ * WARNING (#1712): yield before observing queued source changes, then qualify
24
+ * all current readings in one synchronous batch. Missing readings require an
25
+ * await and a fresh batch afterward. Source comparisons may request native
26
+ * refreshes; the caller must establish another current proof after those
27
+ * awaits. Never preserve a positive batch across an await or replay the SDK
28
+ * witness independently for every plugin and nested validator.
29
+ *
30
+ * The project root reaches ttsc's environment worker, so that isolate proves
31
+ * the Go SDK and executables from the plugin cache's records instead of reading
32
+ * 135 MB of SDK once per bundler or runtime process (samchon/ttsc#1722).
22
33
  *
23
34
  * @param cached Optional resident generation whose existing source-state and
24
35
  * environment witness may qualify source reuse. Other preparation owners
25
36
  * retain direct source comparison.
26
- * @evidence contracts/common.md#principled-implementation Every reported plugin directory prepares its actual current environment. The same result's matching manifest state can share source proof only with a healthy exact-source tracker and the environment under which that tree was proven. Otherwise this operation compares source state once and a mismatch refreshes environment authority for the following owning validator to compare again; failed preparation cannot qualify an input.
37
+ * @param projectRoot Project whose plugin cache holds those records; the
38
+ * resident generation's own root when omitted.
39
+ * @evidence contracts/common.md#principled-implementation Every reported plugin directory qualifies current environment authority; only missing readings require asynchronous preparation. The same result's matching manifest state can share source proof only with a healthy exact-source tracker and the environment under which that tree was proven. Otherwise this operation compares source state once and a mismatch refreshes environment authority for the following owning validator to compare again; failed preparation cannot qualify an input.
27
40
  * @evidence contracts/common.md#clear-and-simple-design One async boundary precedes existing synchronous generation, delivery and terminal proofs.
28
41
  * @evidence contracts/common.md#prohibited-implementation-shortcuts Missing observations stay unproved; reported binary state never substitutes for native environment preparation or source comparison.
29
42
  * @evidence contracts/common.md#meaningful-documentation Native prose identifies off-thread work, mismatch refresh and preserved downstream failure ownership.
30
43
  * @evidence contracts/portability.md#os-neutral-implementation The same native toolchain/environment reader and caller filesystem source digest qualify each directory without platform guesses.
31
- * @evidence contracts/performance.md#efficient-algorithms The envelope selector builds its directory map once per result, and preparation visits each reported directory once. Environment requests build keys from effective variables and qualify native dependencies. A qualified source witness avoids enumeration; other source comparisons enumerate and sort files, check metadata and hash bytes when the digest cannot be reused. A mismatch requests one environment refresh rather than a second source comparison here.
44
+ * @evidence contracts/performance.md#efficient-algorithms The envelope selector indexes directories once per result. Linear directory passes batch-qualify current readings, prepare missing authority, compare source state and refresh mismatches. Each synchronous batch hashes variables once and shares distinct native dependencies; any preparation await requires another current batch. A qualified source witness avoids enumeration; other source comparisons enumerate and sort files, check metadata and hash bytes when the digest cannot be reused. A mismatch requests one environment refresh rather than a second source comparison here.
32
45
  * @evidence contracts/performance.md#reuse-equivalent-work The environment owner shares equivalent in-flight requests and still-qualified readings. Resident source proof is reused only for the exact result and manifest digest, unchanged qualified environment and currently healthy covered source notifications; absent, dirty, replaced or unavailable witnesses retain direct proof. No epoch or quiet watcher alone authorizes reuse, and subsequent admission still owns its current validation.
33
46
  * @evidence contracts/performance.md#bound-retention-and-release-resources This module records asynchronous execution ownership in a WeakSet before preparation, including failures, so disposed results are not retained. Requests and worker lifetimes remain with the environment owner; this sequential operation awaits each request and acquires no native observer or independent cancellation handle.
34
47
  */
@@ -36,12 +49,37 @@ export async function preparePluginBuildEnvironments(
36
49
  result: TtscCachedProjectTransform["result"],
37
50
  filesystem: TtscTransformFilesystemOperations,
38
51
  cached?: TtscCachedProjectTransform,
52
+ projectRoot: string | undefined = cached?.projectRoot,
39
53
  ): Promise<void> {
40
54
  asyncResults.add(result);
41
- for (const [directory, state] of selectPluginSourceInputs(result)) {
55
+ const sources = selectPluginSourceInputs(result);
56
+ // Preserve the async preparation boundary even for warm environments.
57
+ // Events queued by the caller before awaiting preparation must participate
58
+ // in the source witness below. Observe the batch after this yield, never
59
+ // carry a positive environment observation across it (#1712).
60
+ await Promise.resolve();
61
+ const current = PluginBuildEnvironmentReadings.cachedAll(sources.keys());
62
+ let awaited = false;
63
+ for (const directory of sources.keys()) {
64
+ if (current.get(directory) !== undefined) continue;
65
+ awaited = true;
66
+ try {
67
+ await PluginBuildEnvironmentReadings.prepare(
68
+ directory,
69
+ false,
70
+ projectRoot,
71
+ );
72
+ } catch {
73
+ // Keep unavailable authority for admission rather than cold fallback.
74
+ }
75
+ }
76
+ const environments = awaited
77
+ ? PluginBuildEnvironmentReadings.cachedAll(sources.keys())
78
+ : current;
79
+ const refresh: string[] = [];
80
+ for (const [directory, state] of sources) {
42
81
  try {
43
- await PluginBuildEnvironmentReadings.prepare(directory);
44
- const environment = PluginBuildEnvironmentReadings.cached(directory);
82
+ const environment = environments.get(directory);
45
83
  if (
46
84
  cached?.result === result &&
47
85
  cached.hostInputValidation?.trees.get(directory) === state &&
@@ -52,16 +90,31 @@ export async function preparePluginBuildEnvironments(
52
90
  )
53
91
  continue;
54
92
  if (
55
- !pluginSourceHolds(directory, state, filesystem, {
56
- environment,
57
- })
93
+ !pluginSourceHolds(
94
+ directory,
95
+ state,
96
+ filesystem,
97
+ { environment },
98
+ projectRoot,
99
+ )
58
100
  )
59
- await PluginBuildEnvironmentReadings.prepare(directory, true);
101
+ refresh.push(directory);
60
102
  } catch {
61
103
  // Admission and terminal recovery interpret unavailable proof in their
62
104
  // own domain; this boundary never upgrades it to a successful reading.
63
105
  }
64
106
  }
107
+ for (const directory of refresh) {
108
+ try {
109
+ await PluginBuildEnvironmentReadings.prepare(
110
+ directory,
111
+ true,
112
+ projectRoot,
113
+ );
114
+ } catch {
115
+ // Synchronous admission requalifies after this asynchronous window.
116
+ }
117
+ }
65
118
  }
66
119
 
67
120
  /**
@@ -6,10 +6,11 @@ import type { WatchBrokerRegistration } from "./WatchBrokerRegistration";
6
6
  * The live state of the isolated watch process.
7
7
  *
8
8
  * The broker multiplexes every Windows and macOS watch of the process over one
9
- * IPC channel, a tracker's and an input observer's scope's alike. Registrations
10
- * and drains are counted so the channel is referenced only while a reply is
11
- * outstanding, and each registration keeps the sink its messages go to and the
12
- * spelling map that translates the child's canonical paths back to its own.
9
+ * ordered transport, a tracker's and an input observer's scope's alike. Windows
10
+ * uses the native helper's stdio; macOS uses Node IPC. Registrations and drains
11
+ * are counted so the channel is referenced only while a reply is outstanding,
12
+ * and each registration keeps the sink its messages go to and the spelling map
13
+ * that translates the child's canonical paths back to its own.
13
14
  *
14
15
  * @evidence contracts/common.md#principled-implementation
15
16
  * Registration and request ids distinguish multiplexed owners; drain scopes
@@ -38,6 +39,16 @@ export interface WatchBroker {
38
39
  /** The isolated watch process; unreferenced whenever no reply is outstanding. */
39
40
  child: ChildProcess;
40
41
 
42
+ /**
43
+ * Native stdio transport on Windows; absent for the macOS IPC broker and
44
+ * explicit test transports.
45
+ */
46
+ transport?: {
47
+ send(message: unknown): boolean;
48
+ reference(active: boolean): void;
49
+ close(): void;
50
+ };
51
+
41
52
  /**
42
53
  * Round-trips awaiting the child's reply, by request id, each released with
43
54
  * whether the child answered it.
@@ -0,0 +1,82 @@
1
+ import type { WatchBroker } from "./WatchBroker";
2
+
3
+ /**
4
+ * Common lifecycle seam for the native Windows stdio broker and macOS IPC.
5
+ *
6
+ * The transport owns framing and demand references only. Ordered native
7
+ * notifications and per-registration readiness remain backend responsibilities;
8
+ * a successful send cannot certify coverage or cache reuse.
9
+ *
10
+ * @evidence contracts/common.md#principled-implementation One transport seam preserves explicit failure and reference ownership for both supported broker backends.
11
+ * @evidence contracts/common.md#clear-and-simple-design Callers express send, demand and retirement through this namespace instead of duplicating platform checks or modifying a ChildProcess.
12
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Supported child streams and IPC APIs are used without replacing runtime methods.
13
+ * @evidence contracts/common.md#meaningful-documentation Native prose separates transport completion from native watch authority.
14
+ * @evidence contracts/portability.md#os-neutral-implementation Native selection stays at broker startup; all tracker and observer consumers share these operations.
15
+ * @evidenceExclude contracts/performance.md#efficient-algorithms Member operations own their delegated cost.
16
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work The broker owner selects transport and sharing lifetime.
17
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources This namespace itself retains no transport registry.
18
+ */
19
+ export namespace WatchBrokerTransport {
20
+ /**
21
+ * Queue a message on the selected transport. False refuses delivery; true
22
+ * only means queued, with actual acknowledgment or failure still
23
+ * outstanding.
24
+ *
25
+ * @evidence contracts/common.md#principled-implementation Native and IPC transports preserve separate queue acceptance and observed backend replies.
26
+ * @evidence contracts/common.md#clear-and-simple-design One selection delegates framing to the startup-owned transport.
27
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts No queue result is upgraded into readiness or a native drain.
28
+ * @evidence contracts/common.md#meaningful-documentation Native prose states the limited meaning of the returned boolean.
29
+ * @evidence contracts/portability.md#os-neutral-implementation Explicit stdio capability takes precedence over optional IPC.
30
+ * @evidence contracts/performance.md#efficient-algorithms Transport selection is fixed work; JSON framing, message bytes and pipe backpressure belong to the selected sender.
31
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work Sending an effect does not own computation reuse.
32
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources The selected sender and request owner retain queued bytes and outstanding acknowledgment state.
33
+ */
34
+ export function send(broker: WatchBroker, message: unknown): boolean {
35
+ return broker.transport === undefined
36
+ ? broker.child.send?.(message as object) === true
37
+ : broker.transport.send(message);
38
+ }
39
+
40
+ /**
41
+ * Keep the selected reply channel live exactly while caller demand exists.
42
+ * Counts belong to registration/drain owners; native references are flags.
43
+ *
44
+ * @evidence contracts/common.md#principled-implementation Outstanding requests retain both process and reply channel, preventing host exit before acknowledgment.
45
+ * @evidence contracts/common.md#clear-and-simple-design One operation applies the caller's aggregated demand to either transport.
46
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Optional Bun IPC methods are used as capabilities without installing replacements.
47
+ * @evidence contracts/common.md#meaningful-documentation Native prose identifies count ownership and flag semantics.
48
+ * @evidence contracts/portability.md#os-neutral-implementation Optional IPC methods and a selected native pipe capability express runtime differences.
49
+ * @evidenceExclude contracts/performance.md#efficient-algorithms Reference toggling selects no data-processing algorithm.
50
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work This effect owns no shared computation.
51
+ * @evidence contracts/performance.md#bound-retention-and-release-resources The caller supplies aggregate demand; removing the last demand unreferences process and reply channel without asserting native termination.
52
+ */
53
+ export function reference(broker: WatchBroker, active: boolean): void {
54
+ if (broker.transport !== undefined) broker.transport.reference(active);
55
+ else if (active) {
56
+ broker.child.ref();
57
+ broker.child.channel?.ref?.();
58
+ } else {
59
+ broker.child.unref();
60
+ broker.child.channel?.unref?.();
61
+ }
62
+ }
63
+
64
+ /**
65
+ * End this broker's request stream. The last-registration owner separately
66
+ * attempts process termination; closing a channel is not proof of child
67
+ * exit.
68
+ *
69
+ * @evidence contracts/common.md#principled-implementation Channel retirement is distinct from process exit and native resource closure.
70
+ * @evidence contracts/common.md#clear-and-simple-design Startup-owned transport closes its request stream without platform checks in consumers.
71
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Supported end/disconnect operations preserve native ownership without synthetic exit acknowledgment.
72
+ * @evidence contracts/common.md#meaningful-documentation Native prose identifies the independent termination attempt and limited closure meaning.
73
+ * @evidence contracts/portability.md#os-neutral-implementation Selected stream closure and optional IPC disconnection keep platform details behind the transport seam.
74
+ * @evidenceExclude contracts/performance.md#efficient-algorithms Closing one channel selects no processing algorithm.
75
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work Retirement owns no computation reuse.
76
+ * @evidence contracts/performance.md#bound-retention-and-release-resources The selected transport ends its input; process kill and actual native cleanup remain the broker and backend's responsibilities.
77
+ */
78
+ export function close(broker: WatchBroker): void {
79
+ if (broker.transport !== undefined) broker.transport.close();
80
+ else broker.child.disconnect?.();
81
+ }
82
+ }
@@ -1,16 +1,17 @@
1
1
  import { WATCH_PROBE_TIMEOUT_MS } from "./WATCH_PROBE_TIMEOUT_MS";
2
2
  import type { WatchBroker } from "./WatchBroker";
3
+ import { WatchBrokerTransport } from "./WatchBrokerTransport";
3
4
 
4
5
  /**
5
6
  * Ask the watch broker to acknowledge, and resolve with whether it did.
6
7
  *
7
- * The child answers after two turns of its own loop, so a watch callback it had
8
- * already queued has run, and the ordered IPC channel puts every message it
9
- * sent before the reply ahead of the reply. That is the same proof an
10
- * in-process watcher gets from a macrotask turn, rather than the fixed wait
11
- * this replaces, which guessed at the crossing (samchon/ttsc#1272). On macOS
12
- * the child answers once each stream it can prove has delivered a probe, which
13
- * takes the service's latency (samchon/ttsc#1453).
8
+ * Windows answers after consuming currently queued native completions to an
9
+ * observed empty port. macOS answers once each provable stream has delivered a
10
+ * probe, including the service's latency (#1453). Ordered transport applies
11
+ * every preceding event before the reply. These are current backend frontiers,
12
+ * not atomic timestamp classification of concurrent writes. The optional direct
13
+ * fs.watch program retains its explicit two-turn frontier for protocol tests;
14
+ * it does not supply Windows production proof (#1719).
14
15
  *
15
16
  * A broker that never answers must not hold a delivery, so the wait gives up
16
17
  * after a threshold of twice the probe timeout: the child itself gives up on a
@@ -50,7 +51,7 @@ import type { WatchBroker } from "./WatchBroker";
50
51
  * Native paragraphs and parameters explain ordering, coverage, sharing and
51
52
  * false deadlines under the documentation skill.
52
53
  * @evidence contracts/portability.md#os-neutral-implementation
53
- * OS-neutral host delivery delegates Windows loop ordering and macOS stream
54
+ * OS-neutral host delivery delegates Windows completion-port drainage and macOS stream
54
55
  * probing to the native broker rather than applying one universal timing guess.
55
56
  * @evidence contracts/performance.md#efficient-algorithms
56
57
  * A covering memo query uses fixed identity/id lookup. New requests copy all N
@@ -123,8 +124,7 @@ function startWatchBrokerDrain(
123
124
  broker.drainScopes?.delete(id);
124
125
  broker.pendingDrains -= 1;
125
126
  if (broker.pendingDrains === 0 && broker.pendingRegistrations === 0) {
126
- broker.child.unref();
127
- broker.child.channel?.unref?.();
127
+ WatchBrokerTransport.reference(broker, false);
128
128
  }
129
129
  resolve(answered);
130
130
  };
@@ -134,12 +134,11 @@ function startWatchBrokerDrain(
134
134
  // the reference the loop can empty while a delivery waits here, and the
135
135
  // process exits mid-build with nothing to report.
136
136
  broker.pendingDrains += 1;
137
- broker.child.ref();
138
- broker.child.channel?.ref?.();
137
+ WatchBrokerTransport.reference(broker, true);
139
138
  const timer = setTimeout(() => release(false), timeout);
140
139
  broker.drains.set(id, release);
141
140
  (broker.drainScopes ??= new Map()).set(id, scope);
142
- if (broker.child.send?.({ id, op: "drain" }) !== true) {
141
+ if (WatchBrokerTransport.send(broker, { id, op: "drain" }) !== true) {
143
142
  release(false);
144
143
  }
145
144
  });
@@ -1,3 +1,6 @@
1
+ import readline from "node:readline";
2
+ import { resolveBinary } from "ttsc/binary";
3
+
1
4
  import { traceProcessSpawn } from "../../../tracing/traceProcessSpawn";
2
5
  import { WATCH_BROKER } from "./WATCH_BROKER";
3
6
  import type { WatchBroker } from "./WatchBroker";
@@ -13,11 +16,11 @@ import { watchBrokerSource } from "./watchBrokerSource";
13
16
  * caller-supplied watch capabilities can bypass it. Isolation has a reason on
14
17
  * each native backend:
15
18
  *
16
- * - Node's Windows fs-event backend can hit a native assertion that aborts the
17
- * whole process when a watched temporary tree is deleted. In the child that
18
- * crash becomes an ordinary exit that fails the affected trackers, and those
19
- * generations fall back to proving themselves from recorded state instead of
20
- * taking the host down.
19
+ * - Windows runs ttsc's native completion-port helper directly. Its directory
20
+ * filter excludes access-time notifications: reads must not masquerade as
21
+ * writes (#1719). Actual writes, metadata changes, native loss and failed
22
+ * coverage remain observable; equal bytes cannot erase an A-B-A event. No
23
+ * Node fs-event handle is opened in the host or an intermediate process.
21
24
  * - On macOS, libuv serves every directory watch of one event loop through a
22
25
  * single FSEventStream and re-creates it whenever any watch in that loop
23
26
  * opens or closes, losing the events in between (samchon/ttsc#1418), and it
@@ -26,10 +29,11 @@ import { watchBrokerSource } from "./watchBrokerSource";
26
29
  * passes each drop on as a gap (samchon/ttsc#1425); see
27
30
  * {@link watchBrokerSource}.
28
31
  *
29
- * Registration/drain owners unreference the child and IPC channel after their
32
+ * Registration/drain owners unreference the child and its transport after their
30
33
  * outstanding acknowledgments finish; startup itself returns a referenced
31
- * child. Last-registration closure attempts disconnection and termination. This
32
- * accessor has no independent shutdown deadline or exit wait.
34
+ * child. Last-registration closure ends the request stream and attempts
35
+ * termination. This accessor has no independent shutdown deadline or exit
36
+ * wait.
33
37
  *
34
38
  * @evidence contracts/common.md#principled-implementation
35
39
  * Native watches run in a protocol child. Error/exit dispatch reports failure
@@ -45,13 +49,15 @@ import { watchBrokerSource } from "./watchBrokerSource";
45
49
  * Native platform-reason list and lifecycle paragraph explain isolation and
46
50
  * process ownership under the documentation skill.
47
51
  * @evidence contracts/portability.md#os-neutral-implementation
48
- * OS-neutral startup uses this process's executable and argument-array spawn;
49
- * native FSEvents loading and platform differences remain in this boundary.
52
+ * Windows resolves the same ttsc binary as its compiler owner and uses the
53
+ * native __watch command; macOS uses this runtime and supported FSEvents.
54
+ * Argument-array spawn, hidden Windows processes and ordered transport stay
55
+ * inside this boundary.
50
56
  * @evidence contracts/performance.md#efficient-algorithms
51
- * A current-holder read is fixed work. Cold startup includes optional native
52
- * module resolution/warning, child source construction and native process/IPC
53
- * creation; resolution/path/source bytes and process startup cost do not
54
- * vanish into one spawn call. Failure visits R registrations and D drain
57
+ * A current-holder read is fixed work. Windows cold startup resolves the ttsc
58
+ * binary and opens native protocol pipes; macOS resolves the optional binding,
59
+ * reports missing capability and constructs its child program and IPC channel.
60
+ * Resolution/path/source bytes and native process startup cost remain real. Failure visits R registrations and D drain
55
61
  * callbacks, whose native/reference/sink work remains delegated; it does not
56
62
  * enumerate watched source trees.
57
63
  * Enabled private tracing serializes the actual executable/source argv and
@@ -63,7 +69,7 @@ import { watchBrokerSource } from "./watchBrokerSource";
63
69
  * a health certificate; binding installation changes are not re-resolved
64
70
  * while it remains current, and sink exceptions can interrupt failure handling.
65
71
  * @evidence contracts/performance.md#bound-retention-and-release-resources
66
- * One current module holder retains a child and registration/drain maps;
72
+ * One current module holder retains a direct child and registration/drain maps;
67
73
  * those populations and caller-retained retired brokers have no cap here.
68
74
  * Request owners manage references/timers, and last closure attempts native
69
75
  * disconnection/kill rather than proving exit. Completed failure routing
@@ -77,11 +83,17 @@ export function getWatchBroker(): WatchBroker {
77
83
  const fsevents =
78
84
  process.platform === "darwin" ? fseventsBindingPath() : undefined;
79
85
  if (fsevents === null) warnMissingFseventsBinding();
86
+ const native = process.platform === "win32";
87
+ const binary = native ? resolveBinary() : process.execPath;
88
+ if (binary === null)
89
+ throw new Error("No ttsc native watch helper is available");
80
90
  const child = traceProcessSpawn(
81
- process.execPath,
82
- ["-e", watchBrokerSource(fsevents)],
91
+ binary,
92
+ native ? ["__watch"] : ["-e", watchBrokerSource(fsevents)],
83
93
  {
84
- stdio: ["ignore", "ignore", "ignore", "ipc"],
94
+ stdio: native
95
+ ? ["pipe", "pipe", "ignore"]
96
+ : ["ignore", "ignore", "ignore", "ipc"],
85
97
  windowsHide: true,
86
98
  },
87
99
  );
@@ -110,6 +122,65 @@ export function getWatchBroker(): WatchBroker {
110
122
  WATCH_BROKER.current = undefined;
111
123
  }
112
124
  };
125
+ if (native) {
126
+ // All Windows registrations share one direct native child. No Node watcher,
127
+ // nested child, global runtime patch, or access-time system change is needed.
128
+ const input = child.stdin;
129
+ const output = child.stdout;
130
+ if (input === null || output === null) {
131
+ child.kill();
132
+ throw new Error("The native watch helper has no protocol pipes");
133
+ }
134
+ broker.transport = {
135
+ send(message) {
136
+ if (input.destroyed || input.writableEnded) return false;
137
+ // write(false) means buffered backpressure, not refusal. The callback
138
+ // reports a real transport failure to every still-live registration.
139
+ input.write(JSON.stringify(message) + "\n", (error) => {
140
+ if (error !== null && error !== undefined) {
141
+ fail();
142
+ child.kill();
143
+ }
144
+ });
145
+ return true;
146
+ },
147
+ reference(active) {
148
+ const pipe = output as typeof output & {
149
+ ref?: () => void;
150
+ unref?: () => void;
151
+ };
152
+ if (active) {
153
+ child.ref();
154
+ pipe.ref?.();
155
+ } else {
156
+ child.unref();
157
+ pipe.unref?.();
158
+ }
159
+ },
160
+ close() {
161
+ input.end();
162
+ },
163
+ };
164
+ const lost = (): void => {
165
+ fail();
166
+ child.kill();
167
+ };
168
+ input.on("error", lost);
169
+ output.on("error", lost);
170
+ output.on("end", lost);
171
+ readline
172
+ .createInterface({ input: output, crlfDelay: Infinity })
173
+ .on("line", (line) => {
174
+ let message: unknown;
175
+ try {
176
+ message = JSON.parse(line) as unknown;
177
+ } catch {
178
+ lost();
179
+ return;
180
+ }
181
+ routeWatchBrokerMessage(broker, message);
182
+ });
183
+ }
113
184
  child.on("error", fail);
114
185
  child.on("exit", fail);
115
186
  child.on("message", (message: unknown) =>