Skip to content

Commit 4b677d4

Browse files
Haofeiclaude
andcommitted
Version the package-review artifact with $schema + producer (review #5)
The package-review JSON (consumed by the REIR adapter and CI) carried no schema id or producer version, so a consumer could not reason about compatibility. Add a `$schema` ("rsscript.package_review.v0.1") and `producer` {name, version from CARGO_PKG_VERSION} envelope to PackageReview. Additive and ignored by the REIR adapter (no deny_unknown_fields); bump the schema id on breaking changes. (REIR bundles and rsspkg.lock were already versioned.) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 671f547 commit 4b677d4

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

src/package/review.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,8 @@ pub(super) fn review_package_dir_with_features(
265265
});
266266

267267
Ok(PackageReview {
268+
schema: super::types::PACKAGE_REVIEW_SCHEMA.to_string(),
269+
producer: super::types::ArtifactProducer::current(),
268270
package: super::package_identity(manifest),
269271
manifest_path: package.manifest_path.display().to_string(),
270272
risk,

src/package/types.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,31 @@ use crate::diagnostic::{Diagnostic, Span};
66
use crate::review::{ReviewFinding, ReviewMap};
77
use crate::rust_lower::NativeRustDependency;
88

9+
/// Schema id for the package-review JSON artifact. Bump on breaking changes.
10+
pub const PACKAGE_REVIEW_SCHEMA: &str = "rsscript.package_review.v0.1";
11+
12+
/// The tool + version that produced an artifact, so consumers can reason about
13+
/// schema compatibility instead of guessing.
14+
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
15+
pub struct ArtifactProducer {
16+
pub name: String,
17+
pub version: String,
18+
}
19+
20+
impl ArtifactProducer {
21+
pub fn current() -> Self {
22+
Self {
23+
name: "rsscript".to_string(),
24+
version: env!("CARGO_PKG_VERSION").to_string(),
25+
}
26+
}
27+
}
28+
929
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
1030
pub struct PackageReview {
31+
#[serde(rename = "$schema")]
32+
pub schema: String,
33+
pub producer: ArtifactProducer,
1134
pub package: PackageIdentity,
1235
pub manifest_path: String,
1336
pub risk: PackageRisk,

0 commit comments

Comments
 (0)