@ttsc/graph 0.30.3 → 0.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (292) hide show
  1. package/README.md +122 -30
  2. package/lib/CapturedProcessOutput.d.ts +47 -0
  3. package/lib/CapturedProcessOutput.js +3 -0
  4. package/lib/CapturedProcessOutput.js.map +1 -0
  5. package/lib/ILauncherOption.d.ts +22 -0
  6. package/lib/ILauncherOption.js +3 -0
  7. package/lib/ILauncherOption.js.map +1 -0
  8. package/lib/IProjectOptions.d.ts +18 -0
  9. package/lib/IProjectOptions.js +3 -0
  10. package/lib/IProjectOptions.js.map +1 -0
  11. package/lib/ParsedLauncherOptions.d.ts +13 -0
  12. package/lib/ParsedLauncherOptions.js +3 -0
  13. package/lib/ParsedLauncherOptions.js.map +1 -0
  14. package/lib/TtscGraphApplication.d.ts +38 -1
  15. package/lib/TtscGraphApplication.js +26 -1
  16. package/lib/TtscGraphApplication.js.map +1 -1
  17. package/lib/TtscGraphLauncherArguments.d.ts +115 -0
  18. package/lib/TtscGraphLauncherArguments.js +181 -0
  19. package/lib/TtscGraphLauncherArguments.js.map +1 -0
  20. package/lib/TtscGraphViewSnapshot.d.ts +35 -0
  21. package/lib/TtscGraphViewSnapshot.js +48 -0
  22. package/lib/TtscGraphViewSnapshot.js.map +1 -0
  23. package/lib/index.d.ts +9 -24
  24. package/lib/index.js +6 -128
  25. package/lib/index.js.map +1 -1
  26. package/lib/internal/GraphProcessTrace.d.ts +1 -0
  27. package/lib/internal/GraphProcessTrace.js +235 -0
  28. package/lib/internal/GraphProcessTrace.js.map +1 -0
  29. package/lib/launcherArgs.d.ts +75 -16
  30. package/lib/launcherArgs.js +77 -8
  31. package/lib/launcherArgs.js.map +1 -1
  32. package/lib/model/IArtifactDirectory.d.ts +26 -0
  33. package/lib/model/IArtifactDirectory.js +3 -0
  34. package/lib/model/IArtifactDirectory.js.map +1 -0
  35. package/lib/model/IArtifactInputs.d.ts +19 -0
  36. package/lib/model/IArtifactInputs.js +3 -0
  37. package/lib/model/IArtifactInputs.js.map +1 -0
  38. package/lib/model/IPublishedArtifacts.d.ts +76 -0
  39. package/lib/model/IPublishedArtifacts.js +3 -0
  40. package/lib/model/IPublishedArtifacts.js.map +1 -0
  41. package/lib/model/IPublishedArtifactsResident.d.ts +19 -0
  42. package/lib/model/IPublishedArtifactsResident.js +3 -0
  43. package/lib/model/IPublishedArtifactsResident.js.map +1 -0
  44. package/lib/model/ITtscLintDaemonTarget.d.ts +20 -0
  45. package/lib/model/ITtscLintDaemonTarget.js +3 -0
  46. package/lib/model/ITtscLintDaemonTarget.js.map +1 -0
  47. package/lib/model/TtscGraphLinePeer.d.ts +146 -0
  48. package/lib/model/TtscGraphLinePeer.js +213 -0
  49. package/lib/model/TtscGraphLinePeer.js.map +1 -0
  50. package/lib/model/TtscGraphMemory.d.ts +156 -16
  51. package/lib/model/TtscGraphMemory.js +228 -222
  52. package/lib/model/TtscGraphMemory.js.map +1 -1
  53. package/lib/model/TtscGraphNativeArguments.d.ts +40 -0
  54. package/lib/model/TtscGraphNativeArguments.js +64 -0
  55. package/lib/model/TtscGraphNativeArguments.js.map +1 -0
  56. package/lib/model/TtscGraphNodeId.d.ts +55 -3
  57. package/lib/model/TtscGraphNodeId.js +40 -2
  58. package/lib/model/TtscGraphNodeId.js.map +1 -1
  59. package/lib/model/TtscGraphProjection.d.ts +156 -0
  60. package/lib/model/TtscGraphProjection.js +390 -0
  61. package/lib/model/TtscGraphProjection.js.map +1 -0
  62. package/lib/model/TtscGraphProtocol.d.ts +28 -0
  63. package/lib/model/TtscGraphProtocol.js +928 -0
  64. package/lib/model/TtscGraphProtocol.js.map +1 -0
  65. package/lib/model/TtscGraphReadonly.d.ts +15 -0
  66. package/lib/model/TtscGraphReadonly.js +3 -0
  67. package/lib/model/TtscGraphReadonly.js.map +1 -0
  68. package/lib/model/TtscGraphRequestOptions.d.ts +16 -0
  69. package/lib/model/TtscGraphRequestOptions.js +3 -0
  70. package/lib/model/TtscGraphRequestOptions.js.map +1 -0
  71. package/lib/model/TtscGraphSession.d.ts +82 -36
  72. package/lib/model/TtscGraphSession.js +164 -1238
  73. package/lib/model/TtscGraphSession.js.map +1 -1
  74. package/lib/model/TtscGraphSessionOptions.d.ts +20 -0
  75. package/lib/model/TtscGraphSessionOptions.js +3 -0
  76. package/lib/model/TtscGraphSessionOptions.js.map +1 -0
  77. package/lib/model/TtscGraphSessionState.d.ts +187 -0
  78. package/lib/model/TtscGraphSessionState.js +417 -0
  79. package/lib/model/TtscGraphSessionState.js.map +1 -0
  80. package/lib/model/TtscGraphShardStore.d.ts +64 -3
  81. package/lib/model/TtscGraphShardStore.js +85 -15
  82. package/lib/model/TtscGraphShardStore.js.map +1 -1
  83. package/lib/model/TtscGraphSourceReader.d.ts +31 -8
  84. package/lib/model/TtscGraphSourceReader.js +37 -13
  85. package/lib/model/TtscGraphSourceReader.js.map +1 -1
  86. package/lib/model/TtscLintDaemon.d.ts +35 -17
  87. package/lib/model/TtscLintDaemon.js +39 -117
  88. package/lib/model/TtscLintDaemon.js.map +1 -1
  89. package/lib/model/TtscLintDaemonState.d.ts +69 -0
  90. package/lib/model/TtscLintDaemonState.js +166 -0
  91. package/lib/model/TtscLintDaemonState.js.map +1 -0
  92. package/lib/model/copyGraphRecords.d.ts +14 -0
  93. package/lib/model/copyGraphRecords.js +19 -0
  94. package/lib/model/copyGraphRecords.js.map +1 -0
  95. package/lib/model/copyGraphSnapshot.d.ts +17 -0
  96. package/lib/model/copyGraphSnapshot.js +33 -0
  97. package/lib/model/copyGraphSnapshot.js.map +1 -0
  98. package/lib/model/loadGraph.d.ts +19 -10
  99. package/lib/model/loadGraph.js +21 -12
  100. package/lib/model/loadGraph.js.map +1 -1
  101. package/lib/model/publishedArtifacts.d.ts +78 -97
  102. package/lib/model/publishedArtifacts.js +271 -85
  103. package/lib/model/publishedArtifacts.js.map +1 -1
  104. package/lib/nativeExecutable.d.ts +19 -8
  105. package/lib/nativeExecutable.js +75 -15
  106. package/lib/nativeExecutable.js.map +1 -1
  107. package/lib/reduce.d.ts +19 -45
  108. package/lib/reduce.js +19 -3
  109. package/lib/reduce.js.map +1 -1
  110. package/lib/resolveGraphBinary.d.ts +9 -0
  111. package/lib/resolveGraphBinary.js +11 -3
  112. package/lib/resolveGraphBinary.js.map +1 -1
  113. package/lib/runGraph.d.ts +21 -0
  114. package/lib/runGraph.js +83 -0
  115. package/lib/runGraph.js.map +1 -0
  116. package/lib/server/IResolvedGraphHandle.d.ts +22 -0
  117. package/lib/server/IResolvedGraphHandle.js +3 -0
  118. package/lib/server/IResolvedGraphHandle.js.map +1 -0
  119. package/lib/server/createServer.d.ts +14 -10
  120. package/lib/server/createServer.js +42 -39
  121. package/lib/server/createServer.js.map +1 -1
  122. package/lib/server/exportSurface.d.ts +23 -1
  123. package/lib/server/exportSurface.js +23 -1
  124. package/lib/server/exportSurface.js.map +1 -1
  125. package/lib/server/formatGraphFailure.d.ts +20 -0
  126. package/lib/server/formatGraphFailure.js +35 -0
  127. package/lib/server/formatGraphFailure.js.map +1 -0
  128. package/lib/server/pathPolicy.d.ts +70 -5
  129. package/lib/server/pathPolicy.js +66 -4
  130. package/lib/server/pathPolicy.js.map +1 -1
  131. package/lib/server/resolveHandle.d.ts +10 -5
  132. package/lib/server/resolveHandle.js +39 -7
  133. package/lib/server/resolveHandle.js.map +1 -1
  134. package/lib/server/resultAudit.d.ts +17 -14
  135. package/lib/server/resultAudit.js +56 -27
  136. package/lib/server/resultAudit.js.map +1 -1
  137. package/lib/server/resultNext.d.ts +26 -1
  138. package/lib/server/resultNext.js +14 -0
  139. package/lib/server/resultNext.js.map +1 -1
  140. package/lib/server/runDetails.d.ts +72 -15
  141. package/lib/server/runDetails.js +104 -69
  142. package/lib/server/runDetails.js.map +1 -1
  143. package/lib/server/runEntrypoints.d.ts +9 -0
  144. package/lib/server/runEntrypoints.js +9 -0
  145. package/lib/server/runEntrypoints.js.map +1 -1
  146. package/lib/server/runLookup.d.ts +13 -3
  147. package/lib/server/runLookup.js +19 -6
  148. package/lib/server/runLookup.js.map +1 -1
  149. package/lib/server/runOverview.d.ts +13 -4
  150. package/lib/server/runOverview.js +13 -4
  151. package/lib/server/runOverview.js.map +1 -1
  152. package/lib/server/runTour.d.ts +9 -0
  153. package/lib/server/runTour.js +33 -65
  154. package/lib/server/runTour.js.map +1 -1
  155. package/lib/server/runTrace.d.ts +25 -1
  156. package/lib/server/runTrace.js +133 -88
  157. package/lib/server/runTrace.js.map +1 -1
  158. package/lib/server/startServer.d.ts +16 -0
  159. package/lib/server/startServer.js +24 -1
  160. package/lib/server/startServer.js.map +1 -1
  161. package/lib/structures/ITtscGraphApplication.d.ts +95 -41
  162. package/lib/structures/ITtscGraphDecorator.d.ts +18 -0
  163. package/lib/structures/ITtscGraphDetails.d.ts +81 -6
  164. package/lib/structures/ITtscGraphDocTag.d.ts +17 -8
  165. package/lib/structures/ITtscGraphDump.d.ts +106 -8
  166. package/lib/structures/ITtscGraphEdge.d.ts +14 -2
  167. package/lib/structures/ITtscGraphEntrypoints.d.ts +81 -6
  168. package/lib/structures/ITtscGraphEscape.d.ts +24 -2
  169. package/lib/structures/ITtscGraphEvidence.d.ts +9 -0
  170. package/lib/structures/ITtscGraphLookup.d.ts +42 -9
  171. package/lib/structures/ITtscGraphNext.d.ts +12 -1
  172. package/lib/structures/ITtscGraphNode.d.ts +38 -11
  173. package/lib/structures/ITtscGraphOverview.d.ts +81 -6
  174. package/lib/structures/ITtscGraphSnapshot.d.ts +97 -2
  175. package/lib/structures/ITtscGraphSpan.d.ts +9 -0
  176. package/lib/structures/ITtscGraphTour.d.ts +83 -9
  177. package/lib/structures/ITtscGraphTrace.d.ts +99 -14
  178. package/lib/structures/RawDump.d.ts +22 -0
  179. package/lib/structures/RawDump.js +3 -0
  180. package/lib/structures/RawDump.js.map +1 -0
  181. package/lib/structures/RawEdge.d.ts +20 -0
  182. package/lib/structures/RawEdge.js +3 -0
  183. package/lib/structures/RawEdge.js.map +1 -0
  184. package/lib/structures/RawNode.d.ts +26 -0
  185. package/lib/structures/RawNode.js +3 -0
  186. package/lib/structures/RawNode.js.map +1 -0
  187. package/lib/structures/TtscGraphArtifactNodeKind.d.ts +9 -0
  188. package/lib/structures/TtscGraphArtifactNodeKind.js +9 -0
  189. package/lib/structures/TtscGraphArtifactNodeKind.js.map +1 -1
  190. package/lib/structures/TtscGraphDumpEdgeKind.d.ts +15 -1
  191. package/lib/structures/TtscGraphDumpNodeKind.d.ts +9 -0
  192. package/lib/structures/TtscGraphEdgeKind.d.ts +13 -4
  193. package/lib/structures/TtscGraphNodeKind.d.ts +9 -0
  194. package/lib/structures/TtscGraphNodeModifier.d.ts +9 -0
  195. package/lib/structures/ViewerLink.d.ts +20 -0
  196. package/lib/structures/ViewerLink.js +3 -0
  197. package/lib/structures/ViewerLink.js.map +1 -0
  198. package/lib/structures/ViewerNode.d.ts +24 -0
  199. package/lib/structures/ViewerNode.js +3 -0
  200. package/lib/structures/ViewerNode.js.map +1 -0
  201. package/lib/structures/ViewerPayload.d.ts +42 -0
  202. package/lib/structures/ViewerPayload.js +3 -0
  203. package/lib/structures/ViewerPayload.js.map +1 -0
  204. package/lib/view.d.ts +9 -0
  205. package/lib/view.js +203 -91
  206. package/lib/view.js.map +1 -1
  207. package/lib/viewer/viewer.js +1 -1
  208. package/package.json +8 -6
  209. package/src/CapturedProcessOutput.ts +50 -0
  210. package/src/ILauncherOption.ts +24 -0
  211. package/src/IProjectOptions.ts +19 -0
  212. package/src/ParsedLauncherOptions.ts +13 -0
  213. package/src/TtscGraphApplication.ts +38 -1
  214. package/src/TtscGraphLauncherArguments.ts +207 -0
  215. package/src/TtscGraphViewSnapshot.ts +46 -0
  216. package/src/index.ts +9 -160
  217. package/src/internal/GraphProcessTrace.ts +242 -0
  218. package/src/launcherArgs.ts +89 -23
  219. package/src/model/IArtifactDirectory.ts +27 -0
  220. package/src/model/IArtifactInputs.ts +21 -0
  221. package/src/model/IPublishedArtifacts.ts +81 -0
  222. package/src/model/IPublishedArtifactsResident.ts +24 -0
  223. package/src/model/ITtscLintDaemonTarget.ts +22 -0
  224. package/src/model/TtscGraphLinePeer.ts +318 -0
  225. package/src/model/TtscGraphMemory.ts +284 -246
  226. package/src/model/TtscGraphNativeArguments.ts +67 -0
  227. package/src/model/TtscGraphNodeId.ts +57 -3
  228. package/src/model/TtscGraphProjection.ts +473 -0
  229. package/src/model/TtscGraphProtocol.ts +90 -0
  230. package/src/model/TtscGraphReadonly.ts +17 -0
  231. package/src/model/TtscGraphRequestOptions.ts +16 -0
  232. package/src/model/TtscGraphSession.ts +196 -475
  233. package/src/model/TtscGraphSessionOptions.ts +22 -0
  234. package/src/model/TtscGraphSessionState.ts +558 -0
  235. package/src/model/TtscGraphShardStore.ts +99 -23
  236. package/src/model/TtscGraphSourceReader.ts +37 -15
  237. package/src/model/TtscLintDaemon.ts +55 -136
  238. package/src/model/TtscLintDaemonState.ts +174 -0
  239. package/src/model/copyGraphRecords.ts +17 -0
  240. package/src/model/copyGraphSnapshot.ts +30 -0
  241. package/src/model/loadGraph.ts +23 -12
  242. package/src/model/publishedArtifacts.ts +361 -182
  243. package/src/nativeExecutable.ts +93 -26
  244. package/src/reduce.ts +24 -51
  245. package/src/resolveGraphBinary.ts +13 -3
  246. package/src/runGraph.ts +90 -0
  247. package/src/server/IResolvedGraphHandle.ts +24 -0
  248. package/src/server/createServer.ts +16 -22
  249. package/src/server/exportSurface.ts +23 -1
  250. package/src/server/formatGraphFailure.ts +32 -0
  251. package/src/server/pathPolicy.ts +70 -5
  252. package/src/server/resolveHandle.ts +45 -14
  253. package/src/server/resultAudit.ts +58 -27
  254. package/src/server/resultNext.ts +26 -1
  255. package/src/server/runDetails.ts +138 -73
  256. package/src/server/runEntrypoints.ts +13 -1
  257. package/src/server/runLookup.ts +23 -7
  258. package/src/server/runOverview.ts +17 -5
  259. package/src/server/runTour.ts +44 -82
  260. package/src/server/runTrace.ts +175 -102
  261. package/src/server/startServer.ts +29 -1
  262. package/src/structures/ITtscGraphApplication.ts +95 -41
  263. package/src/structures/ITtscGraphDecorator.ts +18 -0
  264. package/src/structures/ITtscGraphDetails.ts +81 -6
  265. package/src/structures/ITtscGraphDocTag.ts +17 -8
  266. package/src/structures/ITtscGraphDump.ts +106 -8
  267. package/src/structures/ITtscGraphEdge.ts +14 -2
  268. package/src/structures/ITtscGraphEntrypoints.ts +81 -6
  269. package/src/structures/ITtscGraphEscape.ts +24 -2
  270. package/src/structures/ITtscGraphEvidence.ts +9 -0
  271. package/src/structures/ITtscGraphLookup.ts +42 -9
  272. package/src/structures/ITtscGraphNext.ts +12 -1
  273. package/src/structures/ITtscGraphNode.ts +38 -11
  274. package/src/structures/ITtscGraphOverview.ts +88 -6
  275. package/src/structures/ITtscGraphSnapshot.ts +117 -2
  276. package/src/structures/ITtscGraphSpan.ts +9 -0
  277. package/src/structures/ITtscGraphTour.ts +83 -9
  278. package/src/structures/ITtscGraphTrace.ts +100 -14
  279. package/src/structures/RawDump.ts +25 -0
  280. package/src/structures/RawEdge.ts +22 -0
  281. package/src/structures/RawNode.ts +31 -0
  282. package/src/structures/TtscGraphArtifactNodeKind.ts +9 -0
  283. package/src/structures/TtscGraphDumpEdgeKind.ts +15 -1
  284. package/src/structures/TtscGraphDumpNodeKind.ts +9 -0
  285. package/src/structures/TtscGraphEdgeKind.ts +13 -4
  286. package/src/structures/TtscGraphNodeKind.ts +9 -0
  287. package/src/structures/TtscGraphNodeModifier.ts +9 -0
  288. package/src/structures/ViewerLink.ts +22 -0
  289. package/src/structures/ViewerNode.ts +28 -0
  290. package/src/structures/ViewerPayload.ts +52 -0
  291. package/src/view.ts +208 -110
  292. package/src/viewer/legend.ts +119 -27
