@ttsc/graph 0.30.4 → 0.31.1

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,10 +1,11 @@
1
1
  import { TtscGraphMemory } from "../model/TtscGraphMemory";
2
+ import { TtscGraphReadonly } from "../model/TtscGraphReadonly";
2
3
  import { ITtscGraphDetails } from "../structures/ITtscGraphDetails";
3
4
  import { ITtscGraphEdge } from "../structures/ITtscGraphEdge";
4
5
  import { ITtscGraphEntrypoints } from "../structures/ITtscGraphEntrypoints";
5
6
  import { ITtscGraphEvidence } from "../structures/ITtscGraphEvidence";
6
7
  import { ITtscGraphNext } from "../structures/ITtscGraphNext";
7
- import { ITtscGraphNode } from "../structures/ITtscGraphNode";
8
+ import { ITtscGraphNode as NodeShape } from "../structures/ITtscGraphNode";
8
9
  import { ITtscGraphTour } from "../structures/ITtscGraphTour";
9
10
  import { ITtscGraphTrace } from "../structures/ITtscGraphTrace";
10
11
  import { exportFanIn, hasExportSurface } from "./exportSurface";
@@ -15,6 +16,8 @@ import { decoratorsOf, docOf, runDetails, signatureOf } from "./runDetails";
15
16
  import { runEntrypoints } from "./runEntrypoints";
16
17
  import { hasDeclarationBody, runTrace } from "./runTrace";
17
18
 
19
+ type ITtscGraphNode = TtscGraphReadonly<NodeShape>;
20
+
18
21
  const DEFAULT_LIMIT = 5;
19
22
  const MAX_LIMIT = 5;
20
23
  /**
@@ -69,6 +72,15 @@ const TOUR_SEED_KINDS = new Set<ITtscGraphNode["kind"]>([
69
72
  * Compose a repository-orientation/code-tour answer surface from existing graph
70
73
  * operations. It returns selected symbols, flows, nearby edges, test anchors,
71
74
  * and answer anchors without reading or embedding source bodies.
75
+ *
76
+ * @evidence contracts/common.md#principled-implementation The tour combines bounded execution traces and graph-derived ranking; named seeds and graph-selected seeds retain separate shares rather than treating identifier matches as question coverage.
77
+ * @evidence contracts/common.md#clear-and-simple-design Existing entrypoint, trace and detail operations own their projections; this composer owns seed selection, flow overlap and orientation anchors.
78
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Ranking is an explicit heuristic over graph facts, not a fabricated completeness claim or a lexical patch for the user's question.
79
+ * @evidence contracts/common.md#meaningful-documentation Native prose names the composition and body-free output; centrality documentation states the implemented heuristic rather than claiming PageRank.
80
+ * @evidence contracts/performance.md#efficient-algorithms Centrality scans graph candidates once, with per-candidate reach limited to four levels and not deepened once 400 nodes have been seen, so a single dense level can exceed 400 and the reach work is bounded by depth rather than by that budget; sorting costs O(V log V), while returned flows have fixed seed and trace budgets.
81
+ * @evidence contracts/performance.md#reuse-equivalent-work Centrality is shared through a WeakMap keyed by the owned frozen graph generation; a new graph computes its own ranks, while request-specific query alignment remains separate.
82
+ * @evidence contracts/performance.md#bound-retention-and-release-resources Cached rank maps remain reachable only while their graph key is reachable; request-local candidate sets and bounded flows are returned or released at completion.
83
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation composes in-memory runners; its only source reads go through graph.source.
72
84
  */
73
85
  export function runTour(
74
86
  graph: TtscGraphMemory,
@@ -466,22 +478,8 @@ function flowStartOf(node: ITtscGraphTrace.INode): ITtscGraphTour.INode {
466
478
  };
467
479
  }
468
480
 
