@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.
- 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/runDetails.ts
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { TtscGraphMemory, leadingToken } from "../model/TtscGraphMemory";
|
|
2
|
+
import { TtscGraphReadonly } from "../model/TtscGraphReadonly";
|
|
2
3
|
import { ITtscGraphDecorator } from "../structures/ITtscGraphDecorator";
|
|
3
4
|
import { ITtscGraphDetails } from "../structures/ITtscGraphDetails";
|
|
4
5
|
import { ITtscGraphDocTag } from "../structures/ITtscGraphDocTag";
|
|
5
6
|
import { ITtscGraphEdge } from "../structures/ITtscGraphEdge";
|
|
6
7
|
import { ITtscGraphEvidence } from "../structures/ITtscGraphEvidence";
|
|
7
|
-
import { ITtscGraphNode } from "../structures/ITtscGraphNode";
|
|
8
|
+
import { ITtscGraphNode as NodeShape } from "../structures/ITtscGraphNode";
|
|
8
9
|
import { isExternalNode, isTestPath } from "./pathPolicy";
|
|
9
10
|
import { resolveGraphHandle } from "./resolveHandle";
|
|
10
11
|
import { IRunnerOutput, resultNext } from "./resultNext";
|
|
11
12
|
|
|
13
|
+
type ITtscGraphNode = TtscGraphReadonly<NodeShape>;
|
|
14
|
+
|
|
12
15
|
// A signature is the declaration head up to the body brace: a handful of lines.
|
|
13
16
|
const MAX_SIGNATURE_LINES = 4;
|
|
14
17
|
// A doc summary is one sentence; the rest of the comment is the file's to keep.
|
|
@@ -38,6 +41,15 @@ const CONTAINER_KINDS = new Set<ITtscGraphNode["kind"]>([
|
|
|
38
41
|
* Resolve each handle to its declared shape: sourceSpan anchors, signature,
|
|
39
42
|
* direct dependencies, and for containers, member outlines. It answers from the
|
|
40
43
|
* graph's resolved structure instead of inlining implementation bodies.
|
|
44
|
+
*
|
|
45
|
+
* @evidence contracts/common.md#principled-implementation Resolved handles select exact node facts, complete literal/member identities and explicitly bounded relationship slices; ambiguity is returned separately.
|
|
46
|
+
* @evidence contracts/common.md#clear-and-simple-design Shape, relationship and source-display helpers each own one projection while this function assembles the selected details envelope.
|
|
47
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts Unknown and ambiguous handles are not converted to guessed declarations; capped members withdraw the corresponding completeness audit.
|
|
48
|
+
* @evidence contracts/common.md#meaningful-documentation Native prose distinguishes declared shape from implementation bodies; helper documentation explains member, reference and citation limits.
|
|
49
|
+
* @evidence contracts/performance.md#efficient-algorithms Each handle uses the shared resolver, whose dotted-suffix fallback may scan V nodes; resolved relationships inspect D incident edges and retain only K ranked references in O(DK) time and O(K) temporary space, where K is at most four, while member/literal output scales with the declaration's own members.
|
|
50
|
+
* @evidence contracts/performance.md#reuse-equivalent-work The graph shares generation indexes and source-line adjudications across handles and requests; this call builds fresh caller-owned projections because request limits and selected handles differ.
|
|
51
|
+
* @evidence contracts/performance.md#bound-retention-and-release-resources Detail, ambiguity and unknown arrays live for this request and transfer to its caller; no query history or native handle is retained by this operation.
|
|
52
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation reads in-memory facts; source lines arrive through graph.source, the reader that owns file access.
|
|
41
53
|
*/
|
|
42
54
|
export function runDetails(
|
|
43
55
|
graph: TtscGraphMemory,
|
|
@@ -170,7 +182,7 @@ export function runDetails(
|
|
|
170
182
|
if (shown.length > 0) detail.members = shown;
|
|
171
183
|
}
|
|
172
184
|
if (node.literals !== undefined && node.literals.length > 0) {
|
|
173
|
-
detail.literals = node.literals;
|
|
185
|
+
detail.literals = [...node.literals];
|
|
174
186
|
}
|
|
175
187
|
if (wantNeighbors) {
|
|
176
188
|
detail.dependsOn = refs(
|
|
@@ -285,7 +297,8 @@ function refs(
|
|
|
285
297
|
limit: number,
|
|
286
298
|
includeExternal: boolean,
|
|
287
299
|
): ITtscGraphDetails.IReference[] {
|
|
288
|
-
const ranked:
|
|
300
|
+
const ranked: RankedReference[] = [];
|
|
301
|
+
let order = 0;
|
|
289
302
|
for (const edge of edges) {
|
|
290
303
|
if (STRUCTURAL_KINDS.has(edge.kind)) continue;
|
|
291
304
|
const other = graph.node(end === "to" ? edge.to : edge.from);
|
|
@@ -301,13 +314,13 @@ function refs(
|
|
|
301
314
|
if (other.evidence?.startLine) ref.line = other.evidence.startLine;
|
|
302
315
|
const evidence = edgeEvidenceOf(edge);
|
|
303
316
|
if (evidence !== undefined) ref.evidence = evidence;
|
|
304
|
-
|
|
317
|
+
retainRanked(
|
|
318
|
+
ranked,
|
|
319
|
+
{ ref, rank: refRank(ref, edge), order: order++ },
|
|
320
|
+
limit,
|
|
321
|
+
);
|
|
305
322
|
}
|
|
306
|
-
|
|
307
|
-
// not the ones nearest the top of a file. Uncapped, `limit` is Infinity and
|
|
308
|
-
// the sort is just a stable order.
|
|
309
|
-
ranked.sort((a, b) => a.rank - b.rank);
|
|
310
|
-
return ranked.map((item) => item.ref).slice(0, limit);
|
|
323
|
+
return ranked.map((item) => item.ref);
|
|
311
324
|
}
|
|
312
325
|
|
|
313
326
|
const executionKinds = new Set([
|
|
@@ -326,7 +339,8 @@ function dependencyRefs(
|
|
|
326
339
|
limit: number,
|
|
327
340
|
includeExternal: boolean,
|
|
328
341
|
): ITtscGraphDetails.IReference[] {
|
|
329
|
-
const ranked:
|
|
342
|
+
const ranked: RankedReference[] = [];
|
|
343
|
+
let order = 0;
|
|
330
344
|
for (const edge of graph.outgoing(node.id)) {
|
|
331
345
|
if (!kinds.has(edge.kind)) continue;
|
|
332
346
|
const other = graph.node(edge.to);
|
|
@@ -343,12 +357,14 @@ function dependencyRefs(
|
|
|
343
357
|
if (other.evidence?.startLine) ref.line = other.evidence.startLine;
|
|
344
358
|
const evidence = edgeEvidenceOf(edge);
|
|
345
359
|
if (evidence !== undefined) ref.evidence = evidence;
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
rank: refRank(ref, edge),
|
|
349
|
-
|
|
360
|
+
retainRanked(
|
|
361
|
+
ranked,
|
|
362
|
+
{ ref, rank: refRank(ref, edge), order: order++ },
|
|
363
|
+
limit,
|
|
364
|
+
true,
|
|
365
|
+
);
|
|
350
366
|
}
|
|
351
|
-
return
|
|
367
|
+
return ranked.map((item) => item.ref);
|
|
352
368
|
}
|
|
353
369
|
|
|
354
370
|
function incomingDependencyRefs(
|
|
@@ -358,7 +374,8 @@ function incomingDependencyRefs(
|
|
|
358
374
|
limit: number,
|
|
359
375
|
includeExternal: boolean,
|
|
360
376
|
): ITtscGraphDetails.IReference[] {
|
|
361
|
-
const ranked:
|
|
377
|
+
const ranked: RankedReference[] = [];
|
|
378
|
+
let order = 0;
|
|
362
379
|
for (const edge of graph.incoming(node.id)) {
|
|
363
380
|
if (!kinds.has(edge.kind)) continue;
|
|
364
381
|
const other = graph.node(edge.from);
|
|
@@ -374,30 +391,52 @@ function incomingDependencyRefs(
|
|
|
374
391
|
if (other.evidence?.startLine) ref.line = other.evidence.startLine;
|
|
375
392
|
const evidence = edgeEvidenceOf(edge);
|
|
376
393
|
if (evidence !== undefined) ref.evidence = evidence;
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
rank: refRank(ref, edge),
|
|
380
|
-
|
|
394
|
+
retainRanked(
|
|
395
|
+
ranked,
|
|
396
|
+
{ ref, rank: refRank(ref, edge), order: order++ },
|
|
397
|
+
limit,
|
|
398
|
+
true,
|
|
399
|
+
);
|
|
381
400
|
}
|
|
382
|
-
return
|
|
401
|
+
return ranked.map((item) => item.ref);
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
interface RankedReference {
|
|
405
|
+
ref: ITtscGraphDetails.IReference;
|
|
406
|
+
rank: number;
|
|
407
|
+
order: number;
|
|
383
408
|
}
|
|
384
409
|
|
|
385
|
-
/**
|
|
386
|
-
function
|
|
387
|
-
ranked:
|
|
410
|
+
/** Keep the best capped references in stable score order as edges arrive. */
|
|
411
|
+
function retainRanked(
|
|
412
|
+
ranked: RankedReference[],
|
|
413
|
+
candidate: RankedReference,
|
|
388
414
|
limit: number,
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
415
|
+
deduplicate = false,
|
|
416
|
+
): void {
|
|
417
|
+
if (deduplicate) {
|
|
418
|
+
const duplicate = ranked.findIndex(
|
|
419
|
+
(item) =>
|
|
420
|
+
item.ref.relation === candidate.ref.relation &&
|
|
421
|
+
item.ref.id === candidate.ref.id,
|
|
422
|
+
);
|
|
423
|
+
if (duplicate >= 0) {
|
|
424
|
+
if (ranked[duplicate]!.rank <= candidate.rank) return;
|
|
425
|
+
ranked.splice(duplicate, 1);
|
|
426
|
+
}
|
|
399
427
|
}
|
|
400
|
-
|
|
428
|
+
const position = ranked.findIndex(
|
|
429
|
+
(item) =>
|
|
430
|
+
candidate.rank < item.rank ||
|
|
431
|
+
(candidate.rank === item.rank && candidate.order < item.order),
|
|
432
|
+
);
|
|
433
|
+
if (position < 0) {
|
|
434
|
+
if (ranked.length < limit) ranked.push(candidate);
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
if (position >= limit) return;
|
|
438
|
+
ranked.splice(position, 0, candidate);
|
|
439
|
+
if (ranked.length > limit) ranked.pop();
|
|
401
440
|
}
|
|
402
441
|
|
|
403
442
|
/**
|
|
@@ -477,12 +516,26 @@ function edgeKindRank(kind: string): number {
|
|
|
477
516
|
}
|
|
478
517
|
}
|
|
479
518
|
|
|
480
|
-
/**
|
|
519
|
+
/**
|
|
520
|
+
* Decorator facts already captured on a node, omitted when absent or empty.
|
|
521
|
+
*
|
|
522
|
+
* @evidence contracts/common.md#principled-implementation The adapter preserves collected decorator order and values while omitting an empty optional facet.
|
|
523
|
+
* @evidence contracts/common.md#clear-and-simple-design One accessor shares decorator projection across details, lookup and tour consumers.
|
|
524
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts No framework-specific reinterpretation changes the collected decorator facts.
|
|
525
|
+
* @evidence contracts/common.md#meaningful-documentation The native headline states collected-fact and empty-facet behavior before the tags.
|
|
526
|
+
* @evidence contracts/performance.md#efficient-algorithms One pass copies each decorator and its arguments, costing their total population without scanning unrelated graph nodes.
|
|
527
|
+
* @evidenceExclude contracts/performance.md#reuse-equivalent-work This caller-owned projection performs no cross-request coordination; the graph owns the shared source facts.
|
|
528
|
+
* @evidenceExclude contracts/performance.md#bound-retention-and-release-resources The returned array transfers to its caller and this helper retains no state or handle.
|
|
529
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation copies in-memory node fields; no file, path or process.
|
|
530
|
+
*/
|
|
481
531
|
export function decoratorsOf(
|
|
482
532
|
node: ITtscGraphNode,
|
|
483
533
|
): ITtscGraphDecorator[] | undefined {
|
|
484
534
|
return node.decorators !== undefined && node.decorators.length > 0
|
|
485
|
-
? node.decorators
|
|
535
|
+
? node.decorators.map((decorator) => ({
|
|
536
|
+
name: decorator.name,
|
|
537
|
+
arguments: decorator.arguments.map((argument) => ({ ...argument })),
|
|
538
|
+
}))
|
|
486
539
|
: undefined;
|
|
487
540
|
}
|
|
488
541
|
|
|
@@ -498,10 +551,19 @@ export function decoratorsOf(
|
|
|
498
551
|
* The optional filter narrows to the tags a caller matched. It runs on the
|
|
499
552
|
* node's own tags, before any elision, so a tag found by an address longer than
|
|
500
553
|
* the budget is still recognized as the one that matched.
|
|
554
|
+
*
|
|
555
|
+
* @evidence contracts/common.md#principled-implementation Filtering original tags before eliding preserves matching addresses; the shared leading-token rule keeps whole citation prefixes intact.
|
|
556
|
+
* @evidence contracts/common.md#clear-and-simple-design One projection helper owns tag selection and display elision for every graph result consumer.
|
|
557
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts Address matches are not re-evaluated against truncated text and long addresses are never cut into another target.
|
|
558
|
+
* @evidence contracts/common.md#meaningful-documentation Separate native paragraphs explain the display budget, protected address and filter-before-elision ordering.
|
|
559
|
+
* @evidence contracts/performance.md#efficient-algorithms Filtering and mapping visit the node's tags once each; elision examines the leading address and copies at most the needed display prefix.
|
|
560
|
+
* @evidenceExclude contracts/performance.md#reuse-equivalent-work Selection depends on a caller predicate and returns a fresh mutable projection; this helper coordinates no reusable result.
|
|
561
|
+
* @evidenceExclude contracts/performance.md#bound-retention-and-release-resources The selected and returned arrays are request-local and no historical tags are retained here.
|
|
562
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation copies and elides in-memory tag text; no file, path or process.
|
|
501
563
|
*/
|
|
502
564
|
export function docTagsOf(
|
|
503
565
|
node: ITtscGraphNode,
|
|
504
|
-
keep?: (tag: ITtscGraphDocTag) => boolean,
|
|
566
|
+
keep?: (tag: TtscGraphReadonly<ITtscGraphDocTag>) => boolean,
|
|
505
567
|
): ITtscGraphDocTag[] | undefined {
|
|
506
568
|
if (node.docTags === undefined || node.docTags.length === 0) return undefined;
|
|
507
569
|
const selected =
|
|
@@ -510,7 +572,7 @@ export function docTagsOf(
|
|
|
510
572
|
return selected.map((tag) =>
|
|
511
573
|
tag.text !== undefined && tag.text.length > MAX_DOC_CHARS
|
|
512
574
|
? { ...tag, text: elideTagText(tag.text) }
|
|
513
|
-
: tag,
|
|
575
|
+
: { ...tag },
|
|
514
576
|
);
|
|
515
577
|
}
|
|
516
578
|
|
|
@@ -534,7 +596,18 @@ function elideTagText(text: string): string {
|
|
|
534
596
|
return text.slice(0, keep).trimEnd() + "…";
|
|
535
597
|
}
|
|
536
598
|
|
|
537
|
-
/**
|
|
599
|
+
/**
|
|
600
|
+
* Relationship evidence as public coordinates, omitted when absent.
|
|
601
|
+
*
|
|
602
|
+
* @evidence contracts/common.md#principled-implementation Copying the actual edge span preserves file and optional endpoints without inferring missing coordinates.
|
|
603
|
+
* @evidence contracts/common.md#clear-and-simple-design One coordinate mapper is shared by graph runners and node implementation evidence.
|
|
604
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts Missing source evidence stays absent rather than being replaced with the caller's declaration span.
|
|
605
|
+
* @evidence contracts/common.md#meaningful-documentation The native headline explains public-coordinate projection and absent evidence behavior.
|
|
606
|
+
* @evidenceExclude contracts/performance.md#efficient-algorithms Copying a fixed set of optional coordinates chooses no input-dependent processing strategy.
|
|
607
|
+
* @evidenceExclude contracts/performance.md#reuse-equivalent-work This fixed-size projection coordinates no cross-request computation.
|
|
608
|
+
* @evidenceExclude contracts/performance.md#bound-retention-and-release-resources The returned value transfers to its caller without a retained handle or cache.
|
|
609
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation copies span coordinates of an in-memory edge; no file, path or process.
|
|
610
|
+
*/
|
|
538
611
|
export function edgeEvidenceOf(
|
|
539
612
|
edge: ITtscGraphEdge,
|
|
540
613
|
): ITtscGraphEvidence | undefined {
|
|
@@ -565,6 +638,15 @@ function evidenceCoordinatesOf(
|
|
|
565
638
|
* sentence above the declaration, and the compiler carries it. It is the
|
|
566
639
|
* declaration's documentation, not the body of the work: an index that lists a
|
|
567
640
|
* symbol with what it is for is doing an index's job.
|
|
641
|
+
*
|
|
642
|
+
* @evidence contracts/common.md#principled-implementation Provenance-gated lines are scanned immediately above the declaration for JSDoc prose, stopping before tags and returning its first sentence.
|
|
643
|
+
* @evidence contracts/common.md#clear-and-simple-design This helper owns a short documentation projection; the source reader owns immutable generation validation and caching.
|
|
644
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts A missing or mismatched source yields absence rather than an inferred purpose from names or implementation text.
|
|
645
|
+
* @evidence contracts/common.md#meaningful-documentation Native paragraphs explain first-sentence purpose and distinguish declaration prose from implementation bodies.
|
|
646
|
+
* @evidence contracts/performance.md#efficient-algorithms The source reader supplies indexed, cached lines; this helper scans only the adjacent comment and joins its prose, costing the comment's lines and characters.
|
|
647
|
+
* @evidenceExclude contracts/performance.md#reuse-equivalent-work Source-byte validation and line splitting are shared by the reader; this pure projection does not coordinate a separate result cache.
|
|
648
|
+
* @evidenceExclude contracts/performance.md#bound-retention-and-release-resources Comment and prose arrays are local to this call and no history or handle is retained.
|
|
649
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation reads lines through graph.source, the reader that owns file access, and adds none of its own.
|
|
568
650
|
*/
|
|
569
651
|
export function docOf(
|
|
570
652
|
graph: TtscGraphMemory,
|
|
@@ -606,47 +688,30 @@ export function docOf(
|
|
|
606
688
|
}
|
|
607
689
|
|
|
608
690
|
/**
|
|
609
|
-
* The
|
|
610
|
-
* the line that opens its body (`{`), or the single declaration line when there
|
|
611
|
-
* is no brace, capped so a wrapped signature cannot run away.
|
|
691
|
+
* The producer's compiler-bounded declaration head, limited to display lines.
|
|
612
692
|
*
|
|
613
|
-
*
|
|
614
|
-
*
|
|
615
|
-
*
|
|
616
|
-
*
|
|
617
|
-
*
|
|
618
|
-
* the
|
|
693
|
+
* Without a producer signature, return undefined. Physical lines cannot
|
|
694
|
+
* establish where a declaration head ends: a body may share its line and a
|
|
695
|
+
* parameter or return type may itself contain braces. The source span remains
|
|
696
|
+
* available when a caller needs to read the declaration.
|
|
697
|
+
*
|
|
698
|
+
* @evidence contracts/common.md#principled-implementation Only the AST-bounded producer head establishes a declaration-only signature; limiting its lines preserves that established boundary.
|
|
699
|
+
* @evidence contracts/common.md#clear-and-simple-design The producer owns declaration syntax boundaries and this helper owns display length, with no second partial TypeScript parser.
|
|
700
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts Missing heads are not repaired by a line-scan heuristic that can leak implementation or neighboring declarations.
|
|
701
|
+
* @evidence contracts/common.md#meaningful-documentation Native paragraphs explain the producer requirement, missing-head absence and source-span escape path.
|
|
702
|
+
* @evidence contracts/performance.md#efficient-algorithms Splitting the producer head and selecting its first display lines costs the supplied signature's length; no source file or graph traversal occurs.
|
|
703
|
+
* @evidenceExclude contracts/performance.md#reuse-equivalent-work The producer head is already shared on the graph node, while this display projection coordinates no repeated work.
|
|
704
|
+
* @evidenceExclude contracts/performance.md#bound-retention-and-release-resources The capped text is caller-owned and this helper retains no cache or native resource.
|
|
705
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation cuts the producer's signature text to a few lines; no file, path or process.
|
|
619
706
|
*/
|
|
620
707
|
export function signatureOf(
|
|
621
|
-
|
|
708
|
+
_graph: TtscGraphMemory,
|
|
622
709
|
node: ITtscGraphNode,
|
|
623
710
|
): string | undefined {
|
|
624
|
-
// The producer cuts the head where the compiler says the body opens, so when
|
|
625
|
-
// it supplied one there is nothing left to infer. The scan below only runs
|
|
626
|
-
// where it could not: it reads whole physical lines and stops at the first one
|
|
627
|
-
// holding a `{`, which leaks implementation text when a declaration shares its
|
|
628
|
-
// line with its body and stops early when the head itself contains a brace.
|
|
629
711
|
if (node.signature !== undefined && node.signature !== "") {
|
|
630
712
|
const capped = node.signature.split("\n").slice(0, MAX_SIGNATURE_LINES);
|
|
631
713
|
const head = capped.join("\n").trim();
|
|
632
714
|
if (head !== "") return head;
|
|
633
715
|
}
|
|
634
|
-
|
|
635
|
-
const lines =
|
|
636
|
-
evidence === undefined ? undefined : graph.source.lines(evidence.file);
|
|
637
|
-
if (lines === undefined || evidence === undefined) return undefined;
|
|
638
|
-
const start = Math.max(0, evidence.startLine - 1);
|
|
639
|
-
const last =
|
|
640
|
-
evidence.endLine === undefined
|
|
641
|
-
? lines.length - 1
|
|
642
|
-
: Math.min(lines.length - 1, evidence.endLine - 1);
|
|
643
|
-
const out: string[] = [];
|
|
644
|
-
for (let i = start; i <= last && out.length < MAX_SIGNATURE_LINES; i++) {
|
|
645
|
-
const line = lines[i];
|
|
646
|
-
if (line === undefined) break;
|
|
647
|
-
out.push(line);
|
|
648
|
-
if (line.includes("{") || line.trimEnd().endsWith(";")) break;
|
|
649
|
-
}
|
|
650
|
-
const text = out.join("\n").trim();
|
|
651
|
-
return text === "" ? undefined : text;
|
|
716
|
+
return undefined;
|
|
652
717
|
}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { TtscGraphMemory } from "../model/TtscGraphMemory";
|
|
2
|
+
import { TtscGraphReadonly } from "../model/TtscGraphReadonly";
|
|
2
3
|
import { ITtscGraphEdge } from "../structures/ITtscGraphEdge";
|
|
3
4
|
import { ITtscGraphEntrypoints } from "../structures/ITtscGraphEntrypoints";
|
|
4
|
-
import { ITtscGraphNode } from "../structures/ITtscGraphNode";
|
|
5
|
+
import { ITtscGraphNode as NodeShape } from "../structures/ITtscGraphNode";
|
|
5
6
|
import { resolveGraphHandle } from "./resolveHandle";
|
|
6
7
|
import { IRunnerOutput, resultNext } from "./resultNext";
|
|
7
8
|
import { decoratorsOf, edgeEvidenceOf, signatureOf } from "./runDetails";
|
|
8
9
|
import { runLookup } from "./runLookup";
|
|
9
10
|
|
|
11
|
+
type ITtscGraphNode = TtscGraphReadonly<NodeShape>;
|
|
12
|
+
|
|
10
13
|
const DEFAULT_LIMIT = 4;
|
|
11
14
|
const MAX_LIMIT = 8;
|
|
12
15
|
const DEFAULT_NEIGHBORS = 0;
|
|
@@ -19,6 +22,15 @@ const STRUCTURAL_KINDS = new Set<string>(["contains", "exports"]);
|
|
|
19
22
|
* gives the model stable handles, declaration signatures, and direct graph
|
|
20
23
|
* context. It is deliberately not a source reader; details adds selected symbol
|
|
21
24
|
* shape and ranges, not implementation text.
|
|
25
|
+
*
|
|
26
|
+
* @evidence contracts/common.md#principled-implementation Lookup hits and directly written handles seed deduplicated graph neighborhoods; unresolved mentions remain explicit instead of inferred starts.
|
|
27
|
+
* @evidence contracts/common.md#clear-and-simple-design Shared lookup and handle resolution own search semantics while this runner owns first-pass context assembly.
|
|
28
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts Node coordinates and typed fields are copied deliberately rather than leaking lookup-only tag fields into another result schema.
|
|
29
|
+
* @evidence contracts/common.md#meaningful-documentation Native prose states first-pass scope and the distinction between details ranges and implementation text.
|
|
30
|
+
* @evidence contracts/performance.md#efficient-algorithms One shared lookup supplies ranked candidates; exact mentions use indexed resolution and at most three seeds contribute bounded direct neighbors.
|
|
31
|
+
* @evidence contracts/performance.md#reuse-equivalent-work This composer borrows lookup and generation indexes; identical entrypoint DTOs are not memoized and remain caller-owned mutable results.
|
|
32
|
+
* @evidence contracts/performance.md#bound-retention-and-release-resources Seed sets and projected arrays are request-local, with fixed seed and neighbor caps; no query history or native handle survives the call.
|
|
33
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation ranks and projects in-memory facts through runLookup and the resolver; no file, path or process.
|
|
22
34
|
*/
|
|
23
35
|
export function runEntrypoints(
|
|
24
36
|
graph: TtscGraphMemory,
|
package/src/server/runLookup.ts
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { TtscGraphMemory, documentationTarget } from "../model/TtscGraphMemory";
|
|
2
|
+
import { TtscGraphReadonly } from "../model/TtscGraphReadonly";
|
|
2
3
|
import { ITtscGraphLookup } from "../structures/ITtscGraphLookup";
|
|
3
|
-
import { ITtscGraphNode } from "../structures/ITtscGraphNode";
|
|
4
|
+
import { ITtscGraphNode as NodeShape } from "../structures/ITtscGraphNode";
|
|
4
5
|
import { isArtifactNodeKind } from "../structures/TtscGraphArtifactNodeKind";
|
|
5
6
|
import { exportFanIn } from "./exportSurface";
|
|
6
7
|
import { isExternalNode, isSupportPath } from "./pathPolicy";
|
|
7
8
|
import { IRunnerOutput, resultNext } from "./resultNext";
|
|
8
9
|
import { decoratorsOf, docTagsOf, signatureOf } from "./runDetails";
|
|
9
10
|
|
|
11
|
+
type ITtscGraphNode = TtscGraphReadonly<NodeShape>;
|
|
12
|
+
|
|
10
13
|
// One file should not crowd out the rest of the ranking, so cap hits per file.
|
|
11
14
|
const PER_FILE = 3;
|
|
12
15
|
// The score a citation carrier reports. Citation hits are placed ahead of the
|
|
@@ -21,9 +24,19 @@ const MAX_LIMIT = 6;
|
|
|
21
24
|
/**
|
|
22
25
|
* Rank the graph's symbols against a natural query. Scoring blends exact and
|
|
23
26
|
* dotted-name matches, CamelCase/subword coverage, file-path terms, a prefix
|
|
24
|
-
* bonus, and dependency centrality, then dampens
|
|
25
|
-
* nodes and caps per file so the result is a
|
|
26
|
-
* than one file's roster.
|
|
27
|
+
* bonus, and dependency centrality, then dampens git-ignored, test,
|
|
28
|
+
* support-path and internal-looking nodes and caps per file so the result is a
|
|
29
|
+
* diverse, relevant shortlist rather than one file's roster.
|
|
30
|
+
* Dependency-boundary nodes are left out unless the request includes them.
|
|
31
|
+
*
|
|
32
|
+
* @evidence contracts/common.md#principled-implementation Exact citation matches precede heuristic name scoring; token, kind, path and graph-centrality signals rank real nodes without certifying question coverage.
|
|
33
|
+
* @evidence contracts/common.md#clear-and-simple-design Citation selection, tokenization and scoring have helper owners; final diversity and signature projection assemble one shortlist.
|
|
34
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts Scores use general identifiers and graph structure rather than known repository answers; truncation reports selection losses and citations bypass per-file name diversity.
|
|
35
|
+
* @evidence contracts/common.md#meaningful-documentation Native prose names ranking signals and helpers explain exact-address precedence and the distinction between a citation and a fuzzy match.
|
|
36
|
+
* @evidence contracts/performance.md#efficient-algorithms Scoring scans candidate nodes and their indexed incident edges, then sorts positive matches in O(M log M); signatures are attached only to the bounded shortlist.
|
|
37
|
+
* @evidence contracts/performance.md#reuse-equivalent-work Name, citation and adjacency indexes are shared across lookups through the graph generation. Identical query result memoization is not implemented; each call produces a caller-owned mutable DTO.
|
|
38
|
+
* @evidence contracts/performance.md#bound-retention-and-release-resources Scored candidates and diversity maps are request-local; the returned shortlist is bounded by the request cap and no historical queries are retained.
|
|
39
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation scores in-memory nodes; no file, path or process.
|
|
27
40
|
*/
|
|
28
41
|
export function runLookup(
|
|
29
42
|
graph: TtscGraphMemory,
|
|
@@ -96,9 +109,12 @@ export function runLookup(
|
|
|
96
109
|
// not a better fuzzy match than the name hits, it is a different and certain
|
|
97
110
|
// kind of answer, and name scoring cannot rank the two against each other.
|
|
98
111
|
const citedIds = new Set(cited.map((hit) => hit.id));
|
|
99
|
-
const ranked =
|
|
100
|
-
|
|
101
|
-
|
|
112
|
+
const ranked = [
|
|
113
|
+
...cited,
|
|
114
|
+
...scored
|
|
115
|
+
.filter((hit) => !citedIds.has(hit.id))
|
|
116
|
+
.sort((a, b) => b.score - a.score),
|
|
117
|
+
];
|
|
102
118
|
|
|
103
119
|
// Diversity: keep at most PER_FILE hits per file while filling up to the limit.
|
|
104
120
|
//
|
|
@@ -1,18 +1,30 @@
|
|
|
1
1
|
import { TtscGraphMemory } from "../model/TtscGraphMemory";
|
|
2
|
-
import {
|
|
2
|
+
import { TtscGraphReadonly } from "../model/TtscGraphReadonly";
|
|
3
|
+
import { ITtscGraphNode as NodeShape } from "../structures/ITtscGraphNode";
|
|
3
4
|
import { ITtscGraphOverview } from "../structures/ITtscGraphOverview";
|
|
4
5
|
import { isPublicApiNoisePath, isSupportPath } from "./pathPolicy";
|
|
5
6
|
import { IRunnerOutput, resultNext } from "./resultNext";
|
|
6
7
|
|
|
8
|
+
type ITtscGraphNode = TtscGraphReadonly<NodeShape>;
|
|
9
|
+
|
|
7
10
|
/** Edges that express nesting/packaging, not code dependency. */
|
|
8
11
|
const STRUCTURAL_KINDS = new Set<string>(["contains", "exports"]);
|
|
9
12
|
|
|
10
13
|
/**
|
|
11
14
|
* Project a compact, source-read-free architecture map: counts by kind, folder
|
|
12
|
-
* layering with
|
|
13
|
-
* fan-in/out, excluding structural edges so nesting does not masquerade
|
|
14
|
-
* dependency), and the
|
|
15
|
-
* reads structure cheaply.
|
|
15
|
+
* layering with exported-symbol counts, the highest-dependency symbols (ranked
|
|
16
|
+
* by real fan-in/out, excluding structural edges so nesting does not masquerade
|
|
17
|
+
* as dependency), and the exported API symbols ranked by the same dependency
|
|
18
|
+
* count. Output is bounded so a model reads structure cheaply.
|
|
19
|
+
*
|
|
20
|
+
* @evidence contracts/common.md#principled-implementation Counts derive from resident nodes/edges; facet helpers distinguish folder population from non-structural dependency connectivity and exported declarations.
|
|
21
|
+
* @evidence contracts/common.md#clear-and-simple-design The aspect selector assembles only requested facets, sharing coordinate and path policies across their helpers.
|
|
22
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts Ranking uses graph connectivity and documented conventional path heuristics rather than named benchmark projects or expected answers.
|
|
23
|
+
* @evidence contracts/common.md#meaningful-documentation Native prose explains source-free facets and structural-edge exclusion; DTO comments describe population and ordering.
|
|
24
|
+
* @evidence contracts/performance.md#efficient-algorithms Counts scan nodes once; selected facets scan their node/edge populations and sort candidate summaries, with dominant O(V log V + E) work for all facets.
|
|
25
|
+
* @evidence contracts/performance.md#reuse-equivalent-work All facets borrow generation indexes; completed facet memoization is not implemented, so repeated requests recompute caller-owned mutable summaries.
|
|
26
|
+
* @evidence contracts/performance.md#bound-retention-and-release-resources Folder maps, candidate summaries and sets are local to one request; output facets are capped and no history or handles are retained.
|
|
27
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation counts and ranks in-memory nodes and edges; no file, path or process.
|
|
16
28
|
*/
|
|
17
29
|
export function runOverview(
|
|
18
30
|
graph: TtscGraphMemory,
|