@@ -1,11 +1,9 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.TtscLintDaemon = void 0;
7
- const node_child_process_1 = require("node:child_process");
8
- const node_readline_1 = __importDefault(require("node:readline"));
4
+ const TtscGraphLinePeer_1 = require("./TtscGraphLinePeer");
5
+ const TtscGraphNativeArguments_1 = require("./TtscGraphNativeArguments");
6
+ const TtscLintDaemonState_1 = require("./TtscLintDaemonState");
9
7
  /**
10
8
  * A resident `@ttsc/lint` sidecar, kept open across the questions one graph
11
9
  * session asks it.
@@ -22,20 +20,26 @@ const node_readline_1 = __importDefault(require("node:readline"));
22
20
  * at all, and a daemon can die mid-session; each of those closes this one and
23
21
  * leaves the caller to spawn per verb, which is the behaviour that existed
24
22
  * before this and is still correct — only slower.
23
+ *
24
+ * @evidence contracts/common.md#principled-implementation Serialized line requests match FIFO responses; unsupported or failed daemon replies return null so callers can use the same direct verb contract.
25
+ * @evidence contracts/common.md#clear-and-simple-design This facade owns one sidecar's launch identity; daemon state owns FIFO replies/fallback and the shared line adapter owns its native transport.
26
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts A failed daemon is retired rather than advertised as a successful empty artifact set.
27
+ * @evidence contracts/common.md#meaningful-documentation Native paragraphs explain resident amortization and the supported direct-command fallback rather than claiming all failures are empty results.
28
+ * @evidenceExclude contracts/performance.md#efficient-algorithms ask delegates FIFO processing and fallback to daemon state; this declaration describes the real sidecar launch identity.
29
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work ask owns continued process/configuration reuse and invalidation.
30
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources ask and close own acquisition, failure and shutdown transitions; the declaration adds no independent lifecycle operation.
31
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation Native invocation and termination decisions are acknowledged on ask and close together with private helpers.
25
32
  */
