codecop 0.1.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.
Files changed (222) hide show
  1. codecop/__init__.py +7 -0
  2. codecop/access.py +140 -0
  3. codecop/access_postgres.py +284 -0
  4. codecop/advisor.py +1512 -0
  5. codecop/advisor_bench.py +493 -0
  6. codecop/advisor_ch.py +2080 -0
  7. codecop/advisor_view.py +381 -0
  8. codecop/advisors.py +184 -0
  9. codecop/agent.py +221 -0
  10. codecop/agentfacts.py +745 -0
  11. codecop/apply/__init__.py +327 -0
  12. codecop/apply/check.py +344 -0
  13. codecop/apply/cli.py +162 -0
  14. codecop/apply/clickhouse.py +379 -0
  15. codecop/apply/common.py +238 -0
  16. codecop/apply/html.py +264 -0
  17. codecop/apply/patch.py +213 -0
  18. codecop/apply/postgres.py +102 -0
  19. codecop/apply/trial.py +166 -0
  20. codecop/assemble.py +104 -0
  21. codecop/baseline.py +1043 -0
  22. codecop/bench.py +2464 -0
  23. codecop/blockers.py +935 -0
  24. codecop/budget.py +980 -0
  25. codecop/catalog_profile.py +525 -0
  26. codecop/changed.py +261 -0
  27. codecop/cicmd.py +1002 -0
  28. codecop/cli.py +5421 -0
  29. codecop/client.py +729 -0
  30. codecop/coverage.py +1067 -0
  31. codecop/coverage_reasons.py +116 -0
  32. codecop/crashlog.py +70 -0
  33. codecop/datagen.py +766 -0
  34. codecop/datagen_postgres.py +630 -0
  35. codecop/datagen_sqlite.py +323 -0
  36. codecop/dbcli.py +885 -0
  37. codecop/definitions.py +457 -0
  38. codecop/discover/__init__.py +702 -0
  39. codecop/discover/arms.py +160 -0
  40. codecop/discover/base.py +234 -0
  41. codecop/discover/dialect.py +296 -0
  42. codecop/discover/elixir.py +64 -0
  43. codecop/discover/engine_go.py +320 -0
  44. codecop/discover/go.py +1947 -0
  45. codecop/discover/java.py +1528 -0
  46. codecop/discover/loops.py +1671 -0
  47. codecop/discover/named_go.py +258 -0
  48. codecop/discover/origins.py +4565 -0
  49. codecop/discover/origins_ts.py +1584 -0
  50. codecop/discover/orm_django.py +2772 -0
  51. codecop/discover/orm_django_models.py +814 -0
  52. codecop/discover/orm_django_sql.py +662 -0
  53. codecop/discover/orm_ent.py +565 -0
  54. codecop/discover/orm_ex_ecto.py +2138 -0
  55. codecop/discover/orm_go.py +2134 -0
  56. codecop/discover/orm_go_bun.py +602 -0
  57. codecop/discover/orm_go_run.py +636 -0
  58. codecop/discover/orm_go_types.py +1082 -0
  59. codecop/discover/orm_java.py +1450 -0
  60. codecop/discover/orm_jdbi.py +743 -0
  61. codecop/discover/orm_jooq.py +806 -0
  62. codecop/discover/orm_jpa.py +1307 -0
  63. codecop/discover/orm_mybatis.py +730 -0
  64. codecop/discover/orm_py.py +557 -0
  65. codecop/discover/orm_py_peewee.py +1266 -0
  66. codecop/discover/orm_py_prisma.py +298 -0
  67. codecop/discover/orm_rb_activerecord.py +1906 -0
  68. codecop/discover/orm_rust.py +1248 -0
  69. codecop/discover/orm_rust_seaorm.py +734 -0
  70. codecop/discover/orm_sqlalchemy.py +2475 -0
  71. codecop/discover/orm_stats.py +307 -0
  72. codecop/discover/orm_tables.py +29 -0
  73. codecop/discover/orm_ts.py +503 -0
  74. codecop/discover/orm_ts_drizzle.py +697 -0
  75. codecop/discover/orm_ts_knex.py +1117 -0
  76. codecop/discover/orm_ts_kysely.py +861 -0
  77. codecop/discover/orm_ts_prisma.py +1045 -0
  78. codecop/discover/orm_ts_schema.py +169 -0
  79. codecop/discover/orm_ts_sequelize.py +1401 -0
  80. codecop/discover/orm_ts_typeorm.py +1067 -0
  81. codecop/discover/probes.py +323 -0
  82. codecop/discover/python.py +595 -0
  83. codecop/discover/ruby.py +793 -0
  84. codecop/discover/rust.py +2378 -0
  85. codecop/discover/schema.py +520 -0
  86. codecop/discover/schema_ent.py +145 -0
  87. codecop/discover/schema_ts.py +420 -0
  88. codecop/discover/tsresolve.py +257 -0
  89. codecop/discover/typescript.py +1728 -0
  90. codecop/discover/xml_mapper.py +526 -0
  91. codecop/engines/__init__.py +515 -0
  92. codecop/engines/base.py +498 -0
  93. codecop/engines/clickhouse.py +1558 -0
  94. codecop/engines/pg_ddl.py +444 -0
  95. codecop/engines/pg_hints.py +137 -0
  96. codecop/engines/postgres.py +1060 -0
  97. codecop/engines/sqlite.py +742 -0
  98. codecop/families/__init__.py +3 -0
  99. codecop/families/build.py +280 -0
  100. codecop/families/cli.py +177 -0
  101. codecop/families/coverage_hook.py +62 -0
  102. codecop/families/driver.py +221 -0
  103. codecop/families/goslice.py +229 -0
  104. codecop/families/goslice_tool/go.mod +3 -0
  105. codecop/families/goslice_tool/main.go +403 -0
  106. codecop/families/holes.py +451 -0
  107. codecop/families/images/Dockerfile.go +5 -0
  108. codecop/families/images/Dockerfile.python +4 -0
  109. codecop/families/images/Dockerfile.rust +4 -0
  110. codecop/families/isolate.py +171 -0
  111. codecop/families/locate.py +270 -0
  112. codecop/families/model.py +301 -0
  113. codecop/families/plangate.py +271 -0
  114. codecop/families/tagpatch.py +174 -0
  115. codecop/fidelity.py +671 -0
  116. codecop/fixgroups.py +130 -0
  117. codecop/formerly.py +91 -0
  118. codecop/grantscript.py +254 -0
  119. codecop/groupbench.py +1375 -0
  120. codecop/groups.py +594 -0
  121. codecop/groups_view.py +186 -0
  122. codecop/heat.py +1405 -0
  123. codecop/heatcli.py +219 -0
  124. codecop/joins.py +1749 -0
  125. codecop/joins_view.py +127 -0
  126. codecop/kinds/__init__.py +507 -0
  127. codecop/kinds/calls/__init__.py +501 -0
  128. codecop/kinds/calls/extract.py +1097 -0
  129. codecop/kinds/calls/harness.py +408 -0
  130. codecop/kinds/calls/measure.py +342 -0
  131. codecop/kinds/calls/rules.py +139 -0
  132. codecop/kinds/calls/runners/RunCalls.java +167 -0
  133. codecop/kinds/calls/runners/run_go.go +141 -0
  134. codecop/kinds/calls/runners/run_node.js +186 -0
  135. codecop/kinds/calls/runners/run_python.py +319 -0
  136. codecop/kinds/calls/runners/run_rust.rs +200 -0
  137. codecop/kinds/calls/standin.py +340 -0
  138. codecop/kinds/pipeline.py +288 -0
  139. codecop/kinds/regex/__init__.py +1167 -0
  140. codecop/kinds/regex/engines/RegexHarness.java +129 -0
  141. codecop/kinds/regex/engines/run_go.go +294 -0
  142. codecop/kinds/regex/engines/run_node.js +99 -0
  143. codecop/kinds/regex/engines/run_python.py +295 -0
  144. codecop/kinds/regex/engines/run_rust.rs +149 -0
  145. codecop/kinds/regex/extract.py +1438 -0
  146. codecop/kinds/regex/harness.py +235 -0
  147. codecop/kinds/regex/measure.py +270 -0
  148. codecop/kinds/regex/shapes.py +418 -0
  149. codecop/kinds/regex/syntax.py +1721 -0
  150. codecop/kinds/testkind.py +107 -0
  151. codecop/kinds/transaction/__init__.py +228 -0
  152. codecop/kinds/transaction/bind.py +355 -0
  153. codecop/kinds/transaction/measure.py +264 -0
  154. codecop/kinds/transaction/plan.py +462 -0
  155. codecop/kinds/transaction/rules.py +540 -0
  156. codecop/kinds/transaction/sandbox.py +94 -0
  157. codecop/kinds/transaction/scenarios.py +520 -0
  158. codecop/kinds/transaction/schedule.py +483 -0
  159. codecop/kinds/transaction/shapes.py +418 -0
  160. codecop/kinds/transaction/verify.py +293 -0
  161. codecop/live.py +237 -0
  162. codecop/loopbench.py +2071 -0
  163. codecop/loopschema.py +591 -0
  164. codecop/mcpserver.py +120 -0
  165. codecop/mechanism.py +214 -0
  166. codecop/members.py +200 -0
  167. codecop/multi.py +443 -0
  168. codecop/observed.py +1868 -0
  169. codecop/parts.py +102 -0
  170. codecop/patterns.py +830 -0
  171. codecop/patterns_view.py +559 -0
  172. codecop/plangate.py +242 -0
  173. codecop/profile.py +439 -0
  174. codecop/prompts/areas.md +19 -0
  175. codecop/prompts/observed_variants.md +20 -0
  176. codecop/prompts/profile.md +60 -0
  177. codecop/prompts/profile_postgres.md +68 -0
  178. codecop/prompts/profile_sizes.md +26 -0
  179. codecop/prompts/profile_sqlite.md +69 -0
  180. codecop/prompts/rank.md +84 -0
  181. codecop/prompts/rank_postgres.md +96 -0
  182. codecop/prompts/rank_sqlite.md +94 -0
  183. codecop/prompts/scenario_variants.md +20 -0
  184. codecop/rank.py +1473 -0
  185. codecop/realdb/__init__.py +688 -0
  186. codecop/realdb/clickhouse.py +1223 -0
  187. codecop/realdb/facts.py +815 -0
  188. codecop/realdb/locality.py +964 -0
  189. codecop/realdb/locks.py +355 -0
  190. codecop/realdb/match.py +531 -0
  191. codecop/realdb/postgres.py +643 -0
  192. codecop/realdb/ratios.py +77 -0
  193. codecop/realdb/sample.py +126 -0
  194. codecop/relations.py +227 -0
  195. codecop/report.py +1854 -0
  196. codecop/resources.py +332 -0
  197. codecop/resources_view.py +266 -0
  198. codecop/rules/entry_points.toml +1013 -0
  199. codecop/rules/sinks.toml +362 -0
  200. codecop/runsonce.py +8 -0
  201. codecop/sandboxschema.py +555 -0
  202. codecop/scenario_agent.py +172 -0
  203. codecop/scenario_bind.py +507 -0
  204. codecop/scenario_sql.py +971 -0
  205. codecop/scenarios.py +675 -0
  206. codecop/scenarios_view.py +274 -0
  207. codecop/schemacli.py +67 -0
  208. codecop/schemas/areas_output.schema.json +21 -0
  209. codecop/schemas/profile_output.schema.json +362 -0
  210. codecop/schemas/rank_output.schema.json +385 -0
  211. codecop/sizes.py +200 -0
  212. codecop/sqlinfo.py +558 -0
  213. codecop/typedparams.py +576 -0
  214. codecop/verdicts.py +212 -0
  215. codecop/writebench.py +720 -0
  216. codecop/writecost.py +440 -0
  217. codecop/writes.py +1208 -0
  218. codecop-0.1.0.dist-info/METADATA +42 -0
  219. codecop-0.1.0.dist-info/RECORD +222 -0
  220. codecop-0.1.0.dist-info/WHEEL +4 -0
  221. codecop-0.1.0.dist-info/entry_points.txt +2 -0
  222. codecop-0.1.0.dist-info/licenses/LICENSE +21 -0
