Skip to content

[Query] Provenance

github-actions[bot] edited this page Jul 21, 2026 · 1 revision

This document was generated from 'src/documentation/wiki-query.ts' on 2026-07-20, 17:48:27 UTC presenting an overview of flowR's query API (v2.12.3). Please do not edit this file/wiki page directly.

Provenance Query [overview]

Calculate the provenance of a given variable, optionally restricted to its enveloping fdef
This query is requested with the type provenance.
Run in the REPL: :query @provenance (<criterion>)[f] <code | file://path>

Given a slicing criterion, flowR will return the provenance of the given program element (i.e., all related vertices in a non-interprocedural and non-context sensitive backward slice).

To exemplify the capabilities, consider the following code:

x <- 1
y <- 2
z <- 3
x

If you are interested in the provenance of the x in the last line you can use:

[
  {
    "type": "provenance",
    "criterion": "4@x"
  }
]

(This can be shortened to @provenance (4@x) "x <- 1\ny <- 2\nz <- 3\nx" when used with the REPL command :query).

Results (prettified and summarized):

Query: provenance (6 ms)
   ╰ Provenance for 4@x
     ╰ Mermaid Url
All queries together required ≈6 ms (1ms accuracy, total 7 ms)

Show Detailed Results as Json

The analysis required 6.9 ms (including parsing and normalization and the query) within the generation environment.

In general, the JSON contains the Ids of the nodes in question as they are present in the normalized AST or the dataflow graph of flowR. Please consult the Interface wiki page for more information on how to get those.

{
  "provenance": {
    ".meta": {
      "timing": 6
    },
    "results": {
      "4@x": [
        9,
        0,
        2,
        "built-in:<-",
        1
      ]
    }
  },
  ".meta": {
    "timing": 6
  }
}
Implementation Details

Responsible for the execution of the Provenance Query query is executeProvenanceQuery in ./src/queries/catalog/provenance-query/provenance-query-executor.ts.

Clone this wiki locally