26
33
  class TtscLintDaemon {
27
34
  target;
28
35
  cwd;
29
36
  tsconfig;
30
- child;
31
- lines;
32
- pending = [];
33
- queue = Promise.resolve();
34
- failed = false;
37
+ state;
35
38
  constructor(target, cwd, tsconfig) {
36
39
  this.target = target;
37
40
  this.cwd = cwd;
38
41
  this.tsconfig = tsconfig;
42
+ this.state = new TtscLintDaemonState_1.TtscLintDaemonState((events) => TtscGraphLinePeer_1.TtscGraphLinePeer.open(this.target.binary, TtscGraphNativeArguments_1.TtscGraphNativeArguments.lint(this.cwd, this.tsconfig, this.target.manifest, this.target.projectContext), events, { cwd: this.cwd, stderr: "drain" }));
39
43
  }
40
44
  /**
41
45
  * Ask one verb and return its raw JSON, or `null` when this daemon cannot
@@ -49,118 +53,36 @@ class TtscLintDaemon {
49
53
  * Requests are serialized. The daemon answers one line per request in order,
50
54
  * with nothing in the reply to address it by, so a second request in flight
51
55
  * would be matched against the first one's answer.
56
+ *
57
+ * @evidence contracts/common.md#principled-implementation A promise queue admits one request at a time because the protocol orders responses without request ids; result text preserves arbitrary JSON values.
58
+ * @evidence contracts/common.md#clear-and-simple-design ask delegates queue admission and reply decoding to daemon state; its configured opener supplies actual native transport and supported sidecar argv.
59
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Null explicitly requests a direct fallback; it cannot silently masquerade as no published artifacts.
60
+ * @evidence contracts/common.md#meaningful-documentation Native paragraphs explain null meaning and why requests must be serialized.
61
+ * @evidence contracts/performance.md#efficient-algorithms Each request writes and decodes one JSON frame; queue work is linear in serialized frame bytes with one active reply.
62
+ * @evidence contracts/performance.md#reuse-equivalent-work The same target/project sidecar retains process, plugin load and configuration across verbs; invalidate explicitly retires warm Program facts when input generations change.
63
+ * @evidence contracts/performance.md#bound-retention-and-release-resources The daemon owns one child and reader; close settles pending replies and kills the child, while queued promises remain proportional to submitted caller demand.
64
+ * @evidence contracts/portability.md#os-neutral-implementation spawn passes executable and an argv vector directly with windowsHide, preserving spaces and native executable semantics without shell quoting.
52
65
  */
53
66
  ask(verb, invalidate) {
54
- const run = this.queue.then(() => this.send(verb, invalidate));
55
- this.queue = run.catch(() => undefined);
56
- return run;
67
+ return this.state.ask(verb, invalidate);
57
68
  }
58
- /** Stop the sidecar. Safe to call more than once, and after a failure. */
69
+ /**
70
+ * Stop the sidecar. Safe to call more than once, and after a failure.
71
+ *
72
+ * Pending replies settle null so callers can switch to the direct command.
73
+ *
74
+ * @evidence contracts/common.md#principled-implementation Marking failed before settling requests prevents new daemon work while reader and child ownership are cleared.
75
+ * @evidence contracts/common.md#clear-and-simple-design One shutdown operation is shared by explicit disposal and transport failure.
76
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Shutdown does not invent a successful reply to unblock a request.
77
+ * @evidence contracts/common.md#meaningful-documentation Native prose states idempotence, failure safety and the meaning of settled null replies.
78
+ * @evidence contracts/performance.md#efficient-algorithms Closing visits outstanding reply callbacks once and clears the reader/child references.
79
+ * @evidence contracts/performance.md#reuse-equivalent-work Closure retires this target's reusable process permanently; later calls return the supported direct-fallback indication.
80
+ * @evidence contracts/performance.md#bound-retention-and-release-resources Both normal and failed shutdown settle pending callbacks, close readline and end/kill the owned process; the returned completion still joins stdio after process exit and rejects unknown or forced termination.
81
+ * @evidence contracts/portability.md#os-neutral-implementation Node stream closure and child.kill own native termination rather than platform shell commands.
82
+ */
59
83
  close() {
60
- this.failed = true;
61
- for (const settle of this.pending.splice(0))
62
- settle(null);
63
- this.lines?.close();
64
- this.lines = undefined;
65
- const child = this.child;
66
- this.child = undefined;
67
- if (child === undefined)
68
- return;
69
- child.stdin.end();
70
- child.kill();
71
- }
72
- async send(verb, invalidate) {
73
- if (this.failed)
74
- return null;
75
- const child = this.start();
76
- if (child === undefined)
77
- return null;
78
- const reply = await new Promise((resolve) => {
79
- this.pending.push(resolve);
80
- child.stdin.write(`${JSON.stringify({ invalidate, verb })}\n`, (error) => {
81
- if (error === null || error === undefined)
82
- return;
83
- this.fail();
84
- });
85
- });
86
- if (reply === null || reply.code !== 0) {
87
- // A nonzero code is the sidecar declining, and this client cannot tell
88
- // "unknown verb" from "the rule failed". Closing rather than retrying
89
- // through the daemon is what makes the caller fall back to the direct
90
- // command, where a real failure surfaces the same way it always did.
91
- this.close();
92
- return null;
93
- }
94
- return reply.result;
95
- }
96
- start() {
97
- if (this.child !== undefined)
98
- return this.child;
99
- if (this.failed)
100
- return undefined;
101
- let child;
102
- try {
103
- child = (0, node_child_process_1.spawn)(this.target.binary, [
104
- "lsp-serve",
105
- `--cwd=${this.cwd}`,
106
- `--tsconfig=${this.tsconfig}`,
107
- `--plugins-json=${this.target.manifest}`,
108
- ...(this.target.projectContext === undefined
109
- ? []
110
- : [`--project-context-json=${this.target.projectContext}`]),
111
- ], { cwd: this.cwd, stdio: ["pipe", "pipe", "pipe"], windowsHide: true });
112
- }
113
- catch {
114
- this.failed = true;
115
- return undefined;
116
- }
117
- this.child = child;
118
- // The sidecar's stderr is its own diagnostic channel and is not this
119
- // client's to interpret; draining it keeps a chatty plugin from filling the
120
- // pipe and stalling the daemon it is talking through.
121
- child.stderr.resume();
122
- child.on("error", () => this.fail());
123
- child.on("exit", () => this.fail());
124
- this.lines = node_readline_1.default.createInterface({ input: child.stdout });
125
- this.lines.on("line", (line) => this.onLine(line));
126
- return child;
127
- }
128
- onLine(line) {
129
- const settle = this.pending.shift();
130
- if (settle === undefined)
131
- return;
132
- let reply;
133
- try {
134
- reply = JSON.parse(line);
135
- }
136
- catch {
137
- settle(null);
138
- return;
139
- }
140
- settle(typeof reply.code === "number"
141
- ? { code: reply.code, result: rawResult(line) }
142
- : null);
143
- }
144
- fail() {
145
- this.close();
84
+ return this.state.close();
146
85
  }
147
86
  }
