@descryy/adapter-go 0.1.0 → 0.3.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/LICENSE +8 -0
- package/dist/adapter.d.ts +2 -5
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +36 -66
- package/dist/adapter.js.map +1 -1
- package/dist/client.d.ts +5 -73
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +11 -115
- package/dist/client.js.map +1 -1
- package/dist/extract.d.ts +3 -25
- package/dist/extract.d.ts.map +1 -1
- package/dist/extract.js +9 -79
- package/dist/extract.js.map +1 -1
- package/dist/parse.d.ts +12 -100
- package/dist/parse.d.ts.map +1 -1
- package/dist/parse.js +38 -150
- package/dist/parse.js.map +1 -1
- package/package.json +15 -6
package/LICENSE
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
Copyright (c) 2026 Descry
|
|
2
|
+
|
|
3
|
+
All rights reserved.
|
|
4
|
+
|
|
5
|
+
This software is proprietary and confidential. No license, express or
|
|
6
|
+
implied, to use, copy, modify, merge, publish, distribute, sublicense, or
|
|
7
|
+
sell copies of this software is granted without prior written permission
|
|
8
|
+
from the copyright holder.
|
package/dist/adapter.d.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The Go `LanguageAdapter` —
|
|
3
|
-
*
|
|
4
|
-
* Structurally this is the Java adapter with a different grammar and a different
|
|
5
|
-
* rule set, which is the whole claim the tree-sitter harness was built to test.
|
|
6
|
-
* Nothing in `@descryy/adapter-treesitter` changed to accommodate Go.
|
|
2
|
+
* The Go `LanguageAdapter` — breadth tier. Structurally the Java adapter with
|
|
3
|
+
* a different grammar/rule set, the claim the tree-sitter harness tests.
|
|
7
4
|
*/
|
|
8
5
|
import { type LanguageAdapter, type ResolutionLevel } from "@descryy/ir";
|
|
9
6
|
import { toRepoRelative } from "@descryy/adapter-common";
|
package/dist/adapter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,EAML,KAAK,eAAe,EAGpB,KAAK,eAAe,EAGrB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAyB,cAAc,EAAwB,MAAM,yBAAyB,CAAC;AAKtG,OAAO,EAAW,QAAQ,EAA4B,MAAM,cAAc,CAAC;AAE3E,eAAO,MAAM,UAAU,eAAe,CAAC;AACvC,eAAO,MAAM,eAAe,UAAU,CAAC;AACvC,eAAO,MAAM,gBAAgB,sBAAuB,CAAC;AAerD,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,QAAQ,CAAC,aAAa,CAAC,EAAE,eAAe,CAAC;CAC1C;AAcD,MAAM,WAAW,SAAU,SAAQ,eAAe;IAChD,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,wBAAgB,eAAe,CAAC,OAAO,GAAE,gBAAqB,GAAG,SAAS,CA8LzE;AAED,2DAA2D;AAC3D,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAS7D;AAED,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,CAAC"}
|
package/dist/adapter.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The Go `LanguageAdapter` —
|
|
3
|
-
*
|
|
4
|
-
* Structurally this is the Java adapter with a different grammar and a different
|
|
5
|
-
* rule set, which is the whole claim the tree-sitter harness was built to test.
|
|
6
|
-
* Nothing in `@descryy/adapter-treesitter` changed to accommodate Go.
|
|
2
|
+
* The Go `LanguageAdapter` — breadth tier. Structurally the Java adapter with
|
|
3
|
+
* a different grammar/rule set, the claim the tree-sitter harness tests.
|
|
7
4
|
*/
|
|
8
5
|
import { createHash } from "node:crypto";
|
|
9
6
|
import { createRequire } from "node:module";
|
|
@@ -25,15 +22,7 @@ function grammarPath() {
|
|
|
25
22
|
return beside;
|
|
26
23
|
return createRequire(import.meta.url).resolve("tree-sitter-go/tree-sitter-go.wasm");
|
|
27
24
|
}
|
|
28
|
-
/**
|
|
29
|
-
* Vendored dependencies are somebody else's source.
|
|
30
|
-
*
|
|
31
|
-
* `vendor/` holds a copy of the module graph, and analysing it both doubles the
|
|
32
|
-
* work and puts a second declaration of every vendored symbol in the graph.
|
|
33
|
-
* Unlike Java's build directories this needs no source-root caveat: `vendor` is
|
|
34
|
-
* a reserved directory name in the Go toolchain, not a package name a project
|
|
35
|
-
* chooses, and `go build` excludes it by the same rule.
|
|
36
|
-
*/
|
|
25
|
+
/** `vendor/` doubles work and double-declares symbols; unlike Java, `vendor` is a reserved Go toolchain name, needing no source-root caveat. */
|
|
37
26
|
function isVendored(file) {
|
|
38
27
|
return `/${file}`.includes("/vendor/") || `/${file}`.includes("/testdata/");
|
|
39
28
|
}
|
|
@@ -42,7 +31,17 @@ export function createGoAdapter(options = {}) {
|
|
|
42
31
|
const ceiling = options.maxResolution ?? 2;
|
|
43
32
|
let session;
|
|
44
33
|
let parser;
|
|
45
|
-
|
|
34
|
+
let nestedCheckouts = [];
|
|
35
|
+
let ignoredByProject = [];
|
|
36
|
+
const filesUnder = (root) => {
|
|
37
|
+
const nested = [];
|
|
38
|
+
const found = discover(root.absolutePath, globs, {
|
|
39
|
+
onNestedCheckout: (dir) => nested.push(dir),
|
|
40
|
+
onIgnored: (names) => (ignoredByProject = names),
|
|
41
|
+
}).filter((file) => !isVendored(file));
|
|
42
|
+
nestedCheckouts = nested;
|
|
43
|
+
return found;
|
|
44
|
+
};
|
|
46
45
|
return {
|
|
47
46
|
id: ADAPTER_ID,
|
|
48
47
|
version: ADAPTER_VERSION,
|
|
@@ -60,36 +59,24 @@ export function createGoAdapter(options = {}) {
|
|
|
60
59
|
// there is no import path, and nothing outside can name these packages.
|
|
61
60
|
evidence.push("no go.mod found — packages have no import path and cannot be identified");
|
|
62
61
|
}
|
|
62
|
+
for (const nested of nestedCheckouts) {
|
|
63
|
+
evidence.push(`skipped ${nested}: a separate checkout with its own .git`);
|
|
64
|
+
}
|
|
65
|
+
if (ignoredByProject.length > 0) {
|
|
66
|
+
evidence.push(`skipped ${ignoredByProject.length} director(ies) the project's own .gitignore excludes: ` +
|
|
67
|
+
`${ignoredByProject.slice(0, 12).join(", ")}`);
|
|
68
|
+
}
|
|
63
69
|
return { detected: files.length > 0, roots: files.length > 0 ? [root.absolutePath] : [], evidence };
|
|
64
70
|
},
|
|
65
71
|
capabilities() {
|
|
66
72
|
return {
|
|
67
73
|
maxResolution: ceiling,
|
|
68
74
|
nodeTypes: ["MODULE", "CLASS", "FUNCTION", "TEST_CASE", "API_ROUTE", "API_ENDPOINT"],
|
|
69
|
-
|
|
70
|
-
* `IMPLEMENTS` is absent, and its absence is the honest part.
|
|
71
|
-
*
|
|
72
|
-
* Go's interface satisfaction is structural: a type implements an
|
|
73
|
-
* interface by having the right method set, and no line of source says
|
|
74
|
-
* so. Deciding it means comparing method sets, which is R3 evidence this
|
|
75
|
-
* adapter does not have — and inferring it from names would be a guess
|
|
76
|
-
* in the one place the corpus has a negative pattern for guessing.
|
|
77
|
-
* Embedding is written down and becomes `INHERITS`.
|
|
78
|
-
*/
|
|
75
|
+
// `IMPLEMENTS` absent: Go satisfaction is structural, needs R3 this adapter lacks. Embedding becomes `INHERITS`.
|
|
79
76
|
edgeTypes: ["IMPORTS", "CALLS", "TESTS", "INHERITS", "USES_TYPE", "SERVES_API", "USES_API"],
|
|
80
77
|
hasCallHierarchy: false,
|
|
81
78
|
hasTypeHierarchy: false,
|
|
82
|
-
|
|
83
|
-
* Directories this ecosystem installs dependencies or build output into —
|
|
84
|
-
* DEC-110's end state. The engine used to hold `node_modules`/`vendor`/`target`
|
|
85
|
-
* in a hardcoded list; it holds none of them now and consumes this instead.
|
|
86
|
-
*
|
|
87
|
-
* `vendor/` holds a copy of the module graph — analysing it doubles the work and
|
|
88
|
-
* puts a second declaration of every vendored symbol in the graph.
|
|
89
|
-
*
|
|
90
|
-
* Names only — the walk matches one path component, so a path or glob matches
|
|
91
|
-
* nothing. Nothing dotted — those are skipped structurally already.
|
|
92
|
-
*/
|
|
79
|
+
// DEC-110: engine no longer hardcodes noise dirs, consumes this instead. Names only, one path component.
|
|
93
80
|
noiseDirectories: ["vendor"],
|
|
94
81
|
frameworkExtractors: [
|
|
95
82
|
"net/http",
|
|
@@ -99,29 +86,14 @@ export function createGoAdapter(options = {}) {
|
|
|
99
86
|
"github.com/gorilla/mux",
|
|
100
87
|
"google.golang.org/grpc",
|
|
101
88
|
],
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
* grades pattern 04 as before; `client-call-extractor` reads `client.ts`'s
|
|
105
|
-
* three call shapes (package-level convenience funcs, `*http.Client`
|
|
106
|
-
* methods, `NewRequest`'s own literal arguments) and genuinely produces
|
|
107
|
-
* `USES_API` edges — see `client.ts`'s own header. Whether golden pattern
|
|
108
|
-
* 08 can confirm it is a separate question from whether the extraction is
|
|
109
|
-
* honest: it needs `order_page` retyped away from `COMPONENT` in this
|
|
110
|
-
* corpus's own `manifest.json` (DEC-262's fork — Go is backend-only and
|
|
111
|
-
* has no honest claim to a UI component, the same reason Kotlin and
|
|
112
|
-
* Python already carry this override) and a fixture that makes a real
|
|
113
|
-
* call. Declaring the capability here is safe either way — DEC-262 found
|
|
114
|
-
* this exact declaration never fails a golden pattern, it either passes
|
|
115
|
-
* genuinely or stays permanently skipped on an honest incapacity, never
|
|
116
|
-
* both silently wrong.
|
|
117
|
-
*/
|
|
89
|
+
// Both HTTP boundary halves: route-extractor (pattern 04), client-call-extractor (real USES_API, `client.ts`).
|
|
90
|
+
// DEC-262: safe either way — never fails a golden pattern, passes genuinely or stays honestly skipped.
|
|
118
91
|
frameworkCapabilities: [ROUTE_EXTRACTOR, CLIENT_CALL_EXTRACTOR],
|
|
119
92
|
};
|
|
120
93
|
},
|
|
121
94
|
async prepare(ctx) {
|
|
122
|
-
// Sorted
|
|
123
|
-
//
|
|
124
|
-
// to hand the files over.
|
|
95
|
+
// Sorted so a build-constraint collision's winner is a property of the
|
|
96
|
+
// repo, not of filesystem enumeration order.
|
|
125
97
|
const files = [...filesUnder(ctx.root)].sort();
|
|
126
98
|
parser ??= await parserFor(grammarPath());
|
|
127
99
|
const modules = goModules(ctx.root.absolutePath, files);
|
|
@@ -147,12 +119,8 @@ export function createGoAdapter(options = {}) {
|
|
|
147
119
|
failures.push(outcome.failure);
|
|
148
120
|
continue;
|
|
149
121
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
* not the file. Reading and parsing were already per-file; this step was
|
|
153
|
-
* the gap, and it is the one that fires on half-written source — which is
|
|
154
|
-
* exactly what someone analysing code they just wrote is handing us.
|
|
155
|
-
*/
|
|
122
|
+
// Tree walk is isolated: a throw here used to cost the whole run, not
|
|
123
|
+
// the file, and it fires hardest on half-written source.
|
|
156
124
|
const read = isolateFile(file, () => readGoFile(outcome.tree.rootNode, file, outcome.tree.rootNode.hasError));
|
|
157
125
|
outcome.tree.delete();
|
|
158
126
|
if (read.failure !== undefined) {
|
|
@@ -202,9 +170,8 @@ export function createGoAdapter(options = {}) {
|
|
|
202
170
|
sourceFiles: active.files.filter((f) => !excludedFiles.has(f)),
|
|
203
171
|
skippedFiles: [
|
|
204
172
|
...active.failures.map((f) => ({ file: f.file, reason: f.kind, detail: f.detail })),
|
|
205
|
-
// `other`, not a fifth reason code
|
|
206
|
-
//
|
|
207
|
-
// walk of it, which the detail says outright.
|
|
173
|
+
// `other`, not a fifth reason code — the file was read and parsed;
|
|
174
|
+
// what failed is our walk of it, which the detail says outright.
|
|
208
175
|
...active.unfinished.map((f) => ({ file: f.file, reason: "other", detail: f.detail })),
|
|
209
176
|
...active.withoutModule.map((file) => ({ file, reason: "other", detail: REASONS.noImportPath })),
|
|
210
177
|
],
|
|
@@ -239,8 +206,11 @@ export function hashOf(root, relative) {
|
|
|
239
206
|
try {
|
|
240
207
|
return createHash("sha256").update(readFileSync(join(root, relative))).digest("hex").slice(0, 32);
|
|
241
208
|
}
|
|
242
|
-
catch {
|
|
243
|
-
|
|
209
|
+
catch (error) {
|
|
210
|
+
// Disclosed gap, not a hash: `""` would collide every unreadable file (C-F7).
|
|
211
|
+
// Marker can't equal a real hash; keyed by path so two never collide either.
|
|
212
|
+
const code = error instanceof Error && "code" in error ? String(error.code) : "UNKNOWN";
|
|
213
|
+
return `unreadable:${code}:${relative}`;
|
|
244
214
|
}
|
|
245
215
|
}
|
|
246
216
|
export { LANGUAGE, toRepoRelative };
|
package/dist/adapter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAUL,qBAAqB,EACrB,eAAe,GAChB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,cAAc,EAAwB,MAAM,yBAAyB,CAAC;AACtG,OAAO,EAAE,SAAS,EAAE,SAAS,EAAkC,MAAM,6BAA6B,CAAC;AAEnG,OAAO,EAAE,iBAAiB,EAAE,QAAQ,IAAI,UAAU,EAAe,MAAM,YAAY,CAAC;AAC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O,cAAc,IAAI,IAAI,QAAQ,EAAE,CAAC;IAC1C,CAAC;AACH,CAAC;AAED,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,CAAC"}
|
package/dist/client.d.ts
CHANGED
|
@@ -1,61 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* `
|
|
5
|
-
* This reads the other end — an outbound call with a statically knowable path —
|
|
6
|
-
* and mints the **same** `API_ENDPOINT` node from the same `endpointQsp`, so the
|
|
7
|
-
* two join without either side knowing the other ran (DEC-115).
|
|
8
|
-
*
|
|
9
|
-
* FUNCTION ──USES_API──▶ API_ENDPOINT ◀──SERVES_API── API_ROUTE
|
|
10
|
-
*
|
|
11
|
-
* ## Structured like `routes.ts`, not like Java's `client.ts`
|
|
12
|
-
*
|
|
13
|
-
* Java's client reader walks `JavaRef` — a flat, already-collected list of
|
|
14
|
-
* references with a `firstStringArgument` field captured at parse time. Go has
|
|
15
|
-
* no equivalent: `GoRef` keeps a short `raw` summary but not positional argument
|
|
16
|
-
* access, because nothing before this needed it. `net/http.NewRequest(method,
|
|
17
|
-
* url, body)` needs **two** literal positions read out of one call — the verb
|
|
18
|
-
* and the path both — so this reads `call_expression` nodes directly off the
|
|
19
|
-
* tree, the same shape `routes.ts`'s `readCall` already uses for the provider
|
|
20
|
-
* side of this exact boundary.
|
|
21
|
-
*
|
|
22
|
-
* ## Three shapes, one budget
|
|
23
|
-
*
|
|
24
|
-
* | shape | evidence |
|
|
25
|
-
* | --- | --- |
|
|
26
|
-
* | `http.Get(url)` / `Head` / `Post` / `PostForm` | the receiver is the `net/http` package itself, resolved through the file's own import table |
|
|
27
|
-
* | `client.Get(url)` / `Head` / `Post` / `PostForm` / `Do(req)` | the receiver's **declared type** is `http.Client` (pointer stripped), from a parameter, a `:=` composite literal, or a `var` |
|
|
28
|
-
* | `http.NewRequest(method, url, body)` / `NewRequestWithContext(ctx, method, url, body)` | the receiver is the `net/http` package; verb **and** path are both this call's own arguments — the verb as a string literal or one of `net/http`'s own exported `Method*` constants, the path as a string literal |
|
|
29
|
-
*
|
|
30
|
-
* `Do(req)` is refused unconditionally, never traced back to whatever built
|
|
31
|
-
* `req` — the same shape Java's `OkHttpClient`/`java.net.http.HttpClient`
|
|
32
|
-
* builder-client rows are refused for (D-FIX-3): the request is a separately
|
|
33
|
-
* constructed object, and reading through a builder chain to find where it was
|
|
34
|
-
* built is a different, larger row. `NewRequest`'s own call is a separate,
|
|
35
|
-
* independent extraction site — its literal arguments are read directly, never
|
|
36
|
-
* traced forward into whatever `.Do()` call eventually consumes the request it
|
|
37
|
-
* returns, so nothing here double-counts one HTTP call as two edges.
|
|
38
|
-
*
|
|
39
|
-
* ## Why the receiver's type must be written down
|
|
40
|
-
*
|
|
41
|
-
* `Get`, `Post`, `Do` are ordinary method names — a cache client, a mock, a
|
|
42
|
-
* test double could all have one. Admitting a call on the name alone would emit
|
|
43
|
-
* `USES_API` for anything shaped like `thing.Get(x)`, joining a caller to a
|
|
44
|
-
* route it never calls. So `client.*` is only admitted when the receiver's
|
|
45
|
-
* declared type resolves, through the import table, to `net/http.Client` —
|
|
46
|
-
* the same discipline `routes.ts` already holds for `NewServeMux`.
|
|
47
|
-
*
|
|
48
|
-
* ## The origin check, reused rather than re-derived
|
|
49
|
-
*
|
|
50
|
-
* `namesAnotherOrigin`/`relativePath` are copied verbatim from
|
|
51
|
-
* `adapter-java/src/client.ts` (via `adapter-csharp`'s DEC-260/261 fix): only an
|
|
52
|
-
* unambiguous absolute form (an explicit scheme, or `//host/...`) earns
|
|
53
|
-
* "another origin"; a bare relative path with no leading slash is `undetermined`
|
|
54
|
-
* — it may resolve against a `Client.BaseURL` this reader does not see, or it
|
|
55
|
-
* may not, and claiming either is a guess. This project has now found the
|
|
56
|
-
* identical latent bug in three languages that copied "does not start with a
|
|
57
|
-
* scheme" as sufficient evidence; the fourth and fifth (Rust, Ruby, PHP) reuse
|
|
58
|
-
* this same text rather than re-deriving it a fourth time.
|
|
2
|
+
* Caller's half of the HTTP boundary: `USES_API`, golden pattern 08. Mints
|
|
3
|
+
* the same `API_ENDPOINT` as `routes.ts`'s `SERVES_API` side (DEC-115).
|
|
4
|
+
* `client.*` only admitted on a resolved `http.Client` type.
|
|
59
5
|
*/
|
|
60
6
|
import type { Node } from "@descryy/adapter-treesitter";
|
|
61
7
|
import { type IdentityScope, type IRNode } from "@descryy/ir";
|
|
@@ -90,25 +36,11 @@ export interface GoClientCall extends GoClientCallSite {
|
|
|
90
36
|
export interface GoClientRefusal extends GoClientRefusalSite {
|
|
91
37
|
readonly fromId: string;
|
|
92
38
|
}
|
|
93
|
-
/**
|
|
94
|
-
* Every outbound HTTP call in one function body, with a ledger row for each
|
|
95
|
-
* refusal.
|
|
96
|
-
*
|
|
97
|
-
* `locals` is the function's **already-fully-walked** local table — parameters
|
|
98
|
-
* and `:=`/`var` declarations alike — so a `*http.Client` parameter and a
|
|
99
|
-
* `client := &http.Client{}` local are both visible with no separate pass. It
|
|
100
|
-
* is read, never written: this module adds no new declarations to it.
|
|
101
|
-
*/
|
|
39
|
+
/** Every outbound HTTP call in a function body, ledger row per refusal. `locals` read but never written here. */
|
|
102
40
|
export declare function readGoClientCalls(body: Node, unit: GoFile, locals: ReadonlyMap<string, string | null>, isTest: boolean, parameterNames?: ReadonlySet<string>): {
|
|
103
41
|
readonly calls: readonly GoClientCallSite[];
|
|
104
42
|
readonly refusals: readonly GoClientRefusalSite[];
|
|
105
43
|
};
|
|
106
|
-
/**
|
|
107
|
-
* The `API_ENDPOINT` a call joins to — minted identically to the route side.
|
|
108
|
-
*
|
|
109
|
-
* Shares `endpointQsp` with `extract.ts`'s `SERVES_API` block, so the two ids
|
|
110
|
-
* agree exactly. DEC-115's one hard constraint: two producers that mint
|
|
111
|
-
* different ids for the same route do not conflict, they silently fail to join.
|
|
112
|
-
*/
|
|
44
|
+
/** The `API_ENDPOINT` a call joins to, minted identically to the route side — shares `endpointQsp` (DEC-115). */
|
|
113
45
|
export declare function endpointFor(scope: IdentityScope, call: GoClientCall, producedBy: string, normalise: (template: string) => string): IRNode;
|
|
114
46
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,EAAuB,KAAK,aAAa,EAAE,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AAEnF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAyBzC,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,oEAAoE;IACpE,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,YAAY,CAAC;CAC5C;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,gFAAgF;IAChF,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,sFAAsF;IACtF,QAAQ,CAAC,YAAY,EAAE,gBAAgB,GAAG,cAAc,GAAG,SAAS,CAAC;IACrE;;;;OAIG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,eAAe,GAAG,OAAO,CAAC;CACtE;AAKD,MAAM,MAAM,gBAAgB,GAAG,eAAe,GAAG,iBAAiB,GAAG,gBAAgB,CAAC;AAiCtF,MAAM,WAAW,YAAa,SAAQ,gBAAgB;IACpD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,eAAgB,SAAQ,mBAAmB;IAC1D,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAmDD,iHAAiH;AACjH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,EAC1C,MAAM,EAAE,OAAO,EACf,cAAc,GAAE,WAAW,CAAC,MAAM,CAAa,GAC9C;IAAE,QAAQ,CAAC,KAAK,EAAE,SAAS,gBAAgB,EAAE,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,SAAS,mBAAmB,EAAE,CAAA;CAAE,CAsHpG;AAED,iHAAiH;AACjH,wBAAgB,WAAW,CACzB,KAAK,EAAE,aAAa,EACpB,IAAI,EAAE,YAAY,EAClB,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,GACtC,MAAM,CAaR"}
|
package/dist/client.js
CHANGED
|
@@ -1,61 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* `
|
|
5
|
-
* This reads the other end — an outbound call with a statically knowable path —
|
|
6
|
-
* and mints the **same** `API_ENDPOINT` node from the same `endpointQsp`, so the
|
|
7
|
-
* two join without either side knowing the other ran (DEC-115).
|
|
8
|
-
*
|
|
9
|
-
* FUNCTION ──USES_API──▶ API_ENDPOINT ◀──SERVES_API── API_ROUTE
|
|
10
|
-
*
|
|
11
|
-
* ## Structured like `routes.ts`, not like Java's `client.ts`
|
|
12
|
-
*
|
|
13
|
-
* Java's client reader walks `JavaRef` — a flat, already-collected list of
|
|
14
|
-
* references with a `firstStringArgument` field captured at parse time. Go has
|
|
15
|
-
* no equivalent: `GoRef` keeps a short `raw` summary but not positional argument
|
|
16
|
-
* access, because nothing before this needed it. `net/http.NewRequest(method,
|
|
17
|
-
* url, body)` needs **two** literal positions read out of one call — the verb
|
|
18
|
-
* and the path both — so this reads `call_expression` nodes directly off the
|
|
19
|
-
* tree, the same shape `routes.ts`'s `readCall` already uses for the provider
|
|
20
|
-
* side of this exact boundary.
|
|
21
|
-
*
|
|
22
|
-
* ## Three shapes, one budget
|
|
23
|
-
*
|
|
24
|
-
* | shape | evidence |
|
|
25
|
-
* | --- | --- |
|
|
26
|
-
* | `http.Get(url)` / `Head` / `Post` / `PostForm` | the receiver is the `net/http` package itself, resolved through the file's own import table |
|
|
27
|
-
* | `client.Get(url)` / `Head` / `Post` / `PostForm` / `Do(req)` | the receiver's **declared type** is `http.Client` (pointer stripped), from a parameter, a `:=` composite literal, or a `var` |
|
|
28
|
-
* | `http.NewRequest(method, url, body)` / `NewRequestWithContext(ctx, method, url, body)` | the receiver is the `net/http` package; verb **and** path are both this call's own arguments — the verb as a string literal or one of `net/http`'s own exported `Method*` constants, the path as a string literal |
|
|
29
|
-
*
|
|
30
|
-
* `Do(req)` is refused unconditionally, never traced back to whatever built
|
|
31
|
-
* `req` — the same shape Java's `OkHttpClient`/`java.net.http.HttpClient`
|
|
32
|
-
* builder-client rows are refused for (D-FIX-3): the request is a separately
|
|
33
|
-
* constructed object, and reading through a builder chain to find where it was
|
|
34
|
-
* built is a different, larger row. `NewRequest`'s own call is a separate,
|
|
35
|
-
* independent extraction site — its literal arguments are read directly, never
|
|
36
|
-
* traced forward into whatever `.Do()` call eventually consumes the request it
|
|
37
|
-
* returns, so nothing here double-counts one HTTP call as two edges.
|
|
38
|
-
*
|
|
39
|
-
* ## Why the receiver's type must be written down
|
|
40
|
-
*
|
|
41
|
-
* `Get`, `Post`, `Do` are ordinary method names — a cache client, a mock, a
|
|
42
|
-
* test double could all have one. Admitting a call on the name alone would emit
|
|
43
|
-
* `USES_API` for anything shaped like `thing.Get(x)`, joining a caller to a
|
|
44
|
-
* route it never calls. So `client.*` is only admitted when the receiver's
|
|
45
|
-
* declared type resolves, through the import table, to `net/http.Client` —
|
|
46
|
-
* the same discipline `routes.ts` already holds for `NewServeMux`.
|
|
47
|
-
*
|
|
48
|
-
* ## The origin check, reused rather than re-derived
|
|
49
|
-
*
|
|
50
|
-
* `namesAnotherOrigin`/`relativePath` are copied verbatim from
|
|
51
|
-
* `adapter-java/src/client.ts` (via `adapter-csharp`'s DEC-260/261 fix): only an
|
|
52
|
-
* unambiguous absolute form (an explicit scheme, or `//host/...`) earns
|
|
53
|
-
* "another origin"; a bare relative path with no leading slash is `undetermined`
|
|
54
|
-
* — it may resolve against a `Client.BaseURL` this reader does not see, or it
|
|
55
|
-
* may not, and claiming either is a guess. This project has now found the
|
|
56
|
-
* identical latent bug in three languages that copied "does not start with a
|
|
57
|
-
* scheme" as sufficient evidence; the fourth and fifth (Rust, Ruby, PHP) reuse
|
|
58
|
-
* this same text rather than re-deriving it a fourth time.
|
|
2
|
+
* Caller's half of the HTTP boundary: `USES_API`, golden pattern 08. Mints
|
|
3
|
+
* the same `API_ENDPOINT` as `routes.ts`'s `SERVES_API` side (DEC-115).
|
|
4
|
+
* `client.*` only admitted on a resolved `http.Client` type.
|
|
59
5
|
*/
|
|
60
6
|
import { endpointQsp, nodeId } from "@descryy/ir";
|
|
61
7
|
const HTTP_PACKAGE = "net/http";
|
|
@@ -66,18 +12,7 @@ const VERB_METHODS = new Map([
|
|
|
66
12
|
["Post", "POST"],
|
|
67
13
|
["PostForm", "POST"],
|
|
68
14
|
]);
|
|
69
|
-
/**
|
|
70
|
-
* `net/http`'s own exported verb constants — `http.MethodGet`, and so on.
|
|
71
|
-
*
|
|
72
|
-
* Reading these is resolution, not inference: `http.MethodGet`'s value is
|
|
73
|
-
* fixed by the stdlib's own public API (RFC 7231's registered methods), the
|
|
74
|
-
* same way `http.NewServeMux` names a known constructor in `routes.ts`. This
|
|
75
|
-
* is the idiomatic form: on `gin` and `prometheus`, `http.NewRequest(http.MethodGet,
|
|
76
|
-
* ...)` outnumbers a bare `"GET"` string literal by a wide margin. Missing it
|
|
77
|
-
* would have meant refusing nearly every real `NewRequest` call in both
|
|
78
|
-
* corpora as "not a bare string literal" — technically true of the argument's
|
|
79
|
-
* *node type*, but not of what the source actually states.
|
|
80
|
-
*/
|
|
15
|
+
/** `net/http`'s exported verb constants — resolution, not inference. Outnumbers bare string literals by far on `gin`/`prometheus`. */
|
|
81
16
|
const HTTP_METHOD_CONSTANTS = new Map([
|
|
82
17
|
["MethodGet", "GET"],
|
|
83
18
|
["MethodHead", "HEAD"],
|
|
@@ -103,11 +38,7 @@ function argumentKindOf(text) {
|
|
|
103
38
|
return "field";
|
|
104
39
|
return "other";
|
|
105
40
|
}
|
|
106
|
-
/**
|
|
107
|
-
* Why an argument node could not be read as a literal path — a bare
|
|
108
|
-
* identifier that is the enclosing function's own input parameter, a known
|
|
109
|
-
* environment-read call, or something this reader does not trace.
|
|
110
|
-
*/
|
|
41
|
+
/** Why an argument couldn't be read as a literal path: input param, env-read call, or untraced. */
|
|
111
42
|
function diagnoseArgument(text, parameterNames) {
|
|
112
43
|
if (text === undefined)
|
|
113
44
|
return CAPABILITY_GAP;
|
|
@@ -130,12 +61,7 @@ function literalOf(node) {
|
|
|
130
61
|
return undefined;
|
|
131
62
|
return text.replace(/^["`]|["`]$/g, "");
|
|
132
63
|
}
|
|
133
|
-
/**
|
|
134
|
-
* A path this reader will claim: repository-relative, no scheme, no assembly.
|
|
135
|
-
*
|
|
136
|
-
* Copied from `adapter-java`/`adapter-csharp`'s `client.ts` — see this file's
|
|
137
|
-
* own header for why re-derivation is exactly what this row was told not to do.
|
|
138
|
-
*/
|
|
64
|
+
/** Repo-relative, no scheme, no assembly. Copied verbatim from `adapter-java`/`adapter-csharp` (DEC-260/261) — not re-derived. */
|
|
139
65
|
function relativePath(value) {
|
|
140
66
|
if (!value.startsWith("/"))
|
|
141
67
|
return undefined;
|
|
@@ -148,19 +74,11 @@ function relativePath(value) {
|
|
|
148
74
|
function namesAnotherOrigin(value) {
|
|
149
75
|
return /^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//.test(value) || value.startsWith("//");
|
|
150
76
|
}
|
|
151
|
-
/**
|
|
152
|
-
* Does `base` (as written at a call site) resolve to `net/http` through this
|
|
153
|
-
* file's own import table? The alias may not be `http` — `import xhttp "net/http"`
|
|
154
|
-
* is legal Go, and the import table is exactly what already resolves it.
|
|
155
|
-
*/
|
|
77
|
+
/** Does `base` resolve to `net/http` via the import table? Alias may not be `http` (`import xhttp "net/http"`). */
|
|
156
78
|
function isHttpPackage(base, unit) {
|
|
157
79
|
return unit.imports.get(base) === HTTP_PACKAGE;
|
|
158
80
|
}
|
|
159
|
-
/**
|
|
160
|
-
* A verb, from either a string literal (`"GET"`, case-normalised) or one of
|
|
161
|
-
* `net/http`'s own exported constants (`http.MethodGet`) — see
|
|
162
|
-
* {@link HTTP_METHOD_CONSTANTS}.
|
|
163
|
-
*/
|
|
81
|
+
/** A verb: a string literal (case-normalised) or one of {@link HTTP_METHOD_CONSTANTS}. */
|
|
164
82
|
function verbOf(node, unit) {
|
|
165
83
|
const literal = literalOf(node);
|
|
166
84
|
if (literal !== undefined)
|
|
@@ -175,15 +93,7 @@ function verbOf(node, unit) {
|
|
|
175
93
|
return undefined;
|
|
176
94
|
return HTTP_METHOD_CONSTANTS.get(field.text);
|
|
177
95
|
}
|
|
178
|
-
/**
|
|
179
|
-
* Does a written type name (pointer already stripped by `baseTypeName`, e.g.
|
|
180
|
-
* `"http.Client"` or `"xhttp.Client"`) resolve to `net/http.Client`?
|
|
181
|
-
*
|
|
182
|
-
* `baseTypeName` returns a `qualified_type`'s text verbatim — whatever
|
|
183
|
-
* qualifier the source actually wrote — so the qualifier is resolved through
|
|
184
|
-
* the import table exactly as {@link isHttpPackage} does for a package-level
|
|
185
|
-
* call, rather than string-matched against the literal text `"http.Client"`.
|
|
186
|
-
*/
|
|
96
|
+
/** Does a written type name resolve to `net/http.Client`? Qualifier resolved via import table, not string-matched. */
|
|
187
97
|
function isHttpClientType(written, unit) {
|
|
188
98
|
if (written === null || written === undefined)
|
|
189
99
|
return false;
|
|
@@ -194,15 +104,7 @@ function isHttpClientType(written, unit) {
|
|
|
194
104
|
const name = written.slice(cut + 1);
|
|
195
105
|
return name === "Client" && unit.imports.get(qualifier) === HTTP_PACKAGE;
|
|
196
106
|
}
|
|
197
|
-
/**
|
|
198
|
-
* Every outbound HTTP call in one function body, with a ledger row for each
|
|
199
|
-
* refusal.
|
|
200
|
-
*
|
|
201
|
-
* `locals` is the function's **already-fully-walked** local table — parameters
|
|
202
|
-
* and `:=`/`var` declarations alike — so a `*http.Client` parameter and a
|
|
203
|
-
* `client := &http.Client{}` local are both visible with no separate pass. It
|
|
204
|
-
* is read, never written: this module adds no new declarations to it.
|
|
205
|
-
*/
|
|
107
|
+
/** Every outbound HTTP call in a function body, ledger row per refusal. `locals` read but never written here. */
|
|
206
108
|
export function readGoClientCalls(body, unit, locals, isTest, parameterNames = new Set()) {
|
|
207
109
|
const calls = [];
|
|
208
110
|
const refusals = [];
|
|
@@ -318,13 +220,7 @@ export function readGoClientCalls(body, unit, locals, isTest, parameterNames = n
|
|
|
318
220
|
visit(body);
|
|
319
221
|
return { calls, refusals };
|
|
320
222
|
}
|
|
321
|
-
/**
|
|
322
|
-
* The `API_ENDPOINT` a call joins to — minted identically to the route side.
|
|
323
|
-
*
|
|
324
|
-
* Shares `endpointQsp` with `extract.ts`'s `SERVES_API` block, so the two ids
|
|
325
|
-
* agree exactly. DEC-115's one hard constraint: two producers that mint
|
|
326
|
-
* different ids for the same route do not conflict, they silently fail to join.
|
|
327
|
-
*/
|
|
223
|
+
/** The `API_ENDPOINT` a call joins to, minted identically to the route side — shares `endpointQsp` (DEC-115). */
|
|
328
224
|
export function endpointFor(scope, call, producedBy, normalise) {
|
|
329
225
|
const template = normalise(call.template);
|
|
330
226
|
return {
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,EAAmC,MAAM,aAAa,CAAC;AAInF,MAAM,YAAY,GAAG,UAAU,CAAC;AAEhC,4FAA4F;AAC5F,MAAM,YAAY,GAAgC,IAAI,GAAG,CAAC;IACxD,CAAC,KAAK,EAAE,KAAK,CAAC;IACd,CAAC,MAAM,EAAE,MAAM,CAAC;IAChB,CAAC,MAAM,EAAE,MAAM,CAAC;IAChB,CAAC,UAAU,EAAE,MAAM,CAAC;CACrB,CAAC,CAAC;AAEH,sIAAsI;AACtI,MAAM,qBAAqB,GAAgC,IAAI,GAAG,CAAC;IACjE,CAAC,WAAW,EAAE,KAAK,CAAC;IACpB,CAAC,YAAY,EAAE,MAAM,CAAC;IACtB,CAAC,YAAY,EAAE,MAAM,CAAC;IACtB,CAAC,WAAW,EAAE,KAAK,CAAC;IACpB,CAAC,aAAa,EAAE,OAAO,CAAC;IACxB,CAAC,cAAc,EAAE,QAAQ,CAAC;IAC1B,CAAC,eAAe,EAAE,SAAS,CAAC;IAC5B,CAAC,eAAe,EAAE,SAAS,CAAC;IAC5B,CAAC,aAAa,EAAE,OAAO,CAAC;CACzB,CAAC,CAAC;AAsCH,MAAM,cAAc,GAAkB,EAAE,SAAS,EAAE,IAAI,EAAE,YAAY,EAAE,gBAAgB,EAAE,CAAC;AAC1F,MAAM,eAAe,GAAkB,EAAE,SAAS,EAAE,IAAI,EAAE,YAAY,EAAE,iBAAiB,EAAE,CAAC;AAE5F,mFAAmF;AACnF,MAAM,iBAAiB,GAAG,CAAC,+BAA+B,EAAE,kCAAkC,CAAC,CAAC;AAEhG,wFAAwF;AACxF,SAAS,cAAc,CAAC,IAAY;IAClC,IAAI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*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* Files in one Go package share a namespace completely: an unqualified name in
|
|
7
|
-
* one file resolves to a declaration in another that never mentions it. So the
|
|
8
|
-
* resolver's first scope is not the file but the package, which is the opposite
|
|
9
|
-
* of Java and TypeScript, where a file must import what it uses.
|
|
10
|
-
*
|
|
11
|
-
* Identity is the easy half. A package's import path is a declared name that
|
|
12
|
-
* other code writes verbatim, so `qsp = importPath::Symbol` needs none of the
|
|
13
|
-
* anchor inference TypeScript needs (DEC-047) or the source-set disambiguation
|
|
14
|
-
* Java needs. Go states it.
|
|
15
|
-
*
|
|
16
|
-
* ## What is deliberately not claimed
|
|
17
|
-
*
|
|
18
|
-
* **Interface satisfaction.** Go's is structural: a type implements an interface
|
|
19
|
-
* by having the right methods, and nothing in the source says so. Computing it
|
|
20
|
-
* needs full method-set comparison, which is R3 evidence, and guessing it from
|
|
21
|
-
* name similarity would be exactly the kind of edge that corrupts every layer
|
|
22
|
-
* above. `IMPLEMENTS` is therefore never emitted, and `capabilities()` says so.
|
|
23
|
-
* Embedding *is* explicit and becomes `INHERITS`.
|
|
24
|
-
*
|
|
25
|
-
* `:=` with anything but a composite literal, dot imports, and any receiver that
|
|
26
|
-
* is not a written name all go to the ledger with their reason.
|
|
2
|
+
* Go files to Canonical IR. Package, not file, is the resolver's scope (files
|
|
3
|
+
* share a namespace completely). Import path is declared, so `qsp` needs no
|
|
4
|
+
* anchor inference (DEC-047). `IMPLEMENTS` never emitted — structural in Go.
|
|
27
5
|
*/
|
|
28
6
|
import { type IdentityScope, type IREdge, type IRNode, type ResolutionLevel, type UnresolvedRef } from "@descryy/ir";
|
|
29
7
|
import type { GoFile } from "./parse.ts";
|
package/dist/extract.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract.d.ts","sourceRoot":"","sources":["../src/extract.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"extract.d.ts","sourceRoot":"","sources":["../src/extract.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAOL,KAAK,aAAa,EAClB,KAAK,MAAM,EACX,KAAK,MAAM,EACX,KAAK,eAAe,EACpB,KAAK,aAAa,EACnB,MAAM,aAAa,CAAC;AAGrB,OAAO,KAAK,EAAE,MAAM,EAA6C,MAAM,YAAY,CAAC;AAGpF,eAAO,MAAM,QAAQ,OAAO,CAAC;AAI7B,QAAA,MAAM,OAAO;;;;;;;;CAqBH,CAAC;AAEX,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAC9B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAClC,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;CACnC;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,UAAU,EAAE,SAAS,aAAa,EAAE,CAAC;CAC/C;AAgCD,wBAAgB,OAAO,CAAC,KAAK,EAAE,YAAY,GAAG,UAAU,CA4yBvD;AAED,OAAO,EAAE,OAAO,EAAE,CAAC"}
|