@ttsc/graph 0.19.1 → 0.19.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/model/TtscGraphSession.js +449 -162
- package/lib/model/TtscGraphSession.js.map +1 -1
- package/lib/model/loadGraph.js +321 -88
- package/lib/model/loadGraph.js.map +1 -1
- package/lib/structures/ITtscGraphDump.d.ts +169 -6
- package/lib/structures/ITtscGraphSnapshot.d.ts +55 -0
- package/lib/structures/ITtscGraphSnapshot.js +3 -0
- package/lib/structures/ITtscGraphSnapshot.js.map +1 -0
- package/lib/structures/index.d.ts +1 -0
- package/lib/structures/index.js +1 -0
- package/lib/structures/index.js.map +1 -1
- package/package.json +2 -2
- package/src/model/TtscGraphSession.ts +62 -16
- package/src/model/loadGraph.ts +31 -0
- package/src/structures/ITtscGraphDump.ts +194 -6
- package/src/structures/ITtscGraphSnapshot.ts +69 -0
- package/src/structures/index.ts +1 -0
|
@@ -7,13 +7,19 @@ import { ITtscGraphSpan } from "./ITtscGraphSpan";
|
|
|
7
7
|
* wire contract between the Go fact-builder and the TypeScript graph engine.
|
|
8
8
|
*
|
|
9
9
|
* It is the complete graph with none of the per-response caps the MCP tools
|
|
10
|
-
* apply: every node and edge the build resolved
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
10
|
+
* apply: every node and edge the build resolved, plus the `provenance` that
|
|
11
|
+
* says which program resolved them. The server parses each changed native
|
|
12
|
+
* snapshot (typia-validated) into an in-memory resident graph and reuses that
|
|
13
|
+
* warm model while project inputs stay unchanged; the bundled 3D viewer reduces
|
|
14
|
+
* the same dump.
|
|
14
15
|
*
|
|
15
|
-
*
|
|
16
|
-
* edges
|
|
16
|
+
* `project` is absolute. Every other path is relative to it — `tsconfig`, and
|
|
17
|
+
* the `file` fields on nodes, edges, diagnostics, and the provenance manifest.
|
|
18
|
+
*
|
|
19
|
+
* Two kinds of path fall outside the project and so cannot be relative to it: a
|
|
20
|
+
* dependency keeps its `node_modules/`-relative tail, which is what makes a
|
|
21
|
+
* dependency leaf readable, and anything else the compiler loaded keeps the
|
|
22
|
+
* identity the compiler gave it — a virtual lib stays `bundled:///…`.
|
|
17
23
|
*/
|
|
18
24
|
export interface ITtscGraphDump {
|
|
19
25
|
/** Absolute path of the project root the graph was built for. */
|
|
@@ -22,6 +28,17 @@ export interface ITtscGraphDump {
|
|
|
22
28
|
/** The tsconfig the program was loaded from, relative to `project`. */
|
|
23
29
|
tsconfig: string;
|
|
24
30
|
|
|
31
|
+
/** Evidence about the one program that produced everything below. */
|
|
32
|
+
provenance: ITtscGraphDump.IProvenance;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The compiler's findings for the same generation that produced the facts.
|
|
36
|
+
*
|
|
37
|
+
* Empty means the program reported none. It does not mean they were not
|
|
38
|
+
* collected — `provenance.capabilities` is what says whether they were.
|
|
39
|
+
*/
|
|
40
|
+
diagnostics: ITtscGraphDump.IDiagnostic[];
|
|
41
|
+
|
|
25
42
|
/** Every node the build recorded. */
|
|
26
43
|
nodes: ITtscGraphDump.INode[];
|
|
27
44
|
|
|
@@ -30,6 +47,177 @@ export interface ITtscGraphDump {
|
|
|
30
47
|
}
|
|
31
48
|
|
|
32
49
|
export namespace ITtscGraphDump {
|
|
50
|
+
/**
|
|
51
|
+
* What a snapshot knows about its own origin.
|
|
52
|
+
*
|
|
53
|
+
* The graph's claim is that its nodes, edges, spans, and diagnostics all came
|
|
54
|
+
* from one `Program`. Without this the claim is unprovable from the response:
|
|
55
|
+
* a consumer could only re-read the disk afterwards and hope nothing moved,
|
|
56
|
+
* which is not sound — a write that lands and reverts in between is invisible
|
|
57
|
+
* to it, and a re-read proves what the disk says now, never what the checker
|
|
58
|
+
* resolved against.
|
|
59
|
+
*
|
|
60
|
+
* This carries no source text. A digest is the opposite of inlining: it is
|
|
61
|
+
* what lets a consumer prove byte-identity against text it read itself,
|
|
62
|
+
* without the graph ever shipping that text.
|
|
63
|
+
*/
|
|
64
|
+
export interface IProvenance {
|
|
65
|
+
/**
|
|
66
|
+
* The dump body's schema version, moved when a field is added, removed, or
|
|
67
|
+
* redefined. Independent of the serve protocol's version: a dump written to
|
|
68
|
+
* a file has a schema but never rode the protocol.
|
|
69
|
+
*/
|
|
70
|
+
schemaVersion: number;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* What this snapshot proves. A consumer degrades against this rather than
|
|
74
|
+
* guessing from a field's emptiness, because an empty list and an
|
|
75
|
+
* uncollected one look identical on the wire.
|
|
76
|
+
*
|
|
77
|
+
* The known members are `universe`, `sourceDigests`, `diskDigests`, and
|
|
78
|
+
* `diagnostics`. The type stays `string[]` rather than a union of those on
|
|
79
|
+
* purpose: a union would make `typia.assert` reject a newer producer for
|
|
80
|
+
* naming a capability this client has not heard of, turning "proves more
|
|
81
|
+
* than you know about" into a hard failure. An unknown capability is
|
|
82
|
+
* exactly the case a consumer should ignore.
|
|
83
|
+
*/
|
|
84
|
+
capabilities: string[];
|
|
85
|
+
|
|
86
|
+
/** What built the snapshot. */
|
|
87
|
+
producer: IProducer;
|
|
88
|
+
|
|
89
|
+
/** The inputs that decide which files are in the program at all. */
|
|
90
|
+
universe: IUniverse;
|
|
91
|
+
|
|
92
|
+
/** One entry per file the program loaded, ordered by file. */
|
|
93
|
+
sources: ISourceDigest[];
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Identifies the binary and the checker behind the facts.
|
|
98
|
+
*
|
|
99
|
+
* `tool` and `version` are separate because more than one binary can produce
|
|
100
|
+
* a dump and they do not share a version line — the shipped `ttscgraph` is
|
|
101
|
+
* stamped at release, the internal viewer tool is not versioned at all — so
|
|
102
|
+
* folding the name in would hand a consumer that parses a version a tool
|
|
103
|
+
* name.
|
|
104
|
+
*/
|
|
105
|
+
export interface IProducer {
|
|
106
|
+
/** The producing binary's name, such as `ttscgraph`. */
|
|
107
|
+
tool: string;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* The producing binary's build version, as its `--version` prints it. A
|
|
111
|
+
* local build reports the dev placeholder; a tool that carries no version
|
|
112
|
+
* reports `""`.
|
|
113
|
+
*/
|
|
114
|
+
version: string;
|
|
115
|
+
|
|
116
|
+
/** The TypeScript version typescript-go implements. */
|
|
117
|
+
typescript: string;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* The build universe: the inputs that decide which files the program
|
|
122
|
+
* contains, as opposed to what is inside them. A change to any of them can
|
|
123
|
+
* add or drop whole files, so a consumer reusing facts across snapshots must
|
|
124
|
+
* treat a universe change as invalidating everything.
|
|
125
|
+
*/
|
|
126
|
+
export interface IUniverse {
|
|
127
|
+
/**
|
|
128
|
+
* The tsconfig chain — the project's config and everything it extends.
|
|
129
|
+
*
|
|
130
|
+
* It stays an input regardless of what any source contains: compiler
|
|
131
|
+
* options change the meaning of code the checker resolves without any
|
|
132
|
+
* source file changing.
|
|
133
|
+
*/
|
|
134
|
+
configs: IFileDigest[];
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* The resolved root file set, one entry per (config, file) pair. A root a
|
|
138
|
+
* config names but that does not exist is still listed: its absence is part
|
|
139
|
+
* of the fingerprint, and creating it later changes the program.
|
|
140
|
+
*/
|
|
141
|
+
roots: IRootFile[];
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/** A root file attributed to the config that named it. */
|
|
145
|
+
export interface IRootFile {
|
|
146
|
+
/** The tsconfig that named this root, project-relative. */
|
|
147
|
+
config: string;
|
|
148
|
+
|
|
149
|
+
/** The root file, project-relative. */
|
|
150
|
+
file: string;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/** A file and the hex-encoded SHA-256 of its on-disk bytes. */
|
|
154
|
+
export interface IFileDigest {
|
|
155
|
+
/** Project-relative. */
|
|
156
|
+
file: string;
|
|
157
|
+
|
|
158
|
+
/** Hex-encoded SHA-256. */
|
|
159
|
+
digest: string;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* The manifest entry for one source file the program loaded.
|
|
164
|
+
*
|
|
165
|
+
* Two digests, because "the bytes the checker read" and "the bytes on disk"
|
|
166
|
+
* are not always the same string and a consumer needs to know which one it
|
|
167
|
+
* compares against. They diverge when a source-preamble plugin injects text
|
|
168
|
+
* ahead of the file before tsgo parses it, which a real plugin project does
|
|
169
|
+
* on every build.
|
|
170
|
+
*/
|
|
171
|
+
export interface ISourceDigest {
|
|
172
|
+
/** Project-relative. */
|
|
173
|
+
file: string;
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Hex-encoded SHA-256 of the text the checker resolved against — the ground
|
|
177
|
+
* truth for the facts. Every node, edge, and span attributed to this file
|
|
178
|
+
* was computed from these bytes.
|
|
179
|
+
*/
|
|
180
|
+
checkerDigest: string;
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Hex-encoded SHA-256 of the file's on-disk bytes at snapshot time, or `""`
|
|
184
|
+
* when it could not be read: it vanished mid-load, or it is a virtual
|
|
185
|
+
* source with no on-disk identity.
|
|
186
|
+
*
|
|
187
|
+
* This is the one a consumer that opens the file itself can reproduce. When
|
|
188
|
+
* it equals `checkerDigest`, a matching read proves byte-identity with the
|
|
189
|
+
* facts. When it does not, the checker saw augmented text and that proof is
|
|
190
|
+
* simply not available for this file — which is a thing to report, not to
|
|
191
|
+
* paper over.
|
|
192
|
+
*
|
|
193
|
+
* Read it only when `provenance.capabilities` lists `diskDigests`. Without
|
|
194
|
+
* that claim every one of these is empty because the producer never hashed
|
|
195
|
+
* the disk, which is a different fact from a file that could not be read.
|
|
196
|
+
*/
|
|
197
|
+
diskDigest: string;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/** One compiler diagnostic from the generation that produced the facts. */
|
|
201
|
+
export interface IDiagnostic {
|
|
202
|
+
/** Project-relative. */
|
|
203
|
+
file: string;
|
|
204
|
+
|
|
205
|
+
/** 1-based line. */
|
|
206
|
+
line: number;
|
|
207
|
+
|
|
208
|
+
/** 1-based column. */
|
|
209
|
+
column: number;
|
|
210
|
+
|
|
211
|
+
/** The TypeScript diagnostic code, such as 2322. */
|
|
212
|
+
code: number;
|
|
213
|
+
|
|
214
|
+
/** Whether the finding fails a build. */
|
|
215
|
+
category: "error" | "warning";
|
|
216
|
+
|
|
217
|
+
/** The diagnostic text, without the code prefix. */
|
|
218
|
+
message: string;
|
|
219
|
+
}
|
|
220
|
+
|
|
33
221
|
/**
|
|
34
222
|
* A node as the builder sends it: the graph node, minus the file paths inside
|
|
35
223
|
* its spans, which the loader puts back from the node's own `file`.
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { ITtscGraphDump } from "./ITtscGraphDump";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* One response frame of the `ttscgraph serve` protocol.
|
|
5
|
+
*
|
|
6
|
+
* This is the envelope around a snapshot, mirrored by hand from `serveResponse`
|
|
7
|
+
* in `packages/ttsc/cmd/ttscgraph/serve.go`. There is no generator between the
|
|
8
|
+
* Go struct and this interface, so the two drift silently unless something
|
|
9
|
+
* checks them; `TtscGraphSession` validates every frame against this shape
|
|
10
|
+
* rather than casting it, so a drift surfaces as a precise error on the first
|
|
11
|
+
* frame instead of an `undefined` several layers downstream.
|
|
12
|
+
*/
|
|
13
|
+
export interface ITtscGraphSnapshot {
|
|
14
|
+
/** Echoes the request's id, so a response finds its caller. */
|
|
15
|
+
id: number;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The protocol version the server speaks.
|
|
19
|
+
*
|
|
20
|
+
* It rides every frame rather than a handshake. The binary and this package
|
|
21
|
+
* version independently — the session runs whichever `ttscgraph` the target
|
|
22
|
+
* project installed, or whatever `TTSC_GRAPH_BINARY` points at — so a
|
|
23
|
+
* mismatched pair is reachable, and before this field nothing detected it:
|
|
24
|
+
* the first symptom was a misparsed dump or a silently absent value.
|
|
25
|
+
*/
|
|
26
|
+
protocolVersion: number;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* What the producer did to answer this request.
|
|
30
|
+
*
|
|
31
|
+
* Required, and never absent — including on the error path, where it is
|
|
32
|
+
* `"error"`. A consumer can report `rebuild` versus `incremental` honestly
|
|
33
|
+
* because the compiler said so; no generation counter can distinguish a reuse
|
|
34
|
+
* from a full rebuild after the fact.
|
|
35
|
+
*/
|
|
36
|
+
mode: ITtscGraphSnapshot.Mode;
|
|
37
|
+
|
|
38
|
+
/** What this server can prove about the snapshots it publishes. */
|
|
39
|
+
capabilities: string[];
|
|
40
|
+
|
|
41
|
+
/** Whether the graph moved since the last snapshot. */
|
|
42
|
+
changed: boolean;
|
|
43
|
+
|
|
44
|
+
/** The snapshot, present exactly when `changed` is true. */
|
|
45
|
+
dump?: ITtscGraphDump;
|
|
46
|
+
|
|
47
|
+
/** Set when the request produced no snapshot; `mode` is then `"error"`. */
|
|
48
|
+
error?: string;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export namespace ITtscGraphSnapshot {
|
|
52
|
+
/**
|
|
53
|
+
* The computation modes the producer reports, plus the transport's `error`.
|
|
54
|
+
*
|
|
55
|
+
* - `initial`: the session's first snapshot.
|
|
56
|
+
* - `reload`: the build universe moved, so the program was reloaded whole.
|
|
57
|
+
* - `unchanged`: nothing moved; no dump rides it and the last one still holds.
|
|
58
|
+
* - `incremental`: edits applied onto the reused resident program.
|
|
59
|
+
* - `rebuild`: edits applied, but the program could not be reused.
|
|
60
|
+
* - `error`: no snapshot was produced.
|
|
61
|
+
*/
|
|
62
|
+
export type Mode =
|
|
63
|
+
| "initial"
|
|
64
|
+
| "reload"
|
|
65
|
+
| "unchanged"
|
|
66
|
+
| "incremental"
|
|
67
|
+
| "rebuild"
|
|
68
|
+
| "error";
|
|
69
|
+
}
|
package/src/structures/index.ts
CHANGED
|
@@ -17,6 +17,7 @@ export * from "./ITtscGraphOverview";
|
|
|
17
17
|
export * from "./ITtscGraphLookup";
|
|
18
18
|
export * from "./ITtscGraphNext";
|
|
19
19
|
export * from "./ITtscGraphTrace";
|
|
20
|
+
export * from "./ITtscGraphSnapshot";
|
|
20
21
|
export * from "./ITtscGraphSpan";
|
|
21
22
|
export * from "./ITtscGraphTour";
|
|
22
23
|
export * from "./TtscGraphEdgeKind";
|