469
- function flowAnchorsOf(
470
- trace: ITtscGraphTrace,
471
- hops: ITtscGraphTrace.IHop[],
472
- reached: ITtscGraphTrace.INode[],
473
- ): ITtscGraphTour.IAnchor[] {
474
- return uniqueAnchors([
475
- ...anchorFromNode("flow start", trace.start),
476
- ...reached.flatMap((node) => anchorFromNode("flow node", node)),
477
- ...hops.flatMap((hop) =>
478
- anchorFromEvidence("flow edge", `${hop.from} -> ${hop.to}`, hop.evidence),
479
- ),
480
- ]);
481
- }
482
-
483
481
  /**
484
- * The words of the question that could name code: the ranking's own terms.
482
+ * Identifier terms from the caller's symbol guesses used to align ranking.
485
483
  *
486
484
  * A question about TypeORM says "TypeORM", which splits into `type` and `orm`,
487
485
  * and both are inside the project's own name — they say nothing about which
@@ -526,23 +524,11 @@ function rankedTourSeeds(
526
524
  }
527
525
 
528
526
  /**
529
- * How central a symbol is to running this codebase, as one standard algorithm
530
- * instead of a ledger of hand-tuned bonuses.
527
+ * Rank a seed by normalized publication, bounded execution reach and fan-in,
528
+ * then apply the caller's identifier alignment and broad-tour damping.
531
529
  *
532
- * This score used to be a sum: so many points for the symbol's kind, so many
533
- * per log of each degree, a capped term for its reach, another for what its
534
- * package exports, another for what the tests call — nine signals, each with a
535
- * multiplier and a cap that someone picked while watching a benchmark. Word
536
- * lists in numeric form. All of it was approximating one question the graph can
537
- * answer exactly: _if you use what this package publishes, what runs?_
538
- *
539
- * Personalized PageRank answers it. The walker starts on the export surface —
540
- * the symbols the package puts on the wire, members included — and follows the
541
- * execution edges, crossing from an abstract declaration to its implementations
542
- * the way `runTrace` does. Public entries hold mass because the walk starts on
543
- * them; the spine holds mass because every path runs through it. One damping
544
- * constant, 0.85, from the literature — the same algorithm aider's repo map
545
- * ranks symbols with.
530
+ * This is a graph-structure heuristic, not PageRank or proof that a seed
531
+ * answers the question. `computeCentrality` owns the underlying score.
546
532
  */