148
87
  exports.TtscLintDaemon = TtscLintDaemon;
149
- /**
150
- * The `result` member, as the JSON text this daemon's callers parse.
151
- *
152
- * A verb's result is arbitrary JSON that the caller decodes itself, so it is
153
- * handed back as text rather than as a value — which is what the direct command
154
- * hands over, and what keeps the two paths interchangeable. The text is
155
- * re-serialized rather than sliced out of the line: the bytes are not identical
156
- * to the sidecar's own, but the value they decode to is, and no caller here
157
- * reads anything else.
158
- *
159
- * A reply with no `result` is `"null"`, so a caller parses a value either way
160
- * instead of being handed the empty string.
161
- */
162
- function rawResult(line) {
163
- const parsed = JSON.parse(line);
164
- return parsed.result === undefined ? "null" : JSON.stringify(parsed.result);
165
- }
166
88
  //# sourceMappingURL=TtscLintDaemon.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TtscLintDaemon.js","sourceRoot":"","sources":["../../src/model/TtscLintDaemon.ts"],"names":[],"mappings":";;;;;;AAAA,2DAAgF;AAChF,kEAAqC;AASrC;;;;;;;;;;;;;;;;GAgBG;AACH;IAQqB,MAAM;IACN,GAAG;IACH,QAAQ;IATnB,KAAK,CAA6C;IAClD,KAAK,CAAiC;IAC7B,OAAO,GAAuC,EAAE,CAAC;IAC1D,KAAK,GAAqB,OAAO,CAAC,OAAO,EAAE,CAAC;IAC5C,MAAM,GAAG,KAAK,CAAC;IAEvB,YACmB,MAA6B,EAC7B,GAAW,EACX,QAAgB;sBAFhB,MAAM;mBACN,GAAG;wBACH,QAAQ;IACxB,CAAC;IAEJ;;;;;;;;;;;;OAYG;IACI,GAAG,CAAC,IAAY,EAAE,UAAmB;QAC1C,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC;QAC/D,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QACxC,OAAO,GAAG,CAAC;IACb,CAAC;IAED,0EAA0E;IACnE,KAAK;QACV,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;YAAE,MAAM,CAAC,IAAI,CAAC,CAAC;QAC1D,IAAI,CAAC,KAAK,EAAE,KAAK,EAAE,CAAC;QACpB,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;QACvB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACzB,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;QACvB,IAAI,KAAK,KAA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EAAE,CAC9C,qCAAiB,CAAC,IAAI,CACpB,IAAI,CAAC,MAAM,CAAC,MAAM,EAClB,mDAAwB,CAAC,IAAI,CAC3B,IAAI,CAAC,GAAG,EACR,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,MAAM,CAAC,QAAQ,EACpB,IAAI,CAAC,MAAM,CAAC,cAAc,CAC3B,EACD,MAAM,EACN,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,CACnC,CACF,CAAC;IACJ,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;OAqBG;IACI,GAAG,CAAC,IAAY,EAAE,UAAmB;QAC1C,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IAC1C,CAAC;IAED;;;;;;;;;;;;;OAaG;IACI,KAAK;QACV,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IAC5B,CAAC;CACF"}
