Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions .ripr/traceability.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8240,6 +8240,9 @@ id = "RIPR-SPEC-0147"
name = "typed analysis outcome projection"
spec = "docs/specs/RIPR-SPEC-0147-analysis-outcome-projection.md"
tests = [
"crates/ripr/tests/cli_smoke/unsupported_diff_exit.rs::diff_json_outcomes_preserve_report_and_exit_contract",
"crates/ripr/tests/cli_smoke/unsupported_diff_exit.rs::diff_human_unsupported_and_usage_keep_stream_contracts",
"crates/ripr/tests/cli_smoke/unsupported_diff_exit.rs::diff_discovery_names_unsupported_and_partial_exits",
"crates/ripr/tests/cli_smoke/unsupported_check_exit.rs::check_json_outcome_exit_preserves_subject_and_coverage",
"crates/ripr/tests/cli_smoke/unsupported_check_exit.rs::unsupported_check_keeps_rendered_formats_and_repo_scope",
"crates/ripr/tests/cli_smoke/unsupported_check_exit.rs::check_json_malformed_options_remain_empty_exit_two",
Expand Down Expand Up @@ -8302,7 +8305,9 @@ tests = [
"crates/ripr/src/output/agent_seam_packets.rs::tests::diff_packet_marks_missing_producer_outcome_incomplete",
]
code = [
"crates/ripr/src/cli/commands.rs",
"crates/ripr/src/cli/commands/check.rs",
"crates/ripr/src/cli/commands_context.rs",
"crates/ripr/src/analysis_outcome.rs",
"crates/ripr/src/analysis/diff/parse.rs",
"crates/ripr/src/analysis/pipeline.rs",
Expand Down
4 changes: 4 additions & 0 deletions changelog.d/7793-diff-unsupported-exit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<!-- section: Fixed -->
- `ripr diff` now exits 2 for typed `unsupported_input` after emitting its
original report once, matching `ripr check`. Complete and usable partial
reports remain advisory exit 0; JSON discovery names the mapping (#7793).
9 changes: 5 additions & 4 deletions crates/ripr/src/cli/command_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ pub(crate) struct CommandOutputs {
pub(crate) enum CommandExitContract {
/// Standard contract: `0` completed, `2` could not complete. Never `3`.
CompletedOrFailed,
/// `ripr check`: findings, including `exposed`, still complete with `0`.
/// `ripr check` / `ripr diff`: findings still complete with `0`;
/// unsupported input keeps its report and exits `2`.
AdvisoryFindings,
/// `ripr gate evaluate`: `config_error` is `2`, `blocked` is `3`.
GateEvaluate,
Expand Down Expand Up @@ -200,7 +201,7 @@ const EXIT_RECEIPT_CHECK: CommandExitContract = CommandExitContract::ReceiptChec
/// whose `exit` field disagrees is a catalog integrity failure (#5066).
fn required_exit_contract(id: &str) -> Option<CommandExitContract> {
match id {
"cmd:check" => Some(EXIT_ADVISORY_FINDINGS),
"cmd:check" | "cmd:diff" => Some(EXIT_ADVISORY_FINDINGS),
"cmd:gate.evaluate" => Some(EXIT_GATE_EVALUATE),
"cmd:agent.verify" | "cmd:agent.card" | "cmd:agent.stub" => {
Some(EXIT_TYPED_REFUSAL_EMPTY_STDOUT)
Expand Down Expand Up @@ -2047,8 +2048,8 @@ const METADATA: &[CommandMetadata] = &[
example: "ripr diff --root . --base REV --head HEAD --json",
next_routes: &["check", "explain"],
stop_states: &["explicit refusal on unresolvable revisions"],
exit: EXIT_COMPLETED_OR_FAILED,
limitations: "delivers JSON on stdout; redirect to a file when a report artifact is needed.",
exit: EXIT_ADVISORY_FINDINGS,
limitations: "delivers JSON on stdout; redirect to a file when a report artifact is needed. Findings and partial_with_limitations stay advisory (exit 0); unsupported_input keeps its report and exits 2.",
not_applicable_reason: None,
},
CommandMetadata {
Expand Down
7 changes: 6 additions & 1 deletion crates/ripr/src/cli/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2913,7 +2913,12 @@ pub(super) fn diff(args: &[String]) -> Result<(), String> {
print!("{}", output::diff_report::render_diff_report_json(&report)?)
}
}
Ok(())
// Preserve the already-rendered report, including supported subjects in
// an unsupported input. A second refusal would corrupt JSON stdout.
crate::cli::commands_context::analysis_outcome_exit_result(
"diff",
output.analysis_outcome.as_ref(),
)
}

fn parse_diff_options(args: &[String]) -> Result<DiffOptions, String> {
Expand Down
13 changes: 3 additions & 10 deletions crates/ripr/src/cli/commands/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use crate::analysis;
use crate::app::{self, CheckInput, OutputFormat};
use crate::cli::commands_context::{
config_load_refusal, ensure_command_root, write_stdout_chunked,
analysis_outcome_exit_result, config_load_refusal, ensure_command_root, write_stdout_chunked,
};
use crate::cli::help;
use crate::cli::parse::{
Expand Down Expand Up @@ -1295,15 +1295,8 @@ pub(in crate::cli) fn check(args: &[String]) -> Result<(), String> {
// report, including retained findings and coverage identity; appending a
// refusal here would corrupt machine output. Genuine partial reports
// remain advisory, so completeness or zero findings cannot own this exit.
if !format.is_repo_scope()
&& output.analysis_outcome.as_ref().is_some_and(|outcome| {
outcome.kind == crate::analysis_outcome::AnalysisOutcomeKind::UnsupportedInput
})
{
return Err(
"check: analysis could not complete (unsupported_input); see the emitted report's limitations and recovery routes"
.to_string(),
);
if !format.is_repo_scope() {
analysis_outcome_exit_result("check", output.analysis_outcome.as_ref())?;
}
if let Some(sink) = &progress {
sink.commit_success();
Expand Down
17 changes: 17 additions & 0 deletions crates/ripr/src/cli/commands_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,23 @@ use crate::app::CheckInput;
use crate::config::{CheckInputExplicit, RiprConfig, apply_to_check_input, load_for_root};
use std::path::Path;

/// Map a producer outcome after its original report has reached stdout.
/// Only the typed unsupported-input result fails; usable partial evidence
/// stays advisory. The caller must not append a refusal to the report.
pub(super) fn analysis_outcome_exit_result(
command_name: &str,
outcome: Option<&crate::analysis_outcome::AnalysisOutcome>,
) -> Result<(), String> {
if outcome.is_some_and(|outcome| {
outcome.kind == crate::analysis_outcome::AnalysisOutcomeKind::UnsupportedInput
}) {
return Err(format!(
"{command_name}: analysis could not complete (unsupported_input); see the emitted report's limitations and recovery routes"
));
}
Ok(())
}

pub(super) fn ensure_command_root(root: &Path, command_name: &str) -> Result<(), String> {
// Detected once: every branch below keys on the same typed components.
let stripped = windows_stripped_components(root);
Expand Down
9 changes: 8 additions & 1 deletion crates/ripr/src/cli/help/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,9 +354,16 @@ Options:
--no-unchanged-tests Limit the index to changed Rust files.

The diff report emits changed files, changed seams, static evidence for those
seams, a diff-complete runtime status, an explicit full-repo-limited context
seams, the typed diff runtime status, an explicit full-repo-limited context
status, and a receipt path hint. It does not run mutation testing, edit files,
or turn the full-repo limitation into a success state.

Exit status:
Complete and partial_with_limitations reports exit 0, regardless of findings.
`unsupported_input` reports exit 2 after the original report is written;
limitations and recovery routes remain available in that report. Usage and
operational errors also exit 2. An empty diff is complete no_scope (exit 0).
Diagnostic prose stays on stderr; JSON stdout contains one report.
"#;
pub(super) const EXPLAIN_HELP: &str = r#"Print why ripr flagged a specific change.

Expand Down
3 changes: 3 additions & 0 deletions crates/ripr/tests/cli_smoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ mod unknown_explain;
#[cfg(feature = "lang-rust")]
#[path = "cli_smoke/unsupported_check_exit.rs"]
mod unsupported_check_exit;
#[cfg(feature = "lang-rust")]
#[path = "cli_smoke/unsupported_diff_exit.rs"]
mod unsupported_diff_exit;
#[cfg(unix)]
#[path = "cli_smoke/workflow_directory.rs"]
mod workflow_directory;
Expand Down
Loading
Loading