@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
@@ -3,8 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FlowrAnalyzerDependenciesContext = void 0;
4
4
  const abstract_flowr_analyzer_context_1 = require("./abstract-flowr-analyzer-context");
5
5
  const flowr_analyzer_package_versions_plugin_1 = require("../plugins/package-version-plugins/flowr-analyzer-package-versions-plugin");
6
+ const package_1 = require("../plugins/package-version-plugins/package");
6
7
  const identifier_1 = require("../../dataflow/environments/identifier");
7
8
  const config_1 = require("../../config");
9
+ const r_version_1 = require("../../util/r-version");
8
10
  /**
9
11
  * Manages the project's dependencies, their versions, and their interplay with {@link FlowrAnalyzerPackageVersionsPlugin}s.
10
12
  */
@@ -32,6 +34,12 @@ class FlowrAnalyzerDependenciesContext extends abstract_flowr_analyzer_context_1
32
34
  }
33
35
  return this.plugins.flatMap(p => p.loadedDatabases());
34
36
  }
37
+ availableSignatureDatabases() {
38
+ return [...new Set(this.loadedSignatureDatabases().map(d => d.scope))];
39
+ }
40
+ hasSignatureDatabase() {
41
+ return (0, config_1.isSigDbEnabled)(this.ctx.config) && this.plugins.some(p => p.loadedDatabases().length > 0);
42
+ }
35
43
  packagesExporting(name) {
36
44
  if (!(0, config_1.isSigDbEnabled)(this.ctx.config)) {
37
45
  return [];
@@ -129,10 +137,13 @@ class FlowrAnalyzerDependenciesContext extends abstract_flowr_analyzer_context_1
129
137
  }
130
138
  return this;
131
139
  }
