diff --git a/.config/nextest-guests.toml b/.config/nextest-guests.toml
new file mode 100644
index 0000000000..4a97fd855c
--- /dev/null
+++ b/.config/nextest-guests.toml
@@ -0,0 +1,25 @@
+# The extension guests' nextest profiles (ADR 0393 D1). Each guest is its own workspace, so nextest finds no
+# config of its own: the gate's `guests` check prefixes this file with a `[store]` table (the repository root's
+# `target/nextest`) and appends a `[profile.
.junit]` path per guest, then passes the result with
+# `--config-file`. The bodies are `.config/nextest.toml`'s, line for line (a gate test holds them in step); its package
+# overrides and JUnit tables stay there (they name root packages, and nextest refuses to parse them against a guest
+# manifest).
+
+[profile.default]
+retries = 0
+fail-fast = true
+slow-timeout = { period = "30s", terminate-after = 2 }
+status-level = "fail"
+
+[profile.ci]
+retries = 1
+fail-fast = false
+slow-timeout = { period = "60s", terminate-after = 3 }
+status-level = "all"
+
+[profile.gate]
+retries = 0
+fail-fast = false
+slow-timeout = { period = "60s", terminate-after = 3 }
+status-level = "fail"
+final-status-level = "slow"
diff --git a/.config/nextest.toml b/.config/nextest.toml
index 1a2911935f..df9bae2095 100644
--- a/.config/nextest.toml
+++ b/.config/nextest.toml
@@ -38,6 +38,19 @@ path = "junit.xml"
filter = "package(specforge-cli) & test(=extension_authoring::a_scaffolded_extension_builds_and_validates)"
slow-timeout = { period = "60s", terminate-after = 10 }
+# Applies one edit plan of as many creates as the `gsd import` operation cap
+# (`MAX_OPS` in gsd/import/src/limits.rs, ADR 0391 D9): ~38 s at 2,000 on an
+# idle machine, past the default 60 s bound when loaded.
+[[profile.default.overrides]]
+filter = "package(specforge-ops) & test(=plans::one_plan_of_many_creates_applies)"
+slow-timeout = { period = "60s", terminate-after = 3 }
+
+# The X2 floor's negative control (ADR 0393 D8) collects the ledger twice with
+# the real specforge: a cold wasm compile of the packs.
+[[profile.default.overrides]]
+filter = "package(gate) & test(=dogfood::tests::x2_floor_fails_a_ledger_copy_missing_one_case)"
+slow-timeout = { period = "120s", terminate-after = 3 }
+
# absorb's end-to-end tests load `@gsd/core` and the old builtins cold on a
# Windows runner, where a compile takes longer than the default kill bound
# allows (ADR 0375 D4). Windows only: the Linux and macOS bounds are unchanged.
diff --git a/.github/workflows/bootstrap.yml b/.github/workflows/bootstrap.yml
index 9841ae75d7..48d67fa6eb 100644
--- a/.github/workflows/bootstrap.yml
+++ b/.github/workflows/bootstrap.yml
@@ -2,7 +2,7 @@ name: Bootstrap
# A cold clone rebuilds every committed blob. It takes ~8 min uncached, so a PR runs it only when what the blobs
# compile from changes (the paths every `inputs.json` records, plus the build tooling); main runs it on every push.
-# A gsd input runs it too: `gsd/core/**`, `gsd/kit/**`, `gsd/.cargo/**` (the SDK patch) and `gsd/Cargo.lock`, which
+# A gsd input runs it too: `gsd/core/**`, `gsd/import/**`, `gsd/kit/**`, `gsd/.cargo/**` (the SDK patch) and `gsd/Cargo.lock`, which
# `@gsd/core`'s record hashes whole. A gate test holds these paths to every input any record lists.
# A PR that misses it still has the `builtins` check (ci.yml), which compares each blob's recorded inputs.
on:
@@ -21,6 +21,7 @@ on:
- "fixtures/**"
- "examples/marketing/extension/**"
- "gsd/core/**"
+ - "gsd/import/**"
- "gsd/kit/**"
- "gsd/Cargo.lock"
- "gsd/.cargo/**"
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 020766d0a8..faf3986284 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -111,6 +111,23 @@ jobs:
# A PR runs the checks its diff reaches (quick's triggers); main runs the whole list.
- name: Run the shard's checks
run: cargo gate ci --only ${{ matrix.checks }} ${{ github.event_name == 'pull_request' && format('--since origin/{0}', github.base_ref) || '' }}
+ # The artifact's name is its directory, so the dogfood job's download lands where a local run writes (ADR 0393 D2).
+ - name: Keep the guests' JUnit reports for dogfood
+ if: github.event_name == 'push' && matrix.shard == 'specs'
+ uses: actions/upload-artifact@v4
+ with:
+ name: junit-guests
+ path: target/nextest/ci/junit-guests
+ if-no-files-found: error
+ retention-days: 1
+ - name: Keep the gsd JUnit report for dogfood
+ if: github.event_name == 'push' && matrix.shard == 'gsd'
+ uses: actions/upload-artifact@v4
+ with:
+ name: junit-gsd
+ path: target/nextest/ci/junit-gsd
+ if-no-files-found: error
+ retention-days: 1
- name: Build-time budget
shell: bash
run: |
@@ -375,8 +392,9 @@ jobs:
echo "$line"
dogfood:
- # Each tests partition's nextest JUnit report lands in its own directory under target/nextest/ci (no
- # merge-multiple: every partition writes junit.xml); dogfood merges them and judges the requirements' proof.
+ # Each tests partition's nextest JUnit report, the guests' (junit-guests) and the gsd one (junit-gsd) land in their
+ # own directories under target/nextest/ci (no merge-multiple: every partition writes junit.xml); dogfood merges
+ # them and judges the requirements' proof.
name: Check list (dogfood)
needs: [ci, tests]
if: github.event_name == 'push'
@@ -397,9 +415,13 @@ jobs:
prefix-key: ${{ env.CACHE_PREFIX }}
shared-key: specs
save-if: false
+ # dogfood runs the X2 floor's negative control under nextest (ADR 0393 D8).
+ - uses: taiki-e/install-action@v2
+ with:
+ tool: nextest
- uses: actions/download-artifact@v4
with:
- pattern: junit-tests-*
+ pattern: junit-*
path: target/nextest/ci
- name: Run dogfood
run: cargo gate ci --only dogfood
diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md
index a08f6c34ad..7a278e4f33 100644
--- a/ARCHITECTURE.md
+++ b/ARCHITECTURE.md
@@ -6,7 +6,7 @@ How SpecForge is built. For what it is and why it exists, start with the [README
The compiler is a **pure typed-graph engine**. It knows how to parse `keyword name { fields }` blocks, resolve references, detect orphans and cycles, and emit a validated graph — but it carries **no domain vocabulary**. Every entity kind, edge type, and validation rule comes from an extension. If a new domain required a compiler change, the architecture would have failed.
-Fifteen extensions ship as builtins, embedded in the binary. A first-party builtin is `@specforge/`; a builtin of a family is `@/` (`@code/core`), its crate `extensions//`, and its codes print namespaced (`code/E101`, [ADR 0328](docs/adr/0328-a-builtin-is-embedded-and-a-non-specforge-builtin-catalogues-its-codes.md)). `@gsd/core` is the one builtin outside `extensions/`: its crate is `gsd/core`, and its codes print namespaced `gsd/…` ([ADR 0366](docs/adr/0366-gsd-core-is-vendored-as-a-builtin-with-a-size-allowance-of-its-own.md)). Enable one with `specforge add ` (or `specforge init --extensions ...`); it is recorded in `specforge.json`, with nothing to download:
+Twenty-eight extensions ship as builtins, embedded in the binary. A first-party builtin is `@specforge/`; a builtin of a family is `@/` (`@code/core`), its crate `extensions//`, and its codes print namespaced (`code/E101`, [ADR 0328](docs/adr/0328-a-builtin-is-embedded-and-a-non-specforge-builtin-catalogues-its-codes.md)). Two builtins live outside `extensions/`, in the gsd workspace: `@gsd/core`, whose crate is `gsd/core` and whose codes print namespaced `gsd/…` ([ADR 0366](docs/adr/0366-gsd-core-is-vendored-as-a-builtin-with-a-size-allowance-of-its-own.md)), and `@gsd/import`, whose crate is `gsd/import` ([ADR 0391](docs/adr/0391-gsd-import-reads-a-planning-folder-once-into-one-edit-plan.md)). Enable one with `specforge add ` (or `specforge init --extensions ...`); it is recorded in `specforge.json`, with nothing to download:
| Extension | Entity kinds | Purpose |
|-----------|-------------|---------|
@@ -17,14 +17,27 @@ Fifteen extensions ship as builtins, embedded in the binary. A first-party built
| **`@specforge/testing`** | — | Test vocabulary: which kinds accept `verify` obligations and of which kinds (W004/W009). Enabled with `@specforge/software`; test-runner extensions build on it ([ADR 0002](docs/adr/0002-test-runner-extensions.md)). |
| **`@specforge/cargo-test`** | — | Rust test runner: `specforge collect` runs `cargo test` (after you approve the command once per project) and records which entities the `#[specforge_test]`-annotated tests prove. Enabled by `init` in a Cargo project; `specforge add` also enables `@specforge/testing`. |
| **`@specforge/vitest`** | — | vitest runner: `specforge collect` runs the project's own vitest (after you approve the command once per project) and records which entities tests name in their `meta.specforge`. Enabled by `init` in a vitest project; `specforge add` also enables `@specforge/testing`. |
-| **`@code/core`** | test · test_run (collector-written) | The neutral base of test facts ([ADR 0329](docs/adr/0329-code-core-holds-test-facts-and-their-ids.md)): the kinds a runner pack collects into, and the checks of the references a spec writes to them (`code/E101`, `code/W102`, `code/W401`, `code/I402`). Declares no collector. |
+| **`@code/core`** | test · test_run · item · package · coverage · api_item · static_finding · dependency · vulnerability (collector-written) | The neutral base of code facts ([ADR 0329](docs/adr/0329-code-core-holds-test-facts-and-their-ids.md)): the kinds a runner, source or manifest pack collects into, the report kinds a standard report's reader mints ([ADR 0388](docs/adr/0388-x2-is-the-share-of-test-ids-a-standard-report-saw.md)), and the checks of the references a spec writes to them (`code/E101`, `code/W102`, `code/W401`, `code/I402`) and of what a report leaves unmapped (`code/W104` to `code/W107`). Declares no collector. |
| **`@specforge/checks`** | — | The generic value checkers: files, formats, check digits, links and git, each family behind a setting ([ADR 0338](docs/adr/0338-one-foundation-extension-holds-the-generic-value-checkers.md)). |
| **`@javascript/node-test`** | — | node --test runner: `specforge collect` runs the project's own node test runner (after you approve the command once per project) and records its tests as `test`/`test_run` facts, cited as `js:/#`. `specforge add` also enables `@code/core`. |
| **`@rust/cargo`** | — | Reads every `Cargo.toml` with cargo's own manifest model into `package` facts (`pkg:cargo/`): version, edition, targets, the project packages it depends on. Runs nothing ([ADR 0348](docs/adr/0348-a-collector-declares-a-config-file-and-the-rust-packs.md)). `specforge add` also enables `@code/core`. |
| **`@rust/source`** | — | Walks each cargo target's module tree and has the host's reader parse it into `item` facts (`rust:::`), a test function with the id nextest gives it and the entity its `#[specforge_test]` names. `specforge add` also enables `@rust/cargo`. |
| **`@rust/test`** | — | nextest runner: `specforge collect` runs `cargo-nextest` (after you approve the command and the config file it reads, once per project) and records its tests as `test`/`test_run` facts, cited as `rust:#`; an ignored test is held as `skipped`. `specforge add` also enables `@rust/source`. |
| **`@javascript/source`** | — | Has the host's reader parse a JavaScript or TypeScript project's source (test files and generated output left out) into `item` facts (`js:/::[.]`), whether an importer reaches each, and a `package` fact per named `package.json` (`pkg:npm/`). Runs nothing. `specforge add` also enables `@code/core`. |
+| **`@rust/coverage`** | — | Runs `cargo-llvm-cov` over nextest (after you approve the command once per project) and records its LCOV as `coverage` facts of the items each line lands in; a file outside the project is skipped and shown as W203 ([ADR 0389](docs/adr/0389-report-packs-run-standard-tools-and-doctor-names-a-missing-one.md)). `specforge add` also enables `@rust/source`. |
+| **`@rust/lint`** | — | Runs `cargo-clippy` (after approval), captures its JSON messages and records each diagnostic as a `static_finding` fact citing the item holding it. `specforge add` also enables `@rust/source`. |
+| **`@rust/deps`** | — | Runs `cargo-cyclonedx` (after approval), reads each BOM it wrote fresh, and records `dependency` facts; runs `osv-scanner` on `Cargo.lock` and records `vulnerability` facts. `specforge add` also enables `@rust/source`. |
+| **`@rust/api`** | — | Runs `cargo-public-api` (after approval), captures its text and records the crate's public API as `api_item` facts. `specforge add` also enables `@rust/source`. |
+| **`@rust/proof`** | — | Runs Kani (after approval, Linux x86_64 and macOS only), captures its output and records each proof harness as a `test`/`test_run` fact, `rust:#`, placed at its function; a cut-off output is refused, never half-read. `specforge add` also enables `@rust/source`. |
+| **`@javascript/coverage`** | — | Runs c8 around the project's own `npm test` (after approval) and records its LCOV as `coverage` facts. `specforge add` also enables `@javascript/source`. |
+| **`@javascript/lint`** | — | Runs ESLint with its SARIF formatter (after approval) and records each result as a `static_finding` fact. `specforge add` also enables `@javascript/source`. |
+| **`@javascript/deps`** | — | Runs cyclonedx-npm on `package-lock.json` (after approval) for `dependency` facts, and `osv-scanner` for `vulnerability` facts. `specforge add` also enables `@javascript/source`. |
+| **`@javascript/api`** | — | Runs api-extractor (after approval) on a config file the host writes and records the package's public API as `api_item` facts. `specforge add` also enables `@javascript/source`. |
+| **`@javascript/vitest`** | — | vitest runner: runs `vitest run` with its JUnit reporter (after approval) and records its tests as `test`/`test_run` facts, `js:/#`; the legacy `@specforge/vitest` stays beside it. `specforge add` also enables `@javascript/source`. |
+| **`@javascript/jest`** | — | jest runner: runs jest with jest-junit through an env file the host writes (after approval) and records its tests as `test`/`test_run` facts. `specforge add` also enables `@javascript/source`. |
+| **`@javascript/playwright`** | — | Playwright runner: runs `playwright test` (after approval), captures its JUnit and records its tests as `test`/`test_run` facts. `specforge add` also enables `@javascript/source`. |
| **`@gsd/core`** | requirement · milestone · phase · plan · task · summary · verification · … (61 kinds, scoped) | The GSD spec framework as one extension: its roadmap, plans, execution, verification and UAT kinds, its judged rules and codes, settings and profiles, and the prompts, agents, skills, slash commands and hooks it installs into a coding agent's host ([ADR 0366](docs/adr/0366-gsd-core-is-vendored-as-a-builtin-with-a-size-allowance-of-its-own.md), [ADR 0370](docs/adr/0370-gsd-core-holds-exactly-gsd-cores-kinds-and-fields.md)). |
+| **`@gsd/import`** | — (one command) | `specforge gsd import` reads a GSD `.planning/` once into one edit plan writing `spec/gsd/`, with a report of everything it does not map ([ADR 0391](docs/adr/0391-gsd-import-reads-a-planning-folder-once-into-one-edit-plan.md)). Its required peer is `@gsd/core`. |
Anyone can author and publish their own extension ([Extension Protocol](docs/extension-protocol.md)); the open Graph Protocol is the moat, not the implementation. The full catalog is in the [extension inventory](docs/extension-inventory.md).
diff --git a/CONTEXT.md b/CONTEXT.md
index 00e21e6836..6e182ed0b7 100644
--- a/CONTEXT.md
+++ b/CONTEXT.md
@@ -557,7 +557,8 @@ Terms the code, the specs and the docs use with one meaning. Architecture decisi
(`specforge_project::ExtensionLoad`: `NoRuntime`, or what was loaded `In` a runtime).
- **Builtin**: a component this specforge embeds, a row of `BUILTINS`, loaded by name (`specforge add @code/core`),
whatever its scope. Its crate is `extensions/` (named `@specforge/`), `extensions//`
- (named `@/`), or `gsd/core` for `@gsd/core`, the one builtin outside `extensions/` (ADR 0366), and
+ (named `@/`), or `gsd/core` for `@gsd/core` and `gsd/import` for `@gsd/import`, the two builtins outside `extensions/`
+ (ADR 0366, ADR 0391), and
holds a `wasm/` dir. Not the same as first party: a builtin outside `@specforge/`
catalogues its codes and prints them namespaced, as a third party's do (`code/E101`, ADR 0328).
- **First-party extension**: an extension of the `@specforge/` scope. Its codes are bare, in the static catalogue that
@@ -566,7 +567,13 @@ Terms the code, the specs and the docs use with one meaning. Architecture decisi
(`extensions/code/`); its builtins are named `@/`. The family `specforge` is refused (ADR 0328 D3).
- **Extension library**: a crate in an extension family with no `wasm/` dir: an rlib named `specforge--`,
never embedded, that builtins link (`extensions/code/junit`, `extensions/code/facts`). Editing it re-vendors the
- builtins that link it.
+ builtins that link it. The six report readers are `specforge-code-lcov`, `-api`, `-sarif`, `-cyclonedx` and `-osv`
+ (`extensions/code/{lcov,api,sarif,cyclonedx,osv}`, linking code-facts, ADR 0388) and `specforge-code-kani`
+ (`extensions/code/kani`, Kani's regular output, linking nothing). The report packs link them (ADR 0389), so editing
+ a reader re-vendors exactly the packs that link it; `specforge-code-kani` feeds `@rust/proof` only.
+- **X2**: the share of items carrying a test id whose id a test fact holds, that is, a standard test report saw it,
+ whatever its status. `cargo gate full`'s dogfood check prints it for SpecForge, taskboard and ledger, with no floor
+ (`gate/src/x2.rs`, ADR 0388).
- **Builtin's name**: the name a builtin this specforge embeds declares. Only that builtin loads under it: a `.wasm` file entry whose component declares it is refused by the load's admit (E028), and add, update, init, publish, extension validate and extension init refuse a candidate declaring it (`extension_conflict`). One predicate, `Builtins::contains` (ADR 0028 D7, ADR 0214).
- **Load key**: the key the runtime holds an entry's component under while its declaration is read: a builtin's or a locked entry's name, a `.wasm` file entry's `file:`, a candidate's `__candidate`. Every name the load admits is a package name and no temporary key is one, so a load never replaces another entry's extension (`load_key`, ADR 0223).
- **Extension inventory**: every extension a project has, one row per name: enabled by a
diff --git a/Cargo.lock b/Cargo.lock
index adc4adb4ea..150bd571d0 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1258,9 +1258,9 @@ checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb"
[[package]]
name = "form_urlencoded"
-version = "1.2.2"
+version = "1.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf"
+checksum = "afa489199eaffb1211795df1c6236ce1ad0d41a6fa45250add73e3b02420f06e"
dependencies = [
"percent-encoding",
]
@@ -5708,9 +5708,9 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1"
[[package]]
name = "url"
-version = "2.5.8"
+version = "2.5.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed"
+checksum = "f00cd2407bb42c0ef17be88d4cf020f5cceffd121665bac9b8b9493a369b3b1a"
dependencies = [
"form_urlencoded",
"idna",
diff --git a/crates/app/ops/src/analysis/analyze.rs b/crates/app/ops/src/analysis/analyze.rs
index 98c36d4837..afefda1cfb 100644
--- a/crates/app/ops/src/analysis/analyze.rs
+++ b/crates/app/ops/src/analysis/analyze.rs
@@ -382,12 +382,14 @@ pub fn analyze(
}
// An analyze pass reads what changed as the compile it analyzes takes it (ADR 0376 D6).
let delta = view.project().pass_delta();
+ // A pass's declared file reads go through the view's containment: a bounded one refuses a hard link (ADR 0146).
+ let disk = view.containment().file_reads_disk();
if let Some(runtime) = view.runtime() {
let context = PassContext {
test_results: report.as_deref(),
proved_claims: proved.as_ref().map(|_| &proved_claims),
judgements: Some(view.project().judgements()),
- files: Some(view.env().file_source(&specforge_registry::PlainDisk)),
+ files: Some(view.env().file_source(&disk)),
delta: delta.as_deref(),
..PassContext::of(view.entities())
};
diff --git a/crates/app/ops/src/analysis/collect/collector.rs b/crates/app/ops/src/analysis/collect/collector.rs
index a8234366e6..beab5c2cfb 100644
--- a/crates/app/ops/src/analysis/collect/collector.rs
+++ b/crates/app/ops/src/analysis/collect/collector.rs
@@ -7,7 +7,7 @@ use specforge_effects::Uses;
use specforge_effects::git::{Git, Located};
use specforge_protocol_types::{
CONFIG_PLACEHOLDER, ExtensionDeclaration, FILTER_PLACEHOLDER, Input, Inputs, Operation,
- PortScope, ProcessConfig, REPORT_PLACEHOLDER,
+ PortScope, ProcessConfig, REPORT_PLACEHOLDER, is_report_name, is_wild,
};
use std::path::Path;
@@ -41,8 +41,10 @@ pub struct Collector {
/// The arguments its process capability appends after `run` when a caller passes a filter (ADR 0360), `{filter}`
/// in one of them the caller's text: empty when it takes none.
pub filter: Vec,
- /// What installs its program, said when the program is not found (ADR 0348 D4).
+ /// What installs its programs, said when one is not found (ADR 0348 D4).
pub install: Option,
+ /// The other programs its command runs beside `run`'s first, which doctor looks up too (ADR 0389 D3).
+ pub requires: Vec,
}
impl Collector {
@@ -114,6 +116,7 @@ fn collector(
config: process.and_then(|p| p.config.clone()),
filter: process.map(|p| p.filter.clone()).unwrap_or_default(),
install: c.install.clone(),
+ requires: c.requires.clone(),
}
}
@@ -143,6 +146,16 @@ fn in_a_repository(git: Option<&dyn Git>, root: &Path) -> bool {
git.is_some_and(|git| !matches!(git.locate(root), Located::NotARepository))
}
+/// The collectors a collect run here would detect, a repository asked of `git`: what doctor probes the programs of.
+pub fn detected_here(
+ declarations: &[ExtensionDeclaration],
+ root: &Path,
+ git: Option<&dyn Git>,
+) -> Vec {
+ let all = collectors(declarations);
+ detect(&all, root, git).into_iter().cloned().collect()
+}
+
/// The scopes a collect run here would use, per extension: each detected collector's process capability (ADR 0335
/// D2), a repository asked of `git`: what `specforge grants` and doctor call in use.
pub fn uses_here(
@@ -201,9 +214,19 @@ pub(super) fn wildcard(pattern: &str, name: &str) -> bool {
true
}
-/// The report location, held. An extension may only declare a relative name without `..`
-/// ([`crate::containment::declared`], E058); where the name lands is the request's containment
-/// (a symlink that leaves the project is `outside_root`).
+/// The collector's report when it is a glob (ADR 0389): one of its `/`-separated segments holds `*` or `?`.
+pub(super) fn report_glob(collector: &Collector) -> Option<&str> {
+ collector
+ .report
+ .as_deref()
+ .filter(|report| report.split('/').any(is_wild))
+}
+
+/// The report location, held: the report itself, or for a glob its literal base directory (the segments before the
+/// first wildcard; the project root when there are none). An extension may only declare a relative name without `..`
+/// ([`crate::containment::declared`], E058); where the name lands is the request's containment (a symlink that leaves
+/// the project is `outside_root`). A glob names files the tool writes itself, so one whose last segment is not a
+/// literal file name, or a command told its report (`{report}`) or a captured output, which need one file, is E058.
pub(super) fn report_path(
collector: &Collector,
root: &Path,
@@ -222,7 +245,47 @@ pub(super) fn report_path(
),
));
};
- Ok(containment.resolve(&root.join(relative))?)
+ if report_glob(collector).is_none() {
+ return Ok(containment.resolve(&root.join(relative))?);
+ }
+ // The registry refuses this declaration (E030); a collector built from one anyway reads nothing.
+ if !is_report_name(report) {
+ return Err(OpError::coded(
+ OpErrorKind::PreconditionFailed,
+ codes::E058,
+ format!(
+ "collector '{}' of {} declares the report glob '{report}': a report glob must end in a literal file \
+ name, so it names the files one tool writes",
+ collector.name, collector.extension
+ ),
+ ));
+ }
+ if collector.told_its_report() || collector.capture.is_some() {
+ return Err(OpError::coded(
+ OpErrorKind::PreconditionFailed,
+ codes::E058,
+ format!(
+ "collector '{}' of {} declares the report glob '{report}' and also {}: a report glob names files the \
+ tool writes itself, so there is no single file to name",
+ collector.name,
+ collector.extension,
+ if collector.capture.is_some() {
+ "captures its output"
+ } else {
+ "tells its command `{report}`"
+ }
+ ),
+ ));
+ }
+ let base: Vec<&str> = report
+ .split('/')
+ .take_while(|segment| !is_wild(segment))
+ .collect();
+ let base = match base.join("/") {
+ literal if literal.is_empty() => root.to_path_buf(),
+ literal => root.join(literal),
+ };
+ Ok(containment.resolve(&base)?)
}
/// E058 for a report asked of a collector that reads through its ports.
diff --git a/crates/app/ops/src/analysis/collect/dispatch.rs b/crates/app/ops/src/analysis/collect/dispatch.rs
index 02679571f0..26d7c83429 100644
--- a/crates/app/ops/src/analysis/collect/dispatch.rs
+++ b/crates/app/ops/src/analysis/collect/dispatch.rs
@@ -4,8 +4,12 @@ use super::collector::Collector;
use crate::view::ProjectView;
use crate::{Containment, Held, OpError, OpErrorKind};
use specforge_common::codes;
+use specforge_effects::process::OUTPUT_CAP;
+use specforge_project::file_reads::{FileSource, glob_paths};
use specforge_protocol_types::Operation;
-use specforge_protocol_types::{CollectInput, CollectOutput, CollectReportFile, Fact, RawGraph};
+use specforge_protocol_types::{
+ CollectInput, CollectOutput, CollectReportFile, FILE_READ_MAX, Fact, GLOB_VISITS_MAX, RawGraph,
+};
use specforge_wasm::{CallError, CallFailure, ExtensionCalls, PortCall};
use std::path::{Path, PathBuf};
use std::time::SystemTime;
@@ -35,31 +39,98 @@ pub(super) fn read_report(
since: Option,
containment: &Containment,
) -> Result, OpError> {
- let fresh = |path: &PathBuf| {
- since.is_none_or(|since| {
- std::fs::metadata(path)
- .and_then(|m| m.modified())
- .is_ok_and(|modified| modified >= since)
- })
- };
let mut held = Vec::new();
if report.real.is_dir() {
- for path in json_files(&report.real).into_iter().filter(fresh) {
+ for path in json_files(&report.real)
+ .into_iter()
+ .filter(|path| fresh(path, since))
+ {
let name = path.file_name().unwrap_or_default();
held.push(report.entry(containment, Path::new(name))?);
}
} else if report.real.is_file() {
held.push(report.clone());
}
+ read_held(&held, root, containment)
+}
+
+/// Read every project file `glob` matches (ADR 0389), listed by the walk `Input::files` globs take
+/// ([`glob_paths`]: ADR 0293 D4), only those modified at or after `since` when given. Each match is held by
+/// `containment` before it is opened: one that lands outside (a link out of the project) is skipped, never read, and
+/// its project path is returned beside the files, for a W203 to name. A walk cut short is E045 naming the cap; a read
+/// that fails is E045.
+pub(super) fn read_glob(
+ glob: &str,
+ project: &FileSource<'_>,
+ root: &Path,
+ since: Option,
+ containment: &Containment,
+) -> Result<(Vec, Vec), OpError> {
+ let listed = glob_paths(project, glob);
+ if listed.truncated {
+ return Err(OpError::coded(
+ OpErrorKind::SchemaMismatch,
+ codes::E045,
+ format!(
+ "the report glob '{glob}' reaches past the walk's cap of {GLOB_VISITS_MAX} entries or {FILE_READ_MAX} files; \
+ name a narrower glob"
+ ),
+ ));
+ }
+ let mut outside = Vec::new();
+ let mut held: Vec = Vec::new();
+ for path in &listed.files {
+ match containment.resolve(&root.join(path)) {
+ Ok(file) if fresh(&file.real, since) => held.push(file),
+ Ok(_) => {}
+ Err(_) => outside.push(path.clone()),
+ }
+ }
+ Ok((read_held(&held, root, containment)?, outside))
+}
+
+/// Whether the file at `path` was modified at or after `since` (always, with no `since`).
+fn fresh(path: &Path, since: Option) -> bool {
+ since.is_none_or(|since| {
+ std::fs::metadata(path)
+ .and_then(|m| m.modified())
+ .is_ok_and(|modified| modified >= since)
+ })
+}
+
+/// The most bytes one collector's report files hold together: what a captured standard output may hold
+/// ([`OUTPUT_CAP`]), so a directory or a glob of many files reads no more than one capture.
+pub const REPORT_BYTES_MAX: u64 = OUTPUT_CAP;
+
+/// The text of each `held` file as a report, named as a project path of `root`, read through `containment`: a
+/// bounded one refuses a file with several names, which a hard link from outside the project could have made
+/// (ADR 0146). A read that fails, text that is not UTF-8, or files past [`REPORT_BYTES_MAX`] together, is E045.
+fn read_held(
+ held: &[Held],
+ root: &Path,
+ containment: &Containment,
+) -> Result, OpError> {
+ let mut total: u64 = 0;
held.iter()
.map(|file| {
- let content = file.read_to_string().map_err(|e| {
+ let content = containment.read_held(file).and_then(utf8).map_err(|e| {
OpError::coded(
OpErrorKind::SchemaMismatch,
codes::E045,
format!("failed to read report {}: {e}", file.named.display()),
)
})?;
+ total = total.saturating_add(content.len() as u64);
+ if total > REPORT_BYTES_MAX {
+ return Err(OpError::coded(
+ OpErrorKind::SchemaMismatch,
+ codes::E045,
+ format!(
+ "the report files reach past {REPORT_BYTES_MAX} bytes together at {}; name a narrower report",
+ file.named.display()
+ ),
+ ));
+ }
Ok(CollectReportFile {
path: file.shown(root).into_string(),
content,
@@ -68,6 +139,16 @@ pub(super) fn read_report(
.collect()
}
+/// `bytes` as text: bytes that are not UTF-8 are `InvalidData`, worded as `regular::read_to_string` words them.
+fn utf8(bytes: Vec) -> std::io::Result {
+ String::from_utf8(bytes).map_err(|_| {
+ std::io::Error::new(
+ std::io::ErrorKind::InvalidData,
+ "stream did not contain valid UTF-8",
+ )
+ })
+}
+
/// Hand the report files, and the captured standard output if any, to the
/// collector's pure export: the protocol's `CollectInput` in, its
/// `CollectOutput` out. Err: the export trapped, or answered something
diff --git a/crates/app/ops/src/analysis/collect/evidence.rs b/crates/app/ops/src/analysis/collect/evidence.rs
index 97bba82c96..c09f7f41cf 100644
--- a/crates/app/ops/src/analysis/collect/evidence.rs
+++ b/crates/app/ops/src/analysis/collect/evidence.rs
@@ -5,25 +5,31 @@
use super::collector::{
ConfigFile, capture_path, captures_stdout, command_line, config_file, read_capture,
- reads_no_report, report_path,
+ reads_no_report, report_glob, report_path,
};
-use super::dispatch::read_report;
+use super::dispatch::{read_glob, read_report};
use super::{Collector, Mode, fail};
use crate::machine::{CollectorCommand, CollectorMachine, Ran, RunFailure, RunnerOutput};
use crate::{Containment, Held, OpError, OpErrorKind};
use specforge_common::codes;
+use specforge_project::file_reads::FileSource;
use specforge_protocol_types::CollectReportFile;
use std::path::{Path, PathBuf};
+use std::time::SystemTime;
/// A collector's declared report location and captured output, held.
pub(super) struct Declared {
+ /// The report, or a glob's literal base directory.
report: Held,
+ /// The report glob, when the report is one (ADR 0389).
+ glob: Option,
capture: Option,
}
impl Declared {
/// `collector`'s declared report and capture, held by `containment`: E058 for a report name that is not
- /// relative-without-`..` or an unknown capture; `outside_root` for one that lands outside.
+ /// relative-without-`..`, an unknown capture, or a glob a single path is asked of; `outside_root` for one that
+ /// lands outside.
fn of(collector: &Collector, root: &Path, containment: &Containment) -> Result {
let report = report_path(collector, root, containment)?;
let capturing = captures_stdout(collector)
@@ -33,7 +39,36 @@ impl Declared {
} else {
None
};
- Ok(Declared { report, capture })
+ Ok(Declared {
+ report,
+ glob: report_glob(collector).map(str::to_string),
+ capture,
+ })
+ }
+
+ /// The report files: every match of the glob, else the file or the directory's `*.json` files; only those modified
+ /// since `since` when given. Beside them, the glob's matches that land outside the project, not read.
+ fn read(
+ &self,
+ root: &Path,
+ since: Option,
+ containment: &Containment,
+ project: &FileSource<'_>,
+ ) -> Result<(Vec, Vec), OpError> {
+ match &self.glob {
+ Some(glob) => read_glob(glob, project, root, since, containment),
+ None => Ok((
+ read_report(&self.report, root, since, containment)?,
+ Vec::new(),
+ )),
+ }
+ }
+
+ /// Where the report is, as a message names it: the glob, else the declared location.
+ fn shown(&self) -> String {
+ self.glob
+ .clone()
+ .unwrap_or_else(|| self.report.named.display().to_string())
}
/// The captured output, if the collector captures one and it is there.
@@ -70,6 +105,8 @@ pub(super) struct Evidence {
pub(super) exit_code: Option,
/// Whether the collector's command ran.
pub(super) ran: bool,
+ /// The report glob's matches that land outside the project (a link out of it), not read (ADR 0389 D6).
+ pub(super) unread: Vec,
}
impl<'m> Source<'m> {
@@ -120,15 +157,18 @@ impl<'m> Source<'m> {
}
/// Gather the evidence: under `Run`, announce then run (E045 when it cannot start or its capture cannot be
- /// written), then read. No report file and no captured output is E045, worded for the source.
+ /// written), then read; a report glob is listed over `project`. No report file and no captured output is E045,
+ /// worded for the source.
pub(super) fn gather(
&self,
collector: &Collector,
root: &Path,
containment: &Containment,
+ project: &FileSource<'_>,
machine: &dyn CollectorMachine,
announce: &mut dyn FnMut(&Collector, &[String]),
) -> Result {
+ let mut unread = Vec::new();
let (files, stdout, exit_code, ran) = match self {
Source::Run {
output,
@@ -140,8 +180,7 @@ impl<'m> Source<'m> {
let ran = run_command(
machine,
root,
- (&declared.report, !collector.told_its_report()),
- declared.capture.as_ref(),
+ (declared, !collector.told_its_report()),
config.as_ref(),
argv,
*output,
@@ -150,11 +189,13 @@ impl<'m> Source<'m> {
let message = failure.said(collector, argv);
fail(OpErrorKind::SchemaMismatch, codes::E045, message)
})?;
- let files = read_report(&declared.report, root, Some(ran.started), containment)?;
+ let files;
+ (files, unread) = declared.read(root, Some(ran.started), containment, project)?;
(files, declared.stdout(), ran.exit_code, true)
}
Source::Written(declared) => {
- let files = read_report(&declared.report, root, None, containment)?;
+ let files;
+ (files, unread) = declared.read(root, None, containment, project)?;
(files, declared.stdout(), None, false)
}
Source::Given(paths) => {
@@ -174,17 +215,18 @@ impl<'m> Source<'m> {
&& files.is_empty()
&& stdout.as_deref().is_none_or(str::is_empty)
{
- return Err(fail(
- OpErrorKind::SchemaMismatch,
- codes::E045,
- self.nothing_found(collector),
- ));
+ let mut message = self.nothing_found(collector);
+ if !unread.is_empty() {
+ message.push_str(&format!("; {}", super::warnings::unread_paths(&unread)));
+ }
+ return Err(fail(OpErrorKind::SchemaMismatch, codes::E045, message));
}
Ok(Evidence {
files,
stdout,
exit_code,
ran,
+ unread,
})
}
@@ -194,12 +236,12 @@ impl<'m> Source<'m> {
Source::Run { declared, .. } => format!(
"{} produced no report at {} (did the tests build?)",
collector.name,
- declared.report.named.display()
+ declared.shown()
),
Source::Written(declared) => format!(
"no {} report at {}; run the tests to write one (`specforge collect` runs them)",
collector.name,
- declared.report.named.display()
+ declared.shown()
),
Source::Given(_) => "the report files given don't exist".to_string(),
Source::Outcomes => format!("{} read no outcome", collector.name),
@@ -245,18 +287,21 @@ impl From for NotRan {
/// there) and filtered by modification time when it's read. The config file the command reads is written
/// fresh before it starts (ADR 0348 D2). A captured standard output still reaches the chosen output as it's
/// produced, and is also written to `capture`. Every file it removes, creates or writes is a held one, and the
-/// report, the capture and the config are names the run owns: a link at one is replaced, never followed.
+/// report, the capture and the config are names the run owns: a link at one is replaced, never followed. A report
+/// glob's files are the tool's: nothing is removed or created for them, and the command is told its base directory,
+/// never in `SPECFORGE_REPORT` (ADR 0389).
fn run_command(
machine: &dyn CollectorMachine,
root: &Path,
- (report, report_in_env): (&Held, bool),
- capture: Option<&Held>,
+ (declared, told_nothing): (&Declared, bool),
config: Option<&ConfigFile>,
argv: &[String],
output: RunnerOutput,
) -> Result {
+ let (report, capture) = (&declared.report, declared.capture.as_ref());
+ let owned = declared.glob.is_none();
// The report's name is the run's (ADR 0171): a file or a link at it is unlinked, never what a link names.
- if !report.real.is_dir() {
+ if owned && !report.real.is_dir() {
match report.remove() {
Err(e) if e.kind() != std::io::ErrorKind::NotFound => {
return Err(format!("{}: {e}", report.named.display()).into());
@@ -264,7 +309,9 @@ fn run_command(
_ => {}
}
}
- for file in std::iter::once(report)
+ for file in owned
+ .then_some(report)
+ .into_iter()
.chain(capture)
.chain(config.map(|config| &config.held))
{
@@ -287,7 +334,7 @@ fn run_command(
argv,
dir: root,
report: &report.at,
- report_in_env,
+ report_in_env: owned && told_nothing,
output,
};
machine
diff --git a/crates/app/ops/src/analysis/collect/mod.rs b/crates/app/ops/src/analysis/collect/mod.rs
index b3860cd28e..3ca50705ac 100644
--- a/crates/app/ops/src/analysis/collect/mod.rs
+++ b/crates/app/ops/src/analysis/collect/mod.rs
@@ -23,14 +23,15 @@ mod facts;
mod merge;
mod order;
mod process;
+mod warnings;
pub use crate::machine::{
CollectorCommand, CollectorMachine, REPORT_ENV, Ran, RunFailure, RunnerOutput,
};
use collector::detect;
-pub use collector::{Collector, collectors, uses_here};
-pub use dispatch::dispatch;
+pub use collector::{Collector, collectors, detected_here, uses_here};
use dispatch::dispatch_over;
+pub use dispatch::{REPORT_BYTES_MAX, dispatch};
use evidence::{Evidence, Source};
pub use merge::MergeStats;
use merge::{KnownEntities, merge};
@@ -298,13 +299,23 @@ pub fn collect(
let mut served = order::Served::new(root, containment, &available);
// The syntax cache writes that failed over every collector, and the first one's error: W200 once.
let (mut unwritten, mut unwritable) = (0, None);
+ // A report glob is listed by the walk `Input::files` globs take (ADR 0389), over the plain disk.
+ let project = view.env().file_source(&specforge_registry::PlainDisk);
for (collector, source) in planned {
let Evidence {
files,
stdout,
exit_code,
ran,
- } = match source.gather(collector, root, containment, machine, &mut *announce) {
+ unread,
+ } = match source.gather(
+ collector,
+ root,
+ containment,
+ &project,
+ machine,
+ &mut *announce,
+ ) {
Ok(evidence) => evidence,
// Detection chose it, so the project did not ask for it: no evidence skips it (ADR 0331).
Err(error) if chosen == Chosen::Detected && error.code == codes::E045.id() => {
@@ -313,6 +324,7 @@ pub fn collect(
}
Err(error) => return Err(error.into()),
};
+ diagnostics.extend(warnings::unread(collector, &unread));
let lent = crate::extension::lend::port_call(
view,
@@ -339,6 +351,7 @@ pub fn collect(
}
failed
})?;
+ diagnostics.extend(warnings::warned(collector, &collected.warnings));
let mut syntax = None;
if let Some(lent) = lent {
diagnostics.extend(lent.take_denials());
diff --git a/crates/app/ops/src/analysis/collect/tests.rs b/crates/app/ops/src/analysis/collect/tests.rs
index 39ca9e6be5..fc5c043520 100644
--- a/crates/app/ops/src/analysis/collect/tests.rs
+++ b/crates/app/ops/src/analysis/collect/tests.rs
@@ -25,6 +25,7 @@ fn collector(report: &str) -> Collector {
config: None,
filter: Vec::new(),
install: None,
+ requires: Vec::new(),
}
}
@@ -99,6 +100,7 @@ fn collected(entries: &[(&str, &str, TestStatus)]) -> CollectOutput {
unlinked: Vec::new(),
plan: None,
facts: Vec::new(),
+ warnings: Vec::new(),
}
}
diff --git a/crates/app/ops/src/analysis/collect/warnings.rs b/crates/app/ops/src/analysis/collect/warnings.rs
new file mode 100644
index 0000000000..03be3ab3f3
--- /dev/null
+++ b/crates/app/ops/src/analysis/collect/warnings.rs
@@ -0,0 +1,76 @@
+//! A collector's warnings (ADR 0389): the lines its export returns about what it read but could not use, each one
+//! W203 naming the collector, escaped, at most [`WARNINGS_SHOWN`] of them and then one counting the rest; and the host's
+//! own W203 naming the report glob matches it did not read.
+
+use super::Collector;
+use specforge_common::remedy::printable;
+use specforge_common::{Diagnostic, codes};
+
+/// The most W203 lines one collector reports before one more counts the rest.
+const WARNINGS_SHOWN: usize = 100;
+
+/// W203 for each of `collector`'s warning `lines`, up to [`WARNINGS_SHOWN`], then one counting the lines not shown.
+pub(super) fn warned(collector: &Collector, lines: &[String]) -> Vec {
+ let mut warned: Vec = lines
+ .iter()
+ .take(WARNINGS_SHOWN)
+ .map(|line| {
+ Diagnostic::new(
+ codes::W203,
+ format!(
+ "collector '{}' of {} warns: {}",
+ collector.name,
+ collector.extension,
+ printable(line)
+ ),
+ )
+ })
+ .collect();
+ if let Some(more) = lines.len().checked_sub(WARNINGS_SHOWN).filter(|n| *n > 0) {
+ warned.push(Diagnostic::new(
+ codes::W203,
+ format!(
+ "collector '{}' of {} returned {more} more warnings, not shown",
+ collector.name, collector.extension
+ ),
+ ));
+ }
+ warned
+}
+
+/// The most report glob matches one W203 names before it counts the rest.
+const UNREAD_SHOWN: usize = 5;
+
+/// One W203 naming the report glob matches of `collector` that land outside the project and were not read (ADR 0389
+/// D6): the first [`UNREAD_SHOWN`], then how many more; none when every match was read.
+pub(super) fn unread(collector: &Collector, paths: &[String]) -> Option {
+ (!paths.is_empty()).then(|| {
+ Diagnostic::new(
+ codes::W203,
+ format!(
+ "collector '{}' of {}: {}",
+ collector.name,
+ collector.extension,
+ unread_paths(paths)
+ ),
+ )
+ })
+}
+
+/// ` report glob match(es) land outside ...: ` and the first [`UNREAD_SHOWN`] of `paths`, escaped, then how many
+/// more: what the W203 says, and what E045 adds when no other match was read.
+pub(super) fn unread_paths(paths: &[String]) -> String {
+ let mut named: Vec = paths
+ .iter()
+ .take(UNREAD_SHOWN)
+ .map(|path| printable(path).into_owned())
+ .collect();
+ if paths.len() > UNREAD_SHOWN {
+ named.push(format!("and {} more", paths.len() - UNREAD_SHOWN));
+ }
+ format!(
+ "{} report glob match(es) land outside the project through a link, so they were not read: {}",
+ paths.len(),
+ named.join(", ")
+ )
+}
diff --git a/crates/app/ops/src/analysis/doctor.rs b/crates/app/ops/src/analysis/doctor.rs
index e343c1df90..b9ee6f55fb 100644
--- a/crates/app/ops/src/analysis/doctor.rs
+++ b/crates/app/ops/src/analysis/doctor.rs
@@ -205,6 +205,13 @@ pub enum About {
/// The SMT solver `specforge analyze --prove` asks does not run here: the
/// W098 it reports.
Toolchain,
+ /// A program a collector detected here runs that this machine lacks (`tool_missing`, ADR 0389 D3): the
+ /// collectors it stops and the codes no collector can then judge.
+ Tools {
+ program: String,
+ collectors: Vec,
+ codes: Vec,
+ },
/// What the extensions may make the host do here (ADR 0335 D2): the consent store cannot be used (W186), or
/// a run here uses effects this machine has not approved (W170).
Grants,
@@ -234,6 +241,7 @@ pub enum Part {
Conflict,
Shadowing,
Toolchain,
+ Tools,
Grants,
Host,
}
@@ -256,6 +264,7 @@ impl About {
About::Conflict { .. } => Part::Conflict,
About::Shadowing { .. } => Part::Shadowing,
About::Toolchain => Part::Toolchain,
+ About::Tools { .. } => Part::Tools,
About::Grants => Part::Grants,
About::Host { .. } => Part::Host,
}
@@ -365,6 +374,17 @@ impl DoctorReport {
self
}
+ /// This report with one info finding per program a collector detected here runs that `process` does not find
+ /// (ADR 0389 D3): never a failure. A view without a root adds nothing.
+ pub fn with_tools(
+ mut self,
+ view: &ProjectView,
+ process: &dyn specforge_effects::Process,
+ ) -> Self {
+ self.findings.extend(tools::probe(view, process));
+ self
+ }
+
/// The one document both surfaces return: `{ok, extensions_ok,
/// cache_status, installed_count, z3_available, extensions,
/// enhancements, conflicts: [message…], findings: [...]}`.
@@ -637,3 +657,4 @@ fn remediation(diag: &Diagnostic, codes: &Codebook, fallback: impl FnOnce() -> S
pub mod on_path;
#[cfg(test)]
mod tests;
+mod tools;
diff --git a/crates/app/ops/src/analysis/doctor/tools.rs b/crates/app/ops/src/analysis/doctor/tools.rs
new file mode 100644
index 0000000000..c2dbf5577b
--- /dev/null
+++ b/crates/app/ops/src/analysis/doctor/tools.rs
@@ -0,0 +1,249 @@
+//! The programs the collectors detected here run (ADR 0389 D3): its argv's first, or the `npx` or `node` script it
+//! names, and each program it `requires`. `specforge doctor` asks the process port's `which` for each (an `npx`
+//! program also in the `node_modules/.bin` of the root and of each npm workspace package inside the project, never
+//! above the root) and says, once per program it does not find, which collectors that stops and which codes no collector can
+//! then judge, derived from each collector's `answers` and each code's `facts` in the code book: a code that judges a
+//! kind a runnable collector still answers is not named. An info note, never a failure; a program that is found says
+//! nothing. Nothing is run.
+
+use std::collections::{BTreeMap, BTreeSet};
+use std::path::Path;
+
+use specforge_common::remedy::printable;
+use specforge_effects::Process;
+use specforge_protocol_types::{is_install_line, is_program_name, is_wild};
+
+use super::{About, Finding, FindingStatus};
+use crate::Containment;
+use crate::analysis::collect::detected_here;
+use crate::view::ProjectView;
+
+/// The finding code of a program a detected collector runs that this machine lacks.
+const TOOL_MISSING: &str = "tool_missing";
+
+/// What one missing program stops.
+#[derive(Default)]
+struct Missing {
+ collectors: BTreeSet,
+ /// The kinds its collectors answer.
+ kinds: Vec,
+ installs: Vec,
+}
+
+/// One info finding per program a collector detected in `view`'s project runs that `process` does not find. The codes
+/// it names are the ones that judge a kind its collectors answer and no kind a runnable detected collector answers (one
+/// whose program is found, or that runs none): another collector still answering a kind keeps its codes judged.
+pub(super) fn probe(view: &ProjectView, process: &dyn Process) -> Vec {
+ let Some(root) = view.root() else {
+ return Vec::new();
+ };
+ let git = view.env().git();
+ let codes = view.registries().codes();
+ let lookup = Lookup {
+ root,
+ containment: view.containment(),
+ process,
+ bin_dirs: bin_dirs(root, view.containment()),
+ };
+ let mut missing: BTreeMap = BTreeMap::new();
+ let mut answered: Vec = Vec::new();
+ for collector in detected_here(view.registries().declarations(), root, git.as_deref()) {
+ let lacking: Vec = lookup
+ .program(&collector.run)
+ .into_iter()
+ .chain(lookup.required(&collector.requires))
+ .collect();
+ if lacking.is_empty() {
+ answered.extend(collector.answers);
+ continue;
+ }
+ for program in lacking {
+ let entry = missing.entry(printable(&program).into_owned()).or_default();
+ entry.collectors.insert(format!(
+ "{} ({})",
+ printable(&collector.name),
+ printable(&collector.extension)
+ ));
+ entry.kinds.extend(collector.answers.iter().cloned());
+ if let Some(line) = collector.install.as_deref().filter(|l| is_install_line(l)) {
+ let line = printable(line).into_owned();
+ if !entry.installs.contains(&line) {
+ entry.installs.push(line);
+ }
+ }
+ }
+ }
+ missing
+ .into_iter()
+ .map(|(program, m)| {
+ let off = codes.switched_off(&m.kinds, &answered);
+ finding(program, m, off)
+ })
+ .collect()
+}
+
+/// Where doctor looks a program up: PATH through the process port, and files under the project root, held by its
+/// containment (a link out of the project reads as absent). It reads nothing above the root and runs nothing.
+struct Lookup<'a> {
+ root: &'a Path,
+ containment: &'a Containment,
+ process: &'a dyn Process,
+ /// The project-relative directories whose `node_modules/.bin` an `npx` program may be in ([`bin_dirs`]).
+ bin_dirs: Vec,
+}
+
+impl Lookup<'_> {
+ fn found(&self, program: &str) -> bool {
+ self.process.which(program).is_some()
+ }
+
+ /// Whether the declared relative path `relative` is a file under the root.
+ fn under_root(&self, relative: &str) -> bool {
+ crate::containment::declared(Path::new(relative)).is_some_and(|p| {
+ self.containment
+ .resolve(&self.root.join(p))
+ .is_ok_and(|held| held.real.is_file())
+ })
+ }
+
+ /// The program `run` needs that this machine lacks; none when it has it, or `run` is empty (ADR 0389 D3). `npx
+ /// -- ` needs ``, in a `node_modules/.bin` of [`Lookup::bin_dirs`] or on PATH; `node
+ /// node_modules//...` needs `node` and that script under the root, else names the package; anything else
+ /// needs its first item on PATH.
+ fn program(&self, run: &[String]) -> Option {
+ let first = run.first()?;
+ match first.as_str() {
+ "npx" => {
+ if let Some(bin) = run.iter().skip_while(|arg| *arg != "--").nth(1) {
+ let local = |name: &str| {
+ self.bin_dirs
+ .iter()
+ .any(|dir| self.under_root(&format!("{dir}node_modules/.bin/{name}")))
+ };
+ let present = local(bin) || local(&format!("{bin}.cmd")) || self.found(bin);
+ return (!present).then(|| bin.clone());
+ }
+ }
+ "node" => {
+ if !self.found("node") {
+ return Some("node".into());
+ }
+ let script = run[1..]
+ .iter()
+ .find(|arg| arg.starts_with("node_modules/"))?;
+ if self.under_root(script) {
+ return None;
+ }
+ if crate::containment::declared(Path::new(script)).is_none() {
+ return Some(script.clone());
+ }
+ // The package directory: `jest`, or a scoped `@acme/tool`.
+ let mut segments = script["node_modules/".len()..].split('/');
+ let package = match segments.next() {
+ Some(scope) if scope.starts_with('@') => {
+ format!("{scope}/{}", segments.next().unwrap_or_default())
+ }
+ name => name.unwrap_or_default().to_string(),
+ };
+ return Some(package);
+ }
+ _ => {}
+ }
+ (!self.found(first)).then(|| first.clone())
+ }
+
+ /// The programs of a collector's `requires` that PATH lacks; a name that is no bare program name is W021's and
+ /// never looked up.
+ fn required(&self, requires: &[String]) -> Vec {
+ requires
+ .iter()
+ .filter(|program| is_program_name(program) && !self.found(program))
+ .cloned()
+ .collect()
+ }
+}
+
+/// The project-relative directories, each ending `/` (the root `""`), whose `node_modules/.bin` may hold an `npx`
+/// program: the root, then each npm workspace package directory the root `package.json` names (`workspaces`, a list or
+/// `{"packages": [...]}`), inside the project. shortcut: a pattern is a literal directory or one ending `/*` (every
+/// directory directly under it); `**` and inner wildcards are not expanded, upgrade when a monorepo needs them.
+fn bin_dirs(root: &Path, containment: &Containment) -> Vec {
+ let mut dirs = vec![String::new()];
+ let Ok((_, bytes)) = containment.read(&root.join("package.json")) else {
+ return dirs;
+ };
+ let Ok(manifest) = serde_json::from_slice::(&bytes) else {
+ return dirs;
+ };
+ let workspaces = manifest.get("workspaces");
+ let patterns = workspaces
+ .and_then(serde_json::Value::as_array)
+ .or_else(|| workspaces?.get("packages")?.as_array());
+ let inside = |dir: &str| {
+ !dir.split('/').any(is_wild)
+ && crate::containment::declared(Path::new(dir)).is_some()
+ && containment
+ .resolve(&root.join(dir))
+ .is_ok_and(|held| held.real.is_dir())
+ };
+ for pattern in patterns
+ .into_iter()
+ .flatten()
+ .filter_map(serde_json::Value::as_str)
+ {
+ let pattern = pattern
+ .strip_prefix("./")
+ .unwrap_or(pattern)
+ .trim_end_matches('/');
+ match pattern.strip_suffix("/*") {
+ Some(parent) if inside(parent) => {
+ let mut names: Vec = std::fs::read_dir(root.join(parent))
+ .into_iter()
+ .flatten()
+ .flatten()
+ .filter_map(|entry| entry.file_name().into_string().ok())
+ .filter(|name| inside(&format!("{parent}/{name}")))
+ .collect();
+ names.sort();
+ dirs.extend(names.into_iter().map(|name| format!("{parent}/{name}/")));
+ }
+ None if inside(pattern) => dirs.push(format!("{pattern}/")),
+ _ => {}
+ }
+ }
+ dirs
+}
+
+/// The finding about `program`, missing, which switches off `codes`.
+fn finding(program: String, missing: Missing, codes: Vec) -> Finding {
+ let collectors: Vec = missing.collectors.into_iter().collect();
+ let mut check = format!(
+ "`{program}` is not found here, so collector {} cannot run",
+ collectors.join(", ")
+ );
+ if !codes.is_empty() {
+ check.push_str(&format!(
+ "; no collector that runs here answers what {} judge, so they are not judged here",
+ codes.join(", ")
+ ));
+ }
+ let remediation = if missing.installs.is_empty() {
+ format!("install `{program}` and put it on PATH")
+ } else {
+ missing.installs.join("; ")
+ };
+ Finding {
+ about: About::Tools {
+ program,
+ collectors,
+ codes,
+ },
+ check,
+ status: FindingStatus::Info,
+ code: TOOL_MISSING.into(),
+ remediation,
+ }
+}
+
+#[cfg(test)]
+mod tests;
diff --git a/crates/app/ops/src/analysis/doctor/tools/tests.rs b/crates/app/ops/src/analysis/doctor/tools/tests.rs
new file mode 100644
index 0000000000..5928b57cbe
--- /dev/null
+++ b/crates/app/ops/src/analysis/doctor/tools/tests.rs
@@ -0,0 +1,486 @@
+use super::*;
+use crate::analysis::doctor::{DoctorReport, Part, diagnose};
+use crate::testing::{ScriptedSolver, Viewed};
+use specforge_effects::testing::FakeProcess;
+use specforge_extension_sdk::{ContributionsBuilder, ExtensionMeta};
+use specforge_project::testing::Assembled;
+use specforge_protocol_types::ExtensionDeclaration;
+use specforge_test_macros::test as specforge_test;
+
+/// `extension` with one collector `name` detected on `Cargo.toml`, running `run`, answering `answers`.
+fn runner(
+ extension: &str,
+ name: &str,
+ run: &[&str],
+ answers: &[&str],
+ install: Option<&str>,
+) -> ExtensionDeclaration {
+ let mut c = ContributionsBuilder::new(ExtensionMeta::new(extension, "1.0.0"));
+ c.collector(name, |collector| {
+ collector
+ .detect_files(&["Cargo.toml"])
+ .run(run)
+ .answers(answers);
+ if let Some(line) = install {
+ collector.install(line);
+ }
+ // `{config}` in an argv is sound only beside the config file it names.
+ if run.iter().any(|arg| arg.contains("{config}")) {
+ collector.config("jest.json", "{\"output\": \"{report}\"}");
+ }
+ collector.collect(|_| Ok(Default::default()));
+ });
+ c.declaration()
+}
+
+/// `@acme/core`, cataloguing codes judging collected kinds: W104 coverage, W108 proof.
+fn judge() -> ExtensionDeclaration {
+ let mut c = ContributionsBuilder::new(ExtensionMeta::new("@acme/core", "1.0.0"));
+ c.code("W104", |d| {
+ d.title("Coverage on no item")
+ .explanation("Serve the item.")
+ .facts(&["coverage"]);
+ });
+ c.code("W108", |d| {
+ d.title("Proof on no item")
+ .explanation("Serve the item.")
+ .facts(&["proof"]);
+ });
+ c.declaration()
+}
+
+fn cov() -> ExtensionDeclaration {
+ runner(
+ "@acme/cov",
+ "cov",
+ &["cargo-llvm-cov", "llvm-cov"],
+ &["coverage"],
+ Some("cargo install cargo-llvm-cov --locked"),
+ )
+}
+
+/// The report of a project loading `declarations` and holding the empty `files`, diagnosed under `process`.
+fn diagnosed(
+ declarations: Vec,
+ files: &[&str],
+ process: &FakeProcess,
+) -> DoctorReport {
+ let fixture = Assembled::new().declarations(declarations);
+ for file in files {
+ fixture.write(file, "");
+ }
+ let view = fixture.view();
+ diagnose(&view, &ScriptedSolver::ready()).with_tools(&view, process)
+}
+
+fn tools(report: &DoctorReport) -> Vec<&Finding> {
+ report.about(Part::Tools).collect()
+}
+
+/// The missing programs `run`, by `@x/run`'s one collector, gives in a project holding `Cargo.toml` and `files`.
+fn missing(run: &[&str], files: &[&str], process: &FakeProcess) -> Vec {
+ let mut held = vec!["Cargo.toml"];
+ held.extend(files);
+ let report = diagnosed(
+ vec![runner("@x/run", "run", run, &[], None)],
+ &held,
+ process,
+ );
+ tools(&report)
+ .iter()
+ .map(|f| match &f.about {
+ About::Tools { program, .. } => program.clone(),
+ other => panic!("{other:?}"),
+ })
+ .collect()
+}
+
+const API_EXTRACTOR: &[&str] = &["npx", "--no", "--", "api-extractor", "run"];
+
+#[specforge_test(requirement = "FEATURE-021")]
+fn npx_names_the_program_after_its_double_dash() {
+ assert_eq!(
+ missing(API_EXTRACTOR, &[], &FakeProcess::new()),
+ ["api-extractor"]
+ );
+ let npx_only = FakeProcess::new().on_path("npx", "/usr/bin/npx");
+ assert_eq!(
+ missing(API_EXTRACTOR, &[], &npx_only),
+ ["api-extractor"],
+ "npx on PATH says nothing of the program it would run"
+ );
+}
+
+#[specforge_test(requirement = "FEATURE-021")]
+fn an_npx_program_in_node_modules_bin_or_on_path_is_present() {
+ for bin in [
+ "node_modules/.bin/api-extractor",
+ "node_modules/.bin/api-extractor.cmd",
+ ] {
+ assert!(
+ missing(API_EXTRACTOR, &[bin], &FakeProcess::new()).is_empty(),
+ "{bin}"
+ );
+ }
+ let on_path = FakeProcess::new().on_path("api-extractor", "/usr/bin/api-extractor");
+ assert!(missing(API_EXTRACTOR, &[], &on_path).is_empty());
+}
+
+/// The missing programs of `API_EXTRACTOR` in a project holding `Cargo.toml` and `files` with their contents.
+fn missing_among(files: &[(&str, &str)]) -> Vec {
+ let fixture =
+ Assembled::new().declarations(vec![runner("@x/run", "run", API_EXTRACTOR, &[], None)]);
+ fixture.write("Cargo.toml", "");
+ for (file, contents) in files {
+ fixture.write(file, contents);
+ }
+ let view = fixture.view();
+ let report = diagnose(&view, &ScriptedSolver::ready()).with_tools(&view, &FakeProcess::new());
+ tools(&report)
+ .iter()
+ .map(|f| match &f.about {
+ About::Tools { program, .. } => program.clone(),
+ other => panic!("{other:?}"),
+ })
+ .collect()
+}
+
+#[specforge_test(requirement = "FEATURE-021")]
+fn an_npx_program_in_a_workspace_packages_node_modules_bin_is_present() {
+ let bin = "node_modules/.bin/api-extractor";
+ for (manifest, dir) in [
+ (r#"{"workspaces": ["packages/*"]}"#, "packages/a/"),
+ (r#"{"workspaces": ["./tools/lint/"]}"#, "tools/lint/"),
+ (r#"{"workspaces": {"packages": ["apps/*"]}}"#, "apps/web/"),
+ ] {
+ let at = format!("{dir}{bin}");
+ assert!(
+ missing_among(&[("package.json", manifest), (&at, "")]).is_empty(),
+ "{manifest} {at}"
+ );
+ }
+ // A package the workspaces do not name, a pattern leaving the root, or a deeper glob is not looked in.
+ for (manifest, dir) in [
+ (r#"{"workspaces": ["packages/*"]}"#, "other/a/"),
+ (r#"{"workspaces": ["../beside"]}"#, "beside/"),
+ (r#"{"workspaces": ["packages/**"]}"#, "packages/a/"),
+ ] {
+ let at = format!("{dir}{bin}");
+ assert_eq!(
+ missing_among(&[("package.json", manifest), (&at, "")]),
+ ["api-extractor"],
+ "{manifest} {at}"
+ );
+ }
+}
+
+/// `@x/cov`, running `cargo-llvm-cov llvm-cov nextest` and so requiring `cargo-nextest`, answering coverage.
+fn cov_with_nextest() -> ExtensionDeclaration {
+ let mut c = ContributionsBuilder::new(ExtensionMeta::new("@x/cov", "1.0.0"));
+ c.collector("cov", |k| {
+ k.detect_files(&["Cargo.toml"])
+ .run(&["cargo-llvm-cov", "llvm-cov", "nextest"])
+ .requires(&["cargo-nextest"])
+ .install("cargo install cargo-llvm-cov cargo-nextest --locked")
+ .answers(&["coverage"])
+ .collect(|_| Ok(Default::default()));
+ });
+ c.declaration()
+}
+
+#[specforge_test(requirement = "FEATURE-021")]
+fn a_required_program_missing_is_its_own_finding_with_the_collectors_install_line() {
+ let llvm_cov = FakeProcess::new().on_path("cargo-llvm-cov", "/usr/bin/cargo-llvm-cov");
+
+ let report = diagnosed(
+ vec![cov_with_nextest(), judge()],
+ &["Cargo.toml"],
+ &llvm_cov,
+ );
+
+ let found = tools(&report);
+ assert_eq!(found.len(), 1, "{found:?}");
+ assert_eq!(
+ found[0].about,
+ About::Tools {
+ program: "cargo-nextest".into(),
+ collectors: vec!["cov (@x/cov)".into()],
+ codes: vec!["acme/W104".into()],
+ }
+ );
+ assert_eq!(
+ found[0].remediation,
+ "cargo install cargo-llvm-cov cargo-nextest --locked"
+ );
+
+ let both = llvm_cov.on_path("cargo-nextest", "/usr/bin/cargo-nextest");
+ let report = diagnosed(vec![cov_with_nextest(), judge()], &["Cargo.toml"], &both);
+ assert!(tools(&report).is_empty(), "{:?}", tools(&report));
+}
+
+const JEST: &[&str] = &[
+ "node",
+ "--env-file={config}",
+ "node_modules/jest/bin/jest.js",
+];
+
+#[specforge_test(requirement = "FEATURE-021")]
+fn a_node_script_missing_from_node_modules_names_its_package() {
+ let node = FakeProcess::new().on_path("node", "/usr/bin/node");
+ assert_eq!(missing(JEST, &[], &node), ["jest"]);
+ assert!(missing(JEST, &["node_modules/jest/bin/jest.js"], &node).is_empty());
+ let scoped = &["node", "node_modules/@acme/tool/cli.js"];
+ assert_eq!(missing(scoped, &[], &node), ["@acme/tool"]);
+}
+
+#[specforge_test(requirement = "FEATURE-021")]
+fn without_node_the_program_is_node() {
+ assert_eq!(
+ missing(
+ JEST,
+ &["node_modules/jest/bin/jest.js"],
+ &FakeProcess::new()
+ ),
+ ["node"]
+ );
+}
+
+#[specforge_test(requirement = "FEATURE-021")]
+fn a_script_path_leaving_the_root_is_never_probed_and_reads_as_missing() {
+ let node = FakeProcess::new().on_path("node", "/usr/bin/node");
+ let escaping = &["node", "node_modules/../../x.js"];
+
+ assert_eq!(missing(escaping, &[], &node), ["node_modules/../../x.js"]);
+}
+
+#[specforge_test(requirement = "FEATURE-021")]
+fn collectors_sharing_a_missing_program_give_one_finding_with_the_union_of_codes() {
+ let a = runner("@x/a", "a", &["cargo-kani"], &["proof"], None);
+ let b = runner("@x/b", "b", &["cargo-kani"], &["coverage"], None);
+
+ let report = diagnosed(vec![b, a, judge()], &["Cargo.toml"], &FakeProcess::new());
+
+ let found = tools(&report);
+ assert_eq!(found.len(), 1, "{found:?}");
+ assert_eq!(
+ found[0].about,
+ About::Tools {
+ program: "cargo-kani".into(),
+ collectors: vec!["a (@x/a)".into(), "b (@x/b)".into()],
+ codes: vec!["acme/W104".into(), "acme/W108".into()],
+ }
+ );
+ assert_eq!(
+ found[0].remediation,
+ "install `cargo-kani` and put it on PATH"
+ );
+}
+
+/// The codes of the one tools finding of `report`.
+fn codes_of(report: &DoctorReport) -> Vec {
+ let found = tools(report);
+ let [finding] = &found[..] else {
+ panic!("one finding: {found:?}");
+ };
+ let About::Tools { codes, .. } = &finding.about else {
+ panic!("{:?}", finding.about);
+ };
+ codes.clone()
+}
+
+#[specforge_test(requirement = "FEATURE-021")]
+fn a_kind_a_present_collector_still_answers_keeps_its_codes_judged() {
+ // c8 still answers coverage, so losing cargo-llvm-cov switches no code off.
+ let c8 = runner(
+ "@acme/jscov",
+ "jscov",
+ &["npx", "--no", "--", "c8"],
+ &["coverage"],
+ None,
+ );
+ let process = FakeProcess::new().on_path("c8", "/usr/bin/c8");
+
+ let report = diagnosed(vec![cov(), c8, judge()], &["Cargo.toml"], &process);
+
+ assert_eq!(codes_of(&report), Vec::::new());
+ let check = &tools(&report)[0].check;
+ assert!(check.contains("`cargo-llvm-cov`"), "{check}");
+ assert!(!check.contains("not judged"), "{check}");
+}
+
+#[specforge_test(requirement = "FEATURE-021")]
+fn a_code_judging_a_kind_still_answered_is_not_named() {
+ let mut c = ContributionsBuilder::new(ExtensionMeta::new("@acme/core", "1.0.0"));
+ c.code("W104", |d| {
+ d.title("Coverage on no item")
+ .explanation("Serve the item.")
+ .facts(&["coverage"]);
+ });
+ c.code("E101", |d| {
+ d.title("Fact on no item")
+ .explanation("Serve the item.")
+ .facts(&["coverage", "item"]);
+ });
+ // A source reader that runs no program still answers item.
+ c.collector("items", |k| {
+ k.detect_files(&["Cargo.toml"])
+ .answers(&["item"])
+ .collect(|_| Ok(Default::default()));
+ });
+
+ let report = diagnosed(
+ vec![cov(), c.declaration()],
+ &["Cargo.toml"],
+ &FakeProcess::new(),
+ );
+
+ assert_eq!(codes_of(&report), ["acme/W104"]);
+ assert!(
+ tools(&report)[0].check.contains("acme/W104"),
+ "{}",
+ tools(&report)[0].check
+ );
+}
+
+#[specforge_test(requirement = "FEATURE-021")]
+fn a_missing_program_whose_kinds_no_code_judges_still_gets_a_finding() {
+ let deps = runner("@x/deps", "deps", &["osv-scanner"], &["dependency"], None);
+
+ let report = diagnosed(vec![deps, judge()], &["Cargo.toml"], &FakeProcess::new());
+
+ let found = tools(&report);
+ assert_eq!(found.len(), 1, "{found:?}");
+ let About::Tools { codes, .. } = &found[0].about else {
+ panic!("{:?}", found[0].about);
+ };
+ assert!(codes.is_empty(), "{codes:?}");
+ assert!(!found[0].check.contains("not judged"), "{}", found[0].check);
+}
+
+#[specforge_test(requirement = "FEATURE-021")]
+fn ten_missing_programs_leave_doctor_healthy() {
+ let programs: Vec = (0..10).map(|i| format!("tool-{i}")).collect();
+ let declarations: Vec = programs
+ .iter()
+ .map(|program| runner(&format!("@x/{program}"), program, &[program], &[], None))
+ .collect();
+
+ let report = diagnosed(declarations, &["Cargo.toml"], &FakeProcess::new());
+
+ assert_eq!(tools(&report).len(), 10);
+ assert!(report.ok(), "tool notes never fail doctor");
+ assert_eq!(report.about(Part::Toolchain).count(), 0);
+ assert!(report.z3_available());
+}
+
+#[specforge_test(requirement = "FEATURE-021")]
+fn a_missing_program_is_one_info_finding_naming_its_collectors_and_codes() {
+ let report = diagnosed(vec![cov(), judge()], &["Cargo.toml"], &FakeProcess::new());
+
+ let found = tools(&report);
+ assert_eq!(found.len(), 1, "{found:?}");
+ let finding = found[0];
+ assert_eq!(finding.status, FindingStatus::Info);
+ assert_eq!(finding.code, "tool_missing");
+ let About::Tools {
+ program,
+ collectors,
+ codes,
+ } = &finding.about
+ else {
+ panic!("{:?}", finding.about);
+ };
+ assert_eq!(program, "cargo-llvm-cov");
+ assert_eq!(collectors, &["cov (@acme/cov)"]);
+ assert_eq!(codes, &["acme/W104"]);
+ assert!(
+ finding.check.contains("`cargo-llvm-cov`"),
+ "{}",
+ finding.check
+ );
+ assert!(finding.check.contains(&codes[0]), "{}", finding.check);
+ assert_eq!(finding.remediation, "cargo install cargo-llvm-cov --locked");
+ assert!(report.ok(), "a missing tool never fails doctor");
+ assert!(report.z3_available(), "a tool note is no toolchain finding");
+}
+
+#[specforge_test(requirement = "FEATURE-021")]
+fn a_declaration_string_with_control_characters_is_printed_escaped() {
+ // A third-party declaration whose program sets the terminal's title and writes lines of its own, and whose
+ // install line clears the screen and adds a command on a line of its own (T-11-09).
+ let program = "tool\u{1b}]0;owned\u{7}\nline\r";
+ let install = "cargo install tool\u{1b}[2J\nrm -rf ~\r";
+ let report = diagnosed(
+ vec![
+ runner("@x/run", "run", &[program], &["coverage"], Some(install)),
+ judge(),
+ ],
+ &["Cargo.toml"],
+ &FakeProcess::new(),
+ );
+
+ let found = tools(&report);
+ assert_eq!(found.len(), 1, "{found:?}");
+ let About::Tools {
+ program: named,
+ collectors,
+ codes,
+ } = &found[0].about
+ else {
+ panic!("{:?}", found[0].about);
+ };
+ assert_eq!(named, "tool\\u{1b}]0;owned\\u{7}\\nline\\r");
+ let shown = [
+ named.as_str(),
+ &collectors.join(" "),
+ &codes.join(" "),
+ &found[0].check,
+ &found[0].remediation,
+ ]
+ .join(" ");
+ for raw in ['\u{1b}', '\u{7}', '\n', '\r'] {
+ assert!(!shown.contains(raw), "{raw:?} in {shown:?}");
+ }
+ // The install line is refused, not escaped: the finding names the program instead.
+ assert_eq!(
+ found[0].remediation,
+ format!("install `{named}` and put it on PATH")
+ );
+}
+
+#[specforge_test(requirement = "FEATURE-021")]
+fn a_program_on_path_says_nothing() {
+ let process = FakeProcess::new().on_path("cargo-llvm-cov", "/usr/bin/cargo-llvm-cov");
+
+ let report = diagnosed(vec![cov(), judge()], &["Cargo.toml"], &process);
+
+ assert!(tools(&report).is_empty(), "{:?}", tools(&report));
+ assert!(process.requests().is_empty(), "doctor runs nothing");
+}
+
+#[specforge_test(requirement = "FEATURE-021")]
+fn a_collector_not_detected_here_is_not_probed() {
+ let report = diagnosed(vec![cov(), judge()], &[], &FakeProcess::new());
+
+ assert!(tools(&report).is_empty(), "{:?}", tools(&report));
+}
+
+#[specforge_test(requirement = "FEATURE-021")]
+fn the_document_carries_the_tool_finding_and_its_fields() {
+ let report = diagnosed(vec![cov(), judge()], &["Cargo.toml"], &FakeProcess::new());
+
+ let document = serde_json::to_value(report.document()).unwrap();
+ let finding = document["findings"]
+ .as_array()
+ .unwrap()
+ .iter()
+ .find(|f| f["about"] == "tools")
+ .expect("a tools finding");
+ assert_eq!(finding["program"], "cargo-llvm-cov");
+ assert_eq!(
+ finding["collectors"],
+ serde_json::json!(["cov (@acme/cov)"])
+ );
+ assert_eq!(finding["codes"].as_array().unwrap().len(), 1);
+ assert_eq!(finding["status"], "info");
+}
diff --git a/crates/app/ops/src/authoring/apply/command.rs b/crates/app/ops/src/authoring/apply/command.rs
index 4a110dd364..e319d49b26 100644
--- a/crates/app/ops/src/authoring/apply/command.rs
+++ b/crates/app/ops/src/authoring/apply/command.rs
@@ -133,6 +133,7 @@ pub fn execute_with(
} else {
let origin = Origin::Command {
extension: command.extension().to_string(),
+ imports: command.imports(),
};
match apply_plan_with(view, plan, &origin, dry_run, caller, rules, calendar) {
Ok(edited) if edited.wrote.previewed() => PlanOutcome::Previewed(edited),
diff --git a/crates/app/ops/src/authoring/apply/flags.rs b/crates/app/ops/src/authoring/apply/flags.rs
index 4577d3be1c..507d1117ba 100644
--- a/crates/app/ops/src/authoring/apply/flags.rs
+++ b/crates/app/ops/src/authoring/apply/flags.rs
@@ -777,7 +777,7 @@ fn refuse(
/// Whether `origin` may set a harness value of a field `declaring` declares: a command, collector or hook of that
/// extension, or of one whose handshake names it a peer dependency.
pub(crate) fn may_write_harness(view: &ProjectView<'_>, origin: &Origin, declaring: &str) -> bool {
- let (Origin::Command { extension }
+ let (Origin::Command { extension, .. }
| Origin::Collector { extension }
| Origin::Hook { extension }) = origin
else {
diff --git a/crates/app/ops/src/authoring/apply/mod.rs b/crates/app/ops/src/authoring/apply/mod.rs
index 84d232a220..8c48027cd0 100644
--- a/crates/app/ops/src/authoring/apply/mod.rs
+++ b/crates/app/ops/src/authoring/apply/mod.rs
@@ -23,7 +23,7 @@ pub use collector::apply_collected;
pub use command::{CommandRun, PlanOutcome, execute, execute_with};
pub use judged::HostJudgedRules;
-use crate::authoring::edit::{EditField, Edited, Step, plan_steps};
+use crate::authoring::edit::{EditField, Edited, Lands, Step, plan_steps};
use crate::authoring::planned::PlannedChange;
use crate::view::ProjectView;
use crate::{Caller, OpError, OpErrorKind, Refusal, Writes, Wrote};
@@ -95,8 +95,9 @@ pub enum Surface {
/// Who asked for a write.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Origin {
- /// A command of `extension` answered the plan.
- Command { extension: String },
+ /// A command of `extension` answered the plan. `imports`: the command declares it imports what was recorded
+ /// outside the spec, so its plan is judged for host errors only (ADR 0392).
+ Command { extension: String, imports: bool },
/// A collector of `extension` answered the plan.
Collector { extension: String },
/// A hook of `extension` answered the plan.
@@ -176,8 +177,13 @@ pub fn apply_plan_with(
steps.insert(at + inserted, step);
}
revision::against_compile(view.project(), &lowered.files)?;
- let host_only = matches!(origin, Origin::Collector { .. });
- let planned = plan_steps(view, &steps, host_only)?;
+ // History an extension's rule cannot unmake: a collected fact (ADR 0303) and an import (ADR 0392).
+ let lands = match origin {
+ Origin::Collector { .. } => Lands::Extensions,
+ Origin::Command { imports: true, .. } => Lands::ThirdParty,
+ _ => Lands::Nothing,
+ };
+ let planned = plan_steps(view, &steps, lands)?;
let report = planned.report().clone();
let wrote = Wrote::unless_preview(dry_run, || {
let change = planned.change().clone().serialized();
@@ -194,7 +200,7 @@ pub fn apply_plan_with(
change.apply_checked(caller, || {
revision::against_disk(&sources, caller, &files)?;
verdict::against_disk(project, &verdicts)?;
- rejudge(project, &change, &files, host_only)
+ rejudge(project, &change, &files, lands)
})
})?;
Ok(Edited { report, wrote })
@@ -344,7 +350,7 @@ fn rejudge(
project: &CompiledProject,
change: &PlannedChange,
files: &std::collections::BTreeMap,
- host_only: bool,
+ lands: Lands,
) -> Result<(), OpError> {
let own: BTreeSet = files.keys().cloned().collect();
if !project.sources_moved(&own) {
@@ -360,7 +366,7 @@ fn rejudge(
&after,
project.environment().registries(),
change,
- host_only,
+ lands,
)
.map_err(|refusal| refusal.error)
}
diff --git a/crates/app/ops/src/authoring/apply/verdict.rs b/crates/app/ops/src/authoring/apply/verdict.rs
index 30e0672a0e..e63d5a2403 100644
--- a/crates/app/ops/src/authoring/apply/verdict.rs
+++ b/crates/app/ops/src/authoring/apply/verdict.rs
@@ -251,7 +251,7 @@ pub(crate) fn check(
format!("'{}' is no outcome of the rule '{}'", op.outcome, op.rule),
));
}
- if !matches!(origin, Origin::Command { extension } if *extension == rule.extension) {
+ if !matches!(origin, Origin::Command { extension, .. } if *extension == rule.extension) {
return Err(refused(
op,
"origin",
diff --git a/crates/app/ops/src/authoring/edit/mod.rs b/crates/app/ops/src/authoring/edit/mod.rs
index acc0035950..9c993ca5dd 100644
--- a/crates/app/ops/src/authoring/edit/mod.rs
+++ b/crates/app/ops/src/authoring/edit/mod.rs
@@ -24,6 +24,7 @@ pub use skeleton::{Skeleton, Skeletons, Slot, SlotOf};
use specforge_project::harness::compose;
pub use steps::{Step, plan, plan_steps};
pub use typed::takes_json;
+pub use validate::Lands;
use crate::authoring::format::{Configs, Place};
use crate::authoring::planned::PlannedChange;
diff --git a/crates/app/ops/src/authoring/edit/steps.rs b/crates/app/ops/src/authoring/edit/steps.rs
index 3cd72b81e9..13c5be827f 100644
--- a/crates/app/ops/src/authoring/edit/steps.rs
+++ b/crates/app/ops/src/authoring/edit/steps.rs
@@ -3,6 +3,7 @@
//! that compile and merges its texts, and the edits after it are planned over a compile of the merged texts.
use super::declared::Declared;
+use super::validate::Lands;
use super::{Edit, EditField, EditPlan, EditReport, Planner, describe, validate};
use crate::Refusal;
use crate::authoring::format::{Configs, Forms};
@@ -75,14 +76,14 @@ pub(super) fn relocated(path: &str, moves: &[(String, String)]) -> String {
/// through the view's disk (ADR 0169).
pub fn plan(view: &ProjectView<'_>, edits: &[Edit]) -> Result> {
let steps: Vec = edits.iter().cloned().map(Step::Edit).collect();
- plan_steps(view, &steps, false)
+ plan_steps(view, &steps, Lands::Nothing)
}
-/// [`plan`] over steps, renames among them. `host_only`: an extension's error is no error the plan adds (ADR 0303).
+/// [`plan`] over steps, renames among them. `lands`: the errors the plan may add (ADR 0303, ADR 0392).
pub fn plan_steps(
view: &ProjectView<'_>,
steps: &[Step],
- host_only: bool,
+ lands: Lands,
) -> Result> {
crate::config::refuse_rewrite(view.env().config_problems())?;
view.project_root()?;
@@ -115,7 +116,7 @@ pub fn plan_steps(
})?;
at = end;
}
- conclude(view, carry, host_only)
+ conclude(view, carry, lands)
}
/// A run of edits, planned over the project as the steps before left it; the refusal names the edit's place in the run.
@@ -230,7 +231,7 @@ fn rename_step(
fn conclude(
view: &ProjectView<'_>,
carry: Carry,
- host_only: bool,
+ lands: Lands,
) -> Result> {
let project = view.project();
let Carry {
@@ -275,7 +276,7 @@ fn conclude(
let added = if change.is_empty() {
Vec::new()
} else {
- validate::check(view, &change, &declared, host_only)?
+ validate::check(view, &change, &declared, lands)?
};
let report = EditReport {
entities: change.entities(),
diff --git a/crates/app/ops/src/authoring/edit/validate.rs b/crates/app/ops/src/authoring/edit/validate.rs
index ed78024557..c907ece13e 100644
--- a/crates/app/ops/src/authoring/edit/validate.rs
+++ b/crates/app/ops/src/authoring/edit/validate.rs
@@ -15,7 +15,7 @@ use super::steps::relocated;
use crate::authoring::planned::PlannedChange;
use crate::view::ProjectView;
use crate::{OpError, OpErrorKind, Refusal};
-use specforge_common::{Diagnostic, DiagnosticList, Severity, codes};
+use specforge_common::{Codebook, Diagnostic, DiagnosticList, Severity, codes};
use specforge_diagnostics::CodeRef;
use specforge_graph::{GraphDelta, compute_graph_delta_over};
use specforge_project::CompiledProject;
@@ -127,15 +127,44 @@ fn revealed(
}
}
+/// Which of the errors a plan adds are written rather than refused (E080): the plan records history, which an
+/// extension's rule cannot unmake.
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub enum Lands {
+ /// None: every error the plan adds refuses it (a typed edit; a command's or a hook's plan).
+ Nothing,
+ /// Every extension's error, whatever its code: a collector's plan (ADR 0303).
+ Extensions,
+ /// An extension's rule about authored entities, its own catalogued code (`gsd.security/E101`, `gsd/E312`): an
+ /// importing command's plan (ADR 0392, `Codebook::authored_rule`). Every other error still refuses: the host's
+ /// own, a `@specforge/*` builtin's (the E016 a path's value check reports), and one that judges the records
+ /// against the facts collected from the tree (`code/E101`, a reference naming no collected fact).
+ ThirdParty,
+}
+
+impl Lands {
+ /// Whether `d`, an error the plan adds, is written rather than refused; `codes` is the loaded extensions' catalog.
+ pub(crate) fn lands(self, d: &Diagnostic, codes: &Codebook) -> bool {
+ match self {
+ Lands::Nothing => false,
+ Lands::Extensions => d.origin().is_some(),
+ Lands::ThirdParty => d
+ .origin()
+ .is_some_and(|origin| codes.authored_rule(origin, &d.code)),
+ }
+ }
+}
+
/// The diagnostics of `after` that `before` does not have, one by one: (errors, warnings and infos). A diagnostic
-/// `judged` names is never an error here, whatever its severity. `moved` relocates the subjects of `before`.
-/// `host_only`: an extension's diagnostic is never an error here either (ADR 0303).
+/// `judged` names is never an error here, whatever its severity. `moved` relocates the subjects of `before`. An error
+/// `lands` writes, read against the catalog `codes`, is not one either (ADR 0303, ADR 0392).
pub(crate) fn added(
before: &[Diagnostic],
after: Vec,
judged: impl Fn(&Diagnostic) -> bool,
moved: &Moves,
- host_only: bool,
+ lands: Lands,
+ codes: &Codebook,
) -> (Vec, Vec) {
let mut had: HashMap = HashMap::new();
for d in before {
@@ -149,10 +178,7 @@ pub(crate) fn added(
}
match had.get_mut(&key(&d, &[])) {
Some(n) if *n > 0 => *n -= 1,
- _ if d.severity == Severity::Error
- && !judged(&d)
- && !(host_only && d.origin().is_some()) =>
- {
+ _ if d.severity == Severity::Error && !judged(&d) && !lands.lands(&d, codes) => {
errors.push(d)
}
_ => rest.push(d),
@@ -167,14 +193,15 @@ pub(crate) fn refuse_new_errors(
after: &CompiledProject,
registries: &RegistryBuild,
change: &PlannedChange,
- host_only: bool,
+ lands: Lands,
) -> Result<(), Refusal> {
let (errors, _) = added(
&before.judged_diagnostics(),
after.diagnostics(),
not_added(before, after, Some(change)),
change.moved(),
- host_only,
+ lands,
+ registries.codes(),
);
if errors.is_empty() {
Ok(())
@@ -191,7 +218,7 @@ pub fn check(
view: &ProjectView<'_>,
change: &PlannedChange,
declared: &Declared,
- host_only: bool,
+ lands: Lands,
) -> Result, Refusal> {
let before = view.project().judged_diagnostics();
let texts = change.after();
@@ -205,7 +232,8 @@ pub fn check(
post.diagnostics(),
not_added(view.project(), &post, Some(change)),
change.moved(),
- host_only,
+ lands,
+ view.registries().codes(),
);
if !errors.is_empty() {
return Err(new_errors(errors, view.registries().codes()));
@@ -222,7 +250,7 @@ pub fn check(
Err(undeclared(&beyond))
}
-fn new_errors(errors: Vec, codes: &specforge_common::Codebook) -> Refusal {
+fn new_errors(errors: Vec, codes: &Codebook) -> Refusal {
let mut message = format!(
"the edit would leave the project with {} error{} it does not have; nothing was written",
errors.len(),
@@ -308,7 +336,14 @@ mod tests {
let mut pending = Diagnostic::new(codes::W167, "an interrupted write is pending rollback");
// A preset that raises W167 makes it an error of the edited project.
pending.severity = Severity::Error;
- let (errors, rest) = added(&[], vec![pending], |_| false, &[], false);
+ let (errors, rest) = added(
+ &[],
+ vec![pending],
+ |_| false,
+ &[],
+ Lands::Nothing,
+ &Codebook::default(),
+ );
assert!(errors.is_empty() && rest.is_empty());
}
@@ -326,7 +361,8 @@ mod tests {
vec![error("gsd/E501"), error("gsd/E999")],
judged,
&[],
- false,
+ Lands::Nothing,
+ &Codebook::default(),
);
assert_eq!(errors.len(), 1);
assert_eq!(errors[0].code, "gsd/E999");
@@ -338,7 +374,8 @@ mod tests {
vec![error("gsd/E501")],
judged,
&[],
- false,
+ Lands::Nothing,
+ &Codebook::default(),
);
assert!(errors.is_empty() && rest.is_empty());
}
@@ -372,7 +409,8 @@ mod tests {
vec![finding("v1.0/01/01-01/TR2")],
|_| false,
&[],
- false,
+ Lands::Nothing,
+ &Codebook::default(),
);
assert_eq!(errors.len(), 1);
}
@@ -384,11 +422,30 @@ mod tests {
let moves = [("v1.0/01".to_string(), "v1.0/02".to_string())];
let after = vec![finding("v1.0/02/01-01/TR1")];
assert!(
- added(&before, after.clone(), |_| false, &moves, false)
- .0
- .is_empty()
+ added(
+ &before,
+ after.clone(),
+ |_| false,
+ &moves,
+ Lands::Nothing,
+ &Codebook::default()
+ )
+ .0
+ .is_empty()
+ );
+ assert_eq!(
+ added(
+ &before,
+ after,
+ |_| false,
+ &[],
+ Lands::Nothing,
+ &Codebook::default()
+ )
+ .0
+ .len(),
+ 1
);
- assert_eq!(added(&before, after, |_| false, &[], false).0.len(), 1);
}
fn finding(entity: &str) -> Diagnostic {
@@ -404,13 +461,71 @@ mod tests {
}
#[specforge_test(requirement = "FEATURE-128")]
- fn host_only_ignores_an_extensions_error_and_keeps_a_host_one() {
+ fn a_collectors_plan_lands_an_extensions_error_and_keeps_a_host_one() {
let host = Diagnostic::untyped("E003", Severity::Error, "unresolved");
let ext = finding("v1.0/01/01-01/TR1");
- let (errors, _) = added(&[], vec![host, ext.clone()], |_| false, &[], true);
+ let (errors, _) = added(
+ &[],
+ vec![host, ext.clone()],
+ |_| false,
+ &[],
+ Lands::Extensions,
+ &Codebook::default(),
+ );
assert_eq!(errors.len(), 1);
assert_eq!(errors[0].code, "E003");
- assert_eq!(added(&[], vec![ext], |_| false, &[], false).0.len(), 1);
+ assert_eq!(
+ added(
+ &[],
+ vec![ext],
+ |_| false,
+ &[],
+ Lands::Nothing,
+ &Codebook::default()
+ )
+ .0
+ .len(),
+ 1
+ );
+ }
+
+ #[specforge_test(requirement = "FEATURE-131")]
+ fn an_import_lands_an_authored_rule_error_and_keeps_every_other() {
+ let entry = |local: &str, facts: &[&str]| specforge_diagnostics::ExtensionCode {
+ local: local.into(),
+ title: "t".into(),
+ explanation: "e".into(),
+ docs: None,
+ machine: false,
+ reported_while: None,
+ settled_later: false,
+ facts: facts.iter().map(|kind| kind.to_string()).collect(),
+ };
+ let mut book = Codebook::default();
+ book.add("@gsd/core", vec![entry("E502", &[])]).unwrap();
+ book.add("@code/core", vec![entry("E101", &["test"])])
+ .unwrap();
+ let host = Diagnostic::untyped("E003", Severity::Error, "unresolved");
+ let path = Diagnostic::from_extension("@specforge/checks", "E016", Severity::Error, "gone");
+ // A builtin outside `@specforge/` that judges collected facts: a reference naming no fact refuses (WR-A01).
+ let dangling =
+ Diagnostic::from_extension("@code/core", "code/E101", Severity::Error, "no fact");
+ let uncatalogued =
+ Diagnostic::from_extension("@gsd/core", "gsd/E999", Severity::Error, "not listed");
+ let rule = finding("v1.0/01/01-01/TR1");
+ let (errors, _) = added(
+ &[],
+ vec![host, path.clone(), dangling, uncatalogued, rule.clone()],
+ |_| false,
+ &[],
+ Lands::ThirdParty,
+ &book,
+ );
+ let codes: Vec<&str> = errors.iter().map(|d| d.code.as_str()).collect();
+ assert_eq!(codes, ["E003", "E016", "code/E101", "gsd/E999"]);
+ assert!(Lands::ThirdParty.lands(&rule, &book));
+ // A collector's plan lands the first-party extension's error too (ADR 0303).
+ assert!(Lands::Extensions.lands(&path, &book) && !Lands::ThirdParty.lands(&path, &book));
}
#[specforge_test(requirement = "FEATURE-131")]
diff --git a/crates/app/ops/src/authoring/migrate.rs b/crates/app/ops/src/authoring/migrate.rs
index fc32f0c5c3..b3c04d2bfe 100644
--- a/crates/app/ops/src/authoring/migrate.rs
+++ b/crates/app/ops/src/authoring/migrate.rs
@@ -30,7 +30,7 @@ use specforge_wasm::WasmRuntime;
use std::collections::{BTreeMap, HashMap};
use std::path::Path;
-use crate::authoring::edit::validate::{added, not_added};
+use crate::authoring::edit::validate::{Lands, added, not_added};
use crate::authoring::format::{Configs, Forms, Place};
use crate::change::{ProjectChange, unreadable, unwritable};
use crate::{Caller, Held, OpError, OpErrorKind, ReadFailure, Refusal, Writes, Wrote};
@@ -375,7 +375,8 @@ pub fn judge(
verdict.post_diagnostics.clone(),
judged,
&[],
- false,
+ Lands::Nothing,
+ post.environment().registries().codes(),
)
.0
.len();
diff --git a/crates/app/ops/src/containment/disk.rs b/crates/app/ops/src/containment/disk.rs
index 9a8cda986a..f844c23cad 100644
--- a/crates/app/ops/src/containment/disk.rs
+++ b/crates/app/ops/src/containment/disk.rs
@@ -3,7 +3,7 @@
//! file checked (ADR 0104, ADR 0112 D1).
use std::io;
-use std::path::Path;
+use std::path::{Path, PathBuf};
use specforge_registry::{Disk, PlainDisk};
@@ -40,3 +40,31 @@ impl Disk for ContainedDisk {
}
}
}
+
+/// The plain file system, each file read through one containment: what a declared file read (`Input::files`, ADR 0293)
+/// of a call or an analyze pass reads through. It lists, tells a directory and resolves a link as the plain disk does,
+/// so the shared walk still sees a linked directory and the path check still sees where a link lands; a read is the
+/// containment's, so a bounded one refuses a file with several names (ADR 0146), as a report read does (ADR 0390 D12).
+pub struct FileReadsDisk(pub(crate) ContainedDisk);
+
+impl Disk for FileReadsDisk {
+ fn exists(&self, path: &Path) -> bool {
+ PlainDisk.exists(path)
+ }
+
+ fn list(&self, dir: &Path) -> Option> {
+ PlainDisk.list(dir)
+ }
+
+ fn read(&self, path: &Path) -> io::Result> {
+ self.0.read(path)
+ }
+
+ fn is_dir(&self, path: &Path) -> bool {
+ PlainDisk.is_dir(path)
+ }
+
+ fn canonical(&self, path: &Path) -> Option {
+ PlainDisk.canonical(path)
+ }
+}
diff --git a/crates/app/ops/src/containment/disk_tests.rs b/crates/app/ops/src/containment/disk_tests.rs
index 29e81ecdae..7e558e31ff 100644
--- a/crates/app/ops/src/containment/disk_tests.rs
+++ b/crates/app/ops/src/containment/disk_tests.rs
@@ -79,6 +79,27 @@ fn an_unbounded_containment_reads_a_file_with_two_names() {
assert_eq!(disk.read(&base.join("proj/hard")).unwrap(), b"SECRETWORD");
}
+/// The declared file reads' disk walks as the plain one (it sees where a link lands) and reads as the containment.
+#[test]
+fn the_file_reads_disk_resolves_links_plainly_and_refuses_a_second_name_when_bounded() {
+ let (_dir, base) = scene();
+ let root = base.join("proj");
+ std::fs::write(base.join("outside/secret"), "SECRETWORD").unwrap();
+ std::fs::hard_link(base.join("outside/secret"), root.join("hard")).unwrap();
+ std::os::unix::fs::symlink(base.join("outside"), root.join("away")).unwrap();
+ let disk = Containment::within(&root).file_reads_disk();
+ assert_eq!(
+ disk.canonical(&root.join("away")),
+ Some(base.join("outside"))
+ );
+ assert!(disk.is_dir(&root.join("away")));
+ let error = disk.read(&root.join("hard")).unwrap_err();
+ assert_eq!(error.kind(), std::io::ErrorKind::InvalidInput);
+ assert!(!error.to_string().contains("SECRETWORD"), "{error}");
+ let unbounded = Containment::unbounded().file_reads_disk();
+ assert_eq!(unbounded.read(&root.join("hard")).unwrap(), b"SECRETWORD");
+}
+
#[test]
fn a_directory_is_not_refused_for_its_link_count() {
let (_dir, base) = scene();
diff --git a/crates/app/ops/src/containment/mod.rs b/crates/app/ops/src/containment/mod.rs
index 212b17464b..a4bd1325eb 100644
--- a/crates/app/ops/src/containment/mod.rs
+++ b/crates/app/ops/src/containment/mod.rs
@@ -10,7 +10,7 @@
mod disk;
mod file;
-pub use disk::ContainedDisk;
+pub use disk::{ContainedDisk, FileReadsDisk};
pub use file::{ReadFailure, declared};
use std::collections::BTreeMap;
@@ -92,6 +92,12 @@ impl Containment {
ContainedDisk(self.clone())
}
+ /// The disk a declared file read (`Input::files`) reads through: walked as the plain disk, each file read
+ /// through this containment, so a bounded one refuses a file with several names (ADR 0146).
+ pub fn file_reads_disk(&self) -> FileReadsDisk {
+ FileReadsDisk(self.disk())
+ }
+
/// The same kind of bound for a project inside this one: `within(dir)` when bounded,
/// unbounded when unbounded. A change bounds its writes to its own project (ADR 0092 D8).
pub fn narrowed(&self, dir: &Path) -> Self {
diff --git a/crates/app/ops/src/extension/command.rs b/crates/app/ops/src/extension/command.rs
index 2fec2cd207..861a9dc176 100644
--- a/crates/app/ops/src/extension/command.rs
+++ b/crates/app/ops/src/extension/command.rs
@@ -212,6 +212,11 @@ impl ExtensionCommand {
self.declaration.human
}
+ /// Whether it imports what was recorded outside the spec: its plan is judged for host errors only (ADR 0392).
+ pub fn imports(&self) -> bool {
+ self.declaration.imports
+ }
+
/// The declaring extension's short name, which routes its commands.
pub fn short(&self) -> &str {
&self.short
diff --git a/crates/app/ops/src/extension/inputs.rs b/crates/app/ops/src/extension/inputs.rs
index 8e90c971ca..dafa20781a 100644
--- a/crates/app/ops/src/extension/inputs.rs
+++ b/crates/app/ops/src/extension/inputs.rs
@@ -27,16 +27,18 @@ impl<'v, 'p> Serve<'v, 'p> {
}
}
- /// The facts of each `files` input, by read name. A call runs once: they are read from the plain disk (ADR 0293).
+ /// The facts of each `files` input, by read name. A call runs once: they are read from the plain disk (ADR 0293),
+ /// each file through the view's containment, so a bounded one refuses a hard link (ADR 0146).
pub(crate) fn files(&self) -> FileMap {
let reads = self.inputs.files();
if reads.is_empty() {
return FileMap::default();
}
+ let disk = self.view.containment().file_reads_disk();
specforge_project::file_reads::read(
&reads,
self.view.entities(),
- &self.view.env().file_source(&specforge_registry::PlainDisk),
+ &self.view.env().file_source(&disk),
)
}
diff --git a/crates/app/ops/src/read/explain.rs b/crates/app/ops/src/read/explain.rs
index 103604cd8b..148b34fe91 100644
--- a/crates/app/ops/src/read/explain.rs
+++ b/crates/app/ops/src/read/explain.rs
@@ -138,6 +138,7 @@ mod tests {
machine: false,
reported_while: None,
settled_later: false,
+ facts: Vec::new(),
})
.collect();
book.add(extension, entries).unwrap();
diff --git a/crates/app/ops/tests/javascript_report_packs.rs b/crates/app/ops/tests/javascript_report_packs.rs
new file mode 100644
index 0000000000..5760492535
--- /dev/null
+++ b/crates/app/ops/tests/javascript_report_packs.rs
@@ -0,0 +1,481 @@
+//! The JavaScript report and runner packs end to end (ADR 0389): `@javascript/coverage`, `@javascript/lint`,
+//! `@javascript/deps`, `@javascript/api`, `@javascript/vitest`, `@javascript/jest` and `@javascript/playwright` from
+//! their real blobs collect the fixture workspace `tests/fixtures/javascript-source`, a scripted machine standing in
+//! for each tool, beside the legacy `@specforge/vitest` (owner decision D4). Each report is a short inline text in the
+//! format of its pack's own fixture (the recordings of c8, ESLint's SARIF formatter, cyclonedx-npm, osv-scanner,
+//! api-extractor, vitest, jest-junit and Playwright).
+#![allow(
+ clippy::unwrap_used,
+ reason = "a test's unwrap is its assertion: a None or an Err fails the test"
+)]
+
+use std::sync::Arc;
+use std::time::Duration;
+
+use specforge_effects::testing::MemoryConsent;
+use specforge_effects::{EffectsMode, Ports};
+use specforge_ops::analysis::collect::{Mode, Outcome, Request, RunnerOutput, collect};
+use specforge_ops::asking::Asking;
+use specforge_ops::testing::{ScriptedMachine, ScriptedRun};
+use specforge_ops::{Caller, Containment};
+use specforge_project::testing::TestProject;
+use specforge_protocol_types::Fact;
+
+/// `@javascript/source`, the seven packs, the legacy vitest pack with the peer it requires, and
+/// `@specforge/software`, whose behaviors the fixture's spec declares.
+const PACKS: [&str; 12] = [
+ "@specforge/software",
+ "@code/core",
+ "@javascript/source",
+ "@javascript/coverage",
+ "@javascript/lint",
+ "@javascript/deps",
+ "@javascript/api",
+ "@javascript/vitest",
+ "@javascript/jest",
+ "@javascript/playwright",
+ "@specforge/testing",
+ "@specforge/vitest",
+];
+const FIXTURE: &str = concat!(
+ env!("CARGO_MANIFEST_DIR"),
+ "/tests/fixtures/javascript-source"
+);
+/// The workspace's one test file, in the package `@acme/core`.
+const TEST_FILE: &str = "packages/core/test/board.test.ts";
+
+/// The fixture workspace with the files each pack is detected by, the packs enabled, and `@javascript/source`'s
+/// packages and items collected and stored, as a collect of every detected collector stores them first.
+fn fixture() -> TestProject {
+ let p = TestProject::copy_of(FIXTURE)
+ .files(&[
+ (
+ "package-lock.json",
+ r#"{"name": "app", "lockfileVersion": 3, "packages": {}}"#,
+ ),
+ ("eslint.config.js", "export default [];\n"),
+ ("tsconfig.json", "{}\n"),
+ ("vitest.config.ts", "export default {};\n"),
+ ("jest.config.js", "module.exports = {};\n"),
+ ("playwright.config.ts", "export default {};\n"),
+ ])
+ .enabling(&PACKS);
+ // It runs no command: nothing is scripted.
+ let mut outcome = collected(&p, "javascript-source", &ScriptedMachine::new());
+ let compiled = p.compile();
+ let view = specforge_ops::view::ProjectView::of(&compiled);
+ let dry_run = false;
+ specforge_ops::authoring::apply::apply_collected(
+ &view,
+ Vec::new(),
+ std::mem::take(&mut outcome.facts),
+ dry_run,
+ specforge_ops::testing::caller(),
+ )
+ .unwrap();
+ p
+}
+
+/// A machine whose one run does `run` and exits 0.
+fn machine(run: ScriptedRun) -> ScriptedMachine {
+ ScriptedMachine::new().answering(ScriptedRun {
+ exit_code: Some(0),
+ ..run
+ })
+}
+
+/// A run that writes `report` at the report location.
+fn writing(report: &str) -> ScriptedRun {
+ ScriptedRun {
+ files: vec![("".into(), report.to_string())],
+ ..ScriptedRun::default()
+ }
+}
+
+/// Collect `runner` of `p` through `machine`, everything approved.
+fn collected(p: &TestProject, runner: &str, machine: &ScriptedMachine) -> Outcome {
+ let compiled = p.compile();
+ let view = specforge_ops::view::ProjectView::of(&compiled);
+ // The disk, as the CLI lends it: the syntax import reads through the host's own reader.
+ let ports = Ports {
+ fs: Arc::new(specforge_fs::LocalFs),
+ ..specforge_effects::testing::ports()
+ };
+ let consent = MemoryConsent::approving_everything();
+ let containment = Containment::unbounded();
+ collect(
+ &view,
+ Request {
+ runner: Some(runner),
+ mode: Mode::Run(RunnerOutput::Discard),
+ announce: &mut |_, _| {},
+ filter: None,
+ caller: Caller::new(&containment, Asking::Nobody).lending(
+ &ports,
+ &consent,
+ EffectsMode::Online,
+ ),
+ },
+ machine,
+ &consent,
+ )
+ .map_err(|refusal| format!("{}: {}", refusal.error.code, refusal.error.message))
+ .unwrap()
+}
+
+/// The facts `collector` answered of `kind`.
+fn facts<'o>(outcome: &'o Outcome, collector: &str, kind: &str) -> Vec<&'o Fact> {
+ outcome
+ .facts
+ .stores
+ .iter()
+ .filter(|s| s.collector == collector)
+ .flat_map(|s| &s.facts)
+ .filter(|f| f.kind == kind)
+ .collect()
+}
+
+fn ids(facts: &[&Fact]) -> Vec {
+ facts.iter().map(|f| f.id.clone()).collect()
+}
+
+/// The messages of `outcome`'s diagnostics with `code`.
+fn said(outcome: &Outcome, code: &str) -> Vec {
+ outcome
+ .diagnostics
+ .iter()
+ .filter(|d| d.code == code)
+ .map(|d| d.message.clone())
+ .collect()
+}
+
+#[specforge_test_macros::test(requirement = "FEATURE-151")]
+fn the_legacy_vitest_is_detected_beside_javascript_vitest() {
+ let p = fixture();
+ let compiled = p.compile();
+ let errors: Vec = compiled
+ .diagnostics()
+ .iter()
+ .filter(|d| d.code.starts_with('E'))
+ .map(|d| format!("{}: {}", d.code, d.message))
+ .collect();
+ assert!(errors.is_empty(), "{errors:?}");
+ let view = specforge_ops::view::ProjectView::of(&compiled);
+ let detected = specforge_ops::analysis::collect::detected_here(
+ view.registries().declarations(),
+ p.root(),
+ None,
+ );
+ let named = |name: &str| {
+ detected
+ .iter()
+ .find(|c| c.name == name)
+ .map(|c| c.extension.clone())
+ };
+ assert_eq!(named("vitest").as_deref(), Some("@specforge/vitest"));
+ assert_eq!(
+ named("javascript-vitest").as_deref(),
+ Some("@javascript/vitest")
+ );
+}
+
+#[specforge_test_macros::test(requirement = "FEATURE-144")]
+fn javascript_coverage_records_the_lines_of_an_item() {
+ let p = fixture();
+ // c8's LCOV: the two body lines of `add`.
+ let lcov =
+ "TN:\nSF:packages/core/src/index.ts\nFN:2,add\nFNDA:1,add\nDA:2,1\nDA:3,1\nend_of_record\n";
+ let outcome = collected(&p, "javascript-coverage", &machine(writing(lcov)));
+ let coverage = facts(&outcome, "javascript-coverage", "coverage");
+ assert_eq!(ids(&coverage), ["cov:js:@acme/core/src/index.ts::add"]);
+ assert_eq!(coverage[0].fields["lines_hit"], 2);
+}
+
+/// ESLint's SARIF: one `no-unused-vars` result at line 2 of `view.tsx`.
+const SARIF: &str = r#"{
+ "version": "2.1.0",
+ "runs": [{
+ "tool": {"driver": {"name": "ESLint", "version": "10.15.0", "rules": [{"id": "no-unused-vars"}]}},
+ "results": [{
+ "level": "error",
+ "message": {"text": "'title' is defined but never used."},
+ "ruleId": "no-unused-vars",
+ "locations": [{"physicalLocation": {
+ "artifactLocation": {"uri": "packages/core/src/view.tsx"},
+ "region": {"startLine": 2, "startColumn": 3, "endLine": 2, "endColumn": 9}
+ }}]
+ }]
+ }]
+}"#;
+
+#[specforge_test_macros::test(requirement = "FEATURE-145")]
+fn javascript_lint_records_a_finding_at_its_item() {
+ let p = fixture();
+ let outcome = collected(&p, "javascript-lint", &machine(writing(SARIF)));
+ let findings = facts(&outcome, "javascript-lint", "static_finding");
+ assert_eq!(findings.len(), 1, "{:?}", ids(&findings));
+ assert_eq!(
+ findings[0].fields["item"],
+ "js:@acme/core/src/view.tsx::View"
+ );
+}
+
+/// cyclonedx-npm's BOM of the root package `app`: its one dependency, lodash.
+const BOM: &str = r#"{
+ "bomFormat": "CycloneDX",
+ "specVersion": "1.6",
+ "version": 1,
+ "metadata": {"component": {"type": "application", "name": "app", "version": "0.0.0",
+ "bom-ref": "app@0.0.0", "purl": "pkg:npm/app@0.0.0"}},
+ "components": [{"type": "library", "name": "lodash", "version": "4.17.15",
+ "bom-ref": "lodash@4.17.15", "purl": "pkg:npm/lodash@4.17.15"}],
+ "dependencies": [{"ref": "app@0.0.0", "dependsOn": ["lodash@4.17.15"]}, {"ref": "lodash@4.17.15"}]
+}"#;
+
+/// osv-scanner's report: one advisory of lodash in the npm lockfile, and a PyPI package of another lockfile, an
+/// ecosystem no pack collects.
+const OSV: &str = r#"{
+ "results": [
+ {
+ "source": {"path": "package-lock.json", "type": "lockfile"},
+ "packages": [{
+ "package": {"name": "lodash", "version": "4.17.15", "ecosystem": "npm"},
+ "vulnerabilities": [{
+ "id": "GHSA-35jh-r3h4-6jhm",
+ "aliases": ["CVE-2021-23337"],
+ "summary": "Command Injection in lodash",
+ "affected": [{"package": {"ecosystem": "npm", "name": "lodash", "purl": "pkg:npm/lodash"}}],
+ "database_specific": {"severity": "HIGH"}
+ }],
+ "groups": [{"ids": ["GHSA-35jh-r3h4-6jhm"]}]
+ }]
+ },
+ {
+ "source": {"path": "tools/requirements.txt", "type": "lockfile"},
+ "packages": [{
+ "package": {"name": "requests", "version": "2.0.0", "ecosystem": "PyPI"},
+ "vulnerabilities": [{"id": "PYSEC-2099-1", "summary": "An invented advisory"}],
+ "groups": [{"ids": ["PYSEC-2099-1"]}]
+ }]
+ }
+ ]
+}"#;
+
+#[specforge_test_macros::test(requirement = "FEATURE-147")]
+#[specforge_test_macros::test(requirement = "FEATURE-128")]
+fn javascript_deps_records_dependencies_and_vulnerabilities_and_warns_of_a_skipped_entry() {
+ let p = fixture();
+ let sbom = collected(&p, "javascript-sbom", &machine(writing(BOM)));
+ assert_eq!(
+ ids(&facts(&sbom, "javascript-sbom", "dependency")),
+ ["dep:pkg:npm/app/pkg%3Anpm%2Flodash%404.17.15"]
+ );
+
+ let osv = collected(&p, "javascript-osv", &machine(writing(OSV)));
+ let vulnerabilities = facts(&osv, "javascript-osv", "vulnerability");
+ assert_eq!(vulnerabilities.len(), 1, "{:?}", ids(&vulnerabilities));
+ assert_eq!(vulnerabilities[0].fields["package"], "pkg:npm/app");
+ assert_eq!(vulnerabilities[0].fields["osv_id"], "GHSA-35jh-r3h4-6jhm");
+ let warned = said(&osv, "W203");
+ assert_eq!(warned.len(), 1, "{warned:?}");
+ assert!(
+ warned[0].contains("'javascript-osv'")
+ && warned[0].contains("'requests' 2.0.0 in 'tools/requirements.txt'"),
+ "{warned:?}"
+ );
+}
+
+/// api-extractor's doc model of `@acme/core`: its function `add`.
+const DOC_MODEL: &str = r#"{
+ "metadata": {"toolPackage": "@microsoft/api-extractor", "toolVersion": "7.60.1", "schemaVersion": 1011},
+ "kind": "Package",
+ "canonicalReference": "@acme/core!",
+ "name": "@acme/core",
+ "members": [{
+ "kind": "EntryPoint",
+ "canonicalReference": "@acme/core!",
+ "name": "",
+ "members": [{
+ "kind": "Function",
+ "canonicalReference": "@acme/core!add:function(1)",
+ "excerptTokens": [{"kind": "Content", "text": "export declare function add(a: number, b: number): number;"}],
+ "fileUrlPath": "dist/index.d.ts",
+ "releaseTag": "Public",
+ "name": "add"
+ }]
+ }]
+}"#;
+
+#[specforge_test_macros::test(requirement = "FEATURE-149")]
+fn javascript_api_writes_its_config_and_records_the_doc_model() {
+ let p = fixture();
+ let outcome = collected(&p, "javascript-api", &machine(writing(DOC_MODEL)));
+ let config = p.read(".specforge/reports/javascript-api.api-extractor.json");
+ assert!(
+ config.contains(r#""apiJsonFilePath": ""#)
+ && config.contains("javascript-api.api.json")
+ && !config.contains("{report}"),
+ "{config}"
+ );
+ let api = facts(&outcome, "javascript-api", "api_item");
+ assert_eq!(ids(&api), ["api:js:%40acme%2Fcore::add"]);
+ assert_eq!(api[0].fields["item"], "js:@acme/core/src/index.ts::add");
+}
+
+/// api-extractor's recordings of `@demo/widget` (the API reader's fixtures): the committed report before a break, and
+/// the doc model and report of the run that breaks it.
+const TAGGED_REPORT: &str = include_str!(
+ "../../../../extensions/code/api/fixtures/api-extractor-7.60.1.widget-tagged.api.md"
+);
+const CHANGED_MODEL: &str = include_str!(
+ "../../../../extensions/code/api/fixtures/api-extractor-7.60.1.widget-changed.api.json"
+);
+const CHANGED_REPORT: &str = include_str!(
+ "../../../../extensions/code/api/fixtures/api-extractor-7.60.1.widget-changed.api.md"
+);
+
+/// Each `api_item`'s name path (its id after `::`) and its `change`.
+fn changes(outcome: &Outcome) -> Vec<(String, Option)> {
+ facts(outcome, "javascript-api", "api_item")
+ .iter()
+ .map(|f| {
+ let name = f.id.split_once("::").map_or("", |(_, name)| name);
+ let change = f.fields.get("change").and_then(|c| c.as_str());
+ (name.to_string(), change.map(str::to_string))
+ })
+ .collect()
+}
+
+#[specforge_test_macros::test(requirement = "FEATURE-149")]
+fn javascript_api_reads_the_committed_report_and_not_temp() {
+ let p = fixture();
+ // The committed report, stamped before the run: the accepted side is read whatever its age, unlike a report.
+ p.write("etc/widget.api.md", TAGGED_REPORT);
+ std::fs::File::options()
+ .write(true)
+ .open(p.root().join("etc/widget.api.md"))
+ .unwrap()
+ .set_modified(ScriptedMachine::started() - Duration::from_secs(1))
+ .unwrap();
+ // api-extractor's own copy of this run's report: fresh, and never the accepted side.
+ p.write("temp/widget.api.md", CHANGED_REPORT);
+
+ let outcome = collected(&p, "javascript-api", &machine(writing(CHANGED_MODEL)));
+ let against_etc = changes(&outcome);
+ for (name, change) in [("create", "changed"), ("trial", "removed")] {
+ assert!(
+ against_etc.contains(&(name.to_string(), Some(change.to_string()))),
+ "{name} {change}: {against_etc:?}"
+ );
+ }
+ assert_eq!(said(&outcome, "W203"), Vec::::new());
+
+ p.remove("etc/widget.api.md");
+ let outcome = collected(&p, "javascript-api", &machine(writing(CHANGED_MODEL)));
+ let only_temp = changes(&outcome);
+ assert!(!only_temp.is_empty());
+ assert!(
+ only_temp.iter().all(|(_, change)| change.is_none()),
+ "{only_temp:?}"
+ );
+ assert_eq!(said(&outcome, "W203"), Vec::::new());
+}
+
+/// The `test` facts `collector` answered: (id, status).
+fn tests_of(outcome: &Outcome, collector: &str) -> Vec<(String, String)> {
+ facts(outcome, collector, "test")
+ .iter()
+ .map(|f| {
+ (
+ f.id.clone(),
+ f.fields["status"].as_str().unwrap().to_string(),
+ )
+ })
+ .collect()
+}
+
+/// Two cases of `board`, `adds` passed and `fails` failed, each test id under the workspace's test file.
+fn assert_two_cases(outcome: &Outcome, collector: &str) {
+ let tests = tests_of(outcome, collector);
+ assert_eq!(tests.len(), 2, "{tests:?}");
+ for (id, _) in &tests {
+ assert!(
+ id.starts_with("js:@acme/core/test/board.test.ts#"),
+ "{tests:?}"
+ );
+ }
+ let status = |name: &str| {
+ tests
+ .iter()
+ .find(|(id, _)| id.ends_with(name))
+ .map(|(_, status)| status.as_str())
+ };
+ assert_eq!(status("adds"), Some("passed"), "{tests:?}");
+ assert_eq!(status("fails"), Some("failed"), "{tests:?}");
+}
+
+#[specforge_test_macros::test(requirement = "FEATURE-151")]
+fn javascript_vitest_records_its_junit_cases() {
+ let p = fixture();
+ let junit = format!(
+ r#"
+
+
+
+
+
+ AssertionError: expected 1 to be 2
+
+
+
+"#
+ );
+ let outcome = collected(&p, "javascript-vitest", &machine(writing(&junit)));
+ assert_two_cases(&outcome, "javascript-vitest");
+}
+
+#[specforge_test_macros::test(requirement = "FEATURE-152")]
+fn javascript_jest_writes_its_env_file_and_records_its_junit_cases() {
+ let p = fixture();
+ let junit = format!(
+ r#"
+
+
+
+
+
+ Error: expect(received).toBe(expected)
+
+
+
+"#
+ );
+ let outcome = collected(&p, "javascript-jest", &machine(writing(&junit)));
+ let env = p.read(".specforge/reports/javascript-jest.jest-junit.env.toml");
+ assert!(
+ env.contains("JEST_JUNIT_OUTPUT_FILE = \"")
+ && env.contains("javascript-jest.xml")
+ && env.contains("JEST_JUNIT_ADD_FILE_ATTRIBUTE = \"true\""),
+ "{env}"
+ );
+ assert_two_cases(&outcome, "javascript-jest");
+}
+
+#[specforge_test_macros::test(requirement = "FEATURE-153")]
+fn javascript_playwright_records_its_captured_junit_cases() {
+ let p = fixture();
+ let junit = format!(
+ "\n\
+\n\
+\n\n\
+\n\
+Error\n\n\
+\n\n"
+ );
+ let run = ScriptedRun {
+ stdout: Some(junit),
+ ..ScriptedRun::default()
+ };
+ let outcome = collected(&p, "javascript-playwright", &machine(run));
+ assert_two_cases(&outcome, "javascript-playwright");
+}
diff --git a/crates/app/ops/tests/javascript_source.rs b/crates/app/ops/tests/javascript_source.rs
index 0ad219956d..12c16e2968 100644
--- a/crates/app/ops/tests/javascript_source.rs
+++ b/crates/app/ops/tests/javascript_source.rs
@@ -166,6 +166,7 @@ fn a_fixture_workspace_collects_its_items_with_ids_kinds_and_locations() {
expected.extend(
[
"js:@acme/core/src/view.tsx::View",
+ "js:@acme/core/test/board.test.ts::adds",
"js:app/packages/cli/bin/cli.mjs::main",
"js:app/scripts/legacy.cjs::build",
"js:app/scripts/legacy.cjs::clean",
@@ -176,7 +177,7 @@ fn a_fixture_workspace_collects_its_items_with_ids_kinds_and_locations() {
assert_eq!(
ids(&outcome, "item"),
expected,
- "nothing from test/, coverage/ or *.min.js"
+ "from test/ only its test call, nothing from coverage/ or *.min.js"
);
let add = fact(&outcome, &core("add"));
@@ -222,7 +223,7 @@ fn a_fixture_workspace_collects_its_items_with_ids_kinds_and_locations() {
}
#[specforge_test_macros::test(requirement = "FEATURE-056")]
-fn a_test_file_mints_no_item_beside_its_runners_test() {
+fn a_test_call_is_an_item_whose_test_id_is_its_runners_test() {
let p = project(FIXTURE, true);
let outcome = collected_with(
&p,
@@ -236,11 +237,23 @@ fn a_test_file_mints_no_item_beside_its_runners_test() {
.map(|f| f.id.as_str())
.collect();
assert_eq!(tests, ["js:@acme/core/test/board.test.ts#adds"]);
+ // The call `test("adds", …)` is the one item of its file: the helper `function adds()` beside it is none.
let from_tests: Vec<&str> = ids(&outcome, "item")
.into_iter()
.filter(|id| id.contains("/test/"))
.collect();
- assert!(from_tests.is_empty(), "{from_tests:?}");
+ assert_eq!(from_tests, ["js:@acme/core/test/board.test.ts::adds"]);
+ let call = fact(&outcome, from_tests[0]);
+ assert_eq!(call.fields["kind"], json!(["function"]));
+ assert_eq!(call.fields["attrs"], json!(["test"]));
+ assert_eq!(
+ call.fields["test_id"], tests[0],
+ "node-test's id for the case"
+ );
+ assert_eq!(
+ call.at[0].start_line, 7,
+ "the call's line, not the helper's"
+ );
}
#[specforge_test_macros::test(requirement = "FEATURE-056")]
@@ -300,7 +313,7 @@ fn the_items_point_at_their_package_fact() {
.unwrap();
let compiled = p.compile();
let items = compiled.graph().nodes_by_kind("item");
- assert_eq!(items.len(), 17);
+ assert_eq!(items.len(), 18, "seventeen source items and one test call");
let code: Vec = compiled
.diagnostics()
.iter()
diff --git a/crates/app/ops/tests/operations/collect/mod.rs b/crates/app/ops/tests/operations/collect/mod.rs
index 9a0e7632fc..420cff8b8b 100644
--- a/crates/app/ops/tests/operations/collect/mod.rs
+++ b/crates/app/ops/tests/operations/collect/mod.rs
@@ -16,9 +16,11 @@ mod ports;
mod reads;
mod refusals;
mod report_first;
+mod report_globs;
mod report_paths;
mod retained;
mod runs;
+mod warnings;
use std::path::{Path, PathBuf};
use std::sync::Arc;
@@ -226,6 +228,15 @@ impl Runner {
self
}
+ /// Its export also returns the warning `line` (ADR 0389).
+ pub fn warning(mut self, line: &str) -> Self {
+ let Answer::Output(output) = &mut self.answer else {
+ panic!("a trapping runner warns of nothing");
+ };
+ output.warnings.push(line.to_string());
+ self
+ }
+
/// Its export traps.
pub fn trapping(mut self) -> Self {
self.answer = Answer::Trap;
diff --git a/crates/app/ops/tests/operations/collect/report_globs.rs b/crates/app/ops/tests/operations/collect/report_globs.rs
new file mode 100644
index 0000000000..71183c7f1c
--- /dev/null
+++ b/crates/app/ops/tests/operations/collect/report_globs.rs
@@ -0,0 +1,313 @@
+//! A collector's report may be a glob over project files the tool writes itself (ADR 0389): after a run the host
+//! hands the export every fresh match of the shared walk (ADR 0293 D4), each held by containment.
+
+use super::{Fixture, Machine, Runner, paths};
+use specforge_ops::analysis::collect::{CollectField, Mode, Outcome, RunnerOutput};
+use specforge_ops::asking::Asking;
+use specforge_ops::testing::{ScriptedMachine, ScriptedRun};
+use specforge_ops::{Containment, Refusal};
+use specforge_test_macros::test as specforge_test;
+
+const GLOB: &str = "**/rust-sbom.cdx.json";
+
+/// Collector `acme` reporting `GLOB`, run as `acme` (no `{report}`).
+fn sbom() -> Runner {
+ Runner::new("acme").run(&["acme"]).report(GLOB)
+}
+
+/// A run writing `files` (relative to the project root, a glob's base) and exiting 0.
+fn writing(files: &[&str]) -> ScriptedRun {
+ ScriptedRun {
+ files: files
+ .iter()
+ .map(|path| ((*path).into(), "{}".to_string()))
+ .collect(),
+ exit_code: Some(0),
+ ..ScriptedRun::default()
+ }
+}
+
+/// Run `acme`, named, with every capability approved.
+fn run(fx: &Fixture, machine: &Machine) -> Result> {
+ fx.collect_with(
+ Some("acme"),
+ Mode::Run(RunnerOutput::Discard),
+ &Containment::unbounded(),
+ Asking::Nobody,
+ machine,
+ )
+}
+
+#[specforge_test(requirement = "FEATURE-128")]
+fn a_report_glob_hands_over_every_match_the_run_wrote_sorted() {
+ let fx = Fixture::new(vec![sbom()]);
+ let machine = Machine::new()
+ .approving_everything()
+ .answering(writing(&["b/c/rust-sbom.cdx.json", "a/rust-sbom.cdx.json"]));
+
+ run(&fx, &machine).unwrap();
+
+ assert_eq!(
+ paths(&fx.dispatched()[0]),
+ ["a/rust-sbom.cdx.json", "b/c/rust-sbom.cdx.json"]
+ );
+}
+
+#[specforge_test(requirement = "FEATURE-128")]
+fn a_match_older_than_the_run_is_not_handed_over_and_nothing_is_removed() {
+ let fx = Fixture::new(vec![sbom()]);
+ fx.write("old/rust-sbom.cdx.json", "{}");
+ std::fs::File::options()
+ .write(true)
+ .open(fx.root().join("old/rust-sbom.cdx.json"))
+ .unwrap()
+ .set_modified(ScriptedMachine::started() - std::time::Duration::from_secs(1))
+ .unwrap();
+ let machine = Machine::new()
+ .approving_everything()
+ .answering(writing(&["a/rust-sbom.cdx.json"]));
+
+ run(&fx, &machine).unwrap();
+
+ assert_eq!(paths(&fx.dispatched()[0]), ["a/rust-sbom.cdx.json"]);
+ assert!(fx.exists("old/rust-sbom.cdx.json"), "nothing is removed");
+}
+
+#[specforge_test(requirement = "FEATURE-128")]
+fn a_report_glob_skips_build_output_and_enters_no_link() {
+ let fx = Fixture::new(vec![sbom()]);
+ #[cfg(unix)]
+ let outside = tempfile::tempdir().unwrap();
+ #[cfg(unix)]
+ {
+ std::fs::write(outside.path().join("rust-sbom.cdx.json"), "{}").unwrap();
+ std::os::unix::fs::symlink(outside.path(), fx.root().join("linked")).unwrap();
+ }
+ let machine = Machine::new().approving_everything().answering(writing(&[
+ "target/debug/rust-sbom.cdx.json",
+ "node_modules/x/rust-sbom.cdx.json",
+ "a/rust-sbom.cdx.json",
+ ]));
+
+ run(&fx, &machine).unwrap();
+
+ assert_eq!(paths(&fx.dispatched()[0]), ["a/rust-sbom.cdx.json"]);
+}
+
+#[cfg(unix)]
+#[specforge_test(requirement = "FEATURE-128")]
+fn a_match_linking_out_of_the_project_is_not_read_and_named_in_a_w203() {
+ let outside = tempfile::tempdir().unwrap();
+ std::fs::write(outside.path().join("bom.json"), "{\"secret\": 1}").unwrap();
+ let linked = |fx: &Fixture| {
+ std::fs::create_dir(fx.root().join("a")).unwrap();
+ std::os::unix::fs::symlink(
+ outside.path().join("bom.json"),
+ fx.root().join("a/rust-sbom.cdx.json"),
+ )
+ .unwrap();
+ };
+ let collect = |fx: &Fixture, machine: &Machine| {
+ fx.collect_with(
+ Some("acme"),
+ Mode::Run(RunnerOutput::Discard),
+ &Containment::within(fx.root()),
+ Asking::Nobody,
+ machine,
+ )
+ };
+
+ let fx = Fixture::new(vec![sbom()]);
+ linked(&fx);
+ let machine = Machine::new()
+ .approving_everything()
+ .answering(writing(&["b/rust-sbom.cdx.json"]));
+ let outcome = collect(&fx, &machine).unwrap();
+ assert_eq!(paths(&fx.dispatched()[0]), ["b/rust-sbom.cdx.json"]);
+ let warned: Vec<&str> = outcome
+ .diagnostics
+ .iter()
+ .filter(|d| d.code == "W203")
+ .map(|d| d.message.as_str())
+ .collect();
+ assert_eq!(warned.len(), 1, "{warned:?}");
+ assert!(
+ warned[0].contains("'acme'") && warned[0].contains("a/rust-sbom.cdx.json"),
+ "{}",
+ warned[0]
+ );
+
+ // The only match links out: the "no report" refusal names it.
+ let fx = Fixture::new(vec![sbom()]);
+ linked(&fx);
+ let machine = Machine::new()
+ .approving_everything()
+ .answering(writing(&[]));
+ let refusal = collect(&fx, &machine).unwrap_err();
+ assert_eq!(refusal.error.code, "E045", "{refusal:?}");
+ assert!(
+ refusal.error.message.contains("produced no report")
+ && refusal.error.message.contains("a/rust-sbom.cdx.json"),
+ "{}",
+ refusal.error.message
+ );
+}
+
+#[specforge_test(requirement = "FEATURE-128")]
+fn a_hard_linked_report_is_refused_in_a_bounded_containment() {
+ let outside = tempfile::tempdir().unwrap();
+ std::fs::write(outside.path().join("bom.json"), "{\"secret\": 1}").unwrap();
+ // The project's only match is a second name of a file outside it: the run writes nothing.
+ let linked = || {
+ let fx = Fixture::new(vec![sbom()]);
+ std::fs::create_dir(fx.root().join("a")).unwrap();
+ std::fs::hard_link(
+ outside.path().join("bom.json"),
+ fx.root().join("a/rust-sbom.cdx.json"),
+ )
+ .unwrap();
+ let machine = Machine::new()
+ .approving_everything()
+ .answering(writing(&[]));
+ (fx, machine)
+ };
+
+ let (fx, machine) = linked();
+ let refusal = fx
+ .collect_with(
+ Some("acme"),
+ Mode::Run(RunnerOutput::Discard),
+ &Containment::within(fx.root()),
+ Asking::Nobody,
+ &machine,
+ )
+ .unwrap_err();
+ assert_eq!(refusal.error.code, "E045", "{refusal:?}");
+ assert!(
+ refusal.error.message.contains("failed to read report")
+ && refusal.error.message.contains("rust-sbom.cdx.json"),
+ "{}",
+ refusal.error.message
+ );
+ assert!(fx.dispatched().is_empty(), "the collector receives nothing");
+
+ // The CLI runs unbounded (ADR 0092 D6): the same link is read.
+ let (fx, machine) = linked();
+ run(&fx, &machine).unwrap();
+ assert_eq!(paths(&fx.dispatched()[0]), ["a/rust-sbom.cdx.json"]);
+}
+
+#[specforge_test(requirement = "FEATURE-128")]
+fn a_report_glob_with_a_report_placeholder_or_a_capture_is_e058() {
+ let told = Runner::new("acme").report(GLOB);
+ let configured = sbom()
+ .run(&["acme", "--config", "{config}"])
+ .configuring("acme.toml", "out = \"{report}\"");
+ let captured = sbom().capturing_stdout();
+ for runner in [told, configured, captured] {
+ let fx = Fixture::new(vec![runner]);
+ let machine = Machine::new().approving_everything();
+ let refusal = run(&fx, &machine).unwrap_err();
+ assert_eq!(refusal.error.code, "E058", "{refusal:?}");
+ assert!(
+ refusal.error.message.contains("'acme'"),
+ "{}",
+ refusal.error.message
+ );
+ assert!(machine.runs().is_empty(), "{:?}", machine.runs());
+ }
+}
+
+#[specforge_test(requirement = "FEATURE-128")]
+fn a_report_glob_matching_nothing_or_past_the_walk_cap_is_e045() {
+ let fx = Fixture::new(vec![sbom()]);
+ let machine = Machine::new()
+ .approving_everything()
+ .answering(writing(&["a/other.json"]));
+ let refusal = run(&fx, &machine).unwrap_err();
+ assert_eq!(refusal.error.code, "E045");
+ assert!(
+ refusal.error.message.contains("produced no report"),
+ "{refusal:?}"
+ );
+
+ let fx = Fixture::new(vec![sbom()]);
+ std::fs::create_dir(fx.root().join("many")).unwrap();
+ for i in 0..20_001 {
+ std::fs::write(fx.root().join(format!("many/{i}")), "").unwrap();
+ }
+ let machine = Machine::new()
+ .approving_everything()
+ .answering(writing(&["a/rust-sbom.cdx.json"]));
+ let refusal = run(&fx, &machine).unwrap_err();
+ assert_eq!(refusal.error.code, "E045");
+ assert!(
+ refusal.error.message.contains("20000"),
+ "{}",
+ refusal.error.message
+ );
+}
+
+#[specforge_test(requirement = "FEATURE-128")]
+fn a_report_glob_runs_with_its_base_as_the_report_and_no_report_variable() {
+ let fx = Fixture::new(vec![sbom()]);
+ let machine = Machine::new()
+ .approving_everything()
+ .answering(writing(&["a/rust-sbom.cdx.json"]));
+
+ run(&fx, &machine).unwrap();
+
+ let runs = machine.runs();
+ assert_eq!(runs[0].report, fx.root());
+ assert!(!runs[0].report_in_env);
+
+ let fx = Fixture::new(vec![
+ Runner::new("acme").run(&["acme"]).report("out/**/a.json"),
+ ]);
+ let machine = Machine::new()
+ .approving_everything()
+ .answering(writing(&["x/a.json"]));
+ run(&fx, &machine).unwrap();
+ assert_eq!(machine.runs()[0].report, fx.root().join("out"));
+ assert_eq!(paths(&fx.dispatched()[0]), ["out/x/a.json"]);
+}
+
+#[specforge_test(requirement = "FEATURE-128")]
+fn a_report_glob_ending_in_a_wildcard_is_e058_and_nothing_runs() {
+ for glob in ["**/*", "**/*.pem", "**/.env*", "keys/?.json"] {
+ let fx = Fixture::new(vec![Runner::new("acme").run(&["acme"]).report(glob)]);
+ fx.write("a/id.pem", "secret");
+ let machine = Machine::new().approving_everything();
+ let refusal = run(&fx, &machine).unwrap_err();
+ assert_eq!(refusal.error.code, "E058", "{glob}: {refusal:?}");
+ assert!(
+ refusal.error.message.contains("literal file name"),
+ "{}",
+ refusal.error.message
+ );
+ assert!(machine.runs().is_empty(), "{:?}", machine.runs());
+ assert!(fx.dispatched().is_empty(), "{glob}");
+ }
+}
+
+#[specforge_test(requirement = "FEATURE-128")]
+fn a_report_over_the_byte_cap_is_e045_naming_it() {
+ let fx = Fixture::new(vec![sbom()]);
+ let half = specforge_ops::analysis::collect::REPORT_BYTES_MAX / 2 + 1;
+ for dir in ["a", "b"] {
+ std::fs::create_dir(fx.root().join(dir)).unwrap();
+ let file = std::fs::File::create(fx.root().join(dir).join("rust-sbom.cdx.json")).unwrap();
+ file.set_len(half).unwrap();
+ }
+ let machine = Machine::new()
+ .approving_everything()
+ .answering(writing(&[]));
+ let refusal = run(&fx, &machine).unwrap_err();
+ assert_eq!(refusal.error.code, "E045", "{refusal:?}");
+ assert!(
+ refusal.error.message.contains("67108864"),
+ "{}",
+ refusal.error.message
+ );
+ assert!(fx.dispatched().is_empty());
+}
diff --git a/crates/app/ops/tests/operations/collect/warnings.rs b/crates/app/ops/tests/operations/collect/warnings.rs
new file mode 100644
index 0000000000..6bbb7ea746
--- /dev/null
+++ b/crates/app/ops/tests/operations/collect/warnings.rs
@@ -0,0 +1,61 @@
+//! A collector's warnings (ADR 0389): each line its export returns under `warnings` is one W203 naming the
+//! collector, escaped, at most 100 per collector and then one counting the rest.
+
+use specforge_common::{Diagnostic, Severity};
+use specforge_test_macros::test as specforge_test;
+
+use super::{Fixture, Machine, Runner};
+
+/// Collect `runner` from its existing report: the W203 diagnostics of the outcome.
+fn warned(runner: Runner) -> Vec {
+ let fixture = Fixture::new(vec![runner]);
+ fixture.write("out/acme.json", "{}");
+ let outcome = fixture
+ .no_run(Some("acme"), &Machine::new())
+ .expect("the collect runs");
+ outcome
+ .diagnostics
+ .into_iter()
+ .filter(|d| d.code == "W203")
+ .collect()
+}
+
+#[specforge_test(requirement = "FEATURE-128")]
+fn a_warning_line_is_one_w203_naming_the_collector() {
+ let line = "skipped 1 file outside the project: /elsewhere/a.rs";
+ let warned = warned(Runner::new("acme").warning(line));
+ assert_eq!(warned.len(), 1, "{warned:?}");
+ assert_eq!(warned[0].severity, Severity::Warning);
+ let message = &warned[0].message;
+ assert!(message.contains("'acme'"), "{message}");
+ assert!(message.contains("@acme/acme"), "{message}");
+ assert!(message.contains(line), "{message}");
+}
+
+#[specforge_test(requirement = "FEATURE-128")]
+fn a_warning_line_prints_escaped() {
+ let warned = warned(Runner::new("acme").warning("\u{1b}[31mred"));
+ assert_eq!(warned.len(), 1, "{warned:?}");
+ assert!(!warned[0].message.contains('\u{1b}'), "{:?}", warned[0]);
+ assert!(
+ warned[0].message.contains("\\u{1b}[31mred"),
+ "{:?}",
+ warned[0]
+ );
+}
+
+#[specforge_test(requirement = "FEATURE-128")]
+fn past_a_hundred_warning_lines_one_w203_counts_the_rest() {
+ let runner = (0..150).fold(Runner::new("acme"), |runner, i| {
+ runner.warning(&format!("line {i}"))
+ });
+ let warned = warned(runner);
+ assert_eq!(warned.len(), 101);
+ assert!(warned[99].message.ends_with("line 99"), "{:?}", warned[99]);
+ assert!(warned[100].message.contains("50 more"), "{:?}", warned[100]);
+}
+
+#[specforge_test(requirement = "FEATURE-128")]
+fn a_collector_answering_no_warnings_gives_no_w203() {
+ assert!(warned(Runner::new("acme").proving("a", "t")).is_empty());
+}
diff --git a/crates/app/ops/tests/operations/context_records.rs b/crates/app/ops/tests/operations/context_records.rs
index 99cf3e7f0e..5689dca558 100644
--- a/crates/app/ops/tests/operations/context_records.rs
+++ b/crates/app/ops/tests/operations/context_records.rs
@@ -68,6 +68,7 @@ fn apply(project: &TestProject, origin: &Origin, ops: Value) -> String {
fn gsd() -> Origin {
Origin::Command {
extension: GSD_JUDGED.to_string(),
+ imports: false,
}
}
@@ -175,6 +176,7 @@ fn a_record_is_refused_for_an_unknown_route_an_unrecorded_kind_another_origin_or
let before = spec(&project);
let other = Origin::Command {
extension: "@acme/other".to_string(),
+ imports: false,
};
for (origin, ops, reason) in [
(
diff --git a/crates/app/ops/tests/operations/extension_calls.rs b/crates/app/ops/tests/operations/extension_calls.rs
index 10f7b48718..5a20aa55f5 100644
--- a/crates/app/ops/tests/operations/extension_calls.rs
+++ b/crates/app/ops/tests/operations/extension_calls.rs
@@ -82,6 +82,7 @@ fn collector() -> Collector {
config: None,
filter: Vec::new(),
install: None,
+ requires: Vec::new(),
}
}
diff --git a/crates/app/ops/tests/operations/harness.rs b/crates/app/ops/tests/operations/harness.rs
index 983c459477..30f5056a3e 100644
--- a/crates/app/ops/tests/operations/harness.rs
+++ b/crates/app/ops/tests/operations/harness.rs
@@ -300,6 +300,7 @@ fn a_typed_edit_of_a_context_field_is_refused_context_field() {
Origin::mcp(),
Origin::Command {
extension: specforge_project::testing::GSD_JUDGED.to_string(),
+ imports: false,
},
];
for origin in &origins {
diff --git a/crates/app/ops/tests/operations/imports.rs b/crates/app/ops/tests/operations/imports.rs
new file mode 100644
index 0000000000..6944a0e09a
--- /dev/null
+++ b/crates/app/ops/tests/operations/imports.rs
@@ -0,0 +1,171 @@
+//! A command that declares `imports` copies history recorded outside the spec, so its plan is judged for host errors
+//! only (ADR 0392): an extension's rule error about authored entities lands; a host error, a first-party
+//! (`@specforge/*`) extension's error and one that judges collected facts still refuse the whole plan. A collector's
+//! plan (ADR 0303) lands that first-party error too; an import's does not. A command that does not declare it is
+//! refused for every error (E080). `@t/core`'s `import` declares it, `record` does not; the guard pass reports E087
+//! while a phase's goal is [`GUARDED`], and E901, a code that judges collected facts, while another phase's goal is
+//! [`RACED`] too.
+
+use std::sync::Arc;
+
+use serde_json::{Value, json};
+use specforge_project::testing::{
+ CORE, GSD_WRITES_EXTENSIONS, GUARDED, GsdWrites, RACED, TestProject, component_runtime,
+ gsd_writes_answer,
+};
+use specforge_test_macros::test as specforge_test;
+use specforge_wasm::testing::InProcessRuntime;
+
+use crate::plans::{MILESTONE, Ran, compiled, project, revision, run_command, set};
+
+/// The plan that leaves the project with an extension's error: phase `03`'s goal set to [`GUARDED`].
+fn guarded(p: &TestProject) -> Value {
+ json!([set(
+ "v1.0/03",
+ "goal",
+ json!(GUARDED),
+ &revision(p, "m.spec")
+ )])
+}
+
+/// The plan that leaves the project with a host error: a decision whose phase is no entity.
+fn dangling() -> Value {
+ json!([{"op": "create", "kind": "decision", "id": "D-01", "title": "D", "file": "d.spec",
+ "revision": "absent", "fields": {"phase": "99", "origin": "context"}}])
+}
+
+/// The runtime in which `@t/core`'s command `id` answers `ops`, its guard on.
+fn runtime(id: &str, ops: Value) -> Arc {
+ Arc::new(
+ GsdWrites::new()
+ .guarding_a_goal()
+ .answering(CORE, &format!("cmd__{id}"), gsd_writes_answer(0, ops))
+ .runtime(),
+ )
+}
+
+/// `@t/core`'s command `id` answering `ops`, its guard on.
+fn ran(p: &TestProject, id: &str, ops: Value) -> Ran {
+ let runtime = runtime(id, ops);
+ run_command(p, &compiled(p, &runtime), &runtime, "core", id)
+}
+
+/// `import` answering [`guarded`], another writer landing `z.spec` (`landed`) after the compile: the plan is judged
+/// again over the disk, under the write lock.
+fn imported_after(p: &TestProject, landed: &str) -> Ran {
+ let runtime = runtime("import", guarded(p));
+ let compiled = compiled(p, &runtime);
+ std::fs::write(p.root().join("z.spec"), landed).unwrap();
+ run_command(p, &compiled, &runtime, "core", "import")
+}
+
+/// The code a plan was refused with, if it was.
+fn refusal(ran: &Ran) -> Option<&str> {
+ ran.refusal.as_ref().map(|(code, _)| code.as_str())
+}
+
+/// The codes of the errors a refusal (E080) names.
+fn refused_codes(ran: &Ran) -> Vec {
+ let Some((_, data)) = &ran.refusal else {
+ return Vec::new();
+ };
+ data["diagnostics"]
+ .as_array()
+ .into_iter()
+ .flatten()
+ .filter_map(|d| d["code"].as_str().map(str::to_string))
+ .collect()
+}
+
+#[specforge_test(requirement = "FEATURE-131")]
+fn an_imports_plan_keeps_an_extensions_error() {
+ let p = project();
+ let ran = ran(&p, "import", guarded(&p));
+
+ assert_eq!(refusal(&ran), None);
+ assert_eq!(ran.wrote, ["m.spec"]);
+ let written = std::fs::read_to_string(p.root().join("m.spec")).unwrap();
+ assert!(written.contains(GUARDED), "{written}");
+}
+
+#[specforge_test(requirement = "FEATURE-131")]
+fn an_imports_plan_that_adds_a_host_error_is_refused() {
+ let p = project();
+ let ran = ran(&p, "import", dangling());
+
+ assert_eq!(refusal(&ran), Some("E080"));
+ assert!(ran.wrote.is_empty(), "{:?}", ran.wrote);
+ assert!(!p.root().join("d.spec").exists());
+}
+
+#[specforge_test(requirement = "FEATURE-131")]
+fn a_command_that_does_not_declare_imports_is_refused_for_both() {
+ let p = project();
+ let extension = ran(&p, "record", guarded(&p));
+ let host = ran(&p, "record", dangling());
+
+ assert_eq!(refusal(&extension), Some("E080"));
+ assert_eq!(refusal(&host), Some("E080"));
+ assert!(extension.wrote.is_empty() && host.wrote.is_empty());
+}
+
+/// A first-party extension's error refuses an import (ADR 0392, ADR 0391 D9): a phase's goal is a file
+/// `@specforge/checks` reads, and the import names one that does not exist, so `@specforge/checks` reports E016 with
+/// its origin and a bare code.
+#[specforge_test(requirement = "FEATURE-131")]
+fn an_imports_plan_that_adds_a_first_party_extensions_error_is_refused() {
+ let mut extensions = GSD_WRITES_EXTENSIONS.to_vec();
+ extensions.push("@specforge/checks");
+ let p = TestProject::new()
+ .config(|c| {
+ c["name"] = "p".into();
+ c["checks"] = json!({ "fields": { "phase.goal": ["@specforge/checks:file"] } });
+ })
+ .enabling(&extensions)
+ .installing_enabled()
+ .file("m.spec", MILESTONE);
+ let ops = json!([set(
+ "v1.0/03",
+ "goal",
+ json!("missing.md"),
+ &revision(&p, "m.spec")
+ )]);
+ let runtime = Arc::new(
+ GsdWrites::new()
+ .answering(CORE, "cmd__import", gsd_writes_answer(0, ops))
+ .runtime()
+ .beside(component_runtime()),
+ );
+ let ran = run_command(&p, &compiled(&p, &runtime), &runtime, "core", "import");
+
+ assert_eq!(refusal(&ran), Some("E080"));
+ assert_eq!(refused_codes(&ran), ["E016"]);
+ assert!(ran.wrote.is_empty(), "{:?}", ran.wrote);
+}
+
+/// The re-judgement under the write lock lands what the plan's check landed: another writer's file moved the disk
+/// after the compile, and the import's extension rule error is still written.
+#[specforge_test(requirement = "FEATURE-131")]
+fn the_re_judge_under_the_lock_keeps_an_imports_rule_error() {
+ let p = project();
+ let ran = imported_after(&p, "phase 04 \"Four\" {\n milestone v1.0\n}\n");
+
+ assert_eq!(refusal(&ran), None);
+ let written = std::fs::read_to_string(p.root().join("m.spec")).unwrap();
+ assert!(written.contains(GUARDED), "{written}");
+}
+
+/// The re-judgement under the write lock refuses what an import may not land: only the disk as the other writer
+/// left it (a phase whose goal is [`RACED`]) adds E901, a code that judges collected facts, so only that judgement
+/// sees it, and a collector's rule there would have written it.
+#[specforge_test(requirement = "FEATURE-131")]
+fn the_re_judge_under_the_lock_refuses_what_an_import_may_not_land() {
+ let p = project();
+ let landed = format!("phase 04 \"Four\" {{\n milestone v1.0\n goal \"{RACED}\"\n}}\n");
+ let ran = imported_after(&p, &landed);
+
+ assert_eq!(refusal(&ran), Some("E080"));
+ assert_eq!(refused_codes(&ran), ["t/E901"]);
+ let written = std::fs::read_to_string(p.root().join("m.spec")).unwrap();
+ assert!(!written.contains(GUARDED), "{written}");
+}
diff --git a/crates/app/ops/tests/operations/judged_inputs.rs b/crates/app/ops/tests/operations/judged_inputs.rs
index ae1bfff272..a4c4a67ce5 100644
--- a/crates/app/ops/tests/operations/judged_inputs.rs
+++ b/crates/app/ops/tests/operations/judged_inputs.rs
@@ -45,6 +45,7 @@ fn record(project: &specforge_project::testing::TestProject, basis: &Value) -> S
.unwrap();
let origin = Origin::Command {
extension: GSD_JUDGED.to_string(),
+ imports: false,
};
match apply_plan_with(
&view,
diff --git a/crates/app/ops/tests/operations/main.rs b/crates/app/ops/tests/operations/main.rs
index 627d376b04..bc93a32e2c 100644
--- a/crates/app/ops/tests/operations/main.rs
+++ b/crates/app/ops/tests/operations/main.rs
@@ -59,6 +59,7 @@ mod held_spelling;
mod hooks;
mod host_support;
mod human;
+mod imports;
mod infer;
mod infer_guide;
mod infer_sources;
diff --git a/crates/app/ops/tests/operations/migrate.rs b/crates/app/ops/tests/operations/migrate.rs
index f666c0b26a..995c45162b 100644
--- a/crates/app/ops/tests/operations/migrate.rs
+++ b/crates/app/ops/tests/operations/migrate.rs
@@ -140,11 +140,11 @@ fn a_header_only_migration_of_the_frozen_spec_keeps_its_graph() {
"{:?}",
outcome.structural_differences()
);
- assert!(
- outcome.verdict.post_errors().next().is_none(),
- "{:?}",
- outcome.verdict.post_errors().collect::>()
- );
+ // `@code/core` 1.2.0 declares `coverage` (ADR 0388): the unedited corpus's `term coverage` is its one error.
+ let errors: Vec<_> = outcome.verdict.post_errors().collect();
+ let pinned = errors.len() == 1 && errors[0].message.contains("ID 'coverage' collides");
+ assert!(pinned, "{errors:?}");
+ assert_eq!(errors[0].code, "E013", "{errors:?}");
}
#[specforge_test(requirement = "FEATURE-122")]
diff --git a/crates/app/ops/tests/operations/owner_reveals.rs b/crates/app/ops/tests/operations/owner_reveals.rs
index eda2a51f5e..da720bc357 100644
--- a/crates/app/ops/tests/operations/owner_reveals.rs
+++ b/crates/app/ops/tests/operations/owner_reveals.rs
@@ -111,7 +111,7 @@ fn refused(project: &CompiledProject, field: &str) -> Option {
/// The added errors `steps` are refused with, planned over `project`: their codes, or `None` when it is not refused.
fn refused_steps(project: &CompiledProject, steps: &[Step]) -> Option> {
- let refusal = edit::plan_steps(&ProjectView::of(project), steps, false).err()?;
+ let refusal = edit::plan_steps(&ProjectView::of(project), steps, edit::Lands::Nothing).err()?;
assert_eq!(
refusal.error.code.to_string(),
"E080",
diff --git a/crates/app/ops/tests/operations/plans.rs b/crates/app/ops/tests/operations/plans.rs
index 11ad68f7cf..2206313d3e 100644
--- a/crates/app/ops/tests/operations/plans.rs
+++ b/crates/app/ops/tests/operations/plans.rs
@@ -8,6 +8,8 @@
use std::sync::Arc;
use serde_json::{Map, Value, json};
+use specforge_extension_sdk::DeclaredCategory;
+use specforge_extension_sdk::prelude::{ContributionsBuilder, ExtensionMeta};
use specforge_ops::authoring::apply::{PlanOutcome, Surface, execute};
use specforge_ops::extension::command::{CommandFormat, ExtensionCommands};
use specforge_ops::view::ProjectView;
@@ -428,6 +430,112 @@ fn a_harness_value_is_set_only_by_its_extension_or_a_peer() {
assert_eq!(error.error.code, "harness_field");
}
+/// A create of the UAT test `U9` in the new file `03-09.spec`, scoped as [`ONE`] is and holding the harness value
+/// `result` `pass`: the op `gsd import` answers for a recorded result (ADR 0391 D7, assumption A7).
+fn create_u9() -> Value {
+ json!([{"op": "create", "kind": "uat_test", "id": "U9", "title": "U9", "file": "03-09.spec",
+ "revision": "absent", "fields": {"phase": "03", "result": "pass"}}])
+}
+
+/// The create landed: the file holds the entity and the ledger its `result` line.
+fn holds_u9(p: &TestProject) {
+ let text = std::fs::read_to_string(p.root().join("03-09.spec")).unwrap();
+ assert!(
+ text.contains("uat_test U9") && text.contains("result"),
+ "{text}"
+ );
+ assert!(
+ ledger(p).contains(&line("v1.0/03/U9", "result", "\"pass\"")),
+ "{}",
+ ledger(p)
+ );
+}
+
+#[specforge_test(requirement = "FEATURE-131")]
+fn a_peer_creates_an_entity_holding_a_harness_value() {
+ let p = project();
+ assert_eq!(refused(&p, UI, "ui", "mark", create_u9()), None);
+ holds_u9(&p);
+ let q = project();
+ let runtime = serving(&[(OTHER, "cmd__record", 0, create_u9())]);
+ let ran = run_command(&q, &compiled(&q, &runtime), &runtime, "other", "record");
+ assert_eq!(
+ ran.refusal.map(|(code, _)| code).as_deref(),
+ Some("harness_field")
+ );
+ assert!(ran.wrote.is_empty(), "{:?}", ran.wrote);
+}
+
+/// `@gsd/import`'s operation cap (ADR 0391 D9), `MAX_OPS` read from the guest's own source, so this test measures the
+/// cap the importer enforces, not a copy of it: 2,000 creates apply in ~38 s; 5,000 took 218 s, 10,000 passed 60 s.
+fn importer_max_ops() -> usize {
+ let path = specforge_repo_root::repo_root().join("gsd/import/src/limits.rs");
+ let source = std::fs::read_to_string(&path).unwrap();
+ source
+ .lines()
+ .find_map(|line| line.strip_prefix("pub const MAX_OPS: usize = "))
+ .and_then(|value| value.trim_end_matches(';').replace('_', "").parse().ok())
+ .unwrap_or_else(|| panic!("{} declares no `pub const MAX_OPS: usize`", path.display()))
+}
+
+#[specforge_test(requirement = "FEATURE-131")]
+fn one_plan_of_many_creates_applies() {
+ let max_ops = importer_max_ops();
+ let p = TestProject::new()
+ .config(|c| c["name"] = "p".into())
+ .enabling(&GSD_WRITES_EXTENSIONS)
+ .installing_enabled()
+ .file("m.spec", MILESTONE);
+ let ops: Vec = (1..=max_ops)
+ .map(|n| {
+ json!({"op": "create", "kind": "uat_test", "id": format!("U{n}"), "title": "U",
+ "file": format!("bulk/{}.spec", (n - 1) / 100), "revision": "absent",
+ "fields": {"phase": "03"}})
+ })
+ .collect();
+ let runtime = serving(&[(UI, "cmd__mark", 0, Value::Array(ops))]);
+ let ran = run_command(&p, &compiled(&p, &runtime), &runtime, "ui", "mark");
+ assert_eq!(ran.refusal, None);
+ let mut wrote = ran.wrote;
+ wrote.sort_unstable();
+ let mut expected: Vec = (0..max_ops.div_ceil(100))
+ .map(|k| format!("bulk/{k}.spec"))
+ .collect();
+ expected.sort_unstable();
+ assert_eq!(wrote, expected);
+}
+
+/// An extension that names [`CORE`] an optional peer, with one writing command `mark`.
+const OPTIONAL: &str = "@t/optional";
+
+fn optional() -> ContributionsBuilder {
+ let mut c = ContributionsBuilder::new(ExtensionMeta::new(OPTIONAL, "1.0.0"));
+ c.optional_peer(CORE, "^1.0");
+ let mark = json!({"id": "mark", "title": "mark", "description": "mark", "export": "cmd__mark",
+ "args": [], "writes": true});
+ c.raw_category(DeclaredCategory::Surfaces, json!([{"commands": [mark]}]));
+ c
+}
+
+#[specforge_test(requirement = "FEATURE-131")]
+fn an_optional_peer_creates_an_entity_holding_a_harness_value() {
+ let mut enabled = GSD_WRITES_EXTENSIONS.to_vec();
+ enabled.push(OPTIONAL);
+ let p = TestProject::new()
+ .config(|c| c["name"] = "p".into())
+ .enabling(&enabled)
+ .installing_enabled()
+ .file("m.spec", MILESTONE);
+ let runtime = Arc::new(GsdWrites::new().runtime().with(optional).answer_raw(
+ OPTIONAL,
+ "cmd__mark",
+ gsd_writes_answer(0, create_u9()),
+ ));
+ let ran = run_command(&p, &compiled(&p, &runtime), &runtime, "optional", "mark");
+ assert_eq!(ran.refusal, None);
+ holds_u9(&p);
+}
+
#[specforge_test(requirement = "FEATURE-131")]
fn a_plan_from_a_command_that_does_not_declare_writes_is_refused() {
let p = project();
diff --git a/crates/app/ops/tests/operations/prompt_judges.rs b/crates/app/ops/tests/operations/prompt_judges.rs
index 901a3e4e1d..f413113cb7 100644
--- a/crates/app/ops/tests/operations/prompt_judges.rs
+++ b/crates/app/ops/tests/operations/prompt_judges.rs
@@ -87,6 +87,7 @@ fn record(project: &TestProject, extension: &str, judge: &str) -> String {
.unwrap();
let origin = Origin::Command {
extension: extension.to_string(),
+ imports: false,
};
match apply_plan_with(
&view,
diff --git a/crates/app/ops/tests/operations/settled_later.rs b/crates/app/ops/tests/operations/settled_later.rs
index ff92c76139..bec4600021 100644
--- a/crates/app/ops/tests/operations/settled_later.rs
+++ b/crates/app/ops/tests/operations/settled_later.rs
@@ -184,7 +184,7 @@ fn reported(project: &CompiledProject) -> Vec {
/// E080 refuses it with (`Err`).
fn planned(spec: &str, steps: &[Step]) -> Result, Vec> {
let compiled = project(spec).compile_in(runtime());
- match edit::plan_steps(&ProjectView::of(&compiled), steps, false) {
+ match edit::plan_steps(&ProjectView::of(&compiled), steps, edit::Lands::Nothing) {
Ok(plan) => Ok(plan
.report()
.added
diff --git a/crates/app/ops/tests/operations/verdicts.rs b/crates/app/ops/tests/operations/verdicts.rs
index fe499ce1bb..dff599b85e 100644
--- a/crates/app/ops/tests/operations/verdicts.rs
+++ b/crates/app/ops/tests/operations/verdicts.rs
@@ -208,6 +208,7 @@ pub(crate) fn gsd_in(
let plan: EditPlan = serde_json::from_value(json!({"ops": ops})).unwrap();
let origin = Origin::Command {
extension: GSD_JUDGED.to_string(),
+ imports: false,
};
match apply_plan_with(
&view,
diff --git a/crates/app/ops/tests/rust_packs.rs b/crates/app/ops/tests/rust_packs.rs
index b24b51cbe8..f8e5ee40c8 100644
--- a/crates/app/ops/tests/rust_packs.rs
+++ b/crates/app/ops/tests/rust_packs.rs
@@ -570,3 +570,77 @@ fn the_source_guest_maps_the_fixture_within_its_fuel() {
let outcome = collect_in(&compiled, None, &machine(None)).unwrap();
assert_eq!(facts(&outcome, "rust-source").len(), ITEMS.len());
}
+
+/// The fixture with `src/.rs` holding `source`, declared by its lib.
+fn with_module(module: &str, source: &str) -> TestProject {
+ let lib = std::fs::read_to_string(format!("{FIXTURE}/src/lib.rs")).unwrap();
+ fixture()
+ .file("src/lib.rs", format!("{lib}\nmod {module};\n"))
+ .file(&format!("src/{module}.rs"), source)
+}
+
+#[specforge_test_macros::test(requirement = "FEATURE-004")]
+#[specforge_test_macros::test(requirement = "FEATURE-114")]
+fn a_test_compiled_out_on_the_host_is_skipped() {
+ let p = with_module(
+ "extra",
+ "#[cfg(windows)]\n#[test]\nfn only_on_windows() {}\n",
+ );
+ let outcome = collected(&p, None, &machine(None));
+ let id = "rust:adder#extra::only_on_windows";
+ assert_eq!(
+ fact(&outcome, "rust-test", id).fields["status"],
+ "skipped",
+ "the recorded report lacks it: a unix host compiles it out"
+ );
+ assert!(
+ !facts(&outcome, "rust-test")
+ .iter()
+ .any(|f| f.id == format!("run:{id}")),
+ "a test that never ran has no run"
+ );
+}
+
+#[specforge_test_macros::test(requirement = "FEATURE-002")]
+#[specforge_test_macros::test(requirement = "FEATURE-113")]
+fn a_guard_only_helper_is_no_test() {
+ let p = with_module(
+ "guard",
+ "#[specforge_test_macros::test(behavior = \"x\", __guard_only)]\nfn helper() {}\n",
+ );
+ let outcome = collected(&p, None, &machine(None));
+ let helper = fact(&outcome, "rust-source", "rust:adder::guard::helper");
+ assert!(
+ !helper.fields.contains_key("test_id"),
+ "{:?}",
+ helper.fields
+ );
+}
+
+#[specforge_test_macros::test(requirement = "FEATURE-002")]
+#[specforge_test_macros::test(requirement = "FEATURE-108")]
+fn an_excluded_directory_holds_no_package() {
+ let manifest = "[package]\nname = \"subcrate\"\nversion = \"0.1.0\"\nedition = \"2021\"\n";
+ let with_sub = || {
+ fixture()
+ .file("sub/Cargo.toml", manifest)
+ .file("sub/src/lib.rs", "")
+ };
+ let packages = |p: &TestProject| -> Vec {
+ facts(
+ &collected(p, Some("rust-cargo"), &machine(None)),
+ "rust-cargo",
+ )
+ .iter()
+ .map(|f| f.id.clone())
+ .collect()
+ };
+ assert_eq!(
+ packages(&with_sub()),
+ ["pkg:cargo/adder", "pkg:cargo/subcrate"]
+ );
+ let excluded = with_sub().config(|c| {
+ c["settings"] = serde_json::json!({"@rust/cargo": {"exclude": ["sub"]}});
+ });
+ assert_eq!(packages(&excluded), ["pkg:cargo/adder"]);
+}
diff --git a/crates/app/ops/tests/rust_report_packs.rs b/crates/app/ops/tests/rust_report_packs.rs
new file mode 100644
index 0000000000..b87b48af7f
--- /dev/null
+++ b/crates/app/ops/tests/rust_report_packs.rs
@@ -0,0 +1,443 @@
+//! The Rust report packs end to end (ADR 0389): `@rust/coverage`, `@rust/lint`, `@rust/deps`, `@rust/api` and
+//! `@rust/proof` from their real blobs collect the fixture crate `tests/fixtures/rust-packs`, a scripted machine
+//! standing in for each tool. Each report is a short inline text in the format of its pack's own fixture: LCOV for
+//! cargo-llvm-cov, clippy's JSON messages, a CycloneDX BOM for cargo-cyclonedx, cargo-public-api's text and Kani's
+//! regular output.
+#![allow(
+ clippy::unwrap_used,
+ reason = "a test's unwrap is its assertion: a None or an Err fails the test"
+)]
+
+use std::sync::Arc;
+use std::time::Duration;
+
+use specforge_effects::testing::MemoryConsent;
+use specforge_effects::{EffectsMode, Ports};
+use specforge_ops::analysis::collect::{Mode, Outcome, Request, RunnerOutput, collect};
+use specforge_ops::asking::Asking;
+use specforge_ops::testing::{ScriptedMachine, ScriptedRun};
+use specforge_ops::{Caller, Containment};
+use specforge_project::testing::TestProject;
+use specforge_protocol_types::Fact;
+
+/// The five report packs, the packs whose facts they read, and `@specforge/software`, whose behaviors the fixture's
+/// tests name.
+const PACKS: [&str; 9] = [
+ "@specforge/software",
+ "@code/core",
+ "@rust/cargo",
+ "@rust/source",
+ "@rust/coverage",
+ "@rust/lint",
+ "@rust/deps",
+ "@rust/api",
+ "@rust/proof",
+];
+const FIXTURE: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/tests/fixtures/rust-packs");
+
+/// The fixture crate, the report packs enabled, and the packages and items of `@rust/cargo` and `@rust/source`
+/// collected and stored, as a collect of every detected collector stores them before a report pack runs.
+fn fixture() -> TestProject {
+ let p = TestProject::copy_of(FIXTURE).enabling(&PACKS);
+ for collector in ["rust-cargo", "rust-source"] {
+ // Neither runs a command: nothing is scripted.
+ let mut outcome = collected(&p, collector, &ScriptedMachine::new());
+ let compiled = p.compile();
+ let view = specforge_ops::view::ProjectView::of(&compiled);
+ let dry_run = false;
+ specforge_ops::authoring::apply::apply_collected(
+ &view,
+ Vec::new(),
+ std::mem::take(&mut outcome.facts),
+ dry_run,
+ specforge_ops::testing::caller(),
+ )
+ .unwrap();
+ }
+ p
+}
+
+/// A machine whose one run does `run` and exits 0.
+fn machine(run: ScriptedRun) -> ScriptedMachine {
+ ScriptedMachine::new().answering(ScriptedRun {
+ exit_code: Some(0),
+ ..run
+ })
+}
+
+/// A run that writes `report` at the report location.
+fn writing(report: &str) -> ScriptedRun {
+ ScriptedRun {
+ files: vec![("".into(), report.to_string())],
+ ..ScriptedRun::default()
+ }
+}
+
+/// A run that prints `stdout`, which a capture pack reads.
+fn printing(stdout: &str) -> ScriptedRun {
+ ScriptedRun {
+ stdout: Some(stdout.to_string()),
+ ..ScriptedRun::default()
+ }
+}
+
+/// Collect `runner` of `p` through `machine`, everything approved, unbounded as the CLI; a refusal is its code and
+/// message.
+fn collect_or_refused(
+ p: &TestProject,
+ runner: &str,
+ machine: &ScriptedMachine,
+) -> Result {
+ collect_within(p, runner, machine, &Containment::unbounded())
+}
+
+/// [`collect_or_refused`] inside `containment`.
+fn collect_within(
+ p: &TestProject,
+ runner: &str,
+ machine: &ScriptedMachine,
+ containment: &Containment,
+) -> Result {
+ let compiled = p.compile();
+ // The view and the caller share the one containment, as an MCP call's do (ADR 0183).
+ let view = specforge_ops::view::ProjectView::of(&compiled).bounded_by(containment);
+ // The disk, as the CLI lends it: rust-source's reads go through the host's own reader.
+ let ports = Ports {
+ fs: Arc::new(specforge_fs::LocalFs),
+ ..specforge_effects::testing::ports()
+ };
+ let consent = MemoryConsent::approving_everything();
+ collect(
+ &view,
+ Request {
+ runner: Some(runner),
+ mode: Mode::Run(RunnerOutput::Discard),
+ announce: &mut |_, _| {},
+ filter: None,
+ caller: Caller::new(containment, Asking::Nobody).lending(
+ &ports,
+ &consent,
+ EffectsMode::Online,
+ ),
+ },
+ machine,
+ &consent,
+ )
+ .map_err(|refusal| format!("{}: {}", refusal.error.code, refusal.error.message))
+}
+
+fn collected(p: &TestProject, runner: &str, machine: &ScriptedMachine) -> Outcome {
+ collect_or_refused(p, runner, machine).unwrap()
+}
+
+/// The facts `collector` answered of `kind`.
+fn facts<'o>(outcome: &'o Outcome, collector: &str, kind: &str) -> Vec<&'o Fact> {
+ outcome
+ .facts
+ .stores
+ .iter()
+ .filter(|s| s.collector == collector)
+ .flat_map(|s| &s.facts)
+ .filter(|f| f.kind == kind)
+ .collect()
+}
+
+fn ids(facts: &[&Fact]) -> Vec {
+ facts.iter().map(|f| f.id.clone()).collect()
+}
+
+/// The messages of `outcome`'s diagnostics with `code`.
+fn said(outcome: &Outcome, code: &str) -> Vec {
+ outcome
+ .diagnostics
+ .iter()
+ .filter(|d| d.code == code)
+ .map(|d| d.message.clone())
+ .collect()
+}
+
+/// cargo-llvm-cov's LCOV of the fixture: two lines of `tests::adds` in `src/lib.rs`, and one record of the standard
+/// library under `/rustc/`, outside the project.
+const LCOV: &str = "TN:\n\
+SF:src/lib.rs\n\
+FN:14,_RNvNtCs1_5adder5tests4adds\n\
+FNDA:1,_RNvNtCs1_5adder5tests4adds\n\
+DA:14,1\n\
+DA:15,1\n\
+end_of_record\n\
+SF:/rustc/0123456789abcdef/library/core/src/ops/arith.rs\n\
+DA:1,1\n\
+end_of_record\n";
+
+#[specforge_test_macros::test(requirement = "FEATURE-143")]
+#[specforge_test_macros::test(requirement = "FEATURE-128")]
+fn rust_coverage_records_coverage_and_warns_of_a_file_outside_the_project() {
+ let p = fixture();
+ let outcome = collected(&p, "rust-coverage", &machine(writing(LCOV)));
+ let coverage = facts(&outcome, "rust-coverage", "coverage");
+ assert_eq!(ids(&coverage), ["cov:rust:adder::tests::adds"]);
+ assert_eq!(coverage[0].fields["file"], "src/lib.rs");
+ assert_eq!(coverage[0].fields["lines_hit"], 2);
+ let warned = said(&outcome, "W203");
+ assert_eq!(warned.len(), 1, "{warned:?}");
+ assert!(
+ warned[0].contains("'rust-coverage'")
+ && warned[0].contains("/rustc/0123456789abcdef/library/core/src/ops/arith.rs"),
+ "{warned:?}"
+ );
+}
+
+/// One clippy JSON message: `rule` at `line` of `src/lib.rs`, the primary span.
+fn clippy(rule: &str, line: u32) -> String {
+ serde_json::json!({
+ "reason": "compiler-message",
+ "package_id": "path+file:///project#adder@0.1.0",
+ "target": {"kind": ["lib"], "name": "adder", "src_path": "src/lib.rs"},
+ "message": {
+ "$message_type": "diagnostic",
+ "level": "warning",
+ "message": format!("{rule} fired"),
+ "code": {"code": rule, "explanation": null},
+ "spans": [{
+ "file_name": "src/lib.rs",
+ "is_primary": true,
+ "line_start": line,
+ "line_end": line,
+ "column_start": 5,
+ "column_end": 9
+ }],
+ "children": []
+ }
+ })
+ .to_string()
+}
+
+#[specforge_test_macros::test(requirement = "FEATURE-146")]
+fn rust_lint_records_each_clippy_diagnostic() {
+ let p = fixture();
+ let stdout = format!(
+ "{}\n{}\n{{\"reason\":\"build-finished\",\"success\":true}}\n",
+ clippy("clippy::unwrap_used", 15),
+ clippy("unused_variables", 20)
+ );
+ let outcome = collected(&p, "rust-lint", &machine(printing(&stdout)));
+ let findings = facts(&outcome, "rust-lint", "static_finding");
+ let cited: Vec<&serde_json::Value> = findings.iter().map(|f| &f.fields["item"]).collect();
+ assert_eq!(
+ cited,
+ ["rust:adder::tests::adds", "rust:adder::tests::slow"],
+ "each finding cites the innermost item holding its line: {:?}",
+ ids(&findings)
+ );
+ assert!(said(&outcome, "W203").is_empty());
+}
+
+/// A cargo-cyclonedx BOM of the fixture crate whose one component is `name`.
+fn bom(name: &str) -> String {
+ serde_json::json!({
+ "bomFormat": "CycloneDX",
+ "specVersion": "1.5",
+ "version": 1,
+ "metadata": {
+ "component": {
+ "type": "application",
+ "bom-ref": "path+file:///project#adder@0.1.0",
+ "name": "adder",
+ "version": "0.1.0",
+ "purl": "pkg:cargo/adder@0.1.0?download_url=file://."
+ }
+ },
+ "components": [{
+ "type": "library",
+ "bom-ref": format!("registry+https://github.com/rust-lang/crates.io-index#{name}@1.0.0"),
+ "name": name,
+ "version": "1.0.0",
+ "scope": "required",
+ "purl": format!("pkg:cargo/{name}@1.0.0")
+ }]
+ })
+ .to_string()
+}
+
+/// Write `text` at `path` of `p`, stamped one second before the run starts: a file an earlier run left or the project
+/// committed.
+fn earlier(p: &TestProject, path: &str, text: &str) {
+ p.write(path, text);
+ std::fs::File::options()
+ .write(true)
+ .open(p.root().join(path))
+ .unwrap()
+ .set_modified(ScriptedMachine::started() - Duration::from_secs(1))
+ .unwrap();
+}
+
+#[specforge_test_macros::test(requirement = "FEATURE-148")]
+fn rust_sbom_reads_only_the_bom_the_run_wrote() {
+ let p = fixture();
+ // A BOM an earlier run left: the report glob reaches it, freshness does not.
+ earlier(&p, "stale/rust-sbom.cdx.json", &bom("stale"));
+ // The glob's base is the root: cargo-cyclonedx writes the BOM beside the root manifest.
+ let run = ScriptedRun {
+ files: vec![("rust-sbom.cdx.json".into(), bom("serde"))],
+ ..ScriptedRun::default()
+ };
+ let outcome = collected(&p, "rust-sbom", &machine(run));
+ let dependencies = ids(&facts(&outcome, "rust-sbom", "dependency"));
+ assert_eq!(
+ dependencies,
+ ["dep:pkg:cargo/adder/pkg%3Acargo%2Fserde%401.0.0"]
+ );
+}
+
+/// cargo-public-api's text of the fixture's library: its one public function, re-exported at the root.
+const PUBLIC_API: &str = "pub mod adder\npub fn adder::add(a: i32, b: i32) -> i32\n";
+
+#[specforge_test_macros::test(requirement = "FEATURE-150")]
+fn rust_api_records_the_public_api() {
+ let p = fixture();
+ let outcome = collected(&p, "rust-api", &machine(printing(PUBLIC_API)));
+ let api = facts(&outcome, "rust-api", "api_item");
+ assert_eq!(ids(&api), ["api:rust:adder", "api:rust:adder::add"]);
+ assert_eq!(api[1].fields["kind"], "function");
+}
+
+/// Each fact's id and its `change`, sorted by id.
+fn changes(api: &[&Fact]) -> Vec<(String, Option)> {
+ let mut changes: Vec<_> = api
+ .iter()
+ .map(|f| {
+ let change = f.fields.get("change").and_then(|c| c.as_str());
+ (f.id.clone(), change.map(str::to_string))
+ })
+ .collect();
+ changes.sort();
+ changes
+}
+
+#[specforge_test_macros::test(requirement = "FEATURE-150")]
+fn rust_api_reads_the_committed_accepted_api() {
+ let p = fixture();
+ // Committed before the run: the accepted side is read whatever its age, unlike a report.
+ let accepted = format!("{PUBLIC_API}pub fn adder::sub(a: i32, b: i32) -> i32\n");
+ earlier(&p, "tests/public-api.txt", &accepted);
+ let outcome = collected(&p, "rust-api", &machine(printing(PUBLIC_API)));
+ let change = |id: &str, change: &str| (id.to_string(), Some(change.to_string()));
+ assert_eq!(
+ changes(&facts(&outcome, "rust-api", "api_item")),
+ [
+ change("api:rust:adder", "unchanged"),
+ change("api:rust:adder::add", "unchanged"),
+ change("api:rust:adder::sub", "removed"),
+ ]
+ );
+ assert_eq!(said(&outcome, "W203"), Vec::::new());
+}
+
+#[specforge_test_macros::test(requirement = "FEATURE-150")]
+fn an_accepted_report_past_64_kib_is_read() {
+ let p = fixture();
+ let mut accepted = PUBLIC_API.to_string();
+ for n in 0..2700 {
+ accepted.push_str(&format!("pub fn adder::generated_{n:04}() -> i32\n"));
+ }
+ assert!(accepted.len() > 96 * 1024, "{}", accepted.len());
+ earlier(&p, "tests/public-api.txt", &accepted);
+ let outcome = collected(&p, "rust-api", &machine(printing(PUBLIC_API)));
+ let changes = changes(&facts(&outcome, "rust-api", "api_item"));
+ assert!(
+ changes.contains(&(
+ "api:rust:adder::add".to_string(),
+ Some("unchanged".to_string())
+ )),
+ "{:?}",
+ &changes[..3]
+ );
+ let warned = said(&outcome, "W203");
+ assert!(
+ !warned.iter().any(|w| w.contains("too_large")),
+ "{warned:?}"
+ );
+}
+
+#[specforge_test_macros::test(requirement = "FEATURE-150")]
+fn a_hard_linked_accepted_file_is_not_read_in_a_bounded_containment() {
+ let outside = tempfile::tempdir().unwrap();
+ let secret = outside.path().join("public-api.txt");
+ std::fs::write(
+ &secret,
+ format!("{PUBLIC_API}pub fn adder::sub(a: i32, b: i32) -> i32\n"),
+ )
+ .unwrap();
+ let p = fixture();
+ std::fs::create_dir_all(p.root().join("tests")).unwrap();
+ std::fs::hard_link(&secret, p.root().join("tests/public-api.txt")).unwrap();
+
+ // MCP bounds the request: the second name of a file outside the project is never read (ADR 0146).
+ let bounded = Containment::within(p.root());
+ let run = machine(printing(PUBLIC_API));
+ let outcome = collect_within(&p, "rust-api", &run, &bounded).unwrap();
+ let api = facts(&outcome, "rust-api", "api_item");
+ assert!(
+ changes(&api).iter().all(|(_, change)| change.is_none()),
+ "{:?}",
+ changes(&api)
+ );
+ let warned = said(&outcome, "W203");
+ assert!(
+ warned
+ .iter()
+ .any(|w| w.contains("tests/public-api.txt") && w.contains("(unreadable)")),
+ "{warned:?}"
+ );
+
+ // The CLI runs unbounded (ADR 0092 D6): the same link is read.
+ let outcome = collected(&p, "rust-api", &machine(printing(PUBLIC_API)));
+ let changes = changes(&facts(&outcome, "rust-api", "api_item"));
+ assert!(
+ changes.contains(&(
+ "api:rust:adder::sub".to_string(),
+ Some("removed".to_string())
+ )),
+ "{changes:?}"
+ );
+}
+
+/// Kani's regular output: the harness `tests::slow`, which only the fixture's library holds, verified.
+const KANI: &str = "Kani Rust Verifier 0.68.0 (cargo plugin)\n\
+ Compiling adder v0.1.0 (/project)\n\
+Checking harness tests::slow...\n\
+\n\
+RESULTS:\n\
+Check 1: tests::slow.assertion.1\n\
+\t - Status: SUCCESS\n\
+\t - Description: \"assertion failed\"\n\
+\n\
+SUMMARY:\n\
+ ** 0 of 1 failed\n\
+\n\
+VERIFICATION:- SUCCESSFUL\n\
+Verification Time: 0.25s\n\
+\n\
+Manual Harness Summary:\n\
+Complete - 1 successfully verified harnesses, 0 failures, 1 total.\n";
+
+#[specforge_test_macros::test(requirement = "FEATURE-154")]
+fn rust_proof_records_a_verified_harness_at_its_item() {
+ let p = fixture();
+ let outcome = collected(&p, "rust-proof", &machine(printing(KANI)));
+ let tests = facts(&outcome, "rust-proof", "test");
+ assert_eq!(ids(&tests), ["rust:adder#tests::slow"]);
+ assert_eq!(tests[0].fields["status"], "passed");
+ assert_eq!(tests[0].fields["file"], "src/lib.rs");
+ assert!(!tests[0].at.is_empty(), "placed at the harness fn");
+}
+
+#[specforge_test_macros::test(requirement = "FEATURE-154")]
+fn a_kani_output_cut_before_complete_is_the_collectors_error() {
+ let p = fixture();
+ let cut = &KANI[..KANI.find("Manual Harness Summary").unwrap()];
+ let refused = collect_or_refused(&p, "rust-proof", &machine(printing(cut))).unwrap_err();
+ // The run is refused whole: no proof result is stored, none dropped silently.
+ assert!(refused.starts_with("E028: "), "{refused}");
+ assert!(refused.contains("rust-proof"), "{refused}");
+}
diff --git a/crates/kernel/common/tests/titled_list.rs b/crates/kernel/common/tests/titled_list.rs
index 1ae0bef642..df73f66a5e 100644
--- a/crates/kernel/common/tests/titled_list.rs
+++ b/crates/kernel/common/tests/titled_list.rs
@@ -16,6 +16,7 @@ fn a_list_and_a_document_title_a_code_from_the_code_book_they_were_built_with()
machine: false,
reported_while: None,
settled_later: false,
+ facts: Vec::new(),
}],
)
.unwrap();
diff --git a/crates/kernel/effects/src/testing.rs b/crates/kernel/effects/src/testing.rs
index 8ae9aa485d..81687d5128 100644
--- a/crates/kernel/effects/src/testing.rs
+++ b/crates/kernel/effects/src/testing.rs
@@ -39,6 +39,7 @@ pub fn ports() -> Ports {
#[derive(Default)]
pub struct FakeProcess {
answers: BTreeMap)>,
+ paths: BTreeMap,
requests: Mutex>,
}
@@ -60,6 +61,12 @@ impl FakeProcess {
self
}
+ /// `which(program)` finds it `at`; every other program stays not found.
+ pub fn on_path(mut self, program: &str, at: impl Into) -> Self {
+ self.paths.insert(program.to_string(), at.into());
+ self
+ }
+
/// The requests run so far, in order.
pub fn requests(&self) -> Vec {
self.requests.lock().expect("no request panics").clone()
@@ -102,6 +109,10 @@ impl Process for FakeProcess {
}
outcome
}
+
+ fn which(&self, program: &str) -> Option {
+ self.paths.get(program).cloned()
+ }
}
/// A file port over files held in memory, by absolute path; a directory is any prefix of a file's path. With a
diff --git a/crates/leaf/diagnostics/src/catalog.rs b/crates/leaf/diagnostics/src/catalog.rs
index 0513c4b2ca..b266a36e90 100644
--- a/crates/leaf/diagnostics/src/catalog.rs
+++ b/crates/leaf/diagnostics/src/catalog.rs
@@ -205,7 +205,7 @@ catalog! {
"An entity writes a field its kind does not declare, and that field is the other side of a relation a reference field owns, its own kind's included. A relation is written on its owning field only (ADR 0150): the one reference field an extension declares for it. The other side is derived, never written: `query` shows it as the incoming edges and `trace` as the upstream. The field is recognised in two ways: a reference field whose targets hold this kind names it in its `inverse_of`, a self-relation's and a union's included (so a documented reverse such as `behaviors` on a feature, or `superseded_by` on a decision, is refused even when its ids do not resolve), or every id it lists is one other kind's entity and that kind owns a single-kind reference field into this one (`journeys [..]` on a feature). By its values alone a self-relation's or a union's other side is not recognised, and a kind that accepts any field is not checked. The graph still carries the field's untyped edge, and `check` fails. Remove the field and write the owning field on each entity it listed; the suggestion names both.";
E080: Error core,
"Typed edit would add errors",
- "A typed edit (`specforge new`, `set`, `unset`, `link`, `unlink`, `delete`, or MCP `specforge.edit`) was planned, and the project it would leave reports errors the project does not report now (the same error by code, severity, message shape, file and, for an extension's finding, its subject): the edit is refused and nothing is written. The refusal lists each new error (an unresolved reference, a missing required field, a value its field does not take, …). Fix what they name first: create the referenced entity, give the required field, or make both changes in one `specforge.edit` call. `delete --unlink-references` removes the references a delete would leave dangling. A judged rule's finding (no verdict, a stale or a failing verdict) is never one of them: its judge settles it, not the edit (ADR 0297). Nor is an extension's finding whose code waits for an owner state (`reported_while`) and that the edit revealed by moving its entity into that state: the edit is accepted and the finding is reported once it is written (ADR 0363). Nor is an extension's finding whose code a later step of the authoring settles (`settled_later`) on an entity the edit creates, or creates something under, when the edit alters nothing the project held there: the edit is accepted, lists the finding, and `check` reports it until that step is written; an edit that creates neither, one that also sets, unsets, links, unlinks, deletes or moves at or under that entity, and a migration still count it (ADR 0385). A writing collector's plan is compared with the project as its collect left it, and is refused for host errors only: an extension's error refuses no collected fact (ADR 0303).";
+ "A typed edit (`specforge new`, `set`, `unset`, `link`, `unlink`, `delete`, or MCP `specforge.edit`) was planned, and the project it would leave reports errors the project does not report now (the same error by code, severity, message shape, file and, for an extension's finding, its subject): the edit is refused and nothing is written. The refusal lists each new error (an unresolved reference, a missing required field, a value its field does not take, …). Fix what they name first: create the referenced entity, give the required field, or make both changes in one `specforge.edit` call. `delete --unlink-references` removes the references a delete would leave dangling. A judged rule's finding (no verdict, a stale or a failing verdict) is never one of them: its judge settles it, not the edit (ADR 0297). Nor is an extension's finding whose code waits for an owner state (`reported_while`) and that the edit revealed by moving its entity into that state: the edit is accepted and the finding is reported once it is written (ADR 0363). Nor is an extension's finding whose code a later step of the authoring settles (`settled_later`) on an entity the edit creates, or creates something under, when the edit alters nothing the project held there: the edit is accepted, lists the finding, and `check` reports it until that step is written; an edit that creates neither, one that also sets, unsets, links, unlinks, deletes or moves at or under that entity, and a migration still count it (ADR 0385). A writing collector's plan is compared with the project as its collect left it, and is refused for host errors only: an extension's error refuses no collected fact (ADR 0303). The plan of a command that declares `imports` writes an extension's rule error about authored entities the imported records carry, and `check` reports it: a code in the extension's namespace that its own catalog lists and whose entry judges no collected fact. It is still refused for any other error: the host's or a `@specforge/*` builtin's (E016 included), and one that judges the records against collected facts, such as `code/E101` (ADR 0392).";
E081: Error core,
"Field written twice in one block",
"A block writes one field (an entry of a block field, a member of a type) more than once. A field holds one value: the graph keeps the first and every output, check and rule reads it; the message names the first's line. Delete the later line, or give every value in the first: a list field takes all its items in one list (`ports [a, b]`), a block field all its entries in one block. A typed edit that changes the field (`set`, `unset`, `link`, `unlink`) removes the later lines itself. A repeat in a `defaults` block is E078.";
@@ -481,7 +481,7 @@ catalog! {
"An entity sets a field that isn't declared for its kind by any installed extension, or a typed block or block list item sets a key its field declares no member for. Remove it, fix a typo in its name, or install the extension that declares it.";
W021: Warning core,
"Undeclared target kind or edge label",
- "A field, edge type or validation rule references a `target_kind` or edge label that isn't declared — either in the extension's own manifest when it declares no peer dependencies, or in the compiler's global kind/edge registry once all extensions are loaded. Declare the missing kind or edge label, or add the appropriate peer dependency (a validation rule on another extension's kind that this one works without names that extension as its `target_extension` instead). The same code reports a declaration the registry refuses: a `derived_from` that derives nothing, a `proof_role` other than `bound` or `claim`, a `scoped_by` that is not one of the kind's single reference fields with a target kind, targets a kind no extension loads or the kind itself, or closes a scope cycle (the kind is then unscoped), an `enum` field that declares no values, or a `default_value` an enum field does not take. A field that writes a declared edge type from a kind outside its declared `source_kind`, or to a kind outside its declared `target_kind`, is W021 too, and its edges are of no edge type. So is a typed field the registry refuses and drops the attribute of: `members` on a type other than `block` or `block_list`, a `block_list` with none, a member named twice or not one identifier, a member that declares `derived_from`, `target_kinds` together with `target_kind`, on a type other than `reference` or `reference_list`, or naming one kind, a `minimum` or `maximum` on a type other than `integer` or `number`, a fraction or a value beyond `i64` on an `integer`, more than 15 significant digits on a `number`, or a `minimum` above the `maximum` (ADR 0361); a `scoped_by` field with `target_kinds` scopes nothing. Who writes a field is checked too (ADR 0287): a `writer` other than `computed`, `harness`, `human` or `verdict`, `harness` or `verdict` on a member, a computed or verdict field that is also `required`, `immutable`, `append_only` or `derived_from`, `append_only` on a field that is not a list, a computed field no compute pass lists in `computes`, a `computes` entry that is not a computed field of the extension or that two passes list or whose pass is not in the `compute` phase, and a `baseline` naming a kind no loaded extension declares. Who writes a kind is checked as well (ADR 0289): a kind `writer` other than `human`, a `human` field marked `required` on a kind that is not human-only (an agent could then create no entity of the kind), a `guard` pass that declares `computes`, and a `guard` pass that reports the code of a judged rule of its extension (ADR 0302). A kind's `result` is checked too (ADR 0329): on a kind no collector writes, naming a field the kind does not declare or one that is no `enum`, or an enum whose values are not all test statuses (`passed`, `failed`, `skipped`), it is dropped. So is a kind's `complete_when` (ADR 0329): naming a field the kind does not declare or one that is no `enum`, no value, or a value the enum does not take, it is dropped and the kind's entities follow their scope's owner state. The `settings` category is checked too (ADR 0288): a setting named twice or not a dotted name or a family (`*` segments), of a type the field forms do not have, with a default its type refuses, with `gates` or `gates_when_on` (ADR 0305) on a type other than `bool` or on a family (only a setting named whole gates codes), naming a code the extension does not catalog, or gating one code both ways, or with `keys` that do not match its `*`s; a preset whose source is not an enum or bool setting of the extension or of a loaded peer, that names a value its source does not take, that sets a setting the extension does not declare to a value its type refuses, or that raises a code the extension does not catalog; a secret named twice or whose environment variable is not a name; and an item of a kind the host does not know. The `surfaces` category is checked too (ADR 0291): a prompt whose id is not snake_case or whose export is not `prompt__`, that declares an argument twice or named for something the host owns (`path`, `format`, `help`, `settings`, `secrets`, `host`, `argv`), of a type an argument does not take, a reference argument naming no loaded kind, bounds on an argument that is no integer or a default its type refuses, a gate that is not a code the extension catalogs (a command's gates too), a command that is `human` and does not `writes` (ADR 0301), a `subject` that is not an argument it declares, a `when` that is not a bool setting of the extension, or a step that names a command or prompt neither the extension nor a declared peer declares; the prompt or command is dropped whole, since a gate or an argument the host cannot read must not be ignored, and a step's `agent` (until the host knows agents) or an attribution with an empty field is dropped alone. The item is dropped, the rest of the category is kept. The host contributions are checked too (ADR 0292): an agent, skill, slash command or hook the registry refuses and drops, alone — an agent or skill id that is not kebab-case or is declared twice, a hook id that is not snake_case, a tool class outside the host-neutral vocabulary (`read`, `write`, `edit`, `shell`, `search`, `web_fetch`, `web_search`, `ask_user`, `agent`, `skill`, `todo`, `mcp:/`, or a `specforge:`, `specforge:` or `specforge:.` naming an engine tool, engine group or a command an agent may run (ADR 0334), but never on a hook), `mcp:specforge/` (SpecForge's whole server, which the `specforge:` classes name tool by tool), a `specforge:` class naming a human-attested or refused command, a `model` or `effort` outside its tiers that is not a `setting:` naming a string or enum setting of the extension, variants without a `variant_setting` (or the reverse), a `when` that is not a bool setting of the extension, a slash command that names no single prompt or command the extension declares, `tools` or `paths` on a hook of an event that takes none, a `timeout_ms` of 0 or above the ceiling (30 s, or the sandbox's), `writes` on a `statusline` hook, a hook export that is not `hook__`, an attribution with an empty field, and a prompt step whose `agent` is no agent of the extension or of a declared peer. An input the host would serve empty is W021 too (ADR 0293, ADR 0337), the call being kept: an input its call kind is not served, a collector's included, or a second one of a kind served once (`tests`, `state`, `graph`, `slash_commands`, `git`), a `setting` input naming the call's own extension or no extension and setting, and a `files` input whose name is no word or is repeated, that names neither or both of `field` and `glob`, a `field` that is not `kind.field` or that no loaded extension declares, a `root` on a glob or that is no root's name, and a glob that is empty, absolute, climbs with `..`, or has more than four `**` segments.";
+ "A field, edge type or validation rule references a `target_kind` or edge label that isn't declared — either in the extension's own manifest when it declares no peer dependencies, or in the compiler's global kind/edge registry once all extensions are loaded. Declare the missing kind or edge label, or add the appropriate peer dependency (a validation rule on another extension's kind that this one works without names that extension as its `target_extension` instead). The same code reports a declaration the registry refuses: a `derived_from` that derives nothing, a `proof_role` other than `bound` or `claim`, a `scoped_by` that is not one of the kind's single reference fields with a target kind, targets a kind no extension loads or the kind itself, or closes a scope cycle (the kind is then unscoped), an `enum` field that declares no values, or a `default_value` an enum field does not take. A field that writes a declared edge type from a kind outside its declared `source_kind`, or to a kind outside its declared `target_kind`, is W021 too, and its edges are of no edge type. So is a typed field the registry refuses and drops the attribute of: `members` on a type other than `block` or `block_list`, a `block_list` with none, a member named twice or not one identifier, a member that declares `derived_from`, `target_kinds` together with `target_kind`, on a type other than `reference` or `reference_list`, or naming one kind, a `minimum` or `maximum` on a type other than `integer` or `number`, a fraction or a value beyond `i64` on an `integer`, more than 15 significant digits on a `number`, or a `minimum` above the `maximum` (ADR 0361); a `scoped_by` field with `target_kinds` scopes nothing. Who writes a field is checked too (ADR 0287): a `writer` other than `computed`, `harness`, `human` or `verdict`, `harness` or `verdict` on a member, a computed or verdict field that is also `required`, `immutable`, `append_only` or `derived_from`, `append_only` on a field that is not a list, a computed field no compute pass lists in `computes`, a `computes` entry that is not a computed field of the extension or that two passes list or whose pass is not in the `compute` phase, and a `baseline` naming a kind no loaded extension declares. Who writes a kind is checked as well (ADR 0289): a kind `writer` other than `human`, a `human` field marked `required` on a kind that is not human-only (an agent could then create no entity of the kind), a `guard` pass that declares `computes`, and a `guard` pass that reports the code of a judged rule of its extension (ADR 0302). A kind's `result` is checked too (ADR 0329): on a kind no collector writes, naming a field the kind does not declare or one that is no `enum`, or an enum whose values are not all test statuses (`passed`, `failed`, `skipped`), it is dropped. So is a kind's `complete_when` (ADR 0329): naming a field the kind does not declare or one that is no `enum`, no value, or a value the enum does not take, it is dropped and the kind's entities follow their scope's owner state. The `settings` category is checked too (ADR 0288): a setting named twice or not a dotted name or a family (`*` segments), of a type the field forms do not have, with a default its type refuses, with `gates` or `gates_when_on` (ADR 0305) on a type other than `bool` or on a family (only a setting named whole gates codes), naming a code the extension does not catalog, or gating one code both ways, or with `keys` that do not match its `*`s; a preset whose source is not an enum or bool setting of the extension or of a loaded peer, that names a value its source does not take, that sets a setting the extension does not declare to a value its type refuses, or that raises a code the extension does not catalog; a secret named twice or whose environment variable is not a name; and an item of a kind the host does not know. The `surfaces` category is checked too (ADR 0291): a prompt whose id is not snake_case or whose export is not `prompt__`, that declares an argument twice or named for something the host owns (`path`, `format`, `help`, `settings`, `secrets`, `host`, `argv`), of a type an argument does not take, a reference argument naming no loaded kind, bounds on an argument that is no integer or a default its type refuses, a gate that is not a code the extension catalogs (a command's gates too), a command that is `human` and does not `writes` (ADR 0301), a `subject` that is not an argument it declares, a `when` that is not a bool setting of the extension, or a step that names a command or prompt neither the extension nor a declared peer declares; the prompt or command is dropped whole, since a gate or an argument the host cannot read must not be ignored, and a step's `agent` (until the host knows agents) or an attribution with an empty field is dropped alone. The item is dropped, the rest of the category is kept. The host contributions are checked too (ADR 0292): an agent, skill, slash command or hook the registry refuses and drops, alone — an agent or skill id that is not kebab-case or is declared twice, a hook id that is not snake_case, a tool class outside the host-neutral vocabulary (`read`, `write`, `edit`, `shell`, `search`, `web_fetch`, `web_search`, `ask_user`, `agent`, `skill`, `todo`, `mcp:/`, or a `specforge:`, `specforge:` or `specforge:.` naming an engine tool, engine group or a command an agent may run (ADR 0334), but never on a hook), `mcp:specforge/` (SpecForge's whole server, which the `specforge:` classes name tool by tool), a `specforge:` class naming a human-attested or refused command, a `model` or `effort` outside its tiers that is not a `setting:` naming a string or enum setting of the extension, variants without a `variant_setting` (or the reverse), a `when` that is not a bool setting of the extension, a slash command that names no single prompt or command the extension declares, `tools` or `paths` on a hook of an event that takes none, a `timeout_ms` of 0 or above the ceiling (30 s, or the sandbox's), `writes` on a `statusline` hook, a hook export that is not `hook__`, an attribution with an empty field, and a prompt step whose `agent` is no agent of the extension or of a declared peer. An input the host would serve empty is W021 too (ADR 0293, ADR 0337), the call being kept: an input its call kind is not served, a collector's included, or a second one of a kind served once (`tests`, `state`, `graph`, `slash_commands`, `git`), a `setting` input naming the call's own extension or no extension and setting, and a `files` input whose name is no word or is repeated, that names neither or both of `field` and `glob`, a `field` that is not `kind.field` or that no loaded extension declares, a `root` on a glob or that is no root's name, a glob that is empty, absolute, climbs with `..`, or has more than four `**` segments, and a `text_max` that is zero, over 4 MiB or set without `text` (ADR 0390).";
W027: Warning core,
"Import binding not found",
"A selective import, `use { A, B } from \"target\"` or `pub use { A, B } from \"target\"`, names a binding the target file does not export: an entity it neither declares nor re-exports with `pub use`. A binding may be a path (`use { 03/D-01 }`). References resolve without `use`, so the binding changes nothing, but it names nothing either; a rename and a delete keep bindings in step with the entities they name (ADR 0233). Correct the binding's name, or remove it.";
@@ -743,4 +743,7 @@ catalog! {
W202: Warning core,
"Fact store renamed two ways",
"The harness ledger holds two `stale:` lines for one name a fact store holds (ADR 0346 D7): ` stale::::` and `...::`, both for the store's bytes. A rename replaces the line of the name it renames again, so one ledger never writes two; two branches that each renamed the name, merged (`specforge-harness` merges as a union of lines), do. The ledger cannot say which name the source holds now, so none of the store's renames is served: its facts read as collected, and its places as the collect read them (a file the renames rewrote is not the text they are in, W198). A rename of a name the store holds is refused (`stale_conflict`). Run `specforge collect`: it replaces the store and drops its stale lines.";
+ W203: Warning core,
+ "A collector warned of what it skipped",
+ "A collector's export read its report and answered facts, and also returned lines about entries it could not use (ADR 0389): a path outside the project, a record of no supported shape. Each line is one W203 naming the collector and its extension, escaped, at most 100 per collector and then one W203 counting the rest. The facts it did answer are kept. Read the lines and fix the report or the tool's configuration.";
}
diff --git a/crates/leaf/diagnostics/src/codebook.rs b/crates/leaf/diagnostics/src/codebook.rs
index 7ffeed9dcd..67379c5e25 100644
--- a/crates/leaf/diagnostics/src/codebook.rs
+++ b/crates/leaf/diagnostics/src/codebook.rs
@@ -24,6 +24,8 @@ pub struct ExtensionCode {
pub reported_while: Option,
/// A later step of the authoring settles a finding of it (`CodeDescriptor.settled_later`, ADR 0385).
pub settled_later: bool,
+ /// The collected fact kinds it judges (`CodeDescriptor.facts`, ADR 0389): empty for a code about authored entities.
+ pub facts: Vec,
}
/// Two loaded extensions share one code namespace.
@@ -196,6 +198,27 @@ impl Codebook {
.is_some_and(|entry| entry.settled_later)
}
+ /// Whether `code` (as it prints, `gsd.security/E101`), which `extension` reported, is a rule of `extension`'s own
+ /// about authored entities (ADR 0392): `code` is in `extension`'s namespace, `extension`'s own catalog lists it,
+ /// and that entry judges no collected fact kind (`ExtensionCode.facts`, ADR 0389). An importing command's plan
+ /// writes such an error and refuses every other: a first-party code (bare), a code no catalog of `extension`'s
+ /// lists, and one that judges a record against the facts collected from the tree, such as `code/E101` (a
+ /// reference naming no collected fact).
+ pub fn authored_rule(&self, extension: &str, code: &str) -> bool {
+ let CodeRef {
+ namespace: Some(namespace),
+ local,
+ } = CodeRef::parse(code)
+ else {
+ return false;
+ };
+ code_namespace(extension).is_some_and(|own| own.eq_ignore_ascii_case(namespace))
+ && self
+ .owned_by(extension)
+ .and_then(|owned| owned.codes.get(&local.to_uppercase()))
+ .is_some_and(|entry| entry.facts.is_empty())
+ }
+
/// Whether a finding of `code` that `extension` reports speaks on an entity whose owner is `pending` (ADR 0363):
/// always, unless the extension's own catalog entry names the owner state its findings wait for, then only in
/// that state. A first-party extension's code waits for none.
@@ -251,6 +274,30 @@ impl Codebook {
.collect()
}
+ /// The qualified codes (`code/W104`) of every namespace whose entry judges one of the collected kinds `lost` and
+ /// none of the kinds `answered` (`ExtensionCode.facts`, ADR 0389), sorted and unique: the codes no finding can speak
+ /// for when no collector answers `lost` and a collector still answers each of `answered`. A code that also judges a
+ /// kind still answered keeps judging it, so it is not one of them.
+ pub fn switched_off(&self, lost: &[String], answered: &[String]) -> Vec {
+ let mut off: Vec = self
+ .namespaces
+ .iter()
+ .flat_map(|(namespace, owned)| {
+ owned
+ .codes
+ .iter()
+ .filter(|(_, entry)| {
+ entry.facts.iter().any(|kind| lost.contains(kind))
+ && !entry.facts.iter().any(|kind| answered.contains(kind))
+ })
+ .map(move |(local, _)| format!("{namespace}/{local}"))
+ })
+ .collect();
+ off.sort();
+ off.dedup();
+ off
+ }
+
/// The level a diagnostic of `code` (as it prints: `gsd/W304`, `E001`)
/// is reported at: a static entry's catalogued level (`None` for `A###`,
/// whose pass sets it), a namespaced code's letter when its namespace's
@@ -304,6 +351,7 @@ mod tests {
machine: false,
reported_while: None,
settled_later: false,
+ facts: Vec::new(),
})
.collect();
book.add(extension, entries).unwrap();
@@ -462,6 +510,7 @@ mod tests {
machine: true,
reported_while: None,
settled_later: false,
+ facts: Vec::new(),
}],
)
.unwrap();
@@ -489,6 +538,7 @@ mod tests {
machine: false,
reported_while: Some(state.into()),
settled_later: false,
+ facts: Vec::new(),
};
book.add(
"@acme/links",
@@ -522,6 +572,7 @@ mod tests {
machine: false,
reported_while: None,
settled_later: true,
+ facts: Vec::new(),
}],
)
.unwrap();
@@ -538,6 +589,97 @@ mod tests {
);
}
+ #[test]
+ fn an_authored_rule_is_the_reporters_own_catalogued_code_judging_no_fact() {
+ let mut book = book("@gsd/security", &["E101"]);
+ book.add(
+ "@code/core",
+ vec![ExtensionCode {
+ local: "E101".into(),
+ title: "t".into(),
+ explanation: "e".into(),
+ docs: None,
+ machine: false,
+ reported_while: None,
+ settled_later: false,
+ facts: vec!["test".into()],
+ }],
+ )
+ .unwrap();
+ assert!(book.authored_rule("@gsd/security", "gsd.security/E101"));
+ assert!(
+ !book.authored_rule("@code/core", "code/E101"),
+ "it judges collected facts"
+ );
+ assert!(
+ !book.authored_rule("@gsd/security", "gsd.security/E102"),
+ "not catalogued"
+ );
+ assert!(
+ !book.authored_rule("@gsd/security", "code/E101"),
+ "another namespace's code"
+ );
+ assert!(
+ !book.authored_rule("@gsd/security", "E101"),
+ "a bare code is first party"
+ );
+ assert!(
+ !book.authored_rule("@specforge/checks", "E016"),
+ "a first-party extension's code"
+ );
+ }
+
+ #[test]
+ fn switched_off_lists_the_qualified_codes_about_a_lost_kind_sorted_and_unique() {
+ let judging = |local: &str, facts: &[&str]| ExtensionCode {
+ local: local.into(),
+ title: "t".into(),
+ explanation: "e".into(),
+ docs: None,
+ machine: false,
+ reported_while: None,
+ settled_later: false,
+ facts: facts.iter().map(|kind| kind.to_string()).collect(),
+ };
+ let mut book = Codebook::default();
+ book.add(
+ "@code/core",
+ vec![
+ judging("W105", &["static_finding"]),
+ judging("W104", &["coverage", "api_item"]),
+ judging("E101", &[]),
+ ],
+ )
+ .unwrap();
+ book.add("@acme/cov", vec![judging("W900", &["coverage"])])
+ .unwrap();
+ let kinds =
+ |kinds: &[&str]| -> Vec { kinds.iter().map(|k| k.to_string()).collect() };
+ assert_eq!(
+ book.switched_off(&kinds(&["coverage"]), &[]),
+ ["acme.cov/W900", "code/W104"]
+ );
+ assert_eq!(
+ book.switched_off(&kinds(&["coverage", "api_item"]), &[]),
+ ["acme.cov/W900", "code/W104"],
+ "a code judging two of the kinds comes once"
+ );
+ assert!(
+ book.switched_off(&kinds(&["vulnerability"]), &[])
+ .is_empty()
+ );
+ assert!(book.switched_off(&[], &[]).is_empty());
+ // W104 also judges api_item, which a collector still answers: it is still judged.
+ assert_eq!(
+ book.switched_off(&kinds(&["coverage"]), &kinds(&["api_item"])),
+ ["acme.cov/W900"]
+ );
+ assert!(
+ book.switched_off(&kinds(&["coverage"]), &kinds(&["coverage"]))
+ .is_empty()
+ );
+ }
+
#[test]
fn a_first_party_extension_owns_only_the_static_catalogs_codes_it_is_owner_of() {
let book = Codebook::default();
diff --git a/crates/leaf/diagnostics/src/tests/namespace.rs b/crates/leaf/diagnostics/src/tests/namespace.rs
index 6190e0cd13..8ee816a89c 100644
--- a/crates/leaf/diagnostics/src/tests/namespace.rs
+++ b/crates/leaf/diagnostics/src/tests/namespace.rs
@@ -61,6 +61,7 @@ fn code(local: &str) -> ExtensionCode {
machine: false,
reported_while: None,
settled_later: false,
+ facts: Vec::new(),
}
}
diff --git a/crates/leaf/protocol-types/src/calls/collect.rs b/crates/leaf/protocol-types/src/calls/collect.rs
index 51ed2e5876..73b94437bb 100644
--- a/crates/leaf/protocol-types/src/calls/collect.rs
+++ b/crates/leaf/protocol-types/src/calls/collect.rs
@@ -80,6 +80,11 @@ pub struct CollectOutput {
/// The entities the collector observed (protocol 1.15.0, ADR 0327): stored by the host, served read-only.
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub facts: Vec,
+ /// Lines the collector wants the user to read about what it read but could not use (a file outside the
+ /// project, a record skipped), each reported as W203 (protocol 2.3.0, ADR 0389). Never an error: an error is
+ /// the export's `Err`.
+ #[serde(default, skip_serializing_if = "Vec::is_empty")]
+ pub warnings: Vec,
}
/// A test the report doesn't link to an entity: its name, the name split
diff --git a/crates/leaf/protocol-types/src/code_catalog.rs b/crates/leaf/protocol-types/src/code_catalog.rs
index 75d14914f8..b4a66007f5 100644
--- a/crates/leaf/protocol-types/src/code_catalog.rs
+++ b/crates/leaf/protocol-types/src/code_catalog.rs
@@ -6,7 +6,8 @@ use serde::{Deserialize, Serialize};
/// One diagnostic code an extension reports: its local code (`E101`, never
/// qualified; the host adds the namespace), a title, what it means and how
/// to fix it, an optional absolute `http(s)` documentation URL, whether this machine decides it (2.0.0), the owner
-/// state its findings wait for (2.2.0), and whether a later step of the authoring settles its findings (2.3.0).
+/// state its findings wait for (2.2.0), whether a later step of the authoring settles its findings, and the collected
+/// kinds it judges (both 2.3.0).
#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq, Eq)]
pub struct CodeDescriptor {
pub code: String,
@@ -32,4 +33,9 @@ pub struct CodeDescriptor {
/// `check`, `--strict` and every gate read it. Serialized only when set.
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
pub settled_later: bool,
+ /// The collected fact kinds this code judges (the kinds whose facts its passes read to raise it), so a host can
+ /// say which codes cannot be judged when no collector answers those kinds (doctor, 2.3.0, ADR 0389). Empty for a
+ /// code about authored entities; serialized only when not.
+ #[serde(default, skip_serializing_if = "Vec::is_empty")]
+ pub facts: Vec,
}
diff --git a/crates/leaf/protocol-types/src/inputs.rs b/crates/leaf/protocol-types/src/inputs.rs
index e75f930ddf..e58f522ceb 100644
--- a/crates/leaf/protocol-types/src/inputs.rs
+++ b/crates/leaf/protocol-types/src/inputs.rs
@@ -157,7 +157,10 @@ impl InputKind {
/// [`FileRead`]'s fields).
const fn wire(self) -> (&'static str, &'static [&'static str]) {
match self {
- InputKind::Files => ("files", &["name", "field", "glob", "root", "text"]),
+ InputKind::Files => (
+ "files",
+ &["name", "field", "glob", "root", "text", "text_max"],
+ ),
InputKind::Tests => ("tests", &[]),
InputKind::State => ("state", &[]),
InputKind::Graph => ("graph", &[]),
diff --git a/crates/leaf/protocol-types/src/inputs/tests.rs b/crates/leaf/protocol-types/src/inputs/tests.rs
index fc4300ab88..2970d2bb22 100644
--- a/crates/leaf/protocol-types/src/inputs/tests.rs
+++ b/crates/leaf/protocol-types/src/inputs/tests.rs
@@ -11,6 +11,7 @@ fn each() -> Vec {
glob: Some("src/**".into()),
root: Some("project".into()),
text: true,
+ text_max: Some(200_000),
}),
Input::Tests,
Input::State,
diff --git a/crates/leaf/protocol-types/src/lib.rs b/crates/leaf/protocol-types/src/lib.rs
index 73d788e75f..6f2b011f27 100644
--- a/crates/leaf/protocol-types/src/lib.rs
+++ b/crates/leaf/protocol-types/src/lib.rs
@@ -110,7 +110,9 @@ pub use prompt::{
Attribution, PromptArgDescriptor, PromptDescriptor, PromptInput, PromptMessage, PromptOutput,
PromptRole, PromptStep, ServedSlash,
};
-pub use reads::{FILE_READ_MAX, FileFact, FileFacts, FileMap, FileRead};
+pub use reads::{
+ FILE_READ_MAX, FileFact, FileFacts, FileMap, FileRead, GLOB_VISITS_MAX, TEXT_MAX_CEILING_BYTES,
+};
pub use rooted::{PrefixProblem, Root, RootedPath};
pub use route::{ROUTE_START, RouteAnnotationDescriptor, RouteDescriptor, RouteStepDescriptor};
pub use settings::{
@@ -564,10 +566,35 @@ pub struct CollectorDescriptor {
/// input names one, and the only kinds whose facts the host admits from it.
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub answers: Vec,
- /// What to run to install its program, said when the program is not found on PATH (ADR 0348 D4): one printable
- /// line of at most [`INSTALL_LINE_MAX`] bytes.
+ /// What to run to install its programs, said when one is not found on PATH (ADR 0348 D4): one printable line of at
+ /// most [`INSTALL_LINE_MAX`] bytes.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub install: Option,
+ /// The other programs its command runs, beside its argv's first (`cargo-llvm-cov llvm-cov nextest` runs
+ /// `cargo-nextest`): `specforge doctor` looks each up on PATH as it does the first (protocol 2.3.0, ADR 0389 D3).
+ #[serde(default, skip_serializing_if = "Vec::is_empty")]
+ pub requires: Vec,
+}
+
+/// Whether `program` may be named in a collector's `requires`: a bare program name, non-empty, with no path separator,
+/// whitespace or control character, so doctor looks it up on PATH and nowhere else.
+pub fn is_program_name(program: &str) -> bool {
+ !program.is_empty()
+ && !program
+ .chars()
+ .any(|c| matches!(c, '/' | '\\') || c.is_whitespace() || c.is_control())
+}
+
+/// Whether `report` may be a collector's report (ADR 0389 D6): its last `/`-separated segment is a literal file name,
+/// so a glob names the files one tool writes (`**/rust-sbom.cdx.json`) and never every file of a kind (`**/*.pem`).
+pub fn is_report_name(report: &str) -> bool {
+ !is_wild(report.rsplit('/').next().unwrap_or_default())
+}
+
+/// Whether one `/`-separated segment of a declared glob (a file read's, a report's) is a wildcard: it holds `*` or
+/// `?`. The host's walks and the declaration checks read a glob through this one predicate.
+pub fn is_wild(segment: &str) -> bool {
+ segment.contains(['*', '?'])
}
/// The most bytes a collector's install line holds.
diff --git a/crates/leaf/protocol-types/src/reads.rs b/crates/leaf/protocol-types/src/reads.rs
index 23766c43b9..7026bd1f96 100644
--- a/crates/leaf/protocol-types/src/reads.rs
+++ b/crates/leaf/protocol-types/src/reads.rs
@@ -9,7 +9,8 @@ use serde::{Deserialize, Serialize};
/// under `name` in the input's `files`.
///
/// Exactly one of `field` and `glob` names the files; a read that names neither or both, a `name` that is no word or
-/// repeats, or a `root` on a glob is W021 and served empty.
+/// repeats, a `root` on a glob, or a `text_max` that is zero, over [`TEXT_MAX_CEILING_BYTES`] or without `text` is W021
+/// and served empty.
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct FileRead {
/// The key of this read in the input's `files`: a word `[a-z][a-z0-9_]*`, unique among the owner's reads.
@@ -28,21 +29,33 @@ pub struct FileRead {
/// root's costs the read, not the declaration.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub root: Option,
- /// Send each file's text (UTF-8, at most 64 KiB) as well as its facts.
+ /// Send each file's text (UTF-8, at most 64 KiB, or `text_max`) as well as its facts.
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
pub text: bool,
+ /// The most text of one file this read sends, in bytes, instead of 64 KiB; at most 4 MiB, and only with `text`
+ /// (protocol 2.3.0). The read's text budget is then the larger of 1 MiB and four times it.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub text_max: Option,
}
/// The most files one [`FileRead`] names: past it the host reads that many and says [`FileFacts::truncated`].
pub const FILE_READ_MAX: usize = 2000;
+/// The most entries (files and directories, matched or not) the walk of one glob visits: past it the walk stops and
+/// the host says [`FileFacts::truncated`], whatever it matched so far.
+pub const GLOB_VISITS_MAX: usize = 20_000;
+
+/// The largest [`FileRead::text_max`] (4 MiB): the registry refuses a larger one (W021) and the host never sends more.
+pub const TEXT_MAX_CEILING_BYTES: u32 = 4 * 1024 * 1024;
+
/// What the host read for one [`FileRead`].
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct FileFacts {
/// One per (entity, path), sorted by `(entity, path)`; a glob's by `path`.
#[serde(default)]
pub facts: Vec,
- /// The glob matched more files than the host reads ([`FILE_READ_MAX`]).
+ /// The read stopped early: it named more files than the host reads ([`FILE_READ_MAX`]), or its glob's walk
+ /// reached [`GLOB_VISITS_MAX`] entries. The guest cannot tell which.
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
pub truncated: bool,
}
diff --git a/crates/leaf/protocol-types/src/surface.rs b/crates/leaf/protocol-types/src/surface.rs
index a5d4e3ebcb..d465ddee56 100644
--- a/crates/leaf/protocol-types/src/surface.rs
+++ b/crates/leaf/protocol-types/src/surface.rs
@@ -45,6 +45,11 @@ pub struct CommandDescriptor {
/// Records what a person says: the host runs it only for a person at a terminal (protocol 1.12.0, ADR 0301).
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
pub human: bool,
+ /// Imports what was recorded outside the spec: the host writes an error its plan adds only when the code is in the
+ /// reporting extension's own namespace and own catalog and declares no `facts`, and refuses a host, `@specforge/*`,
+ /// fact-judging or uncatalogued code (protocol 2.3.0, ADR 0392).
+ #[serde(default, skip_serializing_if = "std::ops::Not::not")]
+ pub imports: bool,
/// Local codes of the extension: the command is refused (`gate_failed`) while one fails in the `subject`'s scope
/// (protocol 1.10.0, ADR 0291).
#[serde(default, skip_serializing_if = "Vec::is_empty")]
diff --git a/crates/leaf/protocol-types/src/version.rs b/crates/leaf/protocol-types/src/version.rs
index 9e9cedc24e..0f4c8b4d6b 100644
--- a/crates/leaf/protocol-types/src/version.rs
+++ b/crates/leaf/protocol-types/src/version.rs
@@ -84,6 +84,14 @@
/// does not change.
/// - a pass entity carries `title` ([`PassEntity::title`](crate::PassEntity::title), ADR 0387), the title its header
/// writes, as a command's graph node does; absent for a fact written without one.
+/// - a collector may declare `requires`, the other programs its command runs beside its argv's first, which
+/// `specforge doctor` looks up on PATH (ADR 0389 D3); absent when empty.
+/// - a file read may declare `text_max` with `text` ([`FileRead::text_max`](crate::FileRead::text_max), ADR 0390
+/// D3): the most text of one file it is sent, in bytes, instead of 64 KiB, at most 4 MiB; its text budget is then
+/// the larger of 1 MiB and four times it. Zero, over 4 MiB or without `text` is W021 and served empty.
+/// - a command may declare `imports` ([`CommandDescriptor::imports`](crate::CommandDescriptor::imports), ADR 0392):
+/// it imports what was recorded outside the spec, so the host writes a third-party extension's error its plan adds
+/// and refuses a first-party one (E016 included); it must `writes`, else W021.
///
/// A 2.2.0 guest still loads; a 2.3.0 guest is refused by a 2.2 host (E088, newer).
///
diff --git a/crates/leaf/protocol-types/tests/calls_roundtrip.rs b/crates/leaf/protocol-types/tests/calls_roundtrip.rs
index eb2831b471..f29f19157b 100644
--- a/crates/leaf/protocol-types/tests/calls_roundtrip.rs
+++ b/crates/leaf/protocol-types/tests/calls_roundtrip.rs
@@ -309,6 +309,21 @@ fn collect_output_with_facts_round_trips_and_omits_an_empty_list() {
assert!(empty.get("facts").is_none(), "{empty}");
}
+#[test]
+fn collect_output_warnings_round_trip_and_an_empty_list_is_off_the_wire() {
+ use specforge_protocol_types::CollectOutput;
+
+ let answer = json!({"entity_results": [], "warnings": ["skipped 1 file outside the project: /elsewhere/a.rs"]});
+ let output: CollectOutput = round_trips(&answer);
+ assert_eq!(
+ output.warnings,
+ ["skipped 1 file outside the project: /elsewhere/a.rs"]
+ );
+
+ let empty = serde_json::to_value(CollectOutput::default()).unwrap();
+ assert!(empty.get("warnings").is_none(), "{empty}");
+}
+
#[test]
fn a_pass_entity_carries_pending_and_its_unheld_spans_and_omits_them_when_absent() {
use specforge_protocol_types::PassEntity;
diff --git a/crates/leaf/protocol-types/tests/declaration.rs b/crates/leaf/protocol-types/tests/declaration.rs
index 121402e1ea..ef9d64384f 100644
--- a/crates/leaf/protocol-types/tests/declaration.rs
+++ b/crates/leaf/protocol-types/tests/declaration.rs
@@ -115,6 +115,7 @@ fn full() -> ExtensionDeclaration {
machine: true,
reported_while: Some("complete".to_string()),
settled_later: true,
+ facts: vec!["coverage".to_string()],
},
CodeDescriptor {
code: "R002".to_string(),
@@ -502,6 +503,8 @@ fn codes_round_trip_on_the_wire() {
assert!(items[1].get("docs").is_none(), "{}", items[1]);
assert_eq!(items[0]["settled_later"], true);
assert!(items[1].get("settled_later").is_none(), "{}", items[1]);
+ assert_eq!(items[0]["facts"], serde_json::json!(["coverage"]));
+ assert!(items[1].get("facts").is_none(), "{}", items[1]);
assert!(declared.declares(DeclaredCategory::Codes));
let loaded = ExtensionDeclaration::from_wire(
declared.handshake.clone(),
diff --git a/crates/pipeline/registry/src/collectors.rs b/crates/pipeline/registry/src/collectors.rs
index e6835db730..a82a99951a 100644
--- a/crates/pipeline/registry/src/collectors.rs
+++ b/crates/pipeline/registry/src/collectors.rs
@@ -116,6 +116,7 @@ mod tests {
},
answers: answers.iter().map(ToString::to_string).collect(),
install: None,
+ requires: Vec::new(),
}
}
diff --git a/crates/pipeline/registry/src/compilation/capabilities.rs b/crates/pipeline/registry/src/compilation/capabilities.rs
index cb1dd845ca..fb0488cb38 100644
--- a/crates/pipeline/registry/src/compilation/capabilities.rs
+++ b/crates/pipeline/registry/src/compilation/capabilities.rs
@@ -3,11 +3,12 @@
use specforge_protocol_types::{
ExtensionDeclaration, INSTALL_LINE_MAX, Owner, capability_problems, is_install_line,
+ is_program_name,
};
/// The messages (W021) about the capabilities `declaration` makes, and about its collectors' `capability`: a
-/// collector that keeps a `capture` with no command has no output to keep (ADR 0345 D2), and an install line must be
-/// one printable line (ADR 0348 D4).
+/// collector that keeps a `capture` with no command has no output to keep (ADR 0345 D2), an install line must be
+/// one printable line (ADR 0348 D4), and a `requires` program a bare program name (ADR 0389 D3).
pub(crate) fn problems(declaration: &ExtensionDeclaration) -> Vec {
let name = declaration.name();
let uncaptured = declaration
@@ -44,5 +45,19 @@ pub(crate) fn problems(declaration: &ExtensionDeclaration) -> Vec {
)
})
}))
+ .chain(declaration.collectors.iter().flat_map(move |collector| {
+ collector
+ .requires
+ .iter()
+ .filter(|program| !is_program_name(program))
+ .map(move |program| {
+ format!(
+ "extension '{name}': collector '{}': its `requires` program '{}' is no bare program name \
+ (non-empty, no path separator, whitespace or control character)",
+ collector.name,
+ program.escape_debug()
+ )
+ })
+ }))
.collect()
}
diff --git a/crates/pipeline/registry/src/compilation/codes.rs b/crates/pipeline/registry/src/compilation/codes.rs
index 29472b7764..cdda57aed1 100644
--- a/crates/pipeline/registry/src/compilation/codes.rs
+++ b/crates/pipeline/registry/src/compilation/codes.rs
@@ -53,6 +53,7 @@ pub fn extension_codes(declaration: &ExtensionDeclaration) -> Vec
machine: entry.machine,
reported_while: entry.reported_while.clone(),
settled_later: entry.settled_later,
+ facts: entry.facts.clone(),
})
.collect()
}
diff --git a/crates/pipeline/registry/src/compilation/declaration.rs b/crates/pipeline/registry/src/compilation/declaration.rs
index 920962282b..aada868c01 100644
--- a/crates/pipeline/registry/src/compilation/declaration.rs
+++ b/crates/pipeline/registry/src/compilation/declaration.rs
@@ -9,7 +9,8 @@ use std::collections::{HashMap, HashSet, VecDeque};
use specforge_common::{Diagnostic, codes};
use specforge_diagnostics::is_local_code;
use specforge_protocol_types::{
- CompilerPassDescriptor, ExtensionDeclaration, FieldDescriptor, FieldType, is_valid_short,
+ CompilerPassDescriptor, ExtensionDeclaration, FieldDescriptor, FieldType, is_report_name,
+ is_valid_short,
};
use super::populate::keyword;
@@ -20,7 +21,8 @@ fn e030(message: String) -> Diagnostic {
/// E030: a declaration the host cannot use as declared: an empty name or
/// version, an `ext_short` that is not lowercase kebab case (it names a CLI
-/// subcommand and an MCP tool prefix), or a malformed `codes` entry.
+/// subcommand and an MCP tool prefix), a malformed `codes` entry, or a
+/// collector report glob that does not end in a literal file name (ADR 0389 D6).
pub(crate) fn shape(declaration: &ExtensionDeclaration) -> Vec {
let name = declaration.name();
let mut diagnostics = Vec::new();
@@ -43,6 +45,19 @@ pub(crate) fn shape(declaration: &ExtensionDeclaration) -> Vec {
);
}
diagnostics.extend(code_entries(declaration));
+ for collector in &declaration.collectors {
+ if let Some(report) = collector
+ .report
+ .as_deref()
+ .filter(|report| !is_report_name(report))
+ {
+ diagnostics.push(e030(format!(
+ "extension '{name}': collector '{}' declares the report '{report}': a report glob must end in a \
+ literal file name, so it names the files one tool writes",
+ collector.name
+ )));
+ }
+ }
diagnostics
}
diff --git a/crates/pipeline/registry/src/inputs.rs b/crates/pipeline/registry/src/inputs.rs
index c6c54ebc26..e2a7051750 100644
--- a/crates/pipeline/registry/src/inputs.rs
+++ b/crates/pipeline/registry/src/inputs.rs
@@ -6,7 +6,7 @@ use std::collections::HashSet;
use specforge_common::structural::NODE_KINDS;
use specforge_protocol_types::{
- ExtensionDeclaration, FieldWriter, FileRead, Input, InputKind, Root,
+ ExtensionDeclaration, FieldWriter, FileRead, Input, InputKind, Root, TEXT_MAX_CEILING_BYTES,
};
use crate::compilation::UnloadedPeers;
@@ -43,8 +43,9 @@ pub fn served(kind: CallKind, input: &Input) -> bool {
/// Why `read` cannot be served as declared, or `None` when its shape is sound: a name that is no word, neither or both
/// of `field` and `glob`, a field that is not `kind.field`, a glob that is absolute, climbs with `..`, has an empty
-/// segment or more than [`MAX_DOUBLE_STAR`] `**` segments, `root` on a glob, or a `root` that is no root's name. A name repeated in an owner's reads is
-/// [`problems`]'.
+/// segment or more than [`MAX_DOUBLE_STAR`] `**` segments, `root` on a glob, a `root` that is no root's name, or a
+/// `text_max` that is zero, over [`TEXT_MAX_CEILING_BYTES`] or set without `text`. A name repeated in an owner's
+/// reads is [`problems`]'.
pub fn read_problem(read: &FileRead) -> Option {
if !is_word(&read.name) {
return Some(format!(
@@ -52,6 +53,18 @@ pub fn read_problem(read: &FileRead) -> Option {
read.name
));
}
+ match read.text_max {
+ Some(0) => return Some("its text_max is zero".to_string()),
+ Some(max) if max > TEXT_MAX_CEILING_BYTES => {
+ return Some(format!(
+ "its text_max {max} is over 4 MiB ({TEXT_MAX_CEILING_BYTES} bytes)"
+ ));
+ }
+ Some(_) if !read.text => {
+ return Some("it sets `text_max` but asks for no text".to_string());
+ }
+ _ => {}
+ }
match (&read.field, &read.glob) {
(None, None) => Some("it names neither a `field` nor a `glob`".to_string()),
(Some(_), Some(_)) => Some("it names both a `field` and a `glob`".to_string()),
@@ -556,4 +569,31 @@ mod tests {
]
);
}
+
+ /// A read's `text_max` is a positive size of at most 4 MiB, and only with `text` (ADR 0390 D3).
+ #[test]
+ fn a_text_max_that_is_zero_too_large_or_without_text_is_a_problem() {
+ let read = |text: bool, text_max: u32| FileRead {
+ name: "report".into(),
+ glob: Some("etc/*.api.md".into()),
+ text,
+ text_max: Some(text_max),
+ ..FileRead::default()
+ };
+ assert_eq!(
+ read_problem(&read(true, 0)).as_deref(),
+ Some("its text_max is zero")
+ );
+ assert_eq!(
+ read_problem(&read(true, 5_000_000)).as_deref(),
+ Some("its text_max 5000000 is over 4 MiB (4194304 bytes)")
+ );
+ assert_eq!(
+ read_problem(&read(false, 200_000)).as_deref(),
+ Some("it sets `text_max` but asks for no text")
+ );
+ for fine in [1, 200_000, TEXT_MAX_CEILING_BYTES] {
+ assert_eq!(read_problem(&read(true, fine)), None, "{fine}");
+ }
+ }
}
diff --git a/crates/pipeline/registry/src/surface/prompts.rs b/crates/pipeline/registry/src/surface/prompts.rs
index dc3c56dc01..6ac8e282a7 100644
--- a/crates/pipeline/registry/src/surface/prompts.rs
+++ b/crates/pipeline/registry/src/surface/prompts.rs
@@ -148,6 +148,9 @@ impl Ctx<'_> {
if command.human && !command.writes {
return Err("it is human and does not write".to_string());
}
+ if command.imports && !command.writes {
+ return Err("it imports and does not write".to_string());
+ }
self.gates(&command.gates)?;
if let Some(subject) = &command.subject {
let takes_entity = command
diff --git a/crates/pipeline/registry/tests/build/namespaces.rs b/crates/pipeline/registry/tests/build/namespaces.rs
index 5770ff98b3..73e517cf3a 100644
--- a/crates/pipeline/registry/tests/build/namespaces.rs
+++ b/crates/pipeline/registry/tests/build/namespaces.rs
@@ -114,3 +114,26 @@ fn a_settled_later_code_reaches_the_code_book_and_no_e030() {
assert!(book.settled_later("@acme/plans", "E301"));
assert!(!book.settled_later("@acme/plans", "E302"));
}
+
+/// A code naming the collected kinds it judges (ADR 0389): the code book lists it by kind, qualified.
+#[spec(requirement = "FEATURE-028")]
+fn a_code_naming_the_kinds_it_judges_reaches_the_code_book() {
+ let reports = declare("@acme/reports", |c| {
+ c.code("W104", |d| {
+ d.title("Report entry on no item")
+ .explanation("Serve the item.")
+ .facts(&["coverage"]);
+ });
+ c.code("W105", |d| {
+ d.title("Plain").explanation("About authored entities.");
+ });
+ });
+ let build = build([reports]);
+ assert!(coded(&build, "E030").is_empty(), "{:?}", codes(&build));
+ let book = build.codes();
+ assert_eq!(
+ book.switched_off(&["coverage".into()], &[]),
+ ["acme.reports/W104"]
+ );
+ assert!(book.switched_off(&["api_item".into()], &[]).is_empty());
+}
diff --git a/crates/pipeline/registry/tests/declarations.rs b/crates/pipeline/registry/tests/declarations.rs
index e07f0aba8c..0b842bf39f 100644
--- a/crates/pipeline/registry/tests/declarations.rs
+++ b/crates/pipeline/registry/tests/declarations.rs
@@ -57,6 +57,35 @@ fn a_malformed_short_name_is_e030() {
);
}
+#[specforge_test_macros::test(requirement = "FEATURE-028")]
+fn a_report_glob_ending_in_a_wildcard_is_e030() {
+ let mut c = declaration("@acme/reports", "1.0.0");
+ for name in ["keys", "secrets", "sbom"] {
+ c.collector(name, |k| {
+ k.report("**/sbom.cdx.json")
+ .collect(|_| Ok(CollectOutput::default()));
+ });
+ }
+ let mut bad = c.declaration();
+ // A raw declaration can carry any report; the SDK refuses one at build.
+ bad.collectors[0].report = Some("**/*.pem".to_string());
+ bad.collectors[1].report = Some("config/.env?".to_string());
+ let build = build_registries(vec![bad]);
+ assert_eq!(codes(&build), ["E030", "E030"]);
+ let messages: Vec<&str> = diagnostics(&build)
+ .iter()
+ .map(|d| d.message.as_str())
+ .collect();
+ assert!(
+ messages[0].contains("collector 'keys' declares the report '**/*.pem'"),
+ "{messages:?}"
+ );
+ assert!(
+ messages[1].contains("collector 'secrets' declares the report 'config/.env?'"),
+ "{messages:?}"
+ );
+}
+
fn with_peer(name: &str, peer: &str, range: &str, optional: bool) -> ExtensionDeclaration {
let mut c = ContributionsBuilder::new(ExtensionMeta::new(name, "1.0.0"));
c.meta.peer_dependencies.push(PeerDependency {
@@ -604,6 +633,25 @@ fn capabilities_with_a_config_that_is_not_sound_are_w021() {
assert_eq!(found.len(), expect.len(), "{found:#?}");
}
+#[specforge_test_macros::test(requirement = "FEATURE-028")]
+fn a_required_program_that_is_no_bare_name_is_w021() {
+ let found = capability_problems_of(|c| {
+ c.collector("cov", |k| {
+ k.requires(&["cargo-nextest", "", "bin/tool", "two words"])
+ .collect(|_| Ok(CollectOutput::default()));
+ });
+ });
+ assert_eq!(found.len(), 3, "{found:#?}");
+ for named in ["''", "'bin/tool'", "'two words'"] {
+ assert!(
+ found
+ .iter()
+ .any(|m| m.contains(&format!("`requires` program {named}"))),
+ "{named} in {found:#?}"
+ );
+ }
+}
+
#[specforge_test_macros::test(requirement = "FEATURE-028")]
fn a_collector_capture_without_a_command_is_w021() {
let found = capability_problems_of(|c| {
diff --git a/crates/pipeline/registry/tests/prompts.rs b/crates/pipeline/registry/tests/prompts.rs
index d2175995c5..7e95e54c5b 100644
--- a/crates/pipeline/registry/tests/prompts.rs
+++ b/crates/pipeline/registry/tests/prompts.rs
@@ -111,21 +111,33 @@ fn a_prompt_declaration_the_registry_refuses_is_w021() {
}
#[specforge_test(requirement = "FEATURE-131")]
-fn a_human_command_that_does_not_write_is_dropped() {
+fn a_human_or_importing_command_that_does_not_write_is_dropped() {
let mut mute = command("attest");
mute["human"] = json!(true);
let mut writing = command("confirm");
writing["human"] = json!(true);
writing["writes"] = json!(true);
+ // An import that does not write is dropped the same way (ADR 0392).
+ let mut reader = command("read");
+ reader["imports"] = json!(true);
+ let mut importing = command("import");
+ importing["imports"] = json!(true);
+ importing["writes"] = json!(true);
let build = build_registries(vec![declaration(
"@t/core",
"t",
- json!({"surfaces": {"commands": [mute, writing]}}),
+ json!({"surfaces": {"commands": [mute, writing, reader, importing]}}),
)]);
let w021 = messages(&build, "W021");
- assert_eq!(w021.len(), 1, "{w021:#?}");
+ assert_eq!(w021.len(), 2, "{w021:#?}");
+ assert!(
+ w021.iter()
+ .any(|m| m.contains("'attest'") && m.contains("human and does not write")),
+ "{w021:#?}"
+ );
assert!(
- w021[0].contains("'attest'") && w021[0].contains("human and does not write"),
+ w021.iter()
+ .any(|m| m.contains("'read'") && m.contains("imports and does not write")),
"{w021:#?}"
);
let routed: Vec<_> = build
@@ -134,7 +146,7 @@ fn a_human_command_that_does_not_write_is_dropped() {
.iter()
.map(|r| r.declaration().id.clone())
.collect();
- assert_eq!(routed, ["confirm"]);
+ assert_eq!(routed, ["confirm", "import"]);
}
#[specforge_test(requirement = "FEATURE-125")]
diff --git a/crates/pipeline/registry/tests/rules/mod.rs b/crates/pipeline/registry/tests/rules/mod.rs
index a7d49e8f96..16279209e1 100644
--- a/crates/pipeline/registry/tests/rules/mod.rs
+++ b/crates/pipeline/registry/tests/rules/mod.rs
@@ -90,6 +90,7 @@ fn catalog_of(rules: &[ValidationRuleDescriptor]) -> Vec ExtensionD
machine: false,
reported_while: None,
settled_later: false,
+ facts: Vec::new(),
});
}
}
diff --git a/crates/runtime/component/data/builtin-vocabulary.json b/crates/runtime/component/data/builtin-vocabulary.json
index 10bb266efb..385f5e5942 100644
--- a/crates/runtime/component/data/builtin-vocabulary.json
+++ b/crates/runtime/component/data/builtin-vocabulary.json
@@ -1,6 +1,9 @@
{
"$comment": "Generated by `cargo run -p xtask --bin revendor` from the builtins' pinned declarations (ADR 0122, ADR 0369). Do not edit.",
"kinds": {
+ "api_item": [
+ "@code/core"
+ ],
"artifact": [
"@gsd/core"
],
@@ -34,6 +37,9 @@
"context": [
"@gsd/core"
],
+ "coverage": [
+ "@code/core"
+ ],
"decision": [
"@gsd/core",
"@specforge/governance"
@@ -45,6 +51,9 @@
"@gsd/core",
"@specforge/product"
],
+ "dependency": [
+ "@code/core"
+ ],
"deviation": [
"@gsd/core"
],
@@ -208,6 +217,9 @@
"stack_choice": [
"@gsd/core"
],
+ "static_finding": [
+ "@code/core"
+ ],
"summary": [
"@gsd/core"
],
@@ -253,6 +265,9 @@
"verify_gap": [
"@gsd/core"
],
+ "vulnerability": [
+ "@code/core"
+ ],
"wave0_item": [
"@gsd/core"
],
diff --git a/crates/runtime/component/src/builtins.rs b/crates/runtime/component/src/builtins.rs
index 0f2214be03..0db64a85c4 100644
--- a/crates/runtime/component/src/builtins.rs
+++ b/crates/runtime/component/src/builtins.rs
@@ -6,12 +6,12 @@ use specforge_wasm::{LoadError, Provenance, WasmRuntime};
/// One builtin extension: its package name, its crate, the component `build-blobs` vendors into
/// `/wasm/`, and the vendored bytes this host embeds. Name and crate follow one rule:
/// `extensions/` is `@specforge/`, and `extensions//` is `@/`
-/// (ADR 0328 D3). One crate lives outside `extensions/` and is named in its row: `@gsd/core` at
-/// `gsd/core`, in the gsd workspace (ADR 0366 D1).
+/// (ADR 0328 D3). Two crates live outside `extensions/` and are named in their rows: `@gsd/core` at
+/// `gsd/core` and `@gsd/import` at `gsd/import`, both in the gsd workspace (ADR 0366 D1, ADR 0391 D12).
pub struct Builtin {
pub name: &'static str,
/// Its crate, from the repository root: `extensions/`, `extensions//`, or
- /// the path a named row gives (`gsd/core`).
+ /// the path a named row gives (`gsd/core`, `gsd/import`).
pub crate_dir: &'static str,
pub artifact: &'static str,
pub bytes: &'static [u8],
@@ -53,8 +53,21 @@ builtins! {
"@rust/cargo" in "rust/cargo" as "specforge_ext_rust_cargo.wasm",
"@rust/source" in "rust/source" as "specforge_ext_rust_source.wasm",
"@rust/test" in "rust/test" as "specforge_ext_rust_test.wasm",
- "@javascript/source" in "javascript/source" as "specforge_ext_javascript_source.wasm";
+ "@javascript/source" in "javascript/source" as "specforge_ext_javascript_source.wasm",
+ "@rust/coverage" in "rust/coverage" as "specforge_ext_rust_coverage.wasm",
+ "@rust/lint" in "rust/lint" as "specforge_ext_rust_lint.wasm",
+ "@rust/deps" in "rust/deps" as "specforge_ext_rust_deps.wasm",
+ "@rust/api" in "rust/api" as "specforge_ext_rust_api.wasm",
+ "@rust/proof" in "rust/proof" as "specforge_ext_rust_proof.wasm",
+ "@javascript/coverage" in "javascript/coverage" as "specforge_ext_javascript_coverage.wasm",
+ "@javascript/lint" in "javascript/lint" as "specforge_ext_javascript_lint.wasm",
+ "@javascript/deps" in "javascript/deps" as "specforge_ext_javascript_deps.wasm",
+ "@javascript/api" in "javascript/api" as "specforge_ext_javascript_api.wasm",
+ "@javascript/vitest" in "javascript/vitest" as "specforge_ext_javascript_vitest.wasm",
+ "@javascript/jest" in "javascript/jest" as "specforge_ext_javascript_jest.wasm",
+ "@javascript/playwright" in "javascript/playwright" as "specforge_ext_javascript_playwright.wasm";
"@gsd/core" at "gsd/core" as "gsd_core.wasm",
+ "@gsd/import" at "gsd/import" as "gsd_import.wasm",
}
/// (name, bytes) of every builtin, read from [`BUILTINS`]: what the extension load reads
@@ -114,7 +127,7 @@ pub fn load_builtins(runtime: &dyn WasmRuntime) -> Result<(), LoadError> {
#[cfg(feature = "testing")]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Family {
- /// The fourteen builtins of the `@specforge/*` starter set and what they load with.
+ /// The twenty-six builtins of the `@specforge/*` starter set and what they load with.
Old,
/// `@gsd/core` with its peers and the collectors that need `@code/core`.
Gsd,
@@ -126,7 +139,8 @@ impl Family {
pub const ALL: [Family; 2] = [Family::Old, Family::Gsd];
/// The names of the set, as ADR 0369 D3 lists them. The old set is in [`BUILTINS`] order; the gsd
- /// set names `@gsd/core` first, then the seven builtins it shares with the old set.
+ /// set names `@gsd/core` and `@gsd/import` first, then the nineteen builtins it shares with the old set
+ /// (`@specforge/vitest` stays in the old set only).
pub const fn names(self) -> &'static [&'static str] {
match self {
Family::Old => &[
@@ -144,9 +158,22 @@ impl Family {
"@rust/source",
"@rust/test",
"@javascript/source",
+ "@rust/coverage",
+ "@rust/lint",
+ "@rust/deps",
+ "@rust/api",
+ "@rust/proof",
+ "@javascript/coverage",
+ "@javascript/lint",
+ "@javascript/deps",
+ "@javascript/api",
+ "@javascript/vitest",
+ "@javascript/jest",
+ "@javascript/playwright",
],
Family::Gsd => &[
"@gsd/core",
+ "@gsd/import",
"@code/core",
"@javascript/node-test",
"@specforge/checks",
@@ -154,6 +181,18 @@ impl Family {
"@rust/source",
"@rust/test",
"@javascript/source",
+ "@rust/coverage",
+ "@rust/lint",
+ "@rust/deps",
+ "@rust/api",
+ "@rust/proof",
+ "@javascript/coverage",
+ "@javascript/lint",
+ "@javascript/deps",
+ "@javascript/api",
+ "@javascript/vitest",
+ "@javascript/jest",
+ "@javascript/playwright",
],
}
}
diff --git a/crates/runtime/component/tests/blob_size.rs b/crates/runtime/component/tests/blob_size.rs
index bcbbb66c0c..4c4d7adb66 100644
--- a/crates/runtime/component/tests/blob_size.rs
+++ b/crates/runtime/component/tests/blob_size.rs
@@ -9,13 +9,14 @@
use specforge_component::builtins::BUILTINS;
use specforge_component::committed::COMMITTED;
-// The fifteen builtins total 18,033,150 B, the sum of the `.wasm` files `revendor` commits (built with
-// `--profile blob` on the pinned rustc): the fourteen under `extensions/` 12,304,701 B, the largest of them
-// `@specforge/checks` at 2,452,015 B, and `gsd/core/wasm/gsd_core.wasm` 5,728,449 B, the one blob over the gate's cap,
-// held to its own allowance (ADR 0366 D3). The budget is that total rounded up to the next 100,000 B, here 18,100,000
-// (66,850 B of headroom): a change that grows the blobs past it re-measures and takes the rule's next step in the same
-// commit (ADR 0373 D3). A build without the profile is far larger, so this catches a profile regression.
-const TOTAL_BUDGET: usize = 18_100_000;
+// The twenty-eight builtins total 27,991,688 B, the sum of the `.wasm` files `revendor` commits (built with
+// `--profile blob` on the pinned rustc): the twenty-six under `extensions/` 20,687,816 B, the largest of them
+// `@specforge/checks` at 2,454,208 B, `gsd/core/wasm/gsd_core.wasm` 5,759,902 B, the one blob over the gate's cap,
+// held to its own allowance (ADR 0366 D3), and `gsd/import/wasm/gsd_import.wasm` 1,543,970 B (ADR 0391 D12). The
+// budget is that total rounded up to the next 100,000 B, here 28,000,000 (8,312 B of headroom): a change that grows
+// the blobs past it re-measures and takes the rule's next step in the same commit (ADR 0373 D3). A build without the
+// profile is far larger, so this catches a profile regression.
+const TOTAL_BUDGET: usize = 28_000_000;
#[test]
fn committed_builtins_stay_under_their_size_budget() {
diff --git a/crates/runtime/component/tests/builtin_codes.rs b/crates/runtime/component/tests/builtin_codes.rs
index 5652bd58e6..4c95b169fb 100644
--- a/crates/runtime/component/tests/builtin_codes.rs
+++ b/crates/runtime/component/tests/builtin_codes.rs
@@ -82,6 +82,56 @@ fn builtin_rules_use_their_own_codes() {
);
}
+/// Every `@gsd/core` error code that an importing command's plan writes rather than refuses (ADR 0392): all of them,
+/// as none declares `facts`. `E533` and `E535` read API and package facts but judge a closed milestone's claim, which
+/// is history, so they land too (ADR 0392, Limits).
+const GSD_CORE_LANDS: &[&str] = &[
+ "E101", "E102", "E105", "E106", "E107", "E108", "E201", "E202", "E206", "E301", "E302", "E303",
+ "E307", "E310", "E312", "E314", "E319", "E320", "E322", "E401", "E402", "E405", "E501", "E502",
+ "E503", "E505", "E507", "E509", "E511", "E512", "E513", "E515", "E516", "E517", "E518", "E521",
+ "E523", "E533", "E535",
+];
+
+#[specforge_test_macros::test(requirement = "FEATURE-131")]
+fn the_gsd_core_errors_an_import_lands_are_pinned() {
+ let name = "@gsd/core";
+ let (_, bytes) = BUILTIN_EXTENSIONS
+ .iter()
+ .find(|(builtin, _)| *builtin == name)
+ .expect("@gsd/core is a builtin");
+ let runtime = ComponentRuntime::new();
+ runtime
+ .load(name, bytes, specforge_wasm::Provenance::third_party(bytes))
+ .expect("builtin loads");
+ let declaration = load_declaration(&runtime, name)
+ .expect("builtin declares itself")
+ .declaration;
+ // The vendored blob read as the registry build reads it, so the pin follows what the host judges.
+ let codes = specforge_registry::extension_codes(&declaration);
+ let errors: Vec = codes
+ .iter()
+ .filter(|code| code.local.starts_with('E'))
+ .map(|code| code.local.clone())
+ .collect();
+ let mut book = Codebook::default();
+ book.add(name, codes).unwrap();
+ let (mut lands, mut refused): (Vec<&str>, Vec<&str>) = errors
+ .iter()
+ .map(String::as_str)
+ .partition(|local| book.authored_rule(name, &format!("gsd/{local}")));
+ lands.sort_unstable();
+ refused.sort_unstable();
+ assert!(
+ refused.is_empty(),
+ "these @gsd/core errors now refuse an import (their catalog entry declares `facts`, ADR 0392); \
+ if that is meant, amend ADR 0392's Limits and this pin: {refused:?}"
+ );
+ assert_eq!(
+ lands, GSD_CORE_LANDS,
+ "the @gsd/core errors an import lands changed: update GSD_CORE_LANDS (ADR 0392)"
+ );
+}
+
#[specforge_test_macros::test(requirement = "FEATURE-007")]
fn the_checks_switches_gate_codes_the_catalog_gives_checks() {
let runtime = ComponentRuntime::new();
diff --git a/crates/runtime/component/tests/builtins_table.rs b/crates/runtime/component/tests/builtins_table.rs
index 1b8844122b..12be85c797 100644
--- a/crates/runtime/component/tests/builtins_table.rs
+++ b/crates/runtime/component/tests/builtins_table.rs
@@ -159,9 +159,11 @@ fn layout(root: &Path) -> Layout {
fn the_table_is_the_extensions_directory_by_the_naming_rule() {
let on_disk = layout(specforge_repo_root::repo_root());
assert!(on_disk.problems.is_empty(), "{:#?}", on_disk.problems);
- // The one builtin outside `extensions/`, named in its row (ADR 0366 D1); every other row is the rule's.
+ // The two builtins outside `extensions/`, named in their rows (ADR 0366 D1, ADR 0391 D12); every
+ // other row is the rule's.
let mut expected = on_disk.builtins;
expected.push(Named::new("gsd/core", "@gsd/core", "gsd_core.wasm"));
+ expected.push(Named::new("gsd/import", "@gsd/import", "gsd_import.wasm"));
expected.sort();
let mut listed: Vec = BUILTINS
.iter()
@@ -170,7 +172,7 @@ fn the_table_is_the_extensions_directory_by_the_naming_rule() {
listed.sort();
assert_eq!(
listed, expected,
- "BUILTINS lists every builtin crate under extensions/, once, named by the rule, and @gsd/core at gsd/core"
+ "BUILTINS lists every builtin crate under extensions/, once, named by the rule, @gsd/core at gsd/core and @gsd/import at gsd/import"
);
for builtin in BUILTINS {
assert!(
diff --git a/crates/runtime/component/tests/declarations/code_core/describe_codes.json b/crates/runtime/component/tests/declarations/code_core/describe_codes.json
index eaaff64916..522623f2d7 100644
--- a/crates/runtime/component/tests/declarations/code_core/describe_codes.json
+++ b/crates/runtime/component/tests/declarations/code_core/describe_codes.json
@@ -4,22 +4,69 @@
{
"code": "E101",
"explanation": "A reference names no collected fact of the kinds its field admits, narrowed to those its id is shaped as (a test id holds `#`, an item id never does), while a fact store the session served holds facts of one of those kinds in its scheme: the test, item or package was renamed, moved or deleted, or the reference is misspelled. A test or run reference is told the closest one of the same file or binary. It is not reported while the citing entity's owner is pending (ADR 0329 D4): a test not written yet is TDD. Fix the reference, or run `specforge collect` if what it names is new. A reference one of its own facts holds (a test run's test) that no fact or entity answers, or that names an entity of another kind, is reported at the place its collector read it, addressed to that collector: its facts disagree, and running `specforge collect` again, or fixing the pack, is the remedy (ADR 0346).",
+ "facts": [
+ "item",
+ "package",
+ "test",
+ "test_run"
+ ],
"title": "A fact reference names no fact"
},
{
"code": "W102",
- "explanation": "A reference names no collected fact, and no fact store the session served holds facts of the kinds its field admits (narrowed to those its id is shaped as) in its scheme: on a fresh clone, or before the pack that writes them ran, there is nothing to check it against. It is reported once per cited reference, and not while the citing entity's owner is pending. Run `specforge collect` with the pack the finding names: `@javascript/node-test` for `js` tests, `@rust/test` for `rust` tests, `@rust/source` for `rust` items, `@javascript/source` for `js` items, `@rust/cargo` for `pkg:cargo` packages, `@javascript/source` for `pkg:npm` packages.",
+ "explanation": "A reference names no collected fact, and no fact store the session served holds facts of the kinds its field admits (narrowed to those its id is shaped as) in its scheme: on a fresh clone, or before the pack that writes them ran, there is nothing to check it against. It is reported once per cited reference, and not while the citing entity's owner is pending. Run `specforge collect` with the pack the finding names: `@javascript/node-test`, `@javascript/vitest`, `@javascript/jest` or `@javascript/playwright` for `js` tests, `@rust/test` or `@rust/proof` for `rust` tests, `@rust/source` for `rust` items, `@javascript/source` for `js` items, `@rust/cargo` for `pkg:cargo` packages, `@javascript/source` for `pkg:npm` packages.",
"title": "No facts of the reference's kinds were collected"
},
{
"code": "W401",
"explanation": "An entity whose owner is complete links a test whose last collected status is `failed`: the proof it cites does not hold. A pending owner's failing test is not reported (TDD). Fix the code or the test, and run `specforge collect` again.",
+ "facts": [
+ "test"
+ ],
"title": "A linked test fails"
},
{
"code": "I402",
"explanation": "A test or item fact's `names` (the entities its source's idiom says it proves or implements) holds a name that is no entity of the project, or the short name of several: the entity was renamed or deleted, or the name is misspelled. Fix the name in the source, then collect again.",
+ "facts": [
+ "item",
+ "test"
+ ],
"title": "A test or item names an entity that does not exist"
+ },
+ {
+ "code": "W104",
+ "explanation": "A fact a report reader minted cites no item, because the report's file or line lies in no collected item (a macro expansion, top-level statements, or a file no source pack collected), or because an API snapshot's entry has a path no collected item has: a re-exported path whose definition path differs, an item a macro generates, or a crate whose library is named apart from its package. A static finding is reported only when no collected package holds its file either, or it has no location. The entry is kept with what the report says of it, so nothing is lost. Collect the source pack for those files (`@rust/source`, `@javascript/source`) and the manifest pack for their packages, then collect the report again.",
+ "facts": [
+ "api_item",
+ "coverage",
+ "static_finding"
+ ],
+ "title": "A report entry names no item"
+ },
+ {
+ "code": "W105",
+ "explanation": "A static finding's SARIF result states no rule (no `ruleId`, no `rule`, and no rule index naming a rule of its tool's driver), or states no level (none on the result, and none in its rule's `defaultConfiguration`): the field reads `unknown`. The finding is kept, never dropped. SARIF's own default level is `warning`; it is not applied, so a level the tool never wrote cannot pass for one it did. Make the tool write its rule ids and levels in its SARIF output, or the rule metadata (`tool.driver.rules` with a `defaultConfiguration.level`), then collect the report again.",
+ "facts": [
+ "static_finding"
+ ],
+ "title": "A finding's rule or level is unknown"
+ },
+ {
+ "code": "W106",
+ "explanation": "A component of a CycloneDX bill of materials carries no package URL (`purl`), so its dependency is named by name and version only (`dep:/@`). The dependency is kept, never dropped, but no other report can be matched to it: an OSV scan or another BOM names a package by its purl. Generate the BOM with an SBOM tool that writes a purl for every component (cargo-cyclonedx, cyclonedx-npm), then collect it again.",
+ "facts": [
+ "dependency"
+ ],
+ "title": "A dependency has no purl"
+ },
+ {
+ "code": "W107",
+ "explanation": "An OSV record of a vulnerability scan has no severity label (`database_specific.severity`) and no CVSS v3 vector this reader rates: its only severity entries are CVSS v4 or v2 vectors, or its v3 vector is malformed. The vulnerability is kept with severity `unknown`, never dropped and never given a guessed rating, so a gate on severity cannot pass it by mistake. Read the advisory by its OSV id (osv.dev, or the database its id names) and judge its severity there.",
+ "facts": [
+ "vulnerability"
+ ],
+ "title": "A vulnerability's severity is unknown"
}
]
}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/code_core/describe_edges.json b/crates/runtime/component/tests/declarations/code_core/describe_edges.json
index 60dd099c67..c3ef2fbcea 100644
--- a/crates/runtime/component/tests/declarations/code_core/describe_edges.json
+++ b/crates/runtime/component/tests/declarations/code_core/describe_edges.json
@@ -45,6 +45,60 @@
"label": "runs_as",
"source_kind": "item",
"target_kind": "test"
+ },
+ {
+ "description": "The item a coverage fact reports on",
+ "edge_arrowhead": null,
+ "edge_color": null,
+ "edge_style": null,
+ "label": "covers",
+ "source_kind": "coverage",
+ "target_kind": "item"
+ },
+ {
+ "description": "The item an API snapshot's entry is the API of",
+ "edge_arrowhead": null,
+ "edge_color": null,
+ "edge_style": null,
+ "label": "api_of",
+ "source_kind": "api_item",
+ "target_kind": "item"
+ },
+ {
+ "description": "The item a static finding lies in",
+ "edge_arrowhead": null,
+ "edge_color": null,
+ "edge_style": null,
+ "label": "found_in",
+ "source_kind": "static_finding",
+ "target_kind": "item"
+ },
+ {
+ "description": "The package a static finding lies in, when no item holds it",
+ "edge_arrowhead": null,
+ "edge_color": null,
+ "edge_style": null,
+ "label": "found_in_package",
+ "source_kind": "static_finding",
+ "target_kind": "package"
+ },
+ {
+ "description": "The project package a dependency is a component of the BOM of",
+ "edge_arrowhead": null,
+ "edge_color": null,
+ "edge_style": null,
+ "label": "dependency_of",
+ "source_kind": "dependency",
+ "target_kind": "package"
+ },
+ {
+ "description": "The project package a vulnerability affects",
+ "edge_arrowhead": null,
+ "edge_color": null,
+ "edge_style": null,
+ "label": "affects",
+ "source_kind": "vulnerability",
+ "target_kind": "package"
}
]
}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/code_core/describe_entities.json b/crates/runtime/component/tests/declarations/code_core/describe_entities.json
index 746f34798f..bbebb917d2 100644
--- a/crates/runtime/component/tests/declarations/code_core/describe_entities.json
+++ b/crates/runtime/component/tests/declarations/code_core/describe_entities.json
@@ -413,6 +413,576 @@
"testable": false,
"verify_kinds": [],
"writer": "collector"
+ },
+ {
+ "description": "What a coverage report (LCOV) says of one item, written by a coverage pack's collector (ADR 0388): cov: for the innermost item holding the report's lines, cov:@ for what no item of a file holds (W104)",
+ "dot_color": null,
+ "dot_fillcolor": null,
+ "dot_shape": null,
+ "fields": [
+ {
+ "default_value": null,
+ "description": "The item holding the lines; absent when no collected item does",
+ "edge": "covers",
+ "field_type": "reference",
+ "inverse_of": null,
+ "name": "item",
+ "required": false,
+ "target_kind": "item"
+ },
+ {
+ "default_value": null,
+ "description": "The report's file, project-relative, with / separators",
+ "edge": null,
+ "field_type": "string",
+ "inverse_of": null,
+ "name": "file",
+ "required": false,
+ "target_kind": null
+ },
+ {
+ "default_value": null,
+ "description": "The functions the report lists in it",
+ "edge": null,
+ "field_type": "integer",
+ "inverse_of": null,
+ "name": "functions_found",
+ "required": false,
+ "target_kind": null
+ },
+ {
+ "default_value": null,
+ "description": "Those of its functions that ran",
+ "edge": null,
+ "field_type": "integer",
+ "inverse_of": null,
+ "name": "functions_hit",
+ "required": false,
+ "target_kind": null
+ },
+ {
+ "default_value": null,
+ "description": "The lines the report measured in it",
+ "edge": null,
+ "field_type": "integer",
+ "inverse_of": null,
+ "name": "lines_found",
+ "required": false,
+ "target_kind": null
+ },
+ {
+ "default_value": null,
+ "description": "Those of its lines that ran",
+ "edge": null,
+ "field_type": "integer",
+ "inverse_of": null,
+ "name": "lines_hit",
+ "required": false,
+ "target_kind": null
+ },
+ {
+ "default_value": null,
+ "description": "The branches the report measured in it",
+ "edge": null,
+ "field_type": "integer",
+ "inverse_of": null,
+ "name": "branches_found",
+ "required": false,
+ "target_kind": null
+ },
+ {
+ "default_value": null,
+ "description": "Those of its branches that were taken",
+ "edge": null,
+ "field_type": "integer",
+ "inverse_of": null,
+ "name": "branches_hit",
+ "required": false,
+ "target_kind": null
+ }
+ ],
+ "has_body_parser": false,
+ "incremental": null,
+ "inference_guide": null,
+ "keyword": null,
+ "lsp_icon": null,
+ "name": "coverage",
+ "open_fields": false,
+ "schemes": [
+ "cov"
+ ],
+ "semantic_token": null,
+ "singleton": false,
+ "supports_verify": false,
+ "testable": false,
+ "verify_kinds": [],
+ "writer": "collector"
+ },
+ {
+ "description": "One public entry of an API snapshot, written by an api pack's collector (ADR 0388): api:rust::: (cargo public-api, a trait-impl member ...::::m), api:js::: (api-extractor), the id holding no line, order nor source file",
+ "dot_color": null,
+ "dot_fillcolor": null,
+ "dot_shape": null,
+ "fields": [
+ {
+ "default_value": null,
+ "description": "The item the entry is the API of; absent when no collected item has its path (W104 for a kind an item can have)",
+ "edge": "api_of",
+ "field_type": "reference",
+ "inverse_of": null,
+ "name": "item",
+ "required": false,
+ "target_kind": "item"
+ },
+ {
+ "default_value": null,
+ "description": "The entry's qualified path as the snapshot wrote it",
+ "edge": null,
+ "field_type": "string",
+ "inverse_of": null,
+ "name": "path",
+ "required": false,
+ "target_kind": null
+ },
+ {
+ "default_value": null,
+ "description": "What the entry is: an item kind, or variant, reexport, extern_crate, other, which no item is",
+ "edge": null,
+ "enum_values": [
+ "module",
+ "function",
+ "method",
+ "field",
+ "struct",
+ "enum",
+ "union",
+ "trait",
+ "type",
+ "const",
+ "static",
+ "macro",
+ "class",
+ "interface",
+ "variable",
+ "namespace",
+ "variant",
+ "reexport",
+ "extern_crate",
+ "other"
+ ],
+ "field_type": "enum",
+ "inverse_of": null,
+ "name": "kind",
+ "required": false,
+ "target_kind": null
+ },
+ {
+ "default_value": null,
+ "description": "Who may name it, as the snapshot wrote it",
+ "edge": null,
+ "enum_values": [
+ "public",
+ "crate",
+ "restricted",
+ "private"
+ ],
+ "field_type": "enum",
+ "inverse_of": null,
+ "name": "visibility",
+ "required": false,
+ "target_kind": null
+ },
+ {
+ "default_value": null,
+ "description": "The entry exactly as the snapshot wrote it, attributes included",
+ "edge": null,
+ "field_type": "string",
+ "inverse_of": null,
+ "name": "signature",
+ "required": false,
+ "target_kind": null
+ },
+ {
+ "default_value": null,
+ "description": "The api-extractor release tag (Public, Beta, Alpha, Internal)",
+ "edge": null,
+ "field_type": "string",
+ "inverse_of": null,
+ "name": "tag",
+ "required": false,
+ "target_kind": null
+ },
+ {
+ "default_value": null,
+ "description": "The entry against the committed accepted report; absent when no accepted report covers its crate or package",
+ "edge": null,
+ "enum_values": [
+ "added",
+ "unchanged",
+ "changed",
+ "narrowed",
+ "removed"
+ ],
+ "field_type": "enum",
+ "inverse_of": null,
+ "name": "change",
+ "required": false,
+ "target_kind": null
+ },
+ {
+ "default_value": null,
+ "description": "The accepted report's entry as it wrote it, for a changed, narrowed or removed entry",
+ "edge": null,
+ "field_type": "string",
+ "inverse_of": null,
+ "name": "accepted_signature",
+ "required": false,
+ "target_kind": null
+ },
+ {
+ "default_value": null,
+ "description": "The accepted report's release tag, for a changed, narrowed or removed entry that has one",
+ "edge": null,
+ "field_type": "string",
+ "inverse_of": null,
+ "name": "accepted_tag",
+ "required": false,
+ "target_kind": null
+ },
+ {
+ "default_value": null,
+ "description": "The accepted report's visibility, for a changed or narrowed entry whose visibility differs",
+ "edge": null,
+ "enum_values": [
+ "public",
+ "crate",
+ "restricted",
+ "private"
+ ],
+ "field_type": "enum",
+ "inverse_of": null,
+ "name": "accepted_visibility",
+ "required": false,
+ "target_kind": null
+ }
+ ],
+ "has_body_parser": false,
+ "incremental": null,
+ "inference_guide": null,
+ "keyword": null,
+ "lsp_icon": null,
+ "name": "api_item",
+ "open_fields": false,
+ "schemes": [
+ "api"
+ ],
+ "semantic_token": null,
+ "singleton": false,
+ "supports_verify": false,
+ "testable": false,
+ "verify_kinds": [],
+ "writer": "collector"
+ },
+ {
+ "description": "One result of a SARIF run (a lint or static analysis finding), written by a lint pack's collector (ADR 0388): sarif:/#:, # with no line, neither with no location, ~2 on a repeat in document order",
+ "dot_color": null,
+ "dot_fillcolor": null,
+ "dot_shape": null,
+ "fields": [
+ {
+ "default_value": null,
+ "description": "The run's tool (tool.driver.name)",
+ "edge": null,
+ "field_type": "string",
+ "inverse_of": null,
+ "name": "tool",
+ "required": false,
+ "target_kind": null
+ },
+ {
+ "default_value": null,
+ "description": "The rule id the result states; unknown when it states none (W105)",
+ "edge": null,
+ "field_type": "string",
+ "inverse_of": null,
+ "name": "rule",
+ "required": false,
+ "target_kind": null
+ },
+ {
+ "default_value": null,
+ "description": "The level the result or its rule's defaultConfiguration states; unknown when neither does (W105), never SARIF's own warning default",
+ "edge": null,
+ "enum_values": [
+ "error",
+ "warning",
+ "note",
+ "none",
+ "unknown"
+ ],
+ "field_type": "enum",
+ "inverse_of": null,
+ "name": "level",
+ "required": false,
+ "target_kind": null
+ },
+ {
+ "default_value": null,
+ "description": "The result's message.text",
+ "edge": null,
+ "field_type": "string",
+ "inverse_of": null,
+ "name": "message",
+ "required": false,
+ "target_kind": null
+ },
+ {
+ "default_value": null,
+ "description": "The file of its first location, project-relative, with / separators",
+ "edge": null,
+ "field_type": "string",
+ "inverse_of": null,
+ "name": "file",
+ "required": false,
+ "target_kind": null
+ },
+ {
+ "default_value": null,
+ "description": "The 1-based start line of its first location",
+ "edge": null,
+ "field_type": "integer",
+ "inverse_of": null,
+ "name": "line",
+ "required": false,
+ "target_kind": null
+ },
+ {
+ "default_value": null,
+ "description": "The innermost item holding its line; absent when no collected item does",
+ "edge": "found_in",
+ "field_type": "reference",
+ "inverse_of": null,
+ "name": "item",
+ "required": false,
+ "target_kind": "item"
+ },
+ {
+ "default_value": null,
+ "description": "The package holding its file, when no item holds its line; absent with neither (W104)",
+ "edge": "found_in_package",
+ "field_type": "reference",
+ "inverse_of": null,
+ "name": "package",
+ "required": false,
+ "target_kind": "package"
+ }
+ ],
+ "has_body_parser": false,
+ "incremental": null,
+ "inference_guide": null,
+ "keyword": null,
+ "lsp_icon": null,
+ "name": "static_finding",
+ "open_fields": false,
+ "schemes": [
+ "sarif"
+ ],
+ "semantic_token": null,
+ "singleton": false,
+ "supports_verify": false,
+ "testable": false,
+ "verify_kinds": [],
+ "writer": "collector"
+ },
+ {
+ "description": "One component of a CycloneDX bill of materials, written by an SBOM pack's collector (ADR 0388): dep:/, or dep:/@<[group/]name[@version]> for a component with no purl (W106); one fact per id, a purl listed twice merged",
+ "dot_color": null,
+ "dot_fillcolor": null,
+ "dot_shape": null,
+ "fields": [
+ {
+ "default_value": null,
+ "description": "The project package the BOM describes (its metadata.component)",
+ "edge": "dependency_of",
+ "field_type": "reference",
+ "inverse_of": null,
+ "name": "package",
+ "required": false,
+ "target_kind": "package"
+ },
+ {
+ "default_value": null,
+ "description": "The component's package URL as written; absent when it has none (W106)",
+ "edge": null,
+ "field_type": "string",
+ "inverse_of": null,
+ "name": "purl",
+ "required": false,
+ "target_kind": null
+ },
+ {
+ "default_value": null,
+ "description": "The component's name, group/name when it states a group",
+ "edge": null,
+ "field_type": "string",
+ "inverse_of": null,
+ "name": "name",
+ "required": false,
+ "target_kind": null
+ },
+ {
+ "default_value": null,
+ "description": "The component's version, when it states one",
+ "edge": null,
+ "field_type": "string",
+ "inverse_of": null,
+ "name": "version",
+ "required": false,
+ "target_kind": null
+ },
+ {
+ "default_value": null,
+ "description": "The component's scope, required when the BOM states none (the spec's default); the widest of a purl listed twice",
+ "edge": null,
+ "enum_values": [
+ "required",
+ "optional",
+ "excluded"
+ ],
+ "field_type": "enum",
+ "inverse_of": null,
+ "name": "scope",
+ "required": false,
+ "target_kind": null
+ },
+ {
+ "default_value": null,
+ "description": "Whether the project package depends on it directly; present only when the BOM states a dependency graph for its root, never false for a graph it does not state",
+ "edge": null,
+ "field_type": "bool",
+ "inverse_of": null,
+ "name": "direct",
+ "required": false,
+ "target_kind": null
+ }
+ ],
+ "has_body_parser": false,
+ "incremental": null,
+ "inference_guide": null,
+ "keyword": null,
+ "lsp_icon": null,
+ "name": "dependency",
+ "open_fields": false,
+ "schemes": [
+ "dep"
+ ],
+ "semantic_token": null,
+ "singleton": false,
+ "supports_verify": false,
+ "testable": false,
+ "verify_kinds": [],
+ "writer": "collector"
+ },
+ {
+ "description": "One OSV record of an osv-scanner report, written by a vulnerability pack's collector (ADR 0388): vuln:/, one fact per project package the scanned lockfile belongs to and OSV id, the versions of one dependency merged; severity critical, high, medium, low, else unknown (W107)",
+ "dot_color": null,
+ "dot_fillcolor": null,
+ "dot_shape": null,
+ "fields": [
+ {
+ "default_value": null,
+ "description": "The project package the scanned lockfile belongs to: the one at its directory, else each one under it",
+ "edge": "affects",
+ "field_type": "reference",
+ "inverse_of": null,
+ "name": "package",
+ "required": false,
+ "target_kind": "package"
+ },
+ {
+ "default_value": null,
+ "description": "The OSV record's id (GHSA-…, RUSTSEC-…)",
+ "edge": null,
+ "field_type": "string",
+ "inverse_of": null,
+ "name": "osv_id",
+ "required": false,
+ "target_kind": null
+ },
+ {
+ "default_value": null,
+ "description": "The record's aliases (CVE ids and the like), sorted",
+ "edge": null,
+ "field_type": "string_list",
+ "inverse_of": null,
+ "name": "aliases",
+ "required": false,
+ "target_kind": null
+ },
+ {
+ "default_value": null,
+ "description": "The record's one-line summary; absent when it states none",
+ "edge": null,
+ "field_type": "string",
+ "inverse_of": null,
+ "name": "summary",
+ "required": false,
+ "target_kind": null
+ },
+ {
+ "default_value": null,
+ "description": "The affected dependency's package URL at each affected version",
+ "edge": null,
+ "field_type": "string_list",
+ "inverse_of": null,
+ "name": "purl",
+ "required": false,
+ "target_kind": null
+ },
+ {
+ "default_value": null,
+ "description": "The affected dependency's versions the lockfile pins",
+ "edge": null,
+ "field_type": "string_list",
+ "inverse_of": null,
+ "name": "version",
+ "required": false,
+ "target_kind": null
+ },
+ {
+ "default_value": null,
+ "description": "The record's own severity label (MODERATE reads medium), else the rating of its highest CVSS v3 base score, else unknown (W107); the highest of the records merged",
+ "edge": null,
+ "enum_values": [
+ "critical",
+ "high",
+ "medium",
+ "low",
+ "unknown"
+ ],
+ "field_type": "enum",
+ "inverse_of": null,
+ "name": "severity",
+ "required": false,
+ "target_kind": null
+ }
+ ],
+ "has_body_parser": false,
+ "incremental": null,
+ "inference_guide": null,
+ "keyword": null,
+ "lsp_icon": null,
+ "name": "vulnerability",
+ "open_fields": false,
+ "schemes": [
+ "vuln"
+ ],
+ "semantic_token": null,
+ "singleton": false,
+ "supports_verify": false,
+ "testable": false,
+ "verify_kinds": [],
+ "writer": "collector"
}
]
}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/code_core/describe_passes.json b/crates/runtime/component/tests/declarations/code_core/describe_passes.json
index 28868686dd..2c8f10712b 100644
--- a/crates/runtime/component/tests/declarations/code_core/describe_passes.json
+++ b/crates/runtime/component/tests/declarations/code_core/describe_passes.json
@@ -32,6 +32,24 @@
],
"name": "proof",
"phase": "check"
+ },
+ {
+ "after": null,
+ "before": null,
+ "inputs": [
+ {
+ "input": "facts",
+ "kinds": [
+ "coverage",
+ "api_item",
+ "static_finding",
+ "dependency",
+ "vulnerability"
+ ]
+ }
+ ],
+ "name": "reports",
+ "phase": "check"
}
]
}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/code_core/handshake.json b/crates/runtime/component/tests/declarations/code_core/handshake.json
index bb8ce8ec27..447d65cdc3 100644
--- a/crates/runtime/component/tests/declarations/code_core/handshake.json
+++ b/crates/runtime/component/tests/declarations/code_core/handshake.json
@@ -1,8 +1,8 @@
{
"protocol_version": "2.3.0",
"name": "@code/core",
- "version": "1.1.0",
+ "version": "1.4.0",
"peer_dependencies": [],
"sandbox_policy": null,
- "description": "The neutral base of code facts: the test, test_run, item and package kinds the code packs collect, and the checks of the references a spec writes to them"
+ "description": "The neutral base of code facts: the test, test_run, item and package kinds the code packs collect, the report facts (coverage, api_item, static_finding, dependency, vulnerability) a standard report's reader mints, and the checks of the references a spec writes to them and of what a report leaves unmapped"
}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/gsd_core/describe_codes.json b/crates/runtime/component/tests/declarations/gsd_core/describe_codes.json
index d1f46b793c..8ac125bb1a 100644
--- a/crates/runtime/component/tests/declarations/gsd_core/describe_codes.json
+++ b/crates/runtime/component/tests/declarations/gsd_core/describe_codes.json
@@ -442,6 +442,18 @@
"docs": "https://github.com/leaderiop/SpecForge/blob/main/gsd/core/spec/rules.md#project-and-roadmap",
"explanation": "A phase's title does not begin with a phase number: its label reads the number from its id. It is a warning, and an error under gsd-strict and gsd-plus.",
"title": "Phase title embeds a number"
+ },
+ {
+ "code": "E533",
+ "docs": "https://github.com/leaderiop/SpecForge/blob/main/gsd/core/spec/rules.md#project-and-roadmap",
+ "explanation": "A milestone whose API facts show a changed, narrowed or removed item is closed while its version is API-compatible with the last shipped milestone of its workstream scope (Cargo's rule: for 0.x the minor counts as major), or while its name is not a version, so no major bump can be shown. It is an error.",
+ "title": "Breaking API change without a major version bump"
+ },
+ {
+ "code": "E535",
+ "docs": "https://github.com/leaderiop/SpecForge/blob/main/gsd/core/spec/rules.md#project-and-roadmap",
+ "explanation": "A milestone named by its version is closed while a package fact's version is not its version, while its version is not later than the last shipped milestone of its workstream scope, or while the last shipped milestone's tag does not resolve to a commit. It is an error.",
+ "title": "Release evidence does not match the milestone"
}
]
}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/gsd_core/describe_entities.json b/crates/runtime/component/tests/declarations/gsd_core/describe_entities.json
index f5c76dd2f6..9fbb1c9b84 100644
--- a/crates/runtime/component/tests/declarations/gsd_core/describe_entities.json
+++ b/crates/runtime/component/tests/declarations/gsd_core/describe_entities.json
@@ -761,6 +761,125 @@
"required": false,
"target_kind": null,
"writer": "computed"
+ },
+ {
+ "default_value": null,
+ "description": "the API items the last collect found changed, narrowed or removed against the committed accepted report: ``; absent when no API fact carries a change; gsd/E533 reads it",
+ "edge": null,
+ "field_type": "string_list",
+ "inverse_of": null,
+ "name": "api_breaks",
+ "required": false,
+ "target_kind": null,
+ "writer": "computed"
+ },
+ {
+ "default_value": null,
+ "description": "the release evidence gsd/E535 reads: `tag` and `commit` the recorded tag of a shipped milestone, `packages` the `name` and `version` of each package fact not at an open milestone's version, at most 50, and `more` the count past them; absent when nothing was observed",
+ "edge": null,
+ "field_type": "block",
+ "inverse_of": null,
+ "members": [
+ {
+ "default_value": null,
+ "description": null,
+ "edge": null,
+ "field_type": "string",
+ "inverse_of": null,
+ "name": "tag",
+ "required": false,
+ "target_kind": null
+ },
+ {
+ "default_value": null,
+ "description": null,
+ "edge": null,
+ "field_type": "string",
+ "inverse_of": null,
+ "name": "commit",
+ "required": false,
+ "target_kind": null
+ },
+ {
+ "default_value": null,
+ "description": null,
+ "edge": null,
+ "field_type": "block_list",
+ "inverse_of": null,
+ "members": [
+ {
+ "default_value": null,
+ "description": null,
+ "edge": null,
+ "field_type": "string",
+ "inverse_of": null,
+ "name": "name",
+ "required": false,
+ "target_kind": null
+ },
+ {
+ "default_value": null,
+ "description": null,
+ "edge": null,
+ "field_type": "string",
+ "inverse_of": null,
+ "name": "version",
+ "required": false,
+ "target_kind": null
+ }
+ ],
+ "name": "packages",
+ "required": false,
+ "target_kind": null
+ },
+ {
+ "default_value": null,
+ "description": null,
+ "edge": null,
+ "field_type": "integer",
+ "inverse_of": null,
+ "name": "more",
+ "required": false,
+ "target_kind": null
+ }
+ ],
+ "name": "release",
+ "required": false,
+ "target_kind": null,
+ "writer": "computed"
+ },
+ {
+ "default_value": null,
+ "description": "written by gsd-git from `refs/tags/v` for a shipped milestone named by its version: the tag's `name`, and the `commit` it resolves to, absent when it resolves to none",
+ "edge": null,
+ "field_type": "block",
+ "inverse_of": null,
+ "members": [
+ {
+ "default_value": null,
+ "description": null,
+ "edge": null,
+ "field_type": "string",
+ "inverse_of": null,
+ "name": "name",
+ "required": false,
+ "target_kind": null
+ },
+ {
+ "default_value": null,
+ "description": null,
+ "edge": null,
+ "field_type": "string",
+ "inverse_of": null,
+ "name": "commit",
+ "required": false,
+ "target_kind": null
+ }
+ ],
+ "name": "tag",
+ "required": false,
+ "target_kind": null,
+ "writer": "harness"
}
],
"has_body_parser": false,
diff --git a/crates/runtime/component/tests/declarations/gsd_core/describe_passes.json b/crates/runtime/component/tests/declarations/gsd_core/describe_passes.json
index 80a5b67f56..91c08d9933 100644
--- a/crates/runtime/component/tests/declarations/gsd_core/describe_passes.json
+++ b/crates/runtime/component/tests/declarations/gsd_core/describe_passes.json
@@ -111,6 +111,8 @@
"milestone.git_range",
"milestone.progress",
"milestone.branch",
+ "milestone.api_breaks",
+ "milestone.release",
"phase.inserted",
"phase.backlog",
"phase.branch",
@@ -171,7 +173,9 @@
{
"input": "facts",
"kinds": [
- "test"
+ "test",
+ "api_item",
+ "package"
]
}
],
@@ -387,6 +391,24 @@
"E516"
]
},
+ {
+ "after": null,
+ "before": null,
+ "name": "gate_e533",
+ "phase": "guard",
+ "reports": [
+ "E533"
+ ]
+ },
+ {
+ "after": null,
+ "before": null,
+ "name": "gate_e535",
+ "phase": "guard",
+ "reports": [
+ "E535"
+ ]
+ },
{
"after": null,
"before": null,
diff --git a/crates/runtime/component/tests/declarations/gsd_core/describe_routes.json b/crates/runtime/component/tests/declarations/gsd_core/describe_routes.json
index 5fb38b68f1..cfbf7208a3 100644
--- a/crates/runtime/component/tests/declarations/gsd_core/describe_routes.json
+++ b/crates/runtime/component/tests/declarations/gsd_core/describe_routes.json
@@ -60,6 +60,29 @@
"via": "/dist/index.d.ts\",\n \"apiReport\": { \"enabled\": false },\n \"docModel\": { \"enabled\": true, \"apiJsonFilePath\": \"{report}\" },\n \"dtsRollup\": { \"enabled\": false },\n \"tsdocMetadata\": { \"enabled\": false },\n \"messages\": {\n \"compilerMessageReporting\": { \"default\": { \"logLevel\": \"none\" } },\n \"extractorMessageReporting\": { \"default\": { \"logLevel\": \"none\" } },\n \"tsdocMessageReporting\": { \"default\": { \"logLevel\": \"none\" } }\n }\n}\n"
+ },
+ "env": [
+ "NODE_*",
+ "CI"
+ ],
+ "name": "javascript-api",
+ "port": "process",
+ "why": "run the command whose report the collector 'javascript-api' reads"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_api/describe_checkers.json b/crates/runtime/component/tests/declarations/javascript_api/describe_checkers.json
new file mode 100644
index 0000000000..2c0d93db04
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_api/describe_checkers.json
@@ -0,0 +1,4 @@
+{
+ "category": "checkers",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_api/describe_codes.json b/crates/runtime/component/tests/declarations/javascript_api/describe_codes.json
new file mode 100644
index 0000000000..476fe856cc
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_api/describe_codes.json
@@ -0,0 +1,4 @@
+{
+ "category": "codes",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_api/describe_collectors.json b/crates/runtime/component/tests/declarations/javascript_api/describe_collectors.json
new file mode 100644
index 0000000000..719e904c3a
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_api/describe_collectors.json
@@ -0,0 +1,46 @@
+{
+ "category": "collectors",
+ "items": [
+ {
+ "answers": [
+ "api_item"
+ ],
+ "auto_detect": {
+ "env_vars": [],
+ "file_patterns": [
+ "tsconfig.json"
+ ]
+ },
+ "capability": "javascript-api",
+ "export": "collect__javascript_api",
+ "input_formats": [
+ "api-extractor-json"
+ ],
+ "inputs": [
+ {
+ "input": "facts",
+ "kinds": [
+ "item"
+ ]
+ },
+ {
+ "glob": "**/etc/*.api.md",
+ "input": "files",
+ "name": "accepted",
+ "text": true,
+ "text_max": 4194304
+ },
+ {
+ "glob": "common/reviews/api/*.api.md",
+ "input": "files",
+ "name": "reviews",
+ "text": true,
+ "text_max": 4194304
+ }
+ ],
+ "install": "npm install --save-dev @microsoft/api-extractor typescript",
+ "name": "javascript-api",
+ "report": ".specforge/reports/javascript-api.api.json"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_api/describe_contexts.json b/crates/runtime/component/tests/declarations/javascript_api/describe_contexts.json
new file mode 100644
index 0000000000..afd6be3149
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_api/describe_contexts.json
@@ -0,0 +1,4 @@
+{
+ "category": "contexts",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_api/describe_edges.json b/crates/runtime/component/tests/declarations/javascript_api/describe_edges.json
new file mode 100644
index 0000000000..bb4c7452e4
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_api/describe_edges.json
@@ -0,0 +1,4 @@
+{
+ "category": "edges",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_api/describe_enhancements.json b/crates/runtime/component/tests/declarations/javascript_api/describe_enhancements.json
new file mode 100644
index 0000000000..e79b88a896
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_api/describe_enhancements.json
@@ -0,0 +1,4 @@
+{
+ "category": "enhancements",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_api/describe_entities.json b/crates/runtime/component/tests/declarations/javascript_api/describe_entities.json
new file mode 100644
index 0000000000..ade72d8d90
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_api/describe_entities.json
@@ -0,0 +1,4 @@
+{
+ "category": "entities",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_api/describe_feature_flags.json b/crates/runtime/component/tests/declarations/javascript_api/describe_feature_flags.json
new file mode 100644
index 0000000000..355b7dc9d2
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_api/describe_feature_flags.json
@@ -0,0 +1,4 @@
+{
+ "category": "feature_flags",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_api/describe_passes.json b/crates/runtime/component/tests/declarations/javascript_api/describe_passes.json
new file mode 100644
index 0000000000..c5e67bce72
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_api/describe_passes.json
@@ -0,0 +1,4 @@
+{
+ "category": "passes",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_api/describe_routes.json b/crates/runtime/component/tests/declarations/javascript_api/describe_routes.json
new file mode 100644
index 0000000000..425fbe7ef2
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_api/describe_routes.json
@@ -0,0 +1,4 @@
+{
+ "category": "routes",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_api/describe_settings.json b/crates/runtime/component/tests/declarations/javascript_api/describe_settings.json
new file mode 100644
index 0000000000..25d73ebee3
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_api/describe_settings.json
@@ -0,0 +1,4 @@
+{
+ "category": "settings",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_api/describe_shared_fields.json b/crates/runtime/component/tests/declarations/javascript_api/describe_shared_fields.json
new file mode 100644
index 0000000000..6677481472
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_api/describe_shared_fields.json
@@ -0,0 +1,4 @@
+{
+ "category": "shared_fields",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_api/describe_surfaces.json b/crates/runtime/component/tests/declarations/javascript_api/describe_surfaces.json
new file mode 100644
index 0000000000..11f01236f3
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_api/describe_surfaces.json
@@ -0,0 +1,4 @@
+{
+ "category": "surfaces",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_api/describe_validation_rules.json b/crates/runtime/component/tests/declarations/javascript_api/describe_validation_rules.json
new file mode 100644
index 0000000000..00357eaaf2
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_api/describe_validation_rules.json
@@ -0,0 +1,4 @@
+{
+ "category": "validation_rules",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_api/handshake.json b/crates/runtime/component/tests/declarations/javascript_api/handshake.json
new file mode 100644
index 0000000000..7b49b18b24
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_api/handshake.json
@@ -0,0 +1,19 @@
+{
+ "protocol_version": "2.3.0",
+ "name": "@javascript/api",
+ "version": "1.0.0",
+ "peer_dependencies": [
+ {
+ "name": "@code/core",
+ "version": "^1.4",
+ "optional": false
+ },
+ {
+ "name": "@javascript/source",
+ "version": "^1.0",
+ "optional": false
+ }
+ ],
+ "sandbox_policy": null,
+ "description": "Runs api-extractor and records the package's public API as api_item facts (@code/core)"
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_coverage/describe_capabilities.json b/crates/runtime/component/tests/declarations/javascript_coverage/describe_capabilities.json
new file mode 100644
index 0000000000..124c0df37a
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_coverage/describe_capabilities.json
@@ -0,0 +1,29 @@
+{
+ "category": "capabilities",
+ "items": [
+ {
+ "argv": [
+ "npx",
+ "--no",
+ "--",
+ "c8",
+ "--reporter=lcovonly",
+ "--reports-dir=.specforge/reports/javascript-coverage",
+ "npm",
+ "test"
+ ],
+ "call_kinds": [
+ "collect"
+ ],
+ "env": [
+ "NODE_*",
+ "NPM_CONFIG_*",
+ "npm_config_*",
+ "CI"
+ ],
+ "name": "javascript-coverage",
+ "port": "process",
+ "why": "run the command whose report the collector 'javascript-coverage' reads"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_coverage/describe_checkers.json b/crates/runtime/component/tests/declarations/javascript_coverage/describe_checkers.json
new file mode 100644
index 0000000000..2c0d93db04
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_coverage/describe_checkers.json
@@ -0,0 +1,4 @@
+{
+ "category": "checkers",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_coverage/describe_codes.json b/crates/runtime/component/tests/declarations/javascript_coverage/describe_codes.json
new file mode 100644
index 0000000000..476fe856cc
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_coverage/describe_codes.json
@@ -0,0 +1,4 @@
+{
+ "category": "codes",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_coverage/describe_collectors.json b/crates/runtime/component/tests/declarations/javascript_coverage/describe_collectors.json
new file mode 100644
index 0000000000..9aa5fa609b
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_coverage/describe_collectors.json
@@ -0,0 +1,32 @@
+{
+ "category": "collectors",
+ "items": [
+ {
+ "answers": [
+ "coverage"
+ ],
+ "auto_detect": {
+ "env_vars": [],
+ "file_patterns": [
+ "package.json"
+ ]
+ },
+ "capability": "javascript-coverage",
+ "export": "collect__javascript_coverage",
+ "input_formats": [
+ "lcov"
+ ],
+ "inputs": [
+ {
+ "input": "facts",
+ "kinds": [
+ "item"
+ ]
+ }
+ ],
+ "install": "npm install --save-dev c8",
+ "name": "javascript-coverage",
+ "report": ".specforge/reports/javascript-coverage/lcov.info"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_coverage/describe_contexts.json b/crates/runtime/component/tests/declarations/javascript_coverage/describe_contexts.json
new file mode 100644
index 0000000000..afd6be3149
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_coverage/describe_contexts.json
@@ -0,0 +1,4 @@
+{
+ "category": "contexts",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_coverage/describe_edges.json b/crates/runtime/component/tests/declarations/javascript_coverage/describe_edges.json
new file mode 100644
index 0000000000..bb4c7452e4
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_coverage/describe_edges.json
@@ -0,0 +1,4 @@
+{
+ "category": "edges",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_coverage/describe_enhancements.json b/crates/runtime/component/tests/declarations/javascript_coverage/describe_enhancements.json
new file mode 100644
index 0000000000..e79b88a896
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_coverage/describe_enhancements.json
@@ -0,0 +1,4 @@
+{
+ "category": "enhancements",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_coverage/describe_entities.json b/crates/runtime/component/tests/declarations/javascript_coverage/describe_entities.json
new file mode 100644
index 0000000000..ade72d8d90
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_coverage/describe_entities.json
@@ -0,0 +1,4 @@
+{
+ "category": "entities",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_coverage/describe_feature_flags.json b/crates/runtime/component/tests/declarations/javascript_coverage/describe_feature_flags.json
new file mode 100644
index 0000000000..355b7dc9d2
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_coverage/describe_feature_flags.json
@@ -0,0 +1,4 @@
+{
+ "category": "feature_flags",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_coverage/describe_passes.json b/crates/runtime/component/tests/declarations/javascript_coverage/describe_passes.json
new file mode 100644
index 0000000000..c5e67bce72
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_coverage/describe_passes.json
@@ -0,0 +1,4 @@
+{
+ "category": "passes",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_coverage/describe_routes.json b/crates/runtime/component/tests/declarations/javascript_coverage/describe_routes.json
new file mode 100644
index 0000000000..425fbe7ef2
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_coverage/describe_routes.json
@@ -0,0 +1,4 @@
+{
+ "category": "routes",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_coverage/describe_settings.json b/crates/runtime/component/tests/declarations/javascript_coverage/describe_settings.json
new file mode 100644
index 0000000000..25d73ebee3
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_coverage/describe_settings.json
@@ -0,0 +1,4 @@
+{
+ "category": "settings",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_coverage/describe_shared_fields.json b/crates/runtime/component/tests/declarations/javascript_coverage/describe_shared_fields.json
new file mode 100644
index 0000000000..6677481472
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_coverage/describe_shared_fields.json
@@ -0,0 +1,4 @@
+{
+ "category": "shared_fields",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_coverage/describe_surfaces.json b/crates/runtime/component/tests/declarations/javascript_coverage/describe_surfaces.json
new file mode 100644
index 0000000000..11f01236f3
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_coverage/describe_surfaces.json
@@ -0,0 +1,4 @@
+{
+ "category": "surfaces",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_coverage/describe_validation_rules.json b/crates/runtime/component/tests/declarations/javascript_coverage/describe_validation_rules.json
new file mode 100644
index 0000000000..00357eaaf2
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_coverage/describe_validation_rules.json
@@ -0,0 +1,4 @@
+{
+ "category": "validation_rules",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_coverage/handshake.json b/crates/runtime/component/tests/declarations/javascript_coverage/handshake.json
new file mode 100644
index 0000000000..b6d8e9ba17
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_coverage/handshake.json
@@ -0,0 +1,19 @@
+{
+ "protocol_version": "2.3.0",
+ "name": "@javascript/coverage",
+ "version": "1.0.0",
+ "peer_dependencies": [
+ {
+ "name": "@code/core",
+ "version": "^1.2",
+ "optional": false
+ },
+ {
+ "name": "@javascript/source",
+ "version": "^1.0",
+ "optional": false
+ }
+ ],
+ "sandbox_policy": null,
+ "description": "Runs c8 around npm test and records its LCOV coverage as coverage facts (@code/core)"
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_deps/describe_capabilities.json b/crates/runtime/component/tests/declarations/javascript_deps/describe_capabilities.json
new file mode 100644
index 0000000000..298b77ce21
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_deps/describe_capabilities.json
@@ -0,0 +1,60 @@
+{
+ "category": "capabilities",
+ "items": [
+ {
+ "argv": [
+ "npx",
+ "--no",
+ "--",
+ "cyclonedx-npm",
+ "--output-format",
+ "JSON",
+ "--spec-version",
+ "1.6",
+ "--package-lock-only",
+ "--output-file",
+ "{report}"
+ ],
+ "call_kinds": [
+ "collect"
+ ],
+ "env": [
+ "NODE_*",
+ "NPM_CONFIG_*",
+ "npm_config_*",
+ "CI"
+ ],
+ "name": "javascript-sbom",
+ "port": "process",
+ "why": "run the command whose report the collector 'javascript-sbom' reads"
+ },
+ {
+ "argv": [
+ "osv-scanner",
+ "scan",
+ "source",
+ "--lockfile",
+ "package-lock.json",
+ "--format",
+ "json",
+ "--output-file",
+ "{report}"
+ ],
+ "call_kinds": [
+ "collect"
+ ],
+ "env": [
+ "HTTPS_PROXY",
+ "HTTP_PROXY",
+ "NO_PROXY",
+ "https_proxy",
+ "http_proxy",
+ "no_proxy",
+ "OSV_*"
+ ],
+ "name": "javascript-osv",
+ "port": "process",
+ "why": "run the command whose report the collector 'javascript-osv' reads"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_deps/describe_checkers.json b/crates/runtime/component/tests/declarations/javascript_deps/describe_checkers.json
new file mode 100644
index 0000000000..2c0d93db04
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_deps/describe_checkers.json
@@ -0,0 +1,4 @@
+{
+ "category": "checkers",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_deps/describe_codes.json b/crates/runtime/component/tests/declarations/javascript_deps/describe_codes.json
new file mode 100644
index 0000000000..476fe856cc
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_deps/describe_codes.json
@@ -0,0 +1,4 @@
+{
+ "category": "codes",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_deps/describe_collectors.json b/crates/runtime/component/tests/declarations/javascript_deps/describe_collectors.json
new file mode 100644
index 0000000000..02895ddd78
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_deps/describe_collectors.json
@@ -0,0 +1,59 @@
+{
+ "category": "collectors",
+ "items": [
+ {
+ "answers": [
+ "dependency"
+ ],
+ "auto_detect": {
+ "env_vars": [],
+ "file_patterns": [
+ "package-lock.json"
+ ]
+ },
+ "capability": "javascript-sbom",
+ "export": "collect__javascript_sbom",
+ "input_formats": [
+ "cyclonedx-json"
+ ],
+ "inputs": [
+ {
+ "input": "facts",
+ "kinds": [
+ "package"
+ ]
+ }
+ ],
+ "install": "npm install --save-dev @cyclonedx/cyclonedx-npm",
+ "name": "javascript-sbom",
+ "report": ".specforge/reports/javascript-sbom.cdx.json"
+ },
+ {
+ "answers": [
+ "vulnerability"
+ ],
+ "auto_detect": {
+ "env_vars": [],
+ "file_patterns": [
+ "package-lock.json"
+ ]
+ },
+ "capability": "javascript-osv",
+ "export": "collect__javascript_osv",
+ "input_formats": [
+ "osv-json"
+ ],
+ "inputs": [
+ {
+ "input": "facts",
+ "kinds": [
+ "package"
+ ]
+ }
+ ],
+ "install": "go install github.com/google/osv-scanner/v2/cmd/osv-scanner@latest (or: brew install osv-scanner)",
+ "name": "javascript-osv",
+ "report": ".specforge/reports/javascript-osv.json"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_deps/describe_contexts.json b/crates/runtime/component/tests/declarations/javascript_deps/describe_contexts.json
new file mode 100644
index 0000000000..afd6be3149
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_deps/describe_contexts.json
@@ -0,0 +1,4 @@
+{
+ "category": "contexts",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_deps/describe_edges.json b/crates/runtime/component/tests/declarations/javascript_deps/describe_edges.json
new file mode 100644
index 0000000000..bb4c7452e4
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_deps/describe_edges.json
@@ -0,0 +1,4 @@
+{
+ "category": "edges",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_deps/describe_enhancements.json b/crates/runtime/component/tests/declarations/javascript_deps/describe_enhancements.json
new file mode 100644
index 0000000000..e79b88a896
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_deps/describe_enhancements.json
@@ -0,0 +1,4 @@
+{
+ "category": "enhancements",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_deps/describe_entities.json b/crates/runtime/component/tests/declarations/javascript_deps/describe_entities.json
new file mode 100644
index 0000000000..ade72d8d90
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_deps/describe_entities.json
@@ -0,0 +1,4 @@
+{
+ "category": "entities",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_deps/describe_feature_flags.json b/crates/runtime/component/tests/declarations/javascript_deps/describe_feature_flags.json
new file mode 100644
index 0000000000..355b7dc9d2
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_deps/describe_feature_flags.json
@@ -0,0 +1,4 @@
+{
+ "category": "feature_flags",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_deps/describe_passes.json b/crates/runtime/component/tests/declarations/javascript_deps/describe_passes.json
new file mode 100644
index 0000000000..c5e67bce72
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_deps/describe_passes.json
@@ -0,0 +1,4 @@
+{
+ "category": "passes",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_deps/describe_routes.json b/crates/runtime/component/tests/declarations/javascript_deps/describe_routes.json
new file mode 100644
index 0000000000..425fbe7ef2
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_deps/describe_routes.json
@@ -0,0 +1,4 @@
+{
+ "category": "routes",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_deps/describe_settings.json b/crates/runtime/component/tests/declarations/javascript_deps/describe_settings.json
new file mode 100644
index 0000000000..25d73ebee3
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_deps/describe_settings.json
@@ -0,0 +1,4 @@
+{
+ "category": "settings",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_deps/describe_shared_fields.json b/crates/runtime/component/tests/declarations/javascript_deps/describe_shared_fields.json
new file mode 100644
index 0000000000..6677481472
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_deps/describe_shared_fields.json
@@ -0,0 +1,4 @@
+{
+ "category": "shared_fields",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_deps/describe_surfaces.json b/crates/runtime/component/tests/declarations/javascript_deps/describe_surfaces.json
new file mode 100644
index 0000000000..11f01236f3
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_deps/describe_surfaces.json
@@ -0,0 +1,4 @@
+{
+ "category": "surfaces",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_deps/describe_validation_rules.json b/crates/runtime/component/tests/declarations/javascript_deps/describe_validation_rules.json
new file mode 100644
index 0000000000..00357eaaf2
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_deps/describe_validation_rules.json
@@ -0,0 +1,4 @@
+{
+ "category": "validation_rules",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_deps/handshake.json b/crates/runtime/component/tests/declarations/javascript_deps/handshake.json
new file mode 100644
index 0000000000..edbe6f0fe0
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_deps/handshake.json
@@ -0,0 +1,19 @@
+{
+ "protocol_version": "2.3.0",
+ "name": "@javascript/deps",
+ "version": "1.0.0",
+ "peer_dependencies": [
+ {
+ "name": "@code/core",
+ "version": "^1.2",
+ "optional": false
+ },
+ {
+ "name": "@javascript/source",
+ "version": "^1.0",
+ "optional": false
+ }
+ ],
+ "sandbox_policy": null,
+ "description": "Runs cyclonedx-npm and osv-scanner and records dependencies and vulnerabilities as facts (@code/core)"
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_jest/describe_capabilities.json b/crates/runtime/component/tests/declarations/javascript_jest/describe_capabilities.json
new file mode 100644
index 0000000000..4aaf1b02e3
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_jest/describe_capabilities.json
@@ -0,0 +1,32 @@
+{
+ "category": "capabilities",
+ "items": [
+ {
+ "argv": [
+ "node",
+ "--env-file={config}",
+ "node_modules/jest/bin/jest.js",
+ "--reporters=default",
+ "--reporters=jest-junit"
+ ],
+ "call_kinds": [
+ "collect"
+ ],
+ "config": {
+ "name": "jest-junit.env.toml",
+ "template": "JEST_JUNIT_OUTPUT_FILE = \"{report}\"\nJEST_JUNIT_ADD_FILE_ATTRIBUTE = \"true\"\nJEST_JUNIT_ANCESTOR_SEPARATOR = \" > \"\nJEST_JUNIT_SUITE_NAME = \"{filepath}\"\nJEST_JUNIT_CLASSNAME = \"{classname}\"\nJEST_JUNIT_TITLE = \"{title}\"\n"
+ },
+ "env": [
+ "NODE_*",
+ "CI"
+ ],
+ "filter": [
+ "-t",
+ "{filter}"
+ ],
+ "name": "javascript-jest",
+ "port": "process",
+ "why": "run the command whose report the collector 'javascript-jest' reads"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_jest/describe_checkers.json b/crates/runtime/component/tests/declarations/javascript_jest/describe_checkers.json
new file mode 100644
index 0000000000..2c0d93db04
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_jest/describe_checkers.json
@@ -0,0 +1,4 @@
+{
+ "category": "checkers",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_jest/describe_codes.json b/crates/runtime/component/tests/declarations/javascript_jest/describe_codes.json
new file mode 100644
index 0000000000..476fe856cc
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_jest/describe_codes.json
@@ -0,0 +1,4 @@
+{
+ "category": "codes",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_jest/describe_collectors.json b/crates/runtime/component/tests/declarations/javascript_jest/describe_collectors.json
new file mode 100644
index 0000000000..2674150061
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_jest/describe_collectors.json
@@ -0,0 +1,33 @@
+{
+ "category": "collectors",
+ "items": [
+ {
+ "answers": [
+ "test",
+ "test_run"
+ ],
+ "auto_detect": {
+ "env_vars": [],
+ "file_patterns": [
+ "jest.config.*"
+ ]
+ },
+ "capability": "javascript-jest",
+ "export": "collect__javascript_jest",
+ "input_formats": [
+ "junit-xml"
+ ],
+ "inputs": [
+ {
+ "glob": "**/package.json",
+ "input": "files",
+ "name": "packages",
+ "text": true
+ }
+ ],
+ "install": "npm install --save-dev jest jest-junit",
+ "name": "javascript-jest",
+ "report": ".specforge/reports/javascript-jest.xml"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_jest/describe_contexts.json b/crates/runtime/component/tests/declarations/javascript_jest/describe_contexts.json
new file mode 100644
index 0000000000..afd6be3149
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_jest/describe_contexts.json
@@ -0,0 +1,4 @@
+{
+ "category": "contexts",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_jest/describe_edges.json b/crates/runtime/component/tests/declarations/javascript_jest/describe_edges.json
new file mode 100644
index 0000000000..bb4c7452e4
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_jest/describe_edges.json
@@ -0,0 +1,4 @@
+{
+ "category": "edges",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_jest/describe_enhancements.json b/crates/runtime/component/tests/declarations/javascript_jest/describe_enhancements.json
new file mode 100644
index 0000000000..e79b88a896
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_jest/describe_enhancements.json
@@ -0,0 +1,4 @@
+{
+ "category": "enhancements",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_jest/describe_entities.json b/crates/runtime/component/tests/declarations/javascript_jest/describe_entities.json
new file mode 100644
index 0000000000..ade72d8d90
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_jest/describe_entities.json
@@ -0,0 +1,4 @@
+{
+ "category": "entities",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_jest/describe_feature_flags.json b/crates/runtime/component/tests/declarations/javascript_jest/describe_feature_flags.json
new file mode 100644
index 0000000000..355b7dc9d2
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_jest/describe_feature_flags.json
@@ -0,0 +1,4 @@
+{
+ "category": "feature_flags",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_jest/describe_passes.json b/crates/runtime/component/tests/declarations/javascript_jest/describe_passes.json
new file mode 100644
index 0000000000..c5e67bce72
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_jest/describe_passes.json
@@ -0,0 +1,4 @@
+{
+ "category": "passes",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_jest/describe_routes.json b/crates/runtime/component/tests/declarations/javascript_jest/describe_routes.json
new file mode 100644
index 0000000000..425fbe7ef2
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_jest/describe_routes.json
@@ -0,0 +1,4 @@
+{
+ "category": "routes",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_jest/describe_settings.json b/crates/runtime/component/tests/declarations/javascript_jest/describe_settings.json
new file mode 100644
index 0000000000..25d73ebee3
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_jest/describe_settings.json
@@ -0,0 +1,4 @@
+{
+ "category": "settings",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_jest/describe_shared_fields.json b/crates/runtime/component/tests/declarations/javascript_jest/describe_shared_fields.json
new file mode 100644
index 0000000000..6677481472
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_jest/describe_shared_fields.json
@@ -0,0 +1,4 @@
+{
+ "category": "shared_fields",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_jest/describe_surfaces.json b/crates/runtime/component/tests/declarations/javascript_jest/describe_surfaces.json
new file mode 100644
index 0000000000..11f01236f3
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_jest/describe_surfaces.json
@@ -0,0 +1,4 @@
+{
+ "category": "surfaces",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_jest/describe_validation_rules.json b/crates/runtime/component/tests/declarations/javascript_jest/describe_validation_rules.json
new file mode 100644
index 0000000000..00357eaaf2
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_jest/describe_validation_rules.json
@@ -0,0 +1,4 @@
+{
+ "category": "validation_rules",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_jest/handshake.json b/crates/runtime/component/tests/declarations/javascript_jest/handshake.json
new file mode 100644
index 0000000000..5b9aec681c
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_jest/handshake.json
@@ -0,0 +1,19 @@
+{
+ "protocol_version": "2.3.0",
+ "name": "@javascript/jest",
+ "version": "1.0.0",
+ "peer_dependencies": [
+ {
+ "name": "@code/core",
+ "version": "^1.2",
+ "optional": false
+ },
+ {
+ "name": "@javascript/source",
+ "version": "^1.0",
+ "optional": false
+ }
+ ],
+ "sandbox_policy": null,
+ "description": "Runs jest with jest-junit and records its tests as test facts (@code/core)"
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_lint/describe_capabilities.json b/crates/runtime/component/tests/declarations/javascript_lint/describe_capabilities.json
new file mode 100644
index 0000000000..602c4f72e4
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_lint/describe_capabilities.json
@@ -0,0 +1,29 @@
+{
+ "category": "capabilities",
+ "items": [
+ {
+ "argv": [
+ "npx",
+ "--no",
+ "--",
+ "eslint",
+ "--format",
+ "@microsoft/eslint-formatter-sarif",
+ "--output-file",
+ "{report}",
+ "."
+ ],
+ "call_kinds": [
+ "collect"
+ ],
+ "env": [
+ "NODE_*",
+ "ESLINT_*",
+ "CI"
+ ],
+ "name": "javascript-lint",
+ "port": "process",
+ "why": "run the command whose report the collector 'javascript-lint' reads"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_lint/describe_checkers.json b/crates/runtime/component/tests/declarations/javascript_lint/describe_checkers.json
new file mode 100644
index 0000000000..2c0d93db04
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_lint/describe_checkers.json
@@ -0,0 +1,4 @@
+{
+ "category": "checkers",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_lint/describe_codes.json b/crates/runtime/component/tests/declarations/javascript_lint/describe_codes.json
new file mode 100644
index 0000000000..476fe856cc
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_lint/describe_codes.json
@@ -0,0 +1,4 @@
+{
+ "category": "codes",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_lint/describe_collectors.json b/crates/runtime/component/tests/declarations/javascript_lint/describe_collectors.json
new file mode 100644
index 0000000000..16166d413e
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_lint/describe_collectors.json
@@ -0,0 +1,33 @@
+{
+ "category": "collectors",
+ "items": [
+ {
+ "answers": [
+ "static_finding"
+ ],
+ "auto_detect": {
+ "env_vars": [],
+ "file_patterns": [
+ "eslint.config.*"
+ ]
+ },
+ "capability": "javascript-lint",
+ "export": "collect__javascript_lint",
+ "input_formats": [
+ "sarif"
+ ],
+ "inputs": [
+ {
+ "input": "facts",
+ "kinds": [
+ "item",
+ "package"
+ ]
+ }
+ ],
+ "install": "npm install --save-dev eslint @microsoft/eslint-formatter-sarif",
+ "name": "javascript-lint",
+ "report": ".specforge/reports/javascript-lint.sarif"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_lint/describe_contexts.json b/crates/runtime/component/tests/declarations/javascript_lint/describe_contexts.json
new file mode 100644
index 0000000000..afd6be3149
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_lint/describe_contexts.json
@@ -0,0 +1,4 @@
+{
+ "category": "contexts",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_lint/describe_edges.json b/crates/runtime/component/tests/declarations/javascript_lint/describe_edges.json
new file mode 100644
index 0000000000..bb4c7452e4
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_lint/describe_edges.json
@@ -0,0 +1,4 @@
+{
+ "category": "edges",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_lint/describe_enhancements.json b/crates/runtime/component/tests/declarations/javascript_lint/describe_enhancements.json
new file mode 100644
index 0000000000..e79b88a896
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_lint/describe_enhancements.json
@@ -0,0 +1,4 @@
+{
+ "category": "enhancements",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_lint/describe_entities.json b/crates/runtime/component/tests/declarations/javascript_lint/describe_entities.json
new file mode 100644
index 0000000000..ade72d8d90
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_lint/describe_entities.json
@@ -0,0 +1,4 @@
+{
+ "category": "entities",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_lint/describe_feature_flags.json b/crates/runtime/component/tests/declarations/javascript_lint/describe_feature_flags.json
new file mode 100644
index 0000000000..355b7dc9d2
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_lint/describe_feature_flags.json
@@ -0,0 +1,4 @@
+{
+ "category": "feature_flags",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_lint/describe_passes.json b/crates/runtime/component/tests/declarations/javascript_lint/describe_passes.json
new file mode 100644
index 0000000000..c5e67bce72
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_lint/describe_passes.json
@@ -0,0 +1,4 @@
+{
+ "category": "passes",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_lint/describe_routes.json b/crates/runtime/component/tests/declarations/javascript_lint/describe_routes.json
new file mode 100644
index 0000000000..425fbe7ef2
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_lint/describe_routes.json
@@ -0,0 +1,4 @@
+{
+ "category": "routes",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_lint/describe_settings.json b/crates/runtime/component/tests/declarations/javascript_lint/describe_settings.json
new file mode 100644
index 0000000000..25d73ebee3
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_lint/describe_settings.json
@@ -0,0 +1,4 @@
+{
+ "category": "settings",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_lint/describe_shared_fields.json b/crates/runtime/component/tests/declarations/javascript_lint/describe_shared_fields.json
new file mode 100644
index 0000000000..6677481472
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_lint/describe_shared_fields.json
@@ -0,0 +1,4 @@
+{
+ "category": "shared_fields",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_lint/describe_surfaces.json b/crates/runtime/component/tests/declarations/javascript_lint/describe_surfaces.json
new file mode 100644
index 0000000000..11f01236f3
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_lint/describe_surfaces.json
@@ -0,0 +1,4 @@
+{
+ "category": "surfaces",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_lint/describe_validation_rules.json b/crates/runtime/component/tests/declarations/javascript_lint/describe_validation_rules.json
new file mode 100644
index 0000000000..00357eaaf2
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_lint/describe_validation_rules.json
@@ -0,0 +1,4 @@
+{
+ "category": "validation_rules",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_lint/handshake.json b/crates/runtime/component/tests/declarations/javascript_lint/handshake.json
new file mode 100644
index 0000000000..81082446c6
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_lint/handshake.json
@@ -0,0 +1,19 @@
+{
+ "protocol_version": "2.3.0",
+ "name": "@javascript/lint",
+ "version": "1.0.0",
+ "peer_dependencies": [
+ {
+ "name": "@code/core",
+ "version": "^1.2",
+ "optional": false
+ },
+ {
+ "name": "@javascript/source",
+ "version": "^1.0",
+ "optional": false
+ }
+ ],
+ "sandbox_policy": null,
+ "description": "Runs ESLint with its SARIF formatter and records its findings as static_finding facts (@code/core)"
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_playwright/describe_capabilities.json b/crates/runtime/component/tests/declarations/javascript_playwright/describe_capabilities.json
new file mode 100644
index 0000000000..86bf7a9e07
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_playwright/describe_capabilities.json
@@ -0,0 +1,31 @@
+{
+ "category": "capabilities",
+ "items": [
+ {
+ "argv": [
+ "npx",
+ "--no",
+ "--",
+ "playwright",
+ "test",
+ "--reporter=junit",
+ "--output=.specforge/reports/javascript-playwright-results"
+ ],
+ "call_kinds": [
+ "collect"
+ ],
+ "env": [
+ "NODE_*",
+ "PLAYWRIGHT_BROWSERS_PATH",
+ "CI"
+ ],
+ "filter": [
+ "--grep",
+ "{filter}"
+ ],
+ "name": "javascript-playwright",
+ "port": "process",
+ "why": "run the command whose report the collector 'javascript-playwright' reads"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_playwright/describe_checkers.json b/crates/runtime/component/tests/declarations/javascript_playwright/describe_checkers.json
new file mode 100644
index 0000000000..2c0d93db04
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_playwright/describe_checkers.json
@@ -0,0 +1,4 @@
+{
+ "category": "checkers",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_playwright/describe_codes.json b/crates/runtime/component/tests/declarations/javascript_playwright/describe_codes.json
new file mode 100644
index 0000000000..476fe856cc
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_playwright/describe_codes.json
@@ -0,0 +1,4 @@
+{
+ "category": "codes",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_playwright/describe_collectors.json b/crates/runtime/component/tests/declarations/javascript_playwright/describe_collectors.json
new file mode 100644
index 0000000000..4cded500ce
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_playwright/describe_collectors.json
@@ -0,0 +1,34 @@
+{
+ "category": "collectors",
+ "items": [
+ {
+ "answers": [
+ "test",
+ "test_run"
+ ],
+ "auto_detect": {
+ "env_vars": [],
+ "file_patterns": [
+ "playwright.config.*"
+ ]
+ },
+ "capability": "javascript-playwright",
+ "capture": "stdout",
+ "export": "collect__javascript_playwright",
+ "input_formats": [
+ "junit-xml"
+ ],
+ "inputs": [
+ {
+ "glob": "**/package.json",
+ "input": "files",
+ "name": "packages",
+ "text": true
+ }
+ ],
+ "install": "npm install --save-dev @playwright/test",
+ "name": "javascript-playwright",
+ "report": ".specforge/reports/javascript-playwright"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_playwright/describe_contexts.json b/crates/runtime/component/tests/declarations/javascript_playwright/describe_contexts.json
new file mode 100644
index 0000000000..afd6be3149
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_playwright/describe_contexts.json
@@ -0,0 +1,4 @@
+{
+ "category": "contexts",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_playwright/describe_edges.json b/crates/runtime/component/tests/declarations/javascript_playwright/describe_edges.json
new file mode 100644
index 0000000000..bb4c7452e4
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_playwright/describe_edges.json
@@ -0,0 +1,4 @@
+{
+ "category": "edges",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_playwright/describe_enhancements.json b/crates/runtime/component/tests/declarations/javascript_playwright/describe_enhancements.json
new file mode 100644
index 0000000000..e79b88a896
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_playwright/describe_enhancements.json
@@ -0,0 +1,4 @@
+{
+ "category": "enhancements",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_playwright/describe_entities.json b/crates/runtime/component/tests/declarations/javascript_playwright/describe_entities.json
new file mode 100644
index 0000000000..ade72d8d90
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_playwright/describe_entities.json
@@ -0,0 +1,4 @@
+{
+ "category": "entities",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_playwright/describe_feature_flags.json b/crates/runtime/component/tests/declarations/javascript_playwright/describe_feature_flags.json
new file mode 100644
index 0000000000..355b7dc9d2
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_playwright/describe_feature_flags.json
@@ -0,0 +1,4 @@
+{
+ "category": "feature_flags",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_playwright/describe_passes.json b/crates/runtime/component/tests/declarations/javascript_playwright/describe_passes.json
new file mode 100644
index 0000000000..c5e67bce72
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_playwright/describe_passes.json
@@ -0,0 +1,4 @@
+{
+ "category": "passes",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_playwright/describe_routes.json b/crates/runtime/component/tests/declarations/javascript_playwright/describe_routes.json
new file mode 100644
index 0000000000..425fbe7ef2
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_playwright/describe_routes.json
@@ -0,0 +1,4 @@
+{
+ "category": "routes",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_playwright/describe_settings.json b/crates/runtime/component/tests/declarations/javascript_playwright/describe_settings.json
new file mode 100644
index 0000000000..25d73ebee3
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_playwright/describe_settings.json
@@ -0,0 +1,4 @@
+{
+ "category": "settings",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_playwright/describe_shared_fields.json b/crates/runtime/component/tests/declarations/javascript_playwright/describe_shared_fields.json
new file mode 100644
index 0000000000..6677481472
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_playwright/describe_shared_fields.json
@@ -0,0 +1,4 @@
+{
+ "category": "shared_fields",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_playwright/describe_surfaces.json b/crates/runtime/component/tests/declarations/javascript_playwright/describe_surfaces.json
new file mode 100644
index 0000000000..11f01236f3
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_playwright/describe_surfaces.json
@@ -0,0 +1,4 @@
+{
+ "category": "surfaces",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_playwright/describe_validation_rules.json b/crates/runtime/component/tests/declarations/javascript_playwright/describe_validation_rules.json
new file mode 100644
index 0000000000..00357eaaf2
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_playwright/describe_validation_rules.json
@@ -0,0 +1,4 @@
+{
+ "category": "validation_rules",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_playwright/handshake.json b/crates/runtime/component/tests/declarations/javascript_playwright/handshake.json
new file mode 100644
index 0000000000..5fec38b7cd
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_playwright/handshake.json
@@ -0,0 +1,19 @@
+{
+ "protocol_version": "2.3.0",
+ "name": "@javascript/playwright",
+ "version": "1.0.0",
+ "peer_dependencies": [
+ {
+ "name": "@code/core",
+ "version": "^1.2",
+ "optional": false
+ },
+ {
+ "name": "@javascript/source",
+ "version": "^1.0",
+ "optional": false
+ }
+ ],
+ "sandbox_policy": null,
+ "description": "Runs Playwright and records its tests as test facts (@code/core)"
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_vitest/describe_capabilities.json b/crates/runtime/component/tests/declarations/javascript_vitest/describe_capabilities.json
new file mode 100644
index 0000000000..9f5c941bb1
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_vitest/describe_capabilities.json
@@ -0,0 +1,32 @@
+{
+ "category": "capabilities",
+ "items": [
+ {
+ "argv": [
+ "npx",
+ "--no",
+ "--",
+ "vitest",
+ "run",
+ "--reporter=default",
+ "--reporter=junit",
+ "--outputFile.junit={report}"
+ ],
+ "call_kinds": [
+ "collect"
+ ],
+ "env": [
+ "NODE_*",
+ "VITEST_*",
+ "CI"
+ ],
+ "filter": [
+ "-t",
+ "{filter}"
+ ],
+ "name": "javascript-vitest",
+ "port": "process",
+ "why": "run the command whose report the collector 'javascript-vitest' reads"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_vitest/describe_checkers.json b/crates/runtime/component/tests/declarations/javascript_vitest/describe_checkers.json
new file mode 100644
index 0000000000..2c0d93db04
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_vitest/describe_checkers.json
@@ -0,0 +1,4 @@
+{
+ "category": "checkers",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_vitest/describe_codes.json b/crates/runtime/component/tests/declarations/javascript_vitest/describe_codes.json
new file mode 100644
index 0000000000..476fe856cc
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_vitest/describe_codes.json
@@ -0,0 +1,4 @@
+{
+ "category": "codes",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_vitest/describe_collectors.json b/crates/runtime/component/tests/declarations/javascript_vitest/describe_collectors.json
new file mode 100644
index 0000000000..c4f94d4037
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_vitest/describe_collectors.json
@@ -0,0 +1,34 @@
+{
+ "category": "collectors",
+ "items": [
+ {
+ "answers": [
+ "test",
+ "test_run"
+ ],
+ "auto_detect": {
+ "env_vars": [],
+ "file_patterns": [
+ "vitest.config.*",
+ "vitest.workspace.*"
+ ]
+ },
+ "capability": "javascript-vitest",
+ "export": "collect__javascript_vitest",
+ "input_formats": [
+ "junit-xml"
+ ],
+ "inputs": [
+ {
+ "glob": "**/package.json",
+ "input": "files",
+ "name": "packages",
+ "text": true
+ }
+ ],
+ "install": "npm install --save-dev vitest",
+ "name": "javascript-vitest",
+ "report": ".specforge/reports/javascript-vitest.xml"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_vitest/describe_contexts.json b/crates/runtime/component/tests/declarations/javascript_vitest/describe_contexts.json
new file mode 100644
index 0000000000..afd6be3149
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_vitest/describe_contexts.json
@@ -0,0 +1,4 @@
+{
+ "category": "contexts",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_vitest/describe_edges.json b/crates/runtime/component/tests/declarations/javascript_vitest/describe_edges.json
new file mode 100644
index 0000000000..bb4c7452e4
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_vitest/describe_edges.json
@@ -0,0 +1,4 @@
+{
+ "category": "edges",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_vitest/describe_enhancements.json b/crates/runtime/component/tests/declarations/javascript_vitest/describe_enhancements.json
new file mode 100644
index 0000000000..e79b88a896
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_vitest/describe_enhancements.json
@@ -0,0 +1,4 @@
+{
+ "category": "enhancements",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_vitest/describe_entities.json b/crates/runtime/component/tests/declarations/javascript_vitest/describe_entities.json
new file mode 100644
index 0000000000..ade72d8d90
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_vitest/describe_entities.json
@@ -0,0 +1,4 @@
+{
+ "category": "entities",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_vitest/describe_feature_flags.json b/crates/runtime/component/tests/declarations/javascript_vitest/describe_feature_flags.json
new file mode 100644
index 0000000000..355b7dc9d2
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_vitest/describe_feature_flags.json
@@ -0,0 +1,4 @@
+{
+ "category": "feature_flags",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_vitest/describe_passes.json b/crates/runtime/component/tests/declarations/javascript_vitest/describe_passes.json
new file mode 100644
index 0000000000..c5e67bce72
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_vitest/describe_passes.json
@@ -0,0 +1,4 @@
+{
+ "category": "passes",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_vitest/describe_routes.json b/crates/runtime/component/tests/declarations/javascript_vitest/describe_routes.json
new file mode 100644
index 0000000000..425fbe7ef2
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_vitest/describe_routes.json
@@ -0,0 +1,4 @@
+{
+ "category": "routes",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_vitest/describe_settings.json b/crates/runtime/component/tests/declarations/javascript_vitest/describe_settings.json
new file mode 100644
index 0000000000..25d73ebee3
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_vitest/describe_settings.json
@@ -0,0 +1,4 @@
+{
+ "category": "settings",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_vitest/describe_shared_fields.json b/crates/runtime/component/tests/declarations/javascript_vitest/describe_shared_fields.json
new file mode 100644
index 0000000000..6677481472
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_vitest/describe_shared_fields.json
@@ -0,0 +1,4 @@
+{
+ "category": "shared_fields",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_vitest/describe_surfaces.json b/crates/runtime/component/tests/declarations/javascript_vitest/describe_surfaces.json
new file mode 100644
index 0000000000..11f01236f3
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_vitest/describe_surfaces.json
@@ -0,0 +1,4 @@
+{
+ "category": "surfaces",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_vitest/describe_validation_rules.json b/crates/runtime/component/tests/declarations/javascript_vitest/describe_validation_rules.json
new file mode 100644
index 0000000000..00357eaaf2
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_vitest/describe_validation_rules.json
@@ -0,0 +1,4 @@
+{
+ "category": "validation_rules",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/javascript_vitest/handshake.json b/crates/runtime/component/tests/declarations/javascript_vitest/handshake.json
new file mode 100644
index 0000000000..50fa0544c1
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/javascript_vitest/handshake.json
@@ -0,0 +1,19 @@
+{
+ "protocol_version": "2.3.0",
+ "name": "@javascript/vitest",
+ "version": "1.0.0",
+ "peer_dependencies": [
+ {
+ "name": "@code/core",
+ "version": "^1.2",
+ "optional": false
+ },
+ {
+ "name": "@javascript/source",
+ "version": "^1.0",
+ "optional": false
+ }
+ ],
+ "sandbox_policy": null,
+ "description": "Runs vitest and records its tests as test facts (@code/core)"
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_api/describe_capabilities.json b/crates/runtime/component/tests/declarations/rust_api/describe_capabilities.json
new file mode 100644
index 0000000000..2151cf59ac
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_api/describe_capabilities.json
@@ -0,0 +1,32 @@
+{
+ "category": "capabilities",
+ "items": [
+ {
+ "argv": [
+ "cargo-public-api",
+ "--color",
+ "never",
+ "-ss"
+ ],
+ "call_kinds": [
+ "collect"
+ ],
+ "env": [
+ "CARGO_*",
+ "RUSTUP_*",
+ "RUSTC",
+ "RUSTC_*",
+ "RUSTFLAGS",
+ "RUSTDOCFLAGS",
+ "RUST_LOG"
+ ],
+ "filter": [
+ "--package",
+ "{filter}"
+ ],
+ "name": "rust-api",
+ "port": "process",
+ "why": "run the command whose report the collector 'rust-api' reads"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_api/describe_checkers.json b/crates/runtime/component/tests/declarations/rust_api/describe_checkers.json
new file mode 100644
index 0000000000..2c0d93db04
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_api/describe_checkers.json
@@ -0,0 +1,4 @@
+{
+ "category": "checkers",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_api/describe_codes.json b/crates/runtime/component/tests/declarations/rust_api/describe_codes.json
new file mode 100644
index 0000000000..476fe856cc
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_api/describe_codes.json
@@ -0,0 +1,4 @@
+{
+ "category": "codes",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_api/describe_collectors.json b/crates/runtime/component/tests/declarations/rust_api/describe_collectors.json
new file mode 100644
index 0000000000..26955d557b
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_api/describe_collectors.json
@@ -0,0 +1,41 @@
+{
+ "category": "collectors",
+ "items": [
+ {
+ "answers": [
+ "api_item"
+ ],
+ "auto_detect": {
+ "env_vars": [],
+ "file_patterns": [
+ "Cargo.toml"
+ ]
+ },
+ "capability": "rust-api",
+ "capture": "stdout",
+ "export": "collect__rust_api",
+ "input_formats": [
+ "public-api-text"
+ ],
+ "inputs": [
+ {
+ "input": "facts",
+ "kinds": [
+ "item",
+ "package"
+ ]
+ },
+ {
+ "glob": "**/public-api.txt",
+ "input": "files",
+ "name": "accepted",
+ "text": true,
+ "text_max": 4194304
+ }
+ ],
+ "install": "cargo install cargo-public-api --locked (and: rustup toolchain install nightly --profile minimal)",
+ "name": "rust-api",
+ "report": ".specforge/reports/rust-api"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_api/describe_contexts.json b/crates/runtime/component/tests/declarations/rust_api/describe_contexts.json
new file mode 100644
index 0000000000..afd6be3149
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_api/describe_contexts.json
@@ -0,0 +1,4 @@
+{
+ "category": "contexts",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_api/describe_edges.json b/crates/runtime/component/tests/declarations/rust_api/describe_edges.json
new file mode 100644
index 0000000000..bb4c7452e4
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_api/describe_edges.json
@@ -0,0 +1,4 @@
+{
+ "category": "edges",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_api/describe_enhancements.json b/crates/runtime/component/tests/declarations/rust_api/describe_enhancements.json
new file mode 100644
index 0000000000..e79b88a896
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_api/describe_enhancements.json
@@ -0,0 +1,4 @@
+{
+ "category": "enhancements",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_api/describe_entities.json b/crates/runtime/component/tests/declarations/rust_api/describe_entities.json
new file mode 100644
index 0000000000..ade72d8d90
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_api/describe_entities.json
@@ -0,0 +1,4 @@
+{
+ "category": "entities",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_api/describe_feature_flags.json b/crates/runtime/component/tests/declarations/rust_api/describe_feature_flags.json
new file mode 100644
index 0000000000..355b7dc9d2
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_api/describe_feature_flags.json
@@ -0,0 +1,4 @@
+{
+ "category": "feature_flags",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_api/describe_passes.json b/crates/runtime/component/tests/declarations/rust_api/describe_passes.json
new file mode 100644
index 0000000000..c5e67bce72
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_api/describe_passes.json
@@ -0,0 +1,4 @@
+{
+ "category": "passes",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_api/describe_routes.json b/crates/runtime/component/tests/declarations/rust_api/describe_routes.json
new file mode 100644
index 0000000000..425fbe7ef2
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_api/describe_routes.json
@@ -0,0 +1,4 @@
+{
+ "category": "routes",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_api/describe_settings.json b/crates/runtime/component/tests/declarations/rust_api/describe_settings.json
new file mode 100644
index 0000000000..25d73ebee3
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_api/describe_settings.json
@@ -0,0 +1,4 @@
+{
+ "category": "settings",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_api/describe_shared_fields.json b/crates/runtime/component/tests/declarations/rust_api/describe_shared_fields.json
new file mode 100644
index 0000000000..6677481472
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_api/describe_shared_fields.json
@@ -0,0 +1,4 @@
+{
+ "category": "shared_fields",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_api/describe_surfaces.json b/crates/runtime/component/tests/declarations/rust_api/describe_surfaces.json
new file mode 100644
index 0000000000..11f01236f3
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_api/describe_surfaces.json
@@ -0,0 +1,4 @@
+{
+ "category": "surfaces",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_api/describe_validation_rules.json b/crates/runtime/component/tests/declarations/rust_api/describe_validation_rules.json
new file mode 100644
index 0000000000..00357eaaf2
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_api/describe_validation_rules.json
@@ -0,0 +1,4 @@
+{
+ "category": "validation_rules",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_api/handshake.json b/crates/runtime/component/tests/declarations/rust_api/handshake.json
new file mode 100644
index 0000000000..6dcad0a6d9
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_api/handshake.json
@@ -0,0 +1,19 @@
+{
+ "protocol_version": "2.3.0",
+ "name": "@rust/api",
+ "version": "1.0.0",
+ "peer_dependencies": [
+ {
+ "name": "@code/core",
+ "version": "^1.4",
+ "optional": false
+ },
+ {
+ "name": "@rust/source",
+ "version": "^1.0",
+ "optional": false
+ }
+ ],
+ "sandbox_policy": null,
+ "description": "Runs cargo public-api and records the crate's public API as api_item facts (@code/core)"
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_cargo/describe_settings.json b/crates/runtime/component/tests/declarations/rust_cargo/describe_settings.json
index 25d73ebee3..f2031fa58c 100644
--- a/crates/runtime/component/tests/declarations/rust_cargo/describe_settings.json
+++ b/crates/runtime/component/tests/declarations/rust_cargo/describe_settings.json
@@ -1,4 +1,12 @@
{
"category": "settings",
- "items": []
+ "items": [
+ {
+ "default": [],
+ "description": "Project-relative directories whose manifests are no packages of this project (a fixture's or an example's crate): @rust/cargo answers no package for a manifest in or under one, so @rust/source reads no item there; the tool-running packs still run over the whole cargo workspace",
+ "field_type": "string_list",
+ "kind": "setting",
+ "name": "exclude"
+ }
+ ]
}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_coverage/describe_capabilities.json b/crates/runtime/component/tests/declarations/rust_coverage/describe_capabilities.json
new file mode 100644
index 0000000000..6553faa138
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_coverage/describe_capabilities.json
@@ -0,0 +1,32 @@
+{
+ "category": "capabilities",
+ "items": [
+ {
+ "argv": [
+ "cargo-llvm-cov",
+ "llvm-cov",
+ "nextest",
+ "--workspace",
+ "--ignore-run-fail",
+ "--lcov",
+ "--output-path",
+ "{report}"
+ ],
+ "call_kinds": [
+ "collect"
+ ],
+ "env": [
+ "CARGO_*",
+ "RUSTUP_*",
+ "RUSTC",
+ "RUSTC_*",
+ "RUSTFLAGS",
+ "RUSTDOCFLAGS",
+ "LLVM_*"
+ ],
+ "name": "rust-coverage",
+ "port": "process",
+ "why": "run the command whose report the collector 'rust-coverage' reads"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_coverage/describe_checkers.json b/crates/runtime/component/tests/declarations/rust_coverage/describe_checkers.json
new file mode 100644
index 0000000000..2c0d93db04
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_coverage/describe_checkers.json
@@ -0,0 +1,4 @@
+{
+ "category": "checkers",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_coverage/describe_codes.json b/crates/runtime/component/tests/declarations/rust_coverage/describe_codes.json
new file mode 100644
index 0000000000..476fe856cc
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_coverage/describe_codes.json
@@ -0,0 +1,4 @@
+{
+ "category": "codes",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_coverage/describe_collectors.json b/crates/runtime/component/tests/declarations/rust_coverage/describe_collectors.json
new file mode 100644
index 0000000000..600a2d5cc9
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_coverage/describe_collectors.json
@@ -0,0 +1,35 @@
+{
+ "category": "collectors",
+ "items": [
+ {
+ "answers": [
+ "coverage"
+ ],
+ "auto_detect": {
+ "env_vars": [],
+ "file_patterns": [
+ "Cargo.toml"
+ ]
+ },
+ "capability": "rust-coverage",
+ "export": "collect__rust_coverage",
+ "input_formats": [
+ "lcov"
+ ],
+ "inputs": [
+ {
+ "input": "facts",
+ "kinds": [
+ "item"
+ ]
+ }
+ ],
+ "install": "cargo install cargo-llvm-cov cargo-nextest --locked",
+ "name": "rust-coverage",
+ "report": ".specforge/reports/rust-coverage.lcov",
+ "requires": [
+ "cargo-nextest"
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_coverage/describe_contexts.json b/crates/runtime/component/tests/declarations/rust_coverage/describe_contexts.json
new file mode 100644
index 0000000000..afd6be3149
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_coverage/describe_contexts.json
@@ -0,0 +1,4 @@
+{
+ "category": "contexts",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_coverage/describe_edges.json b/crates/runtime/component/tests/declarations/rust_coverage/describe_edges.json
new file mode 100644
index 0000000000..bb4c7452e4
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_coverage/describe_edges.json
@@ -0,0 +1,4 @@
+{
+ "category": "edges",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_coverage/describe_enhancements.json b/crates/runtime/component/tests/declarations/rust_coverage/describe_enhancements.json
new file mode 100644
index 0000000000..e79b88a896
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_coverage/describe_enhancements.json
@@ -0,0 +1,4 @@
+{
+ "category": "enhancements",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_coverage/describe_entities.json b/crates/runtime/component/tests/declarations/rust_coverage/describe_entities.json
new file mode 100644
index 0000000000..ade72d8d90
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_coverage/describe_entities.json
@@ -0,0 +1,4 @@
+{
+ "category": "entities",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_coverage/describe_feature_flags.json b/crates/runtime/component/tests/declarations/rust_coverage/describe_feature_flags.json
new file mode 100644
index 0000000000..355b7dc9d2
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_coverage/describe_feature_flags.json
@@ -0,0 +1,4 @@
+{
+ "category": "feature_flags",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_coverage/describe_passes.json b/crates/runtime/component/tests/declarations/rust_coverage/describe_passes.json
new file mode 100644
index 0000000000..c5e67bce72
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_coverage/describe_passes.json
@@ -0,0 +1,4 @@
+{
+ "category": "passes",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_coverage/describe_routes.json b/crates/runtime/component/tests/declarations/rust_coverage/describe_routes.json
new file mode 100644
index 0000000000..425fbe7ef2
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_coverage/describe_routes.json
@@ -0,0 +1,4 @@
+{
+ "category": "routes",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_coverage/describe_settings.json b/crates/runtime/component/tests/declarations/rust_coverage/describe_settings.json
new file mode 100644
index 0000000000..25d73ebee3
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_coverage/describe_settings.json
@@ -0,0 +1,4 @@
+{
+ "category": "settings",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_coverage/describe_shared_fields.json b/crates/runtime/component/tests/declarations/rust_coverage/describe_shared_fields.json
new file mode 100644
index 0000000000..6677481472
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_coverage/describe_shared_fields.json
@@ -0,0 +1,4 @@
+{
+ "category": "shared_fields",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_coverage/describe_surfaces.json b/crates/runtime/component/tests/declarations/rust_coverage/describe_surfaces.json
new file mode 100644
index 0000000000..11f01236f3
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_coverage/describe_surfaces.json
@@ -0,0 +1,4 @@
+{
+ "category": "surfaces",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_coverage/describe_validation_rules.json b/crates/runtime/component/tests/declarations/rust_coverage/describe_validation_rules.json
new file mode 100644
index 0000000000..00357eaaf2
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_coverage/describe_validation_rules.json
@@ -0,0 +1,4 @@
+{
+ "category": "validation_rules",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_coverage/handshake.json b/crates/runtime/component/tests/declarations/rust_coverage/handshake.json
new file mode 100644
index 0000000000..22a39f0c62
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_coverage/handshake.json
@@ -0,0 +1,19 @@
+{
+ "protocol_version": "2.3.0",
+ "name": "@rust/coverage",
+ "version": "1.0.0",
+ "peer_dependencies": [
+ {
+ "name": "@code/core",
+ "version": "^1.2",
+ "optional": false
+ },
+ {
+ "name": "@rust/source",
+ "version": "^1.0",
+ "optional": false
+ }
+ ],
+ "sandbox_policy": null,
+ "description": "Runs cargo llvm-cov and records its LCOV coverage as coverage facts (@code/core)"
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_deps/describe_capabilities.json b/crates/runtime/component/tests/declarations/rust_deps/describe_capabilities.json
new file mode 100644
index 0000000000..d5895c338a
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_deps/describe_capabilities.json
@@ -0,0 +1,59 @@
+{
+ "category": "capabilities",
+ "items": [
+ {
+ "argv": [
+ "cargo-cyclonedx",
+ "cyclonedx",
+ "--format",
+ "json",
+ "--spec-version",
+ "1.5",
+ "--all-features",
+ "--override-filename",
+ "rust-sbom.cdx"
+ ],
+ "call_kinds": [
+ "collect"
+ ],
+ "env": [
+ "CARGO_*",
+ "RUSTUP_*",
+ "RUSTC",
+ "RUSTC_*",
+ "SOURCE_DATE_EPOCH"
+ ],
+ "name": "rust-sbom",
+ "port": "process",
+ "why": "run the command whose report the collector 'rust-sbom' reads"
+ },
+ {
+ "argv": [
+ "osv-scanner",
+ "scan",
+ "source",
+ "--lockfile",
+ "Cargo.lock",
+ "--format",
+ "json",
+ "--output-file",
+ "{report}"
+ ],
+ "call_kinds": [
+ "collect"
+ ],
+ "env": [
+ "HTTPS_PROXY",
+ "HTTP_PROXY",
+ "NO_PROXY",
+ "https_proxy",
+ "http_proxy",
+ "no_proxy",
+ "OSV_*"
+ ],
+ "name": "rust-osv",
+ "port": "process",
+ "why": "run the command whose report the collector 'rust-osv' reads"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_deps/describe_checkers.json b/crates/runtime/component/tests/declarations/rust_deps/describe_checkers.json
new file mode 100644
index 0000000000..2c0d93db04
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_deps/describe_checkers.json
@@ -0,0 +1,4 @@
+{
+ "category": "checkers",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_deps/describe_codes.json b/crates/runtime/component/tests/declarations/rust_deps/describe_codes.json
new file mode 100644
index 0000000000..476fe856cc
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_deps/describe_codes.json
@@ -0,0 +1,4 @@
+{
+ "category": "codes",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_deps/describe_collectors.json b/crates/runtime/component/tests/declarations/rust_deps/describe_collectors.json
new file mode 100644
index 0000000000..75b5b50f9d
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_deps/describe_collectors.json
@@ -0,0 +1,59 @@
+{
+ "category": "collectors",
+ "items": [
+ {
+ "answers": [
+ "dependency"
+ ],
+ "auto_detect": {
+ "env_vars": [],
+ "file_patterns": [
+ "Cargo.toml"
+ ]
+ },
+ "capability": "rust-sbom",
+ "export": "collect__rust_sbom",
+ "input_formats": [
+ "cyclonedx-json"
+ ],
+ "inputs": [
+ {
+ "input": "facts",
+ "kinds": [
+ "package"
+ ]
+ }
+ ],
+ "install": "cargo install cargo-cyclonedx --locked",
+ "name": "rust-sbom",
+ "report": "**/rust-sbom.cdx.json"
+ },
+ {
+ "answers": [
+ "vulnerability"
+ ],
+ "auto_detect": {
+ "env_vars": [],
+ "file_patterns": [
+ "Cargo.lock"
+ ]
+ },
+ "capability": "rust-osv",
+ "export": "collect__rust_osv",
+ "input_formats": [
+ "osv-json"
+ ],
+ "inputs": [
+ {
+ "input": "facts",
+ "kinds": [
+ "package"
+ ]
+ }
+ ],
+ "install": "go install github.com/google/osv-scanner/v2/cmd/osv-scanner@latest (or: brew install osv-scanner)",
+ "name": "rust-osv",
+ "report": ".specforge/reports/rust-osv.json"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_deps/describe_contexts.json b/crates/runtime/component/tests/declarations/rust_deps/describe_contexts.json
new file mode 100644
index 0000000000..afd6be3149
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_deps/describe_contexts.json
@@ -0,0 +1,4 @@
+{
+ "category": "contexts",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_deps/describe_edges.json b/crates/runtime/component/tests/declarations/rust_deps/describe_edges.json
new file mode 100644
index 0000000000..bb4c7452e4
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_deps/describe_edges.json
@@ -0,0 +1,4 @@
+{
+ "category": "edges",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_deps/describe_enhancements.json b/crates/runtime/component/tests/declarations/rust_deps/describe_enhancements.json
new file mode 100644
index 0000000000..e79b88a896
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_deps/describe_enhancements.json
@@ -0,0 +1,4 @@
+{
+ "category": "enhancements",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_deps/describe_entities.json b/crates/runtime/component/tests/declarations/rust_deps/describe_entities.json
new file mode 100644
index 0000000000..ade72d8d90
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_deps/describe_entities.json
@@ -0,0 +1,4 @@
+{
+ "category": "entities",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_deps/describe_feature_flags.json b/crates/runtime/component/tests/declarations/rust_deps/describe_feature_flags.json
new file mode 100644
index 0000000000..355b7dc9d2
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_deps/describe_feature_flags.json
@@ -0,0 +1,4 @@
+{
+ "category": "feature_flags",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_deps/describe_passes.json b/crates/runtime/component/tests/declarations/rust_deps/describe_passes.json
new file mode 100644
index 0000000000..c5e67bce72
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_deps/describe_passes.json
@@ -0,0 +1,4 @@
+{
+ "category": "passes",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_deps/describe_routes.json b/crates/runtime/component/tests/declarations/rust_deps/describe_routes.json
new file mode 100644
index 0000000000..425fbe7ef2
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_deps/describe_routes.json
@@ -0,0 +1,4 @@
+{
+ "category": "routes",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_deps/describe_settings.json b/crates/runtime/component/tests/declarations/rust_deps/describe_settings.json
new file mode 100644
index 0000000000..25d73ebee3
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_deps/describe_settings.json
@@ -0,0 +1,4 @@
+{
+ "category": "settings",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_deps/describe_shared_fields.json b/crates/runtime/component/tests/declarations/rust_deps/describe_shared_fields.json
new file mode 100644
index 0000000000..6677481472
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_deps/describe_shared_fields.json
@@ -0,0 +1,4 @@
+{
+ "category": "shared_fields",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_deps/describe_surfaces.json b/crates/runtime/component/tests/declarations/rust_deps/describe_surfaces.json
new file mode 100644
index 0000000000..11f01236f3
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_deps/describe_surfaces.json
@@ -0,0 +1,4 @@
+{
+ "category": "surfaces",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_deps/describe_validation_rules.json b/crates/runtime/component/tests/declarations/rust_deps/describe_validation_rules.json
new file mode 100644
index 0000000000..00357eaaf2
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_deps/describe_validation_rules.json
@@ -0,0 +1,4 @@
+{
+ "category": "validation_rules",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_deps/handshake.json b/crates/runtime/component/tests/declarations/rust_deps/handshake.json
new file mode 100644
index 0000000000..54cc8d5d05
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_deps/handshake.json
@@ -0,0 +1,19 @@
+{
+ "protocol_version": "2.3.0",
+ "name": "@rust/deps",
+ "version": "1.0.0",
+ "peer_dependencies": [
+ {
+ "name": "@code/core",
+ "version": "^1.2",
+ "optional": false
+ },
+ {
+ "name": "@rust/source",
+ "version": "^1.0",
+ "optional": false
+ }
+ ],
+ "sandbox_policy": null,
+ "description": "Runs cargo-cyclonedx and osv-scanner and records dependencies and vulnerabilities as facts (@code/core)"
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_lint/describe_capabilities.json b/crates/runtime/component/tests/declarations/rust_lint/describe_capabilities.json
new file mode 100644
index 0000000000..5882bcf8a9
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_lint/describe_capabilities.json
@@ -0,0 +1,29 @@
+{
+ "category": "capabilities",
+ "items": [
+ {
+ "argv": [
+ "cargo-clippy",
+ "clippy",
+ "--workspace",
+ "--all-targets",
+ "--message-format=json"
+ ],
+ "call_kinds": [
+ "collect"
+ ],
+ "env": [
+ "CARGO_*",
+ "RUSTUP_*",
+ "RUSTC",
+ "RUSTC_*",
+ "RUSTFLAGS",
+ "RUSTDOCFLAGS",
+ "CLIPPY_*"
+ ],
+ "name": "rust-lint",
+ "port": "process",
+ "why": "run the command whose report the collector 'rust-lint' reads"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_lint/describe_checkers.json b/crates/runtime/component/tests/declarations/rust_lint/describe_checkers.json
new file mode 100644
index 0000000000..2c0d93db04
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_lint/describe_checkers.json
@@ -0,0 +1,4 @@
+{
+ "category": "checkers",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_lint/describe_codes.json b/crates/runtime/component/tests/declarations/rust_lint/describe_codes.json
new file mode 100644
index 0000000000..476fe856cc
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_lint/describe_codes.json
@@ -0,0 +1,4 @@
+{
+ "category": "codes",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_lint/describe_collectors.json b/crates/runtime/component/tests/declarations/rust_lint/describe_collectors.json
new file mode 100644
index 0000000000..430fce273b
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_lint/describe_collectors.json
@@ -0,0 +1,34 @@
+{
+ "category": "collectors",
+ "items": [
+ {
+ "answers": [
+ "static_finding"
+ ],
+ "auto_detect": {
+ "env_vars": [],
+ "file_patterns": [
+ "Cargo.toml"
+ ]
+ },
+ "capability": "rust-lint",
+ "capture": "stdout",
+ "export": "collect__rust_lint",
+ "input_formats": [
+ "cargo-json"
+ ],
+ "inputs": [
+ {
+ "input": "facts",
+ "kinds": [
+ "item",
+ "package"
+ ]
+ }
+ ],
+ "install": "rustup component add clippy",
+ "name": "rust-lint",
+ "report": ".specforge/reports/rust-lint"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_lint/describe_contexts.json b/crates/runtime/component/tests/declarations/rust_lint/describe_contexts.json
new file mode 100644
index 0000000000..afd6be3149
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_lint/describe_contexts.json
@@ -0,0 +1,4 @@
+{
+ "category": "contexts",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_lint/describe_edges.json b/crates/runtime/component/tests/declarations/rust_lint/describe_edges.json
new file mode 100644
index 0000000000..bb4c7452e4
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_lint/describe_edges.json
@@ -0,0 +1,4 @@
+{
+ "category": "edges",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_lint/describe_enhancements.json b/crates/runtime/component/tests/declarations/rust_lint/describe_enhancements.json
new file mode 100644
index 0000000000..e79b88a896
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_lint/describe_enhancements.json
@@ -0,0 +1,4 @@
+{
+ "category": "enhancements",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_lint/describe_entities.json b/crates/runtime/component/tests/declarations/rust_lint/describe_entities.json
new file mode 100644
index 0000000000..ade72d8d90
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_lint/describe_entities.json
@@ -0,0 +1,4 @@
+{
+ "category": "entities",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_lint/describe_feature_flags.json b/crates/runtime/component/tests/declarations/rust_lint/describe_feature_flags.json
new file mode 100644
index 0000000000..355b7dc9d2
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_lint/describe_feature_flags.json
@@ -0,0 +1,4 @@
+{
+ "category": "feature_flags",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_lint/describe_passes.json b/crates/runtime/component/tests/declarations/rust_lint/describe_passes.json
new file mode 100644
index 0000000000..c5e67bce72
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_lint/describe_passes.json
@@ -0,0 +1,4 @@
+{
+ "category": "passes",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_lint/describe_routes.json b/crates/runtime/component/tests/declarations/rust_lint/describe_routes.json
new file mode 100644
index 0000000000..425fbe7ef2
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_lint/describe_routes.json
@@ -0,0 +1,4 @@
+{
+ "category": "routes",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_lint/describe_settings.json b/crates/runtime/component/tests/declarations/rust_lint/describe_settings.json
new file mode 100644
index 0000000000..25d73ebee3
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_lint/describe_settings.json
@@ -0,0 +1,4 @@
+{
+ "category": "settings",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_lint/describe_shared_fields.json b/crates/runtime/component/tests/declarations/rust_lint/describe_shared_fields.json
new file mode 100644
index 0000000000..6677481472
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_lint/describe_shared_fields.json
@@ -0,0 +1,4 @@
+{
+ "category": "shared_fields",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_lint/describe_surfaces.json b/crates/runtime/component/tests/declarations/rust_lint/describe_surfaces.json
new file mode 100644
index 0000000000..11f01236f3
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_lint/describe_surfaces.json
@@ -0,0 +1,4 @@
+{
+ "category": "surfaces",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_lint/describe_validation_rules.json b/crates/runtime/component/tests/declarations/rust_lint/describe_validation_rules.json
new file mode 100644
index 0000000000..00357eaaf2
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_lint/describe_validation_rules.json
@@ -0,0 +1,4 @@
+{
+ "category": "validation_rules",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_lint/handshake.json b/crates/runtime/component/tests/declarations/rust_lint/handshake.json
new file mode 100644
index 0000000000..0d4f64c853
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_lint/handshake.json
@@ -0,0 +1,19 @@
+{
+ "protocol_version": "2.3.0",
+ "name": "@rust/lint",
+ "version": "1.0.0",
+ "peer_dependencies": [
+ {
+ "name": "@code/core",
+ "version": "^1.2",
+ "optional": false
+ },
+ {
+ "name": "@rust/source",
+ "version": "^1.0",
+ "optional": false
+ }
+ ],
+ "sandbox_policy": null,
+ "description": "Runs cargo clippy and records its diagnostics as static_finding facts (@code/core)"
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_proof/describe_capabilities.json b/crates/runtime/component/tests/declarations/rust_proof/describe_capabilities.json
new file mode 100644
index 0000000000..52c0e8e0f1
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_proof/describe_capabilities.json
@@ -0,0 +1,31 @@
+{
+ "category": "capabilities",
+ "items": [
+ {
+ "argv": [
+ "cargo-kani",
+ "--workspace",
+ "--output-format",
+ "regular"
+ ],
+ "call_kinds": [
+ "collect"
+ ],
+ "env": [
+ "CARGO_*",
+ "RUSTUP_*",
+ "RUSTC",
+ "RUSTC_*",
+ "RUSTFLAGS",
+ "KANI_*"
+ ],
+ "filter": [
+ "--harness",
+ "{filter}"
+ ],
+ "name": "rust-proof",
+ "port": "process",
+ "why": "run the command whose report the collector 'rust-proof' reads"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_proof/describe_checkers.json b/crates/runtime/component/tests/declarations/rust_proof/describe_checkers.json
new file mode 100644
index 0000000000..2c0d93db04
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_proof/describe_checkers.json
@@ -0,0 +1,4 @@
+{
+ "category": "checkers",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_proof/describe_codes.json b/crates/runtime/component/tests/declarations/rust_proof/describe_codes.json
new file mode 100644
index 0000000000..476fe856cc
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_proof/describe_codes.json
@@ -0,0 +1,4 @@
+{
+ "category": "codes",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_proof/describe_collectors.json b/crates/runtime/component/tests/declarations/rust_proof/describe_collectors.json
new file mode 100644
index 0000000000..0610576a55
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_proof/describe_collectors.json
@@ -0,0 +1,35 @@
+{
+ "category": "collectors",
+ "items": [
+ {
+ "answers": [
+ "test",
+ "test_run"
+ ],
+ "auto_detect": {
+ "env_vars": [],
+ "file_patterns": [
+ "Cargo.toml"
+ ]
+ },
+ "capability": "rust-proof",
+ "capture": "stdout",
+ "export": "collect__rust_proof",
+ "input_formats": [
+ "kani-regular"
+ ],
+ "inputs": [
+ {
+ "input": "facts",
+ "kinds": [
+ "item",
+ "package"
+ ]
+ }
+ ],
+ "install": "cargo install --locked kani-verifier && cargo kani setup",
+ "name": "rust-proof",
+ "report": ".specforge/reports/rust-proof"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_proof/describe_contexts.json b/crates/runtime/component/tests/declarations/rust_proof/describe_contexts.json
new file mode 100644
index 0000000000..afd6be3149
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_proof/describe_contexts.json
@@ -0,0 +1,4 @@
+{
+ "category": "contexts",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_proof/describe_edges.json b/crates/runtime/component/tests/declarations/rust_proof/describe_edges.json
new file mode 100644
index 0000000000..bb4c7452e4
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_proof/describe_edges.json
@@ -0,0 +1,4 @@
+{
+ "category": "edges",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_proof/describe_enhancements.json b/crates/runtime/component/tests/declarations/rust_proof/describe_enhancements.json
new file mode 100644
index 0000000000..e79b88a896
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_proof/describe_enhancements.json
@@ -0,0 +1,4 @@
+{
+ "category": "enhancements",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_proof/describe_entities.json b/crates/runtime/component/tests/declarations/rust_proof/describe_entities.json
new file mode 100644
index 0000000000..ade72d8d90
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_proof/describe_entities.json
@@ -0,0 +1,4 @@
+{
+ "category": "entities",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_proof/describe_feature_flags.json b/crates/runtime/component/tests/declarations/rust_proof/describe_feature_flags.json
new file mode 100644
index 0000000000..355b7dc9d2
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_proof/describe_feature_flags.json
@@ -0,0 +1,4 @@
+{
+ "category": "feature_flags",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_proof/describe_passes.json b/crates/runtime/component/tests/declarations/rust_proof/describe_passes.json
new file mode 100644
index 0000000000..c5e67bce72
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_proof/describe_passes.json
@@ -0,0 +1,4 @@
+{
+ "category": "passes",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_proof/describe_routes.json b/crates/runtime/component/tests/declarations/rust_proof/describe_routes.json
new file mode 100644
index 0000000000..425fbe7ef2
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_proof/describe_routes.json
@@ -0,0 +1,4 @@
+{
+ "category": "routes",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_proof/describe_settings.json b/crates/runtime/component/tests/declarations/rust_proof/describe_settings.json
new file mode 100644
index 0000000000..25d73ebee3
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_proof/describe_settings.json
@@ -0,0 +1,4 @@
+{
+ "category": "settings",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_proof/describe_shared_fields.json b/crates/runtime/component/tests/declarations/rust_proof/describe_shared_fields.json
new file mode 100644
index 0000000000..6677481472
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_proof/describe_shared_fields.json
@@ -0,0 +1,4 @@
+{
+ "category": "shared_fields",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_proof/describe_surfaces.json b/crates/runtime/component/tests/declarations/rust_proof/describe_surfaces.json
new file mode 100644
index 0000000000..11f01236f3
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_proof/describe_surfaces.json
@@ -0,0 +1,4 @@
+{
+ "category": "surfaces",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_proof/describe_validation_rules.json b/crates/runtime/component/tests/declarations/rust_proof/describe_validation_rules.json
new file mode 100644
index 0000000000..00357eaaf2
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_proof/describe_validation_rules.json
@@ -0,0 +1,4 @@
+{
+ "category": "validation_rules",
+ "items": []
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/declarations/rust_proof/handshake.json b/crates/runtime/component/tests/declarations/rust_proof/handshake.json
new file mode 100644
index 0000000000..7c5a6e7a89
--- /dev/null
+++ b/crates/runtime/component/tests/declarations/rust_proof/handshake.json
@@ -0,0 +1,19 @@
+{
+ "protocol_version": "2.3.0",
+ "name": "@rust/proof",
+ "version": "1.0.0",
+ "peer_dependencies": [
+ {
+ "name": "@code/core",
+ "version": "^1.2",
+ "optional": false
+ },
+ {
+ "name": "@rust/source",
+ "version": "^1.0",
+ "optional": false
+ }
+ ],
+ "sandbox_policy": null,
+ "description": "Runs Kani and records each proof harness as test facts (@code/core)"
+}
\ No newline at end of file
diff --git a/crates/runtime/component/tests/families.rs b/crates/runtime/component/tests/families.rs
index 631b1a3d15..cc3cba64ed 100644
--- a/crates/runtime/component/tests/families.rs
+++ b/crates/runtime/component/tests/families.rs
@@ -54,12 +54,24 @@ fn the_two_sets_are_adr_0369s_and_every_builtin_is_in_one() {
"@rust/test",
"@javascript/source",
"@javascript/node-test",
+ "@rust/coverage",
+ "@rust/lint",
+ "@rust/deps",
+ "@rust/api",
+ "@rust/proof",
+ "@javascript/coverage",
+ "@javascript/lint",
+ "@javascript/deps",
+ "@javascript/api",
+ "@javascript/vitest",
+ "@javascript/jest",
+ "@javascript/playwright",
]),
"both sets"
);
assert_eq!(
names(&gsd.difference(&old).copied().collect()),
- ["@gsd/core"],
+ ["@gsd/core", "@gsd/import"],
"the gsd set only"
);
@@ -114,6 +126,57 @@ fn each_set_builds_one_registry_with_no_e026_and_no_missing_peer() {
}
}
+/// The legacy `@specforge/vitest` and `@javascript/vitest`, each with the peers it requires
+/// (`@specforge/testing`; `@code/core` and `@javascript/source`), build one registry with no E026 and no
+/// missing peer, and each keeps its own collector (owner decision D4: the old pack stays in the old set,
+/// so a project may load both while it moves).
+#[test]
+fn the_old_vitest_loads_beside_javascript_vitest() {
+ let names = [
+ "@specforge/testing",
+ "@code/core",
+ "@javascript/source",
+ "@specforge/vitest",
+ "@javascript/vitest",
+ ];
+ for name in names {
+ assert!(
+ BUILTINS.iter().any(|builtin| builtin.name == name),
+ "'{name}' is a BUILTINS row"
+ );
+ }
+ let declarations: Vec<_> = pinned_builtin_declarations()
+ .unwrap()
+ .into_iter()
+ .filter(|declaration| names.contains(&declaration.name()))
+ .collect();
+ assert_eq!(declarations.len(), names.len());
+ let collectors: BTreeSet<(String, String)> = declarations
+ .iter()
+ .flat_map(|declaration| {
+ declaration
+ .collectors
+ .iter()
+ .map(|collector| (declaration.name().to_string(), collector.name.clone()))
+ })
+ .collect();
+ for (owner, collector) in [
+ ("@specforge/vitest", "vitest"),
+ ("@javascript/vitest", "javascript-vitest"),
+ ] {
+ assert!(
+ collectors.contains(&(owner.to_string(), collector.to_string())),
+ "{owner} declares the collector '{collector}': {collectors:?}"
+ );
+ }
+
+ let build = build_registries(declarations);
+ for code in ["E026", "E027"] {
+ let found: Vec<_> = build.diagnostics().filter(|d| d.code == code).collect();
+ assert!(found.is_empty(), "{code}: {found:?}");
+ }
+}
+
/// The kinds `@gsd/core` declares, as a declaration named `@gsd/core` with nothing else in it. They are
/// read from `gsd/core/tests/golden/kinds.json`, which the gsd suite's own golden test keeps equal to
/// the extension's declaration, so this follows every later change to those kinds with no edit here.
diff --git a/crates/runtime/extension-sdk/src/builders.rs b/crates/runtime/extension-sdk/src/builders.rs
index 866b2b06c0..0f12c1da86 100644
--- a/crates/runtime/extension-sdk/src/builders.rs
+++ b/crates/runtime/extension-sdk/src/builders.rs
@@ -439,6 +439,13 @@ impl CodeBuilder {
self.0.settled_later = true;
self
}
+ /// The collected fact kinds this code judges (the kinds whose facts its passes read to raise it), so a host can
+ /// say which codes cannot be judged when no collector answers them (`specforge doctor`, ADR 0389). Leave it out
+ /// for a code about authored entities.
+ pub fn facts(&mut self, kinds: &[&str]) -> &mut Self {
+ self.0.facts = kinds.iter().map(|kind| kind.to_string()).collect();
+ self
+ }
}
/// Builder for [`ValidationRuleDescriptor`], with a `custom` rule's
@@ -659,6 +666,7 @@ impl CollectorBuilder {
inputs: Vec::new(),
answers: Vec::new(),
install: None,
+ requires: Vec::new(),
},
collect: None,
run: None,
@@ -745,11 +753,16 @@ impl CollectorBuilder {
self.env = names.iter().map(|n| n.to_string()).collect();
self
}
- /// What to run to install the command's program, said when it is not found on PATH (ADR 0348 D4).
+ /// What to run to install the command's programs, said when one is not found on PATH (ADR 0348 D4).
pub fn install(&mut self, line: &str) -> &mut Self {
self.descriptor.install = Some(line.to_string());
self
}
+ /// The other programs the command runs beside its first, which `specforge doctor` looks up (ADR 0389 D3).
+ pub fn requires(&mut self, programs: &[&str]) -> &mut Self {
+ self.descriptor.requires = programs.iter().map(ToString::to_string).collect();
+ self
+ }
/// The `process` capability (one the extension declares with
/// [`ContributionsBuilder::capability`](crate::ContributionsBuilder::capability)) whose command the host runs.
pub fn capability(&mut self, name: &str) -> &mut Self {
@@ -757,9 +770,16 @@ impl CollectorBuilder {
self.descriptor.capability = Some(name.to_string());
self
}
- /// Report file or directory the runner writes, relative to the project
- /// root. A directory is read as every `*.json` file directly inside it.
+ /// The report the runner writes, relative to the project root: a file, a directory (read as every `*.json` file
+ /// directly inside it), or a glob over project files the tool writes itself (`**/name.json`), every match read
+ /// fresh after each run by the walk `Input::files` globs take (ADR 0389). A glob's command is told no path: it
+ /// takes no `{report}` and no `capture_stdout()`. Its last segment is a literal file name: a wildcard there panics.
pub fn report(&mut self, path: &str) -> &mut Self {
+ assert!(
+ specforge_protocol_types::is_report_name(path),
+ "collector '{}' declares the report '{path}': a report glob must end in a literal file name",
+ self.descriptor.name
+ );
self.descriptor.report = Some(path.to_string());
self
}
diff --git a/crates/runtime/extension-sdk/src/lib.rs b/crates/runtime/extension-sdk/src/lib.rs
index 0cc4004465..e353841b76 100644
--- a/crates/runtime/extension-sdk/src/lib.rs
+++ b/crates/runtime/extension-sdk/src/lib.rs
@@ -38,9 +38,9 @@ pub use specforge_protocol_types::{
pub use specforge_protocol_types::{
ByteRange, CapabilityDescriptor, CheckFinding, CheckItem, CheckOutcome, CheckPhase, CheckPlan,
- CheckRef, CheckStatus, CheckValuesInput, CheckerDescriptor, FILE_READ_MAX, FsAccess, GitOp,
- HttpMethod, MAX_PROBE_ROUNDS, Operation, OutcomeClass, OutcomeData, PlannedItem, PortScope,
- Probe, ProbeOutcome, StatEntry, ValueForm,
+ CheckRef, CheckStatus, CheckValuesInput, CheckerDescriptor, FILE_READ_MAX, FsAccess,
+ GLOB_VISITS_MAX, GitOp, HttpMethod, MAX_PROBE_ROUNDS, Operation, OutcomeClass, OutcomeData,
+ PlannedItem, PortScope, Probe, ProbeOutcome, StatEntry, TEXT_MAX_CEILING_BYTES, ValueForm,
};
pub use specforge_protocol_types::{
@@ -655,7 +655,7 @@ pub mod prelude {
pub use crate::{
CollectEntityResult, CollectInput, CollectOutput, CollectReportFile, CollectUnlinkedTest,
CollectorBuilder, DanglingReason, DanglingReference, FILE_READ_MAX, Fact, FactLocation,
- PlanBuilder,
+ GLOB_VISITS_MAX, PlanBuilder, TEXT_MAX_CEILING_BYTES,
};
pub use crate::{DeltaAspect, DeltaBase, DeltaChange, DeltaEdge, DeltaNode, DeltaPayload};
pub use specforge_extension_sdk_macros::extension;
diff --git a/crates/runtime/extension-sdk/src/reads.rs b/crates/runtime/extension-sdk/src/reads.rs
index 764360b053..b1f46d16f2 100644
--- a/crates/runtime/extension-sdk/src/reads.rs
+++ b/crates/runtime/extension-sdk/src/reads.rs
@@ -44,6 +44,14 @@ impl FileReadSpec {
self.0.text = true;
self
}
+
+ /// Send each file's text up to `bytes` (at most 4 MiB) instead of 64 KiB, as well as its facts; the read's text
+ /// budget is the larger of 1 MiB and four times `bytes` (protocol 2.3.0).
+ pub fn text_up_to(mut self, bytes: u32) -> Self {
+ self.0.text = true;
+ self.0.text_max = Some(bytes);
+ self
+ }
}
impl From for FileRead {
diff --git a/crates/runtime/extension-sdk/src/surface.rs b/crates/runtime/extension-sdk/src/surface.rs
index b63b97deb9..0ecf6baa8c 100644
--- a/crates/runtime/extension-sdk/src/surface.rs
+++ b/crates/runtime/extension-sdk/src/surface.rs
@@ -412,6 +412,15 @@ impl CommandBuilder {
self.writes()
}
+ /// The command imports what was recorded outside the spec (a legacy project's history), so the host judges its
+ /// plan for host errors only: an error lands, and `check` reports it, only when its code is in the reporting
+ /// extension's own namespace and own catalog and declares no `facts`; a host or `@specforge/*` code (E016), a
+ /// fact-judging one (`code/E101`) and an uncatalogued one still refuse (ADR 0392). It `writes`.
+ pub fn imports(&mut self) -> &mut Self {
+ self.descriptor.imports = true;
+ self.writes()
+ }
+
/// The command answers an edit plan ([`CommandOutput::with_plan`]) the host applies (ADR 0289). It receives
/// the `revisions` of the project's sources, and the host gives it `--dry-run`, so no arg may take that name.
pub fn writes(&mut self) -> &mut Self {
diff --git a/crates/runtime/extension-sdk/tests/declaration.rs b/crates/runtime/extension-sdk/tests/declaration.rs
index 03a24630dc..a11b561c5c 100644
--- a/crates/runtime/extension-sdk/tests/declaration.rs
+++ b/crates/runtime/extension-sdk/tests/declaration.rs
@@ -344,6 +344,22 @@ fn a_code_entry_may_be_settled_later() {
assert!(!declared.codes[1].settled_later);
}
+#[specforge_test_macros::test(requirement = "FEATURE-028")]
+fn a_code_entry_may_name_the_collected_kinds_it_judges() {
+ let mut b = ContributionsBuilder::new(ExtensionMeta::new("@acme/reports", "0.1.0"));
+ b.code("W104", |d| {
+ d.title("Report entry on no item")
+ .explanation("Serve the item.")
+ .facts(&["coverage", "api_item"]);
+ });
+ b.code("W105", |d| {
+ d.title("Plain").explanation("About authored entities.");
+ });
+ let declared = b.declaration();
+ assert_eq!(declared.codes[0].facts, ["coverage", "api_item"]);
+ assert!(declared.codes[1].facts.is_empty());
+}
+
#[specforge_test_macros::test(requirement = "FEATURE-028")]
fn settings_presets_secrets_and_flags_are_declared() {
let mut b = ContributionsBuilder::new(ExtensionMeta::new("@acme/gsd", "0.1.0"));
diff --git a/crates/runtime/extension-sdk/tests/golden.rs b/crates/runtime/extension-sdk/tests/golden.rs
index 3a29ec483c..c56551b193 100644
--- a/crates/runtime/extension-sdk/tests/golden.rs
+++ b/crates/runtime/extension-sdk/tests/golden.rs
@@ -158,8 +158,9 @@ fn mock_host_pins_wire_output() {
/// No builtin of the old set contributes to a host (ADR 0292): its pinned `surfaces` holds none of the four
/// kinds, and a guest that declares none is byte-equal to what it was before they existed. `@gsd/core`
-/// (`gsd_core`) contributes agents, skills, slash commands and hooks by design (ADR 0373 D7), so its
-/// directory is not read.
+/// (`gsd_core`) contributes agents, skills, slash commands and hooks by design (ADR 0373 D7), and
+/// `@gsd/import` (`gsd_import`) declares its command's file inputs (ADR 0391), so their directories,
+/// the gsd set's own, are not read.
#[specforge_test_macros::test(requirement = "FEATURE-013")]
fn the_builtins_declare_no_host_contribution() {
let root = specforge_repo_root::repo_root().join("crates/runtime/component/tests/declarations");
@@ -167,7 +168,10 @@ fn the_builtins_declare_no_host_contribution() {
for dir in std::fs::read_dir(&root).unwrap() {
let dir = dir.unwrap().path();
// The old set and the pinned examples only (ADR 0373 D7).
- if dir.file_name().is_some_and(|name| name == "gsd_core") {
+ if dir
+ .file_name()
+ .is_some_and(|name| name == "gsd_core" || name == "gsd_import")
+ {
continue;
}
let surfaces = dir.join("describe_surfaces.json");
diff --git a/crates/runtime/extension-sdk/tests/operations.rs b/crates/runtime/extension-sdk/tests/operations.rs
index 459ccbe442..fee9312019 100644
--- a/crates/runtime/extension-sdk/tests/operations.rs
+++ b/crates/runtime/extension-sdk/tests/operations.rs
@@ -53,6 +53,7 @@ fn extension() -> ContributionsBuilder {
unlinked: Vec::new(),
plan: None,
facts: Vec::new(),
+ warnings: Vec::new(),
})
});
});
@@ -179,6 +180,16 @@ fn a_collector_without_its_handler_is_refused() {
});
}
+#[test]
+#[should_panic(expected = "collector 'k' declares the report '**/*.pem'")]
+fn a_report_glob_ending_in_a_wildcard_is_refused() {
+ let mut c = ContributionsBuilder::new(ExtensionMeta::new("@acme/x", "1.0.0"));
+ c.collector("k", |k| {
+ k.report("**/*.pem")
+ .collect(|_| Ok(CollectOutput::default()));
+ });
+}
+
#[test]
#[should_panic(expected = "custom rule 'E1' declares no handler")]
fn a_custom_rule_without_its_handler_is_refused() {
diff --git a/crates/runtime/extension-sdk/tests/plan.rs b/crates/runtime/extension-sdk/tests/plan.rs
index 70cbee1b8f..d7fe8c4b9d 100644
--- a/crates/runtime/extension-sdk/tests/plan.rs
+++ b/crates/runtime/extension-sdk/tests/plan.rs
@@ -189,3 +189,25 @@ fn human_sets_writes() {
let plain = serde_json::to_value(&writer().declaration().surfaces.commands[0]).unwrap();
assert!(plain.get("human").is_none());
}
+
+#[specforge_test(requirement = "FEATURE-131")]
+fn imports_sets_writes() {
+ let mut b = ContributionsBuilder::new(ExtensionMeta::new("@acme/i", "1.0.0"));
+ b.command("import", |c| {
+ c.title("Import")
+ .description("Import what a legacy project recorded")
+ .imports()
+ .handler(|_| CommandOutput::ok("ok\n"));
+ });
+ let declaration = b.declaration();
+ let command = &declaration.surfaces.commands[0];
+ assert!(command.imports && command.writes && !command.human);
+ let wire = serde_json::to_value(command).unwrap();
+ assert_eq!(
+ (wire["imports"].clone(), wire["writes"].clone()),
+ (json!(true), json!(true))
+ );
+ // An ordinary command does not carry the key.
+ let plain = serde_json::to_value(&writer().declaration().surfaces.commands[0]).unwrap();
+ assert!(plain.get("imports").is_none());
+}
diff --git a/crates/runtime/wasm/tests/calls.rs b/crates/runtime/wasm/tests/calls.rs
index 39fafd658f..70933ad678 100644
--- a/crates/runtime/wasm/tests/calls.rs
+++ b/crates/runtime/wasm/tests/calls.rs
@@ -115,6 +115,7 @@ fn collect_answer() -> CollectOutput {
}],
plan: None,
facts: Vec::new(),
+ warnings: Vec::new(),
}
}
diff --git a/crates/runtime/wasm/tests/protocol_types.rs b/crates/runtime/wasm/tests/protocol_types.rs
index 7fbfbf5d75..43aec512ae 100644
--- a/crates/runtime/wasm/tests/protocol_types.rs
+++ b/crates/runtime/wasm/tests/protocol_types.rs
@@ -546,6 +546,7 @@ fn collector_descriptor_with_auto_detect() {
inputs: vec![],
answers: vec!["test".to_string()],
install: None,
+ requires: vec![],
};
let json = serde_json::to_string(&collector).unwrap();
let decoded: CollectorDescriptor = serde_json::from_str(&json).unwrap();
diff --git a/crates/session/project/src/file_reads.rs b/crates/session/project/src/file_reads.rs
index b6c314d1c3..bddfc44d46 100644
--- a/crates/session/project/src/file_reads.rs
+++ b/crates/session/project/src/file_reads.rs
@@ -17,17 +17,18 @@ use specforge_effects::contained::{Contained, Resolved};
use specforge_effects::fs::SKIPPED;
use specforge_effects::{Root, Roots};
-use specforge_protocol_types::{FILE_READ_MAX, FileFact, FileFacts, FileRead};
+use specforge_protocol_types::{
+ FILE_READ_MAX, FileFact, FileFacts, FileRead, GLOB_VISITS_MAX, is_wild,
+};
use specforge_registry::{Disk, DiskLookup, EntitySnapshot, paths_named, read_problem};
use crate::judged::file_digest;
-/// The most text of one file a read sends.
+/// The most text of one file a read sends, unless it declares `text_max`.
pub const TEXT_CAP: usize = 64 * 1024;
-/// The most text one read sends in all.
+/// The most text one read sends in all, unless four times its per-file cap is more: at most 16 MiB, as a read whose
+/// `text_max` is over [`specforge_protocol_types::TEXT_MAX_CEILING_BYTES`] is never read (`read_problem`, W021).
pub const TEXT_BUDGET: usize = 1024 * 1024;
-/// The most entries (files and directories) one glob visits, matched or not.
-pub const MAX_VISITS: usize = 20_000;
/// Where the files are read from.
#[derive(Clone)]
@@ -100,7 +101,7 @@ pub fn read(
if read_problem(read).is_some() || files.contains_key(&read.name) {
continue;
}
- let mut budget = TEXT_BUDGET;
+ let mut budget = text_cap(read).map_or(TEXT_BUDGET, |cap| TEXT_BUDGET.max(4 * cap));
let facts = match (&read.field, &read.glob) {
(Some(field), _) => field_facts(read, field, entities, &ctx, &mut budget),
(_, Some(glob)) => glob_facts(read, glob, &ctx, &mut budget),
@@ -111,6 +112,13 @@ pub fn read(
files
}
+/// The most text of one file `read` sends: `None` when it asks for no text. `read` passed `read_problem`, the one
+/// check of `text_max` against the ceiling.
+fn text_cap(read: &FileRead) -> Option {
+ read.text
+ .then(|| read.text_max.map_or(TEXT_CAP, |max| max as usize))
+}
+
fn field_facts(
read: &FileRead,
field: &str,
@@ -144,13 +152,40 @@ fn field_facts(
let facts = named
.into_iter()
.take(FILE_READ_MAX)
- .map(|((entity, path), at)| fact(ctx, path, Some(entity), at.as_ref(), read.text, budget))
+ .map(|((entity, path), at)| {
+ fact(ctx, path, Some(entity), at.as_ref(), text_cap(read), budget)
+ })
.collect();
FileFacts { facts, truncated }
}
fn glob_facts(read: &FileRead, glob: &str, ctx: &Ctx<'_>, budget: &mut usize) -> FileFacts {
- let source = ctx.source;
+ let GlobPaths { files, truncated } = glob_paths(ctx.source, glob);
+ let facts = files
+ .into_iter()
+ .map(|path| {
+ let at = ctx.contained.resolve(&path, Root::Project).ok();
+ fact(ctx, path, None, at.as_ref(), text_cap(read), budget)
+ })
+ .collect();
+ FileFacts { facts, truncated }
+}
+
+/// The project files a glob matches: project-relative, `/` separated, sorted and unique.
+#[derive(Debug, Clone, Default, PartialEq, Eq)]
+pub struct GlobPaths {
+ pub files: Vec,
+ /// The walk stopped early: past [`GLOB_VISITS_MAX`] entries, or past [`FILE_READ_MAX`] matches.
+ pub truncated: bool,
+}
+
+/// The project files under `source` that `glob` matches, by the one walk every glob read takes (ADR 0293 D4): a
+/// directory in [`SKIPPED`] is entered only when the glob names it, a directory reached through a link is not entered
+/// (nor a literal prefix that links out of the project), and the walk stops after [`GLOB_VISITS_MAX`] entries. A file
+/// collector's report glob reads through it too (ADR 0389).
+pub fn glob_paths(source: &FileSource<'_>, glob: &str) -> GlobPaths {
+ let lookup = DiskLookup(source.disk);
+ let contained = Contained::new(&source.roots, &lookup);
let segments: Vec<&str> = glob.split('/').filter(|s| *s != ".").collect();
let named_here: Vec<&str> = segments.iter().copied().filter(|s| !is_wild(s)).collect();
// Directories above the first wildcard are walked to directly: only the rest of the pattern decides.
@@ -167,9 +202,9 @@ fn glob_facts(read: &FileRead, glob: &str, ctx: &Ctx<'_>, budget: &mut usize) ->
let mut found = Found::default();
let first = source.project_root.join(&start);
// A literal prefix that is itself a link out of the project is not entered.
- if start.is_empty() || ctx.contained.resolve(&start, Root::Project).is_ok() {
+ if start.is_empty() || contained.resolve(&start, Root::Project).is_ok() {
let real = source.disk.canonical(&first);
- walk(ctx, &start, real.as_deref(), &plan, &mut found);
+ walk(source, &start, real.as_deref(), &plan, &mut found);
}
let Found {
mut files,
@@ -178,14 +213,7 @@ fn glob_facts(read: &FileRead, glob: &str, ctx: &Ctx<'_>, budget: &mut usize) ->
} = found;
files.sort();
files.dedup();
- let facts = files
- .into_iter()
- .map(|path| {
- let at = ctx.contained.resolve(&path, Root::Project).ok();
- fact(ctx, path, None, at.as_ref(), read.text, budget)
- })
- .collect();
- FileFacts { facts, truncated }
+ GlobPaths { files, truncated }
}
struct Walk<'a> {
@@ -208,8 +236,13 @@ struct Found {
/// The files under `dir` (project-relative, `/` separated; empty is the root; `real` is `dir` with its links
/// resolved, when the disk has links) whose path matches the glob, in order. A directory reached through a link is
/// not entered: a link into an ancestor would loop, and one out of the project would leave it.
-fn walk(ctx: &Ctx<'_>, dir: &str, real: Option<&Path>, plan: &Walk<'_>, found: &mut Found) {
- let source = ctx.source;
+fn walk(
+ source: &FileSource<'_>,
+ dir: &str,
+ real: Option<&Path>,
+ plan: &Walk<'_>,
+ found: &mut Found,
+) {
let at = if dir.is_empty() {
source.project_root.to_path_buf()
} else {
@@ -220,7 +253,7 @@ fn walk(ctx: &Ctx<'_>, dir: &str, real: Option<&Path>, plan: &Walk<'_>, found: &
};
for name in names {
found.visits += 1;
- if found.truncated || found.visits > MAX_VISITS {
+ if found.truncated || found.visits > GLOB_VISITS_MAX {
found.truncated = true;
return;
}
@@ -244,7 +277,7 @@ fn walk(ctx: &Ctx<'_>, dir: &str, real: Option<&Path>, plan: &Walk<'_>, found: &
_ => false,
};
if !linked {
- walk(ctx, &rel, child_real.as_deref(), plan, found);
+ walk(source, &rel, child_real.as_deref(), plan, found);
}
} else if specforge_common::path_glob::matches(plan.glob, &rel) {
if found.files.len() == FILE_READ_MAX {
@@ -256,13 +289,14 @@ fn walk(ctx: &Ctx<'_>, dir: &str, real: Option<&Path>, plan: &Walk<'_>, found: &
}
}
-/// The facts of the file `at` resolves to (`None`: the path leaves the project and is not read).
+/// The facts of the file `at` resolves to (`None`: the path leaves the project and is not read), and its text when
+/// `cap` is set and the file is within it.
fn fact(
ctx: &Ctx<'_>,
path: String,
entity: Option,
at: Option<&Resolved>,
- text: bool,
+ cap: Option,
budget: &mut usize,
) -> FileFact {
let mut fact = FileFact {
@@ -283,7 +317,7 @@ fn fact(
}
// A text read never carries a secret-looking file, by its name or the name a link resolves to. Its existence is
// still a fact and still a check input.
- if text && resolved.withheld {
+ if cap.is_some() && resolved.withheld {
fact.error = Some("denied".into());
return fact;
}
@@ -294,11 +328,9 @@ fn fact(
let open_line = !bytes.is_empty() && bytes.last() != Some(&b'\n');
fact.lines = Some(newlines + u64::from(open_line));
fact.digest = Some(file_digest(&bytes));
- if text {
+ if let Some(cap) = cap {
match String::from_utf8(bytes) {
- _ if fact.bytes > Some(TEXT_CAP as u64) => {
- fact.error = Some("too_large".into())
- }
+ _ if fact.bytes > Some(cap as u64) => fact.error = Some("too_large".into()),
Ok(body) if body.len() > *budget => fact.error = Some("budget".into()),
Ok(body) => {
*budget -= body.len();
@@ -320,7 +352,3 @@ fn fact(
fn slashed(path: &Path) -> String {
path.to_string_lossy().replace('\\', "/")
}
-
-fn is_wild(segment: &str) -> bool {
- segment.contains(['*', '?'])
-}
diff --git a/crates/session/project/src/testing.rs b/crates/session/project/src/testing.rs
index d8c6b168d0..1da27a8f1b 100644
--- a/crates/session/project/src/testing.rs
+++ b/crates/session/project/src/testing.rs
@@ -56,8 +56,8 @@ pub use gsd_facts::{
pub use gsd_hosts::{GSD_HOSTS_EXTENSIONS, GsdHosts, gsd_hosts_sources};
pub use gsd_prompts::{GSD_PROMPTS_EXTENSIONS, GsdPrompts, NO_CONTEXT, gsd_prompts_sources};
pub use gsd_writes::{
- CORE, GSD_WRITES_EXTENSIONS, GUARDED, GsdWrites, OTHER, UI, gsd_writes_answer, gsd_writes_wire,
- revision_of,
+ CORE, GSD_WRITES_EXTENSIONS, GUARDED, GsdWrites, OTHER, RACED, UI, gsd_writes_answer,
+ gsd_writes_wire, revision_of,
};
pub use items::{
CITES, ITEM_EXTENSIONS, ITEMS, WORKTREE, declare_cites, declare_items, item, item_declarations,
diff --git a/crates/session/project/src/testing/gsd_writes.rs b/crates/session/project/src/testing/gsd_writes.rs
index 810e6d2cd4..f7ca58b025 100644
--- a/crates/session/project/src/testing/gsd_writes.rs
+++ b/crates/session/project/src/testing/gsd_writes.rs
@@ -3,7 +3,8 @@
//! fails, not the fixture:
//!
//! - [`CORE`] (`@t/core`): the kinds of [`super::gsd_history_wire`] and `override` (human-only), `commit`; a writing
-//! command `record`, a command `quiet` that declares no `writes`, a writing collector `git`
+//! command `record`, a command `quiet` that declares no `writes`, a human command `attest`, an importing command
+//! `import`, a writing collector `git`
//! - [`UI`] (`@t/ui`, a peer of core): a writing collector `dom`, a writing command `mark`
//! - [`OTHER`] (`@t/other`, no peer): a writing command `record`
//!
@@ -61,19 +62,26 @@ fn guard_wire() -> Value {
/// The goal [`GsdWrites::guarding_a_goal`]'s guard objects to.
pub const GUARDED: &str = "GUARDED";
+/// The goal that, beside a [`GUARDED`] one, makes the guard also report E901, a code that judges collected facts.
+pub const RACED: &str = "RACED";
+
fn marked_guard(export: &str, input: &[u8]) -> Option, String>> {
if export != "__pass_phase_complete" {
return None;
}
- let quoted = format!("\"{GUARDED}\"");
- let held = input
- .windows(quoted.len())
- .any(|window| window == quoted.as_bytes());
- let diagnostics = if held {
- json!([{"code": specforge_common::codes::E087.to_string(), "severity": "Error", "message": "a phase is not complete", "entity": "v1.0/03"}])
- } else {
- json!([])
+ let held = |goal: &str| {
+ let quoted = format!("\"{goal}\"");
+ input
+ .windows(quoted.len())
+ .any(|window| window == quoted.as_bytes())
};
+ let mut diagnostics = Vec::new();
+ if held(GUARDED) {
+ diagnostics.push(json!({"code": specforge_common::codes::E087.to_string(), "severity": "Error", "message": "a phase is not complete", "entity": "v1.0/03"}));
+ if held(RACED) {
+ diagnostics.push(json!({"code": "E901", "severity": "Error", "message": "a fact names nothing", "entity": "v1.0/03"}));
+ }
+ }
let output = json!({"diagnostics": diagnostics, "summary": {}, "values": []});
Some(Ok(output.to_string().into_bytes()))
}
@@ -128,8 +136,9 @@ impl GsdWrites {
)
}
- /// [`CORE`] declares the guard pass `phase_complete`, which reports E700 for as long as the project holds a
+ /// [`CORE`] declares the guard pass `phase_complete`, which reports E087 for as long as the project holds a
/// phase whose `goal` is [`GUARDED`]: a rule about the state a write leaves, which a project can already violate.
+ /// While another phase's goal is [`RACED`] too, it also reports E901, a code that judges collected facts.
pub fn guarding_a_goal(mut self) -> Self {
self.guard = true;
self.marked = true;
@@ -191,6 +200,13 @@ fn attest() -> Value {
attest
}
+/// A command that imports what was recorded outside the spec (ADR 0392): its plan is judged for host errors only.
+fn import() -> Value {
+ let mut import = command("import", true);
+ import["imports"] = json!(true);
+ import
+}
+
fn core(guard: bool) -> ContributionsBuilder {
let mut c = ContributionsBuilder::new(ExtensionMeta::new(CORE, "1.0.0"));
c.raw_category(DeclaredCategory::Entities, gsd_writes_wire());
@@ -199,9 +215,20 @@ fn core(guard: bool) -> ContributionsBuilder {
passes.as_array_mut().expect("an array").push(guard_wire());
}
c.raw_category(DeclaredCategory::Passes, passes);
+ // The guard's code, a rule about authored entities: an importing command's plan writes it (ADR 0392).
+ c.code(&specforge_common::codes::E087.to_string(), |d| {
+ d.title("A phase is not complete")
+ .explanation("A phase's goal is GUARDED.");
+ });
+ // A code that judges collected facts: an importing command's plan refuses it (ADR 0392).
+ c.code("E901", |d| {
+ d.title("A fact names nothing")
+ .explanation("A phase's goal is GUARDED while another's is RACED.")
+ .facts(&["commit"]);
+ });
c.raw_category(
DeclaredCategory::Surfaces,
- json!([{"commands": [command("record", true), command("quiet", false), attest()]}]),
+ json!([{"commands": [command("record", true), command("quiet", false), attest(), import()]}]),
);
c.raw_category(DeclaredCategory::Collectors, json!([collector("git")]));
c
diff --git a/crates/session/project/tests/builtin_vocabulary.rs b/crates/session/project/tests/builtin_vocabulary.rs
index dfbbd9dff4..a97840e0fe 100644
--- a/crates/session/project/tests/builtin_vocabulary.rs
+++ b/crates/session/project/tests/builtin_vocabulary.rs
@@ -174,7 +174,7 @@ fn no_builtin_declares_a_writer_or_history_flag() {
}
#[specforge_test_macros::test(requirement = "FEATURE-028")]
-fn the_builtins_declare_no_settings() {
+fn only_checks_and_cargo_declare_settings() {
// The old set only: @gsd/core scopes, sets and pins by design (ADR 0373 D7, ADR 0370).
let declarations = old_set_declarations();
for declaration in &declarations {
@@ -184,18 +184,23 @@ fn the_builtins_declare_no_settings() {
declaration.name()
);
let text = serde_json::to_string(declaration).unwrap();
+ let names = || -> Vec {
+ serde_json::from_str::(&text).unwrap()["settings"]
+ .as_array()
+ .unwrap()
+ .iter()
+ .map(|s| s["name"].as_str().unwrap_or_default().to_string())
+ .collect()
+ };
if declaration.name() == "@specforge/checks" {
- let names: Vec =
- serde_json::from_str::(&text).unwrap()["settings"]
- .as_array()
- .unwrap()
- .iter()
- .map(|s| s["name"].as_str().unwrap_or_default().to_string())
- .collect();
+ let names = names();
assert!(
!names.is_empty() && names.iter().all(|n| n.starts_with("families.")),
"{names:?}"
);
+ } else if declaration.name() == "@rust/cargo" {
+ // The fixture and example directories a project leaves out of its packages (ADR 0393 D7).
+ assert_eq!(names(), ["exclude"]);
} else {
assert!(
!text.contains("\"settings\""),
diff --git a/crates/session/project/tests/builtins/code_core.rs b/crates/session/project/tests/builtins/code_core.rs
index 5e27a3cc50..21a8d4a974 100644
--- a/crates/session/project/tests/builtins/code_core.rs
+++ b/crates/session/project/tests/builtins/code_core.rs
@@ -308,7 +308,7 @@ fn a_rust_test_ref_beside_only_item_facts_is_code_w102() {
"code/W102".to_string(),
"T1".to_string(),
"`proof` names `rust:toy#tests::adds`, but no `rust` `test` facts were collected: run \
- `specforge collect` with `@rust/test`"
+ `specforge collect` with `@rust/test` or `@rust/proof`"
.to_string()
)],
"{:?}",
@@ -383,3 +383,101 @@ fn a_harness_immutable_reference_is_no_finding() {
assert_eq!(found(&compiled), [], "{:?}", compiled.diagnostics());
}
+
+/// The project package the report facts below cite.
+const TOY: &str = "pkg:cargo/toy";
+
+/// The item `rust:toy::add` and the package [`TOY`], then the report facts `reports`: one store, as collected.
+fn with_reports(reports: Value) -> Value {
+ let mut facts = items(&["rust:toy::add"]);
+ let all = facts.as_array_mut().unwrap();
+ all.push(json!({"kind": "package", "id": TOY, "fields": {"name": "toy", "path": ""}}));
+ all.extend(reports.as_array().unwrap().iter().cloned());
+ facts
+}
+
+/// One report fact of each kind: unmappable when `mapped` is false (no item, no package, no purl, unknown rule and
+/// severity), else naming its item and purl, with a known rule and severity.
+fn reports(mapped: bool) -> Value {
+ let item = |mut fields: Value| {
+ if mapped {
+ fields["item"] = "rust:toy::add".into();
+ }
+ fields
+ };
+ let (rule, severity) = if mapped {
+ ("needless_return", "high")
+ } else {
+ ("unknown", "unknown")
+ };
+ let mut dependency =
+ json!({"package": TOY, "name": "serde", "version": "1.0.0", "scope": "required"});
+ if mapped {
+ dependency["purl"] = "pkg:cargo/serde@1.0.0".into();
+ }
+ json!([
+ {"kind": "coverage", "id": "cov:@src/gen.rs",
+ "fields": item(json!({"file": "src/gen.rs", "lines_found": 3, "lines_hit": 1}))},
+ {"kind": "api_item", "id": "api:rust:toy::add",
+ "fields": item(json!({"path": "toy::add", "kind": "function", "visibility": "public",
+ "signature": "pub fn toy::add()"}))},
+ {"kind": "static_finding", "id": "sarif:clippy/rule",
+ "fields": item(json!({"tool": "clippy", "rule": rule, "level": "warning", "message": "m"}))},
+ {"kind": "dependency", "id": "dep:pkg:cargo/toy/serde", "fields": dependency},
+ {"kind": "vulnerability", "id": "vuln:pkg:cargo/toy/RUSTSEC-2099-0001",
+ "fields": {"package": TOY, "osv_id": "RUSTSEC-2099-0001", "aliases": [],
+ "purl": ["pkg:cargo/serde@1.0.0"], "version": ["1.0.0"], "severity": severity}},
+ ])
+}
+
+/// The `reports` pass (ADR 0388) raises each code on its class only, once per fact, naming the fact: W104 on the
+/// coverage, api_item and finding naming no item, W105 on the finding's unknown rule, W106 on the purl-less
+/// dependency, W107 on the vulnerability of unknown severity.
+#[specforge_test_macros::test(requirement = "FEATURE-003")]
+fn the_reports_pass_warns_once_per_unmappable_report_fact() {
+ let p = project(&[]);
+ stored(p.root(), "rust-source", KEY, with_reports(reports(false)));
+
+ let compiled = compiled(&p);
+
+ let mut found: Vec<(String, String)> = about(&compiled)
+ .into_iter()
+ .map(|(code, entity, message)| {
+ assert!(message.contains(&entity), "{message} names {entity}");
+ (code, entity)
+ })
+ .collect();
+ found.sort();
+ let expected = [
+ ("code/W104", "api:rust:toy::add"),
+ ("code/W104", "cov:@src/gen.rs"),
+ ("code/W104", "sarif:clippy/rule"),
+ ("code/W105", "sarif:clippy/rule"),
+ ("code/W106", "dep:pkg:cargo/toy/serde"),
+ ("code/W107", "vuln:pkg:cargo/toy/RUSTSEC-2099-0001"),
+ ]
+ .map(|(code, entity)| (code.to_string(), entity.to_string()));
+ assert_eq!(found, expected, "{:?}", compiled.diagnostics());
+}
+
+/// Report facts naming their item and purl, with a known rule and severity, raise no report code (ADR 0388).
+#[specforge_test_macros::test(requirement = "FEATURE-003")]
+fn mapped_report_facts_get_no_report_warning() {
+ let p = project(&[]);
+ stored(p.root(), "rust-source", KEY, with_reports(reports(true)));
+
+ let compiled = compiled(&p);
+
+ assert_eq!(about(&compiled), [], "{:?}", compiled.diagnostics());
+}
+
+/// A project storing no report fact gets no report code (ADR 0388).
+#[specforge_test_macros::test(requirement = "FEATURE-003")]
+fn a_project_with_no_report_facts_gets_no_report_warning() {
+ let p = project(&[]);
+ stored(p.root(), "rust-source", KEY, with_reports(json!([])));
+
+ let compiled = compiled(&p);
+
+ assert_eq!(about(&compiled), [], "{:?}", compiled.diagnostics());
+}
diff --git a/crates/session/project/tests/check_passes.rs b/crates/session/project/tests/check_passes.rs
index ed0773aff5..ff2ef5ce8d 100644
--- a/crates/session/project/tests/check_passes.rs
+++ b/crates/session/project/tests/check_passes.rs
@@ -446,6 +446,7 @@ fn a_pass_finding_with_a_code_it_may_not_use_is_reported() {
machine: false,
reported_while: None,
settled_later: false,
+ facts: Vec::new(),
}],
)
.unwrap();
@@ -526,6 +527,7 @@ fn a_pass_finding_of_a_machine_code_is_marked_machine() {
machine,
reported_while: None,
settled_later: false,
+ facts: Vec::new(),
};
let mut book = specforge_diagnostics::Codebook::default();
book.add("@acme/links", vec![code("W950", false), code("W951", true)])
diff --git a/crates/session/project/tests/file_reads.rs b/crates/session/project/tests/file_reads.rs
index 156aecc492..4378e0173b 100644
--- a/crates/session/project/tests/file_reads.rs
+++ b/crates/session/project/tests/file_reads.rs
@@ -209,6 +209,68 @@ fn a_file_over_the_cap_has_facts_and_no_text() {
assert!(f.get("text").is_none() && f["digest"].is_string(), "{f}");
}
+/// A read that declares `text_max` is sent the text of a file past 64 KiB; a read of the same file without it is
+/// still `too_large`.
+#[test]
+fn a_read_with_text_max_is_served_a_file_past_64_kib() {
+ let project = gsd_facts_project().file("big.txt", "a".repeat(200_000));
+ let (_, _, input) = probed(
+ project,
+ json!([
+ {"name": "wide", "glob": "big.txt", "text": true, "text_max": 300_000},
+ {"name": "plain", "glob": "big.txt", "text": true},
+ ]),
+ );
+
+ let wide = fact(&input, "wide", "big.txt");
+ assert_eq!(wide["text"].as_str().map(str::len), Some(200_000));
+ assert!(wide.get("error").is_none(), "{wide}");
+ let plain = fact(&input, "plain", "big.txt");
+ assert!(plain.get("text").is_none(), "{plain}");
+ assert_eq!(plain["error"], "too_large");
+}
+
+/// A read's text budget is the larger of 1 MiB and four times its `text_max`, spent in path order.
+#[test]
+fn a_text_max_read_spends_four_times_its_cap() {
+ let mut project = gsd_facts_project();
+ for n in 0..5 {
+ project = project.file(&format!("wide/f{n}.txt"), "a".repeat(300_000));
+ }
+ let (_, _, input) = probed(
+ project,
+ json!([{"name": "wide", "glob": "wide/*.txt", "text": true, "text_max": 300_000}]),
+ );
+
+ let found = facts(&input, "wide");
+ let paths: Vec<&str> = found.iter().map(|f| f["path"].as_str().unwrap()).collect();
+ assert_eq!(
+ paths,
+ [
+ "wide/f0.txt",
+ "wide/f1.txt",
+ "wide/f2.txt",
+ "wide/f3.txt",
+ "wide/f4.txt"
+ ]
+ );
+ let served: Vec<(bool, Option<&str>)> = found
+ .iter()
+ .map(|f| (f["text"].is_string(), f["error"].as_str()))
+ .collect();
+ // 4 x 300,000 = 1,200,000 bytes fit the budget; the fifth file does not.
+ assert_eq!(
+ served,
+ [
+ (true, None),
+ (true, None),
+ (true, None),
+ (true, None),
+ (false, Some("budget"))
+ ]
+ );
+}
+
#[test]
fn a_non_utf8_file_has_facts_and_not_utf8() {
let project = project_of(&plan_naming(&["bin.dat"])).file("bin.dat", [0xff_u8, 0xfe, 0x00]);
@@ -304,6 +366,63 @@ fn a_glob_skips_build_and_vcs_directories_unless_it_names_them() {
assert_eq!(facts(&input, "named")[0]["path"], "target/out.rs");
}
+/// `gsd import` reads `.planning/**` and `specforge.json` (ADR 0391 D2): a dot-directory is walked like any other,
+/// its nested files and a `.gitkeep` served with text, and a credential-looking name in it is withheld.
+#[test]
+fn a_glob_reads_a_dot_directory() {
+ let planning = [
+ (".planning/PROJECT.md", "# Project\n"),
+ (".planning/config.json", "{\"mode\": \"yolo\"}\n"),
+ (".planning/phases/01-core/01-01-PLAN.md", "# Plan\n"),
+ (".planning/phases/03-listing/.gitkeep", ""),
+ (
+ ".planning/quick/261105-tcl-totals/261105-tcl-PLAN.md",
+ "# Quick\n",
+ ),
+ ];
+ let mut project = gsd_facts_project().file(".planning/.env", "TOKEN=hunter2\n");
+ for (path, text) in planning {
+ project = project.file(path, text);
+ }
+ let manifest = fs::read_to_string(project.root().join("specforge.json")).unwrap();
+ let (_, _, input) = probed(
+ project,
+ json!([
+ {"name": "planning", "glob": ".planning/**", "text": true},
+ {"name": "manifest", "glob": "specforge.json", "text": true},
+ ]),
+ );
+
+ let served: Vec<(&str, &str)> = facts(&input, "planning")
+ .iter()
+ .filter(|f| f["path"] != ".planning/.env")
+ .map(|f| {
+ assert_eq!(f["exists"], true, "{f}");
+ assert!(f.get("error").is_none(), "{f}");
+ (f["path"].as_str().unwrap(), f["text"].as_str().unwrap())
+ })
+ .collect();
+ let mut expected = planning.to_vec();
+ expected.sort_unstable();
+ assert_eq!(served, expected);
+ assert!(input["files"]["planning"].get("truncated").is_none());
+ // The host names the credential-looking file and withholds its text, as any text read does.
+ let env = fact(&input, "planning", ".planning/.env");
+ assert_eq!(
+ (env["exists"].as_bool(), env["error"].as_str()),
+ (Some(true), Some("denied")),
+ "{env}"
+ );
+ assert!(
+ env.get("text").is_none() && env.get("digest").is_none(),
+ "{env}"
+ );
+
+ let read = facts(&input, "manifest");
+ assert_eq!(read.len(), 1, "{read:?}");
+ assert_eq!(read[0]["text"], manifest.as_str());
+}
+
#[test]
fn a_malformed_read_is_reported_and_served_empty() {
let project = gsd_facts_project();
@@ -314,6 +433,9 @@ fn a_malformed_read_is_reported_and_served_empty() {
{"name": "absolute", "glob": "/etc/*"},
{"name": "deep", "glob": "**/**/**/**/**/x"},
{"name": "ghost", "field": "plan.no_such_field"},
+ {"name": "zero", "glob": "src/*.rs", "text": true, "text_max": 0},
+ {"name": "huge", "glob": "src/*.rs", "text": true, "text_max": 5_000_000},
+ {"name": "textless", "glob": "src/*.rs", "text_max": 200_000},
{"name": "fine", "glob": "src/*.rs"},
{"name": "fine", "glob": "src/lib.rs"},
])));
@@ -335,7 +457,9 @@ fn a_malformed_read_is_reported_and_served_empty() {
.filter(|d| d.code == "W021" && d.message.contains("read"))
.map(|d| d.message.clone())
.collect();
- assert_eq!(messages.len(), 7, "{messages:#?}");
+ assert_eq!(messages.len(), 10, "{messages:#?}");
+ let text_max = messages.iter().filter(|m| m.contains("text_max"));
+ assert_eq!(text_max.count(), 3, "{messages:#?}");
assert!(GSD_FACTS_SPEC.contains("plan"));
}
diff --git a/crates/session/project/tests/namespaced_codes.rs b/crates/session/project/tests/namespaced_codes.rs
index afcc0c7595..f29e4fa54f 100644
--- a/crates/session/project/tests/namespaced_codes.rs
+++ b/crates/session/project/tests/namespaced_codes.rs
@@ -20,6 +20,7 @@ fn findings(
machine: false,
reported_while: None,
settled_later: false,
+ facts: Vec::new(),
}],
)
.unwrap();
diff --git a/crates/session/project/tests/registry_build_snapshot.rs b/crates/session/project/tests/registry_build_snapshot.rs
index 0b830c5ab3..ff0336d110 100644
--- a/crates/session/project/tests/registry_build_snapshot.rs
+++ b/crates/session/project/tests/registry_build_snapshot.rs
@@ -271,7 +271,7 @@ fn digest(env: &Environment) -> Value {
fn registry_build_of_the_builtins_matches_its_snapshot() {
let runtime = std::sync::Arc::new(runtime());
// Each set loads together into its own registry (ADR 0369 D3): two declarers of one keyword never
- // load into one. `all_builtins` pins the old set's fourteen, `all_builtins_gsd` the gsd set's eight.
+ // load into one. `all_builtins` pins the old set's twenty-six, `all_builtins_gsd` the gsd set's twenty-one.
let old: Vec<&str> = Family::Old.builtins().map(|builtin| builtin.name).collect();
insta::assert_json_snapshot!("all_builtins", digest(&load(&runtime, &old)));
let gsd: Vec<&str> = Family::Gsd.builtins().map(|builtin| builtin.name).collect();
diff --git a/crates/session/project/tests/snapshots/tests__registry_build_snapshot__all_builtins.snap b/crates/session/project/tests/snapshots/tests__registry_build_snapshot__all_builtins.snap
index c9ab566324..e578787cdf 100644
--- a/crates/session/project/tests/snapshots/tests__registry_build_snapshot__all_builtins.snap
+++ b/crates/session/project/tests/snapshots/tests__registry_build_snapshot__all_builtins.snap
@@ -1,6 +1,6 @@
---
source: crates/session/project/tests/registry_build_snapshot.rs
-expression: "digest(&load(&runtime, &all))"
+expression: "digest(&load(&runtime, &old))"
---
{
"check_passes": [
@@ -19,6 +19,10 @@ expression: "digest(&load(&runtime, &all))"
{
"extension": "@code/core",
"name": "proof"
+ },
+ {
+ "extension": "@code/core",
+ "name": "reports"
}
],
"commands": [
@@ -1275,6 +1279,120 @@ expression: "digest(&load(&runtime, &all))"
"@specforge/software type.extends -> type"
]
},
+ "affects": {
+ "description": "The project package a vulnerability affects",
+ "edge_arrowhead": null,
+ "edge_color": null,
+ "edge_style": null,
+ "label": "affects",
+ "source_extension": "@code/core",
+ "source_kind": "vulnerability",
+ "sources": [
+ "vulnerability"
+ ],
+ "target_kind": "package",
+ "targets": [
+ "package"
+ ],
+ "writers": [
+ "@code/core vulnerability.package -> package"
+ ]
+ },
+ "api_of": {
+ "description": "The item an API snapshot's entry is the API of",
+ "edge_arrowhead": null,
+ "edge_color": null,
+ "edge_style": null,
+ "label": "api_of",
+ "source_extension": "@code/core",
+ "source_kind": "api_item",
+ "sources": [
+ "api_item"
+ ],
+ "target_kind": "item",
+ "targets": [
+ "item"
+ ],
+ "writers": [
+ "@code/core api_item.item -> item"
+ ]
+ },
+ "covers": {
+ "description": "The item a coverage fact reports on",
+ "edge_arrowhead": null,
+ "edge_color": null,
+ "edge_style": null,
+ "label": "covers",
+ "source_extension": "@code/core",
+ "source_kind": "coverage",
+ "sources": [
+ "coverage"
+ ],
+ "target_kind": "item",
+ "targets": [
+ "item"
+ ],
+ "writers": [
+ "@code/core coverage.item -> item"
+ ]
+ },
+ "dependency_of": {
+ "description": "The project package a dependency is a component of the BOM of",
+ "edge_arrowhead": null,
+ "edge_color": null,
+ "edge_style": null,
+ "label": "dependency_of",
+ "source_extension": "@code/core",
+ "source_kind": "dependency",
+ "sources": [
+ "dependency"
+ ],
+ "target_kind": "package",
+ "targets": [
+ "package"
+ ],
+ "writers": [
+ "@code/core dependency.package -> package"
+ ]
+ },
+ "found_in": {
+ "description": "The item a static finding lies in",
+ "edge_arrowhead": null,
+ "edge_color": null,
+ "edge_style": null,
+ "label": "found_in",
+ "source_extension": "@code/core",
+ "source_kind": "static_finding",
+ "sources": [
+ "static_finding"
+ ],
+ "target_kind": "item",
+ "targets": [
+ "item"
+ ],
+ "writers": [
+ "@code/core static_finding.item -> item"
+ ]
+ },
+ "found_in_package": {
+ "description": "The package a static finding lies in, when no item holds it",
+ "edge_arrowhead": null,
+ "edge_color": null,
+ "edge_style": null,
+ "label": "found_in_package",
+ "source_extension": "@code/core",
+ "source_kind": "static_finding",
+ "sources": [
+ "static_finding"
+ ],
+ "target_kind": "package",
+ "targets": [
+ "package"
+ ],
+ "writers": [
+ "@code/core static_finding.package -> package"
+ ]
+ },
"in_package": {
"description": "The package an item is defined in",
"edge_arrowhead": null,
@@ -1373,9 +1491,21 @@ expression: "digest(&load(&runtime, &all))"
},
"ext_short": {
"@code/core": "core",
+ "@javascript/api": "api",
+ "@javascript/coverage": "coverage",
+ "@javascript/deps": "deps",
+ "@javascript/jest": "jest",
+ "@javascript/lint": "lint",
"@javascript/node-test": "node-test",
+ "@javascript/playwright": "playwright",
"@javascript/source": "source",
+ "@javascript/vitest": "vitest",
+ "@rust/api": "api",
"@rust/cargo": "cargo",
+ "@rust/coverage": "coverage",
+ "@rust/deps": "deps",
+ "@rust/lint": "lint",
+ "@rust/proof": "proof",
"@rust/source": "source",
"@rust/test": "test",
"@specforge/cargo-test": "cargo-test",
@@ -1418,7 +1548,7 @@ expression: "digest(&load(&runtime, &all))"
],
[
"@code/core",
- "1.1.0"
+ "1.4.0"
],
[
"@javascript/node-test",
@@ -1443,9 +1573,217 @@ expression: "digest(&load(&runtime, &all))"
[
"@javascript/source",
"1.0.0"
+ ],
+ [
+ "@rust/coverage",
+ "1.0.0"
+ ],
+ [
+ "@rust/lint",
+ "1.0.0"
+ ],
+ [
+ "@rust/deps",
+ "1.0.0"
+ ],
+ [
+ "@rust/api",
+ "1.0.0"
+ ],
+ [
+ "@rust/proof",
+ "1.0.0"
+ ],
+ [
+ "@javascript/coverage",
+ "1.0.0"
+ ],
+ [
+ "@javascript/lint",
+ "1.0.0"
+ ],
+ [
+ "@javascript/deps",
+ "1.0.0"
+ ],
+ [
+ "@javascript/api",
+ "1.0.0"
+ ],
+ [
+ "@javascript/vitest",
+ "1.0.0"
+ ],
+ [
+ "@javascript/jest",
+ "1.0.0"
+ ],
+ [
+ "@javascript/playwright",
+ "1.0.0"
]
],
"fields": {
+ "api_item.accepted_signature": {
+ "derived_from": null,
+ "description": "The accepted report's entry as it wrote it, for a changed, narrowed or removed entry",
+ "edge": null,
+ "exempts_obligations": false,
+ "field_name": "accepted_signature",
+ "field_type": "String",
+ "headline": false,
+ "inverse_of": null,
+ "kind_name": "api_item",
+ "normative": false,
+ "proof_role": null,
+ "required": false,
+ "source_extension": "@code/core",
+ "target_kind": null
+ },
+ "api_item.accepted_tag": {
+ "derived_from": null,
+ "description": "The accepted report's release tag, for a changed, narrowed or removed entry that has one",
+ "edge": null,
+ "exempts_obligations": false,
+ "field_name": "accepted_tag",
+ "field_type": "String",
+ "headline": false,
+ "inverse_of": null,
+ "kind_name": "api_item",
+ "normative": false,
+ "proof_role": null,
+ "required": false,
+ "source_extension": "@code/core",
+ "target_kind": null
+ },
+ "api_item.accepted_visibility": {
+ "derived_from": null,
+ "description": "The accepted report's visibility, for a changed or narrowed entry whose visibility differs",
+ "edge": null,
+ "exempts_obligations": false,
+ "field_name": "accepted_visibility",
+ "field_type": "Enum([\"public\", \"crate\", \"restricted\", \"private\"])",
+ "headline": false,
+ "inverse_of": null,
+ "kind_name": "api_item",
+ "normative": false,
+ "proof_role": null,
+ "required": false,
+ "source_extension": "@code/core",
+ "target_kind": null
+ },
+ "api_item.change": {
+ "derived_from": null,
+ "description": "The entry against the committed accepted report; absent when no accepted report covers its crate or package",
+ "edge": null,
+ "exempts_obligations": false,
+ "field_name": "change",
+ "field_type": "Enum([\"added\", \"unchanged\", \"changed\", \"narrowed\", \"removed\"])",
+ "headline": false,
+ "inverse_of": null,
+ "kind_name": "api_item",
+ "normative": false,
+ "proof_role": null,
+ "required": false,
+ "source_extension": "@code/core",
+ "target_kind": null
+ },
+ "api_item.item": {
+ "derived_from": null,
+ "description": "The item the entry is the API of; absent when no collected item has its path (W104 for a kind an item can have)",
+ "edge": "api_of",
+ "exempts_obligations": false,
+ "field_name": "item",
+ "field_type": "Reference",
+ "headline": false,
+ "inverse_of": null,
+ "kind_name": "api_item",
+ "normative": false,
+ "proof_role": null,
+ "required": false,
+ "source_extension": "@code/core",
+ "target_kind": "item"
+ },
+ "api_item.kind": {
+ "derived_from": null,
+ "description": "What the entry is: an item kind, or variant, reexport, extern_crate, other, which no item is",
+ "edge": null,
+ "exempts_obligations": false,
+ "field_name": "kind",
+ "field_type": "Enum([\"module\", \"function\", \"method\", \"field\", \"struct\", \"enum\", \"union\", \"trait\", \"type\", \"const\", \"static\", \"macro\", \"class\", \"interface\", \"variable\", \"namespace\", \"variant\", \"reexport\", \"extern_crate\", \"other\"])",
+ "headline": false,
+ "inverse_of": null,
+ "kind_name": "api_item",
+ "normative": false,
+ "proof_role": null,
+ "required": false,
+ "source_extension": "@code/core",
+ "target_kind": null
+ },
+ "api_item.path": {
+ "derived_from": null,
+ "description": "The entry's qualified path as the snapshot wrote it",
+ "edge": null,
+ "exempts_obligations": false,
+ "field_name": "path",
+ "field_type": "String",
+ "headline": false,
+ "inverse_of": null,
+ "kind_name": "api_item",
+ "normative": false,
+ "proof_role": null,
+ "required": false,
+ "source_extension": "@code/core",
+ "target_kind": null
+ },
+ "api_item.signature": {
+ "derived_from": null,
+ "description": "The entry exactly as the snapshot wrote it, attributes included",
+ "edge": null,
+ "exempts_obligations": false,
+ "field_name": "signature",
+ "field_type": "String",
+ "headline": false,
+ "inverse_of": null,
+ "kind_name": "api_item",
+ "normative": false,
+ "proof_role": null,
+ "required": false,
+ "source_extension": "@code/core",
+ "target_kind": null
+ },
+ "api_item.tag": {
+ "derived_from": null,
+ "description": "The api-extractor release tag (Public, Beta, Alpha, Internal)",
+ "edge": null,
+ "exempts_obligations": false,
+ "field_name": "tag",
+ "field_type": "String",
+ "headline": false,
+ "inverse_of": null,
+ "kind_name": "api_item",
+ "normative": false,
+ "proof_role": null,
+ "required": false,
+ "source_extension": "@code/core",
+ "target_kind": null
+ },
+ "api_item.visibility": {
+ "derived_from": null,
+ "description": "Who may name it, as the snapshot wrote it",
+ "edge": null,
+ "exempts_obligations": false,
+ "field_name": "visibility",
+ "field_type": "Enum([\"public\", \"crate\", \"restricted\", \"private\"])",
+ "headline": false,
+ "inverse_of": null,
+ "kind_name": "api_item",
+ "normative": false,
+ "proof_role": null,
+ "required": false,
+ "source_extension": "@code/core",
+ "target_kind": null
+ },
"axiom.assumes": {
"derived_from": null,
"description": "Invariants this axiom assumes as foundational truths",
@@ -2262,6 +2600,134 @@ expression: "digest(&load(&runtime, &all))"
"source_extension": "@specforge/governance",
"target_kind": null
},
+ "coverage.branches_found": {
+ "derived_from": null,
+ "description": "The branches the report measured in it",
+ "edge": null,
+ "exempts_obligations": false,
+ "field_name": "branches_found",
+ "field_type": "Integer",
+ "headline": false,
+ "inverse_of": null,
+ "kind_name": "coverage",
+ "normative": false,
+ "proof_role": null,
+ "required": false,
+ "source_extension": "@code/core",
+ "target_kind": null
+ },
+ "coverage.branches_hit": {
+ "derived_from": null,
+ "description": "Those of its branches that were taken",
+ "edge": null,
+ "exempts_obligations": false,
+ "field_name": "branches_hit",
+ "field_type": "Integer",
+ "headline": false,
+ "inverse_of": null,
+ "kind_name": "coverage",
+ "normative": false,
+ "proof_role": null,
+ "required": false,
+ "source_extension": "@code/core",
+ "target_kind": null
+ },
+ "coverage.file": {
+ "derived_from": null,
+ "description": "The report's file, project-relative, with / separators",
+ "edge": null,
+ "exempts_obligations": false,
+ "field_name": "file",
+ "field_type": "String",
+ "headline": false,
+ "inverse_of": null,
+ "kind_name": "coverage",
+ "normative": false,
+ "proof_role": null,
+ "required": false,
+ "source_extension": "@code/core",
+ "target_kind": null
+ },
+ "coverage.functions_found": {
+ "derived_from": null,
+ "description": "The functions the report lists in it",
+ "edge": null,
+ "exempts_obligations": false,
+ "field_name": "functions_found",
+ "field_type": "Integer",
+ "headline": false,
+ "inverse_of": null,
+ "kind_name": "coverage",
+ "normative": false,
+ "proof_role": null,
+ "required": false,
+ "source_extension": "@code/core",
+ "target_kind": null
+ },
+ "coverage.functions_hit": {
+ "derived_from": null,
+ "description": "Those of its functions that ran",
+ "edge": null,
+ "exempts_obligations": false,
+ "field_name": "functions_hit",
+ "field_type": "Integer",
+ "headline": false,
+ "inverse_of": null,
+ "kind_name": "coverage",
+ "normative": false,
+ "proof_role": null,
+ "required": false,
+ "source_extension": "@code/core",
+ "target_kind": null
+ },
+ "coverage.item": {
+ "derived_from": null,
+ "description": "The item holding the lines; absent when no collected item does",
+ "edge": "covers",
+ "exempts_obligations": false,
+ "field_name": "item",
+ "field_type": "Reference",
+ "headline": false,
+ "inverse_of": null,
+ "kind_name": "coverage",
+ "normative": false,
+ "proof_role": null,
+ "required": false,
+ "source_extension": "@code/core",
+ "target_kind": "item"
+ },
+ "coverage.lines_found": {
+ "derived_from": null,
+ "description": "The lines the report measured in it",
+ "edge": null,
+ "exempts_obligations": false,
+ "field_name": "lines_found",
+ "field_type": "Integer",
+ "headline": false,
+ "inverse_of": null,
+ "kind_name": "coverage",
+ "normative": false,
+ "proof_role": null,
+ "required": false,
+ "source_extension": "@code/core",
+ "target_kind": null
+ },
+ "coverage.lines_hit": {
+ "derived_from": null,
+ "description": "Those of its lines that ran",
+ "edge": null,
+ "exempts_obligations": false,
+ "field_name": "lines_hit",
+ "field_type": "Integer",
+ "headline": false,
+ "inverse_of": null,
+ "kind_name": "coverage",
+ "normative": false,
+ "proof_role": null,
+ "required": false,
+ "source_extension": "@code/core",
+ "target_kind": null
+ },
"decision.affects_features": {
"derived_from": null,
"description": "Product features affected by this decision (requires @specforge/product)",
@@ -2710,6 +3176,102 @@ expression: "digest(&load(&runtime, &all))"
"source_extension": "@specforge/product",
"target_kind": null
},
+ "dependency.direct": {
+ "derived_from": null,
+ "description": "Whether the project package depends on it directly; present only when the BOM states a dependency graph for its root, never false for a graph it does not state",
+ "edge": null,
+ "exempts_obligations": false,
+ "field_name": "direct",
+ "field_type": "Bool",
+ "headline": false,
+ "inverse_of": null,
+ "kind_name": "dependency",
+ "normative": false,
+ "proof_role": null,
+ "required": false,
+ "source_extension": "@code/core",
+ "target_kind": null
+ },
+ "dependency.name": {
+ "derived_from": null,
+ "description": "The component's name, group/name when it states a group",
+ "edge": null,
+ "exempts_obligations": false,
+ "field_name": "name",
+ "field_type": "String",
+ "headline": false,
+ "inverse_of": null,
+ "kind_name": "dependency",
+ "normative": false,
+ "proof_role": null,
+ "required": false,
+ "source_extension": "@code/core",
+ "target_kind": null
+ },
+ "dependency.package": {
+ "derived_from": null,
+ "description": "The project package the BOM describes (its metadata.component)",
+ "edge": "dependency_of",
+ "exempts_obligations": false,
+ "field_name": "package",
+ "field_type": "Reference",
+ "headline": false,
+ "inverse_of": null,
+ "kind_name": "dependency",
+ "normative": false,
+ "proof_role": null,
+ "required": false,
+ "source_extension": "@code/core",
+ "target_kind": "package"
+ },
+ "dependency.purl": {
+ "derived_from": null,
+ "description": "The component's package URL as written; absent when it has none (W106)",
+ "edge": null,
+ "exempts_obligations": false,
+ "field_name": "purl",
+ "field_type": "String",
+ "headline": false,
+ "inverse_of": null,
+ "kind_name": "dependency",
+ "normative": false,
+ "proof_role": null,
+ "required": false,
+ "source_extension": "@code/core",
+ "target_kind": null
+ },
+ "dependency.scope": {
+ "derived_from": null,
+ "description": "The component's scope, required when the BOM states none (the spec's default); the widest of a purl listed twice",
+ "edge": null,
+ "exempts_obligations": false,
+ "field_name": "scope",
+ "field_type": "Enum([\"required\", \"optional\", \"excluded\"])",
+ "headline": false,
+ "inverse_of": null,
+ "kind_name": "dependency",
+ "normative": false,
+ "proof_role": null,
+ "required": false,
+ "source_extension": "@code/core",
+ "target_kind": null
+ },
+ "dependency.version": {
+ "derived_from": null,
+ "description": "The component's version, when it states one",
+ "edge": null,
+ "exempts_obligations": false,
+ "field_name": "version",
+ "field_type": "String",
+ "headline": false,
+ "inverse_of": null,
+ "kind_name": "dependency",
+ "normative": false,
+ "proof_role": null,
+ "required": false,
+ "source_extension": "@code/core",
+ "target_kind": null
+ },
"event.category": {
"derived_from": null,
"description": "Classification of this event (e.g. domain, integration, system)",
@@ -5078,6 +5640,134 @@ expression: "digest(&load(&runtime, &all))"
"source_extension": "@specforge/product",
"target_kind": null
},
+ "static_finding.file": {
+ "derived_from": null,
+ "description": "The file of its first location, project-relative, with / separators",
+ "edge": null,
+ "exempts_obligations": false,
+ "field_name": "file",
+ "field_type": "String",
+ "headline": false,
+ "inverse_of": null,
+ "kind_name": "static_finding",
+ "normative": false,
+ "proof_role": null,
+ "required": false,
+ "source_extension": "@code/core",
+ "target_kind": null
+ },
+ "static_finding.item": {
+ "derived_from": null,
+ "description": "The innermost item holding its line; absent when no collected item does",
+ "edge": "found_in",
+ "exempts_obligations": false,
+ "field_name": "item",
+ "field_type": "Reference",
+ "headline": false,
+ "inverse_of": null,
+ "kind_name": "static_finding",
+ "normative": false,
+ "proof_role": null,
+ "required": false,
+ "source_extension": "@code/core",
+ "target_kind": "item"
+ },
+ "static_finding.level": {
+ "derived_from": null,
+ "description": "The level the result or its rule's defaultConfiguration states; unknown when neither does (W105), never SARIF's own warning default",
+ "edge": null,
+ "exempts_obligations": false,
+ "field_name": "level",
+ "field_type": "Enum([\"error\", \"warning\", \"note\", \"none\", \"unknown\"])",
+ "headline": false,
+ "inverse_of": null,
+ "kind_name": "static_finding",
+ "normative": false,
+ "proof_role": null,
+ "required": false,
+ "source_extension": "@code/core",
+ "target_kind": null
+ },
+ "static_finding.line": {
+ "derived_from": null,
+ "description": "The 1-based start line of its first location",
+ "edge": null,
+ "exempts_obligations": false,
+ "field_name": "line",
+ "field_type": "Integer",
+ "headline": false,
+ "inverse_of": null,
+ "kind_name": "static_finding",
+ "normative": false,
+ "proof_role": null,
+ "required": false,
+ "source_extension": "@code/core",
+ "target_kind": null
+ },
+ "static_finding.message": {
+ "derived_from": null,
+ "description": "The result's message.text",
+ "edge": null,
+ "exempts_obligations": false,
+ "field_name": "message",
+ "field_type": "String",
+ "headline": false,
+ "inverse_of": null,
+ "kind_name": "static_finding",
+ "normative": false,
+ "proof_role": null,
+ "required": false,
+ "source_extension": "@code/core",
+ "target_kind": null
+ },
+ "static_finding.package": {
+ "derived_from": null,
+ "description": "The package holding its file, when no item holds its line; absent with neither (W104)",
+ "edge": "found_in_package",
+ "exempts_obligations": false,
+ "field_name": "package",
+ "field_type": "Reference",
+ "headline": false,
+ "inverse_of": null,
+ "kind_name": "static_finding",
+ "normative": false,
+ "proof_role": null,
+ "required": false,
+ "source_extension": "@code/core",
+ "target_kind": "package"
+ },
+ "static_finding.rule": {
+ "derived_from": null,
+ "description": "The rule id the result states; unknown when it states none (W105)",
+ "edge": null,
+ "exempts_obligations": false,
+ "field_name": "rule",
+ "field_type": "String",
+ "headline": false,
+ "inverse_of": null,
+ "kind_name": "static_finding",
+ "normative": false,
+ "proof_role": null,
+ "required": false,
+ "source_extension": "@code/core",
+ "target_kind": null
+ },
+ "static_finding.tool": {
+ "derived_from": null,
+ "description": "The run's tool (tool.driver.name)",
+ "edge": null,
+ "exempts_obligations": false,
+ "field_name": "tool",
+ "field_type": "String",
+ "headline": false,
+ "inverse_of": null,
+ "kind_name": "static_finding",
+ "normative": false,
+ "proof_role": null,
+ "required": false,
+ "source_extension": "@code/core",
+ "target_kind": null
+ },
"term.aliases": {
"derived_from": null,
"description": "Alternative names or abbreviations for this term",
@@ -5397,6 +6087,118 @@ expression: "digest(&load(&runtime, &all))"
"required": false,
"source_extension": "@specforge/software",
"target_kind": null
+ },
+ "vulnerability.aliases": {
+ "derived_from": null,
+ "description": "The record's aliases (CVE ids and the like), sorted",
+ "edge": null,
+ "exempts_obligations": false,
+ "field_name": "aliases",
+ "field_type": "StringList",
+ "headline": false,
+ "inverse_of": null,
+ "kind_name": "vulnerability",
+ "normative": false,
+ "proof_role": null,
+ "required": false,
+ "source_extension": "@code/core",
+ "target_kind": null
+ },
+ "vulnerability.osv_id": {
+ "derived_from": null,
+ "description": "The OSV record's id (GHSA-…, RUSTSEC-…)",
+ "edge": null,
+ "exempts_obligations": false,
+ "field_name": "osv_id",
+ "field_type": "String",
+ "headline": false,
+ "inverse_of": null,
+ "kind_name": "vulnerability",
+ "normative": false,
+ "proof_role": null,
+ "required": false,
+ "source_extension": "@code/core",
+ "target_kind": null
+ },
+ "vulnerability.package": {
+ "derived_from": null,
+ "description": "The project package the scanned lockfile belongs to: the one at its directory, else each one under it",
+ "edge": "affects",
+ "exempts_obligations": false,
+ "field_name": "package",
+ "field_type": "Reference",
+ "headline": false,
+ "inverse_of": null,
+ "kind_name": "vulnerability",
+ "normative": false,
+ "proof_role": null,
+ "required": false,
+ "source_extension": "@code/core",
+ "target_kind": "package"
+ },
+ "vulnerability.purl": {
+ "derived_from": null,
+ "description": "The affected dependency's package URL at each affected version",
+ "edge": null,
+ "exempts_obligations": false,
+ "field_name": "purl",
+ "field_type": "StringList",
+ "headline": false,
+ "inverse_of": null,
+ "kind_name": "vulnerability",
+ "normative": false,
+ "proof_role": null,
+ "required": false,
+ "source_extension": "@code/core",
+ "target_kind": null
+ },
+ "vulnerability.severity": {
+ "derived_from": null,
+ "description": "The record's own severity label (MODERATE reads medium), else the rating of its highest CVSS v3 base score, else unknown (W107); the highest of the records merged",
+ "edge": null,
+ "exempts_obligations": false,
+ "field_name": "severity",
+ "field_type": "Enum([\"critical\", \"high\", \"medium\", \"low\", \"unknown\"])",
+ "headline": false,
+ "inverse_of": null,
+ "kind_name": "vulnerability",
+ "normative": false,
+ "proof_role": null,
+ "required": false,
+ "source_extension": "@code/core",
+ "target_kind": null
+ },
+ "vulnerability.summary": {
+ "derived_from": null,
+ "description": "The record's one-line summary; absent when it states none",
+ "edge": null,
+ "exempts_obligations": false,
+ "field_name": "summary",
+ "field_type": "String",
+ "headline": false,
+ "inverse_of": null,
+ "kind_name": "vulnerability",
+ "normative": false,
+ "proof_role": null,
+ "required": false,
+ "source_extension": "@code/core",
+ "target_kind": null
+ },
+ "vulnerability.version": {
+ "derived_from": null,
+ "description": "The affected dependency's versions the lockfile pins",
+ "edge": null,
+ "exempts_obligations": false,
+ "field_name": "version",
+ "field_type": "StringList",
+ "headline": false,
+ "inverse_of": null,
+ "kind_name": "vulnerability",
+ "normative": false,
+ "proof_role": null,
+ "required": false,
+ "source_extension": "@code/core",
+ "target_kind": null
}
},
"graph_inputs": {
@@ -5416,6 +6218,16 @@ expression: "digest(&load(&runtime, &all))"
}
],
"field_forms": {
+ "api_item.accepted_signature": "string",
+ "api_item.accepted_tag": "string",
+ "api_item.accepted_visibility": "enum (public, crate, restricted, private)",
+ "api_item.change": "enum (added, unchanged, changed, narrowed, removed)",
+ "api_item.item": "reference",
+ "api_item.kind": "enum (module, function, method, field, struct, enum, union, trait, type, const, static, macro, class, interface, variable, namespace, variant, reexport, extern_crate, other)",
+ "api_item.path": "string",
+ "api_item.signature": "string",
+ "api_item.tag": "string",
+ "api_item.visibility": "enum (public, crate, restricted, private)",
"axiom.assumes": "reference_list",
"axiom.description": "string",
"axiom.expression": "string",
@@ -5467,6 +6279,14 @@ expression: "digest(&load(&runtime, &all))"
"constraint.refs": "string_list",
"constraint.scope": "string",
"constraint.threshold": "string",
+ "coverage.branches_found": "integer",
+ "coverage.branches_hit": "integer",
+ "coverage.file": "string",
+ "coverage.functions_found": "integer",
+ "coverage.functions_hit": "integer",
+ "coverage.item": "reference",
+ "coverage.lines_found": "integer",
+ "coverage.lines_hit": "integer",
"decision.affects_features": "reference_list",
"decision.alternatives": "string_list",
"decision.authors": "string_list",
@@ -5495,6 +6315,12 @@ expression: "digest(&load(&runtime, &all))"
"deliverable.status": "enum (draft, in_progress, shipped, deprecated)",
"deliverable.tags": "string_list",
"deliverable.version": "string",
+ "dependency.direct": "bool",
+ "dependency.name": "string",
+ "dependency.package": "reference",
+ "dependency.purl": "string",
+ "dependency.scope": "enum (required, optional, excluded)",
+ "dependency.version": "string",
"event.category": "identifier",
"event.channel": "string",
"event.channel_type": "identifier",
@@ -5643,6 +6469,14 @@ expression: "digest(&load(&runtime, &all))"
"release.tags": "string_list",
"release.target_date": "date",
"release.version": "string",
+ "static_finding.file": "string",
+ "static_finding.item": "reference",
+ "static_finding.level": "enum (error, warning, note, none, unknown)",
+ "static_finding.line": "integer",
+ "static_finding.message": "string",
+ "static_finding.package": "reference",
+ "static_finding.rule": "string",
+ "static_finding.tool": "string",
"term.aliases": "string_list",
"term.context": "string",
"term.definition": "string",
@@ -5662,7 +6496,14 @@ expression: "digest(&load(&runtime, &all))"
"type.composed_types": "reference_list",
"type.description": "string",
"type.extends": "reference",
- "type.refs": "string_list"
+ "type.refs": "string_list",
+ "vulnerability.aliases": "string_list",
+ "vulnerability.osv_id": "string",
+ "vulnerability.package": "reference",
+ "vulnerability.purl": "string_list",
+ "vulnerability.severity": "enum (critical, high, medium, low, unknown)",
+ "vulnerability.summary": "string",
+ "vulnerability.version": "string_list"
},
"member_kinds": [
"port",
@@ -5670,6 +6511,24 @@ expression: "digest(&load(&runtime, &all))"
]
},
"kinds": {
+ "api_item": {
+ "allowed_verify_kinds": [],
+ "contract_target": false,
+ "declares_types": false,
+ "description": "One public entry of an API snapshot, written by an api pack's collector (ADR 0388): api:rust::: (cargo public-api, a trait-impl member ...::::m), api:js::: (api-extractor), the id holding no line, order nor source file",
+ "dot_color": null,
+ "dot_fillcolor": null,
+ "dot_shape": null,
+ "has_body_parser": false,
+ "kind_name": "api_item",
+ "lsp_icon": null,
+ "open_fields": false,
+ "semantic_token": null,
+ "singleton": false,
+ "source_extension": "@code/core",
+ "supports_verify": false,
+ "testable": false
+ },
"axiom": {
"allowed_verify_kinds": [],
"contract_target": false,
@@ -5772,6 +6631,24 @@ expression: "digest(&load(&runtime, &all))"
"supports_verify": true,
"testable": true
},
+ "coverage": {
+ "allowed_verify_kinds": [],
+ "contract_target": false,
+ "declares_types": false,
+ "description": "What a coverage report (LCOV) says of one item, written by a coverage pack's collector (ADR 0388): cov: for the innermost item holding the report's lines, cov:@ for what no item of a file holds (W104)",
+ "dot_color": null,
+ "dot_fillcolor": null,
+ "dot_shape": null,
+ "has_body_parser": false,
+ "kind_name": "coverage",
+ "lsp_icon": null,
+ "open_fields": false,
+ "semantic_token": null,
+ "singleton": false,
+ "source_extension": "@code/core",
+ "supports_verify": false,
+ "testable": false
+ },
"decision": {
"allowed_verify_kinds": [],
"contract_target": false,
@@ -5808,6 +6685,24 @@ expression: "digest(&load(&runtime, &all))"
"supports_verify": false,
"testable": false
},
+ "dependency": {
+ "allowed_verify_kinds": [],
+ "contract_target": false,
+ "declares_types": false,
+ "description": "One component of a CycloneDX bill of materials, written by an SBOM pack's collector (ADR 0388): dep:/, or dep: