@opensip-cli/graph-go 0.1.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.
Files changed (72) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +8 -0
  3. package/README.md +31 -0
  4. package/dist/__tests__/branch-coverage-2.test.d.ts +21 -0
  5. package/dist/__tests__/branch-coverage-2.test.d.ts.map +1 -0
  6. package/dist/__tests__/branch-coverage-2.test.js +187 -0
  7. package/dist/__tests__/branch-coverage-2.test.js.map +1 -0
  8. package/dist/__tests__/branch-coverage.test.d.ts +17 -0
  9. package/dist/__tests__/branch-coverage.test.d.ts.map +1 -0
  10. package/dist/__tests__/branch-coverage.test.js +136 -0
  11. package/dist/__tests__/branch-coverage.test.js.map +1 -0
  12. package/dist/__tests__/cache-key.test.d.ts +5 -0
  13. package/dist/__tests__/cache-key.test.d.ts.map +1 -0
  14. package/dist/__tests__/cache-key.test.js +45 -0
  15. package/dist/__tests__/cache-key.test.js.map +1 -0
  16. package/dist/__tests__/depends-on-emission.test.d.ts +13 -0
  17. package/dist/__tests__/depends-on-emission.test.d.ts.map +1 -0
  18. package/dist/__tests__/depends-on-emission.test.js +215 -0
  19. package/dist/__tests__/depends-on-emission.test.js.map +1 -0
  20. package/dist/__tests__/discover.test.d.ts +5 -0
  21. package/dist/__tests__/discover.test.d.ts.map +1 -0
  22. package/dist/__tests__/discover.test.js +59 -0
  23. package/dist/__tests__/discover.test.js.map +1 -0
  24. package/dist/__tests__/parse.test.d.ts +5 -0
  25. package/dist/__tests__/parse.test.d.ts.map +1 -0
  26. package/dist/__tests__/parse.test.js +59 -0
  27. package/dist/__tests__/parse.test.js.map +1 -0
  28. package/dist/__tests__/resolve.test.d.ts +18 -0
  29. package/dist/__tests__/resolve.test.d.ts.map +1 -0
  30. package/dist/__tests__/resolve.test.js +205 -0
  31. package/dist/__tests__/resolve.test.js.map +1 -0
  32. package/dist/__tests__/walk.test.d.ts +10 -0
  33. package/dist/__tests__/walk.test.d.ts.map +1 -0
  34. package/dist/__tests__/walk.test.js +163 -0
  35. package/dist/__tests__/walk.test.js.map +1 -0
  36. package/dist/body-digest.d.ts +20 -0
  37. package/dist/body-digest.d.ts.map +1 -0
  38. package/dist/body-digest.js +139 -0
  39. package/dist/body-digest.js.map +1 -0
  40. package/dist/cache-key.d.ts +17 -0
  41. package/dist/cache-key.d.ts.map +1 -0
  42. package/dist/cache-key.js +18 -0
  43. package/dist/cache-key.js.map +1 -0
  44. package/dist/discover.d.ts +24 -0
  45. package/dist/discover.d.ts.map +1 -0
  46. package/dist/discover.js +33 -0
  47. package/dist/discover.js.map +1 -0
  48. package/dist/index.d.ts +43 -0
  49. package/dist/index.d.ts.map +1 -0
  50. package/dist/index.js +46 -0
  51. package/dist/index.js.map +1 -0
  52. package/dist/parse.d.ts +17 -0
  53. package/dist/parse.d.ts.map +1 -0
  54. package/dist/parse.js +14 -0
  55. package/dist/parse.js.map +1 -0
  56. package/dist/resolve.d.ts +32 -0
  57. package/dist/resolve.d.ts.map +1 -0
  58. package/dist/resolve.js +294 -0
  59. package/dist/resolve.js.map +1 -0
  60. package/dist/rule-hints.d.ts +16 -0
  61. package/dist/rule-hints.d.ts.map +1 -0
  62. package/dist/rule-hints.js +62 -0
  63. package/dist/rule-hints.js.map +1 -0
  64. package/dist/walk-metadata.d.ts +22 -0
  65. package/dist/walk-metadata.d.ts.map +1 -0
  66. package/dist/walk-metadata.js +96 -0
  67. package/dist/walk-metadata.js.map +1 -0
  68. package/dist/walk.d.ts +47 -0
  69. package/dist/walk.d.ts.map +1 -0
  70. package/dist/walk.js +278 -0
  71. package/dist/walk.js.map +1 -0
  72. package/package.json +55 -0
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,8 @@
1
+ OpenSIP CLI
2
+ Copyright 2026 opensip-ai
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
5
+ this software except in compliance with the License. A copy of the License is
6
+ included in the LICENSE file and is also available at:
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
package/README.md ADDED
@@ -0,0 +1,31 @@
1
+ <!-- Generated by scripts/build-package-readmes.mjs — do not edit by hand.
2
+ Change the package's "description" (or the generator template) and run
3
+ `pnpm docs:readmes`. CI enforces sync via `pnpm docs:readmes:check`. -->
4
+
5
+ # @opensip-cli/graph-go
6
+
7
+ > Go language adapter for the opensip graph engine
8
+
9
+ This is a **graph language adapter**. Install it alongside the CLI to add language support to `opensip graph`.
10
+
11
+ Part of [**opensip-cli**](https://github.com/opensip-ai/opensip-cli) — an open-source codebase-analysis toolkit: fitness checks (`fit`), static call-graph analysis (`graph`), and simulation (`sim`).
12
+
13
+ ## Install
14
+
15
+ Most users install the CLI, which bundles the first-party tools:
16
+
17
+ ```bash
18
+ curl -fsSL https://opensip.ai/cli/install.sh | bash
19
+ ```
20
+
21
+ This package is published for the CLI and advanced plugin authors; most users should not install `@opensip-cli/graph-go` directly.
22
+
23
+ ## Documentation
24
+
25
+ - 📚 Project docs: https://opensip.ai/docs/opensip-cli/
26
+ - 🧭 Package catalog (what every package does): https://github.com/opensip-ai/opensip-cli/blob/v0.1.0/docs/public/70-reference/02-package-catalog.md
27
+ - 📦 Source: https://github.com/opensip-ai/opensip-cli/tree/v0.1.0/packages/graph/graph-go
28
+
29
+ ## License
30
+
31
+ Apache-2.0 © opensip-ai
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Second round of targeted branch-coverage tests for graph-go.
3
+ *
4
+ * These hit branch directions not exercised by the existing suites:
5
+ * - walk-metadata.ts collectParamEntries — a `(comment)` named child
6
+ * inside a function's parameter_list (the `!== parameter_declaration
7
+ * && !== variadic_parameter_declaration` continue branch).
8
+ * - walk-metadata.ts extractReceiverType — a `(comment)` named child
9
+ * inside a method's receiver parameter_list (the `!==
10
+ * parameter_declaration` continue branch).
11
+ * - walk.ts pushImportSpec / unquoteGoStringLiteral — an import whose
12
+ * `path` is a raw_string_literal (backtick) rather than an
13
+ * interpreted string: `unquoteGoStringLiteral` returns null, so the
14
+ * `specifier === null` early-return branch fires and no dependency
15
+ * site is emitted for it.
16
+ * - resolve.ts resolveCallSites — a 'creation' CallSiteRecord whose
17
+ * `childHash` is undefined: the `r.childHash === undefined` guard
18
+ * `continue`s before emitting a creation edge.
19
+ */
20
+ export {};
21
+ //# sourceMappingURL=branch-coverage-2.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"branch-coverage-2.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/branch-coverage-2.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG"}
@@ -0,0 +1,187 @@
1
+ /**
2
+ * Second round of targeted branch-coverage tests for graph-go.
3
+ *
4
+ * These hit branch directions not exercised by the existing suites:
5
+ * - walk-metadata.ts collectParamEntries — a `(comment)` named child
6
+ * inside a function's parameter_list (the `!== parameter_declaration
7
+ * && !== variadic_parameter_declaration` continue branch).
8
+ * - walk-metadata.ts extractReceiverType — a `(comment)` named child
9
+ * inside a method's receiver parameter_list (the `!==
10
+ * parameter_declaration` continue branch).
11
+ * - walk.ts pushImportSpec / unquoteGoStringLiteral — an import whose
12
+ * `path` is a raw_string_literal (backtick) rather than an
13
+ * interpreted string: `unquoteGoStringLiteral` returns null, so the
14
+ * `specifier === null` early-return branch fires and no dependency
15
+ * site is emitted for it.
16
+ * - resolve.ts resolveCallSites — a 'creation' CallSiteRecord whose
17
+ * `childHash` is undefined: the `r.childHash === undefined` guard
18
+ * `continue`s before emitting a creation edge.
19
+ */
20
+ import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';
21
+ import { tmpdir } from 'node:os';
22
+ import { join } from 'node:path';
23
+ import { afterEach, beforeEach, describe, expect, it } from 'vitest';
24
+ import { goGraphAdapter } from '../index.js';
25
+ let dir;
26
+ beforeEach(() => {
27
+ dir = mkdtempSync(join(tmpdir(), 'graph-go-branch-cov2-'));
28
+ });
29
+ afterEach(() => {
30
+ rmSync(dir, { recursive: true, force: true });
31
+ });
32
+ function discoverAndParse() {
33
+ const discovery = goGraphAdapter.discoverFiles({ cwd: dir });
34
+ const parsed = goGraphAdapter.parseProject({
35
+ projectDirAbs: discovery.projectDirAbs,
36
+ files: discovery.files,
37
+ compilerOptions: discovery.compilerOptions,
38
+ resolutionMode: 'exact',
39
+ });
40
+ return {
41
+ projectDirAbs: discovery.projectDirAbs,
42
+ files: discovery.files,
43
+ project: parsed.project,
44
+ };
45
+ }
46
+ function walk() {
47
+ const { projectDirAbs, files, project } = discoverAndParse();
48
+ return goGraphAdapter.walkProject({ project, projectDirAbs, files });
49
+ }
50
+ describe('graph-go branch coverage (round 2)', () => {
51
+ it('skips a leading comment node inside a function parameter list', () => {
52
+ // The `(comment)` is a named child of the parameter_list, so
53
+ // collectParamEntries iterates it and must skip it (it is neither a
54
+ // parameter_declaration nor a variadic_parameter_declaration) before
55
+ // reaching the real `a int` declaration.
56
+ writeFileSync(join(dir, 'main.go'), `package main\nfunc f(/* leading */ a int, b string) {}\n`, 'utf8');
57
+ const out = walk();
58
+ const params = out.occurrences.f?.[0]?.params;
59
+ expect(params?.map((p) => p.name)).toEqual(['a', 'b']);
60
+ });
61
+ it('skips a leading comment node inside a method receiver list', () => {
62
+ // The `(comment)` precedes the parameter_declaration in the receiver
63
+ // parameter_list, exercising extractReceiverType's skip branch.
64
+ writeFileSync(join(dir, 'main.go'), `package main\ntype Foo struct{}\nfunc (/* recv */ f Foo) bar() int { return 1 }\n`, 'utf8');
65
+ const out = walk();
66
+ const bar = out.occurrences.bar?.[0];
67
+ expect(bar?.kind).toBe('method');
68
+ expect(bar?.enclosingClass).toBe('Foo');
69
+ });
70
+ it('ignores an import whose path is a raw string literal (backtick)', () => {
71
+ // A backtick-quoted import path is not a valid interpreted string,
72
+ // so unquoteGoStringLiteral returns null and pushImportSpec bails out
73
+ // via the `specifier === null` branch — no dependency site emitted.
74
+ writeFileSync(join(dir, 'main.go'), 'package main\nimport `fmt`\nfunc main() {}\n', 'utf8');
75
+ const out = walk();
76
+ // The malformed raw-string import yields zero dependency sites.
77
+ expect(out.dependencySites).toEqual([]);
78
+ // The walker still produces the module-init for the file.
79
+ const moduleInits = Object.keys(out.occurrences).filter((n) => n.startsWith('<module-init:'));
80
+ expect(moduleInits.length).toBe(1);
81
+ });
82
+ it('skips a creation call-site record whose childHash is undefined', () => {
83
+ // The walker never emits a creation record without a childHash, but
84
+ // resolveCallSites defends against it: the `childHash === undefined`
85
+ // guard `continue`s before pushing a creation edge. Drive that guard
86
+ // by feeding a synthetic creation record.
87
+ writeFileSync(join(dir, 'main.go'), `package main\nfunc maker() func() {\n inc := func() {}\n return inc\n}\n`, 'utf8');
88
+ const { projectDirAbs, files, project } = discoverAndParse();
89
+ const walked = goGraphAdapter.walkProject({ project, projectDirAbs, files });
90
+ // Find a real creation record produced by the walker so we have a
91
+ // valid nodeRef/sourceFileRef, then strip its childHash.
92
+ const realCreation = walked.callSites.find((c) => c.kind === 'creation');
93
+ expect(realCreation).toBeDefined();
94
+ const danglingCreation = {
95
+ nodeRef: realCreation.nodeRef,
96
+ sourceFileRef: realCreation.sourceFileRef,
97
+ ownerHash: realCreation.ownerHash,
98
+ kind: 'creation',
99
+ // childHash deliberately omitted (undefined).
100
+ };
101
+ const catalog = {
102
+ version: '3.0',
103
+ tool: 'graph',
104
+ language: 'go',
105
+ builtAt: '2026-05-27T00:00:00.000Z',
106
+ cacheKey: 'test',
107
+ functions: walked.occurrences,
108
+ };
109
+ const resolved = goGraphAdapter.resolveCallSites({
110
+ project,
111
+ catalog,
112
+ callSites: [danglingCreation],
113
+ projectDirAbs,
114
+ resolutionMode: 'exact',
115
+ });
116
+ // The dangling creation record contributes no edges and no stats.
117
+ let edgeCount = 0;
118
+ for (const edges of resolved.edgesByOwner.values())
119
+ edgeCount += edges.length;
120
+ expect(edgeCount).toBe(0);
121
+ expect(resolved.stats.totalCallSites).toBe(0);
122
+ });
123
+ it('tolerates an undefined catalog bucket and a non-.go module-init filePath during dependency resolution', () => {
124
+ // resolveDependencies defends against two shapes a well-formed walker
125
+ // never produces but the contract permits:
126
+ // - an `undefined` value in catalog.functions (the `!occs` continue
127
+ // in the module-init index build), and
128
+ // - a module-init occurrence whose filePath does not end in `.go`
129
+ // (the `!filePath.endsWith('.go')` continue in
130
+ // collectGoPackageMembers).
131
+ // Drive both by handing resolveCallSites a synthetic catalog and a
132
+ // synthetic dependency site whose specifier equals the module path.
133
+ writeFileSync(join(dir, 'go.mod'), `module github.com/example/proj\n`, 'utf8');
134
+ writeFileSync(join(dir, 'main.go'), `package main\nimport "github.com/example/proj"\nfunc main() {}\n`, 'utf8');
135
+ const { projectDirAbs, files, project } = discoverAndParse();
136
+ const walked = goGraphAdapter.walkProject({ project, projectDirAbs, files });
137
+ const realModuleInit = Object.values(walked.occurrences)
138
+ .flat()
139
+ .find((o) => o.kind === 'module-init');
140
+ expect(realModuleInit).toBeDefined();
141
+ // A second module-init occurrence whose filePath is NOT a .go file —
142
+ // it must be skipped when enumerating package members.
143
+ const nonGoModuleInit = {
144
+ ...realModuleInit,
145
+ filePath: 'README',
146
+ bodyHash: 'non-go-hash',
147
+ };
148
+ const syntheticFunctions = {
149
+ [realModuleInit.simpleName]: [realModuleInit],
150
+ '<module-init:README>': [nonGoModuleInit],
151
+ // An undefined bucket — `Object.values` yields it, exercising the
152
+ // `!occs` skip in the module-init index build.
153
+ '<empty>': undefined,
154
+ };
155
+ const catalog = {
156
+ version: '3.0',
157
+ tool: 'graph',
158
+ language: 'go',
159
+ builtAt: '2026-05-27T00:00:00.000Z',
160
+ cacheKey: 'test',
161
+ functions: syntheticFunctions,
162
+ };
163
+ const depSite = {
164
+ nodeRef: null,
165
+ sourceFileRef: null,
166
+ ownerHash: realModuleInit.bodyHash,
167
+ specifier: 'github.com/example/proj',
168
+ line: 2,
169
+ column: 0,
170
+ };
171
+ const resolved = goGraphAdapter.resolveCallSites({
172
+ project,
173
+ catalog,
174
+ callSites: [],
175
+ dependencySites: [depSite],
176
+ projectDirAbs,
177
+ resolutionMode: 'exact',
178
+ });
179
+ const deps = resolved.dependenciesByOwner?.get(realModuleInit.bodyHash);
180
+ expect(deps).toHaveLength(1);
181
+ // The bare-module import resolves to the package members at the
182
+ // project root — only the real .go module-init, never the README one.
183
+ expect(deps[0].to).toEqual([realModuleInit.bodyHash]);
184
+ expect(deps[0].to).not.toContain('non-go-hash');
185
+ });
186
+ });
187
+ //# sourceMappingURL=branch-coverage-2.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"branch-coverage-2.test.js","sourceRoot":"","sources":["../../src/__tests__/branch-coverage-2.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAErE,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAU7C,IAAI,GAAW,CAAC;AAEhB,UAAU,CAAC,GAAG,EAAE;IACd,GAAG,GAAG,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,uBAAuB,CAAC,CAAC,CAAC;AAC7D,CAAC,CAAC,CAAC;AAEH,SAAS,CAAC,GAAG,EAAE;IACb,MAAM,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAChD,CAAC,CAAC,CAAC;AAEH,SAAS,gBAAgB;IAKvB,MAAM,SAAS,GAAG,cAAc,CAAC,aAAa,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC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,MAAM;YAChB,SAAS,EAAE,kBAAkB;SAC9B,CAAC;QAEF,MAAM,OAAO,GAAyB;YACpC,OAAO,EAAE,IAAI;YACb,aAAa,EAAE,IAAI;YACnB,SAAS,EAAE,cAAe,CAAC,QAAQ;YACnC,SAAS,EAAE,yBAAyB;YACpC,IAAI,EAAE,CAAC;YACP,MAAM,EAAE,CAAC;SACV,CAAC;QAEF,MAAM,QAAQ,GAAG,cAAc,CAAC,gBAAgB,CAAC;YAC/C,OAAO;YACP,OAAO;YACP,SAAS,EAAE,EAAE;YACb,eAAe,EAAE,CAAC,OAAO,CAAC;YAC1B,aAAa;YACb,cAAc,EAAE,OAAO;SACxB,CAAC,CAAC;QAEH,MAAM,IAAI,GAAG,QAAQ,CAAC,mBAAmB,EAAE,GAAG,CAAC,cAAe,CAAC,QAAQ,CAAC,CAAC;QACzE,MAAM,CAAC,IAAI,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;QAC7B,gEAAgE;QAChE,sEAAsE;QACtE,MAAM,CAAC,IAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,cAAe,CAAC,QAAQ,CAAC,CAAC,CAAC;QACxD,MAAM,CAAC,IAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;IACnD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Targeted branch-coverage tests for graph-go.
3
+ *
4
+ * These tests hit branches not exercised by the main test files:
5
+ * - resolve.ts:194 — go.mod with blank lines and `//` comments before
6
+ * the `module` directive (covers both operands of the OR).
7
+ * - resolve.ts:221 — import path equals the module path exactly (bare
8
+ * module import, no trailing subdirectory).
9
+ * - walk.ts skipBlockComment loop-exit branch — an unterminated `/*`
10
+ * block comment that runs to EOF.
11
+ * - walk.ts grouped-import without parens (single `import` form) —
12
+ * exercises the `import_spec` (not `import_spec_list`) branch of
13
+ * collectFromImportDeclaration in a way the existing tests don't
14
+ * already drive in isolation.
15
+ */
16
+ export {};
17
+ //# sourceMappingURL=branch-coverage.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"branch-coverage.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/branch-coverage.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG"}
@@ -0,0 +1,136 @@
1
+ /**
2
+ * Targeted branch-coverage tests for graph-go.
3
+ *
4
+ * These tests hit branches not exercised by the main test files:
5
+ * - resolve.ts:194 — go.mod with blank lines and `//` comments before
6
+ * the `module` directive (covers both operands of the OR).
7
+ * - resolve.ts:221 — import path equals the module path exactly (bare
8
+ * module import, no trailing subdirectory).
9
+ * - walk.ts skipBlockComment loop-exit branch — an unterminated `/*`
10
+ * block comment that runs to EOF.
11
+ * - walk.ts grouped-import without parens (single `import` form) —
12
+ * exercises the `import_spec` (not `import_spec_list`) branch of
13
+ * collectFromImportDeclaration in a way the existing tests don't
14
+ * already drive in isolation.
15
+ */
16
+ import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';
17
+ import { tmpdir } from 'node:os';
18
+ import { join } from 'node:path';
19
+ import { afterEach, beforeEach, describe, expect, it } from 'vitest';
20
+ import { goGraphAdapter } from '../index.js';
21
+ let dir;
22
+ beforeEach(() => {
23
+ dir = mkdtempSync(join(tmpdir(), 'graph-go-branch-cov-'));
24
+ });
25
+ afterEach(() => {
26
+ rmSync(dir, { recursive: true, force: true });
27
+ });
28
+ function findModuleInit(catalog, filePath) {
29
+ for (const occs of Object.values(catalog.functions)) {
30
+ for (const o of occs) {
31
+ if (o.kind === 'module-init' && o.filePath === filePath)
32
+ return o;
33
+ }
34
+ }
35
+ return undefined;
36
+ }
37
+ function runAdapter() {
38
+ const discovery = goGraphAdapter.discoverFiles({ cwd: dir });
39
+ const parsed = goGraphAdapter.parseProject({
40
+ projectDirAbs: discovery.projectDirAbs,
41
+ files: discovery.files,
42
+ compilerOptions: discovery.compilerOptions,
43
+ resolutionMode: 'exact',
44
+ });
45
+ const walked = goGraphAdapter.walkProject({
46
+ project: parsed.project,
47
+ projectDirAbs: discovery.projectDirAbs,
48
+ files: discovery.files,
49
+ });
50
+ const catalog = {
51
+ version: '3.0',
52
+ tool: 'graph',
53
+ language: 'go',
54
+ builtAt: '2026-05-27T00:00:00.000Z',
55
+ cacheKey: 'test',
56
+ functions: walked.occurrences,
57
+ };
58
+ const resolved = goGraphAdapter.resolveCallSites({
59
+ project: parsed.project,
60
+ catalog,
61
+ callSites: walked.callSites,
62
+ dependencySites: walked.dependencySites,
63
+ projectDirAbs: discovery.projectDirAbs,
64
+ resolutionMode: 'exact',
65
+ });
66
+ return { catalog, dependenciesByOwner: resolved.dependenciesByOwner };
67
+ }
68
+ describe('graph-go branch coverage', () => {
69
+ it('readGoModulePath skips blank lines and // comments before the module directive', () => {
70
+ // Blank line + `//` comment line + the module directive. This drives
71
+ // both operands of the `length === 0 || startsWith('//')` short-circuit
72
+ // in readGoModulePath.
73
+ writeFileSync(join(dir, 'go.mod'), `\n// a leading comment\n\nmodule github.com/example/myproj\n\ngo 1.22\n`, 'utf8');
74
+ writeFileSync(join(dir, 'main.go'), `package main\n\nimport "github.com/example/myproj"\n\nfunc main() {}\n`, 'utf8');
75
+ const { catalog, dependenciesByOwner } = runAdapter();
76
+ const mainInit = findModuleInit(catalog, 'main.go');
77
+ expect(mainInit).toBeDefined();
78
+ // Resolution worked → the `module` line was found despite the comment
79
+ // and blank lines before it.
80
+ const deps = dependenciesByOwner.get(mainInit.bodyHash);
81
+ expect(deps).toHaveLength(1);
82
+ expect(deps[0].specifier).toBe('github.com/example/myproj');
83
+ });
84
+ it('readGoModulePath handles quoted module path (module "<path>")', () => {
85
+ // Exercises the `match[2]` branch of `match[2] ?? match[3] ?? null`
86
+ // in readGoModulePath (the quoted-form capture group).
87
+ writeFileSync(join(dir, 'go.mod'), `module "github.com/example/quoted"\n`, 'utf8');
88
+ writeFileSync(join(dir, 'main.go'), `package main\nimport "github.com/example/quoted"\nfunc main() {}\n`, 'utf8');
89
+ const { catalog, dependenciesByOwner } = runAdapter();
90
+ const mainInit = findModuleInit(catalog, 'main.go');
91
+ expect(mainInit).toBeDefined();
92
+ // The bare-module import should resolve to the package members at the
93
+ // project root — i.e. main.go's own module-init.
94
+ const deps = dependenciesByOwner?.get(mainInit.bodyHash);
95
+ expect(deps).toHaveLength(1);
96
+ expect(deps[0].to).toEqual([mainInit.bodyHash]);
97
+ });
98
+ it('resolves an import path that EQUALS the module path (bare module import)', () => {
99
+ // Covers the `specifier === modulePath` branch in resolveGoImportPath.
100
+ writeFileSync(join(dir, 'go.mod'), `module github.com/example/myproj\n`, 'utf8');
101
+ writeFileSync(join(dir, 'main.go'), `package main\n\nimport "github.com/example/myproj"\n\nfunc main() {}\n`, 'utf8');
102
+ const { catalog, dependenciesByOwner } = runAdapter();
103
+ const mainInit = findModuleInit(catalog, 'main.go');
104
+ expect(mainInit).toBeDefined();
105
+ const deps = dependenciesByOwner.get(mainInit.bodyHash);
106
+ expect(deps).toHaveLength(1);
107
+ expect(deps[0].specifier).toBe('github.com/example/myproj');
108
+ // The module path itself maps to package members at the project root.
109
+ expect(deps[0].to).toEqual([mainInit.bodyHash]);
110
+ });
111
+ it('stripGoComments tolerates an unterminated /* block comment (runs to EOF)', () => {
112
+ // The `/*` is never closed — skipBlockComment's while-loop exits via
113
+ // its condition becoming false (i >= text.length), exercising the
114
+ // loop-exit branch.
115
+ writeFileSync(join(dir, 'main.go'), `package main\nfunc unterminated() int { return 1 /* trailing comment that never closes`, 'utf8');
116
+ const discovery = goGraphAdapter.discoverFiles({ cwd: dir });
117
+ const parsed = goGraphAdapter.parseProject({
118
+ projectDirAbs: discovery.projectDirAbs,
119
+ files: discovery.files,
120
+ compilerOptions: discovery.compilerOptions,
121
+ resolutionMode: 'exact',
122
+ });
123
+ const walked = goGraphAdapter.walkProject({
124
+ project: parsed.project,
125
+ projectDirAbs: discovery.projectDirAbs,
126
+ files: discovery.files,
127
+ });
128
+ // The file is malformed but the walker must not throw — it should
129
+ // emit whatever it can. We just assert no exception and that the
130
+ // module-init was produced.
131
+ expect(walked.parseErrors).toEqual([]);
132
+ const moduleInits = Object.keys(walked.occurrences).filter((n) => n.startsWith('<module-init:'));
133
+ expect(moduleInits.length).toBe(1);
134
+ });
135
+ });
136
+ //# sourceMappingURL=branch-coverage.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"branch-coverage.test.js","sourceRoot":"","sources":["../../src/__tests__/branch-coverage.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAErE,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAI7C,IAAI,GAAW,CAAC;AAEhB,UAAU,CAAC,GAAG,EAAE;IACd,GAAG,GAAG,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,sBAAsB,CAAC,CAAC,CAAC;AAC5D,CAAC,CAAC,CAAC;AAEH,SAAS,CAAC,GAAG,EAAE;IACb,MAAM,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAChD,CAAC,CAAC,CAAC;AAEH,SAAS,cAAc,CAAC,OAAgB,EAAE,QAAgB;IACxD,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;QACpD,KAAK,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;YACrB,IAAI,CA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X,IAAI,CAAC,GAAG,EAAE,SAAS,CAAC,EACpB,wFAAwF,EACxF,MAAM,CACP,CAAC;QACF,MAAM,SAAS,GAAG,cAAc,CAAC,aAAa,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;QAC7D,MAAM,MAAM,GAAG,cAAc,CAAC,YAAY,CAAC;YACzC,aAAa,EAAE,SAAS,CAAC,aAAa;YACtC,KAAK,EAAE,SAAS,CAAC,KAAK;YACtB,eAAe,EAAE,SAAS,CAAC,eAAe;YAC1C,cAAc,EAAE,OAAO;SACxB,CAAC,CAAC;QACH,MAAM,MAAM,GAAG,cAAc,CAAC,WAAW,CAAC;YACxC,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,aAAa,EAAE,SAAS,CAAC,aAAa;YACtC,KAAK,EAAE,SAAS,CAAC,KAAK;SACvB,CAAC,CAAC;QACH,kEAAkE;QAClE,iEAAiE;QACjE,4BAA4B;QAC5B,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QACvC,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAC/D,CAAC,CAAC,UAAU,CAAC,eAAe,CAAC,CAC9B,CAAC;QACF,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACrC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Branch-coverage tests for graph-go/cache-key.ts.
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=cache-key.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache-key.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/cache-key.test.ts"],"names":[],"mappings":"AAAA;;GAEG"}