@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
@@ -7,6 +7,7 @@ import { WATCH_PROBE_DIRECTORY_PREFIX } from "./WATCH_PROBE_DIRECTORY_PREFIX";
7
7
  import { WATCH_PROBE_TIMEOUT_MS } from "./WATCH_PROBE_TIMEOUT_MS";
8
8
  import type { WatchBrokerLocation } from "./WatchBrokerLocation";
9
9
  import type { WatchBrokerSink } from "./WatchBrokerSink";
10
+ import { WatchBrokerTransport } from "./WatchBrokerTransport";
10
11
  import { drainWatchBroker } from "./drainWatchBroker";
11
12
  import { getWatchBroker } from "./getWatchBroker";
12
13
  import { probeForLocation } from "./probeForLocation";
@@ -16,11 +17,11 @@ import { sweepAbandonedWatchProbes } from "./sweepAbandonedWatchProbes";
16
17
  * Open directory watches in the isolated watch process for one sink, and report
17
18
  * when they hear.
18
19
  *
19
- * On Windows, Node's fs-event backend can assert in native code when a watched
20
- * temporary tree is deleted. Isolation turns that unrecoverable process abort
21
- * into an ordinary broker exit and a conservative fallback in the host. On
22
- * macOS, each registration's watches are streams of their own, started before
23
- * the child reports ready, and a dropped event reaches the sink as a gap
20
+ * On Windows, ttsc's native helper owns completion-port directory subscriptions
21
+ * and omits access-only notifications (#1719). Native loss and failure withdraw
22
+ * coverage; actual change events remain authoritative even after A-B-A writes.
23
+ * On macOS, each registration's watches are streams of their own, started
24
+ * before the child reports ready, and a dropped event reaches the sink as a gap
24
25
  * (samchon/ttsc#1425). A stream that can be probed reports ready only once its
25
26
  * opening probe came back through it; the child suppresses ordinary callbacks
26
27
  * received before that probe. This is its backend protocol, not a guarantee
@@ -143,10 +144,7 @@ export function openBrokeredWatch(
143
144
  };
144
145
  });
145
146
  broker.pendingRegistrations += 1;
146
- broker.child.ref();
147
- // Bun's IPC channel omits Node's Control.ref/unref methods. The child itself
148
- // still owns the outstanding acknowledgement on that runtime.
149
- broker.child.channel?.ref?.();
147
+ WatchBrokerTransport.reference(broker, true);
150
148
  const id = broker.nextId++;
151
149
  let resolveReady!: () => void;