132
- getDependency(name) {
140
+ getDependency(name, version) {
133
141
  if (!this.staticsLoaded) {
134
142
  this.resolveStaticDependencies();
135
143
  }
144
+ if (version !== undefined) {
145
+ return this.resolvePinnedDependency(name, typeof version === 'string' ? r_version_1.RRange.parse('=' + version) : version);
146
+ }
136
147
  const existing = this.dependencies.get(name);
137
148
  // a package already carrying exports is complete; a version-only one is still enriched below
138
149
  if (existing?.namespaceInfo || (!existing && this.resolvedMisses.has(name))) {
@@ -150,9 +161,20 @@ class FlowrAnalyzerDependenciesContext extends abstract_flowr_analyzer_context_1
150
161
  }
151
162
  return existing;
152
163
  }
153
- inferredVersion(name) {
164
+ /** Resolve `name` constrained to `range` via the plugins (uncached); falls back to the cached dependency. */
165
+ resolvePinnedDependency(name, range) {
166
+ const pin = new package_1.Package({ name, versionConstraints: range ? [range] : [] });
167
+ for (const resolve of this.lazyResolvers) {
168
+ const resolved = resolve(name, pin);
169
+ if (resolved) {
170
+ return resolved;
171
+ }
172
+ }
173
+ return this.getDependency(name);
174
+ }
175
+ inferredRange(name) {
154
176
  const pkg = this.getDependency(name);
155
- return pkg?.hasSatisfiableVersion() ? pkg.derivedVersion : undefined;
177
+ return pkg?.hasSatisfiableVersion() ? pkg.derivedRange : undefined;
156
178
  }
157
179
  getDependencies() {
158
180
  if (!this.staticsLoaded) {
@@ -160,6 +182,11 @@ class FlowrAnalyzerDependenciesContext extends abstract_flowr_analyzer_context_1
160
182
  }
161
183
  return Array.from(this.dependencies.values());
162
184
  }
185
+ declaredPackageNames() {
186
+ this.ensureStaticsLoaded();
187
+ const declared = Object.values(this.ctx.meta.getDeclaredPackages());
188
+ return [...new Set(declared.flatMap(group => group?.map(p => p.name) ?? []))];
189
+ }
163
190
  }
164
191
  exports.FlowrAnalyzerDependenciesContext = FlowrAnalyzerDependenciesContext;
165
192
  //# sourceMappingURL=flowr-analyzer-dependencies-context.js.map
@@ -8,7 +8,7 @@ import type { FlowrDescriptionFile } from '../plugins/file-plugins/files/flowr-d
8
8
  import type { FlowrNewsFile } from '../plugins/file-plugins/files/flowr-news-file';
9
9
  import type { FlowrNamespaceFile } from '../plugins/file-plugins/files/flowr-namespace-file';
10
10
  import type { FlowrRProjectFile } from '../plugins/file-plugins/files/flowr-rproject-file';
11
- import { ProjectKind } from './project-kind';
11
+ import type { ProjectKind } from './project-kind';
12
12
  /**
13
13
  * This is a request to process a folder as a project, which will be expanded by the registered {@link FlowrAnalyzerProjectDiscoveryPlugin}s.
14
14
  */
@@ -31,6 +31,7 @@ export type RoleBasedFiles = {
31
31
  [FileRole.License]: FlowrFileProvider[];
32
32
  [FileRole.VirtualEnv]: FlowrFileProvider[];
33
33
  [FileRole.Startup]: FlowrFileProvider[];
34
+ [FileRole.Environment]: FlowrFileProvider[];
34
35
  [FileRole.Source]: FlowrFileProvider[];
35
36
  [FileRole.Data]: FlowrFileProvider[];
36
37
  [FileRole.Other]: FlowrFileProvider[];
@@ -93,6 +94,8 @@ export interface ReadOnlyFlowrAnalyzerFilesContext {
93
94
  * @returns The actual path of the file if it exists, otherwise `undefined`.
94
95
  */
95
96
  exists(path: string, ignoreCase: boolean): string | undefined;
97
+ /** The project root folder (common directory of the requested roots), or `undefined` if none was requested. */
98
+ root(): string | undefined;
96
99
  /**
97
100
  * Until parsers support multiple request types from the virtual context system,
98
101
  * we resolve their contents.
@@ -112,6 +115,11 @@ export interface ReadOnlyFlowrAnalyzerFilesContext {
112
115
  * {@link ProjectKind.Unknown}. The result is cached and invalidated whenever the files change.
113
116
  */
114
117
  projectKind(): ProjectKind;
118
+ /**
119
+ * The root paths that were requested for analysis: the folder for a project request, or the containing
120
+ * folder for a single-file request. Useful to report back which inputs did not resolve to anything.
121
+ */
122
+ getRequestedRoots(): readonly string[];
115
123
  }
116
124
  /**
117
125
  * This is the analyzer file context to be modified by all plugins that affect the files.
@@ -152,14 +160,8 @@ export declare class FlowrAnalyzerFilesContext extends AbstractFlowrAnalyzerCont
152
160
  */
153
161
  consideredFilesList(): readonly string[];
154
162
  projectKind(): ProjectKind;
163
+ getRequestedRoots(): readonly string[];
155
164
  private classifyProject;
156
- /**
157
- * Whether the project is a shiny app: it has the canonical entry files (a single `app.R`, or the `ui.R`+`server.R`
158
- * pair -- a lone `server.R` is not enough) and one of them actually loads or calls the shiny stack. The usage
159
- * check keeps a coincidental `ui.R`/`server.R` pair from being mistaken for an app; only when none of the entry
160
- * files can be read do we fall back to trusting the file names alone.
161
- */
162
- private isShinyApp;
163
165
  /**
164
166
  * Add multiple requests to the context. This is just a convenience method that calls {@link addRequest} for each request.
165
167
  */
@@ -15,17 +15,8 @@ const fs_1 = __importDefault(require("fs"));
15
15
  const path_1 = __importDefault(require("path"));
16
16
  const files_1 = require("../../util/files");
17
17
  const glob_1 = require("../../util/glob");
18
- const project_kind_1 = require("./project-kind");
18
+ const classify_project_kind_1 = require("./classify-project-kind");
19
19
  const fileLog = log_1.log.getSubLogger({ name: 'flowr-analyzer-files-context' });
20
- const notebookExtension = /\.(ipynb|rmd|qmd|rnw)$/;
21
- const shinyDescriptionTypes = new Set(['shiny', 'shiny-app', 'shinyapp']);
22
- /** the (lower-cased) file names a shiny app is assembled from; the app is `app.r`, or the `ui.r`+`server.r` pair */
23
- const shinyEntryFiles = new Set(['app.r', 'ui.r', 'server.r', 'global.r']);
24
- /**
25
- * Evidence that a file actually is part of a shiny app rather than just sharing a name: a load of the shiny stack
26
- * or a call to one of its entry points. Kept broad enough to also catch `bslib`/`shinydashboard`/`golem` apps.
27
- */
28
- const shinyUsage = /(?:library|require|requireNamespace|loadNamespace)\s*\(\s*['"]?(?:shiny|bslib|shinydashboard|shinyMobile|golem|flexdashboard)\b|\b(?:shinyApp|shinyServer|shinyUI|runApp|fluidPage|fluidRow|navbarPage|bootstrapPage|fillPage|dashboardPage|page_fluid|page_sidebar|page_navbar|pageWithSidebar)\s*\(/;
29
20
  function wrapFile(file, roles) {
30
21
  if (typeof file === 'string') {
31
22
  return new flowr_file_1.FlowrTextFile(file, roles);
@@ -109,20 +100,28 @@ class FlowrAnalyzerFilesContext extends abstract_flowr_analyzer_context_1.Abstra
109
100
  projectKind() {
110
101
  return this.projectKindCache ??= this.ctx.config.project.useProjectType ?? this.classifyProject();
111
102
  }
103
+ getRequestedRoots() {
104
+ return this.requestedRoots;
105
+ }
112
106
  classifyProject() {
107
+ const opts = (0, classify_project_kind_1.resolveClassifyOptions)(this.ctx.config.project.classification);
113
108
  const descriptions = this.getFilesByRole(flowr_file_1.FileRole.Description);
114
- // an explicit `Type: shiny` in the DESCRIPTION settles it without looking at any source
115
- if (descriptions.some(d => shinyDescriptionTypes.has(d.type() ?? ''))) {
116
- return project_kind_1.ProjectKind.ShinyApp;
117
- }
118
- // the readable entry files by (lower-cased) name, plus every known file name for the coarser checks below
109
+ const reader = (f) => () => {
110
+ try {
111
+ return f.content().toString();
112
+ }
113
+ catch {
114
+ return undefined;
115
+ }
116
+ };
117
+ // the readable entry files by (lower-cased) name, plus every known file name for the coarser checks
119
118
  const entries = new Map();
120
119
  const names = new Set();
121
120
  for (const f of this.getAllFiles()) {
122
121
  const name = path_1.default.basename(f.path()).toLowerCase();
123
122
  names.add(name);
124
- if (shinyEntryFiles.has(name)) {
125
- entries.set(name, f);
123
+ if (opts.shinyEntryFiles.has(name)) {
124
+ entries.set(name, reader(f));
126
125
  }
127
126
  }
128
127
  const pending = this.loadingOrder.getUnorderedRequests()
@@ -130,57 +129,16 @@ class FlowrAnalyzerFilesContext extends abstract_flowr_analyzer_context_1.Abstra
130
129
  for (const p of [...pending, ...this.consideredFiles]) {
131
130
  const name = path_1.default.basename(p).toLowerCase();
132
131
  names.add(name);
133
- if (shinyEntryFiles.has(name) && !entries.has(name)) {
134
- entries.set(name, this.getFileByPath(p) ?? new flowr_file_1.FlowrTextFile(p));
135
- }
136
- }
137
- if (this.isShinyApp(names, entries)) {
138
- return project_kind_1.ProjectKind.ShinyApp;
139
- }
140
- if (descriptions.length > 0) {
141
- return project_kind_1.ProjectKind.Package;
142
- }
143
- if (names.size === 0) {
144
- return project_kind_1.ProjectKind.Unknown;
145
- }
146
- for (const name of names) {
147
- if (notebookExtension.test(name)) {
148
- return project_kind_1.ProjectKind.Notebook;
149
- }
150
- }
151
- let rSources = 0;
152
- for (const name of names) {
153
- if (name.endsWith('.r')) {
154
- rSources++;
155
- }
156
- }
157
- return rSources <= 1 ? project_kind_1.ProjectKind.Script : project_kind_1.ProjectKind.Project;
158
- }
159
- /**
160
- * Whether the project is a shiny app: it has the canonical entry files (a single `app.R`, or the `ui.R`+`server.R`
161
- * pair -- a lone `server.R` is not enough) and one of them actually loads or calls the shiny stack. The usage
162
- * check keeps a coincidental `ui.R`/`server.R` pair from being mistaken for an app; only when none of the entry
163
- * files can be read do we fall back to trusting the file names alone.
164
- */
165
- isShinyApp(names, entries) {
166
- if (!names.has('app.r') && !(names.has('ui.r') && names.has('server.r'))) {
167
- return false;
168
- }
169
- let couldRead = false;
170
- for (const f of entries.values()) {
171
- let content;
172
- try {
173
- content = f.content().toString();
174
- }
175
- catch {
176
- continue;
177
- }
178
- couldRead = true;
179
- if (shinyUsage.test(content)) {
180
- return true;
132
+ if (opts.shinyEntryFiles.has(name) && !entries.has(name)) {
133
+ entries.set(name, reader(this.getFileByPath(p) ?? new flowr_file_1.FlowrTextFile(p)));
181
134
  }
182
135
  }
183
- return !couldRead;
136
+ return (0, classify_project_kind_1.classifyProjectKind)({
137
+ names,
138
+ entries,
139
+ descriptionTypes: descriptions.map(d => d.type() ?? ''),
140
+ descriptionCount: descriptions.length
141
+ }, opts);
184
142
  }
185
143
  /**
186
144
  * Add multiple requests to the context. This is just a convenience method that calls {@link addRequest} for each request.
@@ -332,7 +290,8 @@ class FlowrAnalyzerFilesContext extends abstract_flowr_analyzer_context_1.Abstra
332
290
  }
333
291
  return undefined;
334
292
  }
335
- catch {
293
+ catch (e) {
294
+ fileLog.warn(`Could not resolve '${p}': ${e instanceof Error ? e.message : String(e)}`);
336
295
  return undefined;
337
296
  }
338
297
  }
@@ -23,6 +23,7 @@ export interface DeclaredPackages {
23
23
  depends?: readonly Package[];
24
24
  suggests?: readonly Package[];
25
25
  linkingTo?: readonly Package[];
26
+ enhances?: readonly Package[];
26
27
  }
27
28
  /** The project metadata a plugin may contribute, see {@link FlowrAnalyzerMetaContext#contribute}. */
28
29
  export interface ProjectMetaFields {
@@ -39,6 +39,11 @@ export declare enum FileRole {
39
39
  * These commonly bootstrap a package manager, e.g. by sourcing `packrat/init.R` or `renv/activate.R`.
40
40
  */
41
41
  Startup = "startup",
42
+ /**
43
+ * Environment-variable definitions read at startup (`.Renviron`, `Renviron.site`). These are `KEY=value`
44
+ * files, not R source, so they are labeled but not parsed as R.
45
+ */
46
+ Environment = "environment",
42
47
  /**
43
48
  * Catch-all for any file that provides usable R source code to incorporate into the analysis.
44
49
  * Please note, that the loading order/inclusion and even potential relevance of these source files
@@ -40,6 +40,11 @@ var FileRole;
40
40
  * These commonly bootstrap a package manager, e.g. by sourcing `packrat/init.R` or `renv/activate.R`.
41
41
  */
42
42
  FileRole["Startup"] = "startup";
43
+ /**
44
+ * Environment-variable definitions read at startup (`.Renviron`, `Renviron.site`). These are `KEY=value`
45
+ * files, not R source, so they are labeled but not parsed as R.
46
+ */
47
+ FileRole["Environment"] = "environment";
43
48
  /**
44
49
  * Catch-all for any file that provides usable R source code to incorporate into the analysis.
45
50
  * Please note, that the loading order/inclusion and even potential relevance of these source files
@@ -12,6 +12,8 @@ import type { DecodedFunction } from './sigdb/decode';
12
12
  import { FunctionArgument, type DataflowGraph } from '../dataflow/graph/graph';
13
13
  import type { ReadOnlyFlowrAnalyzerDependenciesContext } from './context/flowr-analyzer-dependencies-context';
14
14
  import type { ReadonlyFlowrAnalysisProvider } from './flowr-analyzer';
15
+ /** the pseudo-package standing for the analyzed project itself, never one of its own dependencies */
16
+ export declare const ProjectPackage = "current";
15
17
  /** where a single bound on a dependency's version came from */
16
18
  export type ConstraintSource = 'declared' | 'transitive' | 'signature' | 'date' | 'base-r' | 'available' | 'indirect';
17
19
  /**
@@ -31,6 +33,12 @@ export interface DerivedConstraint {
31
33
  readonly parameter?: string;
32
34
  /** the version bound this constraint establishes, if any (e.g. `>=1.1.0`, `<=2021-05-31`) */
33
35
  readonly bound?: string;
36
+ /**
37
+ * Set when the bound only holds for *some* of the origin's own candidate versions (e.g. only the newer releases
38
+ * of `dplyr` require `R >= 4.1`). Such a constraint is reported but never filters, as picking another version of
39
+ * the origin avoids it.
40
+ */
41
+ readonly partial?: boolean;
34
42
  }
35
43
  /** notified of each constraint as it is applied, so a caller can collect provenance (e.g. into the query's evidence) */
36
44
  export type ConstraintObserver = (constraint: DerivedConstraint) => void;
@@ -50,11 +58,19 @@ export interface TimelineEntry {
50
58
  readonly ver: VersionString;
51
59
  readonly date?: Date;
52
60
  }
53
- /** the version qualifier a package imposes on one of its own dependencies (a transitive constraint) */
61
+ /**
62
+ * The version qualifier a package imposes on one of its own dependencies (a transitive constraint). Because the
63
+ * declaring package's own version is usually a guess too, the requirement is read from *every* version of it that is
64
+ * still in play: {@link ranges} holds one alternative per distinct requirement found, and only a
65
+ * {@link universal} constraint (one that every one of those versions declares) may filter.
66
+ */
54
67
  export interface TransitiveConstraint {
55
- readonly range: Range;
56
- /** the declaring package + version, e.g. `dplyr 1.1.0` */
68
+ /** the alternative requirements; a version satisfying any one of them is acceptable */
69
+ readonly ranges: readonly Range[];
70
+ /** the declaring package + version, e.g. `dplyr 1.1.0`, or just `dplyr` when read from several of its versions */
57
71
  readonly from: string;
72
+ /** whether every considered version of the declaring package requires *something*, so the constraint can filter */
73
+ readonly universal: boolean;
58
74
  }
59
75
  /** the versions of a package before and after the signature-usage filter, plus the declared inputs used to build them */
60
76
  export interface SurvivingEntries {
@@ -64,7 +80,7 @@ export interface SurvivingEntries {
64
80
  readonly preSignature: TimelineEntry[];
65
81
  /** the memoized function resolver used for the signature pass (shared so evidence reuses the decodes) */
66
82
  readonly getFn: FnResolver;
67
- /** the combined, satisfiable declared range (`inferredVersion`), or `undefined` if none/contradictory */
83
+ /** the combined, satisfiable declared range (`inferredRange`), or `undefined` if none/contradictory */
68
84
  readonly declaredRange: Range | undefined;
69
85
  /** the raw declared version constraints */
70
86
  readonly declaredConstraints: readonly string[];
@@ -74,6 +90,8 @@ export interface SurvivingEntries {
74
90
  readonly unsatisfiable: boolean;
75
91
  /** the total number of versions the database carries for the package (the full history the candidates are drawn from) */
76
92
  readonly total: number;
93
+ /** how many of those versions the *declared* constraints alone allow, the baseline the guess narrows down from */
94
+ readonly declared: number;
77
95
  }
78
96
  /** one package's surviving versions, ordered by preference for the constraint-space explosion */
79
97
  export interface OrderedCandidates {
@@ -105,50 +123,124 @@ export declare function dateCutoff(spec: string): Date | undefined;
105
123
  export declare function isoDay(date: Date): string;
106
124
  /** scan the dataflow graph for every call that resolves (via {@link Dataflow.qualify}) to a package export */
107
125
  export declare function collectUsage(graph: DataflowGraph, deps?: ReadOnlyFlowrAnalyzerDependenciesContext): Map<string, PackageUsage>;
108
- /** intersection of multiple survivor sets -- versions that survive in every set */
126
+ /** intersection of multiple survivor sets: versions that survive in every set */
109
127
  export declare function intersectSurvivors(survivorSets: readonly (readonly TimelineEntry[])[]): TimelineEntry[];
110
128
  /**
111
- * The transitive constraints declared packages place on their own dependencies (one level deep). `versionOf` overrides
112
- * which version of each declaring package to read the requirements from -- passing the previous pass's guessed versions
113
- * lets two packages tighten each other (a bounded fixpoint over mutual constraints).
129
+ * The transitive constraints declared packages place on their own dependencies (one level deep). `versionsOf` gives
130
+ * the versions of each declaring package that are still in play. The requirements are read from all of them, so a
131
+ * constraint only ever filters when *every* one of them declares it (see {@link TransitiveConstraint}). Without it,
132
+ * the single {@link Package.resolvedVersion|resolved version} is used, which is by definition universal.
114
133
  */
115
- export declare function collectTransitiveConstraints(deps: ReadOnlyFlowrAnalyzerDependenciesContext, sources: readonly PackageSignatureSource[], versionOf?: (pkg: string) => string | undefined): Map<string, TransitiveConstraint[]>;
134
+ export declare function collectTransitiveConstraints(deps: ReadOnlyFlowrAnalyzerDependenciesContext, sources: readonly PackageSignatureSource[], versionsOf?: (pkg: string) => readonly VersionString[] | undefined): Map<string, TransitiveConstraint[]>;
116
135
  /** the default bound for the fixpoint loops, overridable per query with {@link GuessDepVersionsQuery.maxIterations} */
117
136
  export declare const DefaultFixpointIterations = 8;
118
137
  /** repeatedly run `step` until it reports no further change (returns `false`) or `maxIterations` is reached */
119
138
  export declare function iterateToFixpoint(maxIterations: number, step: () => boolean): void;
120
- /** one package's mutable surviving set for the arc-consistency pass */
121
- export interface ArcEntry {
122
- readonly name: string;
123
- readonly src: PackageSignatureSource | undefined;
124
- /** the sigdb package its versions are drawn from (see {@link timelinePackageKey}) */
139
+ /** the per-analysis inputs every constraint pass shares, see {@link VersionSpace} */
140
+ export interface VersionSpaceOptions {
141
+ readonly deps: ReadOnlyFlowrAnalyzerDependenciesContext;
142
+ /** how the analyzed code calls each package, from {@link collectUsage} */
143
+ readonly usage: ReadonlyMap<string, PackageUsage>;
144
+ /** only consider releases up to this instant */
145
+ readonly cutoff?: Date;
146
+ /** the assumed R version bounding base packages, when genuinely known */
147
+ readonly rVersion?: string;
148
+ /** constraint sources to skip entirely: neither filtered on nor reported */
149
+ readonly disabled?: ReadonlySet<ConstraintSource>;
150
+ }
151
+ /** a target's sigdb package key, merged source and memoized signature resolver */
152
+ interface PackageResolution {
125
153
  readonly key: string;
126
- survivors: readonly TimelineEntry[];
154
+ readonly src: PackageSignatureSource | undefined;
155
+ readonly getFn: FnResolver;
156
+ /** the package's release timeline, ascending */
157
+ readonly timeline: readonly TimelineEntry[];
158
+ /** the usage the signature pass judges by (base primitives dropped for a base package), `undefined` if unused */
159
+ readonly usage: PackageUsage | undefined;
160
+ /** whether a version's signatures accept how the code calls it, see {@link makeSignatureFilter} */
161
+ readonly signatureOk: (version: VersionString) => boolean;
162
+ }
163
+ /**
164
+ * The version space of one analysis: the surviving versions of each dependency and the transitive constraints
165
+ * refined to a fixpoint. Holding the shared inputs here keeps the passes to a handful of arguments and lets each
166
+ * package's sigdb key, source and decoded signatures be resolved once. The passes revisit the same versions
167
+ * repeatedly, so that memoization is what makes the fixpoint affordable.
168
+ */
169
+ export declare class VersionSpace {
170
+ readonly deps: ReadOnlyFlowrAnalyzerDependenciesContext;
171
+ readonly sources: readonly PackageSignatureSource[];
172
+ readonly usage: ReadonlyMap<string, PackageUsage>;
173
+ readonly cutoff: Date | undefined;
174
+ readonly rVersion: string | undefined;
175
+ readonly disabled: ReadonlySet<ConstraintSource>;
176
+ private readonly resolved;
177
+ constructor({ deps, usage, cutoff, rVersion, disabled }: VersionSpaceOptions);
178
+ /** the sigdb package, source and signature resolver of a target, resolved once */
179
+ resolve(name: string): PackageResolution;
180
+ /** the versions of `name` surviving every constraint, see {@link survivingEntries} */
181
+ survivors(name: string, transitive: readonly TransitiveConstraint[], observe?: ConstraintObserver): SurvivingEntries;
182
+ /**
183
+ * The transitive constraints, refined to a fixpoint: each pass re-reads every declaring package's requirements
184
+ * from the versions of it that survived the previous pass, so two packages can tighten each other. Feeding back
185
+ * the whole surviving set (not one representative version) is what keeps a requirement that only *some* of those
186
+ * versions declare from filtering (see {@link TransitiveConstraint}).
187
+ *
188
+ * The first pass runs with *no* transitive constraint at all, so every later pass can only shrink the surviving
189
+ * sets and thus only tighten the constraints: the refinement is monotone and cannot oscillate, and stopping early
190
+ * at `maxIterations` leaves it on the permissive side rather than at an arbitrary point. A declaring package that
191
+ * is not among the `targets` is not being guessed, so its {@link Package.resolvedVersion} stands in.
192
+ */
193
+ refineTransitive(targets: readonly string[], maxIterations?: number): Map<string, TransitiveConstraint[]>;
127
194
  }
128
- /** drop, to a fixpoint, versions no co-guessed dependency can satisfy; returns the blocking partners per package */
129
- export declare function enforceArcConsistency(entries: readonly ArcEntry[], maxIterations?: number): Map<string, Map<string, string>>;
195
+ /** the outcome of {@link enforceArcConsistency}: the pruned version sets, and which partner blocked each package */
196
+ export interface ArcConsistency {
197
+ readonly survivors: Map<string, TimelineEntry[]>;
198
+ /** per package, the partner that rejected a version and the requirement it could not meet */
199
+ readonly blockers: Map<string, Map<string, string>>;
200
+ }
201
+ /** drop, to a fixpoint, the versions of each package that no co-guessed dependency can satisfy */
202
+ export declare function enforceArcConsistency(space: VersionSpace, initial: ReadonlyMap<string, TimelineEntry[]>, maxIterations?: number): ArcConsistency;
130
203
  /** a package (or a linked group sharing one version) and its surviving versions, one factor of the combination count */
131
204
  export interface CountFactor {
132
205
  readonly name: string;
133
- readonly src: PackageSignatureSource | undefined;
134
- readonly key: string;
135
206
  readonly survivors: readonly string[];
136
207
  }
208
+ /** two packages whose version choices are not independent, and whether that holds for all of their versions */
209
+ export interface VersionCoupling {
210
+ readonly a: string;
211
+ readonly b: string;
212
+ /** `false` when only *some* versions of the two require each other, so the coupling does not always apply */
213
+ readonly always: boolean;
214
+ /** whether the coupling was counted; a coupling closing a cycle in the graph is dropped from the count */
215
+ readonly counted: boolean;
216
+ }
217
+ /** the result of {@link countRunnableCombinations} */
218
+ export interface CountedCombinations {
219
+ /** the number of runnable version tuples; an upper bound when {@link couplings} contains uncounted entries */
220
+ readonly total: number;
221
+ /** every coupling found between the counted factors */
222
+ readonly couplings: readonly VersionCoupling[];
223
+ }
137
224
  /**
138
- * The runnable-combination count. Everything depends on the shared base/R `hub`, so for each hub version take the
139
- * product of how many versions of every other factor are compatible with it, and sum over the hub. With no hub the
140
- * factors are independent, so it is the plain product. (Constraints between two non-hub factors are not modelled.)
225
+ * The runnable-combination count: how many version tuples satisfy the requirements the factors place on each other.
226
+ * A requirement need not hold for every version of the declaring package (`A 0.2.5` may pin `B` to `0.2.1` while
227
+ * `A 0.3.0` pins it to `0.3.2`), so the two are counted as *coupled* rather than as independent factors: a version
228
+ * of `A` only ever multiplies in the versions of `B` it actually admits.
229
+ *
230
+ * Counting all couplings exactly is #CSP-hard, so they are counted over a spanning forest of the coupling graph,
231
+ * preferring the couplings that always apply. That is exact whenever the graph has no cycle, which covers the common
232
+ * shared-hub shape. A coupling that would close a cycle is dropped and reported as uncounted, leaving the result an
233
+ * upper bound. Only the forest's couplings need their compatibility matrix, so the work stays linear in the factors.
141
234
  */
142
- export declare function countRunnableCombinations(hub: CountFactor | undefined, others: readonly CountFactor[]): number;
143
- /** whether every requirement `pkg@ver` places on a co-guessed dependency is met by one of that partner's surviving versions */
144
- export declare function versionMeetsPartners(src: PackageSignatureSource, pkg: string, ver: string, partnerSurvivors: ReadonlyMap<string, readonly string[]>, selfName: string, onReject?: (partner: string, constraint: string) => void): boolean;
235
+ export declare function countRunnableCombinations(space: VersionSpace, factors: readonly CountFactor[]): CountedCombinations;
145
236
  /** an empty set, shared so callers that do not disable anything need not allocate one */
146
237
  export declare const NoDisabledSources: ReadonlySet<ConstraintSource>;
147
238
  /**
148
239
  * Apply every constraint (declared, transitive, base-R, date, then signature usage) to a package's timeline. When an
149
240
  * `observe` callback is given, emits the provenance of each constraint (including the signature lower bounds).
241
+ * Prefer {@link VersionSpace.survivors}, which is the same call with the shared inputs already bound.
150
242
  */
151
- export declare function survivingEntries(name: string, src: PackageSignatureSource | undefined, deps: ReadOnlyFlowrAnalyzerDependenciesContext, usage: PackageUsage | undefined, transitive: readonly TransitiveConstraint[], cutoff: Date | undefined, rVersion: string | undefined, observe?: ConstraintObserver, disabled?: ReadonlySet<ConstraintSource>, packageKey?: string): SurvivingEntries;
243
+ export declare function survivingEntries(space: VersionSpace, name: string, transitive: readonly TransitiveConstraint[], observe?: ConstraintObserver): SurvivingEntries;
152
244
  /** the sigdb package a target's version history is drawn from: `R` reuses `base` (their releases coincide), everything else is itself */
153
245
  export declare function timelinePackageKey(name: string, sources: readonly PackageSignatureSource[]): string;
154
246
  /** the ordered candidate list for one package, or `undefined` when nothing survives (shared by the query and the iterator) */