Rulebearing Playground Coverage Schemas GitHub

ADR-0073: The extractors read files through rb-model's Files, so the playground can extract from memory

Context

The playground's cruise_ts(files, config, output_type) and cruise_py(...) extract a dropped small repository in the browser. The page hands over a Map of paths to source text. A wasm32-unknown-unknown build has no file system: every std::fs call fails there.

The plan assumed both extractors already read through an Fs trait. Neither did. Both called std::fs directly:

ADR-0010 lets an extractor depend on rb-model only, so a seam both extractors share can live nowhere else.

The plan also asks for explain in the playground, and for its output to equal the command line's. explain lived in rb-cli, which the facade never links (ADR-0067).

Decision

rb-model gains files: Files, MemoryTree and lexical.

Every read an extractor makes goes through a Files.

Over files in memory, what needs the disk or a process is refused by name. Nothing is quietly skipped:

Each is an error that names the option and says to run the command line. A CoffeeScript or LiveScript file is refused as on the command line without --sidecar.

What the playground shares with the command line moves into library crates. rb-cli keeps a re-export or a thin call to each, so both print the same bytes:

Code Was in Now in
explain: finding the rule, rule_json, the text and JSON forms rb-cli rb_rules::explain
the explain --plain sentences rb-cli rb_rules::plain
shouldCalculateMetrics rb-cli rb_rules::evaluate::wants_metrics
summary.optionsUsed and normalizeReporterOptions rb-cli rb_config::options_used

Neither crate's dependency row changes, and neither gains a match language.

rb-wasm joins rb-extract-ts and rb-extract-python in its row. It exports all five functions of § 1.6. The files the page gives sit under /playground, the run's working directory. A path that climbs out of it is refused.

Consequences

Alternatives considered

Option Why not
A trait Fs per extractor, with generic settings Two copies of one seam, and a type parameter through every function of both pipelines, for the same two implementations.
A new crate for the seam Changes every extractor's row in ADR-0010's table, which says an extractor depends on rb-model only.
WASI, with the files written to a virtual disk Needs a WASI runtime in the page and a different target from the one ADR-0067 builds. The extractors' std::fs calls would still be the ones under test, not a seam the native tests can reach.
Leave explain in rb-cli and reimplement it in rb-wasm Two copies of one output that are meant to stay byte-identical.