152
150
  const answered = new Promise<void>((resolve) => {
@@ -166,7 +164,7 @@ export function openBrokeredWatch(
166
164
  let failed = false;
167
165
  let failure: unknown;
168
166
  try {
169
- broker.child.send?.({ id, op: "remove" });
167
+ WatchBrokerTransport.send(broker, { id, op: "remove" });
170
168
  } catch (error) {
171
169
  failed = true;
172
170
  failure = error;
@@ -176,7 +174,7 @@ export function openBrokeredWatch(
176
174
  WATCH_BROKER.current = undefined;
177
175
  }
178
176
  try {
179
- broker.child.disconnect?.();
177
+ WatchBrokerTransport.close(broker);
180
178
  } catch (error) {
181
179
  if (!failed) {
182
180
  failed = true;
@@ -194,7 +192,7 @@ export function openBrokeredWatch(
194
192
  }
195
193
  if (failed) throw failure;
196
194
  };
197
- broker.child.send?.({
195
+ WatchBrokerTransport.send(broker, {
198
196
  allEvents: options.allEvents,
199
197
  locations: normalized,
200
198
  id,
@@ -226,8 +224,7 @@ export function openBrokeredWatch(
226
224
  // a reply over an unreferenced channel lets the loop empty and the process
227
225
  // exit mid-build.
228
226
  if (broker.pendingRegistrations === 0 && broker.pendingDrains === 0) {
229
- broker.child.unref();
230
- broker.child.channel?.unref?.();
227
+ WatchBrokerTransport.reference(broker, false);
231
228
  }
232
229
  });
233
230
  return {
@@ -4,13 +4,13 @@ import type { TtscTransformFilesystemOperations } from "../../filesystem/TtscTra
4
4
  * Whether a tracker over `filesystem` opens its watches in the isolated watch
5
5
  * broker rather than in this process.
6
6
  *
7
- * The host filesystem on Windows and macOS does: Windows so that a native
8
- * fs-event abort cannot take the host down, and macOS so that each watch is its
9
- * own FSEventStream, whose dropped events are reported, rather than one libuv
10
- * re-creates whenever any watch in the host opens or closes, and whose drops it
11
- * discards (samchon/ttsc#1418, samchon/ttsc#1425). An embedder that supplies
12
- * its own `watch` retains that capability, including for a host-filesystem
13
- * view.
7
+ * The host filesystem on Windows and macOS does: Windows so that native
8
+ * mutation filters exclude access-time noise without a Node fs-event handle,
9
+ * and macOS so that each watch is its own FSEventStream, whose dropped events
10
+ * are reported, rather than one libuv re-creates whenever any watch in the host
11
+ * opens or closes, and whose drops it discards (samchon/ttsc#1418,
12
+ * samchon/ttsc#1425). An embedder that supplies its own `watch` retains that
13
+ * capability, including for a host-filesystem view.
14
14
  *
15
15
  * @evidence contracts/common.md#principled-implementation
16
16
  * A supplied filesystem watcher is authoritative; only the native host
@@ -8,13 +8,10 @@ import { WATCH_PROBE_TIMEOUT_MS } from "./WATCH_PROBE_TIMEOUT_MS";
8
8
  * frontier described below; a reply alone does not certify every scope, since
9
9
  * probe-dependent streams can be named unproven and gaps withdraw authority.
10
10
  *
11
- * On Windows the watches are `fs.watch`. A drain yields through two immediate
12
- * turns to allow the loop to poll and deliver queued callbacks before replying.
13
- * The real Windows scenario checks two hundred synchronous write/drain pairs;
14
- * the scripted unit checks this scheduling boundary separately. These checks
15
- * are not a universal kernel-order proof: FIFO completion-port queueing alone
16
- * does not guarantee dequeue order or establish when notification completion
17
- * becomes observable relative to a write and IPC request.
11
+ * Windows production registrations use ttsc's native helper, not this program
12
+ * (#1719). The optional fs.watch backend remains an explicit direct program
13
+ * capability used by its scripted protocol tests; it never supplies Windows
14
+ * production cache proof. Its drain yields through two immediate turns.
18
15
  *
19
16
  * On macOS the watches go through the `fsevents` binding, one FSEventStream per
20
17
  * location, instead of relying on `fs.watch` for stream and loss authority
@@ -59,11 +56,13 @@ import { WATCH_PROBE_TIMEOUT_MS } from "./WATCH_PROBE_TIMEOUT_MS";
59
56
  * The child protocol keeps per-registration streams and ordered drains;
60
57
  * macOS proof requires clean probe delivery. Loss flags withdraw coverage
61
58
  * before probe recognition, so matching a probe name cannot erase that warning.
62
- * The Windows two-turn frontier retains its runtime/backend ordering premise;
59
+ * The optional fs.watch two-turn frontier retains its runtime/backend ordering premise;
63
60
  * this source does not independently prove kernel completeness.
64
61
  * @evidence contracts/common.md#clear-and-simple-design
65
- * One maintained child program serves both native backends; this function only
66
- * injects resolved capability and the shared timeout, with JSON-safe path encoding.
62
+ * One maintained child program serves macOS and the explicitly selected
63
+ * fs.watch protocol capability; Windows production uses its native helper.
64
+ * This function injects resolved capability and the shared timeout with
65
+ * JSON-safe path encoding.
67
66
  * @evidence contracts/common.md#prohibited-implementation-shortcuts
68
67
  * Native flags and deadlines express backend contracts, not fixture-specific
69
68
  * repairs. Missing bindings and probes report uncertainty rather than silent success.
@@ -351,7 +350,7 @@ function drain(requestId) {
351
350
  entry.abandon();
352
351
  }
353
352
  }
354
- // Windows watches, and streams already proven, answer after two turns: the
353
+ // Explicit fs.watch watches, and streams already proven, answer after two turns: the
355
354
  // first lets the loop poll for completions the kernel had already queued,
356
355
  // the second answers after their callbacks.
357
356
  outstanding += 1;
@@ -10,37 +10,28 @@ import { TRANSFORM_RESULT_FILESYSTEM } from "./cache/TRANSFORM_RESULT_FILESYSTEM
10
10
  import type { TtscTransformCache } from "./cache/TtscTransformCache";
11
11
  import { awaitOrEvict } from "./cache/awaitOrEvict";
12
12
  import { createTransformCacheKey } from "./cache/createTransformCacheKey";
13
- import { disposeCachedTransform } from "./cache/disposeCachedTransform";
14
13
  import { evictGeneration } from "./cache/evictGeneration";
15
14
  import { replaysTerminalGeneration } from "./cache/replaysTerminalGeneration";
16
15
  import { selectCachedGenerationAction } from "./cache/selectCachedGenerationAction";
17
- import { selectOrEvict } from "./cache/selectOrEvict";
18
16
  import { transformCacheEpoch } from "./cache/transformCacheEpoch";
19
17
  import { transformCacheTrustsNotifications } from "./cache/transformCacheTrustsNotifications";
20
18
  import { transformFilesystem } from "./cache/transformFilesystem";
21
19
  import { withdrawGenerationNotifications } from "./cache/withdrawGenerationNotifications";
22
- import { reportMissingProgramOutput } from "./diagnostics/reportMissingProgramOutput";
23
- import { reportSuccessDiagnostics } from "./diagnostics/reportSuccessDiagnostics";
24
- import type { TtscTransformedOutput } from "./envelope/TtscTransformedOutput";
25
- import { TtscMissingProgramOutputError } from "./errors/TtscMissingProgramOutputError";
20
+ import { deliverCachedTransform } from "./deliverCachedTransform";
26
21
  import { TtscUnstableGenerationError } from "./errors/TtscUnstableGenerationError";
27
22
  import { transformProject } from "./generation/transformProject";
28
23
  import { preparePluginBuildEnvironments } from "./inputs/preparePluginBuildEnvironments";
29
24
  import { TRANSFORM_CACHE_SESSIONS } from "./session/TRANSFORM_CACHE_SESSIONS";
30
25
  import { settleProjectMutationEvents } from "./tracker/settleProjectMutationEvents";
31
26
  import { resolveProjectSelection } from "./tsconfig/resolveProjectSelection";
32
- import { createTransformResult } from "./utils/createTransformResult";
33
27
  import { isDeclarationFile } from "./utils/isDeclarationFile";
34
28
  import { isHostWrapperQuery } from "./utils/isHostWrapperQuery";
35
29
  import { pluginsAreDisabled } from "./utils/pluginsAreDisabled";
36
30
  import { stripQuery } from "./utils/stripQuery";
37
- import { markCachedSourceServed } from "./validation/markCachedSourceServed";
31
+ import { TtscGenerationProof } from "./validation/TtscGenerationProof";
38
32
  import type { TtscTransformHooks } from "./watch/TtscTransformHooks";
39
33
  import type { TtscWatchSelection } from "./watch/TtscWatchSelection";
40
- import { notifyFailedGenerationInputs } from "./watch/notifyFailedGenerationInputs";
41
34
  import { notifyRejectedGenerationInputs } from "./watch/notifyRejectedGenerationInputs";
42
- import { notifyVolatileDelivery } from "./watch/notifyVolatileDelivery";
43
- import { notifyWatchInputs } from "./watch/notifyWatchInputs";
44
35
  import { prepareProjectRecordDirectories } from "./watch/prepareProjectRecordDirectories";
45
36
 
46
37
  /**
@@ -78,7 +69,7 @@ import { prepareProjectRecordDirectories } from "./watch/prepareProjectRecordDir
78
69
  * per build, not per compilation.
79
70
  * @evidence contracts/common.md#principled-implementation Project selection and generation-qualified cache admission preserve compiler disk authority; fresh-only success additionally needs an explicit nonwatching lifecycle, coherent project declaration and actual host-cache withdrawal, because incomplete observation cannot support watch invalidation.
80
71
  * @evidence contracts/common.md#clear-and-simple-design One delivery coordinator composes project selection, cache admission, compilation, output selection and host notifications; dedicated owners handle proof and lifetime internals.
81
- * @evidence contracts/common.md#prohibited-implementation-shortcuts Wrapper modules cannot poison source baselines and incomplete generations cannot authorize reuse; a separately admitted fresh-only result is evicted before capability checks, unknown or watching lifecycles fail explicitly, and unsupported withdrawal cannot be replaced by a fake record or guessed dependency closure.
72
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Wrapper modules cannot poison source baselines; incomplete local results can share only explicitly nonwatching first deliveries in their exact pass. Unknown/watching lifecycles or unsupported withdrawal reject and evict them rather than invent persistent records or dependency closure.
82
73
  * @evidence contracts/common.md#meaningful-documentation Native paragraphs and argument tags explain project scope, no-transform outcomes, cache epochs and per-build notification responsibilities with links to maintained reference context.
83
74
  * @evidence contracts/performance.md#efficient-algorithms
84
75
  * Selection/key construction pays ancestor/config/alias/option/path text work.
@@ -86,15 +77,18 @@ import { prepareProjectRecordDirectories } from "./watch/prepareProjectRecordDir
86
77
  * replay source/project/external/universal proofs before selecting output.
87
78
  * In-flight/valid completed reuse avoids compilation, not those checks or
88
79
  * output/map/notification/record work. Capture misses pay whole native compile
89
- * and input populations; concurrent supersession can repeat the outer loop
80
+ * and input populations. The common proof owner skips redundant environment
81
+ * preparation for proven first deliveries and shares synchronous native proof
82
+ * queries; persistent/repeated delivery establishes fresh authority. Concurrent supersession can repeat the outer loop
90
83
  * without a delivery-level retry/time bound here.
91
84
  * @evidence contracts/performance.md#reuse-equivalent-work Cache identity covers config/options/plugins/aliases; current generations, pass-qualified terminal verdicts and in-flight Promises are shared only while their source and dependency proof remains valid.
92
85
  * @evidence contracts/performance.md#bound-retention-and-release-resources
93
86
  * Optional cache state retains current generation Promises/results and
94
87
  * per-key dependency/case facts without a byte/key cap here. Native tasks
95
88
  * belong to compiler/capture owners; uncached captures retain no notification
96
- * or persistent clock probe. Fresh-only delivery detaches its generation
97
- * before host callbacks; eviction/disposal attempt independent resource release
89
+ * or persistent clock probe. Fresh-only delivery releases capture resources,
90
+ * retaining only an explicitly admitted local pass result; rejected or failed
91
+ * incomplete handoff detaches its generation. Eviction/disposal attempt independent resource release
98
92
  * and native failures need not close every handle or remove every probe.
99
93
  * @evidence contracts/portability.md#os-neutral-implementation Native module paths and project coordinates use supported path/filesystem abstractions, while actual case policy and watcher capability come from generation proof rather than OS-name assumptions.
100
94
  */
@@ -171,6 +165,8 @@ export async function transformTtsc(
171
165
  await preparePluginBuildEnvironments(
172
166
  terminal.validation.cached.result,
173
167
  filesystem,
168
+ undefined,
169
+ terminal.validation.cached.projectRoot,
174
170
  );
175
171
  if (cache?.get(key) !== transformed) continue;
176
172
  }
@@ -218,15 +214,18 @@ export async function transformTtsc(
218
214
  if (!transformCacheTrustsNotifications(cache)) {
219
215
  withdrawGenerationNotifications(cached);
220
216
  }
221
- await preparePluginBuildEnvironments(cached.result, filesystem, cached);
222
- if (cache?.get(key) !== transformed) continue;
223
217
  if (epoch === undefined) {
224
218
  await settleProjectMutationEvents(cached);
225
219
  if (cache?.get(key) !== transformed) {
226
220
  continue;
227
221
  }
228
222
  }
223
+ await TtscGenerationProof.prepare(cached, file, epoch);
224
+ if (cache?.get(key) !== transformed) continue;
225
+ // No await between this observation and synchronous admission.
226
+ const proof = TtscGenerationProof.create(cached, file, epoch);
229
227
  const action = selectCachedGenerationAction({
228
+ proof,
230
229
  cache,
231
230
  cached,
232
231
  epoch,
@@ -239,36 +238,17 @@ export async function transformTtsc(
239
238
  continue;
240
239
  }
241
240
  if (action === "serve") {
242
- reportSuccessDiagnostics(cached, epoch);
243
- // A resolved `"exception"` / `"failure"` envelope makes this throw;
244
- // that is a failed generation too, so it is retained for this pass or
245
- // evicted outside one before being surfaced.
246
- let output: TtscTransformedOutput;
247
- try {
248
- output = selectOrEvict(cache, key, transformed, epoch, {
249
- file,
250
- projectRoot: cached.projectRoot,
251
- result: cached.result,
252
- tsconfig: cached.tsconfig,
253
- });
254
- } catch (error) {
255
- if (!(error instanceof TtscMissingProgramOutputError)) {
256
- notifyFailedGenerationInputs(hooks, cached, file, watchSelection);
257
- throw error;
258
- }
259
- // The compile is fine and simply has nothing for this module, so the
260
- // module goes back to the host untransformed rather than failing the
261
- // build (samchon/ttsc#1308). Its project config and selection inputs
262
- // still decide whether a later generation will contain this module,
263
- // so hosts must receive the same universal watch-input batch.
264
- reportMissingProgramOutput(cached, error, epoch);
265
- notifyWatchInputs(hooks, cached, file, watchSelection);
266
- markCachedSourceServed(cached, file);
267
- return undefined;
268
- }
269
- notifyWatchInputs(hooks, cached, file, watchSelection);
270
- markCachedSourceServed(cached, file);
271
- return createTransformResult(file, source, output);
241
+ return deliverCachedTransform({
242
+ cache,
243
+ cached,
244
+ generation: transformed,
245
+ key,
246
+ epoch,
247
+ file,
248
+ source,
249
+ hooks,
250
+ selection: watchSelection,
251
+ });
272
252
  }
273
253
  transformed = undefined;
274
254
  }
@@ -336,50 +316,16 @@ export async function transformTtsc(
336
316
  policies.set(key, reported);
337
317
  }
338
318
  }
339
- const { projectRoot, result } = cached;
340
- if (cached.freshDeliveryOnly === true) {
341
- // This delivery owns a newly compiled answer, but unavailable observer
342
- // authority cannot certify any later resident or host-cache delivery.
343
- // Eviction schedules resource release even if a host callback throws.
344
- if (cache === undefined) disposeCachedTransform(cached);
345
- else evictGeneration(cache, key, generation);
346
- if (
347
- result.type === "success" &&
348
- (hooks?.watching !== false ||
349
- hooks.markVolatile === undefined ||
350
- (hooks.project?.watching !== undefined &&
351
- hooks.project.watching !== hooks.watching))
352
- ) {
353
- throw new Error(
354
- "@ttsc/unplugin: plugin input observation is unavailable; fresh output " +
355
- "requires an explicitly nonwatching host with supported cache withdrawal. " +
356
- "Watching, unknown or contradictory lifecycles cannot safely observe its changes.",
357
- );
358
- }
359
- hooks?.markVolatile?.();
360
- }
361
- reportSuccessDiagnostics(cached, epoch);
362
- let output: TtscTransformedOutput;
363
- try {
364
- output = selectOrEvict(cache, key, generation, epoch, {
365
- file,
366
- projectRoot,
367
- result,
368
- tsconfig: cached.tsconfig,
369
- });
370
- } catch (error) {
371
- if (!(error instanceof TtscMissingProgramOutputError)) {
372
- notifyFailedGenerationInputs(hooks, cached, file, watchSelection);
373
- throw error;
374
- }
375
- reportMissingProgramOutput(cached, error, epoch);
376
- notifyWatchInputs(hooks, cached, file, watchSelection);
377
- markCachedSourceServed(cached, file);
378
- return undefined;
379
- }
380
- notifyWatchInputs(hooks, cached, file, watchSelection);
381
- markCachedSourceServed(cached, file);
382
- notifyVolatileDelivery(hooks, cached, file);
383
- return createTransformResult(file, source, output);
319
+ return deliverCachedTransform({
320
+ cache,
321
+ cached,
322
+ generation,
323
+ key,
324
+ epoch,
325
+ file,
326
+ source,
327
+ hooks,
328
+ selection: watchSelection,
329
+ });
384
330
  }
385
331
  }
@@ -0,0 +1,201 @@
1
+ import { PluginBuildEnvironmentReadings } from "ttsc/plugin-source";
2
+
3
+ import type { TtscCachedProjectTransform } from "../cache/TtscCachedProjectTransform";
4
+ import type { TtscTransformCache } from "../cache/TtscTransformCache";
5
+ import { disposeCachedTransform } from "../cache/disposeCachedTransform";
6
+ import { evictGeneration } from "../cache/evictGeneration";
7
+ import { resultFilesystem } from "../cache/resultFilesystem";
8
+ import { envelopeDerivation } from "../envelope/envelopeDerivation";
9
+ import { selectPluginSourceInputs } from "../envelope/selectPluginSourceInputs";
10
+ import { pathIdentityKey } from "../filesystem/pathIdentityKey";
11
+ import { preparePluginBuildEnvironments } from "../inputs/preparePluginBuildEnvironments";
12
+ import { toProjectKey } from "../project/toProjectKey";
13
+ import type { TtscTransformHooks } from "../watch/TtscTransformHooks";
14
+
15
+ /**
16
+ * The shared ownership boundary for generation reuse in every adapter.
17
+ *
18
+ * WARNING (#1712, #1713): a module, a synchronous input-proof transaction, a
19
+ * delivery pass, and a persistent generation have different lifetimes. Keep
20
+ * those distinctions here. Do not add native preparation before every module,
21
+ * keep positive toolchain checks for a whole process, or make Bun's adapter
22
+ * invent its own cache policy. A proven pass shares its first deliveries;
23
+ * persistent/repeated deliveries require new current observations. Incomplete
24
+ * observations can share a coherent local result only inside an explicitly
25
+ * nonwatching pass with actual host-cache withdrawal, never a record or pool.
26
+ *
27
+ * @evidence contracts/common.md#principled-implementation Explicit pass identity, source baseline and first-delivery membership delimit sharing; synchronous transactions independently qualify current native inputs and incomplete local outputs retain stricter lifecycle admission.
28
+ * @evidence contracts/common.md#clear-and-simple-design One core owner supplies the same preparation, pass and fresh-only policies to every adapter instead of separate host-specific caches.
29
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Missing observation never becomes complete snapshot authority; watching, persistent, repeated and unknown boundaries cannot borrow an incomplete pass result.
30
+ * @evidence contracts/common.md#meaningful-documentation Native context names the four lifetimes and warns against the specific performance and stale-cache regressions they prevent.
31
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation Members delegate native observations to the generation's filesystem and the native environment owner.
32
+ * @evidenceExclude contracts/performance.md#efficient-algorithms Members own baseline lookup, batch qualification and admission.
33
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work Members establish the distinct sharing boundaries.
34
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources The namespace owns no registry; transactions and generations have explicit callers.
35
+ */
36
+ export namespace TtscGenerationProof {
37
+ /**
38
+ * One synchronous admission after all asynchronous preparation has settled.
39
+ * Never retain this object in a generation or use it after an await.
40
+ *
41
+ * @evidence contracts/common.md#principled-implementation The exact cached owner prevents a proof of another result from supplying authority; optional native verdict is earned only by this synchronous transaction.
42
+ * @evidence contracts/common.md#clear-and-simple-design One transaction carries environment observations and the shared native predicate verdict.
43
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Absent environment or predicate proof remains absent, never implied success.
44
+ * @evidence contracts/common.md#meaningful-documentation Prose states the no-await lifetime and members distinguish owner, environment and predicate authority.
45
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation Native identity is retained by the referenced generation, not inferred by this carrier.
46
+ * @evidenceExclude contracts/performance.md#efficient-algorithms This carrier executes no computation.
47
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work The creating operation and validators own sharing decisions.
48
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources The synchronous caller owns this handle-free carrier.
49
+ */
50
+ export interface Transaction {
51
+ /** Exact generation being synchronously admitted. */
52
+ readonly cached: TtscCachedProjectTransform;
53
+
54
+ /** Current batch, absent when the pass already owns this input proof. */
55
+ readonly environments?: ReadonlyMap<string, string | undefined>;
56
+
57
+ /** Current native predicate verdict, unbuilt until its first gate. */
58
+ nativePredicates?: boolean;
59
+ }
60
+
61
+ /**
62
+ * Prepare native authority only when this delivery needs a new input proof.
63
+ * The caller must create its synchronous transaction after awaiting this.
64
+ *
65
+ * @evidence contracts/common.md#principled-implementation A qualified first-delivery pass already owns environment proof; all other requests prepare actual authority before synchronous admission.
66
+ * @evidence contracts/common.md#clear-and-simple-design One branch delegates native preparation rather than repeating it in adapters.
67
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Only the existing explicit pass contract permits skipping preparation; no watcher silence or process lifetime substitutes for it.
68
+ * @evidence contracts/common.md#meaningful-documentation Prose states preparation versus transaction ordering.
69
+ * @evidence contracts/portability.md#os-neutral-implementation Preparation uses the actual generation filesystem and native toolchain reader.
70
+ * @evidence contracts/performance.md#efficient-algorithms Qualified first deliveries perform baseline/identity lookups; other deliveries delegate one preparation per unique plugin directory.
71
+ * @evidence contracts/performance.md#reuse-equivalent-work The pass shares its existing first-delivery proof; persistent and repeated deliveries establish new native authority.
72
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources Native requests belong to their environment owner; no transaction survives this await.
73
+ */
74
+ export async function prepare(
75
+ cached: TtscCachedProjectTransform,
76
+ file: string,
77
+ epoch: number | undefined,
78
+ ): Promise<void> {
79
+ if (!sharesPass(cached, file, epoch))
80
+ await preparePluginBuildEnvironments(
81
+ cached.result,
82
+ resultFilesystem(cached.result),
83
+ cached,
84
+ );
85
+ }
86
+
87
+ /**
88
+ * Start fresh synchronous observation after notification and preparation
89
+ * awaits, sharing actual SDK queries and native predicate replay locally.
90
+ *
91
+ * @evidence contracts/common.md#principled-implementation Current environments are batch-qualified after asynchronous work; a qualified pass needs no redundant native environment observation.
92
+ * @evidence contracts/common.md#clear-and-simple-design One constructor binds observations to their exact generation.
93
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts No current verdict is retained across deliveries or asynchronous boundaries.
94
+ * @evidence contracts/common.md#meaningful-documentation Native prose identifies the mandatory ordering and synchronous lifetime.
95
+ * @evidence contracts/portability.md#os-neutral-implementation Native observation remains with the environment witness owner and actual generation path identity.
96
+ * @evidence contracts/performance.md#efficient-algorithms Plugin selection is generation-indexed; one batch shares variable hashing and distinct SDK metadata queries.
97
+ * @evidence contracts/performance.md#reuse-equivalent-work Only the following synchronous validators borrow this batch; pass sharing uses its independent first-delivery contract.
98
+ * @evidence contracts/performance.md#bound-retention-and-release-resources The caller releases the transaction at the end of synchronous admission; no registry or native handle is acquired.
99
+ */
100
+ export function create(
101
+ cached: TtscCachedProjectTransform,
102
+ file: string,
103
+ epoch: number | undefined,
104
+ ): Transaction {
105
+ return {
106
+ cached,
107
+ ...(sharesPass(cached, file, epoch)
108
+ ? {}
109
+ : {
110
+ environments: PluginBuildEnvironmentReadings.cachedAll(
111
+ selectPluginSourceInputs(cached.result).keys(),
112
+ ),
113
+ }),
114
+ };
115
+ }
116
+
117
+ /**
118
+ * Whether this module's first delivery belongs to this generation's proven
119
+ * pass. A missing source baseline cannot acquire this permission.
120
+ *
121
+ * @evidence contracts/common.md#principled-implementation Epoch equality, coherent snapshot or admitted local-pass state, a recorded source and an unserved identity are all required.
122
+ * @evidence contracts/common.md#clear-and-simple-design One predicate is shared by async preparation and synchronous source validation.
123
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts An incomplete ordinary generation or absent module baseline cannot earn pass reuse.
124
+ * @evidence contracts/common.md#meaningful-documentation Prose states the first-delivery and baseline restrictions.
125
+ * @evidence contracts/portability.md#os-neutral-implementation Baselines use the generation's actual identity and compiler project-key policy.
126
+ * @evidence contracts/performance.md#efficient-algorithms Baseline and served-set lookup avoid full input population traversal.
127
+ * @evidence contracts/performance.md#reuse-equivalent-work Only first deliveries in the same explicitly declared pass share its proof; repeated and later-pass requests do not.
128
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources The predicate borrows generation state without retaining another owner.
129
+ */
130
+ export function sharesPass(
131
+ cached: TtscCachedProjectTransform,
132
+ file: string,
133
+ epoch: number | undefined,
134
+ ): boolean {
135
+ if (
136
+ epoch === undefined ||
137
+ cached.deliveryEpoch !== epoch ||
138
+ (cached.projectSnapshotComplete !== true &&
139
+ cached.passDeliveryOnly !== true) ||
140
+ (cached.freshDeliveryOnly === true && cached.passDeliveryOnly !== true)
141
+ )
142
+ return false;
143
+ const identities = envelopeDerivation(cached).identityContext;
144
+ const identity = pathIdentityKey(file, identities);
145
+ if (cached.servedFiles?.has(identity)) return false;
146
+ const key = toProjectKey(cached.projectRoot, file, identities);
147
+ return (
148
+ cached.sourceHashes?.[identity] !== undefined ||
149
+ Object.hasOwn(cached.inputHashes, key) ||
150
+ cached.externalInputHashes?.[identity] !== undefined
151
+ );
152
+ }
153
+
154
+ /**
155
+ * Admit and notify a fresh-only local delivery. A coherent pass-only success
156
+ * can keep its result inside this pass after releasing capture resources;
157
+ * every other fresh-only answer is detached before notifying the host.
158
+ * Callback failure always evicts the incomplete owner.
159
+ *
160
+ * @evidence contracts/common.md#principled-implementation Explicit nonwatching, consistent project lifecycle and cache-withdrawal capability are required on every successful incomplete delivery; retention additionally needs the compile's exact pass-only epoch.
161
+ * @evidence contracts/common.md#clear-and-simple-design One owner handles initial and cached fresh-only admission, resource release and host notification.
162
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Incomplete output never acquires a persistent record or publication, and failed/unknown/watching capability cannot leave a reusable owner.
163
+ * @evidence contracts/common.md#meaningful-documentation Native paragraphs distinguish local pass retention, resource release and callback failure effects.
164
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation This lifecycle operation delegates native resource release to the generation disposer.
165
+ * @evidence contracts/performance.md#efficient-algorithms Identity/epoch checks and one callback add no input scan; resource disposal visits the fixed tracker population.
166
+ * @evidence contracts/performance.md#reuse-equivalent-work Only coherent locally admitted output in its exact nonwatching pass survives; a later pass or repeated module must obtain another result.
167
+ * @evidence contracts/performance.md#bound-retention-and-release-resources Capture resources are released even when local output is kept; rejection and callback failure detach the owning Promise, and the cache lifecycle bounds retained result lifetime.
168
+ */
169
+ export function admitFreshOnly(
170
+ cached: TtscCachedProjectTransform,
171
+ cache: TtscTransformCache | undefined,
172
+ key: string,
173
+ generation: Promise<TtscCachedProjectTransform>,
174
+ epoch: number | undefined,
175
+ hooks: TtscTransformHooks | undefined,
176
+ ): void {
177
+ if (cached.freshDeliveryOnly !== true) return;
178
+ const authorized =
179
+ hooks?.watching === false &&
180
+ hooks.markVolatile !== undefined &&
181
+ (hooks.project?.watching === undefined ||
182
+ hooks.project.watching === false);
183
+ const retain =
184
+ authorized &&
185
+ epoch !== undefined &&
186
+ cached.deliveryEpoch === epoch &&
187
+ cached.passDeliveryOnly === true;
188
+ disposeCachedTransform(cached);
189
+ if (!retain) evictGeneration(cache, key, generation);
190
+ if (cached.result.type === "success" && !authorized)
191
+ throw new Error(
192
+ "@ttsc/unplugin: plugin input observation is unavailable; fresh output requires an explicitly nonwatching host with supported cache withdrawal. Watching, unknown or contradictory lifecycles cannot safely observe its changes.",
193
+ );
194
+ try {
195
+ hooks?.markVolatile?.();
196
+ } catch (error) {
197
+ evictGeneration(cache, key, generation);
198
+ throw error;
199
+ }
200
+ }
201
+ }
@@ -302,7 +302,7 @@ export function captureUniversalHostInputValidation(
302
302
  const prepared = usesPreparedPluginBuildEnvironments(cached.result);
303
303
  const environment = prepared
304
304
  ? PluginBuildEnvironmentReadings.cached(directory)
305
- : processPluginBuildEnvironment(directory);
305
+ : processPluginBuildEnvironment(directory, false, cached.projectRoot);
306
306
  if (
307
307
  environment === undefined ||
308
308
  !pluginSourceHolds(
@@ -310,6 +310,7 @@ export function captureUniversalHostInputValidation(
310
310
  digest,
311
311
  filesystem,
312
312
  prepared ? { environment } : undefined,
313
+ cached.projectRoot,
313
314
  )
314
315
  ) {
315
316
  recordGenerationProofFailure(failures, {