@eagleoutice/flowr 2.13.1 → 2.13.3

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 (158) hide show
  1. package/README.md +46 -44
  2. package/abstract-interpretation/data-frame/mappers/access-mapper.js +1 -0
  3. package/abstract-interpretation/data-frame/mappers/function-mapper.d.ts +1 -1
  4. package/abstract-interpretation/data-frame/mappers/function-mapper.js +3 -0
  5. package/abstract-interpretation/domains/state-domain-like.d.ts +1 -1
  6. package/cli/flowr.js +21 -5
  7. package/cli/repl/commands/repl-commands.js +11 -9
  8. package/cli/repl/commands/repl-query.js +1 -1
  9. package/cli/repl/commands/repl-signature.js +8 -1
  10. package/cli/repl/core.js +13 -10
  11. package/cli/repl/print-version.js +1 -1
  12. package/cli/repl/server/connection.d.ts +1 -1
  13. package/cli/repl/server/net.js +15 -0
  14. package/config.d.ts +37 -0
  15. package/config.js +63 -3
  16. package/control-flow/control-flow-graph.js +2 -1
  17. package/control-flow/semantic-cfg-guided-visitor.d.ts +1 -1
  18. package/core/steps/all/core/11-normalize-tree-sitter.d.ts +1 -1
  19. package/data/sigdb/sigdb.remote.json +1 -1
  20. package/dataflow/environments/append.d.ts +1 -1
  21. package/dataflow/environments/clone.d.ts +1 -1
  22. package/dataflow/environments/environment.d.ts +28 -4
  23. package/dataflow/environments/environment.js +66 -11
  24. package/dataflow/environments/identifier.d.ts +9 -8
  25. package/dataflow/environments/identifier.js +21 -13
  26. package/dataflow/environments/overwrite.d.ts +1 -1
  27. package/dataflow/eval/resolve/alias-tracking.d.ts +1 -1
  28. package/dataflow/eval/resolve/resolve-working-directory.d.ts +29 -0
  29. package/dataflow/eval/resolve/resolve-working-directory.js +168 -0
  30. package/dataflow/extractor.js +2 -1
  31. package/dataflow/graph/dataflowgraph-builder.d.ts +1 -1
  32. package/dataflow/graph/df-helper.d.ts +3 -2
  33. package/dataflow/graph/df-helper.js +11 -15
  34. package/dataflow/graph/diff-dataflow-graph.js +1 -1
  35. package/dataflow/graph/graph-helper.js +2 -6
  36. package/dataflow/graph/graph.d.ts +24 -0
  37. package/dataflow/graph/graph.js +25 -1
  38. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +1 -1
  39. package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +1 -1
  40. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +7 -0
  41. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +51 -0
  42. package/dataflow/internal/process/functions/call/built-in/built-in-eval.d.ts +1 -1
  43. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +1 -1
  44. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +1 -1
  45. package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +5 -2
  46. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +15 -9
  47. package/dataflow/internal/process/functions/call/built-in/built-in-list.d.ts +1 -1
  48. package/dataflow/internal/process/functions/call/built-in/built-in-quote.d.ts +1 -1
  49. package/dataflow/internal/process/functions/call/built-in/built-in-register-hook.d.ts +1 -1
  50. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-dispatch.d.ts +1 -1
  51. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.d.ts +7 -1
  52. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +9 -2
  53. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.d.ts +1 -1
  54. package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.js +2 -2
  55. package/dataflow/internal/process/functions/call/built-in/built-in-vector.d.ts +1 -1
  56. package/documentation/doc-readme.js +14 -12
  57. package/documentation/doc-util/doc-normalized-ast.d.ts +1 -1
  58. package/documentation/wiki-dataflow-graph.js +4 -24
  59. package/documentation/wiki-linter.js +1 -0
  60. package/documentation/wiki-mk/doc-context.d.ts +10 -0
  61. package/documentation/wiki-mk/doc-context.js +3 -0
  62. package/documentation/wiki-query.js +47 -0
  63. package/documentation/wiki-signature-database.js +18 -7
  64. package/linter/linter-rules.d.ts +24 -2
  65. package/linter/linter-rules.js +3 -1
  66. package/linter/rules/absolute-path.d.ts +4 -4
  67. package/linter/rules/absolute-path.js +7 -5
  68. package/linter/rules/dataframe-access-validation.d.ts +1 -1
  69. package/linter/rules/file-path-validity.d.ts +1 -1
  70. package/linter/rules/file-path-validity.js +48 -8
  71. package/linter/rules/function-finder-util.d.ts +2 -1
  72. package/linter/rules/syntactically-valid.d.ts +58 -0
  73. package/linter/rules/syntactically-valid.js +203 -0
  74. package/linter/rules/undefined-symbol-util.js +3 -1
  75. package/linter/rules/undefined-symbol.js +6 -6
  76. package/package.json +25 -12
  77. package/project/context/classify-project-kind.d.ts +40 -0
  78. package/project/context/classify-project-kind.js +76 -0
  79. package/project/context/flowr-analyzer-context.d.ts +4 -4
  80. package/project/context/flowr-analyzer-context.js +3 -3
  81. package/project/context/flowr-analyzer-dependencies-context.d.ts +34 -9
  82. package/project/context/flowr-analyzer-dependencies-context.js +30 -3
  83. package/project/context/flowr-analyzer-files-context.d.ts +10 -8
  84. package/project/context/flowr-analyzer-files-context.js +26 -67
  85. package/project/context/flowr-analyzer-meta-context.d.ts +1 -0
  86. package/project/context/flowr-file.d.ts +5 -0
  87. package/project/context/flowr-file.js +5 -0
  88. package/project/dependency-version-space.d.ts +118 -26
  89. package/project/dependency-version-space.js +343 -87
  90. package/project/plugins/file-plugins/files/flowr-description-file.d.ts +4 -0
  91. package/project/plugins/file-plugins/files/flowr-description-file.js +8 -1
  92. package/project/plugins/file-plugins/files/flowr-rda-file.js +27 -25
  93. package/project/plugins/file-plugins/flowr-analyzer-rprofile-file-plugin.d.ts +12 -4
  94. package/project/plugins/file-plugins/flowr-analyzer-rprofile-file-plugin.js +25 -10
  95. package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.d.ts +1 -1
  96. package/project/plugins/file-plugins/notebooks/flowr-analyzer-sweave-file-plugin.d.ts +1 -1
  97. package/project/plugins/package-version-plugins/flowr-analyzer-meta-description-file-plugin.js +2 -1
  98. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +1 -1
  99. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +4 -4
  100. package/project/plugins/package-version-plugins/package.d.ts +27 -10
  101. package/project/plugins/package-version-plugins/package.js +50 -25
  102. package/project/plugins/plugin-registry.d.ts +2 -1
  103. package/project/plugins/plugin-registry.js +4 -1
  104. package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.d.ts +57 -2
  105. package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +150 -28
  106. package/project/sigdb/decompress.d.ts +1 -1
  107. package/project/sigdb/decompress.js +4 -1
  108. package/project/sigdb/manifest.js +60 -26
  109. package/project/sigdb/reader.d.ts +26 -16
  110. package/project/sigdb/reader.js +52 -21
  111. package/project/sigdb/sigdb-download.d.ts +6 -7
  112. package/project/sigdb/sigdb-download.js +30 -9
  113. package/queries/catalog/dependencies-query/dependencies-query-executor.js +1 -1
  114. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +2 -12
  115. package/queries/catalog/dependencies-query/dependencies-query-format.js +2 -108
  116. package/queries/catalog/does-call-query/does-call-query-format.d.ts +1 -1
  117. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +39 -77
  118. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.d.ts +12 -0
  119. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +54 -24
  120. package/queries/catalog/input-sources-query/input-source-functions.d.ts +13 -0
  121. package/queries/catalog/input-sources-query/input-source-functions.js +96 -1
  122. package/queries/catalog/input-sources-query/input-sources-query-executor.js +40 -4
  123. package/queries/catalog/input-sources-query/input-sources-query-format.js +21 -3
  124. package/queries/catalog/input-sources-query/input-types.d.ts +58 -0
  125. package/queries/catalog/input-sources-query/input-types.js +64 -0
  126. package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +62 -52
  127. package/queries/catalog/input-sources-query/simple-input-classifier.js +334 -101
  128. package/queries/catalog/linter-query/linter-query-format.js +9 -2
  129. package/queries/catalog/project-query/project-query-executor.js +1 -1
  130. package/queries/catalog/signature-query/signature-query-executor.d.ts +7 -1
  131. package/queries/catalog/signature-query/signature-query-executor.js +115 -39
  132. package/queries/catalog/signature-query/signature-query-format.d.ts +5 -1
  133. package/queries/catalog/signature-query/signature-query-format.js +1 -1
  134. package/queries/catalog/signature-query/signature-query-render.js +12 -7
  135. package/queries/query.js +9 -2
  136. package/r-bridge/data/data.d.ts +5 -0
  137. package/r-bridge/data/data.js +6 -0
  138. package/r-bridge/lang-4.x/ast/parser/json/format.js +1 -1
  139. package/r-bridge/retriever.d.ts +1 -1
  140. package/r-bridge/retriever.js +6 -1
  141. package/r-bridge/shell.js +5 -0
  142. package/search/flowr-search-filters.d.ts +2 -1
  143. package/search/flowr-search-printer.js +10 -8
  144. package/slicing/static/static-slicer.d.ts +2 -2
  145. package/util/files.d.ts +6 -4
  146. package/util/files.js +30 -8
  147. package/util/mermaid/dfg.js +1 -1
  148. package/util/objects.js +6 -4
  149. package/util/r-base-packages.d.ts +2 -0
  150. package/util/r-base-packages.js +3 -0
  151. package/util/r-license.js +1 -4
  152. package/util/r-version.d.ts +12 -0
  153. package/util/r-version.js +16 -0
  154. package/util/range.d.ts +6 -2
  155. package/util/range.js +33 -15
  156. package/util/text/ansi.d.ts +7 -3
  157. package/util/text/ansi.js +8 -5
  158. package/util/version.js +4 -4
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.SigDatabaseSet = exports.SigDatabase = exports.MergedSignatureSource = void 0;
7
7
  exports.readSignatureDb = readSignatureDb;
