Skip to contents

Evaluates recursive structural path coverage inside contextual roots.

Usage

coverage_rules_path(snapshot, contexts)

Arguments

snapshot

A filesystem snapshot tibble containing at least:

  • full_path

  • rel_path

contexts

A contextual reconstruction object containing path rules.

Value

A tibble describing recursive structural path-rule coverage.

The returned tibble includes:

explored_path

Recursively expanded structural path.

matched_rule

Contextual rule matched against the structural path.

activity

Structural activity associated with the matched rule.

matched

Logical indicating whether the structural path matched a contextual rule.

Details

The function expands relative filesystem paths into recursive structural components and evaluates whether they match contextual path rules.

Typical use cases include:

  • identifying software development structures;

  • identifying testing workflows;

  • identifying ETL/data engineering workflows;

  • detecting unmatched or noisy filesystem structures;

  • evaluating contextual classification coverage.

Structural matching is recursive.

For example:

  • "R/import/helpers.R" matches "R"

  • "tests/testthat/test-import.R" matches "tests/testthat"

The function operates on snapshot-level observations, not observational aggregation units.

Examples

small_snapshot <- tibble::tibble(
  full_path = c(
    "D:/packages/fscontext/R/import/helpers.R",
    "D:/packages/fscontext/tests/testthat/test-import.R",
    "D:/packages/fscontext/data-raw/input.csv"
  ),
  rel_path = c(
    "R/import/helpers.R",
    "tests/testthat/test-import.R",
    "data-raw/input.csv"
  )
)

small_test_context <- list(
  contexts = list(
    fscontext = list(
      roots =
        "D:/packages/fscontext",
      rules = list(
        path = c(
          "R" =
            "software_development",
          "tests/testthat" =
            "unit_testing",
          "data-raw" =
            "etl"
        )
      )
    )
  )
)

path_coverage <- coverage_rules_path(
  snapshot = small_snapshot,
  contexts = small_test_context
)

path_coverage |>
  dplyr::filter(matched) |>
  dplyr::count(activity)
#> # A tibble: 3 × 2
#>   activity                 n
#>   <chr>                <int>
#> 1 etl                      1
#> 2 software_development     2
#> 3 unit_testing             1