@eagleoutice/flowr 2.13.12 → 2.13.14

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 (77) hide show
  1. package/README.md +29 -26
  2. package/benchmark/calibration.d.ts +18 -0
  3. package/benchmark/calibration.js +63 -0
  4. package/benchmark/slicer.d.ts +19 -0
  5. package/benchmark/slicer.js +84 -1
  6. package/benchmark/stats/feature-counts.d.ts +6 -0
  7. package/benchmark/stats/feature-counts.js +61 -0
  8. package/benchmark/stats/print.js +20 -0
  9. package/benchmark/stats/sigdb-counts.d.ts +7 -0
  10. package/benchmark/stats/sigdb-counts.js +219 -0
  11. package/benchmark/stats/size-of.d.ts +6 -0
  12. package/benchmark/stats/size-of.js +8 -0
  13. package/benchmark/stats/stats.d.ts +79 -0
  14. package/benchmark/stats/stats.js +7 -1
  15. package/benchmark/stopwatch.d.ts +4 -0
  16. package/benchmark/stopwatch.js +12 -1
  17. package/benchmark/summarizer/data.d.ts +17 -1
  18. package/benchmark/summarizer/first-phase/input.js +5 -0
  19. package/benchmark/summarizer/first-phase/process.js +12 -2
  20. package/benchmark/summarizer/second-phase/graph.d.ts +1 -1
  21. package/benchmark/summarizer/second-phase/graph.js +214 -16
  22. package/benchmark/summarizer/second-phase/process.js +56 -0
  23. package/benchmark/summarizer/summarizer.js +1 -2
  24. package/cli/benchmark-app.d.ts +1 -0
  25. package/cli/benchmark-app.js +2 -1
  26. package/cli/benchmark-helper-app.d.ts +1 -0
  27. package/cli/benchmark-helper-app.js +12 -2
  28. package/cli/common/options.d.ts +10 -0
  29. package/cli/common/options.js +3 -1
  30. package/cli/common/scripts-info.d.ts +10 -0
  31. package/config.js +13 -7
  32. package/control-flow/cfg-builder.d.ts +30 -0
  33. package/control-flow/cfg-builder.js +79 -0
  34. package/control-flow/extract-cfg.js +17 -10
  35. package/dataflow/environments/apply-kill.d.ts +3 -3
  36. package/dataflow/environments/apply-kill.js +60 -31
  37. package/dataflow/environments/reference-to-maybe.d.ts +5 -3
  38. package/dataflow/environments/reference-to-maybe.js +17 -52
  39. package/dataflow/environments/resolve-helper.d.ts +2 -1
  40. package/dataflow/environments/resolve-helper.js +2 -1
  41. package/dataflow/graph/df-helper.d.ts +2 -1
  42. package/dataflow/info.d.ts +7 -1
  43. package/dataflow/info.js +36 -7
  44. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +33 -10
  45. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +4 -1
  46. package/dataflow/internal/process/functions/call/built-in/built-in-local.js +6 -2
  47. package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +2 -1
  48. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +7 -2
  49. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +8 -1
  50. package/documentation/doc-readme.js +5 -2
  51. package/documentation/doc-util/doc-issue.d.ts +2 -0
  52. package/documentation/doc-util/doc-issue.js +3 -1
  53. package/documentation/wiki-analyzer.js +10 -4
  54. package/documentation/wiki-core.js +58 -0
  55. package/documentation/wiki-dataflow-graph.js +4 -0
  56. package/documentation/wiki-faq.js +6 -2
  57. package/documentation/wiki-onboarding.js +11 -1
  58. package/documentation/wiki-setup.js +2 -1
  59. package/gas.d.ts +56 -6
  60. package/package.json +9 -4
  61. package/project/cache/flowr-analyzer-cache.d.ts +1 -0
  62. package/project/cache/flowr-analyzer-cache.js +4 -0
  63. package/project/context/flowr-analyzer-context.js +5 -0
  64. package/project/context/flowr-analyzer-gas-context.d.ts +58 -4
  65. package/project/context/flowr-analyzer-gas-context.js +137 -15
  66. package/project/flowr-analyzer.d.ts +25 -7
  67. package/project/flowr-analyzer.js +6 -6
  68. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +11 -9
  69. package/slicing/static/slice-call.js +4 -4
  70. package/slicing/static/slicer-types.d.ts +13 -0
  71. package/slicing/static/static-slicer.d.ts +7 -1
  72. package/slicing/static/static-slicer.js +11 -5
  73. package/slicing/static/visiting-queue.d.ts +3 -1
  74. package/slicing/static/visiting-queue.js +4 -1
  75. package/util/node-version.d.ts +4 -0
  76. package/util/node-version.js +29 -0
  77. package/util/version.js +1 -1