@@ -0,0 +1,69 @@
1
+ import { TtscGraphLinePeer } from "./TtscGraphLinePeer";
2
+ /**
3
+ * FIFO reply correlation and direct-command fallback for one lint daemon.
4
+ *
5
+ * Replies have no request id, so admission is serialized. Null means the
6
+ * resident protocol cannot answer after successful retirement; callers retain
7
+ * their direct verb fallback. Failed joined shutdown rejects instead.
8
+ *
9
+ * @evidence contracts/common.md#principled-implementation Serialized requests and FIFO replies preserve the sidecar protocol; failed and unsupported answers permanently retire this owner.
10
+ * @evidence contracts/common.md#clear-and-simple-design Line parsing and queue/failure transitions are local; the declared opener owns actual process transport.
11
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Null requests a real direct fallback, never an invented empty result or fake success.
12
+ * @evidence contracts/common.md#meaningful-documentation Prose explains no-id serialization and the null fallback contract; ask and close document acquisition and retirement.
13
+ * @evidenceExclude contracts/performance.md#efficient-algorithms ask/close own admission, frame processing and retirement; this declaration groups their retained state.
14
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work ask/close establish continued peer/model reuse, not the class descriptor independently.
15
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources ask/close control acquisition and release; the class declaration adds no separate lifecycle transition.
16
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation queues requests and parses reply lines in memory; the process is reached only through the injected opener's Connection.
17
+ */
18
+ export declare class TtscLintDaemonState {
19
+ private readonly open;
20
+ private child;
21
+ private readonly pending;
22
+ private queue;
23
+ private failed;
24
+ private closing;
25
+ constructor(open: (events: TtscGraphLinePeer.Events) => TtscGraphLinePeer.Connection);
26
+ /**
27
+ * Ask one verb and return its raw JSON, or `null` when this daemon cannot
28
+ * answer it.
29
+ *
30
+ * `null` is always "ask the sidecar directly instead", never "the project has
31
+ * none". The two are indistinguishable downstream — an empty artifact set is
32
+ * the correct answer for most projects — so a daemon that cannot answer must
33
+ * never be allowed to look like one that answered nothing.
34
+ *
35
+ * Requests are serialized. The daemon answers one line per request in order,
36
+ * with nothing in the reply to address it by, so a second request in flight
37
+ * would be matched against the first one's answer.
38
+ *
39
+ * @evidence contracts/common.md#principled-implementation A promise queue admits one request at a time because the protocol orders responses without request ids; result text preserves arbitrary JSON values.
40
+ * @evidence contracts/common.md#clear-and-simple-design ask owns queue admission while send/start/onLine own transport and reply decoding.
41
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Null explicitly requests a direct fallback; it cannot silently masquerade as no published artifacts.
42
+ * @evidence contracts/common.md#meaningful-documentation Native paragraphs explain null meaning and why requests must be serialized.
43
+ * @evidence contracts/performance.md#efficient-algorithms Each request writes and decodes one JSON frame; queue work is linear in serialized frame bytes with one active reply.
44
+ * @evidence contracts/performance.md#reuse-equivalent-work The same target/project sidecar retains process, plugin load and configuration across verbs; invalidate explicitly retires warm Program facts when input generations change.
45
+ * @evidence contracts/performance.md#bound-retention-and-release-resources The daemon owns one child and reader; close settles pending replies and delegates joined EOF shutdown to the actual adapter, while queued promises remain proportional to submitted caller demand.
46
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation queues one request and parses one reply line; the process is reached only through the injected Connection.
47
+ */
48
+ ask(verb: string, invalidate: boolean): Promise<string | null>;
49
+ /**
50
+ * Stop the sidecar. Safe to call more than once, and after a failure.
51
+ *
52
+ * Reply callbacks settle null. Their asks switch to the direct command only
53
+ * after successful retirement; a shutdown failure propagates to the caller.
54
+ *
55
+ * @evidence contracts/common.md#principled-implementation Marking failed before settling requests prevents new daemon work while reader and child ownership are cleared.
56
+ * @evidence contracts/common.md#clear-and-simple-design One shutdown operation is shared by explicit disposal and transport failure.
57
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Shutdown does not invent a successful reply to unblock a request.
58
+ * @evidence contracts/common.md#meaningful-documentation Native prose states idempotence, failure safety and the meaning of settled null replies.
59
+ * @evidence contracts/performance.md#efficient-algorithms Closing visits outstanding reply callbacks once and clears the reader/child references.
60
+ * @evidence contracts/performance.md#reuse-equivalent-work Closure retires this target's reusable process permanently; later calls return the supported direct-fallback indication.
61
+ * @evidence contracts/performance.md#bound-retention-and-release-resources Both normal and failed shutdown settle pending callbacks, close readline and end/kill the owned process; the returned completion still joins stdio after process exit and rejects unknown or forced termination.
62
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation settles pending replies and closes the injected Connection; the process work lives there.
63
+ */
64
+ close(): Promise<void>;
65
+ private send;
66
+ private start;
67
+ private onLine;
68
+ private fail;
69
+ }
@@ -0,0 +1,166 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TtscLintDaemonState = void 0;
4
+ /**
5
+ * FIFO reply correlation and direct-command fallback for one lint daemon.
6
+ *
7
+ * Replies have no request id, so admission is serialized. Null means the
8
+ * resident protocol cannot answer after successful retirement; callers retain
9
+ * their direct verb fallback. Failed joined shutdown rejects instead.
10
+ *
11
+ * @evidence contracts/common.md#principled-implementation Serialized requests and FIFO replies preserve the sidecar protocol; failed and unsupported answers permanently retire this owner.
12
+ * @evidence contracts/common.md#clear-and-simple-design Line parsing and queue/failure transitions are local; the declared opener owns actual process transport.
13
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Null requests a real direct fallback, never an invented empty result or fake success.
14
+ * @evidence contracts/common.md#meaningful-documentation Prose explains no-id serialization and the null fallback contract; ask and close document acquisition and retirement.
15
+ * @evidenceExclude contracts/performance.md#efficient-algorithms ask/close own admission, frame processing and retirement; this declaration groups their retained state.
16
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work ask/close establish continued peer/model reuse, not the class descriptor independently.
17
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources ask/close control acquisition and release; the class declaration adds no separate lifecycle transition.
18
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation queues requests and parses reply lines in memory; the process is reached only through the injected opener's Connection.
19
+ */
20
+ class TtscLintDaemonState {
21
+ open;
22
+ child;
23
+ pending = [];
24
+ queue = Promise.resolve();
25
+ failed = false;
26
+ closing;
27
+ constructor(open) {
28
+ this.open = open;
29
+ }
30
+ /**
31
+ * Ask one verb and return its raw JSON, or `null` when this daemon cannot
32
+ * answer it.
33
+ *
34
+ * `null` is always "ask the sidecar directly instead", never "the project has
35
+ * none". The two are indistinguishable downstream — an empty artifact set is
36
+ * the correct answer for most projects — so a daemon that cannot answer must
37
+ * never be allowed to look like one that answered nothing.
38
+ *
39
+ * Requests are serialized. The daemon answers one line per request in order,
40
+ * with nothing in the reply to address it by, so a second request in flight
41
+ * would be matched against the first one's answer.
42
+ *
43
+ * @evidence contracts/common.md#principled-implementation A promise queue admits one request at a time because the protocol orders responses without request ids; result text preserves arbitrary JSON values.
44
+ * @evidence contracts/common.md#clear-and-simple-design ask owns queue admission while send/start/onLine own transport and reply decoding.
45
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Null explicitly requests a direct fallback; it cannot silently masquerade as no published artifacts.
46
+ * @evidence contracts/common.md#meaningful-documentation Native paragraphs explain null meaning and why requests must be serialized.
47
+ * @evidence contracts/performance.md#efficient-algorithms Each request writes and decodes one JSON frame; queue work is linear in serialized frame bytes with one active reply.
48
+ * @evidence contracts/performance.md#reuse-equivalent-work The same target/project sidecar retains process, plugin load and configuration across verbs; invalidate explicitly retires warm Program facts when input generations change.
49
+ * @evidence contracts/performance.md#bound-retention-and-release-resources The daemon owns one child and reader; close settles pending replies and delegates joined EOF shutdown to the actual adapter, while queued promises remain proportional to submitted caller demand.
50
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation queues one request and parses one reply line; the process is reached only through the injected Connection.
51
+ */
52
+ ask(verb, invalidate) {
53
+ const run = this.queue.then(() => this.send(verb, invalidate));
54
+ this.queue = run.catch(() => undefined);
55
+ return run;
56
+ }
57
+ /**
58
+ * Stop the sidecar. Safe to call more than once, and after a failure.
59
+ *
60
+ * Reply callbacks settle null. Their asks switch to the direct command only
61
+ * after successful retirement; a shutdown failure propagates to the caller.
62
+ *
63
+ * @evidence contracts/common.md#principled-implementation Marking failed before settling requests prevents new daemon work while reader and child ownership are cleared.
64
+ * @evidence contracts/common.md#clear-and-simple-design One shutdown operation is shared by explicit disposal and transport failure.
65
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Shutdown does not invent a successful reply to unblock a request.
66
+ * @evidence contracts/common.md#meaningful-documentation Native prose states idempotence, failure safety and the meaning of settled null replies.
67
+ * @evidence contracts/performance.md#efficient-algorithms Closing visits outstanding reply callbacks once and clears the reader/child references.
68
+ * @evidence contracts/performance.md#reuse-equivalent-work Closure retires this target's reusable process permanently; later calls return the supported direct-fallback indication.
69
+ * @evidence contracts/performance.md#bound-retention-and-release-resources Both normal and failed shutdown settle pending callbacks, close readline and end/kill the owned process; the returned completion still joins stdio after process exit and rejects unknown or forced termination.
70
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation settles pending replies and closes the injected Connection; the process work lives there.
71
+ */
72
+ close() {
73
+ if (this.closing !== undefined)
74
+ return this.closing;
75
+ this.failed = true;
76
+ for (const settle of this.pending.splice(0))
77
+ settle(null);
78
+ const child = this.child;
79
+ this.child = undefined;
80
+ this.closing = Promise.resolve(child?.close(true));
81
+ void this.closing.catch(() => undefined);
82
+ return this.closing;
83
+ }
84
+ async send(verb, invalidate) {
85
+ if (this.failed) {
86
+ await this.closing;
87
+ return null;
88
+ }
89
+ const child = this.start();
90
+ if (child === undefined)
91
+ return null;
92
+ const reply = await new Promise((resolve) => {
93
+ this.pending.push(resolve);
94
+ child.write(`${JSON.stringify({ invalidate, verb })}\n`, (error) => {
95
+ if (error === null || error === undefined)
96
+ return;
97
+ this.fail();
98
+ });
99
+ });
100
+ if (reply === null || reply.code !== 0) {
101
+ // A nonzero code is the sidecar declining, and this client cannot tell
102
+ // "unknown verb" from "the rule failed". Closing rather than retrying
103
+ // through the daemon is what makes the caller fall back to the direct
104
+ // command, where a real failure surfaces the same way it always did.
105
+ await this.close();
106
+ return null;
107
+ }
108
+ return reply.result;
109
+ }
110
+ start() {
111
+ if (this.child !== undefined)
112
+ return this.child;
113
+ if (this.failed)
114
+ return undefined;
115
+ try {
116
+ this.child = this.open({
117
+ line: (line) => this.onLine(line),
118
+ error: () => this.fail(),
119
+ exit: () => this.fail(),
120
+ });
121
+ return this.child;
122
+ }
123
+ catch {
124
+ this.failed = true;
125
+ return undefined;
126
+ }
127
+ }
128
+ onLine(line) {
129
+ const settle = this.pending.shift();
130
+ if (settle === undefined)
131
+ return;
132
+ let reply;
133
+ try {
134
+ reply = JSON.parse(line);
135
+ }
136
+ catch {
137
+ settle(null);
138
+ return;
139
+ }
140
+ settle(typeof reply.code === "number"
141
+ ? { code: reply.code, result: rawResult(line) }
142
+ : null);
143
+ }
144
+ fail() {
145
+ this.close();
146
+ }
147
+ }
148
+ exports.TtscLintDaemonState = TtscLintDaemonState;
149
+ /**
150
+ * The `result` member, as the JSON text this daemon's callers parse.
151
+ *
152
+ * A verb's result is arbitrary JSON that the caller decodes itself, so it is
153
+ * handed back as text rather than as a value — which is what the direct command
154
+ * hands over, and what keeps the two paths interchangeable. The text is
155
+ * re-serialized rather than sliced out of the line: the bytes are not identical
156
+ * to the sidecar's own, but the value they decode to is, and no caller here
157
+ * reads anything else.
158
+ *
159
+ * A reply with no `result` is `"null"`, so a caller parses a value either way
160
+ * instead of being handed the empty string.
161
+ */
162
+ function rawResult(line) {
163
+ const parsed = JSON.parse(line);
164
+ return parsed.result === undefined ? "null" : JSON.stringify(parsed.result);
165
+ }
166
+ //# sourceMappingURL=TtscLintDaemonState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TtscLintDaemonState.js","sourceRoot":"","sources":["../../src/model/TtscLintDaemonState.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;;;;;GAeG;AACH;IAQqB,IAAI;IAPf,KAAK,CAA2C;IACvC,OAAO,GAAuC,EAAE,CAAC;IAC1D,KAAK,GAAqB,OAAO,CAAC,OAAO,EAAE,CAAC;IAC5C,MAAM,GAAG,KAAK,CAAC;IACf,OAAO,CAA4B;IAE3C,YACmB,IAEgB;oBAFhB,IAAI;IAGpB,CAAC;IAEJ;;;;;;;;;;;;;;;;;;;;;OAqBG;IACI,GAAG,CAAC,IAAY,EAAE,UAAmB;QAC1C,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC;QAC/D,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QACxC,OAAO,GAAG,CAAC;IACb,CAAC;IAED;;;;;;;;;;;;;;OAcG;IACI,KAAK;QACV,IAAI,IAAI,CAAC,OAAO,KAAK,SAAS;YAAE,OAAO,IAAI,CAAC,OAAO,CAAC;QACpD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;YAAE,MAAM,CAAC,IAAI,CAAC,CAAC;QAC1D,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,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AAY;IAC7B,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAyB,CAAC;IACxD,OAAO,MAAM,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AAC9E,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { TtscGraphReadonly } from "./TtscGraphReadonly";
2
+ /**
3
+ * Detach frozen graph records into a caller-owned mutable DTO projection.
4
+ *
5
+ * @evidence contracts/common.md#principled-implementation structuredClone detaches every nested array and record before restoring the mutable wire DTO type at the ownership transfer.
6
+ * @evidence contracts/common.md#clear-and-simple-design One inverse ownership operation keeps retained snapshots separate from editable output records.
7
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The mutable return type is backed by a detached copy rather than a cast that exposes the retained frozen snapshot.
8
+ * @evidence contracts/common.md#meaningful-documentation Native prose states that this operation transfers an independent mutable DTO to its caller.
9
+ * @evidence contracts/performance.md#efficient-algorithms One structured clone copies the requested record population without repeated serialization or field-by-field intermediate copies.
10
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work The store owns continued shard reuse; a mutable output requires independent ownership rather than shared result aliases.
11
+ * @evidence contracts/performance.md#bound-retention-and-release-resources The detached result transfers to the caller and this helper retains no historical copies.
12
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation one structuredClone of in-memory records; no file, path or process is touched.
13
+ */
14
+ export declare function copyGraphRecords<T>(value: TtscGraphReadonly<T>): T;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.copyGraphRecords = copyGraphRecords;
4
+ /**
5
+ * Detach frozen graph records into a caller-owned mutable DTO projection.
6
+ *
7
+ * @evidence contracts/common.md#principled-implementation structuredClone detaches every nested array and record before restoring the mutable wire DTO type at the ownership transfer.
8
+ * @evidence contracts/common.md#clear-and-simple-design One inverse ownership operation keeps retained snapshots separate from editable output records.
9
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The mutable return type is backed by a detached copy rather than a cast that exposes the retained frozen snapshot.
10
+ * @evidence contracts/common.md#meaningful-documentation Native prose states that this operation transfers an independent mutable DTO to its caller.
11
+ * @evidence contracts/performance.md#efficient-algorithms One structured clone copies the requested record population without repeated serialization or field-by-field intermediate copies.
12
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work The store owns continued shard reuse; a mutable output requires independent ownership rather than shared result aliases.
13
+ * @evidence contracts/performance.md#bound-retention-and-release-resources The detached result transfers to the caller and this helper retains no historical copies.
14
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation one structuredClone of in-memory records; no file, path or process is touched.
15
+ */
16
+ function copyGraphRecords(value) {
17
+ return structuredClone(value);
18
+ }
19
+ //# sourceMappingURL=copyGraphRecords.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"copyGraphRecords.js","sourceRoot":"","sources":["../../src/model/copyGraphRecords.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;GAWG;AACH,0BAAoC,KAA2B;IAC7D,OAAO,eAAe,CAAC,KAAK,CAAM,CAAC;AACrC,CAAC"}
@@ -0,0 +1,17 @@
1
+ import type { TtscGraphReadonly } from "./TtscGraphReadonly";
2
+ /**
3
+ * Copy and freeze plain graph DTO records before retaining or exposing them.
4
+ *
5
+ * The caller keeps ownership of its input. Graph DTOs contain records, arrays
6
+ * and primitive values, rather than mutable Map/Set or native handle objects.
7
+ *
8
+ * @evidence contracts/common.md#principled-implementation structuredClone detaches nested caller aliases before recursive freezing establishes an immutable owned fact population.
9
+ * @evidence contracts/common.md#clear-and-simple-design One ownership boundary is shared by model and shard storage rather than separate partial field-copy lists.
10
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Caller-owned objects are never frozen to compensate for a borrowed snapshot alias.
11
+ * @evidence contracts/common.md#meaningful-documentation Native prose states input ownership and the plain-DTO precondition, avoiding claims about mutable native collections.
12
+ * @evidence contracts/performance.md#efficient-algorithms One structured clone detaches the population and a WeakSet visits each owned record once during freezing; work and temporary visited storage scale with copied facts.
13
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work Model construction and shard transactions decide snapshot reuse; this ownership primitive performs one requested detachment.
14
+ * @evidence contracts/performance.md#bound-retention-and-release-resources Only the detached frozen result transfers to the caller; visited identities are local and no global population is retained.
15
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation one structuredClone and a recursive freeze of in-memory records; no file, path or process is touched.
16
+ */
17
+ export declare function copyGraphSnapshot<T>(value: T): TtscGraphReadonly<T>;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.copyGraphSnapshot = copyGraphSnapshot;
4
+ /**
5
+ * Copy and freeze plain graph DTO records before retaining or exposing them.
6
+ *
7
+ * The caller keeps ownership of its input. Graph DTOs contain records, arrays
8
+ * and primitive values, rather than mutable Map/Set or native handle objects.
9
+ *
10
+ * @evidence contracts/common.md#principled-implementation structuredClone detaches nested caller aliases before recursive freezing establishes an immutable owned fact population.
11
+ * @evidence contracts/common.md#clear-and-simple-design One ownership boundary is shared by model and shard storage rather than separate partial field-copy lists.
12
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Caller-owned objects are never frozen to compensate for a borrowed snapshot alias.
13
+ * @evidence contracts/common.md#meaningful-documentation Native prose states input ownership and the plain-DTO precondition, avoiding claims about mutable native collections.
14
+ * @evidence contracts/performance.md#efficient-algorithms One structured clone detaches the population and a WeakSet visits each owned record once during freezing; work and temporary visited storage scale with copied facts.
15
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work Model construction and shard transactions decide snapshot reuse; this ownership primitive performs one requested detachment.
16
+ * @evidence contracts/performance.md#bound-retention-and-release-resources Only the detached frozen result transfers to the caller; visited identities are local and no global population is retained.
17
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation one structuredClone and a recursive freeze of in-memory records; no file, path or process is touched.
18
+ */
19
+ function copyGraphSnapshot(value) {
20
+ const owned = structuredClone(value);
21
+ freezeRecords(owned, new WeakSet());
22
+ return owned;
23
+ }
24
+ /** Visit each owned record once, including shared or cyclic references. */
25
+ function freezeRecords(value, visited) {
26
+ if (value === null || typeof value !== "object" || visited.has(value))
27
+ return;
28
+ visited.add(value);
29
+ for (const child of Object.values(value))
30
+ freezeRecords(child, visited);
31
+ Object.freeze(value);
32
+ }
33
+ //# sourceMappingURL=copyGraphSnapshot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"copyGraphSnapshot.js","sourceRoot":"","sources":["../../src/model/copyGraphSnapshot.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;;;;GAcG;AACH,2BAAqC,KAAQ;IAC3C,MAAM,KAAK,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;IACrC,aAAa,CAAC,KAAK,EAAE,IAAI,OAAO,EAAU,CAAC,CAAC;IAC5C,OAAO,KAA6B,CAAC;AACvC,CAAC;AAED,2EAA2E;AAC3E,SAAS,aAAa,CAAC,KAAc,EAAE,OAAwB;IAC7D,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC;QAAE,OAAO;IAC9E,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACnB,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;QAAE,aAAa,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACxE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC"}
@@ -4,21 +4,12 @@ import { TtscGraphMemory } from "./TtscGraphMemory";
4
4
  * The dump schema version this client reads.
