@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.
- package/README.md +122 -30
- package/lib/CapturedProcessOutput.d.ts +47 -0
- package/lib/CapturedProcessOutput.js +3 -0
- package/lib/CapturedProcessOutput.js.map +1 -0
- package/lib/ILauncherOption.d.ts +22 -0
- package/lib/ILauncherOption.js +3 -0
- package/lib/ILauncherOption.js.map +1 -0
- package/lib/IProjectOptions.d.ts +18 -0
- package/lib/IProjectOptions.js +3 -0
- package/lib/IProjectOptions.js.map +1 -0
- package/lib/ParsedLauncherOptions.d.ts +13 -0
- package/lib/ParsedLauncherOptions.js +3 -0
- package/lib/ParsedLauncherOptions.js.map +1 -0
- package/lib/TtscGraphApplication.d.ts +38 -1
- package/lib/TtscGraphApplication.js +26 -1
- package/lib/TtscGraphApplication.js.map +1 -1
- package/lib/TtscGraphLauncherArguments.d.ts +115 -0
- package/lib/TtscGraphLauncherArguments.js +181 -0
- package/lib/TtscGraphLauncherArguments.js.map +1 -0
- package/lib/TtscGraphViewSnapshot.d.ts +35 -0
- package/lib/TtscGraphViewSnapshot.js +48 -0
- package/lib/TtscGraphViewSnapshot.js.map +1 -0
- package/lib/index.d.ts +9 -24
- package/lib/index.js +6 -128
- package/lib/index.js.map +1 -1
- package/lib/internal/GraphProcessTrace.d.ts +1 -0
- package/lib/internal/GraphProcessTrace.js +235 -0
- package/lib/internal/GraphProcessTrace.js.map +1 -0
- package/lib/launcherArgs.d.ts +75 -16
- package/lib/launcherArgs.js +77 -8
- package/lib/launcherArgs.js.map +1 -1
- package/lib/model/IArtifactDirectory.d.ts +26 -0
- package/lib/model/IArtifactDirectory.js +3 -0
- package/lib/model/IArtifactDirectory.js.map +1 -0
- package/lib/model/IArtifactInputs.d.ts +19 -0
- package/lib/model/IArtifactInputs.js +3 -0
- package/lib/model/IArtifactInputs.js.map +1 -0
- package/lib/model/IPublishedArtifacts.d.ts +76 -0
- package/lib/model/IPublishedArtifacts.js +3 -0
- package/lib/model/IPublishedArtifacts.js.map +1 -0
- package/lib/model/IPublishedArtifactsResident.d.ts +19 -0
- package/lib/model/IPublishedArtifactsResident.js +3 -0
- package/lib/model/IPublishedArtifactsResident.js.map +1 -0
- package/lib/model/ITtscLintDaemonTarget.d.ts +20 -0
- package/lib/model/ITtscLintDaemonTarget.js +3 -0
- package/lib/model/ITtscLintDaemonTarget.js.map +1 -0
- package/lib/model/TtscGraphLinePeer.d.ts +146 -0
- package/lib/model/TtscGraphLinePeer.js +213 -0
- package/lib/model/TtscGraphLinePeer.js.map +1 -0
- package/lib/model/TtscGraphMemory.d.ts +156 -16
- package/lib/model/TtscGraphMemory.js +228 -222
- package/lib/model/TtscGraphMemory.js.map +1 -1
- package/lib/model/TtscGraphNativeArguments.d.ts +40 -0
- package/lib/model/TtscGraphNativeArguments.js +64 -0
- package/lib/model/TtscGraphNativeArguments.js.map +1 -0
- package/lib/model/TtscGraphNodeId.d.ts +55 -3
- package/lib/model/TtscGraphNodeId.js +40 -2
- package/lib/model/TtscGraphNodeId.js.map +1 -1
- package/lib/model/TtscGraphProjection.d.ts +156 -0
- package/lib/model/TtscGraphProjection.js +390 -0
- package/lib/model/TtscGraphProjection.js.map +1 -0
- package/lib/model/TtscGraphProtocol.d.ts +28 -0
- package/lib/model/TtscGraphProtocol.js +928 -0
- package/lib/model/TtscGraphProtocol.js.map +1 -0
- package/lib/model/TtscGraphReadonly.d.ts +15 -0
- package/lib/model/TtscGraphReadonly.js +3 -0
- package/lib/model/TtscGraphReadonly.js.map +1 -0
- package/lib/model/TtscGraphRequestOptions.d.ts +16 -0
- package/lib/model/TtscGraphRequestOptions.js +3 -0
- package/lib/model/TtscGraphRequestOptions.js.map +1 -0
- package/lib/model/TtscGraphSession.d.ts +82 -36
- package/lib/model/TtscGraphSession.js +164 -1238
- package/lib/model/TtscGraphSession.js.map +1 -1
- package/lib/model/TtscGraphSessionOptions.d.ts +20 -0
- package/lib/model/TtscGraphSessionOptions.js +3 -0
- package/lib/model/TtscGraphSessionOptions.js.map +1 -0
- package/lib/model/TtscGraphSessionState.d.ts +187 -0
- package/lib/model/TtscGraphSessionState.js +417 -0
- package/lib/model/TtscGraphSessionState.js.map +1 -0
- package/lib/model/TtscGraphShardStore.d.ts +64 -3
- package/lib/model/TtscGraphShardStore.js +85 -15
- package/lib/model/TtscGraphShardStore.js.map +1 -1
- package/lib/model/TtscGraphSourceReader.d.ts +31 -8
- package/lib/model/TtscGraphSourceReader.js +37 -13
- package/lib/model/TtscGraphSourceReader.js.map +1 -1
- package/lib/model/TtscLintDaemon.d.ts +35 -17
- package/lib/model/TtscLintDaemon.js +39 -117
- package/lib/model/TtscLintDaemon.js.map +1 -1
- package/lib/model/TtscLintDaemonState.d.ts +69 -0
- package/lib/model/TtscLintDaemonState.js +166 -0
- package/lib/model/TtscLintDaemonState.js.map +1 -0
- package/lib/model/copyGraphRecords.d.ts +14 -0
- package/lib/model/copyGraphRecords.js +19 -0
- package/lib/model/copyGraphRecords.js.map +1 -0
- package/lib/model/copyGraphSnapshot.d.ts +17 -0
- package/lib/model/copyGraphSnapshot.js +33 -0
- package/lib/model/copyGraphSnapshot.js.map +1 -0
- package/lib/model/loadGraph.d.ts +19 -10
- package/lib/model/loadGraph.js +21 -12
- package/lib/model/loadGraph.js.map +1 -1
- package/lib/model/publishedArtifacts.d.ts +78 -97
- package/lib/model/publishedArtifacts.js +271 -85
- package/lib/model/publishedArtifacts.js.map +1 -1
- package/lib/nativeExecutable.d.ts +19 -8
- package/lib/nativeExecutable.js +75 -15
- package/lib/nativeExecutable.js.map +1 -1
- package/lib/reduce.d.ts +19 -45
- package/lib/reduce.js +19 -3
- package/lib/reduce.js.map +1 -1
- package/lib/resolveGraphBinary.d.ts +9 -0
- package/lib/resolveGraphBinary.js +11 -3
- package/lib/resolveGraphBinary.js.map +1 -1
- package/lib/runGraph.d.ts +21 -0
- package/lib/runGraph.js +83 -0
- package/lib/runGraph.js.map +1 -0
- package/lib/server/IResolvedGraphHandle.d.ts +22 -0
- package/lib/server/IResolvedGraphHandle.js +3 -0
- package/lib/server/IResolvedGraphHandle.js.map +1 -0
- package/lib/server/createServer.d.ts +14 -10
- package/lib/server/createServer.js +42 -39
- package/lib/server/createServer.js.map +1 -1
- package/lib/server/exportSurface.d.ts +23 -1
- package/lib/server/exportSurface.js +23 -1
- package/lib/server/exportSurface.js.map +1 -1
- package/lib/server/formatGraphFailure.d.ts +20 -0
- package/lib/server/formatGraphFailure.js +35 -0
- package/lib/server/formatGraphFailure.js.map +1 -0
- package/lib/server/pathPolicy.d.ts +70 -5
- package/lib/server/pathPolicy.js +66 -4
- package/lib/server/pathPolicy.js.map +1 -1
- package/lib/server/resolveHandle.d.ts +10 -5
- package/lib/server/resolveHandle.js +39 -7
- package/lib/server/resolveHandle.js.map +1 -1
- package/lib/server/resultAudit.d.ts +17 -14
- package/lib/server/resultAudit.js +56 -27
- package/lib/server/resultAudit.js.map +1 -1
- package/lib/server/resultNext.d.ts +26 -1
- package/lib/server/resultNext.js +14 -0
- package/lib/server/resultNext.js.map +1 -1
- package/lib/server/runDetails.d.ts +72 -15
- package/lib/server/runDetails.js +104 -69
- package/lib/server/runDetails.js.map +1 -1
- package/lib/server/runEntrypoints.d.ts +9 -0
- package/lib/server/runEntrypoints.js +9 -0
- package/lib/server/runEntrypoints.js.map +1 -1
- package/lib/server/runLookup.d.ts +13 -3
- package/lib/server/runLookup.js +19 -6
- package/lib/server/runLookup.js.map +1 -1
- package/lib/server/runOverview.d.ts +13 -4
- package/lib/server/runOverview.js +13 -4
- package/lib/server/runOverview.js.map +1 -1
- package/lib/server/runTour.d.ts +9 -0
- package/lib/server/runTour.js +33 -65
- package/lib/server/runTour.js.map +1 -1
- package/lib/server/runTrace.d.ts +25 -1
- package/lib/server/runTrace.js +133 -88
- package/lib/server/runTrace.js.map +1 -1
- package/lib/server/startServer.d.ts +16 -0
- package/lib/server/startServer.js +24 -1
- package/lib/server/startServer.js.map +1 -1
- package/lib/structures/ITtscGraphApplication.d.ts +95 -41
- package/lib/structures/ITtscGraphDecorator.d.ts +18 -0
- package/lib/structures/ITtscGraphDetails.d.ts +81 -6
- package/lib/structures/ITtscGraphDocTag.d.ts +17 -8
- package/lib/structures/ITtscGraphDump.d.ts +106 -8
- package/lib/structures/ITtscGraphEdge.d.ts +14 -2
- package/lib/structures/ITtscGraphEntrypoints.d.ts +81 -6
- package/lib/structures/ITtscGraphEscape.d.ts +24 -2
- package/lib/structures/ITtscGraphEvidence.d.ts +9 -0
- package/lib/structures/ITtscGraphLookup.d.ts +42 -9
- package/lib/structures/ITtscGraphNext.d.ts +12 -1
- package/lib/structures/ITtscGraphNode.d.ts +38 -11
- package/lib/structures/ITtscGraphOverview.d.ts +81 -6
- package/lib/structures/ITtscGraphSnapshot.d.ts +97 -2
- package/lib/structures/ITtscGraphSpan.d.ts +9 -0
- package/lib/structures/ITtscGraphTour.d.ts +83 -9
- package/lib/structures/ITtscGraphTrace.d.ts +99 -14
- package/lib/structures/RawDump.d.ts +22 -0
- package/lib/structures/RawDump.js +3 -0
- package/lib/structures/RawDump.js.map +1 -0
- package/lib/structures/RawEdge.d.ts +20 -0
- package/lib/structures/RawEdge.js +3 -0
- package/lib/structures/RawEdge.js.map +1 -0
- package/lib/structures/RawNode.d.ts +26 -0
- package/lib/structures/RawNode.js +3 -0
- package/lib/structures/RawNode.js.map +1 -0
- package/lib/structures/TtscGraphArtifactNodeKind.d.ts +9 -0
- package/lib/structures/TtscGraphArtifactNodeKind.js +9 -0
- package/lib/structures/TtscGraphArtifactNodeKind.js.map +1 -1
- package/lib/structures/TtscGraphDumpEdgeKind.d.ts +15 -1
- package/lib/structures/TtscGraphDumpNodeKind.d.ts +9 -0
- package/lib/structures/TtscGraphEdgeKind.d.ts +13 -4
- package/lib/structures/TtscGraphNodeKind.d.ts +9 -0
- package/lib/structures/TtscGraphNodeModifier.d.ts +9 -0
- package/lib/structures/ViewerLink.d.ts +20 -0
- package/lib/structures/ViewerLink.js +3 -0
- package/lib/structures/ViewerLink.js.map +1 -0
- package/lib/structures/ViewerNode.d.ts +24 -0
- package/lib/structures/ViewerNode.js +3 -0
- package/lib/structures/ViewerNode.js.map +1 -0
- package/lib/structures/ViewerPayload.d.ts +42 -0
- package/lib/structures/ViewerPayload.js +3 -0
- package/lib/structures/ViewerPayload.js.map +1 -0
- package/lib/view.d.ts +9 -0
- package/lib/view.js +203 -91
- package/lib/view.js.map +1 -1
- package/lib/viewer/viewer.js +1 -1
- package/package.json +8 -6
- package/src/CapturedProcessOutput.ts +50 -0
- package/src/ILauncherOption.ts +24 -0
- package/src/IProjectOptions.ts +19 -0
- package/src/ParsedLauncherOptions.ts +13 -0
- package/src/TtscGraphApplication.ts +38 -1
- package/src/TtscGraphLauncherArguments.ts +207 -0
- package/src/TtscGraphViewSnapshot.ts +46 -0
- package/src/index.ts +9 -160
- package/src/internal/GraphProcessTrace.ts +242 -0
- package/src/launcherArgs.ts +89 -23
- package/src/model/IArtifactDirectory.ts +27 -0
- package/src/model/IArtifactInputs.ts +21 -0
- package/src/model/IPublishedArtifacts.ts +81 -0
- package/src/model/IPublishedArtifactsResident.ts +24 -0
- package/src/model/ITtscLintDaemonTarget.ts +22 -0
- package/src/model/TtscGraphLinePeer.ts +318 -0
- package/src/model/TtscGraphMemory.ts +284 -246
- package/src/model/TtscGraphNativeArguments.ts +67 -0
- package/src/model/TtscGraphNodeId.ts +57 -3
- package/src/model/TtscGraphProjection.ts +473 -0
- package/src/model/TtscGraphProtocol.ts +90 -0
- package/src/model/TtscGraphReadonly.ts +17 -0
- package/src/model/TtscGraphRequestOptions.ts +16 -0
- package/src/model/TtscGraphSession.ts +196 -475
- package/src/model/TtscGraphSessionOptions.ts +22 -0
- package/src/model/TtscGraphSessionState.ts +558 -0
- package/src/model/TtscGraphShardStore.ts +99 -23
- package/src/model/TtscGraphSourceReader.ts +37 -15
- package/src/model/TtscLintDaemon.ts +55 -136
- package/src/model/TtscLintDaemonState.ts +174 -0
- package/src/model/copyGraphRecords.ts +17 -0
- package/src/model/copyGraphSnapshot.ts +30 -0
- package/src/model/loadGraph.ts +23 -12
- package/src/model/publishedArtifacts.ts +361 -182
- package/src/nativeExecutable.ts +93 -26
- package/src/reduce.ts +24 -51
- package/src/resolveGraphBinary.ts +13 -3
- package/src/runGraph.ts +90 -0
- package/src/server/IResolvedGraphHandle.ts +24 -0
- package/src/server/createServer.ts +16 -22
- package/src/server/exportSurface.ts +23 -1
- package/src/server/formatGraphFailure.ts +32 -0
- package/src/server/pathPolicy.ts +70 -5
- package/src/server/resolveHandle.ts +45 -14
- package/src/server/resultAudit.ts +58 -27
- package/src/server/resultNext.ts +26 -1
- package/src/server/runDetails.ts +138 -73
- package/src/server/runEntrypoints.ts +13 -1
- package/src/server/runLookup.ts +23 -7
- package/src/server/runOverview.ts +17 -5
- package/src/server/runTour.ts +44 -82
- package/src/server/runTrace.ts +175 -102
- package/src/server/startServer.ts +29 -1
- package/src/structures/ITtscGraphApplication.ts +95 -41
- package/src/structures/ITtscGraphDecorator.ts +18 -0
- package/src/structures/ITtscGraphDetails.ts +81 -6
- package/src/structures/ITtscGraphDocTag.ts +17 -8
- package/src/structures/ITtscGraphDump.ts +106 -8
- package/src/structures/ITtscGraphEdge.ts +14 -2
- package/src/structures/ITtscGraphEntrypoints.ts +81 -6
- package/src/structures/ITtscGraphEscape.ts +24 -2
- package/src/structures/ITtscGraphEvidence.ts +9 -0
- package/src/structures/ITtscGraphLookup.ts +42 -9
- package/src/structures/ITtscGraphNext.ts +12 -1
- package/src/structures/ITtscGraphNode.ts +38 -11
- package/src/structures/ITtscGraphOverview.ts +88 -6
- package/src/structures/ITtscGraphSnapshot.ts +117 -2
- package/src/structures/ITtscGraphSpan.ts +9 -0
- package/src/structures/ITtscGraphTour.ts +83 -9
- package/src/structures/ITtscGraphTrace.ts +100 -14
- package/src/structures/RawDump.ts +25 -0
- package/src/structures/RawEdge.ts +22 -0
- package/src/structures/RawNode.ts +31 -0
- package/src/structures/TtscGraphArtifactNodeKind.ts +9 -0
- package/src/structures/TtscGraphDumpEdgeKind.ts +15 -1
- package/src/structures/TtscGraphDumpNodeKind.ts +9 -0
- package/src/structures/TtscGraphEdgeKind.ts +13 -4
- package/src/structures/TtscGraphNodeKind.ts +9 -0
- package/src/structures/TtscGraphNodeModifier.ts +9 -0
- package/src/structures/ViewerLink.ts +22 -0
- package/src/structures/ViewerNode.ts +28 -0
- package/src/structures/ViewerPayload.ts +52 -0
- package/src/view.ts +208 -110
- package/src/viewer/legend.ts +119 -27
package/src/server/runTour.ts
CHANGED
|
@@ -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
|
-
*
|
|
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
|
-
*
|
|
530
|
-
*
|
|
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
|
|
533
|
-
*
|
|
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
|
-
*
|
|
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 {
|