@@ -21,11 +21,27 @@ const reference_to_maybe_1 = require("../../../../../environments/reference-to-m
21
21
  const apply_kill_1 = require("../../../../../environments/apply-kill");
22
22
  const built_in_proc_name_1 = require("../../../../../environments/built-in-proc-name");
23
23
  const general_1 = require("../../../../../eval/values/general");
24
+ /**
25
+ * Whether the definitions of this list among the `targets` of a read cover every branch, alone or together.
26
+ * Only then the read is resolved here and must not bubble up as an ingoing reference.
27
+ */
28
+ function coveredByListDefinitions(targets, listEnvironments) {
29
+ let cds;
30
+ for (const target of targets) {
31
+ if (!listEnvironments.has(target.nodeId)) {
32
+ continue;
33
+ }
34
+ else if (target.cds === undefined) {
35
+ return true;
36
+ }
37
+ (cds ??= []).push(...target.cds);
38
+ }
39
+ return cds !== undefined && (0, info_1.happensInEveryBranch)(cds);
40
+ }
24
41
  function linkReadNameToWriteIfPossible(read, environments, listEnvironments, remainingRead, nextGraph) {
25
42
  const readName = read.name && identifier_1.Identifier.isDotDotDotAccess(read.name) ? identifier_1.Identifier.dotdotdot() : read.name;
26
43
  const probableTarget = readName ? (0, resolve_by_name_1.resolveByName)(readName, environments, read.type) : undefined;
27
- // record if at least one has not been defined
28
- if (probableTarget === undefined || probableTarget.some(t => !listEnvironments.has(t.nodeId) || !(0, info_1.happensInEveryBranch)(t.cds))) {
44
+ if (probableTarget === undefined || !coveredByListDefinitions(probableTarget, listEnvironments)) {
29
45
  const readId = readName ? identifier_1.Identifier.getName(readName) : undefined;
30
46
  const has = remainingRead.get(readId);
31
47
  if (has) {
@@ -172,8 +188,7 @@ function updateSideEffectsForCalledFunctions(calledEnvs, inputEnvironment, nextG
172
188
  * Processes a list of expressions joining their dataflow graphs accordingly.
173
189
  */
174
190
  function processExpressionList(name, args, rootId, data) {
175
- const expressions = args.map(unpack_argument_1.unpackNonameArg);
176
- (0, log_1.expensiveTrace)(logger_1.dataflowLogger, () => `[expr list] with ${expressions.length} expressions`);
191
+ (0, log_1.expensiveTrace)(logger_1.dataflowLogger, () => `[expr list] with ${args.length} expressions`);
177
192
  let { environment } = data;
178
193
  // used to detect if a "write" happens within the same expression list
179
194
  const listEnvironments = new Set();
@@ -187,7 +202,9 @@ function processExpressionList(name, args, rootId, data) {
187
202
  const invertExitCds = [];
188
203
  const processedExpressions = [];
189
204
  let defaultReturnExpr = undefined;
190
- for (const expression of expressions) {
205
+ let hooks;
206
+ for (const arg of args) {
207
+ const expression = (0, unpack_argument_1.unpackNonameArg)(arg);
191
208
  if (expression === undefined) {
192
209
  processedExpressions.push(undefined);
193
210
  continue;
@@ -205,7 +222,9 @@ function processExpressionList(name, args, rootId, data) {
205
222
  processed.in = (0, reference_to_maybe_1.makeAllMaybe)(processed.in, nextGraph, processed.environment, false, invertExitCds);
206
223
  processed.unknownReferences = (0, reference_to_maybe_1.makeAllMaybe)(processed.unknownReferences, nextGraph, processed.environment, false);
207
224
  }
208
- out.push(...processed.out);
225
+ if (processed.hooks.length > 0) {
226
+ (hooks ??= []).push(...processed.hooks);
227
+ }
209
228
  // all inputs that have not been written until now are read!
210
229
  for (const read of processed.in) {
211
230
  linkReadNameToWriteIfPossible(read, environment, listEnvironments, remainingRead, nextGraph);
@@ -232,10 +251,14 @@ function processExpressionList(name, args, rootId, data) {
232
251
  if (processed.kill?.length) {
233
252
  // if we may have already exited (break/next), the removal only happens maybe
234
253
  const kills = exitPoints.length > 0 ? (0, apply_kill_1.makeKillsMaybe)(processed.kill, invertExitCds) : processed.kill;
235
- (killed ??= []).push(...kills);
254
+ killed ??= [];
255
+ for (const kill of kills) {
256
+ killed.push(kill);
257
+ }
236
258
  }
237
- for (const { nodeId } of processed.out) {
238
- listEnvironments.add(nodeId);
259
+ for (const ref of processed.out) {
260
+ out.push(ref);
261
+ listEnvironments.add(ref.nodeId);
239
262
  }
240
263
  /** if at least built-one of the exit points encountered happens unconditionally, we exit here (dead code)! */
241
264
  if ((0, info_1.alwaysExits)(processed)) {
@@ -291,7 +314,7 @@ function processExpressionList(name, args, rootId, data) {
291
314
  /* if we have no group, we take the last evaluated expr */
292
315
  entryPoint: meId,
293
316
  exitPoints: exitPoints,
294
- hooks: processedExpressions.flatMap(p => p?.hooks ?? []),
317
+ hooks: hooks ?? [],
295
318
  kill: killed,
296
319
  };
297
320
  }
@@ -67,6 +67,9 @@ function processForLoop(name, args, rootId, data) {
67
67
  (0, reference_to_maybe_1.applyCdToReferences)(body.out, cd);
68
68
  const outgoing = variable.out.concat(writtenVariable, body.out);
69
69
  (0, linker_1.linkCircularRedefinitionsWithinALoop)(nextGraph, nameIdShares, body.out, body.environment);
70
+ /* the loop variable is bound by the head whenever the body runs, so reads of it are not ingoing */
71
+ const loopVariables = new Set(writtenVariable.map(w => w.name));
72
+ const bodyReadsOfOthers = [...nameIdShares.entries()].filter(([n]) => !loopVariables.has(n)).flatMap(([, refs]) => refs);
70
73
  (0, linker_1.reapplyLoopExitPoints)(body.exitPoints, body.in.concat(body.out, body.unknownReferences), nextGraph);
71
74
  (0, common_1.patchFunctionCall)({
72
75
  nextGraph,
@@ -86,7 +89,7 @@ function processForLoop(name, args, rootId, data) {
86
89
  return {
87
90
  unknownReferences: [],
88
91
  // we only want those not bound by a local variable
89
- in: [{ nodeId: rootId, name: name.content, cds: originalDependency, type: identifier_1.ReferenceType.Function }, ...vector.unknownReferences, ...[...nameIdShares.values()].flat()],
92
+ in: [{ nodeId: rootId, name: name.content, cds: originalDependency, type: identifier_1.ReferenceType.Function }, ...vector.unknownReferences, ...bodyReadsOfOthers],
90
93
  out: outgoing,
91
94
  graph: nextGraph,
92
95
  entryPoint: name.info.id,
@@ -9,6 +9,7 @@ const common_1 = require("../common");
9
9
  const unpack_argument_1 = require("../argument/unpack-argument");
10
10
  const scoping_1 = require("../../../../../environments/scoping");
11
11
  const identifier_1 = require("../../../../../environments/identifier");
12
+ const resolve_by_name_1 = require("../../../../../environments/resolve-by-name");
12
13
  const r_argument_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-argument");
13
14
  const built_in_proc_name_1 = require("../../../../../environments/built-in-proc-name");
14
15
  const built_in_envir_utils_1 = require("./built-in-envir-utils");
@@ -56,16 +57,19 @@ function processLocal(name, args, rootId, data, config) {
56
57
  argumentProcessResult: [dfExpr, dfEnv],
57
58
  origin: built_in_proc_name_1.BuiltInProcName.Local
58
59
  });
60
+ const resultEnvironment = envirResolution ? data.environment : (0, scoping_1.popLocalEnvironment)(dfExpr.environment);
61
+ /* definitions of the local scope vanish with it, only what escaped it (e.g. via `<<-`) may bubble up */
62
+ const escaping = envirResolution ? dfExpr.out : dfExpr.out.filter(o => o.name !== undefined && (0, resolve_by_name_1.resolveByName)(o.name, resultEnvironment, o.type)?.some(d => d.nodeId === o.nodeId));
59
63
  const ingoing = dfEnv.in.concat(dfExpr.in, dfEnv.unknownReferences, dfExpr.unknownReferences);
60
64
  ingoing.push({ nodeId: rootId, name: name.content, cds: data.cds, type: identifier_1.ReferenceType.Function });
61
65
  const baseResult = {
62
66
  hooks: dfExpr.hooks.concat(dfEnv.hooks),
63
- environment: envirResolution ? data.environment : (0, scoping_1.popLocalEnvironment)(dfExpr.environment),
67
+ environment: resultEnvironment,
64
68
  exitPoints: dfEnv.exitPoints.concat(dfExpr.exitPoints),
65
69
  graph: dfEnv.graph.mergeWith(dfExpr.graph),
66
70
  entryPoint: rootId,
67
71
  in: ingoing,
68
- out: dfExpr.out.concat(dfEnv.out),
72
+ out: escaping.concat(dfEnv.out),
69
73
  unknownReferences: []
70
74
  };
71
75
  /* move all definitions made inside the body into the custom env's tracked state */
@@ -44,6 +44,7 @@ function processRepeatLoop(name, args, rootId, data) {
44
44
  (0, linker_1.linkCircularRedefinitionsWithinALoop)(information.graph, (0, linker_1.produceNameSharedIdMap)((0, linker_1.findNonLocalReads)(information.graph)), body.out, body.environment);
45
45
  (0, linker_1.reapplyLoopExitPoints)(body.exitPoints, body.in.concat(body.out, body.unknownReferences), information.graph);
46
46
  information.exitPoints = (0, info_1.filterOutLoopExitPoints)(information.exitPoints);
47
- return information;
47
+ /* the body is evaluated in the enclosing environment, so its definitions have to bubble up */
48
+ return { ...information, out: information.out.concat(body.out) };
48
49
  }
49
50
  //# sourceMappingURL=built-in-repeat-loop.js.map
@@ -18,6 +18,7 @@ const unknown_replacement_1 = require("../../../../../graph/unknown-replacement"
18
18
  const built_in_s_seven_dispatch_1 = require("./built-in-s-seven-dispatch");
19
19
  const make_argument_1 = require("../argument/make-argument");
20
20
  const type_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/type");
21
+ const r_access_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-access");
21
22
  const graph_1 = require("../../../../../graph/graph");
22
23
  const range_1 = require("../../../../../../util/range");
23
24
  const built_in_proc_name_1 = require("../../../../../environments/built-in-proc-name");
@@ -99,12 +100,16 @@ args, rootId, data, config) {
99
100
  res.graph.addEdge(rootId, ref, edge_1.EdgeType.Reads);
100
101
  }
101
102
  }
102
- if (firstArg) {
103
+ if (firstArg?.type === type_1.RType.Symbol) {
103
104
  res = {
104
105
  ...res,
105
- in: [...res.in, { name: firstArg.lexeme, type: identifier_1.ReferenceType.Variable, nodeId: firstArg.info.id, cds: data.cds }]
106
+ in: [...res.in, { name: firstArg.content, type: identifier_1.ReferenceType.Variable, nodeId: firstArg.info.id, cds: data.cds }]
106
107
  };
107
108
  }
109
+ else if (firstArg !== undefined && r_access_1.RAccess.is(firstArg)) {
110
+ /* a nested target (e.g. `a$b$c <- 5`) is no variable read, it is read through its own accessor */
111
+ res.graph.addEdge(firstArg.info.id, node_id_1.NodeId.toBuiltIn(firstArg.operator), edge_1.EdgeType.Reads);
112
+ }
108
113
  // dispatches actually as S3:
109
114
  const fns = res.in.filter(i => i.nodeId === rootId);
110
115
  for (const fn of fns) {
@@ -88,7 +88,14 @@ function processTryCatch(name, args, rootId, data, config) {
88
88
  info.graph.addEdge(rootId, e.nodeId, edge_1.EdgeType.Returns);
89
89
  }
90
90
  }
91
- return info;
91
+ /* block and finally are evaluated in the enclosing environment, so their definitions have to bubble up */
92
+ const escaping = [];
93
+ for (const arg of res.processedArguments) {
94
+ if (arg && (blockArg.has(arg.entryPoint) || finallyArg.has(arg.entryPoint))) {
95
+ escaping.push(...arg.out);
96
+ }
97
+ }
98
+ return escaping.length > 0 ? { ...info, out: info.out.concat(escaping) } : info;
92
99
  }
93
100
  function promoteCallToFunction(call, arg, info, data) {
94
101
  let functionId = undefined;
@@ -208,7 +208,7 @@ ${await (0, doc_repl_1.documentReplSession)(treeSitter, [{
208
208
  `), ' ')}
209
209
 
210
210
  * 🚀 **fast call-graph, data-, and control-flow graphs**\\
211
- Within just ${ctx.linkPage('flowr:benchmarks', `${'<i>' + (0, html_hover_over_1.textWithTooltip)((0, numbers_1.roundToDecimals)(await (0, doc_benchmarks_1.getLatestDfAnalysisTime)('"social-science" Benchmark Suite (tree-sitter)'), 1) + ' ms', 'This measurement is automatically fetched from the latest benchmark!') + '</i>'} (as of ${new Date(await (0, doc_benchmarks_1.getLastBenchmarkUpdate)()).toLocaleDateString('en-US', dateOptions)})`)},
211
+ Within just ${ctx.linkPage('flowr:benchmarks', `${'<i>' + (0, html_hover_over_1.textWithTooltip)((0, numbers_1.roundToDecimals)(await (0, doc_benchmarks_1.getLatestDfAnalysisTime)('"real-world" Benchmark Suite (tree-sitter)'), 1) + ' ms', 'This measurement is automatically fetched from the latest benchmark!') + '</i>'} (as of ${new Date(await (0, doc_benchmarks_1.getLastBenchmarkUpdate)()).toLocaleDateString('en-US', dateOptions)})`)},
212
212
  _flowR_ can analyze the data- and control-flow of the average real-world R&nbsp;script. See the ${ctx.linkPage('flowr:benchmarks', 'benchmarks')} for more information,
213
213
  and consult the ${ctx.linkPage('wiki/Dataflow Graph', 'wiki pages')} for more details on the ${ctx.linkPage('wiki/Dataflow Graph', 'dataflow graphs')} as well as ${ctx.linkPage('wiki/Dataflow Graph', 'call graphs', 'perspectives-cg')}.
214
214
 
@@ -283,7 +283,10 @@ ${printPublications()}
283
283
 
284
284
  ## 🚀 Contributing
285
285
 
286
- We welcome every contribution! Please check out the ${ctx.linkPage('wiki/Onboarding', 'developer onboarding')} section in the wiki for all the information you will need.
286
+ We welcome every contribution! The ${ctx.linkPage('wiki/Onboarding', 'developer onboarding')} page has everything you need to get started.
287
+ With **R** and **Node.js** installed, \`npm run setup:dev\` checks your prerequisites, installs the dependencies, and configures the git hooks.
288
+ The [contributing guidelines](${doc_files_1.FlowrGithubBaseRef}/flowr/tree/main/.github/CONTRIBUTING.md) explain our commit conventions,
289
+ and ${ctx.linkPage('wiki/Linting and Testing')} shows how to run the tests.
287
290
 
288
291
  ### Contributors
289
292
 
@@ -1 +1,3 @@
1
1
  export declare const NewIssueUrl = "https://github.com/flowr-analysis/flowr/issues/new/choose";
2
+ /** the question issue form, for everything the wiki does not answer */
3
+ export declare const NewQuestionUrl = "https://github.com/flowr-analysis/flowr/issues/new?template=question.yaml";
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NewIssueUrl = void 0;
3
+ exports.NewQuestionUrl = exports.NewIssueUrl = void 0;
4
4
  const doc_files_1 = require("./doc-files");
5
5
  exports.NewIssueUrl = `${doc_files_1.FlowrGithubBaseRef}/flowr/issues/new/choose`;
6
+ /** the question issue form, for everything the wiki does not answer */
7
+ exports.NewQuestionUrl = `${doc_files_1.FlowrGithubBaseRef}/flowr/issues/new?template=question.yaml`;
6
8
  //# sourceMappingURL=doc-issue.js.map
@@ -456,12 +456,18 @@ ${ctx.hierarchy(flowr_analyzer_gas_context_1.FlowrAnalyzerGasContext, { showImpl
456
456
  Expensive analysis sites ask for the current resource pressure with
457
457
  ${ctx.linkM(flowr_analyzer_gas_context_1.FlowrAnalyzerGasContext, 'checkGas', { codeFont: true, realNameWrapper: 'i' })}, passing the name of the feature they are about to run
458
458
  (see ${ctx.link('GasFeatureKey')}), and may then degrade or skip their work.
459
- The level combines the current heap usage and the time elapsed since the analysis started (or since the last
460
- ${ctx.linkM(flowr_analyzer_context_1.FlowrAnalyzerContext, 'reset')}, which also resets the gas clock via
461
- ${ctx.linkM(flowr_analyzer_gas_context_1.FlowrAnalyzerGasContext, 'reset', { codeFont: true, realNameWrapper: 'i' })}),
462
- each scaled by the per-feature factor from \`config.gas.features\`.
459
+ The level combines the current heap usage and the time elapsed within the contingent of the current operation,
460
+ each scaled by the per-feature factor from \`config.gas.features\` and compared against the thresholds
461
+ configured for that key (see ${ctx.link('GasThresholdSpec')}).
463
462
  Registered ${ctx.link(flowr_analyzer_gas_plugin_1.FlowrAnalyzerGasPlugin)}s may escalate the level for any key.
464
463
 
464
+ Every operation gets a contingent of its own, and anything beginning a new analysis (an added file, a cache
465
+ invalidation, a ${ctx.linkM(flowr_analyzer_context_1.FlowrAnalyzerContext, 'reset')}) restarts it. To restart it between your own
466
+ phases, call ${ctx.linkM(flowr_analyzer_gas_context_1.FlowrAnalyzerGasContext, 'reset', { codeFont: true, realNameWrapper: 'i' })} on the
467
+ writeable context (\`analyzer.context().gas.reset()\`). To bound a single call, pass \`gas\` overrides to it
468
+ (\`analyzer.query([...], { gas: { slicer: { critical: 30_000 } } })\`) or derive a bounded view with
469
+ ${ctx.linkM(flowr_analyzer_gas_context_1.FlowrAnalyzerGasContext, 'scope', { codeFont: true, realNameWrapper: 'i' })}.
470
+
465
471
  ${(0, doc_structure_1.block)({
466
472
  type: 'NOTE',
467
473
  content: `
@@ -593,6 +593,64 @@ scaled_elapsed = elapsed_ms * factor
593
593
  A factor of \`2\` makes the check twice as sensitive: it triggers \`Problematic\` when the heap
594
594
  is at 35% (= 0.7 / 2) instead of 70%.
595
595
 
596
+ ### Per-Feature Thresholds
597
+
598
+ A dataflow extraction, a linter pass and a static slice are not worth the same allowance, so each dimension
599
+ of \`config.gas.thresholds\` may be bounded per feature key (see ${ctx.link('GasThresholdSpec')}), with
600
+ \`default\` covering the keys that have no entry of their own:
601
+
602
+ \`\`\`json
603
+ {
604
+ "gas": {
605
+ "thresholds": {
606
+ "timeMs": {
607
+ "default": { "problematic": 60000, "critical": 120000 },
608
+ "slicer": { "problematic": 24000, "critical": 30000 }
609
+ }
610
+ },
611
+ "features": {
612
+ "slicer": 1
613
+ }
614
+ }
615
+ }
616
+ \`\`\`
617
+
618
+ An entry only has to name the bounds it changes; the rest falls back to \`default\` and then to a directly
619
+ given \`{ problematic, critical }\` pair, which stays valid and still means "the same bound for everything".
620
+
621
+ ### Per-Operation Contingents
622
+
623
+ The elapsed-time bound is *not* measured from the creation of the analyzer. Each analysis run (parse,
624
+ normalize, dataflow) and each ${ctx.link(static_slicer_1.staticSlice.name)} runs against a contingent of its own, so analysing
625
+ a project and then asking for twenty slices gives twenty-one contingents, not one clock the analysis spent.
626
+
627
+ Anything beginning a new analysis restarts it too: an added file, a cache invalidation, a re-parse, or an
628
+ explicit ${ctx.linkM(flowr_analyzer_1.FlowrAnalyzer, 'reset')}. Operations in flight keep theirs, as restarting a running
629
+ traversal's clock would defeat the guard bounding it. To split your *own* phases, call
630
+ ${ctx.linkM(flowr_analyzer_gas_context_1.FlowrAnalyzerGasContext, 'reset', { codeFont: true, realNameWrapper: 'i' })} on the writeable
631
+ context (\`analyzer.context().gas.reset()\`) - supported API, not an internal hook.
632
+
633
+ ### Bounding a Single Call
634
+
635
+ Bounds for one call, keyed by the same feature names and measured from that call (see ${ctx.link('GasOverrides')}):
636
+
637
+ ${(0, doc_code_1.codeBlock)('ts', `await analyzer.query([{ type: 'static-slice', criteria: ['12@product'] }], {
638
+ gas: { slicer: { critical: 30_000 } }
639
+ });`)}
640
+
641
+ Bare \`problematic\`/\`critical\` numbers are elapsed milliseconds; use \`timeMs\`/\`memory\` to be explicit and
642
+ \`factor\` for the sensitivity. Naming a feature enables gas for it even when \`config.gas.features\` disables
643
+ it (pass \`factor: 0\` to keep it off). ${ctx.linkM(flowr_analyzer_1.FlowrAnalyzer, 'runFull')} and
644
+ ${ctx.linkM(flowr_analyzer_1.FlowrAnalyzer, 'runSearch')} take the same, and read-only holders of a context can derive a
645
+ bounded view with ${ctx.linkM(flowr_analyzer_gas_context_1.FlowrAnalyzerGasContext, 'scope', { codeFont: true, realNameWrapper: 'i' })}.
646
+
647
+ ### When the Slicer Runs Out
648
+
649
+ A slice cut short comes back with \`stoppedEarly\` and a \`progress\` saying how far it got (see
650
+ ${ctx.link('SliceProgress')}). A \`frontier\` of \`0\` means the queue drained after all; a small \`frontier\`
651
+ next to a large \`visited\` says little is missing. Without it a truncated slice is all-or-nothing, and
652
+ "as far as flowR got" is not "what is independent", so it would have to be discarded.
653
+
596
654
  ### Known Feature Keys
597
655
 
598
656
  ${ctx.doc('GasFeatureKey')}
@@ -46,6 +46,7 @@ const r_number_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-number");
46
46
  const model_1 = require("../r-bridge/lang-4.x/ast/model/model");
47
47
  const range_1 = require("../util/range");
48
48
  const df_helper_1 = require("../dataflow/graph/df-helper");
49
+ const resolve_helper_1 = require("../dataflow/environments/resolve-helper");
49
50
  const built_in_proc_name_1 = require("../dataflow/environments/built-in-proc-name");
50
51
  async function subExplanation(parser, ctx, { description, code, expectedSubgraph }) {
51
52
  expectedSubgraph = await (0, doc_dfg_1.verifyExpectedSubgraph)(parser, code, expectedSubgraph);
@@ -1097,6 +1098,9 @@ FlowR also provides various helper objects (with the same name as the correspond
1097
1098
  * ${ctx.link(edge_1.DfEdge, undefined, { type: 'variable' })} to get helpful functions wrt. edges (see [below](#dfg-resolving-values))
1098
1099
  * ${ctx.link(identifier_1.Identifier, undefined, { type: 'variable' })} to get helpful functions wrt. identifiers
1099
1100
  * ${ctx.link(graph_1.FunctionArgument, undefined, { type: 'variable' })} to get helpful functions wrt. function arguments
1101
+ * ${ctx.link(resolve_helper_1.Resolve, undefined, { type: 'variable' })} (also reachable as \`Dataflow.resolve\`) to resolve a name against an environment or a node to its value.
1102
+ The entry points differ a lot in cost, so take the narrowest one that answers your question: \`byName\` walks the environment layers once and is served from the layer cache,
1103
+ \`byNameAndType\` additionally filters and merges the definitions of every layer it passes, and \`toValue\` as well as the \`argument\` family run the evaluator on top of a resolution.
1100
1104
 
1101
1105
  Some of these functions have been explained in their respective wiki pages. However, some are part of the ${ctx.linkPage('wiki/Dataflow Graph', 'Dataflow Graph API')} and so we explain them here.
1102
1106
  If you are interested in which features we support and which features are still to be worked on, please refer to our ${ctx.linkPage('wiki/Capabilities', 'capabilities')} page.
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.WikiFaq = void 0;
4
4
  const faqs_1 = require("./data/faq/faqs");
5
+ const doc_issue_1 = require("./doc-util/doc-issue");
5
6
  const doc_maker_1 = require("./wiki-mk/doc-maker");
6
7
  /**
7
8
  * https://github.com/flowr-analysis/flowr/wiki/FAQ
@@ -12,8 +13,11 @@ class WikiFaq extends doc_maker_1.DocMaker {
12
13
  }
13
14
  text({ ctx }) {
14
15
  const faqs = (0, faqs_1.registerFaqs)(ctx);
15
- return `
16
- ${faqs.toMarkdown()}
16
+ return `
17
+ Is your question not answered below? Please [ask it as an issue](${doc_issue_1.NewQuestionUrl}) and we will answer it.
18
+ Answers regularly end up on this page, so asking helps everyone who wonders the same thing later.
19
+
20
+ ${faqs.toMarkdown()}
17
21
  `.trim();
18
22
  }
19
23
  }
@@ -18,15 +18,25 @@ class WikiOnboarding extends doc_maker_1.DocMaker {
18
18
  - 💖 [Contributing guidelines](${doc_files_1.FlowrGithubBaseRef}/flowr/tree/main/.github/CONTRIBUTING.md).\\
19
19
  This page also includes information about how to set up **git-lfs** and several **git hooks**.
20
20
 
21
+ Once you are set up, these pages explain the parts you are most likely to touch:
22
+ - 🔬 ${ctx.linkPage('wiki/Core')} walks through the pipeline from parsing to the dataflow graph.
23
+ - 🖥️ ${ctx.linkPage('wiki/Interface')} covers the REPL, the server, and the API.
24
+ - 🧪 ${ctx.linkPage('wiki/Linting and Testing')} explains which tests exist and how to run them.
25
+
21
26
  If you have any questions, please check out the ${ctx.linkPage('wiki/FAQ')} first, but if the question
22
27
  is not answered there (or in the wiki in general), feel free to ask a question.
23
28
  The ${ctx.linkPage('wiki/FAQ')} also includes information about how you can configure your editor.
24
29
 
25
30
  ## ⌛ TL;DR
26
31
 
27
- The most important steps to get the *flowR* development environment set up (after installing **R** and **Node.js**) can be seen below. For convenience, they can be executed all at once using the following command:
32
+ After installing **R** and **Node.js**, a single command sets everything up:
28
33
  ${(0, doc_code_1.codeBlock)('shell', 'npm run setup:dev')}
29
34
 
35
+ It installs the dependencies, checks your **node** version, tells you whether **R** and **git-lfs** are available,
36
+ configures the git hooks, tests them, and closes with the pages and commands you will need next.
37
+ Missing **R** or **git-lfs** are reported as notes instead of aborting the setup, so you can start with the
38
+ ${ctx.linkPage('wiki/Engines', '`tree-sitter` engine')} right away and add them later.
39
+
30
40
  If you want to execute the steps manually, please follow the instructions below:
31
41
 
32
42
  ${(0, doc_code_1.codeBlock)('shell', `
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.WikiSetup = void 0;
4
4
  const doc_maker_1 = require("./wiki-mk/doc-maker");
5
5
  const doc_files_1 = require("./doc-util/doc-files");
6
+ const node_version_1 = require("../util/node-version");
6
7
  /**
7
8
  * https://github.com/flowr-analysis/flowr/wiki/Setup
8
9
  */
@@ -76,7 +77,7 @@ Again, you only require this for the ${ctx.linkPage('wiki/Engines', '`r-shell` e
76
77
  ### Installing Node.js
77
78
 
78
79
  Furthermore, you need the [node package manager](https://www.npmjs.com/) (for Linux, we recommend using [nvm](https://github.com/nvm-sh/nvm)).
79
- To work, we currently rely on node versions starting from \`22.x\`.
80
+ To work, we currently rely on node versions starting from \`${(0, node_version_1.minimumNodeMajor)()}.x\` (as declared by the \`engines.node\` field of the [package.json](${doc_files_1.RemoteFlowrFilePathBaseRef}package.json)).
80
81
 
81
82
  ### Installing _flowR_
82
83
 
package/gas.d.ts CHANGED
@@ -33,7 +33,7 @@ export declare const GasFeatureKey: {
33
33
  readonly Slicer: "slicer";
34
34
  };
35
35
  export type GasFeatureKey = typeof GasFeatureKey[keyof typeof GasFeatureKey];
36
- /** Paired low/high thresholds used inside {@link FlowrGasThresholds}. */
36
+ /** Paired low/high thresholds used inside {@link GasThresholdSpec}. */
37
37
  export interface GasThresholdPair extends MergeableRecord {
38
38
  /** Returns {@link GasLevel.Problematic} when reached (after factor scaling). */
39
39
  readonly problematic: number;
@@ -41,16 +41,66 @@ export interface GasThresholdPair extends MergeableRecord {
41
41
  readonly critical: number;
42
42
  }
43
43
  /**
44
- * Thresholds for {@link GasLevel} transitions used by {@link ReadOnlyFlowrAnalyzerGasContext.checkGas}.
45
- * Memory values are fractions of the heap limit reported by the active heap source (0-1), time values are in milliseconds.
44
+ * Thresholds for one gas dimension, either as one pair for every feature or split per {@link GasFeatureKey}:
45
+ *
46
+ * ```ts
47
+ * timeMs: {
48
+ * default: { problematic: 60_000, critical: 120_000 },
49
+ * slicer: { problematic: 24_000, critical: 30_000 }
50
+ * }
51
+ * ```
52
+ *
53
+ * Per bound, a feature entry wins over `default`, which wins over the direct pair. A bound nowhere given never triggers.
54
+ */
55
+ export interface GasThresholdSpec extends MergeableRecord {
56
+ /** Shared bound, for every feature without a more specific entry. */
57
+ readonly problematic?: number;
58
+ /** Shared bound, for every feature without a more specific entry. */
59
+ readonly critical?: number;
60
+ /** Bounds for the features that have no entry of their own. */
61
+ readonly default?: Partial<GasThresholdPair>;
62
+ /** Bounds for one {@link GasFeatureKey}. */
63
+ readonly [feature: string]: number | Partial<GasThresholdPair> | undefined;
64
+ }
65
+ /**
66
+ * Thresholds for {@link GasLevel} transitions used by {@link ReadOnlyFlowrAnalyzerGasContext.checkGas}, each
67
+ * dimension boundable per feature (see {@link GasThresholdSpec}).
46
68
  * See the [Gas (Resource Guard)](https://github.com/flowr-analysis/flowr/wiki/Core#gas-resource-guard) wiki section.
47
69
  */
48
70
  export interface FlowrGasThresholds extends MergeableRecord {
49
71
  /** Heap-usage fraction thresholds (0-1, before factor scaling). */
50
- readonly memory: GasThresholdPair;
72
+ readonly memory: GasThresholdSpec;
51
73
  /** Elapsed analysis time thresholds in milliseconds (before factor scaling). */
52
- readonly timeMs: GasThresholdPair;
74
+ readonly timeMs: GasThresholdSpec;
75
+ }
76
+ /** Gas bounds for one feature within a single call, see {@link GasOverrides}. */
77
+ export interface GasFeatureOverride extends MergeableRecord {
78
+ /** Elapsed ms, shorthand for `timeMs.problematic`. */
79
+ readonly problematic?: number;
80
+ /** Elapsed ms, shorthand for `timeMs.critical`. */
81
+ readonly critical?: number;
82
+ /** Overrides `config.gas.thresholds.timeMs` for this call. */
83
+ readonly timeMs?: Partial<GasThresholdPair>;
84
+ /** Overrides `config.gas.thresholds.memory` for this call. */
85
+ readonly memory?: Partial<GasThresholdPair>;
86
+ /** Sensitivity factor, defaulting to the configured one, or `1` if the feature is disabled. */
87
+ readonly factor?: number;
53
88
  }
89
+ /**
90
+ * Gas bounds for a single call, keyed by {@link GasFeatureKey}, measured from that call:
91
+ *
92
+ * ```ts
93
+ * analyzer.query([...], { gas: { slicer: { critical: 30_000 } } });
94
+ * ```
95
+ *
96
+ * Naming a feature enables gas for it even when `config.gas.features` disables it; pass `factor: 0` to keep it off.
97
+ */
98
+ export type GasOverrides = {
99
+ /** Bounds for the features that have no entry of their own. */
100
+ readonly default?: GasFeatureOverride;
101
+ /** Bounds for one {@link GasFeatureKey}. */
102
+ readonly [feature: string]: GasFeatureOverride | undefined;
103
+ };
54
104
  /** Heap statistics used for gas memory checks (field names follow the v8 API). */
55
105
  export interface GasHeapStatistics {
56
106
  readonly used_heap_size: number;
@@ -68,7 +118,7 @@ export interface GasHeapStatistics {
68
118
  * See the [Gas (Resource Guard)](https://github.com/flowr-analysis/flowr/wiki/Core#gas-resource-guard) wiki section.
69
119
  */
70
120
  export interface FlowrGasConfig extends MergeableRecord {
71
- /** Shared thresholds scaled by each feature factor before comparison. */
121
+ /** Thresholds scaled by each feature factor before comparison, optionally bounded per feature (see {@link GasThresholdSpec}). */
72
122
  readonly thresholds: FlowrGasThresholds;
73
123
  /** Per-feature sensitivity factors. Missing or `0` disables checking with zero overhead. */
74
124
  readonly features: Record<string, number | undefined>;
package/package.json CHANGED
@@ -1,7 +1,10 @@
1
1
  {
2
2
  "name": "@eagleoutice/flowr",
3
- "version": "2.13.12",
3
+ "version": "2.13.14",
4
4
  "description": "Static Dataflow Analyzer and Program Slicer for the R Programming Language",
5
+ "engines": {
6
+ "node": ">=22"
7
+ },
5
8
  "types": "dist/src/index.d.ts",
6
9
  "repository": {
7
10
  "type": "git",
@@ -12,7 +15,7 @@
12
15
  "url": "https://github.com/flowr-analysis/flowr/issues"
13
16
  },
14
17
  "scripts": {
15
- "setup:dev": "git lfs fetch && npm ci && git config --local core.hooksPath .githooks/ && git push --dry-run",
18
+ "setup:dev": "npm ci && ts-node --transpile-only scripts/setup-dev.ts",
16
19
  "main": "npm run build:bundle-flowr && node dist/src/cli/flowr.min.js",
17
20
  "flowr": "npm run main --",
18
21
  "flowr:dev": "npm run sync:sigdb && npm run gen:base-packages && npm run main-dev --",
@@ -23,6 +26,8 @@
23
26
  "benchmark-helper": "ts-node src/cli/benchmark-helper-app.ts",
24
27
  "benchmark": "npm run build-dev && node dist/src/cli/benchmark-app.js",
25
28
  "summarizer": "ts-node src/cli/summarizer-app.ts",
29
+ "benchmark:test-counts": "ts-node --transpile-only scripts/test-label-counts.ts",
30
+ "benchmark:compact": "ts-node --transpile-only scripts/compact-benchmark-data.ts",
26
31
  "export-quads": "ts-node src/cli/export-quads-app.ts",
27
32
  "capabilities-markdown": "ts-node src/documentation/doc-capabilities.ts",
28
33
  "wiki": "ts-node src/cli/wiki.ts",
@@ -48,8 +53,8 @@
48
53
  "test:coverage": "npm run test -- --coverage",
49
54
  "test:full": "npm run test-full",
50
55
  "test:bench": "vitest bench --config test/vitest.config.mts",
51
- "test-full": "npm run test:coverage -- --no-watch -- --make-summary --test-installation",
52
- "performance-test": "func() { cd test/performance/ && bash run-all-suites.sh $1 $2 $3 $4; cd ../../; }; func",
56
+ "test-full": "npm run test:coverage -- --no-watch --reporter=default --reporter=json --outputFile.json=coverage/flowr-test-results.json -- --make-summary --test-installation",
57
+ "performance-test": "func() { cd test/performance/ && bash run-all-suites.sh \"$@\"; }; func",
53
58
  "test:performance": "npm run performance-test --",
54
59
  "test:docker": "func() { b() { docker build ${1:+--network=$1} -t flowr-docker-test -f \"$2\" .; }; r() { docker run --rm ${1:+--network=$1} flowr-docker-test --version; }; for df in scripts/Dockerfile scripts/Dockerfile-NoR; do echo \"=== building $df ===\"; b '' \"$df\" || { echo '(retrying with --network=host: bridge networking unavailable)'; b host \"$df\"; } || return 1; echo \"=== smoke-testing $df ===\"; r '' || r host || return 1; done; }; func",
55
60
  "detect-circular-deps": "npx madge --extensions ts,tsx --circular src/",
@@ -34,6 +34,7 @@ export declare class FlowrAnalyzerCache<Parser extends KnownParser> extends Flow
34
34
  private get;
35
35
  reset(): void;
36
36
  private runTapeUntil;
37
+ private stepTapeUntil;
37
38
  private storeIncrementalSnapshotIfAvailable;
38
39
  /**
39
40
  * Get the parse output for the request, parsing if necessary.
@@ -70,6 +70,10 @@ class FlowrAnalyzerCache extends flowr_cache_1.FlowrCache {
70
70
  if (force) {
71
71
  this.reset();
72
72
  }
73
+ /* the contingent belongs to the analysis, so stepping the tape starts one of its own */
74
+ return this.args.context.gas.withGas(undefined, () => this.stepTapeUntil(until));
75
+ }
76
+ async stepTapeUntil(until) {
73
77
  let g;
74
78
  while ((g = until()) === undefined && this.pipeline.hasNextStep()) {
75
79
  await this.pipeline.nextStep();
@@ -202,12 +202,15 @@ class FlowrAnalyzerContext {
202
202
  /** delegate request addition */
203
203
  addRequests(requests) {
204
204
  this.files.addRequests(requests);
205
+ this.gas.reset();
205
206
  }
206
207
  addFile(f) {
207
208
  this.files.addFile(f);
209
+ this.gas.reset();
208
210
  }
209
211
  addFiles(f) {
210
212
  this.files.addFiles(f);
213
+ this.gas.reset();
211
214
  }
212
215
  /**
213
216
  * Get a read-only version of this context.
@@ -233,6 +236,8 @@ class FlowrAnalyzerContext {
233
236
  this.files.receive(event);
234
237
  this.deps.receive(event);
235
238
  this.inc.receive(event);
239
+ /* what became stale is analyzed again, and that gets the full contingent */
240
+ this.gas.receive(event);
236
241
  }
237
242
  }
238
243
  exports.FlowrAnalyzerContext = FlowrAnalyzerContext;