@eagleoutice/flowr 2.15.9 → 2.15.10

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 (112) hide show
  1. package/README.md +34 -25
  2. package/abstract-interpretation/absint-inference.d.ts +2 -2
  3. package/abstract-interpretation/absint-inference.js +32 -79
  4. package/benchmark/slicer.d.ts +0 -1
  5. package/benchmark/slicer.js +1 -2
  6. package/cli/repl/commands/repl-signature.js +12 -3
  7. package/config.d.ts +5 -1
  8. package/control-flow/cfg-properties.js +0 -22
  9. package/control-flow/happens-before.d.ts +2 -2
  10. package/control-flow/happens-before.js +29 -19
  11. package/dataflow/environments/apply-kill.js +6 -2
  12. package/dataflow/environments/built-in-config.d.ts +2 -0
  13. package/dataflow/environments/built-in-props.d.ts +7 -1
  14. package/dataflow/environments/built-in-props.js +8 -1
  15. package/dataflow/environments/built-in.d.ts +7 -2
  16. package/dataflow/environments/built-in.js +11 -5
  17. package/dataflow/environments/default-builtin-config.d.ts +386 -8
  18. package/dataflow/environments/default-builtin-config.js +84 -22
  19. package/dataflow/environments/define.d.ts +3 -2
  20. package/dataflow/environments/define.js +4 -3
  21. package/dataflow/environments/deprecation-info.d.ts +45 -0
  22. package/dataflow/environments/deprecation-info.js +13 -0
  23. package/dataflow/environments/environment.d.ts +1 -1
  24. package/dataflow/environments/environment.js +5 -4
  25. package/dataflow/environments/identifier.d.ts +2 -0
  26. package/dataflow/extractor.js +6 -1
  27. package/dataflow/fn/class-declaration.d.ts +0 -11
  28. package/dataflow/fn/class-declaration.js +0 -20
  29. package/dataflow/fn/higher-order-function.d.ts +9 -1
  30. package/dataflow/fn/higher-order-function.js +14 -7
  31. package/dataflow/fn/strict-function.js +8 -3
  32. package/dataflow/graph/graph.d.ts +7 -0
  33. package/dataflow/graph/graph.js +17 -0
  34. package/dataflow/graph/vertex.d.ts +1 -1
  35. package/dataflow/internal/linker.d.ts +3 -0
  36. package/dataflow/internal/linker.js +67 -6
  37. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.d.ts +113 -0
  38. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +506 -0
  39. package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +9 -0
  40. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +2 -0
  41. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +22 -19
  42. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +5 -1
  43. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +21 -14
  44. package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +14 -4
  45. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +22 -2
  46. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +2 -0
  47. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +4 -3
  48. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +19 -3
  49. package/dataflow/internal/process/functions/call/built-in/built-in-local.js +7 -3
  50. package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +2 -0
  51. package/dataflow/internal/process/functions/call/built-in/built-in-s-four.d.ts +4 -2
  52. package/dataflow/internal/process/functions/call/built-in/built-in-s-four.js +3 -5
  53. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +2 -1
  54. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +8 -0
  55. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +2 -0
  56. package/dataflow/internal/process/functions/call/common.d.ts +3 -1
  57. package/dataflow/internal/process/functions/call/common.js +22 -4
  58. package/dataflow/internal/process/functions/call/deferred.d.ts +6 -0
  59. package/dataflow/internal/process/functions/call/deferred.js +33 -12
  60. package/dataflow/internal/process/functions/call/known-call-handling.js +1 -1
  61. package/dataflow/internal/process/functions/call/named-call-handling.js +15 -0
  62. package/dataflow/internal/process/functions/call/quoted.js +137 -24
  63. package/dataflow/internal/process/process-symbol.js +6 -2
  64. package/documentation/data/faq/faqs.js +3 -3
  65. package/documentation/data/interface/doc-writing-code.js +1 -2
  66. package/documentation/data/server/doc-data-server-messages.js +7 -7
  67. package/documentation/doc-capabilities.js +80 -34
  68. package/documentation/doc-util/doc-query.d.ts +0 -3
  69. package/documentation/doc-util/doc-query.js +4 -3
  70. package/documentation/wiki-analyzer.js +1 -1
  71. package/documentation/wiki-cfg.js +5 -6
  72. package/documentation/wiki-core.js +8 -8
  73. package/documentation/wiki-dataflow-graph.js +10 -11
  74. package/documentation/wiki-interface.js +2 -2
  75. package/documentation/wiki-linting-and-testing.js +3 -3
  76. package/documentation/wiki-overview.js +6 -6
  77. package/documentation/wiki-query.js +9 -101
  78. package/documentation/wiki-signature-database.js +1 -1
  79. package/linter/linter-rules.d.ts +1 -1
  80. package/linter/rules/deprecated-functions.d.ts +1 -45
  81. package/linter/rules/deprecated-functions.js +24 -33
  82. package/package.json +1 -1
  83. package/project/flowr-analyzer.d.ts +2 -0
  84. package/project/flowr-analyzer.js +24 -1
  85. package/project/plugins/file-plugins/files/flowr-rda-file.d.ts +0 -2
  86. package/project/plugins/file-plugins/files/flowr-rda-file.js +10 -55
  87. package/project/plugins/file-plugins/flowr-analyzer-file-plugin.js +2 -1
  88. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +6 -4
  89. package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +2 -2
  90. package/project/sigdb/build.js +4 -0
  91. package/project/sigdb/manifest.d.ts +2 -0
  92. package/project/sigdb/manifest.js +10 -1
  93. package/project/sigdb/reader.js +23 -61
  94. package/project/sigdb/sigdb-download.d.ts +29 -6
  95. package/project/sigdb/sigdb-download.js +212 -64
  96. package/queries/catalog/call-context-query/cascade-action.d.ts +3 -1
  97. package/queries/catalog/call-context-query/cascade-action.js +2 -0
  98. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +3 -0
  99. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +2 -1
  100. package/queries/catalog/origin-query/origin-query-executor.d.ts +1 -1
  101. package/queries/catalog/origin-query/origin-query-executor.js +2 -2
  102. package/queries/catalog/origin-query/origin-query-format.d.ts +2 -2
  103. package/queries/catalog/origin-query/origin-query-format.js +1 -1
  104. package/queries/query.d.ts +1 -1
  105. package/r-bridge/data/data.d.ts +21 -14
  106. package/r-bridge/data/data.js +28 -20
  107. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.d.ts +2 -2
  108. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +11 -2
  109. package/util/files.d.ts +2 -0
  110. package/util/files.js +3 -1
  111. package/util/mermaid/mermaid.js +6 -2
  112. package/util/version.js +2 -2
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.SigDbRemoteFileName = exports.sha256File = void 0;
6
+ exports.isManifestFile = exports.SigDbDownloadError = exports.SigDbRemoteFileName = exports.sha256File = void 0;
7
7
  exports.selectDownloadVariants = selectDownloadVariants;