5
5
  *
6
6
  * Keep it equal to `DumpSchemaVersion` in
7
- * `packages/ttsc/internal/graph/provenance.go`. The two are hand-synchronized,
8
- * and `dump_schema_version_matches_the_typescript_client_test.go` reads this
9
- * constant out of this file and fails if the pair drifts.
7
+ * `packages/ttsc/internal/graph/provenance.go`. The two are hand-synchronized.
10
8
  *
11
9
  * Exported because the resident session reads the same dump body over the serve
12
10
  * protocol and has to hold it to the same number: the envelope's version and
13
11
  * the body's are independent, so a producer can speak this protocol and still
14
12
  * send a body from another schema.
15
- *
16
- * `scripts/assert-ttscgraph-release-candidate.cjs` reads this declaration out
17
- * of this file with a regular expression, because it runs against a packaged
18
- * binary in a workflow that has no reason to have built this package first.
19
- * Rewriting the declaration — adding a type annotation, splitting the line —
20
- * makes that script fail loudly rather than silently, and its message names
21
- * this constant; update its pattern with any such change.
22
13
  */
23
14
  export declare const DUMP_SCHEMA_VERSION = 8;
24
15
  /**
@@ -30,6 +21,15 @@ export declare const DUMP_SCHEMA_VERSION = 8;
30
21
  * Throws when the binary cannot be resolved, the dump command fails, or its
31
22
  * output is not a readable graph — the server surfaces the failure rather than
32
23
  * answering from an empty graph.
24
+ *
25
+ * @evidence contracts/common.md#principled-implementation The selected native producer builds the target project and its JSON is schema-version checked and structurally validated before model construction.
26
+ * @evidence contracts/common.md#clear-and-simple-design One-shot process execution, capture ownership and parse validation have separate helpers; the resident MCP path remains a different lifetime owner.
27
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Failed resolution or native execution throws rather than returning an invented empty graph.
28
+ * @evidence contracts/common.md#meaningful-documentation Native paragraphs state direct/viewer usage, project/binary defaults and every externally visible failure boundary.
29
+ * @evidence contracts/portability.md#os-neutral-implementation Native argv carries cwd, tsconfig and artifact paths without a shell; project-anchored binary resolution and permission repair account for host execution differences.
30
+ * @evidence contracts/performance.md#efficient-algorithms One native dump is followed by linear JSON parsing/validation and model indexing; output is file-backed rather than constrained by a guessed pipe budget.
31
+ * @evidence contracts/performance.md#reuse-equivalent-work Direct loads intentionally build the requested current project anew; callers needing repeated equivalent snapshots use TtscGraphSession's resident producer and model.
32
+ * @evidence contracts/performance.md#bound-retention-and-release-resources The operation owns two capture descriptors until the finally block disposes them; returned graph ownership transfers to the caller, while artifact storage remains process/project scoped.
33
33
  */
