seam-code 0.3.0__py3-none-any.whl
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.
- seam/__init__.py +3 -0
- seam/_data/schema.sql +225 -0
- seam/_web/assets/index-BL_tqprR.js +216 -0
- seam/_web/assets/index-GTKUhVyD.css +1 -0
- seam/_web/index.html +13 -0
- seam/analysis/__init__.py +14 -0
- seam/analysis/affected.py +254 -0
- seam/analysis/builtins.py +966 -0
- seam/analysis/byte_budget.py +217 -0
- seam/analysis/changes.py +709 -0
- seam/analysis/cluster_naming.py +260 -0
- seam/analysis/clustering.py +216 -0
- seam/analysis/confidence.py +699 -0
- seam/analysis/embeddings.py +195 -0
- seam/analysis/flows.py +708 -0
- seam/analysis/impact.py +444 -0
- seam/analysis/imports.py +994 -0
- seam/analysis/imports_ext.py +780 -0
- seam/analysis/imports_resolve.py +176 -0
- seam/analysis/processes.py +453 -0
- seam/analysis/relevance.py +155 -0
- seam/analysis/rwr.py +129 -0
- seam/analysis/staleness.py +328 -0
- seam/analysis/steer.py +282 -0
- seam/analysis/synthesis.py +253 -0
- seam/analysis/synthesis_channels.py +433 -0
- seam/analysis/testpaths.py +103 -0
- seam/analysis/traversal.py +470 -0
- seam/cli/__init__.py +0 -0
- seam/cli/install.py +232 -0
- seam/cli/main.py +2602 -0
- seam/cli/output.py +137 -0
- seam/cli/read.py +244 -0
- seam/cli/serve.py +145 -0
- seam/config.py +551 -0
- seam/indexer/__init__.py +0 -0
- seam/indexer/cluster_index.py +425 -0
- seam/indexer/db.py +496 -0
- seam/indexer/embedding_index.py +183 -0
- seam/indexer/field_access.py +536 -0
- seam/indexer/field_access_c_cpp.py +643 -0
- seam/indexer/field_access_ext.py +708 -0
- seam/indexer/field_access_ext2.py +408 -0
- seam/indexer/field_access_go_rust.py +737 -0
- seam/indexer/field_access_php_swift.py +888 -0
- seam/indexer/field_access_ts.py +626 -0
- seam/indexer/graph.py +321 -0
- seam/indexer/graph_c.py +562 -0
- seam/indexer/graph_c_cpp.py +39 -0
- seam/indexer/graph_common.py +644 -0
- seam/indexer/graph_cpp.py +615 -0
- seam/indexer/graph_csharp.py +651 -0
- seam/indexer/graph_go.py +723 -0
- seam/indexer/graph_go_rust.py +39 -0
- seam/indexer/graph_java.py +689 -0
- seam/indexer/graph_java_csharp.py +38 -0
- seam/indexer/graph_php.py +914 -0
- seam/indexer/graph_python.py +628 -0
- seam/indexer/graph_ruby.py +748 -0
- seam/indexer/graph_rust.py +653 -0
- seam/indexer/graph_scope_infer.py +902 -0
- seam/indexer/graph_scope_infer_ext.py +723 -0
- seam/indexer/graph_scope_infer_ext2.py +992 -0
- seam/indexer/graph_swift.py +1014 -0
- seam/indexer/graph_swift_infer.py +515 -0
- seam/indexer/graph_typescript.py +663 -0
- seam/indexer/migrations.py +816 -0
- seam/indexer/parser.py +204 -0
- seam/indexer/pipeline.py +197 -0
- seam/indexer/signatures.py +634 -0
- seam/indexer/signatures_ext.py +780 -0
- seam/indexer/sync.py +287 -0
- seam/indexer/synthesis_index.py +291 -0
- seam/indexer/tokenize.py +79 -0
- seam/installer/__init__.py +67 -0
- seam/installer/claude.py +97 -0
- seam/installer/codex.py +94 -0
- seam/installer/core.py +127 -0
- seam/installer/cursor.py +61 -0
- seam/installer/guide.py +110 -0
- seam/installer/jsonfile.py +85 -0
- seam/installer/markdownfile.py +146 -0
- seam/installer/tomlfile.py +72 -0
- seam/query/__init__.py +0 -0
- seam/query/clusters.py +206 -0
- seam/query/comments.py +217 -0
- seam/query/context.py +293 -0
- seam/query/engine.py +940 -0
- seam/query/fts.py +328 -0
- seam/query/names.py +470 -0
- seam/query/pack.py +433 -0
- seam/query/semantic.py +339 -0
- seam/query/structure.py +727 -0
- seam/server/__init__.py +0 -0
- seam/server/graph_api.py +437 -0
- seam/server/handler_common.py +323 -0
- seam/server/impact_handler.py +615 -0
- seam/server/mcp.py +556 -0
- seam/server/tools.py +697 -0
- seam/server/trace_handler.py +184 -0
- seam/server/web.py +922 -0
- seam/watcher/__init__.py +0 -0
- seam/watcher/__main__.py +56 -0
- seam/watcher/daemon.py +237 -0
- seam_code-0.3.0.dist-info/METADATA +318 -0
- seam_code-0.3.0.dist-info/RECORD +109 -0
- seam_code-0.3.0.dist-info/WHEEL +4 -0
- seam_code-0.3.0.dist-info/entry_points.txt +2 -0
- seam_code-0.3.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,966 @@
|
|
|
1
|
+
"""Curated builtin/stdlib vocabulary for Phase 5 confidence resolution.
|
|
2
|
+
|
|
3
|
+
Leaf module — imports ONLY stdlib. No DB, no seam.query, no seam.server.
|
|
4
|
+
|
|
5
|
+
Provides:
|
|
6
|
+
is_builtin(name, language) -> bool
|
|
7
|
+
Returns True if `name` is a known builtin for `language`.
|
|
8
|
+
Pure function: no I/O, no side effects, never raises.
|
|
9
|
+
|
|
10
|
+
Design constraints:
|
|
11
|
+
- Conservative sets: common builtins/globals/prelude only — NOT exhaustive stdlib.
|
|
12
|
+
An over-broad set risks shadowing real repo symbols.
|
|
13
|
+
- The repo-declares-it guard in confidence.py (count==0 check) is the safety net.
|
|
14
|
+
A tight list here is the first line of defense.
|
|
15
|
+
- Language-scoped: a name that is a Go builtin doesn't suppress a Python edge.
|
|
16
|
+
Each language's frozenset is fully independent.
|
|
17
|
+
|
|
18
|
+
Called only from confidence.py when name_counts.get(target) == 0.
|
|
19
|
+
The builtin check MUST NOT be called when count > 0 — that structural guarantee
|
|
20
|
+
is enforced by confidence.py's resolve_edge() control flow (user story 5).
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
# ── Python built-in functions and types ──────────────────────────────────────
|
|
24
|
+
# Source: https://docs.python.org/3/library/functions.html (conservative subset)
|
|
25
|
+
_PYTHON_BUILTINS: frozenset[str] = frozenset(
|
|
26
|
+
{
|
|
27
|
+
# Built-in functions
|
|
28
|
+
"abs",
|
|
29
|
+
"aiter",
|
|
30
|
+
"all",
|
|
31
|
+
"anext",
|
|
32
|
+
"any",
|
|
33
|
+
"ascii",
|
|
34
|
+
"bin",
|
|
35
|
+
"bool",
|
|
36
|
+
"breakpoint",
|
|
37
|
+
"bytearray",
|
|
38
|
+
"bytes",
|
|
39
|
+
"callable",
|
|
40
|
+
"chr",
|
|
41
|
+
"classmethod",
|
|
42
|
+
"compile",
|
|
43
|
+
"complex",
|
|
44
|
+
"delattr",
|
|
45
|
+
"dict",
|
|
46
|
+
"dir",
|
|
47
|
+
"divmod",
|
|
48
|
+
"enumerate",
|
|
49
|
+
"eval",
|
|
50
|
+
"exec",
|
|
51
|
+
"filter",
|
|
52
|
+
"float",
|
|
53
|
+
"format",
|
|
54
|
+
"frozenset",
|
|
55
|
+
"getattr",
|
|
56
|
+
"globals",
|
|
57
|
+
"hasattr",
|
|
58
|
+
"hash",
|
|
59
|
+
"help",
|
|
60
|
+
"hex",
|
|
61
|
+
"id",
|
|
62
|
+
"input",
|
|
63
|
+
"int",
|
|
64
|
+
"isinstance",
|
|
65
|
+
"issubclass",
|
|
66
|
+
"iter",
|
|
67
|
+
"len",
|
|
68
|
+
"list",
|
|
69
|
+
"locals",
|
|
70
|
+
"map",
|
|
71
|
+
"max",
|
|
72
|
+
"memoryview",
|
|
73
|
+
"min",
|
|
74
|
+
"next",
|
|
75
|
+
"object",
|
|
76
|
+
"oct",
|
|
77
|
+
"open",
|
|
78
|
+
"ord",
|
|
79
|
+
"pow",
|
|
80
|
+
"print",
|
|
81
|
+
"property",
|
|
82
|
+
"range",
|
|
83
|
+
"repr",
|
|
84
|
+
"reversed",
|
|
85
|
+
"round",
|
|
86
|
+
"set",
|
|
87
|
+
"setattr",
|
|
88
|
+
"slice",
|
|
89
|
+
"sorted",
|
|
90
|
+
"staticmethod",
|
|
91
|
+
"str",
|
|
92
|
+
"sum",
|
|
93
|
+
"super",
|
|
94
|
+
"tuple",
|
|
95
|
+
"type",
|
|
96
|
+
"vars",
|
|
97
|
+
"zip",
|
|
98
|
+
# Built-in constants
|
|
99
|
+
"True",
|
|
100
|
+
"False",
|
|
101
|
+
"None",
|
|
102
|
+
"Ellipsis",
|
|
103
|
+
"NotImplemented",
|
|
104
|
+
# Built-in exceptions (commonly used as call targets)
|
|
105
|
+
"Exception",
|
|
106
|
+
"ValueError",
|
|
107
|
+
"TypeError",
|
|
108
|
+
"KeyError",
|
|
109
|
+
"IndexError",
|
|
110
|
+
"AttributeError",
|
|
111
|
+
"RuntimeError",
|
|
112
|
+
"OSError",
|
|
113
|
+
"IOError",
|
|
114
|
+
"StopIteration",
|
|
115
|
+
"GeneratorExit",
|
|
116
|
+
"SystemExit",
|
|
117
|
+
"KeyboardInterrupt",
|
|
118
|
+
"NotImplementedError",
|
|
119
|
+
"OverflowError",
|
|
120
|
+
"ZeroDivisionError",
|
|
121
|
+
"FileNotFoundError",
|
|
122
|
+
"PermissionError",
|
|
123
|
+
"TimeoutError",
|
|
124
|
+
"AssertionError",
|
|
125
|
+
"ImportError",
|
|
126
|
+
"ModuleNotFoundError",
|
|
127
|
+
"MemoryError",
|
|
128
|
+
"RecursionError",
|
|
129
|
+
"UnicodeError",
|
|
130
|
+
}
|
|
131
|
+
)
|
|
132
|
+
|
|
133
|
+
# ── TypeScript / JavaScript globals and built-in objects ─────────────────────
|
|
134
|
+
# Conservative: well-known globals present in every JS/TS runtime environment.
|
|
135
|
+
# Deliberately excludes browser-only (fetch, document, window) — too likely to
|
|
136
|
+
# collide with user-defined wrappers.
|
|
137
|
+
_TYPESCRIPT_BUILTINS: frozenset[str] = frozenset(
|
|
138
|
+
{
|
|
139
|
+
# Core JS globals
|
|
140
|
+
"undefined",
|
|
141
|
+
"null",
|
|
142
|
+
"NaN",
|
|
143
|
+
"Infinity",
|
|
144
|
+
# Functions
|
|
145
|
+
"parseInt",
|
|
146
|
+
"parseFloat",
|
|
147
|
+
"isNaN",
|
|
148
|
+
"isFinite",
|
|
149
|
+
"encodeURI",
|
|
150
|
+
"decodeURI",
|
|
151
|
+
"encodeURIComponent",
|
|
152
|
+
"decodeURIComponent",
|
|
153
|
+
"eval",
|
|
154
|
+
# Built-in constructors / objects
|
|
155
|
+
"Object",
|
|
156
|
+
"Array",
|
|
157
|
+
"Function",
|
|
158
|
+
"Boolean",
|
|
159
|
+
"Number",
|
|
160
|
+
"String",
|
|
161
|
+
"Symbol",
|
|
162
|
+
"BigInt",
|
|
163
|
+
"RegExp",
|
|
164
|
+
"Date",
|
|
165
|
+
"Error",
|
|
166
|
+
"Map",
|
|
167
|
+
"Set",
|
|
168
|
+
"WeakMap",
|
|
169
|
+
"WeakSet",
|
|
170
|
+
"WeakRef",
|
|
171
|
+
"Promise",
|
|
172
|
+
"Proxy",
|
|
173
|
+
"Reflect",
|
|
174
|
+
"ArrayBuffer",
|
|
175
|
+
"DataView",
|
|
176
|
+
"Int8Array",
|
|
177
|
+
"Uint8Array",
|
|
178
|
+
"Int16Array",
|
|
179
|
+
"Uint16Array",
|
|
180
|
+
"Int32Array",
|
|
181
|
+
"Uint32Array",
|
|
182
|
+
"Float32Array",
|
|
183
|
+
"Float64Array",
|
|
184
|
+
"Uint8ClampedArray",
|
|
185
|
+
"BigInt64Array",
|
|
186
|
+
"BigUint64Array",
|
|
187
|
+
"SharedArrayBuffer",
|
|
188
|
+
"Atomics",
|
|
189
|
+
"JSON",
|
|
190
|
+
"Math",
|
|
191
|
+
"console",
|
|
192
|
+
# Timers (Node.js + browser)
|
|
193
|
+
"setTimeout",
|
|
194
|
+
"setInterval",
|
|
195
|
+
"clearTimeout",
|
|
196
|
+
"clearInterval",
|
|
197
|
+
"setImmediate",
|
|
198
|
+
"clearImmediate",
|
|
199
|
+
# Node.js process/global
|
|
200
|
+
"process",
|
|
201
|
+
"Buffer",
|
|
202
|
+
"global",
|
|
203
|
+
"globalThis",
|
|
204
|
+
"require",
|
|
205
|
+
"module",
|
|
206
|
+
"exports",
|
|
207
|
+
"__dirname",
|
|
208
|
+
"__filename",
|
|
209
|
+
# Generator/iterator
|
|
210
|
+
"Iterator",
|
|
211
|
+
"Generator",
|
|
212
|
+
}
|
|
213
|
+
)
|
|
214
|
+
|
|
215
|
+
# JavaScript shares the same builtin vocabulary as TypeScript for our purposes.
|
|
216
|
+
_JAVASCRIPT_BUILTINS: frozenset[str] = _TYPESCRIPT_BUILTINS
|
|
217
|
+
|
|
218
|
+
# ── Go predeclared identifiers ────────────────────────────────────────────────
|
|
219
|
+
# Source: https://go.dev/ref/spec#Predeclared_identifiers
|
|
220
|
+
_GO_BUILTINS: frozenset[str] = frozenset(
|
|
221
|
+
{
|
|
222
|
+
# Built-in functions
|
|
223
|
+
"append",
|
|
224
|
+
"cap",
|
|
225
|
+
"clear",
|
|
226
|
+
"close",
|
|
227
|
+
"copy",
|
|
228
|
+
"delete",
|
|
229
|
+
"imag",
|
|
230
|
+
"len",
|
|
231
|
+
"make",
|
|
232
|
+
"max",
|
|
233
|
+
"min",
|
|
234
|
+
"new",
|
|
235
|
+
"panic",
|
|
236
|
+
"print",
|
|
237
|
+
"println",
|
|
238
|
+
"real",
|
|
239
|
+
"recover",
|
|
240
|
+
# Predeclared types
|
|
241
|
+
"bool",
|
|
242
|
+
"byte",
|
|
243
|
+
"comparable",
|
|
244
|
+
"complex64",
|
|
245
|
+
"complex128",
|
|
246
|
+
"error",
|
|
247
|
+
"float32",
|
|
248
|
+
"float64",
|
|
249
|
+
"int",
|
|
250
|
+
"int8",
|
|
251
|
+
"int16",
|
|
252
|
+
"int32",
|
|
253
|
+
"int64",
|
|
254
|
+
"rune",
|
|
255
|
+
"string",
|
|
256
|
+
"uint",
|
|
257
|
+
"uint8",
|
|
258
|
+
"uint16",
|
|
259
|
+
"uint32",
|
|
260
|
+
"uint64",
|
|
261
|
+
"uintptr",
|
|
262
|
+
"any",
|
|
263
|
+
# Predeclared constants
|
|
264
|
+
"true",
|
|
265
|
+
"false",
|
|
266
|
+
"iota",
|
|
267
|
+
# Predeclared zero value
|
|
268
|
+
"nil",
|
|
269
|
+
# Blank identifier
|
|
270
|
+
"_",
|
|
271
|
+
}
|
|
272
|
+
)
|
|
273
|
+
|
|
274
|
+
# ── Rust prelude (edition 2021) ───────────────────────────────────────────────
|
|
275
|
+
# Source: https://doc.rust-lang.org/std/prelude/index.html (2021 edition)
|
|
276
|
+
# The prelude is automatically imported into every Rust module.
|
|
277
|
+
# Also includes common macros used as call targets.
|
|
278
|
+
_RUST_BUILTINS: frozenset[str] = frozenset(
|
|
279
|
+
{
|
|
280
|
+
# Prelude types
|
|
281
|
+
"Option",
|
|
282
|
+
"Result",
|
|
283
|
+
"String",
|
|
284
|
+
"str",
|
|
285
|
+
"Vec",
|
|
286
|
+
"Box",
|
|
287
|
+
"Copy",
|
|
288
|
+
"Clone",
|
|
289
|
+
"Send",
|
|
290
|
+
"Sync",
|
|
291
|
+
"Sized",
|
|
292
|
+
"Unpin",
|
|
293
|
+
"Drop",
|
|
294
|
+
"Fn",
|
|
295
|
+
"FnMut",
|
|
296
|
+
"FnOnce",
|
|
297
|
+
"Iterator",
|
|
298
|
+
"IntoIterator",
|
|
299
|
+
"DoubleEndedIterator",
|
|
300
|
+
"ExactSizeIterator",
|
|
301
|
+
"Extend",
|
|
302
|
+
"FromIterator",
|
|
303
|
+
"From",
|
|
304
|
+
"Into",
|
|
305
|
+
"AsRef",
|
|
306
|
+
"AsMut",
|
|
307
|
+
"ToOwned",
|
|
308
|
+
"Default",
|
|
309
|
+
"PartialEq",
|
|
310
|
+
"Eq",
|
|
311
|
+
"PartialOrd",
|
|
312
|
+
"Ord",
|
|
313
|
+
"Hash",
|
|
314
|
+
"Debug",
|
|
315
|
+
"Display",
|
|
316
|
+
"ToString",
|
|
317
|
+
# Prelude enum variants
|
|
318
|
+
"Some",
|
|
319
|
+
"None",
|
|
320
|
+
"Ok",
|
|
321
|
+
"Err",
|
|
322
|
+
# Common macros (used as call targets in AST)
|
|
323
|
+
"println",
|
|
324
|
+
"print",
|
|
325
|
+
"eprintln",
|
|
326
|
+
"eprint",
|
|
327
|
+
"panic",
|
|
328
|
+
"assert",
|
|
329
|
+
"assert_eq",
|
|
330
|
+
"assert_ne",
|
|
331
|
+
"unreachable",
|
|
332
|
+
"unimplemented",
|
|
333
|
+
"todo",
|
|
334
|
+
"format",
|
|
335
|
+
"write",
|
|
336
|
+
"writeln",
|
|
337
|
+
"vec",
|
|
338
|
+
"dbg",
|
|
339
|
+
# Built-in functions
|
|
340
|
+
"drop",
|
|
341
|
+
# Common stdlib traits used as calls
|
|
342
|
+
"Default",
|
|
343
|
+
}
|
|
344
|
+
)
|
|
345
|
+
|
|
346
|
+
# ── Phase 9: new-language builtin sets ───────────────────────────────────────
|
|
347
|
+
# Conservative vocabulary: common builtins/globals/stdlib only — NOT exhaustive.
|
|
348
|
+
# An over-broad set risks shadowing real repo symbols.
|
|
349
|
+
# The count==0 structural guard in confidence.py is the primary safety net.
|
|
350
|
+
|
|
351
|
+
# Java common builtins — core language types, java.lang (auto-imported), common exceptions.
|
|
352
|
+
# WHY conservative: avoiding java.util.*, java.io.* etc. which users commonly name their own
|
|
353
|
+
# classes after (e.g. "List", "Map" — too likely to shadow real repo symbols).
|
|
354
|
+
_JAVA_BUILTINS: frozenset[str] = frozenset(
|
|
355
|
+
{
|
|
356
|
+
# java.lang (auto-imported in every Java file)
|
|
357
|
+
"Object",
|
|
358
|
+
"String",
|
|
359
|
+
"Integer",
|
|
360
|
+
"Long",
|
|
361
|
+
"Double",
|
|
362
|
+
"Float",
|
|
363
|
+
"Boolean",
|
|
364
|
+
"Byte",
|
|
365
|
+
"Short",
|
|
366
|
+
"Character",
|
|
367
|
+
"Number",
|
|
368
|
+
"Math",
|
|
369
|
+
"System",
|
|
370
|
+
"Runtime",
|
|
371
|
+
"Thread",
|
|
372
|
+
"Class",
|
|
373
|
+
"StringBuilder",
|
|
374
|
+
"StringBuffer",
|
|
375
|
+
"Comparable",
|
|
376
|
+
"Iterable",
|
|
377
|
+
"Runnable",
|
|
378
|
+
"Enum",
|
|
379
|
+
"Record",
|
|
380
|
+
"Void",
|
|
381
|
+
# Common exceptions (java.lang)
|
|
382
|
+
"Exception",
|
|
383
|
+
"RuntimeException",
|
|
384
|
+
"Error",
|
|
385
|
+
"Throwable",
|
|
386
|
+
"NullPointerException",
|
|
387
|
+
"IllegalArgumentException",
|
|
388
|
+
"IllegalStateException",
|
|
389
|
+
"IndexOutOfBoundsException",
|
|
390
|
+
"UnsupportedOperationException",
|
|
391
|
+
"ArithmeticException",
|
|
392
|
+
"ClassCastException",
|
|
393
|
+
"ArrayIndexOutOfBoundsException",
|
|
394
|
+
"StackOverflowError",
|
|
395
|
+
"OutOfMemoryError",
|
|
396
|
+
# Primitive wrappers (common as call targets)
|
|
397
|
+
"int",
|
|
398
|
+
"long",
|
|
399
|
+
"double",
|
|
400
|
+
"float",
|
|
401
|
+
"boolean",
|
|
402
|
+
"byte",
|
|
403
|
+
"char",
|
|
404
|
+
"short",
|
|
405
|
+
"void",
|
|
406
|
+
# Special values
|
|
407
|
+
"null",
|
|
408
|
+
"true",
|
|
409
|
+
"false",
|
|
410
|
+
"this",
|
|
411
|
+
"super",
|
|
412
|
+
# Common annotation types
|
|
413
|
+
"Override",
|
|
414
|
+
"Deprecated",
|
|
415
|
+
"SuppressWarnings",
|
|
416
|
+
"FunctionalInterface",
|
|
417
|
+
}
|
|
418
|
+
)
|
|
419
|
+
|
|
420
|
+
# C# common builtins — System namespace types and C# keyword types.
|
|
421
|
+
# WHY conservative: avoiding System.Collections.*, System.IO.* etc. which risk shadowing.
|
|
422
|
+
_CSHARP_BUILTINS: frozenset[str] = frozenset(
|
|
423
|
+
{
|
|
424
|
+
# C# keyword types (aliases for BCL types)
|
|
425
|
+
"string",
|
|
426
|
+
"int",
|
|
427
|
+
"long",
|
|
428
|
+
"double",
|
|
429
|
+
"float",
|
|
430
|
+
"decimal",
|
|
431
|
+
"bool",
|
|
432
|
+
"byte",
|
|
433
|
+
"short",
|
|
434
|
+
"char",
|
|
435
|
+
"object",
|
|
436
|
+
"void",
|
|
437
|
+
"uint",
|
|
438
|
+
"ulong",
|
|
439
|
+
"ushort",
|
|
440
|
+
"sbyte",
|
|
441
|
+
"nint",
|
|
442
|
+
"nuint",
|
|
443
|
+
# System namespace commonly used without qualifier
|
|
444
|
+
"Console",
|
|
445
|
+
"Math",
|
|
446
|
+
"String",
|
|
447
|
+
"Object",
|
|
448
|
+
"Int32",
|
|
449
|
+
"Int64",
|
|
450
|
+
"Double",
|
|
451
|
+
"Boolean",
|
|
452
|
+
"Byte",
|
|
453
|
+
"Char",
|
|
454
|
+
"Type",
|
|
455
|
+
"Enum",
|
|
456
|
+
"Array",
|
|
457
|
+
"Convert",
|
|
458
|
+
"DateTime",
|
|
459
|
+
"TimeSpan",
|
|
460
|
+
"Guid",
|
|
461
|
+
"Environment",
|
|
462
|
+
"GC",
|
|
463
|
+
"Exception",
|
|
464
|
+
# Common exceptions
|
|
465
|
+
"Exception",
|
|
466
|
+
"SystemException",
|
|
467
|
+
"ArgumentException",
|
|
468
|
+
"ArgumentNullException",
|
|
469
|
+
"ArgumentOutOfRangeException",
|
|
470
|
+
"InvalidOperationException",
|
|
471
|
+
"NotImplementedException",
|
|
472
|
+
"NotSupportedException",
|
|
473
|
+
"NullReferenceException",
|
|
474
|
+
"IndexOutOfRangeException",
|
|
475
|
+
"OverflowException",
|
|
476
|
+
"DivideByZeroException",
|
|
477
|
+
"OutOfMemoryException",
|
|
478
|
+
"StackOverflowException",
|
|
479
|
+
# Special keywords that appear as call targets
|
|
480
|
+
"null",
|
|
481
|
+
"true",
|
|
482
|
+
"false",
|
|
483
|
+
"this",
|
|
484
|
+
"base",
|
|
485
|
+
"nameof",
|
|
486
|
+
"typeof",
|
|
487
|
+
"sizeof",
|
|
488
|
+
"default",
|
|
489
|
+
"new",
|
|
490
|
+
}
|
|
491
|
+
)
|
|
492
|
+
|
|
493
|
+
# Ruby common builtins — core Kernel methods, IO primitives, and common globals.
|
|
494
|
+
# WHY conservative: Ruby's open classes mean many common names (e.g. "format",
|
|
495
|
+
# "Array", "Hash") are likely real repo symbols too. Only truly global, unambiguous
|
|
496
|
+
# Kernel methods and constants are included.
|
|
497
|
+
_RUBY_BUILTINS: frozenset[str] = frozenset(
|
|
498
|
+
{
|
|
499
|
+
# Kernel methods (available everywhere without require)
|
|
500
|
+
"puts",
|
|
501
|
+
"print",
|
|
502
|
+
"p",
|
|
503
|
+
"pp",
|
|
504
|
+
"sprintf",
|
|
505
|
+
"format",
|
|
506
|
+
"gets",
|
|
507
|
+
"require",
|
|
508
|
+
"require_relative",
|
|
509
|
+
"load",
|
|
510
|
+
"raise",
|
|
511
|
+
"fail",
|
|
512
|
+
"exit",
|
|
513
|
+
"abort",
|
|
514
|
+
"sleep",
|
|
515
|
+
"rand",
|
|
516
|
+
"srand",
|
|
517
|
+
"lambda",
|
|
518
|
+
"proc",
|
|
519
|
+
"block_given?",
|
|
520
|
+
"caller",
|
|
521
|
+
"binding",
|
|
522
|
+
"loop",
|
|
523
|
+
"at_exit",
|
|
524
|
+
# Common type constructors (capitalized Kernel conversion methods)
|
|
525
|
+
"Array",
|
|
526
|
+
"Integer",
|
|
527
|
+
"Float",
|
|
528
|
+
"String",
|
|
529
|
+
"Rational",
|
|
530
|
+
"Complex",
|
|
531
|
+
# Core constants
|
|
532
|
+
"nil",
|
|
533
|
+
"true",
|
|
534
|
+
"false",
|
|
535
|
+
"self",
|
|
536
|
+
"RUBY_VERSION",
|
|
537
|
+
"RUBY_PLATFORM",
|
|
538
|
+
"ARGV",
|
|
539
|
+
"STDIN",
|
|
540
|
+
"STDOUT",
|
|
541
|
+
"STDERR",
|
|
542
|
+
# Common exceptions (Kernel raise targets)
|
|
543
|
+
"RuntimeError",
|
|
544
|
+
"ArgumentError",
|
|
545
|
+
"TypeError",
|
|
546
|
+
"NameError",
|
|
547
|
+
"NoMethodError",
|
|
548
|
+
"StandardError",
|
|
549
|
+
"Exception",
|
|
550
|
+
"NotImplementedError",
|
|
551
|
+
"StopIteration",
|
|
552
|
+
"IndexError",
|
|
553
|
+
"KeyError",
|
|
554
|
+
"IOError",
|
|
555
|
+
"Errno",
|
|
556
|
+
"Interrupt",
|
|
557
|
+
}
|
|
558
|
+
)
|
|
559
|
+
|
|
560
|
+
# C standard library functions — conservative subset of <stdio.h>, <stdlib.h>,
|
|
561
|
+
# <string.h>, <math.h>, <stddef.h>, and language keywords used as call targets.
|
|
562
|
+
# WHY conservative: avoiding less common stdlib names that risk shadowing real repo
|
|
563
|
+
# symbols. The count==0 guard in confidence.py is the primary safety net.
|
|
564
|
+
_C_BUILTINS: frozenset[str] = frozenset(
|
|
565
|
+
{
|
|
566
|
+
# <stdio.h> — the most commonly called C stdlib functions
|
|
567
|
+
"printf",
|
|
568
|
+
"fprintf",
|
|
569
|
+
"sprintf",
|
|
570
|
+
"snprintf",
|
|
571
|
+
"scanf",
|
|
572
|
+
"fscanf",
|
|
573
|
+
"sscanf",
|
|
574
|
+
"fopen",
|
|
575
|
+
"fclose",
|
|
576
|
+
"fread",
|
|
577
|
+
"fwrite",
|
|
578
|
+
"fgets",
|
|
579
|
+
"fputs",
|
|
580
|
+
"puts",
|
|
581
|
+
"gets",
|
|
582
|
+
"fflush",
|
|
583
|
+
"feof",
|
|
584
|
+
"ferror",
|
|
585
|
+
"perror",
|
|
586
|
+
"putchar",
|
|
587
|
+
"getchar",
|
|
588
|
+
# <stdlib.h>
|
|
589
|
+
"malloc",
|
|
590
|
+
"calloc",
|
|
591
|
+
"realloc",
|
|
592
|
+
"free",
|
|
593
|
+
"exit",
|
|
594
|
+
"abort",
|
|
595
|
+
"atexit",
|
|
596
|
+
"atoi",
|
|
597
|
+
"atol",
|
|
598
|
+
"atof",
|
|
599
|
+
"strtol",
|
|
600
|
+
"strtod",
|
|
601
|
+
"rand",
|
|
602
|
+
"srand",
|
|
603
|
+
"abs",
|
|
604
|
+
"labs",
|
|
605
|
+
"qsort",
|
|
606
|
+
"bsearch",
|
|
607
|
+
"getenv",
|
|
608
|
+
"system",
|
|
609
|
+
# <string.h>
|
|
610
|
+
"memcpy",
|
|
611
|
+
"memmove",
|
|
612
|
+
"memset",
|
|
613
|
+
"memcmp",
|
|
614
|
+
"strcpy",
|
|
615
|
+
"strncpy",
|
|
616
|
+
"strcat",
|
|
617
|
+
"strncat",
|
|
618
|
+
"strcmp",
|
|
619
|
+
"strncmp",
|
|
620
|
+
"strlen",
|
|
621
|
+
"strchr",
|
|
622
|
+
"strrchr",
|
|
623
|
+
"strstr",
|
|
624
|
+
"strtok",
|
|
625
|
+
# <math.h>
|
|
626
|
+
"sqrt",
|
|
627
|
+
"pow",
|
|
628
|
+
"fabs",
|
|
629
|
+
"floor",
|
|
630
|
+
"ceil",
|
|
631
|
+
"sin",
|
|
632
|
+
"cos",
|
|
633
|
+
"tan",
|
|
634
|
+
"log",
|
|
635
|
+
"exp",
|
|
636
|
+
# <stddef.h> / common keywords that appear as call-like expressions
|
|
637
|
+
"sizeof",
|
|
638
|
+
"offsetof",
|
|
639
|
+
# C99 / C11 additions
|
|
640
|
+
"assert",
|
|
641
|
+
}
|
|
642
|
+
)
|
|
643
|
+
|
|
644
|
+
# C++ standard library / STL names — conservative subset covering the most common
|
|
645
|
+
# global names and STL entry points that appear as bare-identifier call targets.
|
|
646
|
+
# WHY conservative: C++ STL is vast; broad sets risk shadowing repo symbols.
|
|
647
|
+
_CPP_BUILTINS: frozenset[str] = frozenset(
|
|
648
|
+
{
|
|
649
|
+
# Namespace name itself (appears in using directives and bare calls)
|
|
650
|
+
"std",
|
|
651
|
+
# Common STL stream objects used without std:: qualifier
|
|
652
|
+
"cout",
|
|
653
|
+
"cin",
|
|
654
|
+
"cerr",
|
|
655
|
+
"clog",
|
|
656
|
+
"endl",
|
|
657
|
+
# Common STL types used as constructors / call targets
|
|
658
|
+
"string",
|
|
659
|
+
"vector",
|
|
660
|
+
"map",
|
|
661
|
+
"set",
|
|
662
|
+
"list",
|
|
663
|
+
"deque",
|
|
664
|
+
"queue",
|
|
665
|
+
"stack",
|
|
666
|
+
"pair",
|
|
667
|
+
"tuple",
|
|
668
|
+
"array",
|
|
669
|
+
"unordered_map",
|
|
670
|
+
"unordered_set",
|
|
671
|
+
"unique_ptr",
|
|
672
|
+
"shared_ptr",
|
|
673
|
+
"weak_ptr",
|
|
674
|
+
"make_unique",
|
|
675
|
+
"make_shared",
|
|
676
|
+
"make_pair",
|
|
677
|
+
"move",
|
|
678
|
+
"forward",
|
|
679
|
+
"swap",
|
|
680
|
+
"sort",
|
|
681
|
+
"find",
|
|
682
|
+
"copy",
|
|
683
|
+
"fill",
|
|
684
|
+
"begin",
|
|
685
|
+
"end",
|
|
686
|
+
"size",
|
|
687
|
+
"empty",
|
|
688
|
+
# C stdlib (inherited in C++; all C builtins are valid C++ too)
|
|
689
|
+
"printf",
|
|
690
|
+
"fprintf",
|
|
691
|
+
"sprintf",
|
|
692
|
+
"malloc",
|
|
693
|
+
"calloc",
|
|
694
|
+
"realloc",
|
|
695
|
+
"free",
|
|
696
|
+
"exit",
|
|
697
|
+
"abort",
|
|
698
|
+
"strlen",
|
|
699
|
+
"strcpy",
|
|
700
|
+
"strcmp",
|
|
701
|
+
"memcpy",
|
|
702
|
+
"memset",
|
|
703
|
+
"assert",
|
|
704
|
+
# C++ exceptions
|
|
705
|
+
"exception",
|
|
706
|
+
"runtime_error",
|
|
707
|
+
"logic_error",
|
|
708
|
+
"invalid_argument",
|
|
709
|
+
"out_of_range",
|
|
710
|
+
"overflow_error",
|
|
711
|
+
"bad_alloc",
|
|
712
|
+
"throw",
|
|
713
|
+
# C++ keywords that appear as call targets (e.g. delete, new)
|
|
714
|
+
"new",
|
|
715
|
+
"delete",
|
|
716
|
+
"sizeof",
|
|
717
|
+
"typeid",
|
|
718
|
+
"static_cast",
|
|
719
|
+
"dynamic_cast",
|
|
720
|
+
"const_cast",
|
|
721
|
+
"reinterpret_cast",
|
|
722
|
+
}
|
|
723
|
+
)
|
|
724
|
+
|
|
725
|
+
# PHP built-in functions and language constructs — conservative subset of the most
|
|
726
|
+
# commonly called PHP global functions and language constructs.
|
|
727
|
+
# WHY conservative: PHP's function namespace is large; over-broad sets risk
|
|
728
|
+
# shadowing user-defined functions with the same names. The count==0 guard in
|
|
729
|
+
# confidence.py is the primary safety net.
|
|
730
|
+
_PHP_BUILTINS: frozenset[str] = frozenset(
|
|
731
|
+
{
|
|
732
|
+
# Language constructs (behave like functions but are keywords)
|
|
733
|
+
"echo",
|
|
734
|
+
"print",
|
|
735
|
+
"die",
|
|
736
|
+
"exit",
|
|
737
|
+
"isset",
|
|
738
|
+
"unset",
|
|
739
|
+
"empty",
|
|
740
|
+
"list",
|
|
741
|
+
"array",
|
|
742
|
+
"include",
|
|
743
|
+
"require",
|
|
744
|
+
"include_once",
|
|
745
|
+
"require_once",
|
|
746
|
+
# String functions
|
|
747
|
+
"strlen",
|
|
748
|
+
"str_len",
|
|
749
|
+
"substr",
|
|
750
|
+
"strpos",
|
|
751
|
+
"strrpos",
|
|
752
|
+
"str_replace",
|
|
753
|
+
"str_contains",
|
|
754
|
+
"str_starts_with",
|
|
755
|
+
"str_ends_with",
|
|
756
|
+
"trim",
|
|
757
|
+
"ltrim",
|
|
758
|
+
"rtrim",
|
|
759
|
+
"strtolower",
|
|
760
|
+
"strtoupper",
|
|
761
|
+
"ucfirst",
|
|
762
|
+
"lcfirst",
|
|
763
|
+
"ucwords",
|
|
764
|
+
"explode",
|
|
765
|
+
"implode",
|
|
766
|
+
"join",
|
|
767
|
+
"split",
|
|
768
|
+
"sprintf",
|
|
769
|
+
"printf",
|
|
770
|
+
"number_format",
|
|
771
|
+
"htmlspecialchars",
|
|
772
|
+
"htmlentities",
|
|
773
|
+
"nl2br",
|
|
774
|
+
"strip_tags",
|
|
775
|
+
"md5",
|
|
776
|
+
"sha1",
|
|
777
|
+
"base64_encode",
|
|
778
|
+
"base64_decode",
|
|
779
|
+
"json_encode",
|
|
780
|
+
"json_decode",
|
|
781
|
+
"serialize",
|
|
782
|
+
"unserialize",
|
|
783
|
+
# Array functions
|
|
784
|
+
"count",
|
|
785
|
+
"sizeof",
|
|
786
|
+
"array_map",
|
|
787
|
+
"array_filter",
|
|
788
|
+
"array_reduce",
|
|
789
|
+
"array_merge",
|
|
790
|
+
"array_push",
|
|
791
|
+
"array_pop",
|
|
792
|
+
"array_shift",
|
|
793
|
+
"array_unshift",
|
|
794
|
+
"array_slice",
|
|
795
|
+
"array_splice",
|
|
796
|
+
"array_keys",
|
|
797
|
+
"array_values",
|
|
798
|
+
"array_flip",
|
|
799
|
+
"array_reverse",
|
|
800
|
+
"array_unique",
|
|
801
|
+
"array_search",
|
|
802
|
+
"in_array",
|
|
803
|
+
"sort",
|
|
804
|
+
"rsort",
|
|
805
|
+
"asort",
|
|
806
|
+
"arsort",
|
|
807
|
+
"ksort",
|
|
808
|
+
"krsort",
|
|
809
|
+
"usort",
|
|
810
|
+
"uasort",
|
|
811
|
+
"uksort",
|
|
812
|
+
"range",
|
|
813
|
+
"compact",
|
|
814
|
+
"extract",
|
|
815
|
+
# Math functions
|
|
816
|
+
"abs",
|
|
817
|
+
"ceil",
|
|
818
|
+
"floor",
|
|
819
|
+
"round",
|
|
820
|
+
"max",
|
|
821
|
+
"min",
|
|
822
|
+
"pow",
|
|
823
|
+
"sqrt",
|
|
824
|
+
"rand",
|
|
825
|
+
"mt_rand",
|
|
826
|
+
"intval",
|
|
827
|
+
"floatval",
|
|
828
|
+
"strval",
|
|
829
|
+
"intdiv",
|
|
830
|
+
"fmod",
|
|
831
|
+
# Type checking
|
|
832
|
+
"is_array",
|
|
833
|
+
"is_string",
|
|
834
|
+
"is_int",
|
|
835
|
+
"is_integer",
|
|
836
|
+
"is_float",
|
|
837
|
+
"is_bool",
|
|
838
|
+
"is_null",
|
|
839
|
+
"is_numeric",
|
|
840
|
+
"is_callable",
|
|
841
|
+
"is_object",
|
|
842
|
+
"gettype",
|
|
843
|
+
"settype",
|
|
844
|
+
"var_dump",
|
|
845
|
+
"var_export",
|
|
846
|
+
"print_r",
|
|
847
|
+
# Date/time
|
|
848
|
+
"time",
|
|
849
|
+
"date",
|
|
850
|
+
"mktime",
|
|
851
|
+
"strtotime",
|
|
852
|
+
"microtime",
|
|
853
|
+
# File/IO
|
|
854
|
+
"file_get_contents",
|
|
855
|
+
"file_put_contents",
|
|
856
|
+
"file_exists",
|
|
857
|
+
"is_file",
|
|
858
|
+
"is_dir",
|
|
859
|
+
"mkdir",
|
|
860
|
+
"rmdir",
|
|
861
|
+
"unlink",
|
|
862
|
+
"rename",
|
|
863
|
+
"fopen",
|
|
864
|
+
"fclose",
|
|
865
|
+
"fgets",
|
|
866
|
+
"fread",
|
|
867
|
+
"fwrite",
|
|
868
|
+
"feof",
|
|
869
|
+
# Error handling
|
|
870
|
+
"trigger_error",
|
|
871
|
+
"set_error_handler",
|
|
872
|
+
"error_reporting",
|
|
873
|
+
# Other common globals
|
|
874
|
+
"header",
|
|
875
|
+
"headers_sent",
|
|
876
|
+
"session_start",
|
|
877
|
+
"session_destroy",
|
|
878
|
+
"ob_start",
|
|
879
|
+
"ob_get_clean",
|
|
880
|
+
"ob_end_clean",
|
|
881
|
+
"class_exists",
|
|
882
|
+
"method_exists",
|
|
883
|
+
"function_exists",
|
|
884
|
+
"defined",
|
|
885
|
+
"define",
|
|
886
|
+
"constant",
|
|
887
|
+
"get_class",
|
|
888
|
+
"get_parent_class",
|
|
889
|
+
"is_a",
|
|
890
|
+
"instanceof",
|
|
891
|
+
"call_user_func",
|
|
892
|
+
"call_user_func_array",
|
|
893
|
+
"func_get_args",
|
|
894
|
+
}
|
|
895
|
+
)
|
|
896
|
+
|
|
897
|
+
# ── Swift standard library types and global functions ─────────────────────────
|
|
898
|
+
# Conservative vocabulary: common Swift stdlib and language built-ins only.
|
|
899
|
+
# NOT exhaustive (no SwiftUI, no Foundation classes beyond primitives) — an
|
|
900
|
+
# over-broad set risks shadowing real repo symbols.
|
|
901
|
+
# The count==0 structural guard in confidence.py is the primary safety net.
|
|
902
|
+
_SWIFT_BUILTINS: frozenset[str] = frozenset(
|
|
903
|
+
{
|
|
904
|
+
# Global functions (commonly called as bare identifiers)
|
|
905
|
+
"print", "debugPrint", "fatalError", "precondition", "preconditionFailure",
|
|
906
|
+
"assert", "assertionFailure", "min", "max", "abs", "zip", "swap",
|
|
907
|
+
# Primitive types
|
|
908
|
+
"Int", "Int8", "Int16", "Int32", "Int64",
|
|
909
|
+
"UInt", "UInt8", "UInt16", "UInt32", "UInt64",
|
|
910
|
+
"Float", "Double", "Bool", "Character", "String", "Substring",
|
|
911
|
+
# Collection types
|
|
912
|
+
"Array", "Dictionary", "Set", "Optional", "Result",
|
|
913
|
+
"Range", "ClosedRange",
|
|
914
|
+
# Special values / literals
|
|
915
|
+
"nil", "true", "false",
|
|
916
|
+
# Type-system keywords that appear as call targets
|
|
917
|
+
"Error", "AnyObject", "Any", "Void", "Never", "Self", "self", "super",
|
|
918
|
+
# Common protocols used as identifiers
|
|
919
|
+
"Comparable", "Equatable", "Hashable", "Codable", "Encodable", "Decodable",
|
|
920
|
+
"CustomStringConvertible",
|
|
921
|
+
}
|
|
922
|
+
)
|
|
923
|
+
|
|
924
|
+
# ── Language registry ─────────────────────────────────────────────────────────
|
|
925
|
+
# Maps language identifiers (matching SEAM_LANGUAGE_MAP values) to builtin sets.
|
|
926
|
+
_LANGUAGE_BUILTINS: dict[str, frozenset[str]] = {
|
|
927
|
+
"python": _PYTHON_BUILTINS,
|
|
928
|
+
"typescript": _TYPESCRIPT_BUILTINS,
|
|
929
|
+
"javascript": _JAVASCRIPT_BUILTINS,
|
|
930
|
+
"go": _GO_BUILTINS,
|
|
931
|
+
"rust": _RUST_BUILTINS,
|
|
932
|
+
# Phase 9 — new languages (empty sets; family agents populate)
|
|
933
|
+
"java": _JAVA_BUILTINS,
|
|
934
|
+
"csharp": _CSHARP_BUILTINS,
|
|
935
|
+
"ruby": _RUBY_BUILTINS,
|
|
936
|
+
"c": _C_BUILTINS,
|
|
937
|
+
"cpp": _CPP_BUILTINS,
|
|
938
|
+
"php": _PHP_BUILTINS,
|
|
939
|
+
# Phase 10 — Swift
|
|
940
|
+
"swift": _SWIFT_BUILTINS,
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
|
|
944
|
+
def is_builtin(name: str, language: str) -> bool:
|
|
945
|
+
"""Return True if `name` is a known builtin for `language`.
|
|
946
|
+
|
|
947
|
+
Language-scoped: a Python builtin name does NOT affect Go edges and vice versa.
|
|
948
|
+
Conservative: the builtin sets cover well-known globals/prelude only, not
|
|
949
|
+
exhaustive stdlib mirrors. The caller (confidence.py) enforces that this is
|
|
950
|
+
only called when name_counts.get(name, 0) == 0 (count==0 structural guard).
|
|
951
|
+
|
|
952
|
+
Args:
|
|
953
|
+
name: The target symbol name to check.
|
|
954
|
+
language: Language identifier (e.g. 'python', 'typescript', 'go', 'rust').
|
|
955
|
+
Unknown languages return False (never raises).
|
|
956
|
+
|
|
957
|
+
Returns:
|
|
958
|
+
True if the name is in the curated builtin vocabulary for the language.
|
|
959
|
+
False if unknown language, empty name, or not in the set.
|
|
960
|
+
"""
|
|
961
|
+
if not name or not language:
|
|
962
|
+
return False
|
|
963
|
+
builtin_set = _LANGUAGE_BUILTINS.get(language)
|
|
964
|
+
if builtin_set is None:
|
|
965
|
+
return False
|
|
966
|
+
return name in builtin_set
|