8
8
  exports.availableVersionEntries = availableVersionEntries;
9
+ exports.classOwnerIndexFor = classOwnerIndexFor;
9
10
  exports.sourceForPackage = sourceForPackage;
10
11
  exports.getSharedSigSourceSync = getSharedSigSourceSync;
11
12
  exports.getSharedSigSource = getSharedSigSource;
@@ -115,13 +116,22 @@ function availableVersionEntries(src, pkg) {
115
116
  .sort((a, b) => r_version_1.RVersion.compare(a.version, b.version) || (a.date && b.date ? a.date.getTime() - b.date.getTime() : 0));
116
117
  }
117
118
  /**
118
- * The reverse index `class -> owning package` over every package's latest version. S3 ownership (a same-named
119
- * constructor plus a registered method) is a stronger signal than an S4 `exportClasses`, so S3-owned classes are
120
- * indexed first and an S4 class only claims a name no S3 owner already took.
119
+ * The reverse index `class -> owning package` over `candidates`, at each one's latest version. S3 ownership (a
120
+ * same-named constructor plus a registered method) is a stronger signal than an S4 `exportClasses`, so S3-owned
121
+ * classes are indexed first and an S4 class only claims a name no S3 owner already took.
122
+ *
123
+ * Restricting the candidates is the targeted counterpart of {@link PackageSignatureSource.classOwner}: class names
124
+ * collide heavily across CRAN, so a whole-database answer is decided by database order, and deriving one means
125
+ * reading every package in the database.
121
126
  */