34
34
  export declare function loadGraph(options?: {
35
35
  /** Project root the graph is built for (default: `process.cwd()`). */
@@ -55,5 +55,14 @@ export declare function loadGraph(options?: {
55
55
  * outlives the process that wrote it — this is the one-shot path, and the JSON
56
56
  * on disk may be from any build — so the version is the first question to ask
57
57
  * of it.
58
+ *
59
+ * @evidence contracts/common.md#principled-implementation Parsing to unknown, reading schema version first and then asserting the full wire type reject mismatched producers before interpreting their shape.
60
+ * @evidence contracts/common.md#clear-and-simple-design This boundary owns dump decoding and validation for direct loads; model construction remains separate.
61
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Malformed JSON and incompatible schemas do not become empty or partially trusted graph facts.
62
+ * @evidence contracts/common.md#meaningful-documentation Native paragraphs explain version-before-shape ordering and why persisted dumps require independent validation.
63
+ * @evidence contracts/performance.md#efficient-algorithms JSON parsing and shape validation process the dump once before model indexing; cost grows with serialized bytes and graph facts.
64
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work This parser validates a supplied exchange string; loadGraph/session own producer sharing and generation identity.
65
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources Parsed data transfers to TtscGraphMemory; this operation acquires no native handle or historical cache.
66
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation Parsing serialized graph facts performs no native filesystem or process operation.
58
67
  */
59
68
  export declare function parseDump(json: string): ITtscGraphDump;