8
8
  exports.downloadFullSigDb = downloadFullSigDb;
9
9
  exports.syncedSigDbDir = syncedSigDbDir;
@@ -12,6 +12,7 @@ exports.sigDbCacheComplete = sigDbCacheComplete;
12
12
  exports.sigDbNeedsSync = sigDbNeedsSync;
13
13
  const fs_1 = __importDefault(require("fs"));
14
14
  const path_1 = __importDefault(require("path"));
15
+ const http_1 = __importDefault(require("http"));
15
16
  const https_1 = __importDefault(require("https"));
16
17
  const crypto_1 = __importDefault(require("crypto"));
17
18
  const decompress_1 = require("./decompress");
@@ -24,10 +25,22 @@ function ghHeaders(accept, withAuth) {
24
25
  const token = withAuth ? (process.env.GH_TOKEN ?? process.env.GITHUB_TOKEN) : undefined;
25
26
  return { 'User-Agent': 'flowr', Accept: accept, ...(token ? { Authorization: `Bearer ${token}` } : {}) };
26
27
  }
28
+ /** how long a connection may stay silent before we give up on it */
29
+ const IdleTimeoutMs = 30_000;
30
+ /** attempts per request, so a flaky connection does not fail a whole sync */
31
+ const MaxAttempts = 3;
32
+ /** an HTTP failure; `retryable` for server-side and rate-limit errors */
33
+ class HttpError extends Error {
34
+ retryable;
35
+ constructor(message, retryable) {
36
+ super(message);
37
+ this.retryable = retryable;
38
+ }
39
+ }
27
40
  /** GET following redirects (GitHub asset URLs redirect to a storage host); resolves the final response for streaming */
