@eagleoutice/flowr 2.11.0 → 2.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (256) hide show
  1. package/README.md +190 -260
  2. package/abstract-interpretation/data-frame/mappers/arguments.js +7 -1
  3. package/abstract-interpretation/domains/set-range-domain.js +1 -1
  4. package/abstract-interpretation/domains/set-upper-bound-domain.js +6 -2
  5. package/benchmark/slicer.d.ts +1 -1
  6. package/benchmark/slicer.js +3 -1
  7. package/benchmark/summarizer/second-phase/graph.js +5 -0
  8. package/cli/common/options.d.ts +8 -0
  9. package/cli/common/options.js +2 -0
  10. package/cli/common/scripts-info.d.ts +8 -0
  11. package/cli/flowr.js +1 -1
  12. package/cli/repl/commands/repl-commands.d.ts +1 -0
  13. package/cli/repl/commands/repl-commands.js +69 -17
  14. package/cli/repl/commands/repl-dataflow.js +48 -4
  15. package/cli/repl/commands/repl-main.d.ts +2 -0
  16. package/cli/repl/commands/repl-main.js +5 -0
  17. package/cli/repl/commands/repl-query.d.ts +4 -1
  18. package/cli/repl/commands/repl-query.js +72 -22
  19. package/cli/repl/commands/repl-signature.d.ts +7 -0
  20. package/cli/repl/commands/repl-signature.js +119 -0
  21. package/cli/repl/core.d.ts +8 -1
  22. package/cli/repl/core.js +46 -6
  23. package/cli/repl/ghost-hint.d.ts +37 -0
  24. package/cli/repl/ghost-hint.js +72 -0
  25. package/cli/repl/parser/slice-query-parser.d.ts +11 -1
  26. package/cli/repl/parser/slice-query-parser.js +45 -16
  27. package/cli/repl/print-version.d.ts +2 -4
  28. package/cli/repl/print-version.js +41 -23
  29. package/cli/repl/server/connection.js +19 -17
  30. package/cli/slicer-app.d.ts +2 -0
  31. package/cli/slicer-app.js +3 -3
  32. package/cli/wiki.d.ts +2 -2
  33. package/cli/wiki.js +2 -2
  34. package/config.d.ts +70 -13
  35. package/config.js +65 -7
  36. package/control-flow/cfg-dead-code.js +0 -1
  37. package/control-flow/control-flow-graph.js +6 -6
  38. package/control-flow/diff-cfg.js +2 -2
  39. package/control-flow/semantic-cfg-guided-visitor.js +2 -0
  40. package/core/print/slice-diff-ansi.js +8 -8
  41. package/core/steps/all/core/20-dataflow.d.ts +2 -2
  42. package/core/steps/all/static-slicing/00-slice.d.ts +5 -0
  43. package/core/steps/all/static-slicing/00-slice.js +1 -1
  44. package/core/steps/all/static-slicing/10-reconstruct.d.ts +7 -0
  45. package/core/steps/all/static-slicing/10-reconstruct.js +6 -2
  46. package/core/steps/pipeline/default-pipelines.d.ts +20 -16
  47. package/data/r-base-packages.generated.d.ts +44 -0
  48. package/data/r-base-packages.generated.js +32 -0
  49. package/data/r-base-primitives.generated.d.ts +1 -0
  50. package/data/r-base-primitives.generated.js +15 -0
  51. package/data/sigdb/sigdb.remote.json +112 -0
  52. package/dataflow/environments/built-in-proc-name.d.ts +4 -0
  53. package/dataflow/environments/built-in-proc-name.js +4 -0
  54. package/dataflow/environments/built-in.d.ts +14 -4
  55. package/dataflow/environments/built-in.js +13 -2
  56. package/dataflow/environments/data-masking-functions.d.ts +12 -0
  57. package/dataflow/environments/data-masking-functions.js +46 -0
  58. package/dataflow/environments/default-builtin-config.d.ts +72 -19
  59. package/dataflow/environments/default-builtin-config.js +48 -14
  60. package/dataflow/environments/diff.js +1 -1
  61. package/dataflow/environments/environment.js +1 -2
  62. package/dataflow/environments/identifier.d.ts +11 -4
  63. package/dataflow/environments/identifier.js +28 -10
  64. package/dataflow/environments/resolve-by-name.js +16 -2
  65. package/dataflow/extractor.js +6 -3
  66. package/dataflow/graph/call-graph.d.ts +2 -2
  67. package/dataflow/graph/df-helper.d.ts +4 -4
  68. package/dataflow/graph/diff-dataflow-graph.js +2 -2
  69. package/dataflow/graph/edge.d.ts +3 -3
  70. package/dataflow/graph/edge.js +3 -3
  71. package/dataflow/graph/graph-helper.d.ts +2 -2
  72. package/dataflow/internal/linker.js +1 -1
  73. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +7 -0
  74. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +20 -0
  75. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +1 -0
  76. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +2 -49
  77. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +6 -1
  78. package/dataflow/internal/process/functions/call/built-in/built-in-get.js +7 -1
  79. package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +19 -0
  80. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +111 -6
  81. package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +13 -0
  82. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +2 -3
  83. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.d.ts +9 -0
  84. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +19 -0
  85. package/dataflow/internal/process/functions/call/built-in/built-in-with.js +12 -4
  86. package/dataflow/internal/process/functions/call/common.js +8 -1
  87. package/dataflow/internal/process/functions/call/default-call-handling.js +6 -0
  88. package/dataflow/internal/process/functions/call/known-call-handling.d.ts +17 -0
  89. package/dataflow/internal/process/functions/call/known-call-handling.js +32 -0
  90. package/dataflow/internal/process/functions/call/named-call-handling.js +29 -7
  91. package/dataflow/internal/process/functions/process-argument.js +12 -1
  92. package/dataflow/internal/process/process-named-call.d.ts +18 -1
  93. package/dataflow/internal/process/process-named-call.js +94 -0
  94. package/dataflow/processor.d.ts +18 -0
  95. package/documentation/data/faq/faqs.js +5 -1
  96. package/documentation/doc-capabilities.js +1 -1
  97. package/documentation/doc-util/doc-cli-option.d.ts +10 -0
  98. package/documentation/doc-util/doc-cli-option.js +23 -0
  99. package/documentation/doc-util/doc-dfg.js +2 -1
  100. package/documentation/doc-util/doc-query.d.ts +9 -3
  101. package/documentation/doc-util/doc-query.js +9 -4
  102. package/documentation/wiki-dataflow-graph.js +8 -5
  103. package/documentation/wiki-interface.js +3 -2
  104. package/documentation/wiki-linter.js +1 -1
  105. package/documentation/wiki-linting-and-testing.js +4 -1
  106. package/documentation/wiki-mk/doc-context.d.ts +14 -0
  107. package/documentation/wiki-mk/doc-context.js +3 -0
  108. package/documentation/wiki-mk/doc-maker.js +3 -1
  109. package/documentation/wiki-query.js +19 -1
  110. package/documentation/wiki-setup.js +10 -7
  111. package/documentation/wiki-signature-database.d.ts +16 -0
  112. package/documentation/wiki-signature-database.js +293 -0
  113. package/linter/linter-format.d.ts +7 -0
  114. package/linter/linter-rules.d.ts +10 -9
  115. package/linter/rules/naming-convention.d.ts +1 -0
  116. package/linter/rules/naming-convention.js +2 -0
  117. package/linter/rules/no-leaked-credentials.js +1 -2
  118. package/linter/rules/roxygen-arguments.js +18 -5
  119. package/linter/rules/stop-with-call-arg.js +2 -2
  120. package/linter/rules/undefined-symbol-util.d.ts +36 -0
  121. package/linter/rules/undefined-symbol-util.js +149 -0
  122. package/linter/rules/undefined-symbol.d.ts +58 -17
  123. package/linter/rules/undefined-symbol.js +143 -33
  124. package/linter/rules/unused-definition.d.ts +8 -1
  125. package/linter/rules/unused-definition.js +126 -1
  126. package/package.json +23 -10
  127. package/project/context/abstract-flowr-analyzer-context.js +7 -1
  128. package/project/context/flowr-analyzer-context.d.ts +8 -0
  129. package/project/context/flowr-analyzer-context.js +10 -0
  130. package/project/context/flowr-analyzer-dependencies-context.d.ts +28 -4
  131. package/project/context/flowr-analyzer-dependencies-context.js +53 -1
  132. package/project/context/flowr-analyzer-files-context.d.ts +1 -0
  133. package/project/context/flowr-analyzer-files-context.js +2 -1
  134. package/project/context/flowr-analyzer-functions-context.js +1 -1
  135. package/project/context/flowr-file.d.ts +5 -0
  136. package/project/context/flowr-file.js +5 -0
  137. package/project/flowr-analyzer-builder.js +12 -2
  138. package/project/plugins/file-plugins/files/flowr-description-file.js +6 -3
  139. package/project/plugins/file-plugins/files/flowr-namespace-file.js +9 -3
  140. package/project/plugins/file-plugins/files/flowr-news-file.js +1 -3
  141. package/project/plugins/file-plugins/flowr-analyzer-inst-file-plugin.d.ts +26 -0
  142. package/project/plugins/file-plugins/flowr-analyzer-inst-file-plugin.js +39 -0
  143. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.js +1 -1
  144. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.js +2 -2
  145. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-namespace-file-plugin.js +1 -0
  146. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.d.ts +18 -2
  147. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.js +19 -0
  148. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +120 -0
  149. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +518 -0
  150. package/project/plugins/package-version-plugins/package.d.ts +5 -3
  151. package/project/plugins/package-version-plugins/package.js +27 -25
  152. package/project/plugins/plugin-registry.d.ts +3 -2
  153. package/project/plugins/plugin-registry.js +4 -2
  154. package/project/plugins/project-discovery/flowr-analyzer-gitignore-project-discovery-plugin.js +7 -2
  155. package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +3 -1
  156. package/project/sigdb/build.d.ts +131 -0
  157. package/project/sigdb/build.js +628 -0
  158. package/project/sigdb/codec.d.ts +51 -0
  159. package/project/sigdb/codec.js +122 -0
  160. package/project/sigdb/decode.d.ts +58 -0
  161. package/project/sigdb/decode.js +129 -0
  162. package/project/sigdb/decompress.d.ts +44 -0
  163. package/project/sigdb/decompress.js +176 -0
  164. package/project/sigdb/hash.d.ts +9 -0
  165. package/project/sigdb/hash.js +54 -0
  166. package/project/sigdb/index-format.d.ts +40 -0
  167. package/project/sigdb/index-format.js +28 -0
  168. package/project/sigdb/manifest.d.ts +68 -0
  169. package/project/sigdb/manifest.js +146 -0
  170. package/project/sigdb/reader.d.ts +250 -0
  171. package/project/sigdb/reader.js +692 -0
  172. package/project/sigdb/schema.d.ts +196 -0
  173. package/project/sigdb/schema.js +33 -0
  174. package/project/sigdb/sigdb-download.d.ts +65 -0
  175. package/project/sigdb/sigdb-download.js +237 -0
  176. package/project/sigdb/signature-match.d.ts +26 -0
  177. package/project/sigdb/signature-match.js +40 -0
  178. package/project/sigdb/version.d.ts +20 -0
  179. package/project/sigdb/version.js +55 -0
  180. package/queries/catalog/call-context-query/call-context-query-executor.js +1 -3
  181. package/queries/catalog/config-query/config-query-format.d.ts +3 -1
  182. package/queries/catalog/config-query/config-query-format.js +68 -9
  183. package/queries/catalog/dataflow-query/dataflow-query-format.js +11 -1
  184. package/queries/catalog/dependencies-query/dependencies-query-executor.js +1 -1
  185. package/queries/catalog/linter-query/linter-query-executor.d.ts +2 -0
  186. package/queries/catalog/linter-query/linter-query-executor.js +6 -1
  187. package/queries/catalog/linter-query/linter-query-format.d.ts +2 -1
  188. package/queries/catalog/linter-query/linter-query-format.js +40 -8
  189. package/queries/catalog/project-query/project-query-executor.d.ts +15 -0
  190. package/queries/catalog/project-query/project-query-executor.js +96 -4
  191. package/queries/catalog/project-query/project-query-format.d.ts +44 -0
  192. package/queries/catalog/project-query/project-query-format.js +33 -2
  193. package/queries/catalog/signature-query/signature-query-executor.d.ts +29 -0
  194. package/queries/catalog/signature-query/signature-query-executor.js +461 -0
  195. package/queries/catalog/signature-query/signature-query-format.d.ts +138 -0
  196. package/queries/catalog/signature-query/signature-query-format.js +76 -0
  197. package/queries/catalog/signature-query/signature-query-render.d.ts +15 -0
  198. package/queries/catalog/signature-query/signature-query-render.js +155 -0
  199. package/queries/catalog/static-slice-query/static-slice-query-executor.js +9 -3
  200. package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +10 -0
  201. package/queries/catalog/static-slice-query/static-slice-query-format.js +19 -1
  202. package/queries/query-print.js +5 -0
  203. package/queries/query.d.ts +10 -1
  204. package/queries/query.js +5 -2
  205. package/r-bridge/init.js +5 -1
  206. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +10 -0
  207. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.js +55 -0
  208. package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +16 -0
  209. package/r-bridge/lang-4.x/ast/model/processing/node-id.js +27 -0
  210. package/r-bridge/lang-4.x/ast/parser/json/format.js +89 -2
  211. package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-expressions.js +2 -4
  212. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +2 -1
  213. package/r-bridge/parser.d.ts +2 -0
  214. package/r-bridge/retriever.js +4 -1
  215. package/r-bridge/roxygen2/documentation-provider.js +2 -1
  216. package/r-bridge/shell.d.ts +5 -0
  217. package/r-bridge/shell.js +17 -1
  218. package/reconstruct/inline/source-inline-map.d.ts +48 -0
  219. package/reconstruct/inline/source-inline-map.js +94 -0
  220. package/reconstruct/reconstruct.d.ts +19 -2
  221. package/reconstruct/reconstruct.js +79 -16
  222. package/search/search-executor/search-generators.js +5 -22
  223. package/search/search-executor/search-transformer.js +10 -6
  224. package/slicing/criterion/parse.d.ts +22 -4
  225. package/slicing/criterion/parse.js +125 -18
  226. package/slicing/static/slice-call.d.ts +24 -1
  227. package/slicing/static/slice-call.js +90 -0
  228. package/slicing/static/static-slicer.d.ts +7 -0
  229. package/slicing/static/static-slicer.js +38 -3
  230. package/util/collections/arrays.d.ts +4 -5
  231. package/util/collections/arrays.js +7 -18
  232. package/util/hash.d.ts +14 -0
  233. package/util/hash.js +31 -0
  234. package/util/mermaid/dfg.d.ts +7 -2
  235. package/util/mermaid/dfg.js +53 -13
  236. package/util/r-base-packages.d.ts +19 -0
  237. package/util/r-base-packages.js +72 -0
  238. package/util/r-license.js +2 -10
  239. package/util/r-version.d.ts +45 -15
  240. package/util/r-version.js +97 -36
  241. package/util/range.d.ts +15 -0
  242. package/util/range.js +39 -0
  243. package/util/schema.d.ts +10 -0
  244. package/util/schema.js +22 -0
  245. package/util/text/ansi.d.ts +13 -1
  246. package/util/text/ansi.js +27 -4
  247. package/util/text/args.js +1 -2
  248. package/util/version.js +28 -8
  249. package/data/pkgdb/pkgdb-latest.json.br +0 -0
  250. package/data/pkgdb/pkgdb-tiny.json.br +0 -0
  251. package/documentation/wiki-package-database.d.ts +0 -9
  252. package/documentation/wiki-package-database.js +0 -63
  253. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-pkgdb-plugin.d.ts +0 -63
  254. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-pkgdb-plugin.js +0 -174
  255. package/project/plugins/package-version-plugins/pkgdb.d.ts +0 -133
  256. package/project/plugins/package-version-plugins/pkgdb.js +0 -370