codecop/changed.py ADDED
@@ -0,0 +1,261 @@
1
+ """`codecop scan --changed-since <ref>`: rank only what a change touches.
2
+
3
+ Discover still reads the whole repository: the inventory, the tables and the
4
+ call graph are only right when they are whole. What is narrowed is the rank
5
+ stage, to the call sites that are
6
+
7
+ - in a file the change touches (`changed_file`), or
8
+ - inside a function that is reached, through calls, from a function whose
9
+ lines the change touches (`reached_from_changed_code`): a caller that now
10
+ calls in a loop, or with another filter, changes what a query costs
11
+ without touching the file the query is in, or
12
+ - reading a table whose CREATE TABLE statement in the repository the change
13
+ touches (`table_definition_changed`): a new sorting key or a dropped
14
+ index changes the cost of every query on the table, with no query edited.
15
+
16
+ "The change" is everything between the merge base of HEAD and the ref and the
17
+ working tree: the commits of the branch plus what is not committed yet, in the
18
+ files git tracks (discover reads only those).
19
+
20
+ What this cannot see, and so does not claim: a query whose cost changes because
21
+ of a changed constant read in another file or a changed config value; a table
22
+ changed by an ALTER in a migration file (only the CREATE TABLE statement
23
+ discover found is tied to the table); and calls the call graph could not link
24
+ (reflection, dependency injection it has no rule for). Functions are followed
25
+ up to MAX_HOPS calls down from the changed one.
26
+
27
+ The scope is recorded in rank.json (`scope`), so coverage counts the call sites
28
+ it left out as `unchanged`, and a partial run can be told from a full one.
29
+ """
30
+
31
+ from __future__ import annotations
32
+
33
+ import json
34
+ import os
35
+ import re
36
+ import subprocess
37
+ from collections import deque
38
+ from pathlib import Path
39
+
40
+ MAX_HOPS = 10
41
+ HUNK = re.compile(r"^@@ -\d+(?:,(\d+))? \+(\d+)(?:,(\d+))? @@")
42
+
43
+ # The scope of the scan running in this process. Set by `codecop scan --changed-since`, read by the rank
44
+ # stage. Kept in memory, not in a file: a file left behind would silently narrow a later full run.
45
+ ACTIVE: dict | None = None
46
+ _CACHE: dict[tuple, dict] = {}
47
+
48
+
49
+ class ChangedError(RuntimeError):
50
+ pass
51
+
52
+
53
+ def _git(root: Path, *args: str) -> str:
54
+ try:
55
+ proc = subprocess.run(["git", "-C", str(root), *args], capture_output=True, text=True)
56
+ except OSError as exc:
57
+ raise ChangedError(f"git is not available: {exc}") from exc
58
+ if proc.returncode != 0:
59
+ raise ChangedError((proc.stderr or proc.stdout).strip().splitlines()[-1] if (proc.stderr or proc.stdout).strip() else "git failed")
60
+ return proc.stdout
61
+
62
+
63
+ def changed_lines(root: Path, ref: str) -> tuple[str, dict[str, list[tuple[int, int]]]]:
64
+ """(merge base, {file: [(first line, last line)]}) for everything changed since the merge base with `ref`.
65
+
66
+ Lines are those of the working tree. A place where lines were only removed counts as the line it
67
+ happened at, so the function around a deletion is a changed function. Deleted files are left out
68
+ (they hold no call site any more). A file git does not track yet is not here, and not in the
69
+ inventory either: discover reads tracked files. Paths are relative to `root`, which may be a
70
+ directory inside the git repository."""
71
+ try:
72
+ base = _git(root, "merge-base", ref, "HEAD").strip()
73
+ except ChangedError as exc:
74
+ raise ChangedError(
75
+ f"no merge base between HEAD and `{ref}` ({exc}). Is the ref fetched? In CI, check out with full history "
76
+ f"(actions/checkout `fetch-depth: 0`) or fetch the base branch first.") from exc
77
+ files: dict[str, list[tuple[int, int]]] = {}
78
+ current = None
79
+ # --relative: paths as seen from `root`, and only what is under it
80
+ body = 0 # lines of the current hunk still to skip: a changed line may itself start with `+++ ` or `@@`
81
+ for line in _git(root, "diff", "--unified=0", "--no-color", "--no-ext-diff", "--relative", "-M", base, "--", ".").splitlines():
82
+ if body > 0:
83
+ if not line.startswith("\\"): # "" is not one of the counted lines
84
+ body -= 1
85
+ continue
86
+ if line.startswith("+++ "):
87
+ name = line[4:].strip()
88
+ current = None if name == "/dev/null" else name[2:] if name.startswith("b/") else name
89
+ if current is not None:
90
+ files.setdefault(current, [])
91
+ continue
92
+ m = HUNK.match(line)
93
+ if m:
94
+ old_count = int(m.group(1)) if m.group(1) is not None else 1
95
+ start, count = int(m.group(2)), int(m.group(3)) if m.group(3) is not None else 1
96
+ body = old_count + count
97
+ if current is not None:
98
+ first = max(start, 1)
99
+ files[current].append((first, first + max(count, 1) - 1))
100
+ return base, files
101
+
102
+
103
+ def _reached(root: Path, files: list[str], changed: dict[str, list[tuple[int, int]]], sites: list[dict]) -> tuple[set[str], int, bool]:
104
+ """(ids of sites inside functions reached from changed functions, changed functions, whether a graph was built)."""
105
+ from .discover import LANG_BY_EXT
106
+ from .discover import origins
107
+
108
+ by_lang: dict[str, list[str]] = {}
109
+ for f in files:
110
+ lang = LANG_BY_EXT.get(os.path.splitext(f)[1])
111
+ if lang:
112
+ by_lang.setdefault(lang, []).append(f)
113
+ try:
114
+ ix, langs, _entries, callers = origins.build(root, by_lang, origins.load_entry_rules())
115
+ except Exception: # no grammar, or a parse the graph cannot survive: fall back to changed files alone, and say so
116
+ return set(), 0, False
117
+ start: set[int] = set()
118
+ for name, ranges in changed.items():
119
+ for fn in ix.by_file.get(name, ()):
120
+ if fn.module:
121
+ continue # the whole file as one pseudo function: its sites are in scope as `changed_file` already
122
+ if any(fn.start <= last and fn.end >= first for first, last in ranges):
123
+ start.add(fn.id)
124
+ callees: dict[int, list[int]] = {}
125
+ for callee, who in callers.items():
126
+ for caller in who:
127
+ callees.setdefault(caller, []).append(callee)
128
+ depth = {fid: 0 for fid in start}
129
+ todo = deque(start)
130
+ while todo:
131
+ fid = todo.popleft()
132
+ if depth[fid] >= MAX_HOPS:
133
+ continue
134
+ for nxt in callees.get(fid, ()):
135
+ if nxt not in depth:
136
+ depth[nxt] = depth[fid] + 1
137
+ todo.append(nxt)
138
+ hit: set[str] = set()
139
+ for s in sites:
140
+ if s.get("language") not in langs or not s.get("id"):
141
+ continue
142
+ fn = ix.at_line(s["file"], s["line"])
143
+ while fn is not None: # a query in a closure belongs to the function around it too
144
+ if fn.id in depth and not fn.module:
145
+ hit.add(s["id"])
146
+ break
147
+ fn = fn.lex
148
+ return hit, len(start), True
149
+
150
+
151
+ def tables_changed(inventory: dict, changed: dict[str, list[tuple[int, int]]]) -> set[str]:
152
+ """Names (without database) of the tables whose definition the change touches. A definition runs from the
153
+ line discover found it at to the line before the next definition in the same file."""
154
+ by_file: dict[str, list[tuple[int, str]]] = {}
155
+ for t in inventory.get("tables") or []:
156
+ for at in t.get("defined_at") or []:
157
+ file, _, line = str(at).rpartition(":")
158
+ if file and line.isdigit():
159
+ by_file.setdefault(file, []).append((int(line), str(t.get("name") or "").split(".")[-1]))
160
+ hit: set[str] = set()
161
+ for file, defs in by_file.items():
162
+ ranges = changed.get(file)
163
+ if not ranges:
164
+ continue
165
+ defs.sort()
166
+ for i, (line, name) in enumerate(defs):
167
+ end = defs[i + 1][0] - 1 if i + 1 < len(defs) else float("inf")
168
+ if name and any(first <= end and last >= line for first, last in ranges):
169
+ hit.add(name)
170
+ return hit
171
+
172
+
173
+ REASONS = ("changed_file", "reached_from_changed_code", "table_definition_changed")
174
+
175
+
176
+ def compute(root: Path, inventory: dict, ref: str, include: list[str] | None = None) -> dict:
177
+ """The scope of a change: which call sites of `inventory` it can affect, and why each is in."""
178
+ from .discover import list_files
179
+
180
+ root = root.resolve()
181
+ base, changed = changed_lines(root, ref)
182
+ sites = inventory.get("call_sites") or []
183
+ # The second engine of a multi-engine scan asks the same question: answer it once per process.
184
+ key = (str(root), ref, base, repr(sorted(changed.items())), inventory.get("generated_at"), len(sites), tuple(include or ()))
185
+ if key in _CACHE:
186
+ return _CACHE[key]
187
+ in_files = {s["id"] for s in sites if s.get("id") and s["file"] in changed}
188
+ files = list_files(root)
189
+ if include:
190
+ files = [f for f in files if any(f == p or f.startswith(p.rstrip("/") + "/") for p in include)]
191
+ reached, functions, graph = _reached(root, files, changed, sites) if changed else (set(), 0, True)
192
+ reasons = {i: "changed_file" for i in in_files}
193
+ for i in reached - in_files:
194
+ reasons[i] = "reached_from_changed_code"
195
+ tables = tables_changed(inventory, changed)
196
+ for s in sites:
197
+ if s.get("id") and s["id"] not in reasons and any(str(t).split(".")[-1] in tables for t in s.get("tables") or []):
198
+ reasons[s["id"]] = "table_definition_changed"
199
+ head = ""
200
+ try:
201
+ head = _git(root, "rev-parse", "HEAD").strip()
202
+ except ChangedError:
203
+ pass
204
+ scope = {
205
+ "mode": "changed_since", "ref": ref, "base": base, "head": head,
206
+ "files_changed": len(changed), "functions_changed": functions, "tables_changed": sorted(tables),
207
+ "call_graph": graph, "max_hops": MAX_HOPS, "sites_total": len(sites), "sites": len(reasons),
208
+ "by_reason": {r: sum(1 for v in reasons.values() if v == r) for r in REASONS},
209
+ "site_ids": sorted(reasons), "reasons": reasons,
210
+ }
211
+ _CACHE[key] = scope
212
+ return scope
213
+
214
+
215
+ def activate(root: Path, inventory: dict, ref: str, include: list[str] | None = None) -> dict:
216
+ global ACTIVE
217
+ ACTIVE = compute(root, inventory, ref, include)
218
+ return ACTIVE
219
+
220
+
221
+ def clear() -> None:
222
+ global ACTIVE
223
+ ACTIVE = None
224
+
225
+
226
+ def restrict(inventory: dict) -> dict:
227
+ """The inventory the rank stage plans from: all of it, or, in a --changed-since scan, the call sites in scope.
228
+ Tables and entry points stay whole: the agent still needs every definition."""
229
+ if ACTIVE is None:
230
+ return inventory
231
+ keep = set(ACTIVE["site_ids"])
232
+ return {**inventory, "call_sites": [s for s in inventory.get("call_sites") or [] if s.get("id") in keep]}
233
+
234
+
235
+ def stamp(rank_result: dict) -> dict:
236
+ """Record the scope in rank.json, so everything read from it later knows the run was partial."""
237
+ if ACTIVE is not None:
238
+ rank_result["scope"] = {k: v for k, v in ACTIVE.items() if k != "reasons"}
239
+ return rank_result
240
+
241
+
242
+ def scope_of(out_dir: Path) -> dict | None:
243
+ """The scope recorded by the scan that wrote this out dir (or any engine directory under it); None for a full scan."""
244
+ for path in [out_dir / "rank.json", *sorted(out_dir.glob("*/rank.json"))]:
245
+ try:
246
+ scope = json.loads(path.read_text()).get("scope")
247
+ except (OSError, ValueError, AttributeError):
248
+ continue
249
+ if isinstance(scope, dict) and scope.get("mode") == "changed_since":
250
+ return scope
251
+ return None
252
+
253
+
254
+ def describe(scope: dict) -> str:
255
+ by = scope["by_reason"]
256
+ text = (f"{scope['sites']:,} of {scope['sites_total']:,} call sites are in scope: {by['changed_file']:,} in the "
257
+ f"{scope['files_changed']:,} changed files, {by['reached_from_changed_code']:,} reached from "
258
+ f"{scope['functions_changed']:,} changed functions")
259
+ if scope.get("tables_changed"):
260
+ text += f", {by.get('table_definition_changed', 0):,} reading {len(scope['tables_changed']):,} tables whose definition changed"
261
+ return text + ("" if scope["call_graph"] else " (the call graph could not be built: changed files only)")