122
- function buildClassOwnerIndex(src) {
127
+ function classOwnerIndexFor(src, candidates) {
123
128
  const index = new Map();
124
- const libs = src.packageNames().map(pkg => ({ pkg, lib: src.lookup(pkg) }));
129
+ const libs = [];
130
+ for (const pkg of candidates) {
131
+ if (src.has(pkg)) {
132
+ libs.push({ pkg, lib: src.lookup(pkg) });
133
+ }
134
+ }
125
135
  for (const pick of [(l) => l?.s3Classes, (l) => l?.s4Classes]) {
126
136
  for (const { pkg, lib } of libs) {
127
137
  for (const cls of pick(lib) ?? []) {
@@ -238,10 +248,12 @@ function sourceForPackage(sources, pkg) {
238
248
  }
239
249
  /**
240
250
  * Fast, partial reader for a single bundle. `open()`/`openSync()` load the string dictionary + `.idx`
241
- * once (a single ranged read of the dictionary section -- no full parse), then every query seeks straight
251
+ * once (a single ranged read of the dictionary section, no full parse), then every query seeks straight
242
252
  * to one package blob on demand. `open()` additionally decompresses a `.br`/`.gz` source into a
243
253
  * hash-keyed cache and reuses it on later startups. Implements {@link PackageSignatureSource}.
244
254
  */
255
+ /** the {@link SigDatabase.fd} of a database that has no file behind it (see {@link SigDatabase.fromMemory}) */
256
+ const NoFile = -1;
245
257
  class SigDatabase {
246
258
  closed = false;
247
259
  /** parsed blobs by blob index so repeated lookups skip the re-read + JSON.parse; FIFO-bounded to cap memory */
@@ -261,10 +273,21 @@ class SigDatabase {
261
273
  this.content = content;
262
274
  this.cranBase = cranBase;
263
275
  }
276
+ /**
277
+ * Use an already-built {@link SigDb} directly, without writing or reading a file: its blobs simply start out in
278
+ * the cache. It holds exactly what a bundle carries, so every query answers as it would from disk; the
279
+ * {@link SigDbBuilder} plus this is all a test needs.
280
+ */
281
+ static fromMemory(db) {
282
+ const index = { byteCount: 0, dict: [0, 0], blobs: [], pkgs: db.pkgs, meta: db.meta };
283
+ const source = new SigDatabase(NoFile, db.strings, index, db.content, db.cranBase ?? schema_1.DefaultCranBase);
284
+ db.blobs.forEach((blob, i) => source.blobCache.set(i, blob));
285
+ return source;
286
+ }
264
287
  /**
265
288
  * Open a plain, seekable `.sigs.ndjson` synchronously. Pass `index` to skip reading the `.idx`,
266
289
  * and `strings` to use an already-loaded shared dictionary instead of the file's own `d` section (for a
267
- * blob-only shard). One ranged read loads the dictionary -- no readline overhead.
290
+ * blob-only shard). One ranged read loads the dictionary, no readline overhead.
268
291
  */
269
292
  static openSync(plainFile, opts = {}) {
270
293
  if ((0, decompress_1.isCompressed)(plainFile)) {
@@ -321,6 +344,9 @@ class SigDatabase {
321
344
  if (cached !== undefined) {
322
345
  return cached;
323
346
  }
347
+ if (this.fd === NoFile) {
348
+ return undefined; // an in-memory database starts out with every blob cached
349
+ }
324
350
  const blob = this.readBlobAt(this.index.blobs[blobIdx]);
325
351
  if (this.blobCache.size >= SigDatabase.BlobCacheCap) {
326
352
  const oldest = this.blobCache.keys().next().value;
@@ -340,11 +366,14 @@ class SigDatabase {
340
366
  }
341
367
  /** read every unique package blob in index order (used to re-hash a whole shard during verification) */
342
368
  allBlobs() {
343
- return this.index.blobs.map(range => this.readBlobAt(range));
369
+ // an in-memory database has no byte ranges to re-read: its blobs are the cached ones, in blob-index order
370
+ return this.fd === NoFile
371
+ ? [...this.blobCache.entries()].sort(([a], [b]) => a - b).map(([, blob]) => blob)
372
+ : this.index.blobs.map(range => this.readBlobAt(range));
344
373
  }
345
374
  /** recompute this bundle's self-contained content hash from its re-read data (matches {@link writeSignatureDb}) */
346
375
  contentHash(blobs = this.allBlobs()) {
347
- // use only this bundle's own package metadata, in package-index order -- a shared manifest may hoist a
376
+ // use only this bundle's own package metadata, in package-index order, since a shared manifest may hoist a
348
377
  // superset of metadata that the self-contained bundle was NOT hashed over
349
378
  const meta = {};
350
379
  for (const pkg of Object.keys(this.index.pkgs)) {
@@ -372,7 +401,7 @@ class SigDatabase {
372
401
  if (version !== undefined) {
373
402
  return classOwnerAtVersion(this, className, version);
374
403
  }
375
- this.classIndex ??= buildClassOwnerIndex(this);
404
+ this.classIndex ??= classOwnerIndexFor(this, this.packageNames());
376
405
  return this.classIndex.get(className);
377
406
  }
378
407
  /** resolve a package version to its blob and the function-record indices of that version (the shared prologue of {@link functions}/{@link functionByName}) */
@@ -451,7 +480,9 @@ class SigDatabase {
451
480
  this.closed = true;
452
481
  this.blobCache.clear();
453
482
  this.classIndex = undefined;
454
- node_fs_1.default.closeSync(this.fd);
483
+ if (this.fd !== NoFile) {
484
+ node_fs_1.default.closeSync(this.fd);
485
+ }
455
486
  }
456
487
  }
457
488
  }
@@ -529,14 +560,14 @@ class SigDatabaseSet {
529
560
  return SigDatabaseSet.assemble(manifest, baseDir, indices, opts.cacheDir);
530
561
  }
531
562
  /**
532
- * Synchronous {@link openManifest} -- needs every shard to embed its index (the default for the bundles
563
+ * Synchronous {@link openManifest}, needing every shard to embed its index (the default for the bundles
533
564
  * flowR ships). Shards and dictionaries still decompress lazily.
534
565
  */
535
566
  static openManifestSync(manifestFile, opts = {}) {
536
567
  const { baseDir, manifest } = SigDatabaseSet.prepManifest(manifestFile, opts);
537
568
  const indices = manifest.shards.map(s => {
538
569
  if (!s.idx) {
539
- throw new Error(`openManifestSync needs every shard to embed its index; shard '${s.id}' does not -- use openManifest`);
570
+ throw new Error(`openManifestSync needs every shard to embed its index; shard '${s.id}' does not, use openManifest`);
540
571
  }
541
572
  return (0, index_format_1.decodeIndex)(s.idx, manifest.meta);
542
573
  });
@@ -569,7 +600,7 @@ class SigDatabaseSet {
569
600
  this.dictCache.set(dictId, strings);
570
601
  return strings;
571
602
  }
572
- /** lazily open a shard -- decompressing its `.br` (and its shared dictionary) into the cache on first access */
603
+ /** lazily open a shard, decompressing its `.br` (and its shared dictionary) into the cache on first access */
573
604
  shard(i) {
574
605
  const existing = this.opened[i];
575
606
  if (existing) {
@@ -628,7 +659,7 @@ class SigDatabaseSet {
628
659
  });
629
660
  await Promise.all([...shardJobs, ...dictJobs]);
630
661
  // open each shard from the now-decompressed cache (cheap; parses each shared dictionary once) so later
631
- // synchronous queries -- including historical, pinned-version lookups -- never block
662
+ // synchronous queries, including historical pinned-version lookups, never block
632
663
  for (const i of need) {
633
664
  this.shard(i);
634
665
  }
@@ -642,7 +673,7 @@ class SigDatabaseSet {
642
673
  // keep only shards that actually carry the requested version (current shards may hold only the latest)
643
674
  return candidates.filter(i => this.shard(i).hasVersion(pkg, version));
644
675
  }
645
- /** read (once) the blob from the shard with the most complete history -- a `full` or `history` tier if present */
676
+ /** read (once) the blob from the shard with the most complete history: a `full` or `history` tier if present */
646
677
  historyBlob(pkg) {
647
678
  const candidates = this.routes.get(pkg);
648
679
  if (!candidates || candidates.length === 0) {
@@ -677,11 +708,11 @@ class SigDatabaseSet {
677
708
  };
678
709
  });
679
710
  }
680
- /** open (blocking) and return every shard database with its manifest ref -- used for whole-set verification */
711
+ /** open (blocking) and return every shard database with its manifest ref, for whole-set verification */
681
712
  allShards() {
682
713
  return this.manifest.shards.map((ref, i) => ({ ref, db: this.shard(i) }));
683
714
  }
684
- /** load (and cache) a shared dictionary's strings by id -- for verification/inspection */
715
+ /** load (and cache) a shared dictionary's strings by id, for verification/inspection */
685
716
  sharedDictionary(id) {
686
717
  return this.dictionaryStrings(id);
687
718
  }
@@ -702,7 +733,7 @@ class SigDatabaseSet {
702
733
  if (version !== undefined) {
703
734
  return classOwnerAtVersion(this, className, version);
704
735
  }
705
- this.classIndex ??= buildClassOwnerIndex(this);
736
+ this.classIndex ??= classOwnerIndexFor(this, this.packageNames());
706
737
  return this.classIndex.get(className);
707
738
  }
708
739
  functions(pkg, version) {
@@ -733,7 +764,7 @@ class SigDatabaseSet {
733
764
  }
734
765
  return Object.keys(this.historyBlob(pkg)?.versions ?? {}).map(r_version_1.RVersion.parseOrZero).sort((a, b) => r_version_1.RVersion.compare(a.str, b.str));
735
766
  }
736
- /** every known release of a package (version + date), ascending -- read once from the most complete shard */
767
+ /** every known release of a package (version + date), ascending, read once from the most complete shard */
737
768
  releaseDates(pkg) {
738
769
  return (0, sigdb_version_1.releasesOf)(this.historyBlob(pkg));
739
770
  }
@@ -774,7 +805,7 @@ function isSyncOpenable(source) {
774
805
  }
775
806
  /**
776
807
  * Open a path-based source once, process-wide, synchronously. Returns the shared instance (opening it on the
777
- * first call), or `undefined` if the path needs async opening (a `.br`/`.gz` bundle -- use {@link getSharedSigSource}).
808
+ * first call), or `undefined` if the path needs async opening (a `.br`/`.gz` bundle, use {@link getSharedSigSource}).
778
809
  * Throws only if a sync-openable source fails to open.
779
810
  */
780
811
  function getSharedSigSourceSync(source) {
@@ -25,10 +25,11 @@ export declare function selectDownloadVariants(names: Iterable<string>): string[
25
25
  export interface SigDbDownloadOptions {
26
26
  /** GitHub `owner/repo` (default `flowr-analysis/flowr`) */
27
27
  readonly repo?: string;
28
- /** release version, i.e. tag `sigdb-v<version>` (default the running flowR version) */
28
+ /** release version, i.e. tag `sigdb-v<version>` (default the running flowR version); ignored when the committed `sigdb.remote.json` is present, whose `tag` then drives the download */
29
29
  readonly version?: string;
30
30
  /** progress callback (one line per asset) */
31
31
  readonly onProgress?: (msg: string) => void;
32
+ readonly force?: boolean;
32
33
  }
33
34
  export interface SigDbDownloadResult {
34
35
  /** the directory the bundle landed in (add it to `solver.sigdb.additionalPaths` to keep it mounted) */
@@ -50,16 +51,14 @@ export declare function downloadFullSigDb(opts?: SigDbDownloadOptions): Promise<
50
51
  * pointer is committed. Lets a caller mount an already-synced bundle via `solver.sigdb.additionalPaths` without
51
52
  * hitting the network.
52
53
  */
53
- export declare function syncedSigDbDir(opts?: {
54
- version?: string;
55
- }): string | undefined;
54
+ export declare function syncedSigDbDir(): string | undefined;
56
55
  /** the GitHub release (`{repo, tag, url}`) the committed pointer downloads from, or `undefined` when no pointer is committed */
57
56
  export declare function sigDbRemoteRelease(): {
58
57
  repo: string;
59
58
  tag: string;
60
59
  url: string;
61
60
  } | undefined;
61
+ /** Fast presence check (existence + byte size only, no hashing) for the shards the committed pointer selects for this runtime; `false` when no pointer is committed or any selected shard is missing/wrong-size. */
62
+ export declare function sigDbCacheComplete(): boolean;
62
63
  /** Startup check: `true` when a committed link file lists shards whose cached copies are missing or hash-mismatched */
63
- export declare function sigDbNeedsSync(opts?: {
64
- version?: string;
65
- }): boolean;
64
+ export declare function sigDbNeedsSync(): boolean;
@@ -8,6 +8,7 @@ exports.selectDownloadVariants = selectDownloadVariants;
8
8
  exports.downloadFullSigDb = downloadFullSigDb;
9
9
  exports.syncedSigDbDir = syncedSigDbDir;
10
10
  exports.sigDbRemoteRelease = sigDbRemoteRelease;
11
+ exports.sigDbCacheComplete = sigDbCacheComplete;
11
12
  exports.sigDbNeedsSync = sigDbNeedsSync;
12
13
  const fs_1 = __importDefault(require("fs"));
13
14
  const path_1 = __importDefault(require("path"));
@@ -134,7 +135,7 @@ async function downloadFullSigDb(opts = {}) {
134
135
  if (pointerPath) {
135
136
  const remote = readPointer(pointerPath);
136
137
  const repo = opts.repo ?? remote.repo ?? DefaultRepo;
137
- const tag = opts.version ? `sigdb-v${opts.version}` : remote.tag;
138
+ const tag = remote.tag;
138
139
  const dir = path_1.default.join((0, decompress_1.sigDbCacheDir)(), 'bundles', tag);
139
140
  fs_1.default.mkdirSync(dir, { recursive: true });
140
141
  // one variant per logical shard/dictionary -- the best this runtime can decompress (never both codecs)
@@ -144,7 +145,7 @@ async function downloadFullSigDb(opts = {}) {
144
145
  for (const name of picked) {
145
146
  const meta = remote.shards[name];
146
147
  const dest = path_1.default.join(dir, name);
147
- if (fs_1.default.existsSync(dest) && (0, exports.sha256File)(dest) === meta.sha256) {
148
+ if (!opts.force && fs_1.default.existsSync(dest) && (0, exports.sha256File)(dest) === meta.sha256) {
148
149
  progress(`have ${name}`);
149
150
  }
150
151
  else {
@@ -176,7 +177,7 @@ async function downloadFullSigDb(opts = {}) {
176
177
  for (const name of selectDownloadVariants(byName.keys())) {
177
178
  const a = byName.get(name);
178
179
  const dest = path_1.default.join(dir, name);
179
- if (fs_1.default.existsSync(dest) && fs_1.default.statSync(dest).size === a.size) {
180
+ if (!opts.force && fs_1.default.existsSync(dest) && fs_1.default.statSync(dest).size === a.size) {
180
181
  progress(`have ${name}`);
181
182
  }
182
183
  else {
@@ -192,13 +193,12 @@ async function downloadFullSigDb(opts = {}) {
192
193
  * pointer is committed. Lets a caller mount an already-synced bundle via `solver.sigdb.additionalPaths` without
193
194
  * hitting the network.
194
195
  */
195
- function syncedSigDbDir(opts = {}) {
196
+ function syncedSigDbDir() {
196
197
  const pointerPath = findRemotePointer();
197
198
  if (!pointerPath) {
198
199
  return undefined;
199
200
  }
200
- const tag = opts.version ? `sigdb-v${opts.version}` : readPointer(pointerPath).tag;
201
- return path_1.default.join((0, decompress_1.sigDbCacheDir)(), 'bundles', tag);
201
+ return path_1.default.join((0, decompress_1.sigDbCacheDir)(), 'bundles', readPointer(pointerPath).tag);
202
202
  }
203
203
  /** the GitHub release (`{repo, tag, url}`) the committed pointer downloads from, or `undefined` when no pointer is committed */
204
204
  function sigDbRemoteRelease() {
@@ -215,16 +215,37 @@ function sigDbRemoteRelease() {
215
215
  return undefined;
216
216
  }
217
217
  }
218
+ /** Fast presence check (existence + byte size only, no hashing) for the shards the committed pointer selects for this runtime; `false` when no pointer is committed or any selected shard is missing/wrong-size. */
219
+ function sigDbCacheComplete() {
220
+ const pointerPath = findRemotePointer();
221
+ if (!pointerPath) {
222
+ return false;
223
+ }
224
+ try {
225
+ const remote = readPointer(pointerPath);
226
+ const dir = path_1.default.join((0, decompress_1.sigDbCacheDir)(undefined, false), 'bundles', remote.tag);
227
+ return selectDownloadVariants(Object.keys(remote.shards)).every(name => {
228
+ try {
229
+ return fs_1.default.statSync(path_1.default.join(dir, name)).size === remote.shards[name].bytes;
230
+ }
231
+ catch {
232
+ return false;
233
+ }
234
+ });
235
+ }
236
+ catch {
237
+ return false;
238
+ }
239
+ }
218
240
  /** Startup check: `true` when a committed link file lists shards whose cached copies are missing or hash-mismatched */
219
- function sigDbNeedsSync(opts = {}) {
241
+ function sigDbNeedsSync() {
220
242
  const pointerPath = findRemotePointer();
221
243
  if (!pointerPath) {
222
244
  return false;
223
245
  }
224
246
  try {
225
247
  const remote = readPointer(pointerPath);
226
- const tag = opts.version ? `sigdb-v${opts.version}` : remote.tag;
227
- const dir = path_1.default.join((0, decompress_1.sigDbCacheDir)(), 'bundles', tag);
248
+ const dir = path_1.default.join((0, decompress_1.sigDbCacheDir)(), 'bundles', remote.tag);
228
249
  return Object.entries(remote.shards).some(([name, meta]) => {
229
250
  const dest = path_1.default.join(dir, name);
230
251
  return !fs_1.default.existsSync(dest) || (0, exports.sha256File)(dest) !== meta.sha256;
@@ -197,7 +197,7 @@ function getResults(queries, { dataflow, config, normalize }, results, kind, fun
197
197
  linkedIds: linked?.length ? linked : undefined,
198
198
  value: resolvedValue ?? info.defaultValue ?? defaultValue,
199
199
  versionConstraints: dep?.versionConstraints,
200
- derivedVersion: dep?.derivedVersion,
200
+ derivedRange: dep?.derivedRange,
201
201
  namespaceInfo: dep?.namespaceInfo
202
202
  }));
203
203
  }
@@ -56,16 +56,6 @@ export declare const DefaultDependencyCategories: {
56
56
  readonly queryDisplayName: "Tests";
57
57
  readonly functions: FunctionInfo[];
58
58
  };
59
- readonly undeclared: {
60
- readonly queryDisplayName: "Undeclared Dependencies";
61
- readonly functions: [];
62
- readonly additionalAnalysis: (data: BasicQueryData, ignoreDefault: boolean, _functions: FunctionInfo[], _queryResults: CallContextQueryResult, result: DependencyInfo[]) => Promise<void>;
63
- };
64
- readonly unused: {
65
- readonly queryDisplayName: "Unused Dependencies";
66
- readonly functions: [];
67
- readonly additionalAnalysis: (data: BasicQueryData, ignoreDefault: boolean, _functions: FunctionInfo[], _queryResults: CallContextQueryResult, result: DependencyInfo[]) => Promise<void>;
68
- };
69
59
  };
70
60
  export type DefaultDependencyCategoryName = keyof typeof DefaultDependencyCategories;
71
61
  export type DependencyCategoryName = DefaultDependencyCategoryName | string;
@@ -89,8 +79,8 @@ export interface DependencyInfo extends Record<string, unknown> {
89
79
  lexemeOfArgument?: string;
90
80
  /** The library name, file, source, destination etc. being sourced, read from, or written to. */
91
81
  value?: string;
92
- versionConstraints?: Range[];
93
- derivedVersion?: Range;
82
+ versionConstraints?: readonly Range[];
83
+ derivedRange?: Range;
94
84
  namespaceInfo?: NamespaceInfo;
95
85
  }
96
86
  /**
@@ -20,71 +20,6 @@ const identifier_1 = require("../../../dataflow/environments/identifier");
20
20
  const r_project_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-project");
21
21
  const model_1 = require("../../../r-bridge/lang-4.x/ast/model/model");
22
22
  exports.Unknown = 'unknown';
23
- /** packages a default R session attaches without an explicit `library()` call, so missing them is not "undeclared" */
24
- const AttachedBasePackages = ['base', 'stats', 'graphics', 'grDevices', 'utils', 'datasets', 'methods'];
25
- /** {@link LibraryFunctions} indexed by name, to recognise a library-load call by its called function */
26
- const LibraryLoadFunctionInfo = new Map(library_functions_1.LibraryFunctions.map(f => [f.name, f]));
27
- /** the literal package name of a `library()`/`require()`-style argument (a bare symbol or a plain string constant) */
28
- function literalPackageName(node) {
29
- if (node?.type === type_1.RType.String) {
30
- return node.content.str;
31
- }
32
- else if (node?.type === type_1.RType.Symbol) {
33
- return identifier_1.Identifier.getName(node.content);
34
- }
35
- return undefined;
36
- }
37
- /** the argument value(s) of a library-load call that (statically) name the package(s) to load, per the matching {@link FunctionInfo} */
38
- function libraryCallArgumentValues(args, info) {
39
- const values = [];
40
- let position = 0;
41
- for (const arg of args) {
42
- if (typeof arg !== 'string' && arg.value !== undefined) {
43
- if (info.argIdx === 'unnamed') {
44
- if (arg.name === undefined) {
45
- values.push(arg.value);
46
- }
47
- }
48
- else if (arg.name !== undefined ? identifier_1.Identifier.getName(arg.name.content) === info.argName : position === info.argIdx) {
49
- values.push(arg.value);
50
- }
51
- }
52
- position++;
53
- }
54
- return values;
55
- }
56
- /**
57
- * The packages used by the code: attached via a `library()`-style call, or referenced via `::`/`:::`.
58
- * Maps each package name to the node id of one representative use site.
59
- *
60
- * This deliberately re-walks the AST instead of depending on the `library` category's result array: categories
61
- * run concurrently (see the executor's `Promise.all`), so another category's finished results are not available.
62
- * Only statically known package names are picked up (a bare symbol or string literal argument), matching the
63
- * `library` category's own `::`/`:::` detection in spirit but staying independent of it.
64
- */
65
- async function collectUsedPackages(data) {
66
- const used = new Map();
67
- r_project_1.RProject.visitAst((await data.analyzer.normalize()).ast, node => {
68
- if (node.type === type_1.RType.Symbol) {
69
- const ns = identifier_1.Identifier.getNamespace(node.content);
70
- if (ns !== undefined && !used.has(ns)) {
71
- used.set(ns, node.info.id);
72
- }
73
- }
74
- else if (node.type === type_1.RType.FunctionCall && node.named) {
75
- const info = LibraryLoadFunctionInfo.get(identifier_1.Identifier.getName(node.functionName.content));
76
- if (info !== undefined) {
77
- for (const value of libraryCallArgumentValues(node.arguments, info)) {
78
- const pkg = literalPackageName(value);
79
- if (pkg !== undefined && !used.has(pkg)) {
80
- used.set(pkg, node.info.id);
81
- }
82
- }
83
- }
84
- }
85
- });
86
- return used;
87
- }
88
23
  exports.DefaultDependencyCategories = {
89
24
  'library': {
90
25
  queryDisplayName: 'Libraries',
@@ -103,7 +38,7 @@ exports.DefaultDependencyCategories = {
103
38
  functionName: model_1.RNode.lexeme(node).includes(':::') ? ':::' : '::',
104
39
  value: ns,
105
40
  versionConstraints: dep?.versionConstraints,
106
- derivedVersion: dep?.derivedVersion,
41
+ derivedRange: dep?.derivedRange,
107
42
  namespaceInfo: dep?.namespaceInfo
108
43
  });
109
44
  }
@@ -133,44 +68,6 @@ exports.DefaultDependencyCategories = {
133
68
  'test': {
134
69
  queryDisplayName: 'Tests',
135
70
  functions: test_functions_1.TestFunctions
136
- },
137
- 'undeclared': {
138
- queryDisplayName: 'Undeclared Dependencies',
139
- functions: [],
140
- /* packages that are used (via `library()`/`require()` or `::`/`:::`) but never declared as a project dependency */
141
- additionalAnalysis: async (data, ignoreDefault, _functions, _queryResults, result) => {
142
- if (ignoreDefault) {
143
- return;
144
- }
145
- const deps = data.analyzer.inspectContext().deps;
146
- const declared = new Set(deps.getDependencies().map(p => p.name));
147
- for (const [pkg, nodeId] of await collectUsedPackages(data)) {
148
- if (!declared.has(pkg) && !AttachedBasePackages.includes(pkg)) {
149
- result.push({ nodeId, functionName: pkg, value: pkg });
150
- }
151
- }
152
- }
153
- },
154
- 'unused': {
155
- queryDisplayName: 'Unused Dependencies',
156
- functions: [],
157
- /* packages declared as a project dependency but never used (via `library()`/`require()` or `::`/`:::`) */
158
- additionalAnalysis: async (data, ignoreDefault, _functions, _queryResults, result) => {
159
- if (ignoreDefault) {
160
- return;
161
- }
162
- const deps = data.analyzer.inspectContext().deps;
163
- const used = await collectUsedPackages(data);
164
- const nodeId = (await data.analyzer.normalize()).ast.files[0]?.root.info.id;
165
- if (nodeId === undefined) {
166
- return;
167
- }
168
- for (const pkg of deps.getDependencies()) {
169
- if (!used.has(pkg.name)) {
170
- result.push({ nodeId, functionName: pkg.name, value: pkg.name });
171
- }
172
- }
173
- }
174
71
  }
175
72
  };
176
73
  function printResultSection(title, infos, result, formatter) {
@@ -182,7 +79,7 @@ function printResultSection(title, infos, result, formatter) {
182
79
  for (const i of infos) {
183
80
  const fn = identifier_1.Identifier.getName(i.functionName);
184
81
  const value = i.value !== undefined ? (0, ansi_1.bold)(i.value, formatter) : (0, ansi_1.faint)('<unresolved>', formatter);
185
- const version = i.derivedVersion !== undefined ? ` ${(0, ansi_1.faint)(i.derivedVersion.format(), formatter)}` : '';
82
+ const version = i.derivedRange !== undefined ? ` ${(0, ansi_1.faint)(i.derivedRange.format(), formatter)}` : '';
186
83
  const linked = i.linkedIds ? `, linked ${i.linkedIds.join(', ')}` : '';
187
84
  result.push(` ${value}${version} ${(0, ansi_1.faint)(`via ${fn} (node ${i.nodeId}${linked})`, formatter)}`);
188
85
  }
@@ -212,9 +109,6 @@ exports.DependenciesQueryDefinition = {
212
109
  const out = queryResults;
213
110
  result.push(`Query: ${(0, ansi_1.bold)('dependencies', formatter)} (${(0, time_1.printAsMs)(out['.meta'].timing, 0)})`);
214
111
  for (const [category, value] of Object.entries(getAllCategories(queries))) {
215
- if (category === 'unused') {
216
- continue; // the unused-dependency detection is unreliable; omit it from the summary for now
217
- }
218
112
  printResultSection(value.queryDisplayName ?? category, out[category] ?? [], result, formatter);
219
113
  }
220
114
  return true;
@@ -2,7 +2,7 @@ import type { BaseQueryFormat, BaseQueryResult } from '../../base-query-format';
2
2
  import Joi from 'joi';
3
3
  import type { ParsedQueryLine } from '../../query';
4
4
  import { executeDoesCallQuery } from './does-call-query-executor';
5
- import { type NodeId } from '../../../r-bridge/lang-4.x/ast/model/processing/node-id';
5
+ import type { NodeId } from '../../../r-bridge/lang-4.x/ast/model/processing/node-id';
6
6
  import type { SlicingCriterion } from '../../../slicing/criterion/parse';
7
7
  import type { ReplOutput } from '../../../cli/repl/commands/repl-main';
8
8
  import type { FlowrConfig } from '../../../config';