Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
fcaa7c7
feat(rstack): resolve review wiring from authored service projects
jeremi Dec 5, 2026
0d0f705
fix(rstack): prepare paired Casework before changing managed state
jeremi Dec 5, 2026
778bb2f
fix(casework): make private development copies writable
jeremi Dec 5, 2026
43bb468
fix(rstack): validate paired description package paths
jeremi Dec 5, 2026
84819b8
fix(rstack): protect managed state from invalid Casework packages
jeremi Dec 5, 2026
dc2b41a
test(rstack): project the run issuer from parsed YAML
jeremi Dec 5, 2026
673dd19
test(rstack): use the selected issuer for review staff
jeremi Dec 5, 2026
b353d39
fix(rstack): type the Casework preflight arguments
jeremi Dec 5, 2026
1881ed3
fix(rstack): preserve portable review package inputs
jeremi Dec 5, 2026
5983f1c
test(rstack): read fixtures through the platform YAML reader
jeremi Dec 5, 2026
d4327f4
fix(casework): check projected package warning diagnostics
jeremi Dec 5, 2026
413df91
test(release): account for the BReg journey timeout
jeremi Dec 5, 2026
929136f
docs(rstack): clarify which review description must be separate
jeremi Dec 5, 2026
0f7a878
test(breg): pin the scoped provisioning timeout
jeremi Dec 5, 2026
3d5aaa2
test(rstack): keep the prospective display schema pin exact
jeremi Dec 5, 2026
8e3c7a7
fix(casework): size the native review export before wiring
jeremi Dec 5, 2026
87526bb
docs(rstack): place initiator trust on the Casework producer
jeremi Dec 5, 2026
4c535fb
fix(casework): restore preflight for unpinned providers
jeremi Dec 5, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1952,7 +1952,7 @@ jobs:
needs: changes
if: needs.changes.outputs.breg_contracts == 'true'
runs-on: ubuntu-24.04
timeout-minutes: 30
timeout-minutes: ${{ matrix.lane == 'contracts-journeys' && 40 || 30 }}
strategy:
fail-fast: false
matrix:
Expand Down
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/registry-caseworkctl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ anyhow.workspace = true
clap.workspace = true
jsonschema.workspace = true
registry-platform-buildinfo.workspace = true
registry-platform-canonical-json.workspace = true
registry-platform-config.workspace = true
registry-platform-provision = { workspace = true, features = ["cli"] }
registry-platform-yaml.workspace = true
Expand Down
6 changes: 6 additions & 0 deletions crates/registry-caseworkctl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,9 @@ struct CheckArgs {
/// Resolve configured environment substitutions while checking the runtime file.
#[arg(long, requires = "runtime_config")]
environment: bool,
/// Internal local review preflight, before BReg activation supplies the export.
#[arg(long, hide = true, conflicts_with_all = ["runtime_config", "against_breg_package", "production", "require_package_closure", "deny_warnings"])]
review_package_provider: Option<String>,
}
pub fn command() -> clap::Command {
Cli::command()
Expand Down Expand Up @@ -822,6 +825,9 @@ fn run(command: Command, posture: Option<DeclaredPosture>) -> Result<Value> {
project, template, ..
} => project::init(&project, &template),
Command::Check(args) => {
if let Some(provider) = args.review_package_provider.as_deref() {
return project::check_review_package(&args.project, provider);
}
let require_package_closure = args.require_package_closure || args.production;
let mut result = if args.runtime_config.is_some() {
project::check(&args.project, require_package_closure, false)
Expand Down
154 changes: 146 additions & 8 deletions crates/registry-caseworkctl/src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ use registry_casework_core::{
CaseworkActsAs, CaseworkProject, ClockPolicy, ConfigLoadError, ReviewContextPolicy,
ReviewContextProviderPolicy,
};
use registry_platform_canonical_json::canonicalize_json;
use registry_platform_config::{
plan_package, write_package, DeclaredPosture, DevelopmentWitness, LoadedRuntimeConfig, Posture,
SecretResolver,
package::file_destination_available, plan_package, write_package, DeclaredPosture,
DevelopmentWitness, LoadedRuntimeConfig, Posture, SecretResolver,
};
use registry_platform_yaml::{Decoded, Diagnostic, Expect, Reader, Report, Severity, Source};
use serde_json::{json, Value};
Expand All @@ -35,6 +36,7 @@ pub(crate) enum ProjectRefusal {
ProjectInputPathInvalid,
ProjectInputOutside,
PackageInputInvalid,
ReviewPackageDestination,
ContextSchemaTooDeep,
ProviderExportInvalid,
ProviderNamespaceMismatch,
Expand Down Expand Up @@ -70,6 +72,9 @@ impl std::fmt::Display for ProjectRefusal {
Self::PackageInputInvalid => {
formatter.write_str("input must be a regular file of at most one MiB")
}
Self::ReviewPackageDestination => {
formatter.write_str("the provider description destination is occupied or shared")
}
Self::ContextSchemaTooDeep => {
formatter.write_str("context schema type nesting exceeds 16")
}
Expand Down Expand Up @@ -881,7 +886,7 @@ pub(crate) fn project_input_path(project: &Path, relative: &str) -> Result<PathB
}
pub(crate) fn read_package_input(path: &Path) -> Result<Vec<u8>> {
let meta = fs::symlink_metadata(path)?;
if !meta.file_type().is_file() || meta.len() > 1024 * 1024 {
if !meta.file_type().is_file() || meta.len() > package_limits().max_file_bytes {
return Err(ProjectRefusal::PackageInputInvalid.into());
}
Ok(fs::read(path)?)
Expand All @@ -891,23 +896,156 @@ pub(crate) fn package_contents(project: &Path) -> Result<BTreeMap<String, Vec<u8
let policy_file = project.join(registry_casework::POLICY_FILE);
let policy_bytes = read_package_input(&policy_file)?;
let policy = CaseworkProject::read(&policy_file.display().to_string(), &policy_bytes)?.value;
let mut paths = registry_casework::package_inputs(&policy, &policy_bytes)?;
paths.remove(registry_casework::POLICY_FILE);
let inputs = capture_package_inputs(project, &policy, policy_bytes, None)?;
check_package_exports(&policy, &inputs, None)?;
Ok(inputs)
}

fn capture_package_inputs(
project: &Path,
policy: &CaseworkProject,
policy_bytes: Vec<u8>,
pending_description: Option<&str>,
) -> Result<BTreeMap<String, Vec<u8>>> {
let paths = registry_casework::package_inputs(policy, &policy_bytes)?;
let mut inputs = BTreeMap::from([(registry_casework::POLICY_FILE.to_owned(), policy_bytes)]);
for path in paths {
let bytes = read_package_input(&project_input_path(project, &path)?)?;
if path == registry_casework::POLICY_FILE {
continue;
}
// Reserve the destination in the package closure until native pairing supplies it.
let bytes = if pending_description == Some(path.as_str()) {
Vec::new()
} else {
read_package_input(&project_input_path(project, &path)?)?
};
inputs.insert(path, bytes);
}
Ok(inputs)
}

fn check_package_exports(
policy: &CaseworkProject,
inputs: &BTreeMap<String, Vec<u8>>,
pending_description: Option<&str>,
) -> Result<()> {
for provider in &policy.context_providers {
if let Some(description) = &provider.description {
if pending_description == Some(description.as_str()) {
continue;
}
let bytes = inputs
.get(description)
.ok_or(ProjectRefusal::PackageInputInvalid)?;
let export = decode_context_export(description, bytes)?;
check_provider_export(&policy, provider, &export)?;
check_provider_export(policy, provider, &export)?;
}
}
Ok(inputs)
Ok(())
}

/// Plan the Casework side of a review package before native pairing. A pinned
/// display schema gives the exact export size. Pairing itself still imports
/// from the verified producer package.
pub(super) fn check_review_package(project: &Path, id: &str) -> Result<Value> {
let refused = || -> anyhow::Error {
Report::new(vec![Diagnostic::error(
"caseworkctl.refused",
"runtime",
"The prospective Casework package inputs cannot be packaged.",
"Correct the Casework package inputs and resolve authoring warnings, then retry.",
)])
.into()
};
let report = check(project, false, true).map_err(|error| {
// A warnings-only package refusal still needs an error diagnostic
// for the runner to recognize the owner report as a domain refusal.
if crate::configuration_report(&error).is_some_and(|report| !report.has_errors()) {
refused()
} else {
error
}
})?;
let policy_file = project.join(registry_casework::POLICY_FILE);
let original = read_package_input(&policy_file)?;
let name = policy_file.display().to_string();
let decoded = CaseworkProject::read(&name, &original)?;
let provider = decoded
.value
.context_providers
.iter()
.find(|provider| provider.id == id)
.ok_or(crate::provider_pair::PairingFailure::ProviderNotDeclared)?;
let relative = crate::provider_pair::pairing_description(provider)?;
let destination = Path::new(&relative);
// The projected export is its own package input. A display schema at
// this destination would be overwritten by the producer export envelope.
if CaseworkProject::schema_references(&name, &original)?
.iter()
.any(|path| Path::new(path) == destination)
{
return Err(ProjectRefusal::ReviewPackageDestination.into());
}
let document = decoded.document.to_json_value();
let declared = provider.description.is_some();
let namespace = provider.source_namespace.clone();
let (policy, bytes) = if declared {
(decoded.value, original)
} else {
let bytes = crate::provider_pair::policy_with_description(
document.clone(),
&original,
id,
&relative,
)?;
let projected = CaseworkProject::read(&name, &bytes)?;
let warnings = projected.document.warnings();
if registry_platform_config::has_denied_warnings(warnings.diagnostics()) {
return Err(refused());
}
(projected.value, bytes)
};
let pinned = policy
.review_policies
.iter()
.find_map(|review| match &review.context {
ReviewContextPolicy::CurrentSource { provider, contract } if provider == id => {
Some((review, contract))
}
_ => None,
});
let replacement = (!declared || pinned.is_some()).then_some(relative.as_str());
let mut inputs = capture_package_inputs(project, &policy, bytes, replacement)?;
if let Some((review, contract)) = pinned {
let action = review.display_schema["x-registry-review-context"]["actionId"]
.as_str()
.ok_or_else(refused)?;
let authored_schema = &document["reviewPolicies"][&review.id]["displaySchema"];
let schema_bytes = if let Some(reference) = authored_schema["$ref"].as_str() {
inputs.get(reference).ok_or_else(refused)?.clone()
} else {
canonicalize_json(authored_schema).map_err(|_| refused())?
};
let export = crate::provider_pair::context_export(
schema_bytes,
contract.clone(),
&namespace,
action,
)
.map_err(|_| refused())?;
inputs.insert(
relative.clone(),
crate::provider_pair::encode_export(&export)?,
);
}
plan_package(project, &inputs, None, &package_limits(), PACKAGE_COMMAND)
.map_err(|_| refused())?;
let pending = (!declared && pinned.is_none()).then_some(relative.as_str());
check_package_exports(&policy, &inputs, pending)?;
if !file_destination_available(project, destination, declared) {
return Err(ProjectRefusal::ReviewPackageDestination.into());
}
Ok(report)
}
pub(super) fn package(project: &Path, output: &Path, revision: Option<&str>) -> Result<Value> {
let inputs = package_contents(project)?;
Expand Down
Loading
Loading