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
6 changes: 5 additions & 1 deletion .ripr/traceability.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12867,6 +12867,10 @@ id = "RIPR-SPEC-0202"
name = "agent card typed refusal envelope"
spec = "docs/specs/RIPR-SPEC-0202-agent-card-typed-refusals.md"
tests = [
"crates/ripr/tests/cli_smoke/agent_policy_guidance.rs::policy_omitted_card_prose_agrees_with_typed_remedy",
"crates/ripr/tests/cli_smoke/agent_policy_guidance.rs::policy_omitted_packet_preserves_refusal_channels",
"crates/ripr/tests/cli_smoke/agent_policy_guidance.rs::policy_omitted_repair_before_preserves_refusal_channels",
"crates/ripr/tests/cli_smoke/agent_policy_guidance.rs::genuinely_unknown_seam_keeps_pilot_guidance_under_omitting_policy",
"crates/ripr/tests/cli_smoke.rs::agent_card_hands_off_one_seam_as_the_default_repair_card",
"crates/ripr/src/cli/commands/agent_card.rs::tests::refusal_envelope_names_kind_seam_message_and_remedy",
"crates/ripr/src/cli/commands/agent_card.rs::tests::opposite_remedy_pairs_stay_distinguishable",
Expand Down Expand Up @@ -15081,4 +15085,4 @@ outputs = [
"docs/OUTPUT_SCHEMA.md",
"schemas/ripr/check.schema.json",
]
metrics = ["unit_test_pass_rate"]
metrics = ["unit_test_pass_rate"]
2 changes: 2 additions & 0 deletions changelog.d/7736-policy-omitted-recovery.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<!-- section: Fixed -->
- Policy-omitted `agent card`, `agent packet`, and `agent repair --phase before` refusals now name `agent brief` to inspect policy instead of recommending a seam re-list. The card's prose and typed remedy share the same command; unknown seam IDs keep pilot/list guidance (#7736).
23 changes: 20 additions & 3 deletions crates/ripr/src/cli/commands/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,25 @@ pub(super) fn unknown_seam_id_hint(root: &Path, seam_id: &str) -> String {
}
}

/// Policy omission needs inspection of the policy, not a new seam listing.
/// Shared with the card's typed remedy so prose and machine guidance agree.
pub(super) fn policy_omitted_seam_remedy_route(root: &Path, seam_id: &str) -> String {
let root = crate::agent::loop_commands::shell_arg(&crate::agent::loop_commands::bound_root(
&root.to_string_lossy(),
));
format!(
"ripr agent brief --root {root} --seam-id {} --json",
crate::agent::loop_commands::shell_arg(seam_id)
)
}

pub(super) fn policy_omitted_seam_hint(root: &Path, seam_id: &str) -> String {
let remedy = policy_omitted_seam_remedy_route(root, seam_id);
format!(
"Inspect the agent policy with `{remedy}`; re-listing cannot change this policy decision."
)
}

fn render_agent_packet(options: &AgentPacketOptions) -> Result<String, CoreError> {
let root = crate::agent::loop_commands::bound_root(&options.root.to_string_lossy());
render_agent_packet_with_context(
Expand Down Expand Up @@ -449,11 +468,9 @@ fn render_agent_packet_for_seam_with_report(

let policy = AgentBriefPolicy::from_config(config);
if let Some(reason) = policy.omission_reason_for_class(entry.class) {
// #4332: a policy-omitted seam is a dead end without the listing
// route; name it like the not-found refusals do.
return Err(CoreError::from(format!(
"agent packet seam_id {seam_id} {reason}. {}",
unknown_seam_id_hint(root, seam_id)
policy_omitted_seam_hint(root, seam_id)
)));
}

Expand Down
19 changes: 7 additions & 12 deletions crates/ripr/src/cli/commands/agent_card.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ use crate::config::load_for_root;
use crate::domain::{AgentCardRefusalKind, RepairCardTarget, RepairCardV1};
use crate::output;

use super::agent::unknown_seam_id_hint;
use super::agent::{
policy_omitted_seam_hint, policy_omitted_seam_remedy_route, unknown_seam_id_hint,
};

/// Schema version of the `ripr agent card` typed-refusal document
/// (`kind: "agent_card_refusal"`). Deliberately distinct from the success
Expand Down Expand Up @@ -133,12 +135,7 @@ fn refusal_remedy_route(
AgentCardRefusalKind::SeamNotFound => {
format!("ripr pilot --root {root}")
}
AgentCardRefusalKind::PolicyOmitted => {
format!(
"ripr agent brief --root {root} --seam-id {} --json",
crate::agent::loop_commands::shell_arg(seam_id)
)
}
AgentCardRefusalKind::PolicyOmitted => policy_omitted_seam_remedy_route(root_path, seam_id),
AgentCardRefusalKind::WitnessUnavailable => {
format!("ripr check --root {root} --json")
}
Expand Down Expand Up @@ -180,16 +177,14 @@ fn render_agent_card(options: &AgentCardOptions) -> Result<RepairCardV1, AgentCa

let policy = AgentBriefPolicy::from_config(&config);
if let Some(reason) = policy.omission_reason_for_class(entry.class) {
// Mirror `agent packet` (#4332): a policy-omitted seam is a dead end
// without the listing route; name it like the not-found refusals do.
// #5007: the policy decision is a typed refusal, never a transient
// error — re-listing seams cannot fix it.
// #5007 / #7736: a policy decision has its own recovery guidance;
// re-listing seams cannot fix it.
return Err(AgentCardError::refusal(
AgentCardRefusalKind::PolicyOmitted,
format!(
"agent card seam_id {} {reason}. {}",
options.seam_id,
unknown_seam_id_hint(&options.root, &options.seam_id)
policy_omitted_seam_hint(&options.root, &options.seam_id)
),
));
}
Expand Down
10 changes: 6 additions & 4 deletions crates/ripr/tests/cli_smoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ use std::sync::atomic::{AtomicU64, Ordering};

#[path = "common/advisory_write_safety.rs"]
mod advisory_write_safety;
#[cfg(feature = "lang-rust")]
#[path = "cli_smoke/agent_policy_guidance.rs"]
mod agent_policy_guidance;
#[path = "../src/build_commit_record.rs"]
mod build_commit_record;
#[cfg(any(feature = "lang-python", feature = "lang-typescript"))]
Expand Down Expand Up @@ -9055,11 +9058,10 @@ fn agent_packet_rejects_configured_off_seam() -> Result<(), Box<dyn std::error::
.join("fixtures/boundary_gap/expected/llm-work-loop/configured-off/stderr.txt"),
)?;
assert!(stderr.contains(expected.trim()));
// #4332: the policy-omitted refusal names the listing route instead of
// dead-ending.
// #7736: policy omission names policy inspection rather than re-listing.
assert!(
stderr.contains("Run `ripr pilot"),
"the policy-omitted refusal must name the listing command:\n{stderr}"
stderr.contains("Inspect the agent policy with `ripr agent brief"),
"the policy-omitted refusal must name policy inspection:\n{stderr}"
);
std::fs::remove_dir_all(root)?;
Ok(())
Expand Down
Loading
Loading