547
533
  function tourSeedScore(
548
534
  graph: TtscGraphMemory,
@@ -561,6 +547,10 @@ function tourSeedScore(
561
547
  const CENTRALITY_SCALE = 100;
562
548
  /** Execution reach is walked this deep and no further. */
563
549
  const REACH_DEPTH = 4;
550
+ /**
551
+ * Reach stops descending to another level once this many nodes are seen. The
552
+ * check runs between levels, so one level may add more than this budget.
553
+ */
564
554
  const REACH_NODE_BUDGET = 400;
565
555
  /** Invocation: the edges that mean "this makes that run". */
566
556
  const INVOKE_KINDS = new Set<string>(["calls", "instantiates", "renders"]);
@@ -764,6 +754,25 @@ function isTourTraceNode(
764
754
  return graph.node(node.id)?.closure !== true && !isNoisePath(node.file);
765
755
  }
766
756
 
757
+ /**
758
+ * The nodes a flow reached, derived from the hops that survived.
759
+ *
760
+ * Deriving it rather than filtering it beside them is what makes a dangling
761
+ * step impossible: a step can only name endpoints of a kept hop, and every such
762
+ * endpoint is here. Filtering the two independently is what let a step narrate
763
+ * a chain from a node the same flow reported it had never reached.
764
+ */
765
+ function reachedOf(
766
+ graph: TtscGraphMemory,
767
+ trace: ITtscGraphTrace,
768
+ hops: readonly ITtscGraphTrace.IHop[],
769
+ ): ITtscGraphTrace.INode[] {
770
+ const touched = new Set(hops.flatMap((hop) => [hop.from, hop.to]));
771
+ return trace.reached.filter(
772
+ (node) => touched.has(node.id) && isTourTraceNode(graph, node),
773
+ );
774
+ }
775
+
767
776
  /**
768
777
  * The hops a flow keeps, and the hops it would keep if the cut were not
769
778
  * applied.
@@ -785,25 +794,6 @@ function isTourTraceNode(
785
794
  * logger never displaces a real chain and a lone terminal action is never
786
795
  * erased.
787
796
  */
788
- /**
789
- * The nodes a flow reached, derived from the hops that survived.
790
- *
791
- * Deriving it rather than filtering it beside them is what makes a dangling
792
- * step impossible: a step can only name endpoints of a kept hop, and every such
793
- * endpoint is here. Filtering the two independently is what let a step narrate
794
- * a chain from a node the same flow reported it had never reached.
795
- */
796
- function reachedOf(
797
- graph: TtscGraphMemory,
798
- trace: ITtscGraphTrace,
799
- hops: readonly ITtscGraphTrace.IHop[],
800
- ): ITtscGraphTrace.INode[] {
801
- const touched = new Set(hops.flatMap((hop) => [hop.from, hop.to]));
802
- return trace.reached.filter(
803
- (node) => touched.has(node.id) && isTourTraceNode(graph, node),
804
- );
805
- }
806
-
807
797
  function tourHops(
808
798
  graph: TtscGraphMemory,
809
799
  hops: readonly ITtscGraphTrace.IHop[],
@@ -895,16 +885,6 @@ function executionDegree(
895
885
  return { in: incoming, out: outgoing };
896
886
  }
897
887
 
898
- /**
899
- * What the declaration is, scored by what it does rather than how it was
900
- * written. `export const parse = (input) => ...` is a function that happens to
901
- * be bound to a name, and the checker sees it call things; scoring it eight
902
- * points against a method's twenty-eight is a bias toward one syntax, and it
903
- * cost zod its own public API — `parse` and `safeParse`, both const arrows,
904
- * lost their tour seats to `ZodType.safeParse`, a method of the previous
905
- * major.
906
- */
907
-
908
888
  /**
909
889
  * How many modules put a symbol on the wire — counting the one that owns it.
910
890
  *
@@ -937,25 +917,6 @@ function ownerOf(graph: TtscGraphMemory, id: string): string | undefined {
937
917
  return undefined;
938
918
  }
939
919
 
940
- /**
941
- * What a user of this package can call, as the graph knows it.
942
- *
943
- * This used to pay for an English verb anywhere in the name — `create`,
944
- * `parse`, `render`, `subscribe` — and for a class whose name contained `app`,
945
- * `server` or `factory`. Neither is a fact about the code. They are a guess
946
- * about the language its authors happened to write in, and a codebase that
947
- * names its entry `起動` or `mk` or `boot` is one the guess is simply wrong
948
- * about. It was also wrong in English: `onRenderTracked` is a devtools hook and
949
- * it took the bonus for the "render" inside it, outranking `track`, the
950
- * function it is named after.
951
- *
952
- * Two facts say the same thing without reading a word of the name. The package
953
- * _publishes_ this symbol — that is its export surface, counted in
954
- * {@link exportFanIn} — and it is a _callable_, so publishing it is publishing
955
- * something to run. A user calls what a package exports and what a package
956
- * exports to be called.
957
- */
958
-
959
920
  function queryMatchScore(node: ITtscGraphNode, terms: string[]): number {
960
921
  return (
961
922
  matchedQueryTerms(node, terms).size * 8 +
@@ -998,8 +959,9 @@ function matchedTerms(words: string[], terms: string[]): Set<string> {
998
959
  * It picks `count` of them, not all of them. Ordering every candidate cost
999
960
  * O(n²) — on VS Code, where tens of thousands of symbols score above zero, one
1000
961
  * tour spent six minutes ranking seeds it then threw away, because the caller
1001
- * keeps only the first few. Stopping at `count` makes the cover O(count · n),
1002
- * and the picks it does make are the same ones.
962
+ * keeps only the first few. Stopping at `count` makes the cover O(count · n)
963
+ * candidate visits, each comparing against the picks so far, and the picks it
964
+ * does make are the same ones.
1003
965
  */
1004
966
  function diverseTourSeeds<
1005
967
  T extends {