28
41
  function httpGet(url, accept, redirects = 5, withAuth = true) {
29
42
  return new Promise((resolve, reject) => {
30
- https_1.default.get(url, { headers: ghHeaders(accept, withAuth) }, res => {
43
+ const req = (url.startsWith('http:') ? http_1.default : https_1.default).get(url, { headers: ghHeaders(accept, withAuth) }, res => {
31
44
  const status = res.statusCode ?? 0;
32
45
  if (status >= 300 && status < 400 && res.headers.location && redirects > 0) {
33
46
  res.resume();
@@ -42,11 +55,29 @@ function httpGet(url, accept, redirects = 5, withAuth = true) {
42
55
  }
43
56
  else {
44
57
  res.resume();
45
- reject(new Error(`GET ${url} -> HTTP ${status}`));
58
+ reject(new HttpError(`GET ${url} -> HTTP ${status}`, status >= 500 || status === 429 || status === 408));
46
59
  }
47
- }).on('error', reject);
60
+ });
61
+ req.setTimeout(IdleTimeoutMs, () => req.destroy(new Error(`GET ${url} -> no data for ${IdleTimeoutMs / 1000}s`)));
62
+ req.on('error', reject);
48
63
  });
49
64
  }
65
+ /** runs `attempt` until it succeeds, retrying network and server errors with a growing pause */
66
+ async function withRetries(what, attempt, progress) {
67
+ for (let i = 1;; i++) {
68
+ try {
69
+ return await attempt();
70
+ }
71
+ catch (e) {
72
+ const retryable = !(e instanceof HttpError) || e.retryable;
73
+ if (!retryable || i >= MaxAttempts) {
74
+ throw e;
75
+ }
76
+ progress(`${what} failed (${e.message}), retry ${i}/${MaxAttempts - 1}`);
77
+ await new Promise(r => setTimeout(r, 1000 * i));
78
+ }
79
+ }
80
+ }
50
81
  async function readJson(url) {
51
82
  const res = await httpGet(url, 'application/vnd.github+json');
52
83
  const chunks = [];
@@ -55,22 +86,62 @@ async function readJson(url) {
55
86
  }
56
87
  return JSON.parse(Buffer.concat(chunks).toString('utf8'));
57
88
  }
58
- async function downloadTo(url, dest) {
59
- const res = await httpGet(url, 'application/octet-stream');
60
- await new Promise((resolve, reject) => {
61
- const out = fs_1.default.createWriteStream(dest);
62
- res.on('error', reject);
63
- out.on('error', reject).on('finish', () => out.close(err => err ? reject(err) : resolve()));
64
- res.pipe(out);
65
- });
89
+ const mb = (bytes) => `${(bytes / 1e6).toFixed(1)} MB`;
90
+ const rate = (bytes, ms) => `${(bytes / 1e6 / Math.max(ms / 1000, 0.001)).toFixed(1)} MB/s`;
91
+ /** Download `url` to `dest` via a temporary file, so a partial or corrupt file never lands there (checked against `sha256`, if given). */
92
+ async function downloadTo(url, dest, name, progress, expected) {
93
+ const part = `${dest}.${process.pid}.part`;
94
+ const start = Date.now();
95
+ try {
96
+ const res = await httpGet(url, 'application/octet-stream');
97
+ const total = expected?.bytes ?? Number(res.headers['content-length'] ?? 0);
98
+ let received = 0;
99
+ let nextReport = 0.25;
100
+ const hash = crypto_1.default.createHash('sha256');
101
+ res.on('data', (chunk) => {
102
+ received += chunk.length;
103
+ hash.update(chunk);
104
+ if (total > 5e6 && received / total >= nextReport && received < total) {
105
+ progress(` ${name}: ${Math.floor(received / total * 100)}% (${mb(received)} of ${mb(total)}, ${rate(received, Date.now() - start)})`);
106
+ nextReport += 0.25;
107
+ }
108
+ });
109
+ await new Promise((resolve, reject) => {
110
+ const out = fs_1.default.createWriteStream(part);
111
+ res.on('error', reject).on('aborted', () => reject(new Error(`connection closed after ${mb(received)}`)));
112
+ out.on('error', reject).on('finish', () => out.close(err => err ? reject(err) : resolve()));
113
+ res.pipe(out);
114
+ });
115
+ if (expected === undefined && total > 0 && received !== total) {
116
+ throw new Error(`expected ${total} bytes but got ${received}`);
117
+ }
118
+ if (expected !== undefined) {
119
+ if (received !== expected.bytes) {
120
+ throw new Error(`expected ${expected.bytes} bytes but got ${received}`);
121
+ }
122
+ const actual = hash.digest('hex');
123
+ if (actual !== expected.sha256) {
124
+ throw new Error(`sha256 mismatch (expected ${expected.sha256.slice(0, 12)}..., got ${actual.slice(0, 12)}...); the download is corrupt or sigdb.remote.json is outdated`);
125
+ }
126
+ }
127
+ fs_1.default.renameSync(part, dest);
128
+ return received;
129
+ }
130
+ finally {
131
+ fs_1.default.rmSync(part, { force: true });
132
+ }
66
133
  }
67
134
  /** hex sha256 of a file's contents (shared by the runtime verify and the `sigdb-remote` pointer generator) */
68
135
  const sha256File = (p) => crypto_1.default.createHash('sha256').update(fs_1.default.readFileSync(p)).digest('hex');
69
136
  exports.sha256File = sha256File;
70
137
  /** the committed link file naming every downloadable shard (base floor + CRAN sets); only this pointer is committed */
71
138
  exports.SigDbRemoteFileName = 'sigdb.remote.json';
72
- /** locate the committed `sigdb.remote.json` link file in the sigdb data dir (dev `src`, built `dist`) */
139
+ /** locate the committed `sigdb.remote.json` link file in the sigdb data dir (dev `src`, built `dist`), or the one `$FLOWR_SIGDB_REMOTE` names */
73
140
  function findRemotePointer() {
141
+ const override = process.env.FLOWR_SIGDB_REMOTE;
142
+ if (override) {
143
+ return fs_1.default.existsSync(override) ? override : undefined;
144
+ }
74
145
  const candidates = [
75
146
  path_1.default.join(__dirname, '../../data/sigdb', exports.SigDbRemoteFileName), // src/ and dist/src/ layouts (same depth)
76
147
  path_1.default.join(process.cwd(), 'src/data/sigdb', exports.SigDbRemoteFileName),
@@ -86,8 +157,8 @@ function findRemotePointer() {
86
157
  });
87
158
  }
88
159
  const readPointer = (p) => JSON.parse(fs_1.default.readFileSync(p, 'utf8'));
89
- /** the direct release-asset CDN URL -- bypasses the REST API (and its rate limit) entirely */
90
- const assetUrl = (repo, tag, name) => `https://github.com/${repo}/releases/download/${tag}/${encodeURIComponent(name)}`;
160
+ /** the direct release-asset URL, which avoids the REST API rate limit; `$FLOWR_SIGDB_MIRROR` replaces the host */
161
+ const assetUrl = (repo, tag, name) => `${process.env.FLOWR_SIGDB_MIRROR ?? 'https://github.com'}/${repo}/releases/download/${tag}/${encodeURIComponent(name)}`;
91
162
  /** runtime-decodable variant extensions, most-preferred first, ending in plain (`''`) as a last resort */
92
163
  function downloadVariantOrder() {
93
164
  return [...(0, codec_1.readableExtsPreferred)(), ''];
@@ -123,70 +194,150 @@ function selectDownloadVariants(names) {
123
194
  /** pick the richest manifest among downloaded files (a `full`/scope manifest first, else any) */
124
195
  const pickManifest = (files) => files.find(f => new RegExp(`full\\.manifest\\.json${codec_1.CompressedExtPattern}$`).test(f))
125
196
  ?? files.find(f => new RegExp(`\\.manifest\\.json${codec_1.CompressedExtPattern}$`).test(f));
197
+ /** Thrown when some files of a bundle could not be fetched; the others are cached, so a retry only fetches the rest. */
198
+ class SigDbDownloadError extends Error {
199
+ tag;
200
+ failed;
201
+ completed;
202
+ constructor(tag, failed, completed) {
203
+ super(`could not fetch ${failed.length} of ${failed.length + completed} file(s) of ${tag}: ${failed.map(f => `${f.name} (${f.reason})`).join('; ')}`);
204
+ this.tag = tag;
205
+ this.failed = failed;
206
+ this.completed = completed;
207
+ }
208
+ }
209
+ exports.SigDbDownloadError = SigDbDownloadError;
210
+ /** whether the file is a manifest (in any codec); these go last as they reference the shards */
211
+ const isManifestFile = (name) => new RegExp(`\\.manifest\\.json${codec_1.CompressedExtPattern}$`).test(name);
212
+ exports.isManifestFile = isManifestFile;
213
+ /** the bundle directories of other tags in the cache, so a sync can say what it leaves behind */
214
+ function staleBundleDirs(current) {
215
+ const bundles = path_1.default.dirname(current);
216
+ try {
217
+ return fs_1.default.readdirSync(bundles, { withFileTypes: true })
218
+ .filter(e => e.isDirectory() && path_1.default.join(bundles, e.name) !== current)
219
+ .map(e => path_1.default.join(bundles, e.name));
220
+ }
221
+ catch {
222
+ return [];
223
+ }
224
+ }
225
+ /** whether the cached copy at `dest` can be kept */
226
+ function isCached(dest, file) {
227
+ try {
228
+ const size = fs_1.default.statSync(dest).size;
229
+ if (file.expected !== undefined) {
230
+ return size === file.expected.bytes && (0, exports.sha256File)(dest) === file.expected.sha256;
231
+ }
232
+ return file.size === undefined || size === file.size;
233
+ }
234
+ catch {
235
+ return false;
236
+ }
237
+ }
238
+ async function syncFiles(tag, repo, planned, opts) {
239
+ const progress = opts.onProgress ?? (() => { });
240
+ const start = Date.now();
241
+ const dir = path_1.default.join((0, decompress_1.sigDbCacheDir)(), 'bundles', tag);
242
+ fs_1.default.mkdirSync(dir, { recursive: true });
243
+ const ordered = [...planned.filter(p => !(0, exports.isManifestFile)(p.name)), ...planned.filter(p => (0, exports.isManifestFile)(p.name))];
244
+ const missing = ordered.filter(p => opts.force || !isCached(path_1.default.join(dir, p.name), p));
245
+ const toFetch = missing.reduce((sum, p) => sum + (p.expected?.bytes ?? p.size ?? 0), 0);
246
+ progress(`signature database ${tag} from ${repo}: ${ordered.length} file(s), ${ordered.length - missing.length} up to date, ${missing.length} to fetch (${mb(toFetch)}) into ${dir}`);
247
+ const files = [];
248
+ const downloaded = [];
249
+ const failed = [];
250
+ let bytes = 0;
251
+ for (const file of ordered) {
252
+ const dest = path_1.default.join(dir, file.name);
253
+ if (!missing.includes(file)) {
254
+ files.push(dest);
255
+ continue;
256
+ }
257
+ if ((0, exports.isManifestFile)(file.name) && failed.length > 0) {
258
+ failed.push({ name: file.name, reason: 'skipped, as the shards it references are incomplete' });
259
+ continue;
260
+ }
261
+ const size = file.expected?.bytes ?? file.size;
262
+ progress(`downloading ${file.name}${size === undefined ? '' : ` (${mb(size)})`}`);
263
+ const fileStart = Date.now();
264
+ try {
265
+ const got = await withRetries(file.name, () => downloadTo(file.url, dest, file.name, progress, file.expected), progress);
266
+ bytes += got;
267
+ progress(` ${file.name}: done in ${((Date.now() - fileStart) / 1000).toFixed(1)}s (${rate(got, Date.now() - fileStart)})${file.expected ? ', checksum verified' : ''}`);
268
+ files.push(dest);
269
+ downloaded.push(dest);
270
+ }
271
+ catch (e) {
272
+ const reason = e.message;
273
+ progress(` ${file.name}: failed (${reason})`);
274
+ failed.push({ name: file.name, reason });
275
+ }
276
+ }
277
+ const ms = Date.now() - start;
278
+ if (failed.length > 0) {
279
+ throw new SigDbDownloadError(tag, failed, files.length);
280
+ }
281
+ /* the bundle synced last takes precedence over the others in the cache, even if nothing had to be fetched */
282
+ const now = new Date();
283
+ fs_1.default.utimesSync(dir, now, now);
284
+ const stale = staleBundleDirs(dir);
285
+ progress(downloaded.length === 0
286
+ ? `signature database ${tag} is up to date`
287
+ : `signature database ${tag}: fetched ${downloaded.length} file(s), ${mb(bytes)} in ${(ms / 1000).toFixed(1)}s`);
288
+ if (stale.length > 0) {
289
+ progress(`the cache still holds ${stale.length} bundle(s) of other releases: ${stale.map(d => path_1.default.basename(d)).join(', ')} (in ${path_1.default.dirname(dir)}); the most recently synced one takes precedence, delete the others to free the space`);
290
+ }
291
+ return { tag, dir, manifest: pickManifest(files), files, downloaded, bytes, ms, stale };
292
+ }
293
+ /** read the committed link file, naming it in the error when it is broken */
294
+ function readPointerChecked(p) {
295
+ let remote;
296
+ try {
297
+ remote = readPointer(p);
298
+ }
299
+ catch (e) {
300
+ throw new Error(`cannot read the signature database link file ${p}: ${e.message}`, { cause: e });
301
+ }
302
+ if (typeof remote.tag !== 'string' || typeof remote.shards !== 'object' || remote.shards === null) {
303
+ throw new Error(`the signature database link file ${p} names no tag or shards`);
304
+ }
305
+ return remote;
306
+ }
126
307
  /**
127
- * Download the signature-database shards into the cache directory and return where they landed. Prefers the
128
- * committed `sigdb.remote.json`, we verify each download by content hash, and **skip shards already
129
- * present with the right hash**.
308
+ * Downloads the signature-database shards into the cache, verified by hash and skipping cached ones. A failing file
309
+ * does not stop the others; a {@link SigDbDownloadError} names what is missing at the end.
130
310
  * Use the returned {@link SigDbDownloadResult.manifest}, or point `solver.sigdb.additionalPaths` at the dir.
131
311
  */
132
312
  async function downloadFullSigDb(opts = {}) {
133
313
  const progress = opts.onProgress ?? (() => { });
134
314
  const pointerPath = findRemotePointer();
135
315
  if (pointerPath) {
136
- const remote = readPointer(pointerPath);
316
+ const remote = readPointerChecked(pointerPath);
137
317
  const repo = opts.repo ?? remote.repo ?? DefaultRepo;
138
- const tag = remote.tag;
139
- const dir = path_1.default.join((0, decompress_1.sigDbCacheDir)(), 'bundles', tag);
140
- fs_1.default.mkdirSync(dir, { recursive: true });
141
318
  // one variant per logical shard/dictionary -- the best this runtime can decompress (never both codecs)
142
- const picked = selectDownloadVariants(Object.keys(remote.shards));
143
- progress(`syncing ${picked.length} shards for ${tag} from ${repo}`);
144
- const files = [];
145
- for (const name of picked) {
146
- const meta = remote.shards[name];
147
- const dest = path_1.default.join(dir, name);
148
- if (!opts.force && fs_1.default.existsSync(dest) && (0, exports.sha256File)(dest) === meta.sha256) {
149
- progress(`have ${name}`);
150
- }
151
- else {
152
- progress(`downloading ${name} (${(meta.bytes / 1e6).toFixed(1)} MB)`);
153
- await downloadTo(assetUrl(repo, tag, name), dest);
154
- if ((0, exports.sha256File)(dest) !== meta.sha256) {
155
- throw new Error(`sha256 mismatch for ${name} (${tag}); the download is corrupt -- retry, or regenerate sigdb.remote.json`);
156
- }
157
- }
158
- files.push(dest);
159
- }
160
- return { dir, manifest: pickManifest(files), files };
319
+ const planned = selectDownloadVariants(Object.keys(remote.shards)).map(name => ({
320
+ name, url: assetUrl(repo, remote.tag, name), expected: remote.shards[name]
321
+ }));
322
+ return syncFiles(remote.tag, repo, planned, opts);
161
323
  }
162
324
  // fallback: no committed link file -> list the release via the API and download by size
163
325
  const repo = opts.repo ?? DefaultRepo;
164
326
  const version = opts.version ?? (0, version_1.flowrVersion)().toString();
165
327
  const tag = `sigdb-v${version}`;
166
- progress(`fetching release ${tag} from ${repo}`);
167
- const release = await readJson(`https://api.github.com/repos/${repo}/releases/tags/${tag}`);
328
+ progress(`no sigdb.remote.json found, listing release ${tag} of ${repo}`);
329
+ const release = await withRetries(`listing ${tag}`, () => readJson(`https://api.github.com/repos/${repo}/releases/tags/${tag}`), progress);
168
330
  const assets = (release.assets ?? [])
169
331
  .filter(a => a.name.endsWith('.br') || a.name.endsWith('.zst') || a.name.endsWith('.manifest.json'));
170
332
  if (assets.length === 0) {
171
333
  throw new Error(`release ${tag} in ${repo} has no signature-database assets${typeof release.message === 'string' ? ` (${release.message})` : ''}`);
172
334
  }
173
- const dir = path_1.default.join((0, decompress_1.sigDbCacheDir)(), 'bundles', tag);
174
- fs_1.default.mkdirSync(dir, { recursive: true });
175
335
  const byName = new Map(assets.map(a => [a.name, a]));
176
- const files = [];
177
- for (const name of selectDownloadVariants(byName.keys())) {
336
+ const planned = selectDownloadVariants(byName.keys()).map(name => {
178
337
  const a = byName.get(name);
179
- const dest = path_1.default.join(dir, name);
180
- if (!opts.force && fs_1.default.existsSync(dest) && fs_1.default.statSync(dest).size === a.size) {
181
- progress(`have ${name}`);
182
- }
183
- else {
184
- progress(`downloading ${name} (${(a.size / 1e6).toFixed(1)} MB)`);
185
- await downloadTo(a.browser_download_url, dest);
186
- }
187
- files.push(dest);
188
- }
189
- return { dir, manifest: pickManifest(files), files };
338
+ return { name, url: a.browser_download_url, size: a.size };
339
+ });
340
+ return syncFiles(tag, repo, planned, opts);
190
341
  }
191
342
  /**
192
343
  * The cache dir a {@link downloadFullSigDb} for the committed link file would populate, or `undefined` if no
@@ -237,7 +388,7 @@ function sigDbCacheComplete() {
237
388
  return false;
238
389
  }
239
390
  }
240
- /** Startup check: `true` when a committed link file lists shards whose cached copies are missing or hash-mismatched */
391
+ /** Startup check: `true` when a committed link file lists shards whose cached copies are missing or mismatched */
241
392
  function sigDbNeedsSync() {
242
393
  const pointerPath = findRemotePointer();
243
394
  if (!pointerPath) {
@@ -245,11 +396,8 @@ function sigDbNeedsSync() {
245
396
  }
246
397
  try {
247
398
  const remote = readPointer(pointerPath);
248
- const dir = path_1.default.join((0, decompress_1.sigDbCacheDir)(), 'bundles', remote.tag);
249
- return Object.entries(remote.shards).some(([name, meta]) => {
250
- const dest = path_1.default.join(dir, name);
251
- return !fs_1.default.existsSync(dest) || (0, exports.sha256File)(dest) !== meta.sha256;
252
- });
399
+ const dir = path_1.default.join((0, decompress_1.sigDbCacheDir)(undefined, false), 'bundles', remote.tag);
400
+ return selectDownloadVariants(Object.keys(remote.shards)).some(name => !isCached(path_1.default.join(dir, name), { name, url: '', expected: remote.shards[name] }));
253
401
  }
254
402
  catch {
255
403
  return false;
@@ -4,5 +4,7 @@ export declare enum CascadeAction {
4
4
  /** The action is to continue the cascade */
5
5
  Continue = "continue",
6
6
  /** The action is to skip the current node */
7
- Skip = "skip"
7
+ Skip = "skip",
8
+ /** The action is to stop the search along this path without linking the current node */
9
+ Block = "block"
8
10
  }
@@ -9,5 +9,7 @@ var CascadeAction;
9
9
  CascadeAction["Continue"] = "continue";
10
10
  /** The action is to skip the current node */
11
11
  CascadeAction["Skip"] = "skip";
12
+ /** The action is to stop the search along this path without linking the current node */
13
+ CascadeAction["Block"] = "block";
12
14
  })(CascadeAction || (exports.CascadeAction = CascadeAction = {}));
13
15
  //# sourceMappingURL=cascade-action.js.map
@@ -206,6 +206,9 @@ function identifyLinkToLastCallRelationSync(from, cfg, graph, { callName, cascad
206
206
  if (act === cascade_action_1.CascadeAction.Skip) {
207
207
  return;
208
208
  }
209
+ else if (act === cascade_action_1.CascadeAction.Block) {
210
+ return true;
211
+ }
209
212
  const tar = satisfiesCallTargets(vertex, graph, CallTargets.MustIncludeGlobal);
210
213
  if (tar !== 'no') {
211
214
  found.push(node);
@@ -16,9 +16,10 @@ async function executeHigherOrderQuery({ analyzer }, queries) {
16
16
  if (filterFor.size === 0 || filterFor.size > 10) {
17
17
  invertedGraph = df_helper_1.Dataflow.invertGraph(graph, analyzer.inspectContext().env.makeCleanEnv());
18
18
  }
19
+ const argumentFacts = new Map();
19
20
  const result = {};
20
21
  for (const id of fns) {
21
- result[id] = function_semantics_1.FunctionSemantics.isHigherOrder(id, graph, { ctx: analyzer.inspectContext(), invertedGraph });
22
+ result[id] = function_semantics_1.FunctionSemantics.isHigherOrder(id, graph, { ctx: analyzer.inspectContext(), invertedGraph, argumentFacts });
22
23
  }
23
24
  return {
24
25
  '.meta': {
@@ -8,4 +8,4 @@ export declare function fingerPrintOfQuery(query: OriginQuery): SlicingCriterion
8
8
  /**
9
9
  * Execute origin queries, catching duplicates with the same fingerprint
10
10
  */
11
- export declare function executeResolveValueQuery({ analyzer }: BasicQueryData, queries: readonly OriginQuery[]): Promise<OriginQueryResult>;
11
+ export declare function executeOriginQuery({ analyzer }: BasicQueryData, queries: readonly OriginQuery[]): Promise<OriginQueryResult>;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.fingerPrintOfQuery = fingerPrintOfQuery;
4
- exports.executeResolveValueQuery = executeResolveValueQuery;
4
+ exports.executeOriginQuery = executeOriginQuery;
5
5
  const log_1 = require("../../../util/log");
6
6
  const parse_1 = require("../../../slicing/criterion/parse");
7
7
  const df_helper_1 = require("../../../dataflow/graph/df-helper");
@@ -14,7 +14,7 @@ function fingerPrintOfQuery(query) {
14
14
  /**
15
15
  * Execute origin queries, catching duplicates with the same fingerprint
16
16
  */
17
- async function executeResolveValueQuery({ analyzer }, queries) {
17
+ async function executeOriginQuery({ analyzer }, queries) {
18
18
  const start = Date.now();
19
19
  const results = {};
20
20
  for (const query of queries) {
@@ -2,7 +2,7 @@ import type { BaseQueryFormat, BaseQueryResult } from '../../base-query-format';
2
2
  import type { SlicingCriterion } from '../../../slicing/criterion/parse';
3
3
  import type { ParsedQueryLine } from '../../query';
4
4
  import Joi from 'joi';
5
- import { executeResolveValueQuery } from './origin-query-executor';
5
+ import { executeOriginQuery } from './origin-query-executor';
6
6
  import type { Origin } from '../../../dataflow/origin/dfg-get-origin';
7
7
  import type { NodeId } from '../../../r-bridge/lang-4.x/ast/model/processing/node-id';
8
8
  import type { ReplOutput } from '../../../cli/repl/commands/repl-main';
@@ -19,7 +19,7 @@ export interface OriginQueryResult extends BaseQueryResult {
19
19
  declare function originQueryLineParser(output: ReplOutput, line: readonly string[], _config: FlowrConfig): ParsedQueryLine<'origin'>;
20
20
  export declare const OriginQueryDefinition: {
21
21
  readonly title: "Origin Query";
22
- readonly executor: typeof executeResolveValueQuery;
22
+ readonly executor: typeof executeOriginQuery;
23
23
  readonly asciiSummarizer: (formatter: import("../../../util/text/ansi").OutputFormatter, _analyzer: import("../../..").ReadonlyFlowrAnalysisProvider<import("../../..").KnownParser>, queryResults: BaseQueryResult, result: string[]) => true;
24
24
  readonly fromLine: typeof originQueryLineParser;
25
25
  readonly completer: typeof criteriaQueryCompleter;
@@ -25,7 +25,7 @@ function originQueryLineParser(output, line, _config) {
25
25
  }
26
26
  exports.OriginQueryDefinition = {
27
27
  title: 'Origin Query',
28
- executor: origin_query_executor_1.executeResolveValueQuery,
28
+ executor: origin_query_executor_1.executeOriginQuery,
29
29
  asciiSummarizer: (formatter, _analyzer, queryResults, result) => {
30
30
  const out = queryResults;
31
31
  result.push(`Query: ${(0, ansi_1.bold)('origin', formatter)} (${(0, time_1.printAsMs)(out['.meta'].timing, 0)})`);
@@ -306,7 +306,7 @@ export declare const SupportedQueries: {
306
306
  };
307
307
  readonly origin: {
308
308
  readonly title: "Origin Query";
309
- readonly executor: typeof import("./catalog/origin-query/origin-query-executor").executeResolveValueQuery;
309
+ readonly executor: typeof import("./catalog/origin-query/origin-query-executor").executeOriginQuery;
310
310
  readonly asciiSummarizer: (formatter: OutputFormatter, _analyzer: ReadonlyFlowrAnalysisProvider<import("..").KnownParser>, queryResults: BaseQueryResult, result: string[]) => true;
311
311
  readonly fromLine: (output: ReplOutput, line: readonly string[], _config: FlowrConfig) => ParsedQueryLine<"origin">;
312
312
  readonly completer: typeof import("../cli/repl/parser/slice-query-parser").criteriaQueryCompleter;
@@ -124,7 +124,7 @@ export declare const flowrCapabilities: {
124
124
  readonly name: "Dynamic Environment Resolution";
125
125
  readonly id: "dynamic-environment-resolution";
126
126
  readonly code: readonly ["new.env"];
127
- readonly description: `_An environment a program builds and names itself, rather than one a ${string} opens._ Covers \`new.env\`, \`assign\`/\`get\`/\`local\` with \`envir=\`, \`e$x\`, \`attach\`, \`with\`, and aliasing such an environment through a variable.`;
127
+ readonly description: `_An environment a program builds and names itself, rather than one a ${string} opens._ Covers \`new.env\`, \`assign\`/\`get\`/\`local\` with \`envir=\`, \`e$x\`, \`attach\`, \`with\`, and aliasing such an environment through a variable. A write from within a function reaches the environment it names, a read of the whole environment (\`as.list(e)\`) sees every field written, and copies of an environment variable (\`g <- e\`) share its fields.`;
128
128
  readonly example: string;
129
129
  readonly capabilities: readonly [{
130
130
  readonly name: "Environment in Control Flow";
@@ -311,8 +311,8 @@ export declare const flowrCapabilities: {
311
311
  }, {
312
312
  readonly name: "Local with Explicit Environment";
313
313
  readonly id: "local-envir-argument";
314
- readonly supported: "partially";
315
- readonly description: "_Send `local`'s body to a specific environment._ `new.env()` and `globalenv()` work, but inside a function that already binds the name the write lands in that frame instead.";
314
+ readonly supported: "fully";
315
+ readonly description: "_Send `local`'s body to a specific environment._ Its writes land in that environment, also inside a function that binds the same name itself.";
316
316
  readonly example: string;
317
317
  readonly url: [{
318
318
  readonly name: "`local`";
@@ -397,7 +397,7 @@ export declare const flowrCapabilities: {
397
397
  readonly name: "Side-Effects in Argument";
398
398
  readonly id: "side-effects-in-argument";
399
399
  readonly supported: "partially";
400
- readonly description: `_An argument that binds a name while it is evaluated, as \`f(x <- 3)\` does._ Whether the argument is ever forced is not modelled (see ${string}), so \`f <- function(a) 1; f(x <- 3)\` still believes \`x\` is 3.`;
400
+ readonly description: `_An argument that binds a name while it is evaluated, as \`f(x <- 3)\` does._ Whether the argument is ever forced is not modelled (see ${string}), so \`f <- function(a) 1; f(x <- 3)\` still believes \`x\` is 3. A call in the argument depends on the call it is handed to, so \`g(FALSE, f(4))\` keeps \`g\`.`;
401
401
  readonly example: string;
402
402
  readonly url: [{
403
403
  name: string;
@@ -458,7 +458,7 @@ export declare const flowrCapabilities: {
458
458
  readonly name: "Functions with global side effects";
459
459
  readonly id: "functions-with-global-side-effects";
460
460
  readonly supported: "partially";
461
- readonly description: `_A call that changes state the rest of the program reads without naming it, as \`setwd\` changes where a path points._ Only the ${string} is interpreted, while other ambient state such as ${string} stays an unknown side effect.`;
461
+ readonly description: `_A call that changes state the rest of the program reads without naming it, as \`setwd\` changes where a path points._ The ${string}, ${string}, and ${string} are tracked, so a read links to the calls that set what it reads. Other ambient state, like environment variables or the random seed, stays an unknown side effect.`;
462
462
  readonly example: string;
463
463
  }, {
464
464
  readonly name: "Working Directory";
@@ -652,7 +652,7 @@ export declare const flowrCapabilities: {
652
652
  readonly id: "assignment-functions";
653
653
  readonly code: readonly ["assign", "delayedAssign"];
654
654
  readonly supported: "partially";
655
- readonly description: `_Bind a name given as a string, with \`assign\`, \`delayedAssign\`, ..._ The name has to be a ${string}, and what a delayed assignment does when forced is not modelled.`;
655
+ readonly description: `_Bind a name given as a string, with \`assign\`, \`delayedAssign\`, ..._ The name has to be a ${string}. A delayed expression runs where the name is first read, so it sees the bindings at that point and its own writes happen there, in the \`assign.env\` given.`;
656
656
  readonly example: string;
657
657
  }, {
658
658
  readonly name: "Range Assignment";
@@ -946,7 +946,14 @@ export declare const flowrCapabilities: {
946
946
  readonly id: "built-in-options";
947
947
  readonly code: readonly ["options", "getOption"];
948
948
  readonly supported: "partially";
949
- readonly description: `_The global options \`options\` sets and \`getOption\` reads._ Option values are not tracked, so \`getOption("digits")\` does not reach a preceding \`options(digits = 3)\`. Unlike the ${string} they are not interpreted at all.`;
949
+ readonly description: "_The global options `options` sets and `getOption`, `.Options`, printing, and formatting read._ Each option is tracked by name, so `getOption(\"digits\")` reaches the last `options(digits = 3)`, `print` and `cat` reach the printing options, and an unrelated option usually stays out of a slice. `withr::with_options` and `local_options` scope a change, and `eval` of code that sets options counts as setting them. The values themselves are not interpreted, an `options(op)` restoring an unknown list may set any option, and options that change every conversion (`scipen`, `OutDec`) stay an unknown side effect. A function flowR cannot see into may read any option.";
950
+ readonly example: string;
951
+ }, {
952
+ readonly name: "Graphics State";
953
+ readonly id: "graphics-state";
954
+ readonly code: readonly ["par", "layout", "palette", "dev.off", "dev.set"];
955
+ readonly supported: "partially";
956
+ readonly description: "_The graphics parameters `par` and `layout` set for the active device, the `palette` all devices share, and the devices opened and closed._ A plot reads the state of the device it draws on, so it links to the `par` calls before it, a new device starts afresh, and `dev.off()` returns to the state of the device that becomes active. `withr::with_par` and the `with_<device>` functions scope a change. Within a function the open devices are unknown, so a device call only adds to what may hold, and grid-based plots like ggplot2 ignore the parameters.";
950
957
  readonly example: string;
951
958
  }, {
952
959
  readonly name: "Help";
@@ -1000,7 +1007,7 @@ export declare const flowrCapabilities: {
1000
1007
  readonly id: "built-in-evaluation";
1001
1008
  readonly code: readonly ["eval", "evalq", "eval.parent"];
1002
1009
  readonly supported: "partially";
1003
- readonly description: `_Run an expression that is a value with \`eval\`, \`evalq\`, \`eval.parent\`, ..._ \`eval(expr, envir)\` runs in an ${string} we may not know, so it is marked an unknown side effect.`;
1010
+ readonly description: `_Run an expression that is a value with \`eval\`, \`evalq\`, \`eval.parent\`, ..._ The captured code is linked where it is evaluated, also through a name bound once to \`quote\`, \`as.name\`, \`str2lang\`, or \`parse\`, but \`eval(expr, envir)\` with an ${string} we do not know stays an unknown side effect.`;
1004
1011
  readonly example: string;
1005
1012
  readonly url: [{
1006
1013
  name: string;
@@ -1019,9 +1026,9 @@ export declare const flowrCapabilities: {
1019
1026
  }, {
1020
1027
  readonly name: "Parsing";
1021
1028
  readonly id: "built-in-parsing";
1022
- readonly code: readonly ["parse", "deparse"];
1029
+ readonly code: readonly ["parse", "str2lang", "deparse"];
1023
1030
  readonly supported: "partially";
1024
- readonly description: `_Turn text into an expression with \`parse\`, and an expression back into text with \`deparse\`._ What \`parse\` produces is only reached through ${string}, and \`deparse\` is not modelled beyond reading its argument.`;
1031
+ readonly description: `_Turn text into an expression with \`parse\` or \`str2lang\`, and an expression back into text with \`deparse\`._ What \`parse\` produces is only reached through ${string}, and \`deparse\` is not modelled beyond reading its argument.`;
1025
1032
  readonly example: string;
1026
1033
  readonly url: [{
1027
1034
  name: string;
@@ -1231,7 +1238,7 @@ export declare const flowrCapabilities: {
1231
1238
  readonly id: "oop-s3-dispatch";
1232
1239
  readonly code: readonly ["UseMethod"];
1233
1240
  readonly supported: "partially";
1234
- readonly description: `_Route a generic call to the method that runs._ \`UseMethod\` links to every ${string} named \`generic.class\` in scope, so the ${string} an object carries narrows the target only where it is known (heavily over-approximating).`;
1241
+ readonly description: `_Route a generic call to the method that runs._ \`UseMethod\` and a built-in generic like \`length\` or \`toString\` link to every ${string} named \`generic.class\` in scope, so the ${string} an object carries narrows the target only where it is known (heavily over-approximating).`;
1235
1242
  readonly url: [{
1236
1243
  name: string;
1237
1244
  href: string;
@@ -1244,7 +1251,7 @@ export declare const flowrCapabilities: {
1244
1251
  readonly id: "oop-s3-inheritance";
1245
1252
  readonly code: readonly ["NextMethod"];
1246
1253
  readonly supported: "partially";
1247
- readonly description: `_Walk the class vector with \`NextMethod\`._ It reaches the generic's ${string}, the one it stands in included, rather than only the next class in the vector.`;
1254
+ readonly description: `_Walk the class vector with \`NextMethod\`._ It reaches the generic's ${string}, the one it stands in included, rather than only the next class in the vector, and hands on the current values of the formals.`;
1248
1255
  readonly url: [{
1249
1256
  name: string;
1250
1257
  href: string;
@@ -1275,9 +1282,9 @@ export declare const flowrCapabilities: {
1275
1282
  }, {
1276
1283
  readonly name: "Dispatch";
1277
1284
  readonly id: "oop-s4-dispatch";
1278
- readonly code: readonly ["standardGeneric", "setGeneric", "setMethod"];
1285
+ readonly code: readonly ["standardGeneric", "setGeneric", "setMethod", "setReplaceMethod"];
1279
1286
  readonly supported: "partially";
1280
- readonly description: `_Route a generic call to the method \`setMethod\` registered._ The generic reaches its methods through the chain they register in, but the signature does not narrow which of them runs, as ${string} for the argument.`;
1287
+ readonly description: `_Route a generic call to the method \`setMethod\` (or \`setReplaceMethod\`, for the \`<-\` generic) registered._ The generic reaches its methods through the chain they register in, but the signature does not narrow which of them runs, as ${string} for the argument.`;
1281
1288
  readonly url: [{
1282
1289
  name: string;
1283
1290
  href: string;