@@ -0,0 +1,68 @@
1
+ import { type SigDbPkgMeta, type SigDbShard, type SigDbTier } from './schema';
2
+ import type { ByteRange, SigDbIndexWire, SigShardIndexWire } from './index-format';
3
+ export declare const SigDbManifestMagic = "flowr-sigdb-manifest";
4
+ export declare const SigDbManifestSchema = 2;
5
+ /** shared-dictionary descriptor in a {@link SigDbManifest}: where it lives and how to seek/verify it */
6
+ export interface SigDbDictRef {
7
+ id: string;
8
+ path: string;
9
+ hash: string;
10
+ range: ByteRange;
11
+ byteCount: number;
12
+ strings: number;
13
+ }
14
+ /** one shard within a {@link SigDbManifest} */
15
+ export interface SigDbShardRef {
16
+ /** stable id, e.g. `current-top` */
17
+ id: string;
18
+ tier: SigDbTier;
19
+ shard?: SigDbShard;
20
+ topN?: number;
21
+ /** path to the shard's `.sigs.ndjson` (relative to the manifest); the `.br` alongside is used when only it ships */
22
+ path: string;
23
+ hash: string;
24
+ packages: number;
25
+ versions: number;
26
+ /** id of the shared dictionary this shard's blobs reindex into (see {@link SigDbManifest.dicts}) */
27
+ dict?: string;
28
+ /**
29
+ * the shard's compact index embedded in the manifest (without its own `meta`/`d` -- those are shared). A
30
+ * reader routes and seeks from the manifest alone, needing only the `.br` files (no `.idx` sidecars).
31
+ */
32
+ idx?: SigDbIndexWire | SigShardIndexWire;
33
+ }
34
+ /** a set of shard files (and shared dictionaries) plus the routing needed to read them as one database */
35
+ export interface SigDbManifest {
36
+ format: string;
37
+ schema: number;
38
+ date: string;
39
+ generated: number;
40
+ cranBase?: string;
41
+ /** package metadata, hoisted here once and shared by every shard (they hold overlapping package sets) */
42
+ meta?: Record<string, SigDbPkgMeta>;
43
+ /** shared string dictionaries; a shard references one by id (they are stored once, not per shard) */
44
+ dicts?: SigDbDictRef[];
45
+ shards: SigDbShardRef[];
46
+ }
47
+ /** write a {@link SigDbManifest} (compact JSON) plus a compressed copy per available codec (`.br` always, `.zst` when supported) beside it */
48
+ export declare function writeManifest(file: string, manifest: SigDbManifest): void;
49
+ /** read a manifest file (transparently decompressing a `.br`/`.zst`/`.gz`) */
50
+ export declare function readManifestFile(manifestFile: string): SigDbManifest;
51
+ /** breadth/temporal scope of a bundled sigdb: base R only, `current` (latest CRAN + base R), or the `full` history */
52
+ export type SigDbScope = 'base' | 'current' | 'full';
53
+ /**
54
+ * Location of a bundled sigdb **manifest**, found by walking up from several roots (this module,
55
+ * `$FLOWR_SIGDB_DIR`, the working directory) across the dev (`src`), build (`dist`) and data-mount
56
+ * layouts. With no `scope` it returns the richest available (`full` &gt; `current` &gt; `base`), so a
57
+ * container that ships the full set uses it automatically while a plain npm install falls back to the
58
+ * bundled `base`. Node only (needs `fs`); pass `searchRoots` to override where it looks.
59
+ */
60
+ export declare function defaultSigDbPath(scope?: SigDbScope, searchRoots?: readonly string[]): string | undefined;
61
+ /**
62
+ * Every distinct sigdb bundle discoverable in the search dirs (see {@link defaultSigDbPath}) -- not just the
63
+ * richest scope. So dropping an extra bundle next to the shipped default (a downloaded full-history
64
+ * `full.manifest.json.br`, a custom `*.manifest.json`, or a standalone `*.sigs.ndjson`) makes flowR mount it
65
+ * automatically. Manifests come first (scope-named leading, richest scope first), then standalone bundles; the
66
+ * shard and dictionary files a manifest already owns are skipped. Deduped by filename, first search location wins.
67
+ */
68
+ export declare function defaultSigDbPaths(searchRoots?: readonly string[]): string[];
@@ -0,0 +1,146 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.SigDbManifestSchema = exports.SigDbManifestMagic = void 0;
7
+ exports.writeManifest = writeManifest;
8
+ exports.readManifestFile = readManifestFile;
9
+ exports.defaultSigDbPath = defaultSigDbPath;
10
+ exports.defaultSigDbPaths = defaultSigDbPaths;
11
+ /**
12
+ * The sharded-database manifest format (shard/dictionary descriptors that route a set of shard files as one
13
+ * database), reading/writing it, and discovering the bundled manifests/bundles on flowR's search path. Split
14
+ * out of `../sigdb` as pure format + filesystem discovery, with no dependency on the reader/writer classes.
15
+ */
16
+ const node_fs_1 = __importDefault(require("node:fs"));
17
+ const node_path_1 = __importDefault(require("node:path"));
18
+ const schema_1 = require("./schema");
19
+ const codec_1 = require("./codec");
20
+ exports.SigDbManifestMagic = 'flowr-sigdb-manifest';
21
+ exports.SigDbManifestSchema = 2;
22
+ /** write a {@link SigDbManifest} (compact JSON) plus a compressed copy per available codec (`.br` always, `.zst` when supported) beside it */
23
+ function writeManifest(file, manifest) {
24
+ node_fs_1.default.mkdirSync(node_path_1.default.dirname(node_path_1.default.resolve(file)), { recursive: true });
25
+ const json = JSON.stringify(manifest);
26
+ node_fs_1.default.writeFileSync(file, json);
27
+ for (const spec of (0, codec_1.writeCodecs)()) {
28
+ node_fs_1.default.writeFileSync(`${file}${spec.ext}`, spec.compressSync(json, { level: 11, sizeHint: json.length }));
29
+ }
30
+ }
31
+ /** read a manifest file (transparently decompressing a `.br`/`.zst`/`.gz`) */
32
+ function readManifestFile(manifestFile) {
33
+ const raw = node_fs_1.default.readFileSync(manifestFile);
34
+ const text = (0, codec_1.compressedExtOf)(manifestFile) ? (0, codec_1.decompressSyncFor)(manifestFile, raw).toString('utf8') : raw.toString('utf8');
35
+ return JSON.parse(text);
36
+ }
37
+ /** richest first: a container shipping the full set uses it, else the slim `current`, else the `base` floor */
38
+ const SigDbScopeOrder = ['full', 'current', 'base'];
39
+ /** layouts a bundled sigdb may sit in, relative to a search root -- the root itself (e.g. a `$FLOWR_SIGDB_DIR` data mount), then the dev `src`, build `dist` and data-dir layouts */
40
+ const SigDbSubDirs = ['', 'data/sigdb', 'src/data/sigdb', 'dist/src/data/sigdb'];
41
+ /** roots to search for a bundled sigdb; extendable via `$FLOWR_SIGDB_DIR` (path-delimiter separated) */
42
+ function sigDbSearchRoots(extra) {
43
+ const roots = [...(extra ?? [])];
44
+ const env = typeof process !== 'undefined' ? process.env?.FLOWR_SIGDB_DIR : undefined;
45
+ if (env) {
46
+ roots.push(...env.split(node_path_1.default.delimiter).filter(Boolean));
47
+ }
48
+ if (typeof __dirname !== 'undefined') {
49
+ roots.push(__dirname);
50
+ }
51
+ if (typeof process !== 'undefined' && typeof process.cwd === 'function') {
52
+ roots.push(process.cwd());
53
+ }
54
+ return roots;
55
+ }
56
+ /**
57
+ * Location of a bundled sigdb **manifest**, found by walking up from several roots (this module,
58
+ * `$FLOWR_SIGDB_DIR`, the working directory) across the dev (`src`), build (`dist`) and data-mount
59
+ * layouts. With no `scope` it returns the richest available (`full` &gt; `current` &gt; `base`), so a
60
+ * container that ships the full set uses it automatically while a plain npm install falls back to the
61
+ * bundled `base`. Node only (needs `fs`); pass `searchRoots` to override where it looks.
62
+ */
63
+ function defaultSigDbPath(scope, searchRoots) {
64
+ if (typeof node_fs_1.default?.existsSync !== 'function') {
65
+ return undefined;
66
+ }
67
+ const scopes = scope ? [scope] : SigDbScopeOrder;
68
+ for (const root of sigDbSearchRoots(searchRoots)) {
69
+ for (let dir = root, i = 0; i < 10; i++) {
70
+ for (const sub of SigDbSubDirs) {
71
+ for (const s of scopes) {
72
+ for (const suffix of ['', ...(0, codec_1.readableExtsPreferred)()]) {
73
+ const candidate = node_path_1.default.join(dir, sub, `${s}.manifest.json${suffix}`);
74
+ if (node_fs_1.default.existsSync(candidate)) {
75
+ return candidate;
76
+ }
77
+ }
78
+ }
79
+ }
80
+ const parent = node_path_1.default.dirname(dir);
81
+ if (parent === dir) {
82
+ break;
83
+ }
84
+ dir = parent;
85
+ }
86
+ }
87
+ return undefined;
88
+ }
89
+ /**
90
+ * Every distinct sigdb bundle discoverable in the search dirs (see {@link defaultSigDbPath}) -- not just the
91
+ * richest scope. So dropping an extra bundle next to the shipped default (a downloaded full-history
92
+ * `full.manifest.json.br`, a custom `*.manifest.json`, or a standalone `*.sigs.ndjson`) makes flowR mount it
93
+ * automatically. Manifests come first (scope-named leading, richest scope first), then standalone bundles; the
94
+ * shard and dictionary files a manifest already owns are skipped. Deduped by filename, first search location wins.
95
+ */
96
+ function defaultSigDbPaths(searchRoots) {
97
+ if (typeof node_fs_1.default?.readdirSync !== 'function') {
98
+ return [];
99
+ }
100
+ const manifests = new Map(); // `<name>.manifest.json` (ignoring compression ext) -> first-found path
101
+ const standalones = new Map(); // `<name>.sigs.ndjson` (ignoring compression ext) -> first-found path
102
+ for (const root of sigDbSearchRoots(searchRoots)) {
103
+ for (let dir = root, i = 0; i < 10; i++) {
104
+ for (const sub of SigDbSubDirs) {
105
+ let entries;
106
+ try {
107
+ entries = node_fs_1.default.readdirSync(node_path_1.default.join(dir, sub));
108
+ }
109
+ catch {
110
+ continue; // directory does not exist on this root
111
+ }
112
+ for (const file of entries) {
113
+ const full = node_path_1.default.join(dir, sub, file);
114
+ if (new RegExp(`\\.manifest\\.json${codec_1.CompressedExtPattern}$`).test(file)) {
115
+ const key = (0, codec_1.stripCompressedExt)(file);
116
+ manifests.set(key, manifests.get(key) ?? full);
117
+ }
118
+ else if (new RegExp(`${schema_1.SigDbExt.replace(/\./g, '\\.')}${codec_1.CompressedExtPattern}$`).test(file) && !file.includes('.dict' + schema_1.SigDbExt)) {
119
+ const key = (0, codec_1.stripCompressedExt)(file);
120
+ standalones.set(key, standalones.get(key) ?? full);
121
+ }
122
+ }
123
+ }
124
+ const parent = node_path_1.default.dirname(dir);
125
+ if (parent === dir) {
126
+ break;
127
+ }
128
+ dir = parent;
129
+ }
130
+ }
131
+ // a standalone bundle is a `.sigs.ndjson` that is not a shard of a discovered manifest (`<manifest>.<shard>...`)
132
+ const prefixes = [...manifests.keys()].map(k => k.replace(/\.manifest\.json$/, ''));
133
+ const isShard = (name) => {
134
+ const base = name.replace(new RegExp(`${schema_1.SigDbExt.replace('.', '\\.')}$`), '');
135
+ return prefixes.some(p => base === p || base.startsWith(p + '.'));
136
+ };
137
+ const scopeRank = (name) => {
138
+ const scope = SigDbScopeOrder.indexOf(name.replace(/\.manifest\.json$/, ''));
139
+ return scope === -1 ? SigDbScopeOrder.length : scope; // custom bundles sort after the known scopes
140
+ };
141
+ const orderedManifests = [...manifests.entries()]
142
+ .sort((a, b) => scopeRank(a[0]) - scopeRank(b[0]) || a[0].localeCompare(b[0])).map(([, p]) => p);
143
+ const bundles = standalones.entries().filter(([name]) => !isShard(name)).map(([, p]) => p);
144
+ return [...orderedManifests, ...bundles];
145
+ }
146
+ //# sourceMappingURL=manifest.js.map
@@ -0,0 +1,250 @@
1
+ import { RVersion } from '../../util/r-version';
2
+ import { type LibraryExports, type PkgBlob, type SigDb, type SigDbContent } from './schema';
3
+ import { type VersionRelease } from './version';
4
+ import { type SigDbIndex } from './index-format';
5
+ import { type DecodedFunction, type ResolvedDependency } from './decode';
6
+ import { type SigDbManifest, type SigDbShardRef } from './manifest';
7
+ /** stream-read a whole bundle into a {@link SigDb} (any size; never one string). Prefer {@link SigDatabase} for partial access. */
8
+ export declare function readSignatureDb(file: string): Promise<SigDb>;
9
+ /**
10
+ * The read interface every package-signature source implements, so a single {@link SigDatabase} and a
11
+ * sharded {@link SigDatabaseSet} are interchangeable. Queries are synchronous; any decompression/caching
12
+ * happens once during `open`.
13
+ */
14
+ export interface PackageSignatureSource {
15
+ /** whether the source can resolve the package at all */
16
+ has(pkg: string): boolean;
17
+ /** the export view of a package version (defaults to its latest) */
18
+ lookup(pkg: string, version?: string): LibraryExports | undefined;
19
+ /** rich per-function view (signatures + call graphs) of a package version */
20
+ functions(pkg: string, version?: string): DecodedFunction[] | undefined;
21
+ /** declared dependencies (Depends/Imports/…) of a package version, with version qualifiers */
22
+ dependencies(pkg: string, version?: string): ResolvedDependency[] | undefined;
23
+ /** every package name this source can resolve */
24
+ packageNames(): string[];
25
+ /** whether the package is an R-core / base package (its versions are the R releases it shipped with) */
26
+ isBaseR(pkg: string): boolean;
27
+ /** for a base package, the R versions it was part of core (ascending); `undefined` otherwise */
28
+ coreVersions(pkg: string): RVersion[] | undefined;
29
+ /** the release date of a package version (defaulting to the newest release), or `undefined` if unknown */
30
+ releaseDate(pkg: string, version?: string): Date | undefined;
31
+ /** every known release of a package (version + date), ascending by R-version order */
32
+ releaseDates(pkg: string): VersionRelease[];
33
+ /** the newest version of a package by release date (falling back to the recorded latest) */
34
+ latestVersion(pkg: string): RVersion | undefined;
35
+ /** release any held file handles */
36
+ close(): void;
37
+ }
38
+ /** options controlling where {@link SigDatabase}/{@link SigDatabaseSet} materialize decompressed caches */
39
+ export interface SigDbOpenOptions {
40
+ /** directory for the decompressed, hash-keyed cache (default: see {@link sigDbCacheDir}) */
41
+ cacheDir?: string;
42
+ /** content hash to key the cache (avoids reading the source header; supplied from a manifest) */
43
+ hash?: string;
44
+ /** index to use instead of a sibling `.idx` (supplied from a manifest so no `.idx` file need ship) */
45
+ index?: SigDbIndex;
46
+ }
47
+ /** a caller-supplied index/dictionary for {@link SigDatabase.openSync} (both derived from the source otherwise) */
48
+ export interface OpenSyncOptions {
49
+ index?: SigDbIndex;
50
+ strings?: string[];
51
+ }
52
+ /** {@link SigDatabase.openSyncFrom} options: cache settings plus an optional precomputed hash/index/dictionary */
53
+ export interface OpenSyncFromOptions extends SigDbOpenOptions, OpenSyncOptions {
54
+ hash?: string;
55
+ }
56
+ /**
57
+ * Fast, partial reader for a single bundle. `open()`/`openSync()` load the string dictionary + `.idx`
58
+ * once (a single ranged read of the dictionary section -- no full parse), then every query seeks straight
59
+ * to one package blob on demand. `open()` additionally decompresses a `.br`/`.gz` source into a
60
+ * hash-keyed cache and reuses it on later startups. Implements {@link PackageSignatureSource}.
61
+ */
62
+ export declare class SigDatabase implements PackageSignatureSource {
63
+ private closed;
64
+ /** parsed blobs by blob index so repeated lookups skip the re-read + JSON.parse; FIFO-bounded to cap memory */
65
+ private readonly blobCache;
66
+ private static readonly BlobCacheCap;
67
+ private readonly fd;
68
+ readonly strings: string[];
69
+ readonly index: SigDbIndex;
70
+ readonly content: SigDbContent | undefined;
71
+ private readonly cranBase;
72
+ private constructor();
73
+ /**
74
+ * Open a plain, seekable `.sigs.ndjson` synchronously. Pass `index` to skip reading the `.idx`,
75
+ * and `strings` to use an already-loaded shared dictionary instead of the file's own `d` section (for a
76
+ * blob-only shard). One ranged read loads the dictionary -- no readline overhead.
77
+ */
78
+ static openSync(plainFile: string, opts?: OpenSyncOptions): SigDatabase;
79
+ /** open a `.sigs.ndjson`, `.br` or `.gz`; compressed sources are decompressed into a hash-keyed cache once */
80
+ static open(source: string, opts?: SigDbOpenOptions): Promise<SigDatabase>;
81
+ /**
82
+ * Like {@link open} but fully synchronous (blocking decompression); a `hash` keys the cache when `source`
83
+ * is compressed. Pass `strings` for a blob-only shard that shares an already-loaded dictionary.
84
+ */
85
+ static openSyncFrom(source: string, opts: OpenSyncFromOptions): SigDatabase;
86
+ has(pkg: string): boolean;
87
+ packageNames(): string[];
88
+ /** load a single package's blob by seeking to its line (undefined if absent); cached by blob index */
89
+ blob(pkg: string): PkgBlob | undefined;
90
+ /** seek to a byte range, read + decode the package blob there (no caching) */
91
+ private readBlobAt;
92
+ /** read every unique package blob in index order (used to re-hash a whole shard during verification) */
93
+ allBlobs(): PkgBlob[];
94
+ /** recompute this bundle's self-contained content hash from its re-read data (matches {@link writeSignatureDb}) */
95
+ contentHash(blobs?: PkgBlob[]): string;
96
+ /** whether this bundle actually carries the given version of a package (not just the package) */
97
+ hasVersion(pkg: string, version: string): boolean;
98
+ lookup(pkg: string, version?: string): LibraryExports | undefined;
99
+ functions(pkg: string, version?: string): DecodedFunction[] | undefined;
100
+ dependencies(pkg: string, version?: string): ResolvedDependency[] | undefined;
101
+ /** whether this is an R-core / base package (its versions are the R releases it shipped with; see {@link SigDbPkgMeta}) */
102
+ isBaseR(pkg: string): boolean;
103
+ /**
104
+ * The R versions a base package was part of core, in ascending R-version order (exactly its stored
105
+ * versions). `undefined` for a non-base package. E.g. `mva` returns `…1.9.1`, `parallel` `2.14.0…`.
106
+ */
107
+ coreVersions(pkg: string): RVersion[] | undefined;
108
+ /** the release date of a package version (defaulting to the newest release), or `undefined` if unknown */
109
+ releaseDate(pkg: string, version?: string): Date | undefined;
110
+ /** every known release date of a package, in ascending R-version order (empty when no dates were stored) */
111
+ releaseDates(pkg: string): VersionRelease[];
112
+ /** the newest version of a package by release date (falling back to the recorded latest, then SemVer order) */
113
+ latestVersion(pkg: string): RVersion | undefined;
114
+ /** close the underlying file descriptor (idempotent; safe to call more than once) */
115
+ close(): void;
116
+ }
117
+ /** options for {@link SigDatabaseSet.openManifest} -- the base cache options plus per-shard enable/disable */
118
+ export interface SigDbSetOpenOptions extends SigDbOpenOptions {
119
+ /** only load these shard ids (e.g. `['base-current','current-top']`); omit to load all */
120
+ includeShards?: readonly string[];
121
+ /** load every shard except these ids (e.g. `['full-top','full-rest']` for a current-only view) */
122
+ excludeShards?: readonly string[];
123
+ }
124
+ /** one mounted shard: its manifest entry paired with the opened {@link SigDatabase} */
125
+ interface MountedShard {
126
+ ref: SigDbShardRef;
127
+ db: SigDatabase;
128
+ }
129
+ /**
130
+ * A transparent, read-only view over several {@link SigDatabase} shards described by a {@link SigDbManifest}.
131
+ * When the manifest embeds each shard's index (the default), `openManifest()` reads only that small file to
132
+ * build the package to shard routing table.
133
+ */
134
+ export declare class SigDatabaseSet implements PackageSignatureSource {
135
+ private readonly opened;
136
+ readonly manifest: SigDbManifest;
137
+ /** the directory the manifest's shard/dict paths are relative to */
138
+ readonly baseDir: string;
139
+ private readonly indices;
140
+ /** package name to shard indices, ordered by preference (current before full) */
141
+ private readonly routes;
142
+ private readonly cacheDir?;
143
+ private constructor();
144
+ /** read + validate a manifest and apply the include/exclude shard filter */
145
+ private static prepManifest;
146
+ /** build the package to shard routing (current before full) and construct the set from resolved indices */
147
+ private static assemble;
148
+ static openManifest(manifestFile: string, opts?: SigDbSetOpenOptions): Promise<SigDatabaseSet>;
149
+ /**
150
+ * Synchronous {@link openManifest} -- needs every shard to embed its index (the default for the bundles
151
+ * flowR ships). Shards and dictionaries still decompress lazily.
152
+ */
153
+ static openManifestSync(manifestFile: string, opts?: SigDbSetOpenOptions): SigDatabaseSet;
154
+ /** shared dictionaries, loaded (decompressed + parsed) once and cached by id */
155
+ private readonly dictCache;
156
+ /** load (and cache) a shared dictionary's strings, decompressing its `.br` into the cache once */
157
+ private dictionaryStrings;
158
+ /** lazily open a shard -- decompressing its `.br` (and its shared dictionary) into the cache on first access */
159
+ private shard;
160
+ /**
161
+ * Warm the shards (and their shared dictionaries) needed for `pkgs`, or **everything** when omitted.
162
+ * Afterward, the synchronous query methods, for the latest *and* historical versions, do no I/O or decompression.
163
+ */
164
+ preload(pkgs?: readonly string[]): Promise<void>;
165
+ /**
166
+ * Warm just the shards matching `include`, e.g., only the current-tier top shards (the base + most-downloaded
167
+ * packages) to speed up common lookups without paying for the long tail or the history shards. See {@link preload}.
168
+ */
169
+ preloadShards(include: (shard: SigDbShardRef) => boolean): Promise<void>;
170
+ /** decompress the given shards + their shared dictionaries concurrently, then open them (see {@link preload}) */
171
+ private warmShards;
172
+ /** the shard indices that can serve this package, preferred order; optionally requiring a specific version */
173
+ private route;
174
+ /** read (once) the blob from the shard with the most complete history -- a `full` or `history` tier if present */
175
+ private historyBlob;
176
+ has(pkg: string): boolean;
177
+ /** whether any active shard actually carries the given version of a package (not just the package) */
178
+ hasVersion(pkg: string, version: string): boolean;
179
+ packageNames(): string[];
180
+ /** open (blocking) and return every shard database with its manifest ref -- used for whole-set verification */
181
+ allShards(): MountedShard[];
182
+ /** load (and cache) a shared dictionary's strings by id -- for verification/inspection */
183
+ sharedDictionary(id: string): string[];
184
+ /** the first non-empty result from the shards that can serve `pkg` (in preferred order: current before full) */
185
+ private firstOf;
186
+ lookup(pkg: string, version?: string): LibraryExports | undefined;
187
+ functions(pkg: string, version?: string): DecodedFunction[] | undefined;
188
+ dependencies(pkg: string, version?: string): ResolvedDependency[] | undefined;
189
+ /** whether this is an R-core / base package (see {@link SigDatabase.isBaseR}); O(1) via the hoisted metadata */
190
+ isBaseR(pkg: string): boolean;
191
+ /** the R versions a base package was part of core (ascending); `undefined` if not a base package */
192
+ coreVersions(pkg: string): RVersion[] | undefined;
193
+ /** every known release of a package (version + date), ascending -- read once from the most complete shard */
194
+ releaseDates(pkg: string): VersionRelease[];
195
+ /** the release date of a package version (defaulting to the newest release), or `undefined` if unknown */
196
+ releaseDate(pkg: string, version?: string): Date | undefined;
197
+ /** the newest version of a package by release date (falling back to the recorded latest, then SemVer order) */
198
+ latestVersion(pkg: string): RVersion | undefined;
199
+ /**
200
+ * Close every opened shard's file descriptor and drop the in-memory caches (opened shards + shared
201
+ * dictionaries), so the (potentially large) dictionary strings can be reclaimed by the GC. Idempotent.
202
+ */
203
+ close(): void;
204
+ }
205
+ /**
206
+ * Open a path-based source once, process-wide, synchronously. Returns the shared instance (opening it on the
207
+ * first call), or `undefined` if the path needs async opening (a `.br`/`.gz` bundle -- use {@link getSharedSigSource}).
208
+ * Throws only if a sync-openable source fails to open.
209
+ */
210
+ export declare function getSharedSigSourceSync(source: string): PackageSignatureSource | undefined;
211
+ /** Open a path-based source once, process-wide (async: also handles `.br`/`.zst`/`.gz` bundles and non-embedded manifests). */
212
+ export declare function getSharedSigSource(source: string): Promise<PackageSignatureSource | undefined>;
213
+ /** per-shard result of {@link verifyShardedDatabase} */
214
+ export interface ShardVerifyResult {
215
+ id: string;
216
+ packages: number;
217
+ /** the shard's content hash recomputed from its re-read blobs matches the manifest + file header */
218
+ hashOk: boolean;
219
+ expectedHash: string;
220
+ actualHash: string;
221
+ }
222
+ /** the outcome of {@link verifyShardedDatabase} */
223
+ export interface SigDbVerifyReport {
224
+ ok: boolean;
225
+ /** the shared dictionaries' recomputed hashes all match the manifest */
226
+ dictsOk: boolean;
227
+ shards: ShardVerifyResult[];
228
+ /** number of distinct packages routed by the manifest */
229
+ routedPackages: number;
230
+ /** functions/dependencies decoded during the spot-check without an out-of-range string */
231
+ spotChecked: number;
232
+ /** required packages (e.g. base R) that were requested but not found */
233
+ missingRequired: string[];
234
+ /** every problem found (empty when `ok`) */
235
+ errors: string[];
236
+ }
237
+ /** {@link verifyShardedDatabase} options: open settings plus which packages must exist and how many to spot-check */
238
+ export interface VerifyOptions extends SigDbOpenOptions {
239
+ requirePackages?: readonly string[];
240
+ sample?: number;
241
+ }
242
+ /**
243
+ * Re-read a written sharded database from its (compressed) files and check it is internally consistent:
244
+ * every shard's content hash recomputed from its re-read blobs matches both the manifest and the file
245
+ * header; every shared dictionary's hash matches; the manifest routes every package a shard holds; a
246
+ * sample of packages decodes (functions + dependencies) with all string indices in range; and any
247
+ * `requirePackages` (e.g. base R) are present. This is a strong correctness gate: correctness over speed.
248
+ */
249
+ export declare function verifyShardedDatabase(manifestFile: string, opts?: VerifyOptions): Promise<SigDbVerifyReport>;
250
+ export {};